/* pkcs11-private-key.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from pkcs11-private-key.vala, do not modify */

/*
 * Seahorse
 *
 * Copyright (C) 2008 Stefan Walter
 * Copyright (C) 2011 Collabora Ltd.
 * Copyright (C) 2013 Red Hat Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#include "seahorse-pkcs11.h"
#include <glib-object.h>
#include <gck/gck.h>
#include <gio/gio.h>
#include <glib.h>
#include "seahorse-common.h"
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <p11-kit/pkcs11.h>
#include <gcr/gcr-base.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	SEAHORSE_PKCS11_PRIVATE_KEY_0_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_PLACE_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_OBJECT_FLAGS_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_ACTIONS_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_PARTNER_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_LABEL_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_MARKUP_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_DESCRIPTION_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_ICON_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_ATTRIBUTES_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_DELETABLE_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_EXPORTABLE_PROPERTY,
	SEAHORSE_PKCS11_PRIVATE_KEY_NUM_PROPERTIES
};
static GParamSpec* seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_NUM_PROPERTIES];
#define _gck_attributes_unref0(var) ((var == NULL) ? NULL : (var = (gck_attributes_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __vala_GckBuilder_free0(var) ((var == NULL) ? NULL : (var = (_vala_GckBuilder_free (var), NULL)))

#define SEAHORSE_PKCS11_TYPE_KEY_DELETER (seahorse_pkcs11_key_deleter_get_type ())
#define SEAHORSE_PKCS11_KEY_DELETER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_PKCS11_TYPE_KEY_DELETER, SeahorsePkcs11KeyDeleter))
#define SEAHORSE_PKCS11_KEY_DELETER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_PKCS11_TYPE_KEY_DELETER, SeahorsePkcs11KeyDeleterClass))
#define SEAHORSE_PKCS11_IS_KEY_DELETER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_PKCS11_TYPE_KEY_DELETER))
#define SEAHORSE_PKCS11_IS_KEY_DELETER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_PKCS11_TYPE_KEY_DELETER))
#define SEAHORSE_PKCS11_KEY_DELETER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_PKCS11_TYPE_KEY_DELETER, SeahorsePkcs11KeyDeleterClass))

typedef struct _SeahorsePkcs11KeyDeleter SeahorsePkcs11KeyDeleter;
typedef struct _SeahorsePkcs11KeyDeleterClass SeahorsePkcs11KeyDeleterClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _SeahorsePkcs11PrivateKeyPrivate {
	GWeakRef _token;
	GckAttributes* _attributes;
	GWeakRef _certificate;
	GIcon* _icon;
};

static gint SeahorsePkcs11PrivateKey_private_offset;
static gpointer seahorse_pkcs11_private_key_parent_class = NULL;
static GckObjectCacheIface * seahorse_pkcs11_private_key_gck_object_cache_parent_iface = NULL;
static SeahorseDeletableIface * seahorse_pkcs11_private_key_seahorse_deletable_parent_iface = NULL;
static SeahorseExportableIface * seahorse_pkcs11_private_key_seahorse_exportable_parent_iface = NULL;
static SeahorseViewableIface * seahorse_pkcs11_private_key_seahorse_viewable_parent_iface = NULL;

static void seahorse_pkcs11_private_key_real_fill (GckObjectCache* base,
                                            GckAttributes* attributes);
static void _vala_GckBuilder_free (GckBuilder* self);
static SeahorseDeleter* seahorse_pkcs11_private_key_real_create_deleter (SeahorseDeletable* base);
VALA_EXTERN SeahorsePkcs11KeyDeleter* seahorse_pkcs11_key_deleter_new (GckObject* cert_or_key);
VALA_EXTERN SeahorsePkcs11KeyDeleter* seahorse_pkcs11_key_deleter_construct (GType object_type,
                                                                 GckObject* cert_or_key);
VALA_EXTERN GType seahorse_pkcs11_key_deleter_get_type (void) G_GNUC_CONST ;
static GList* seahorse_pkcs11_private_key_real_create_exporters (SeahorseExportable* base,
                                                          SeahorseExporterType type);
static GtkWindow* seahorse_pkcs11_private_key_real_create_viewer (SeahorseViewable* base,
                                                           GtkWindow* parent);
static void seahorse_pkcs11_private_key_finalize (GObject * obj);
static GType seahorse_pkcs11_private_key_get_type_once (void);
static void _vala_seahorse_pkcs11_private_key_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_seahorse_pkcs11_private_key_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
seahorse_pkcs11_private_key_get_instance_private (SeahorsePkcs11PrivateKey* self)
{
	return G_STRUCT_MEMBER_P (self, SeahorsePkcs11PrivateKey_private_offset);
}

static void
_vala_GckBuilder_free (GckBuilder* self)
{
	g_boxed_free (gck_builder_get_type (), self);
}

static void
seahorse_pkcs11_private_key_real_fill (GckObjectCache* base,
                                       GckAttributes* attributes)
{
	SeahorsePkcs11PrivateKey * self;
	GckBuilder* builder = NULL;
	GckBuilder* _tmp0_;
	GckAttributes* _tmp1_;
	GckBuilder* _tmp4_;
	GckBuilder* _tmp5_;
	GckAttributes* _tmp6_;
	self = (SeahorsePkcs11PrivateKey*) base;
	g_return_if_fail (attributes != NULL);
	_tmp0_ = gck_builder_new (GCK_BUILDER_NONE);
	builder = _tmp0_;
	_tmp1_ = self->priv->_attributes;
	if (_tmp1_ != NULL) {
		GckBuilder* _tmp2_;
		GckAttributes* _tmp3_;
		_tmp2_ = builder;
		_tmp3_ = self->priv->_attributes;
		gck_builder_add_all (_tmp2_, _tmp3_);
	}
	_tmp4_ = builder;
	gck_builder_set_all (_tmp4_, attributes);
	_tmp5_ = builder;
	_tmp6_ = gck_builder_steal (_tmp5_);
	_gck_attributes_unref0 (self->priv->_attributes);
	self->priv->_attributes = _tmp6_;
	g_object_notify ((GObject*) self, "attributes");
	__vala_GckBuilder_free0 (builder);
}

static SeahorseDeleter*
seahorse_pkcs11_private_key_real_create_deleter (SeahorseDeletable* base)
{
	SeahorsePkcs11PrivateKey * self;
	SeahorsePkcs11KeyDeleter* _tmp0_;
	SeahorseDeleter* result;
	self = (SeahorsePkcs11PrivateKey*) base;
	_tmp0_ = seahorse_pkcs11_key_deleter_new ((GckObject*) self);
	result = (SeahorseDeleter*) _tmp0_;
	return result;
}

static GList*
seahorse_pkcs11_private_key_real_create_exporters (SeahorseExportable* base,
                                                   SeahorseExporterType type)
{
	SeahorsePkcs11PrivateKey * self;
	GList* exporters = NULL;
	GList* result;
	self = (SeahorsePkcs11PrivateKey*) base;
	exporters = NULL;
	result = exporters;
	return result;
}

static GtkWindow*
seahorse_pkcs11_private_key_real_create_viewer (SeahorseViewable* base,
                                                GtkWindow* parent)
{
	SeahorsePkcs11PrivateKey * self;
	SeahorsePkcs11Properties* viewer = NULL;
	SeahorsePkcs11Properties* _tmp0_;
	GtkWindow* result;
	self = (SeahorsePkcs11PrivateKey*) base;
	_tmp0_ = seahorse_pkcs11_properties_new ((GckObject*) self, parent);
	g_object_ref_sink (_tmp0_);
	viewer = _tmp0_;
	gtk_widget_show ((GtkWidget*) viewer);
	result = (GtkWindow*) viewer;
	return result;
}

SeahorsePkcs11PrivateKey*
seahorse_pkcs11_private_key_construct (GType object_type)
{
	SeahorsePkcs11PrivateKey * self = NULL;
	self = (SeahorsePkcs11PrivateKey*) g_object_new (object_type, NULL);
	return self;
}

SeahorsePkcs11PrivateKey*
seahorse_pkcs11_private_key_new (void)
{
	return seahorse_pkcs11_private_key_construct (SEAHORSE_PKCS11_TYPE_PRIVATE_KEY);
}

SeahorsePkcs11Token*
seahorse_pkcs11_private_key_get_place (SeahorsePkcs11PrivateKey* self)
{
	SeahorsePkcs11Token* result;
	GObject* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_weak_ref_get (&self->priv->_token);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, SEAHORSE_PKCS11_TYPE_TOKEN, SeahorsePkcs11Token);
	return result;
}

void
seahorse_pkcs11_private_key_set_place (SeahorsePkcs11PrivateKey* self,
                                       SeahorsePkcs11Token* value)
{
	g_return_if_fail (self != NULL);
	g_weak_ref_set (&self->priv->_token, (GObject*) value);
	g_object_notify_by_pspec ((GObject *) self, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_PLACE_PROPERTY]);
}

SeahorseFlags
seahorse_pkcs11_private_key_get_object_flags (SeahorsePkcs11PrivateKey* self)
{
	SeahorseFlags result;
	g_return_val_if_fail (self != NULL, 0U);
	result = SEAHORSE_FLAG_PERSONAL;
	return result;
}

GtkActionGroup*
seahorse_pkcs11_private_key_get_actions (SeahorsePkcs11PrivateKey* self)
{
	GtkActionGroup* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = NULL;
	return result;
}

SeahorsePkcs11Certificate*
seahorse_pkcs11_private_key_get_partner (SeahorsePkcs11PrivateKey* self)
{
	SeahorsePkcs11Certificate* result;
	GObject* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_weak_ref_get (&self->priv->_certificate);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, SEAHORSE_PKCS11_TYPE_CERTIFICATE, SeahorsePkcs11Certificate);
	return result;
}

void
seahorse_pkcs11_private_key_set_partner (SeahorsePkcs11PrivateKey* self,
                                         SeahorsePkcs11Certificate* value)
{
	g_return_if_fail (self != NULL);
	g_weak_ref_set (&self->priv->_certificate, (GObject*) value);
	g_object_notify ((GObject*) self, "partner");
	g_object_notify ((GObject*) self, "description");
	g_object_notify_by_pspec ((GObject *) self, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_PARTNER_PROPERTY]);
}

gchar*
seahorse_pkcs11_private_key_get_label (SeahorsePkcs11PrivateKey* self)
{
	gchar* result;
	GckAttributes* _tmp0_;
	SeahorsePkcs11Certificate* cert = NULL;
	SeahorsePkcs11Certificate* _tmp4_;
	SeahorsePkcs11Certificate* _tmp5_;
	SeahorsePkcs11Certificate* _tmp6_;
	gchar* _tmp10_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_attributes;
	if (_tmp0_ != NULL) {
		gchar* label = NULL;
		GckAttributes* _tmp1_;
		gchar* _tmp2_ = NULL;
		gboolean _tmp3_;
		_tmp1_ = self->priv->_attributes;
		_tmp3_ = gck_attributes_find_string (_tmp1_, CKA_LABEL, &_tmp2_);
		_g_free0 (label);
		label = _tmp2_;
		if (_tmp3_) {
			result = label;
			return result;
		}
		_g_free0 (label);
	}
	_tmp4_ = seahorse_pkcs11_private_key_get_partner (self);
	_tmp5_ = _tmp4_;
	cert = _tmp5_;
	_tmp6_ = cert;
	if (_tmp6_ != NULL) {
		SeahorsePkcs11Certificate* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp7_ = cert;
		g_object_get ((GcrCertificate*) _tmp7_, "label", &_tmp8_, NULL);
		_tmp9_ = _tmp8_;
		result = _tmp9_;
		_g_object_unref0 (cert);
		return result;
	}
	_tmp10_ = g_strdup (_ ("Unnamed private key"));
	result = _tmp10_;
	_g_object_unref0 (cert);
	return result;
}

gchar*
seahorse_pkcs11_private_key_get_markup (SeahorsePkcs11PrivateKey* self)
{
	gchar* result;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = seahorse_pkcs11_private_key_get_label (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = g_markup_escape_text (_tmp2_, (gssize) -1);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	result = _tmp4_;
	return result;
}

const gchar*
seahorse_pkcs11_private_key_get_description (SeahorsePkcs11PrivateKey* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = _ ("Private key");
	return result;
}

GIcon*
seahorse_pkcs11_private_key_get_icon (SeahorsePkcs11PrivateKey* self)
{
	GIcon* result;
	GIcon* _tmp0_;
	GIcon* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_icon;
	if (_tmp0_ == NULL) {
		GThemedIcon* _tmp1_;
		_tmp1_ = (GThemedIcon*) g_themed_icon_new (GCR_ICON_KEY);
		_g_object_unref0 (self->priv->_icon);
		self->priv->_icon = (GIcon*) _tmp1_;
	}
	_tmp2_ = self->priv->_icon;
	result = _tmp2_;
	return result;
}

static gpointer
_gck_attributes_ref0 (gpointer self)
{
	return self ? gck_attributes_ref (self) : NULL;
}

static GckAttributes*
seahorse_pkcs11_private_key_real_get_attributes (GckObjectCache* base)
{
	GckAttributes* result;
	SeahorsePkcs11PrivateKey* self;
	GckAttributes* _tmp0_;
	GckAttributes* _tmp1_;
	self = (SeahorsePkcs11PrivateKey*) base;
	_tmp0_ = self->priv->_attributes;
	_tmp1_ = _gck_attributes_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
seahorse_pkcs11_private_key_real_set_attributes (GckObjectCache* base,
                                                 GckAttributes* value)
{
	SeahorsePkcs11PrivateKey* self;
	GckAttributes* _tmp0_;
	self = (SeahorsePkcs11PrivateKey*) base;
	_tmp0_ = _gck_attributes_ref0 (value);
	_gck_attributes_unref0 (self->priv->_attributes);
	self->priv->_attributes = _tmp0_;
	g_object_notify ((GObject*) self, "attributes");
	g_object_notify_by_pspec ((GObject *) self, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_ATTRIBUTES_PROPERTY]);
}

static gboolean
seahorse_pkcs11_private_key_real_get_deletable (SeahorseDeletable* base)
{
	gboolean result;
	SeahorsePkcs11PrivateKey* self;
	SeahorsePkcs11Token* token = NULL;
	SeahorsePkcs11Token* _tmp0_;
	SeahorsePkcs11Token* _tmp1_;
	gboolean _tmp2_ = FALSE;
	SeahorsePkcs11Token* _tmp3_;
	self = (SeahorsePkcs11PrivateKey*) base;
	_tmp0_ = seahorse_pkcs11_private_key_get_place (self);
	_tmp1_ = _tmp0_;
	token = _tmp1_;
	_tmp3_ = token;
	if (_tmp3_ == NULL) {
		_tmp2_ = FALSE;
	} else {
		SeahorsePkcs11Token* _tmp4_;
		_tmp4_ = token;
		_tmp2_ = seahorse_pkcs11_token_is_deletable (_tmp4_, (GckObject*) self);
	}
	result = _tmp2_;
	_g_object_unref0 (token);
	return result;
}

static gboolean
seahorse_pkcs11_private_key_real_get_exportable (SeahorseExportable* base)
{
	gboolean result;
	SeahorsePkcs11PrivateKey* self;
	self = (SeahorsePkcs11PrivateKey*) base;
	result = FALSE;
	return result;
}

static void
seahorse_pkcs11_private_key_class_init (SeahorsePkcs11PrivateKeyClass * klass,
                                        gpointer klass_data)
{
	seahorse_pkcs11_private_key_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SeahorsePkcs11PrivateKey_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_seahorse_pkcs11_private_key_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_seahorse_pkcs11_private_key_set_property;
	G_OBJECT_CLASS (klass)->finalize = seahorse_pkcs11_private_key_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_PLACE_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_PLACE_PROPERTY] = g_param_spec_object ("place", "place", "place", SEAHORSE_PKCS11_TYPE_TOKEN, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_OBJECT_FLAGS_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_OBJECT_FLAGS_PROPERTY] = g_param_spec_flags ("object-flags", "object-flags", "object-flags", SEAHORSE_TYPE_FLAGS, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_ACTIONS_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_ACTIONS_PROPERTY] = g_param_spec_object ("actions", "actions", "actions", gtk_action_group_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_PARTNER_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_PARTNER_PROPERTY] = g_param_spec_object ("partner", "partner", "partner", SEAHORSE_PKCS11_TYPE_CERTIFICATE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_LABEL_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_LABEL_PROPERTY] = g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_MARKUP_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_MARKUP_PROPERTY] = g_param_spec_string ("markup", "markup", "markup", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_DESCRIPTION_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_DESCRIPTION_PROPERTY] = g_param_spec_string ("description", "description", "description", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_ICON_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_ICON_PROPERTY] = g_param_spec_object ("icon", "icon", "icon", g_icon_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_ATTRIBUTES_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_ATTRIBUTES_PROPERTY] = g_param_spec_boxed ("attributes", "attributes", "attributes", gck_attributes_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_DELETABLE_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_DELETABLE_PROPERTY] = g_param_spec_boolean ("deletable", "deletable", "deletable", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAHORSE_PKCS11_PRIVATE_KEY_EXPORTABLE_PROPERTY, seahorse_pkcs11_private_key_properties[SEAHORSE_PKCS11_PRIVATE_KEY_EXPORTABLE_PROPERTY] = g_param_spec_boolean ("exportable", "exportable", "exportable", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
seahorse_pkcs11_private_key_gck_object_cache_interface_init (GckObjectCacheIface * iface,
                                                             gpointer iface_data)
{
	seahorse_pkcs11_private_key_gck_object_cache_parent_iface = g_type_interface_peek_parent (iface);
	iface->fill = (void (*) (GckObjectCache*, GckAttributes*)) seahorse_pkcs11_private_key_real_fill;
}

static void
seahorse_pkcs11_private_key_seahorse_deletable_interface_init (SeahorseDeletableIface * iface,
                                                               gpointer iface_data)
{
	seahorse_pkcs11_private_key_seahorse_deletable_parent_iface = g_type_interface_peek_parent (iface);
	iface->create_deleter = (SeahorseDeleter* (*) (SeahorseDeletable*)) seahorse_pkcs11_private_key_real_create_deleter;
	iface->get_deletable = seahorse_pkcs11_private_key_real_get_deletable;
}

static void
seahorse_pkcs11_private_key_seahorse_exportable_interface_init (SeahorseExportableIface * iface,
                                                                gpointer iface_data)
{
	seahorse_pkcs11_private_key_seahorse_exportable_parent_iface = g_type_interface_peek_parent (iface);
	iface->create_exporters = (GList* (*) (SeahorseExportable*, SeahorseExporterType)) seahorse_pkcs11_private_key_real_create_exporters;
	iface->get_exportable = seahorse_pkcs11_private_key_real_get_exportable;
}

static void
seahorse_pkcs11_private_key_seahorse_viewable_interface_init (SeahorseViewableIface * iface,
                                                              gpointer iface_data)
{
	seahorse_pkcs11_private_key_seahorse_viewable_parent_iface = g_type_interface_peek_parent (iface);
	iface->create_viewer = (GtkWindow* (*) (SeahorseViewable*, GtkWindow*)) seahorse_pkcs11_private_key_real_create_viewer;
}

static void
seahorse_pkcs11_private_key_instance_init (SeahorsePkcs11PrivateKey * self,
                                           gpointer klass)
{
	self->priv = seahorse_pkcs11_private_key_get_instance_private (self);
}

static void
seahorse_pkcs11_private_key_finalize (GObject * obj)
{
	SeahorsePkcs11PrivateKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SEAHORSE_PKCS11_TYPE_PRIVATE_KEY, SeahorsePkcs11PrivateKey);
	g_weak_ref_clear (&self->priv->_token);
	_gck_attributes_unref0 (self->priv->_attributes);
	g_weak_ref_clear (&self->priv->_certificate);
	_g_object_unref0 (self->priv->_icon);
	G_OBJECT_CLASS (seahorse_pkcs11_private_key_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
seahorse_pkcs11_private_key_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SeahorsePkcs11PrivateKeyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_pkcs11_private_key_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorsePkcs11PrivateKey), 0, (GInstanceInitFunc) seahorse_pkcs11_private_key_instance_init, NULL };
	static const GInterfaceInfo gck_object_cache_info = { (GInterfaceInitFunc) seahorse_pkcs11_private_key_gck_object_cache_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo seahorse_deletable_info = { (GInterfaceInitFunc) seahorse_pkcs11_private_key_seahorse_deletable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo seahorse_exportable_info = { (GInterfaceInitFunc) seahorse_pkcs11_private_key_seahorse_exportable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo seahorse_viewable_info = { (GInterfaceInitFunc) seahorse_pkcs11_private_key_seahorse_viewable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType seahorse_pkcs11_private_key_type_id;
	seahorse_pkcs11_private_key_type_id = g_type_register_static (gck_object_get_type (), "SeahorsePkcs11PrivateKey", &g_define_type_info, 0);
	g_type_add_interface_static (seahorse_pkcs11_private_key_type_id, gck_object_cache_get_type (), &gck_object_cache_info);
	g_type_add_interface_static (seahorse_pkcs11_private_key_type_id, SEAHORSE_TYPE_DELETABLE, &seahorse_deletable_info);
	g_type_add_interface_static (seahorse_pkcs11_private_key_type_id, SEAHORSE_TYPE_EXPORTABLE, &seahorse_exportable_info);
	g_type_add_interface_static (seahorse_pkcs11_private_key_type_id, SEAHORSE_TYPE_VIEWABLE, &seahorse_viewable_info);
	SeahorsePkcs11PrivateKey_private_offset = g_type_add_instance_private (seahorse_pkcs11_private_key_type_id, sizeof (SeahorsePkcs11PrivateKeyPrivate));
	return seahorse_pkcs11_private_key_type_id;
}

GType
seahorse_pkcs11_private_key_get_type (void)
{
	static volatile gsize seahorse_pkcs11_private_key_type_id__once = 0;
	if (g_once_init_enter (&seahorse_pkcs11_private_key_type_id__once)) {
		GType seahorse_pkcs11_private_key_type_id;
		seahorse_pkcs11_private_key_type_id = seahorse_pkcs11_private_key_get_type_once ();
		g_once_init_leave (&seahorse_pkcs11_private_key_type_id__once, seahorse_pkcs11_private_key_type_id);
	}
	return seahorse_pkcs11_private_key_type_id__once;
}

static void
_vala_seahorse_pkcs11_private_key_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	SeahorsePkcs11PrivateKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SEAHORSE_PKCS11_TYPE_PRIVATE_KEY, SeahorsePkcs11PrivateKey);
	switch (property_id) {
		case SEAHORSE_PKCS11_PRIVATE_KEY_PLACE_PROPERTY:
		g_value_take_object (value, seahorse_pkcs11_private_key_get_place (self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_OBJECT_FLAGS_PROPERTY:
		g_value_set_flags (value, seahorse_pkcs11_private_key_get_object_flags (self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_ACTIONS_PROPERTY:
		g_value_set_object (value, seahorse_pkcs11_private_key_get_actions (self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_PARTNER_PROPERTY:
		g_value_take_object (value, seahorse_pkcs11_private_key_get_partner (self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_LABEL_PROPERTY:
		g_value_take_string (value, seahorse_pkcs11_private_key_get_label (self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_MARKUP_PROPERTY:
		g_value_take_string (value, seahorse_pkcs11_private_key_get_markup (self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_DESCRIPTION_PROPERTY:
		g_value_set_string (value, seahorse_pkcs11_private_key_get_description (self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_ICON_PROPERTY:
		g_value_set_object (value, seahorse_pkcs11_private_key_get_icon (self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_ATTRIBUTES_PROPERTY:
		g_value_take_boxed (value, seahorse_pkcs11_private_key_real_get_attributes ((GckObjectCache*) self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_DELETABLE_PROPERTY:
		g_value_set_boolean (value, seahorse_deletable_get_deletable ((SeahorseDeletable*) self));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_EXPORTABLE_PROPERTY:
		g_value_set_boolean (value, seahorse_exportable_get_exportable ((SeahorseExportable*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_seahorse_pkcs11_private_key_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	SeahorsePkcs11PrivateKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SEAHORSE_PKCS11_TYPE_PRIVATE_KEY, SeahorsePkcs11PrivateKey);
	switch (property_id) {
		case SEAHORSE_PKCS11_PRIVATE_KEY_PLACE_PROPERTY:
		seahorse_pkcs11_private_key_set_place (self, g_value_get_object (value));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_PARTNER_PROPERTY:
		seahorse_pkcs11_private_key_set_partner (self, g_value_get_object (value));
		break;
		case SEAHORSE_PKCS11_PRIVATE_KEY_ATTRIBUTES_PROPERTY:
		seahorse_pkcs11_private_key_real_set_attributes ((GckObjectCache*) self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

