[seahorse/wip/nielsdg/remove-more-deprecated: 4/8] gpgme: Uid: Don't use g_type_class_add_private()
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/wip/nielsdg/remove-more-deprecated: 4/8] gpgme: Uid: Don't use g_type_class_add_private()
- Date: Tue, 19 Feb 2019 05:43:18 +0000 (UTC)
commit 13ac7bd7bcf83cca2e8ddebea8dae242c13f775f
Author: Niels De Graef <nielsdegraef gmail com>
Date: Tue Feb 19 06:01:48 2019 +0100
gpgme: Uid: Don't use g_type_class_add_private()
It's been deprecated a while now in favor of `G_ADD_PRIVATE ()`
pgp/seahorse-gpgme-key-op.c | 6 +-
pgp/seahorse-gpgme-key.c | 2 +-
pgp/seahorse-gpgme-sign.c | 2 +-
pgp/seahorse-gpgme-uid.c | 538 ++++++++++++++++++--------------------
pgp/seahorse-gpgme-uid.h | 25 +-
pgp/seahorse-pgp-key-properties.c | 8 +-
6 files changed, 274 insertions(+), 307 deletions(-)
---
diff --git a/pgp/seahorse-gpgme-key-op.c b/pgp/seahorse-gpgme-key-op.c
index 4d2f381b..2cd6be37 100644
--- a/pgp/seahorse-gpgme-key-op.c
+++ b/pgp/seahorse-gpgme-key-op.c
@@ -600,7 +600,7 @@ seahorse_gpgme_key_op_sign_uid (SeahorseGpgmeUid *uid, SeahorseGpgmeKey *signer
seahorse_gpgme_key_get_private (signer);
- g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (uid), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
+ g_return_val_if_fail (SEAHORSE_GPGME_IS_UID (uid), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
g_return_val_if_fail (SEAHORSE_IS_GPGME_KEY (signer), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
signing_key = seahorse_gpgme_key_get_private (signer);
@@ -1893,7 +1893,7 @@ seahorse_gpgme_key_op_primary_uid (SeahorseGpgmeUid *uid)
gpgme_user_id_t userid;
gpgme_key_t key;
- g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (uid), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
+ g_return_val_if_fail (SEAHORSE_GPGME_IS_UID (uid), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
/* Make sure not revoked */
userid = seahorse_gpgme_uid_get_userid (uid);
@@ -2042,7 +2042,7 @@ seahorse_gpgme_key_op_del_uid (SeahorseGpgmeUid *uid)
SeahorseEditParm *parms;
gpgme_key_t key;
- g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (uid), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
+ g_return_val_if_fail (SEAHORSE_GPGME_IS_UID (uid), GPG_E (GPG_ERR_WRONG_KEY_USAGE));
key = seahorse_gpgme_uid_get_pubkey (uid);
g_return_val_if_fail (key, GPG_E (GPG_ERR_INV_VALUE));
diff --git a/pgp/seahorse-gpgme-key.c b/pgp/seahorse-gpgme-key.c
index 8c2802a3..9e12880c 100644
--- a/pgp/seahorse-gpgme-key.c
+++ b/pgp/seahorse-gpgme-key.c
@@ -252,7 +252,7 @@ realize_uids (SeahorseGpgmeKey *self)
/* Look for out of sync or missing UIDs */
while (uids != NULL) {
- g_return_if_fail (SEAHORSE_IS_GPGME_UID (uids->data));
+ g_return_if_fail (SEAHORSE_GPGME_IS_UID (uids->data));
uid = SEAHORSE_GPGME_UID (uids->data);
uids = g_list_next (uids);
diff --git a/pgp/seahorse-gpgme-sign.c b/pgp/seahorse-gpgme-sign.c
index e6cd489b..8d48ea08 100644
--- a/pgp/seahorse-gpgme-sign.c
+++ b/pgp/seahorse-gpgme-sign.c
@@ -85,7 +85,7 @@ sign_ok_clicked (SeahorseWidget *swidget, GtkWindow *parent)
seahorse_object_get_usage (SEAHORSE_OBJECT (signer)) ==
SEAHORSE_USAGE_PRIVATE_KEY));
to_sign = g_object_get_data (G_OBJECT (swidget), "to-sign");
- if (SEAHORSE_IS_GPGME_UID (to_sign))
+ if (SEAHORSE_GPGME_IS_UID (to_sign))
err = seahorse_gpgme_key_op_sign_uid (SEAHORSE_GPGME_UID (to_sign), SEAHORSE_GPGME_KEY (signer),
check, options);
else if (SEAHORSE_IS_GPGME_KEY (to_sign))
err = seahorse_gpgme_key_op_sign (SEAHORSE_GPGME_KEY (to_sign), SEAHORSE_GPGME_KEY (signer),
check, options);
diff --git a/pgp/seahorse-gpgme-uid.c b/pgp/seahorse-gpgme-uid.c
index 71ebdee1..8570513b 100644
--- a/pgp/seahorse-gpgme-uid.c
+++ b/pgp/seahorse-gpgme-uid.c
@@ -31,360 +31,344 @@
#include <glib/gi18n.h>
enum {
- PROP_0,
- PROP_PUBKEY,
- PROP_USERID,
- PROP_GPGME_INDEX,
- PROP_ACTUAL_INDEX
+ PROP_0,
+ PROP_PUBKEY,
+ PROP_USERID,
+ PROP_GPGME_INDEX,
+ PROP_ACTUAL_INDEX
};
-G_DEFINE_TYPE (SeahorseGpgmeUid, seahorse_gpgme_uid, SEAHORSE_PGP_TYPE_UID);
+struct _SeahorseGpgmeUid {
+ SeahorsePgpUid parent_instance;
-struct _SeahorseGpgmeUidPrivate {
- gpgme_key_t pubkey; /* The public key that this uid is part of */
- gpgme_user_id_t userid; /* The userid referred to */
- guint gpgme_index; /* The GPGME index of the UID */
- gint actual_index; /* The actual index of this UID */
+ gpgme_key_t pubkey; /* The public key that this uid is part of */
+ gpgme_user_id_t userid; /* The userid referred to */
+ guint gpgme_index; /* The GPGME index of the UID */
+ gint actual_index; /* The actual index of this UID */
};
-/* -----------------------------------------------------------------------------
- * INTERNAL HELPERS
- */
+G_DEFINE_TYPE (SeahorseGpgmeUid, seahorse_gpgme_uid, SEAHORSE_PGP_TYPE_UID);
static gchar*
convert_string (const gchar *str)
{
- if (!str)
- return NULL;
-
- /* If not utf8 valid, assume latin 1 */
- if (!g_utf8_validate (str, -1, NULL))
- return g_convert (str, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
-
- return g_strdup (str);
+ if (!str)
+ return NULL;
+
+ /* If not utf8 valid, assume latin 1 */
+ if (!g_utf8_validate (str, -1, NULL))
+ return g_convert (str, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+
+ return g_strdup (str);
}
static void
realize_signatures (SeahorseGpgmeUid *self)
{
- gpgme_key_sig_t gsig;
- SeahorsePgpSignature *sig;
- GList *sigs = NULL;
- guint flags;
-
- g_return_if_fail (self->pv->pubkey);
- g_return_if_fail (self->pv->userid);
-
- /* If this key was loaded without signatures, then leave them as is */
- if ((self->pv->pubkey->keylist_mode & GPGME_KEYLIST_MODE_SIGS) == 0)
- return;
-
- for (gsig = self->pv->userid->signatures; gsig; gsig = gsig->next) {
- sig = seahorse_pgp_signature_new (gsig->keyid);
-
- /* Order of parsing these flags is important */
- flags = 0;
- if (gsig->revoked)
- flags |= SEAHORSE_FLAG_REVOKED;
- if (gsig->expired)
- flags |= SEAHORSE_FLAG_EXPIRED;
- if (flags == 0 && !gsig->invalid)
- flags = SEAHORSE_FLAG_IS_VALID;
- if (gsig->exportable)
- flags |= SEAHORSE_FLAG_EXPORTABLE;
-
- seahorse_pgp_signature_set_flags (sig, flags);
- sigs = g_list_prepend (sigs, sig);
- }
-
- seahorse_pgp_uid_set_signatures (SEAHORSE_PGP_UID (self), sigs);
- seahorse_object_list_free (sigs);
+ gpgme_key_sig_t gsig;
+ SeahorsePgpSignature *sig;
+ GList *sigs = NULL;
+ guint flags;
+
+ g_return_if_fail (self->pubkey);
+ g_return_if_fail (self->userid);
+
+ /* If this key was loaded without signatures, then leave them as is */
+ if ((self->pubkey->keylist_mode & GPGME_KEYLIST_MODE_SIGS) == 0)
+ return;
+
+ for (gsig = self->userid->signatures; gsig; gsig = gsig->next) {
+ sig = seahorse_pgp_signature_new (gsig->keyid);
+
+ /* Order of parsing these flags is important */
+ flags = 0;
+ if (gsig->revoked)
+ flags |= SEAHORSE_FLAG_REVOKED;
+ if (gsig->expired)
+ flags |= SEAHORSE_FLAG_EXPIRED;
+ if (flags == 0 && !gsig->invalid)
+ flags = SEAHORSE_FLAG_IS_VALID;
+ if (gsig->exportable)
+ flags |= SEAHORSE_FLAG_EXPORTABLE;
+
+ seahorse_pgp_signature_set_flags (sig, flags);
+ sigs = g_list_prepend (sigs, sig);
+ }
+
+ seahorse_pgp_uid_set_signatures (SEAHORSE_PGP_UID (self), sigs);
+ seahorse_object_list_free (sigs);
}
static gboolean
compare_strings (const gchar *a, const gchar *b)
{
- if (a == b)
- return TRUE;
- if (!a || !b)
- return FALSE;
- return g_str_equal (a, b);
+ if (a == b)
+ return TRUE;
+ if (!a || !b)
+ return FALSE;
+ return g_str_equal (a, b);
}
static gboolean
compare_pubkeys (gpgme_key_t a, gpgme_key_t b)
{
- g_assert (a);
- g_assert (b);
-
- g_return_val_if_fail (a->subkeys, FALSE);
- g_return_val_if_fail (b->subkeys, FALSE);
-
- return compare_strings (a->subkeys->keyid, b->subkeys->keyid);
-}
-
-/* -----------------------------------------------------------------------------
- * OBJECT
- */
-
-static void
-seahorse_gpgme_uid_init (SeahorseGpgmeUid *self)
-{
- self->pv = G_TYPE_INSTANCE_GET_PRIVATE (self, SEAHORSE_TYPE_GPGME_UID, SeahorseGpgmeUidPrivate);
- self->pv->gpgme_index = 0;
- self->pv->actual_index = -1;
-}
-
-static void
-seahorse_gpgme_uid_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- SeahorseGpgmeUid *self = SEAHORSE_GPGME_UID (object);
-
- switch (prop_id) {
- case PROP_PUBKEY:
- g_value_set_boxed (value, seahorse_gpgme_uid_get_pubkey (self));
- break;
- case PROP_USERID:
- g_value_set_pointer (value, seahorse_gpgme_uid_get_userid (self));
- break;
- case PROP_GPGME_INDEX:
- g_value_set_uint (value, seahorse_gpgme_uid_get_gpgme_index (self));
- break;
- case PROP_ACTUAL_INDEX:
- g_value_set_uint (value, seahorse_gpgme_uid_get_actual_index (self));
- break;
- }
-}
-
-static void
-seahorse_gpgme_uid_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec)
-{
- SeahorseGpgmeUid *self = SEAHORSE_GPGME_UID (object);
- gpgme_key_t pubkey;
-
- switch (prop_id) {
- case PROP_PUBKEY:
- pubkey = g_value_get_boxed (value);
- g_return_if_fail (pubkey);
-
- if (pubkey != self->pv->pubkey) {
-
- if (self->pv->pubkey) {
- /* Should always be set to the same actual key */
- g_return_if_fail (compare_pubkeys (pubkey, self->pv->pubkey));
- gpgme_key_unref (self->pv->pubkey);
- }
-
- self->pv->pubkey = g_value_get_boxed (value);
- if (self->pv->pubkey)
- gpgme_key_ref (self->pv->pubkey);
-
- /* This is expected to be set shortly along with pubkey */
- self->pv->userid = NULL;
- }
- break;
- case PROP_ACTUAL_INDEX:
- seahorse_gpgme_uid_set_actual_index (self, g_value_get_uint (value));
- break;
- case PROP_USERID:
- seahorse_gpgme_uid_set_userid (self, g_value_get_pointer (value));
- break;
- }
-}
+ g_assert (a);
+ g_assert (b);
-static void
-seahorse_gpgme_uid_object_finalize (GObject *gobject)
-{
- SeahorseGpgmeUid *self = SEAHORSE_GPGME_UID (gobject);
-
- /* Unref the key */
- if (self->pv->pubkey)
- gpgme_key_unref (self->pv->pubkey);
- self->pv->pubkey = NULL;
- self->pv->userid = NULL;
-
- G_OBJECT_CLASS (seahorse_gpgme_uid_parent_class)->finalize (gobject);
-}
+ g_return_val_if_fail (a->subkeys, FALSE);
+ g_return_val_if_fail (b->subkeys, FALSE);
-static void
-seahorse_gpgme_uid_class_init (SeahorseGpgmeUidClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- seahorse_gpgme_uid_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (SeahorseGpgmeUidPrivate));
-
- gobject_class->finalize = seahorse_gpgme_uid_object_finalize;
- gobject_class->set_property = seahorse_gpgme_uid_set_property;
- gobject_class->get_property = seahorse_gpgme_uid_get_property;
-
- g_object_class_install_property (gobject_class, PROP_PUBKEY,
- g_param_spec_boxed ("pubkey", "Public Key", "GPGME Public Key that this uid is on",
- SEAHORSE_GPGME_BOXED_KEY, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_USERID,
- g_param_spec_pointer ("userid", "User ID", "GPGME User ID",
- G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_GPGME_INDEX,
- g_param_spec_uint ("gpgme-index", "GPGME Index", "GPGME User ID Index",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_ACTUAL_INDEX,
- g_param_spec_uint ("actual-index", "Actual Index", "Actual GPG Index",
- 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+ return compare_strings (a->subkeys->keyid, b->subkeys->keyid);
}
/* -----------------------------------------------------------------------------
- * PUBLIC
+ * OBJECT
*/
-SeahorseGpgmeUid*
-seahorse_gpgme_uid_new (SeahorseGpgmeKey *parent,
- gpgme_user_id_t userid)
-{
- return g_object_new (SEAHORSE_TYPE_GPGME_UID,
- "parent", parent,
- "pubkey", seahorse_gpgme_key_get_public (parent),
- "userid", userid, NULL);
-}
-
gpgme_key_t
seahorse_gpgme_uid_get_pubkey (SeahorseGpgmeUid *self)
{
- g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (self), NULL);
- g_return_val_if_fail (self->pv->pubkey, NULL);
- return self->pv->pubkey;
+ g_return_val_if_fail (SEAHORSE_GPGME_IS_UID (self), NULL);
+ g_return_val_if_fail (self->pubkey, NULL);
+ return self->pubkey;
}
gpgme_user_id_t
seahorse_gpgme_uid_get_userid (SeahorseGpgmeUid *self)
{
- g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (self), NULL);
- g_return_val_if_fail (self->pv->userid, NULL);
- return self->pv->userid;
+ g_return_val_if_fail (SEAHORSE_GPGME_IS_UID (self), NULL);
+ g_return_val_if_fail (self->userid, NULL);
+ return self->userid;
}
void
seahorse_gpgme_uid_set_userid (SeahorseGpgmeUid *self, gpgme_user_id_t userid)
{
- SeahorsePgpUid *base;
- GObject *obj;
- gpgme_user_id_t uid;
- gchar *string;
- gint index, i;
-
- g_return_if_fail (SEAHORSE_IS_GPGME_UID (self));
- g_return_if_fail (userid);
-
- if (self->pv->userid)
- g_return_if_fail (seahorse_gpgme_uid_is_same (self, userid));
-
- /* Make sure that this userid is in the pubkey */
- index = -1;
- for (i = 0, uid = self->pv->pubkey->uids; uid; ++i, uid = uid->next) {
- if(userid == uid) {
- index = i;
- break;
- }
- }
-
- g_return_if_fail (index >= 0);
-
- self->pv->userid = userid;
- self->pv->gpgme_index = index;
-
- obj = G_OBJECT (self);
- g_object_freeze_notify (obj);
- g_object_notify (obj, "userid");
- g_object_notify (obj, "gpgme_index");
-
- base = SEAHORSE_PGP_UID (self);
-
- string = convert_string (userid->comment);
- seahorse_pgp_uid_set_comment (base, string);
- g_free (string);
-
- string = convert_string (userid->email);
- seahorse_pgp_uid_set_email (base, string);
- g_free (string);
-
- string = convert_string (userid->name);
- seahorse_pgp_uid_set_name (base, string);
- g_free (string);
-
- realize_signatures (self);
-
- seahorse_pgp_uid_set_validity (base, seahorse_gpgme_convert_validity (userid->validity));
-
- g_object_thaw_notify (obj);
+ SeahorsePgpUid *base;
+ GObject *obj;
+ gpgme_user_id_t uid;
+ gchar *string;
+ gint index, i;
+
+ g_return_if_fail (SEAHORSE_GPGME_IS_UID (self));
+ g_return_if_fail (userid);
+
+ if (self->userid)
+ g_return_if_fail (seahorse_gpgme_uid_is_same (self, userid));
+
+ /* Make sure that this userid is in the pubkey */
+ index = -1;
+ for (i = 0, uid = self->pubkey->uids; uid; ++i, uid = uid->next) {
+ if(userid == uid) {
+ index = i;
+ break;
+ }
+ }
+
+ g_return_if_fail (index >= 0);
+
+ self->userid = userid;
+ self->gpgme_index = index;
+
+ obj = G_OBJECT (self);
+ g_object_freeze_notify (obj);
+ g_object_notify (obj, "userid");
+ g_object_notify (obj, "gpgme_index");
+
+ base = SEAHORSE_PGP_UID (self);
+
+ string = convert_string (userid->comment);
+ seahorse_pgp_uid_set_comment (base, string);
+ g_free (string);
+
+ string = convert_string (userid->email);
+ seahorse_pgp_uid_set_email (base, string);
+ g_free (string);
+
+ string = convert_string (userid->name);
+ seahorse_pgp_uid_set_name (base, string);
+ g_free (string);
+
+ realize_signatures (self);
+
+ seahorse_pgp_uid_set_validity (base, seahorse_gpgme_convert_validity (userid->validity));
+
+ g_object_thaw_notify (obj);
}
guint
seahorse_gpgme_uid_get_gpgme_index (SeahorseGpgmeUid *self)
{
- g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (self), 0);
- return self->pv->gpgme_index;
+ g_return_val_if_fail (SEAHORSE_GPGME_IS_UID (self), 0);
+ return self->gpgme_index;
}
guint
seahorse_gpgme_uid_get_actual_index (SeahorseGpgmeUid *self)
{
- g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (self), 0);
- if(self->pv->actual_index < 0)
- return self->pv->gpgme_index + 1;
- return self->pv->actual_index;
+ g_return_val_if_fail (SEAHORSE_GPGME_IS_UID (self), 0);
+ if(self->actual_index < 0)
+ return self->gpgme_index + 1;
+ return self->actual_index;
}
void
seahorse_gpgme_uid_set_actual_index (SeahorseGpgmeUid *self, guint actual_index)
{
- g_return_if_fail (SEAHORSE_IS_GPGME_UID (self));
- self->pv->actual_index = actual_index;
- g_object_notify (G_OBJECT (self), "actual-index");
+ g_return_if_fail (SEAHORSE_GPGME_IS_UID (self));
+ self->actual_index = actual_index;
+ g_object_notify (G_OBJECT (self), "actual-index");
}
gchar*
seahorse_gpgme_uid_calc_label (gpgme_user_id_t userid)
{
- g_return_val_if_fail (userid, NULL);
- return convert_string (userid->uid);
+ g_return_val_if_fail (userid, NULL);
+ return convert_string (userid->uid);
}
gchar*
seahorse_gpgme_uid_calc_name (gpgme_user_id_t userid)
{
- g_return_val_if_fail (userid, NULL);
- return convert_string (userid->name);
+ g_return_val_if_fail (userid, NULL);
+ return convert_string (userid->name);
}
gchar*
seahorse_gpgme_uid_calc_markup (gpgme_user_id_t userid, guint flags)
{
- gchar *email, *name, *comment, *ret;
-
- g_return_val_if_fail (userid, NULL);
-
- name = convert_string (userid->name);
- email = convert_string (userid->email);
- comment = convert_string (userid->comment);
-
- ret = seahorse_pgp_uid_calc_markup (name, email, comment, flags);
-
- g_free (name);
- g_free (email);
- g_free (comment);
-
- return ret;
+ g_autofree gchar *email = NULL, *name = NULL, *comment = NULL;
+
+ g_return_val_if_fail (userid, NULL);
+
+ name = convert_string (userid->name);
+ email = convert_string (userid->email);
+ comment = convert_string (userid->comment);
+
+ return seahorse_pgp_uid_calc_markup (name, email, comment, flags);
}
gboolean
seahorse_gpgme_uid_is_same (SeahorseGpgmeUid *self, gpgme_user_id_t userid)
{
- g_return_val_if_fail (SEAHORSE_IS_GPGME_UID (self), FALSE);
- g_return_val_if_fail (userid, FALSE);
-
- return compare_strings (self->pv->userid->uid, userid->uid);
+ g_return_val_if_fail (SEAHORSE_GPGME_IS_UID (self), FALSE);
+ g_return_val_if_fail (userid, FALSE);
+
+ return compare_strings (self->userid->uid, userid->uid);
+}
+
+static void
+seahorse_gpgme_uid_init (SeahorseGpgmeUid *self)
+{
+ self->gpgme_index = 0;
+ self->actual_index = -1;
+}
+
+static void
+seahorse_gpgme_uid_get_property (GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ SeahorseGpgmeUid *self = SEAHORSE_GPGME_UID (object);
+
+ switch (prop_id) {
+ case PROP_PUBKEY:
+ g_value_set_boxed (value, seahorse_gpgme_uid_get_pubkey (self));
+ break;
+ case PROP_USERID:
+ g_value_set_pointer (value, seahorse_gpgme_uid_get_userid (self));
+ break;
+ case PROP_GPGME_INDEX:
+ g_value_set_uint (value, seahorse_gpgme_uid_get_gpgme_index (self));
+ break;
+ case PROP_ACTUAL_INDEX:
+ g_value_set_uint (value, seahorse_gpgme_uid_get_actual_index (self));
+ break;
+ }
+}
+
+static void
+seahorse_gpgme_uid_set_property (GObject *object, guint prop_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SeahorseGpgmeUid *self = SEAHORSE_GPGME_UID (object);
+ gpgme_key_t pubkey;
+
+ switch (prop_id) {
+ case PROP_PUBKEY:
+ pubkey = g_value_get_boxed (value);
+ g_return_if_fail (pubkey);
+
+ if (pubkey != self->pubkey) {
+
+ if (self->pubkey) {
+ /* Should always be set to the same actual key */
+ g_return_if_fail (compare_pubkeys (pubkey, self->pubkey));
+ gpgme_key_unref (self->pubkey);
+ }
+
+ self->pubkey = g_value_get_boxed (value);
+ if (self->pubkey)
+ gpgme_key_ref (self->pubkey);
+
+ /* This is expected to be set shortly along with pubkey */
+ self->userid = NULL;
+ }
+ break;
+ case PROP_ACTUAL_INDEX:
+ seahorse_gpgme_uid_set_actual_index (self, g_value_get_uint (value));
+ break;
+ case PROP_USERID:
+ seahorse_gpgme_uid_set_userid (self, g_value_get_pointer (value));
+ break;
+ }
+}
+
+static void
+seahorse_gpgme_uid_object_finalize (GObject *gobject)
+{
+ SeahorseGpgmeUid *self = SEAHORSE_GPGME_UID (gobject);
+
+ g_clear_pointer (&self->pubkey, gpgme_key_unref);
+ self->userid = NULL;
+
+ G_OBJECT_CLASS (seahorse_gpgme_uid_parent_class)->finalize (gobject);
+}
+
+static void
+seahorse_gpgme_uid_class_init (SeahorseGpgmeUidClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = seahorse_gpgme_uid_object_finalize;
+ gobject_class->set_property = seahorse_gpgme_uid_set_property;
+ gobject_class->get_property = seahorse_gpgme_uid_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_PUBKEY,
+ g_param_spec_boxed ("pubkey", "Public Key", "GPGME Public Key that this uid is on",
+ SEAHORSE_GPGME_BOXED_KEY,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_USERID,
+ g_param_spec_pointer ("userid", "User ID", "GPGME User ID",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_GPGME_INDEX,
+ g_param_spec_uint ("gpgme-index", "GPGME Index", "GPGME User ID Index",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_ACTUAL_INDEX,
+ g_param_spec_uint ("actual-index", "Actual Index", "Actual GPG Index",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+SeahorseGpgmeUid*
+seahorse_gpgme_uid_new (SeahorseGpgmeKey *parent,
+ gpgme_user_id_t userid)
+{
+ return g_object_new (SEAHORSE_GPGME_TYPE_UID,
+ "parent", parent,
+ "pubkey", seahorse_gpgme_key_get_public (parent),
+ "userid", userid, NULL);
}
diff --git a/pgp/seahorse-gpgme-uid.h b/pgp/seahorse-gpgme-uid.h
index 2c09e65d..d9ce64c2 100644
--- a/pgp/seahorse-gpgme-uid.h
+++ b/pgp/seahorse-gpgme-uid.h
@@ -28,27 +28,10 @@
#include "pgp/seahorse-gpgme-key.h"
#include "pgp/seahorse-pgp-uid.h"
-#define SEAHORSE_TYPE_GPGME_UID (seahorse_gpgme_uid_get_type ())
-#define SEAHORSE_GPGME_UID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_GPGME_UID,
SeahorseGpgmeUid))
-#define SEAHORSE_GPGME_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_GPGME_UID,
SeahorseGpgmeUidClass))
-#define SEAHORSE_IS_GPGME_UID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SEAHORSE_TYPE_GPGME_UID))
-#define SEAHORSE_IS_GPGME_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SEAHORSE_TYPE_GPGME_UID))
-#define SEAHORSE_GPGME_UID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SEAHORSE_TYPE_GPGME_UID,
SeahorseGpgmeUidClass))
-
-typedef struct _SeahorseGpgmeUid SeahorseGpgmeUid;
-typedef struct _SeahorseGpgmeUidClass SeahorseGpgmeUidClass;
-typedef struct _SeahorseGpgmeUidPrivate SeahorseGpgmeUidPrivate;
-
-struct _SeahorseGpgmeUid {
- SeahorsePgpUid parent;
- SeahorseGpgmeUidPrivate *pv;
-};
-
-struct _SeahorseGpgmeUidClass {
- SeahorsePgpUidClass parent_class;
-};
-
-GType seahorse_gpgme_uid_get_type (void);
+#define SEAHORSE_GPGME_TYPE_UID (seahorse_gpgme_uid_get_type ())
+G_DECLARE_FINAL_TYPE (SeahorseGpgmeUid, seahorse_gpgme_uid,
+ SEAHORSE_GPGME, UID,
+ SeahorsePgpUid)
SeahorseGpgmeUid* seahorse_gpgme_uid_new (SeahorseGpgmeKey *parent,
gpgme_user_id_t userid);
diff --git a/pgp/seahorse-pgp-key-properties.c b/pgp/seahorse-pgp-key-properties.c
index be32b271..866f59e9 100644
--- a/pgp/seahorse-pgp-key-properties.c
+++ b/pgp/seahorse-pgp-key-properties.c
@@ -240,7 +240,7 @@ on_uids_make_primary (GSimpleAction *action, GVariant *param, gpointer user_data
uid = names_get_selected_uid (self);
if (uid) {
- g_return_if_fail (SEAHORSE_IS_GPGME_UID (uid));
+ g_return_if_fail (SEAHORSE_GPGME_IS_UID (uid));
err = seahorse_gpgme_key_op_primary_uid (SEAHORSE_GPGME_UID (uid));
if (!GPG_IS_OK (err))
seahorse_gpgme_handle_error (err, _("Couldn’t change primary user ID"));
@@ -260,7 +260,7 @@ on_uids_delete (GSimpleAction *action, GVariant *param, gpointer user_data)
if (uid == NULL)
return;
- g_return_if_fail (SEAHORSE_IS_GPGME_UID (uid));
+ g_return_if_fail (SEAHORSE_GPGME_IS_UID (uid));
message = g_strdup_printf (_("Are you sure you want to permanently delete the “%s” user ID?"),
seahorse_object_get_label (SEAHORSE_OBJECT (uid)));
ret = seahorse_delete_dialog_prompt (GTK_WINDOW (self), message);
@@ -281,7 +281,7 @@ on_uids_sign (GSimpleAction *action, GVariant *param, gpointer user_data)
uid = names_get_selected_uid (self);
if (uid != NULL) {
- g_return_if_fail (SEAHORSE_IS_GPGME_UID (uid));
+ g_return_if_fail (SEAHORSE_GPGME_IS_UID (uid));
seahorse_gpgme_sign_prompt_uid (SEAHORSE_GPGME_UID (uid),
GTK_WINDOW (self));
}
@@ -317,7 +317,7 @@ update_names (GtkTreeSelection *selection, SeahorsePgpKeyProperties *self)
SeahorsePgpUid *uid = names_get_selected_uid (self);
gint index = -1;
- if (uid && SEAHORSE_IS_GPGME_UID (uid))
+ if (uid && SEAHORSE_GPGME_IS_UID (uid))
index = seahorse_gpgme_uid_get_gpgme_index (SEAHORSE_GPGME_UID (uid));
set_action_enabled (self, "uids.make-primary", index > 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]