seahorse r2856 - in trunk: . pgp



Author: nnielsen
Date: Sat Feb 28 06:20:38 2009
New Revision: 2856
URL: http://svn.gnome.org/viewvc/seahorse?rev=2856&view=rev

Log:
Setup ids properly on UID objects.

Modified:
   trunk/ChangeLog
   trunk/pgp/seahorse-gpgme-uid.c
   trunk/pgp/seahorse-pgp-key.c
   trunk/pgp/seahorse-pgp-uid.c
   trunk/pgp/seahorse-pgp-uid.h

Modified: trunk/pgp/seahorse-gpgme-uid.c
==============================================================================
--- trunk/pgp/seahorse-gpgme-uid.c	(original)
+++ trunk/pgp/seahorse-gpgme-uid.c	Sat Feb 28 06:20:38 2009
@@ -68,23 +68,6 @@
 }
 
 static void
-realize_id (SeahorseGpgmeUid *self)
-{
-	gchar *str = NULL;
-	GQuark id = 0;
-	
-	if (self->pv->gpgme_index >= 0 || self->pv->pubkey != NULL) {
-		/* Build up a new id for this UID */
-		g_return_if_fail (self->pv->pubkey->subkeys && self->pv->pubkey->subkeys->keyid);
-		str = seahorse_pgp_key_calc_id (self->pv->pubkey->subkeys->keyid, self->pv->gpgme_index + 1);
-		id = g_quark_from_string (str);
-		g_free (str);
-	}
-
-	g_object_set (self, "id", id, NULL);
-}
-
-static void
 realize_signatures (SeahorseGpgmeUid *self)
 {
 	gpgme_key_sig_t gsig;
@@ -348,7 +331,6 @@
 	seahorse_pgp_uid_set_comment (base, string);
 	g_free (string);
 	
-	realize_id (self);
 	realize_signatures (self);
 
 	seahorse_pgp_uid_set_validity (base, seahorse_gpgme_convert_validity (userid->validity));

Modified: trunk/pgp/seahorse-pgp-key.c
==============================================================================
--- trunk/pgp/seahorse-pgp-key.c	(original)
+++ trunk/pgp/seahorse-pgp-key.c	Sat Feb 28 06:20:38 2009
@@ -103,10 +103,14 @@
 static void
 _seahorse_pgp_key_set_uids (SeahorsePgpKey *self, GList *uids)
 {
+	guint index;
+	GQuark id;
 	GList *l;
 	
 	g_return_if_fail (SEAHORSE_IS_PGP_KEY (self));
 
+	id = seahorse_object_get_id (SEAHORSE_OBJECT (self));
+	
 	/* Remove the parent on each old one */
 	for (l = self->pv->uids; l; l = g_list_next (l)) {
 		seahorse_context_remove_object (seahorse_context_for_app (), l->data);
@@ -115,9 +119,10 @@
 
 	seahorse_object_list_free (self->pv->uids);
 	self->pv->uids = seahorse_object_list_copy (uids);
-
+	
 	/* Set parent and source on each new one, except the first */
-	for (l = self->pv->uids; l; l = g_list_next (l)) {
+	for (l = self->pv->uids, index = 0; l; l = g_list_next (l), ++index) {
+		g_object_set (l->data, "id", seahorse_pgp_uid_calc_id (id, index), NULL);
 		if (l != self->pv->uids)
 			seahorse_object_set_parent (l->data, SEAHORSE_OBJECT (self));
 		seahorse_context_add_object (seahorse_context_for_app (), l->data);

Modified: trunk/pgp/seahorse-pgp-uid.c
==============================================================================
--- trunk/pgp/seahorse-pgp-uid.c	(original)
+++ trunk/pgp/seahorse-pgp-uid.c	Sat Feb 28 06:20:38 2009
@@ -532,3 +532,16 @@
 	 	          comment && comment[0] ? comment : "",
 	 	          comment && comment[0] ? "'" : "");
 }
+
+GQuark
+seahorse_pgp_uid_calc_id (GQuark key_id, guint index)
+{
+	gchar *str = NULL;
+	GQuark id = 0;
+	
+	str = g_strdup_printf ("%s:%u", g_quark_to_string (key_id), index + 1);
+	id = g_quark_from_string (str);
+	g_free (str);
+
+	return id;
+}

Modified: trunk/pgp/seahorse-pgp-uid.h
==============================================================================
--- trunk/pgp/seahorse-pgp-uid.h	(original)
+++ trunk/pgp/seahorse-pgp-uid.h	Sat Feb 28 06:20:38 2009
@@ -89,4 +89,7 @@
                                                          const gchar *comment,
                                                          guint flags);
 
+GQuark            seahorse_pgp_uid_calc_id              (GQuark key_id,
+                                                         guint index);
+
 #endif /* __SEAHORSE_PGP_UID_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]