seahorse r2676 - in trunk: . daemon pgp ssh



Author: nnielsen
Date: Tue Dec 16 18:11:28 2008
New Revision: 2676
URL: http://svn.gnome.org/viewvc/seahorse?rev=2676&view=rev

Log:
	* daemon/seahorse-service-crypto.c:
	* pgp/seahorse-gpgme-key.c:
	* pgp/seahorse-gpgme-key-op.c:
	* pgp/seahorse-gpgme-source.c:
	* pgp/seahorse-hkp-source.c:
	* pgp/seahorse-ldap-source.c:
	* pgp/seahorse-pgp-key.c:
	* pgp/seahorse-pgp-key.h:
	* pgp/seahorse-pgp-signature.c:
	* pgp/seahorse-server-source.c: Add function for calculating 
	displayable identifier. Rename other PGP key ID related functions
	to have 'calc' in the name instead of 'get. 
	
	* ssh/seahorse-ssh-key.c: 
	* ssh/seahorse-ssh-key.h:
	* ssh/seahorse-ssh-source.c: Explicitly set SSH key displayable ID.

Modified:
   trunk/ChangeLog
   trunk/daemon/seahorse-service-crypto.c
   trunk/pgp/seahorse-gpgme-key-op.c
   trunk/pgp/seahorse-gpgme-key.c
   trunk/pgp/seahorse-gpgme-source.c
   trunk/pgp/seahorse-hkp-source.c
   trunk/pgp/seahorse-ldap-source.c
   trunk/pgp/seahorse-pgp-key.c
   trunk/pgp/seahorse-pgp-key.h
   trunk/pgp/seahorse-pgp-signature.c
   trunk/pgp/seahorse-server-source.c
   trunk/ssh/seahorse-ssh-key.c
   trunk/ssh/seahorse-ssh-key.h
   trunk/ssh/seahorse-ssh-source.c

Modified: trunk/daemon/seahorse-service-crypto.c
==============================================================================
--- trunk/daemon/seahorse-service-crypto.c	(original)
+++ trunk/daemon/seahorse-service-crypto.c	Tue Dec 16 18:11:28 2008
@@ -448,7 +448,7 @@
             if (status->signatures->summary & GPGME_SIGSUM_GREEN ||
                 status->signatures->summary & GPGME_SIGSUM_VALID ||
                 status->signatures->summary & GPGME_SIGSUM_KEY_MISSING) {
-                keyid = seahorse_pgp_key_get_cannonical_id (status->signatures->fpr);
+                keyid = seahorse_pgp_key_calc_cannonical_id (status->signatures->fpr);
                 *signer = seahorse_context_id_to_dbus (SCTX_APP (), keyid);
             }
         }
@@ -511,7 +511,7 @@
             if (status->signatures->summary & GPGME_SIGSUM_GREEN ||
                 status->signatures->summary & GPGME_SIGSUM_VALID ||
                 status->signatures->summary & GPGME_SIGSUM_KEY_MISSING) {
-                keyid = seahorse_pgp_key_get_cannonical_id (status->signatures->fpr);
+                keyid = seahorse_pgp_key_calc_cannonical_id (status->signatures->fpr);
                 *signer = seahorse_context_id_to_dbus (SCTX_APP (), keyid);
             }
         }

Modified: trunk/pgp/seahorse-gpgme-key-op.c
==============================================================================
--- trunk/pgp/seahorse-gpgme-key-op.c	(original)
+++ trunk/pgp/seahorse-gpgme-key-op.c	Tue Dec 16 18:11:28 2008
@@ -1227,7 +1227,7 @@
 	g_return_val_if_fail (id, GPG_E (GPG_ERR_INV_VALUE));
 	
 	parms = seahorse_edit_parm_new (ADD_REVOKER_START, add_revoker_action,
-	                                add_revoker_transit, (gpointer)seahorse_pgp_key_get_rawid (id));
+	                                add_revoker_transit, (gpointer)seahorse_pgp_key_calc_rawid (id));
 	
 	return edit_key (pkey, parms);
 }

Modified: trunk/pgp/seahorse-gpgme-key.c
==============================================================================
--- trunk/pgp/seahorse-gpgme-key.c	(original)
+++ trunk/pgp/seahorse-gpgme-key.c	Tue Dec 16 18:11:28 2008
@@ -70,7 +70,7 @@
 	
 	ctx = seahorse_gpgme_source_new_context ();
 	gpgme_set_keylist_mode (ctx, mode);
-	gerr = gpgme_op_keylist_start (ctx, seahorse_pgp_key_get_rawid (id), secret);
+	gerr = gpgme_op_keylist_start (ctx, seahorse_pgp_key_calc_rawid (id), secret);
 	if (GPG_IS_OK (gerr)) {
 		gerr = gpgme_op_keylist_next (ctx, key);
 		gpgme_op_keylist_end (ctx);
@@ -649,7 +649,7 @@
 	
 	memset (&pred, 0, sizeof (pred));
 	pred.type = SEAHORSE_TYPE_GPGME_KEY;
-	pred.id = seahorse_pgp_key_get_cannonical_id (key->subkeys->keyid);
+	pred.id = seahorse_pgp_key_calc_cannonical_id (key->subkeys->keyid);
 	
 	seahorse_context_for_objects_full (NULL, &pred, refresh_each_object, NULL);
 }

Modified: trunk/pgp/seahorse-gpgme-source.c
==============================================================================
--- trunk/pgp/seahorse-gpgme-source.c	(original)
+++ trunk/pgp/seahorse-gpgme-source.c	Tue Dec 16 18:11:28 2008
@@ -309,7 +309,7 @@
 	
 	seahorse_registry_register_type (NULL, SEAHORSE_TYPE_GPGME_SOURCE, "source", "local", SEAHORSE_PGP_STR, NULL);
 
-	seahorse_registry_register_function (NULL, seahorse_pgp_key_get_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
+	seahorse_registry_register_function (NULL, seahorse_pgp_key_calc_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
 }
 
 static void 
@@ -474,7 +474,7 @@
 	g_return_val_if_fail (key->subkeys && key->subkeys->keyid, NULL);
     
 	id = key->subkeys->keyid;
-	keyid = seahorse_pgp_key_get_cannonical_id (id);
+	keyid = seahorse_pgp_key_calc_cannonical_id (id);
 	g_return_val_if_fail (keyid, NULL);
     
 	g_assert (SEAHORSE_IS_GPGME_SOURCE (psrc));
@@ -688,7 +688,7 @@
         }
         
         g_return_val_if_fail (key->subkeys && key->subkeys->keyid, FALSE);
-        keyid = seahorse_pgp_key_get_cannonical_id (key->subkeys->keyid);
+        keyid = seahorse_pgp_key_calc_cannonical_id (key->subkeys->keyid);
         
         /* Invalid id from GPG ? */
         if (!keyid) {
@@ -846,7 +846,7 @@
             if (!GPG_IS_OK (import->result))
                 continue;
             
-            keyid = seahorse_pgp_key_get_cannonical_id (import->fpr);
+            keyid = seahorse_pgp_key_calc_cannonical_id (import->fpr);
             if (!keyid) {
                 g_warning ("imported non key with strange keyid: %s", import->fpr);
                 continue;

Modified: trunk/pgp/seahorse-hkp-source.c
==============================================================================
--- trunk/pgp/seahorse-hkp-source.c	(original)
+++ trunk/pgp/seahorse-hkp-source.c	Tue Dec 16 18:11:28 2008
@@ -524,7 +524,7 @@
 	SeahorseObject *prev;
 	GQuark keyid;
        
-	keyid = seahorse_pgp_key_get_cannonical_id (seahorse_pgp_key_get_keyid (key));
+	keyid = seahorse_pgp_key_calc_cannonical_id (seahorse_pgp_key_get_keyid (key));
 	prev = seahorse_context_get_object (SCTX_APP (), SEAHORSE_SOURCE (ssrc), keyid);
 	if (prev != NULL) {
 		g_return_if_fail (SEAHORSE_IS_PGP_KEY (prev));
@@ -919,7 +919,7 @@
     for (l = keyids; l; l = g_slist_next (l)) {
 
         /* Get the key id and limit it to 8 characters */
-        fpr = seahorse_pgp_key_get_rawid (GPOINTER_TO_UINT (l->data));
+        fpr = seahorse_pgp_key_calc_rawid (GPOINTER_TO_UINT (l->data));
         len = strlen (fpr);
         if (len > 8)
             fpr += (len - 8);
@@ -968,7 +968,7 @@
 	seahorse_registry_register_type (NULL, SEAHORSE_TYPE_HKP_SOURCE, "source", "remote", SEAHORSE_PGP_STR, NULL);
 	seahorse_servers_register_type ("hkp", _("HTTP Key Server"), seahorse_hkp_is_valid_uri);
 	
-	seahorse_registry_register_function (NULL, seahorse_pgp_key_get_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
+	seahorse_registry_register_function (NULL, seahorse_pgp_key_calc_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
 }
 
 static void 

Modified: trunk/pgp/seahorse-ldap-source.c
==============================================================================
--- trunk/pgp/seahorse-ldap-source.c	(original)
+++ trunk/pgp/seahorse-ldap-source.c	Tue Dec 16 18:11:28 2008
@@ -756,7 +756,7 @@
 	SeahorseObject *prev;
 	GQuark keyid;
 
-	keyid = seahorse_pgp_key_get_cannonical_id (seahorse_pgp_key_get_keyid (key));
+	keyid = seahorse_pgp_key_calc_cannonical_id (seahorse_pgp_key_get_keyid (key));
 	prev = seahorse_context_get_object (SCTX_APP (), SEAHORSE_SOURCE (ssrc), keyid);
     
 	if (prev != NULL) {
@@ -1392,7 +1392,7 @@
     
     for (l = keyids; l; l = g_slist_next (l)) 
         fingerprints = g_slist_prepend (fingerprints, 
-            g_strdup (seahorse_pgp_key_get_rawid (GPOINTER_TO_UINT (l->data))));
+            g_strdup (seahorse_pgp_key_calc_rawid (GPOINTER_TO_UINT (l->data))));
     fingerprints = g_slist_reverse (fingerprints);
 
     lop = start_get_operation_multiple (lsrc, fingerprints, output);
@@ -1420,7 +1420,7 @@
 	seahorse_registry_register_type (NULL, SEAHORSE_TYPE_LDAP_SOURCE, "source", "remote", SEAHORSE_PGP_STR, NULL);
 	seahorse_servers_register_type ("ldap", _("LDAP Key Server"), seahorse_ldap_is_valid_uri);
 
-	seahorse_registry_register_function (NULL, seahorse_pgp_key_get_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
+	seahorse_registry_register_function (NULL, seahorse_pgp_key_calc_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
 }
 
 static void 

Modified: trunk/pgp/seahorse-pgp-key.c
==============================================================================
--- trunk/pgp/seahorse-pgp-key.c	(original)
+++ trunk/pgp/seahorse-pgp-key.c	Tue Dec 16 18:11:28 2008
@@ -140,7 +140,7 @@
 	seahorse_object_list_free (self->pv->subkeys);
 	self->pv->subkeys = seahorse_object_list_copy (subkeys);
 	
-	id = seahorse_pgp_key_get_cannonical_id (seahorse_pgp_subkey_get_keyid (subkeys->data));
+	id = seahorse_pgp_key_calc_cannonical_id (seahorse_pgp_subkey_get_keyid (subkeys->data));
 	g_object_set (self, "id", id, NULL); 
 	
 	g_object_notify (G_OBJECT (self), "subkeys");
@@ -168,19 +168,22 @@
 seahorse_pgp_key_realize (SeahorseObject *obj)
 {
 	SeahorsePgpKey *self = SEAHORSE_PGP_KEY (obj);
-	const gchar *identifier, *nickname;
+	const gchar *nickname, *keyid;
 	const gchar *description, *icon;
-	gchar *markup, *name;
+	gchar *markup, *name, *identifier;
 	SeahorseUsage usage;
 	GList *subkeys;
 	
 	
 	SEAHORSE_OBJECT_CLASS (seahorse_pgp_key_parent_class)->realize (obj);
 	
-	identifier = "";
 	subkeys = seahorse_pgp_key_get_subkeys (self);
-	if (subkeys)
-		identifier = seahorse_pgp_subkey_get_keyid (subkeys->data);
+	if (subkeys) {
+		keyid = seahorse_pgp_subkey_get_keyid (subkeys->data);
+		identifier = seahorse_pgp_key_calc_identifier (keyid);
+	} else {
+		identifier = g_strdup ("");
+	}
 
 	name = calc_name (self);
 	markup = calc_markup (self, seahorse_object_get_flags (obj));
@@ -209,6 +212,7 @@
 		      "icon", icon,
 		      NULL);
 		
+	g_free (identifier);
 	g_free (markup);
 	g_free (name);
 }
@@ -398,7 +402,7 @@
  */
 
 GQuark
-seahorse_pgp_key_get_cannonical_id (const gchar *id)
+seahorse_pgp_key_calc_cannonical_id (const gchar *id)
 {
 	guint len = strlen (id);
 	GQuark keyid;
@@ -420,7 +424,7 @@
 }
 
 const gchar* 
-seahorse_pgp_key_get_rawid (GQuark keyid)
+seahorse_pgp_key_calc_rawid (GQuark keyid)
 {
 	const gchar* id, *rawid;
 	
@@ -431,6 +435,20 @@
 	return rawid ? rawid + 1 : id;
 }
 
+gchar*
+seahorse_pgp_key_calc_identifier (const gchar *keyid)
+{
+	guint len;
+	
+	g_return_val_if_fail (keyid, NULL);
+	
+	len = strlen (keyid);
+	if (len > 8)
+		keyid += len - 8;
+	
+	return g_strdup (keyid);
+}
+
 SeahorsePgpKey*
 seahorse_pgp_key_new (void)
 {

Modified: trunk/pgp/seahorse-pgp-key.h
==============================================================================
--- trunk/pgp/seahorse-pgp-key.h	(original)
+++ trunk/pgp/seahorse-pgp-key.h	Tue Dec 16 18:11:28 2008
@@ -102,13 +102,15 @@
 
 const gchar*      seahorse_pgp_key_get_algo             (SeahorsePgpKey *self);
 
-GQuark            seahorse_pgp_key_get_cannonical_id    (const gchar *id);
-
-const gchar*      seahorse_pgp_key_get_rawid            (GQuark keyid);
-
 const gchar*      seahorse_pgp_key_get_keyid            (SeahorsePgpKey *self);
 
 gboolean          seahorse_pgp_key_has_keyid            (SeahorsePgpKey *self, 
                                                          const gchar *keyid);
 
+gchar*            seahorse_pgp_key_calc_identifier      (const gchar *keyid);
+
+GQuark            seahorse_pgp_key_calc_cannonical_id   (const gchar *id);
+
+const gchar*      seahorse_pgp_key_calc_rawid           (GQuark keyid);
+
 #endif /* __SEAHORSE_KEY_H__ */

Modified: trunk/pgp/seahorse-pgp-signature.c
==============================================================================
--- trunk/pgp/seahorse-pgp-signature.c	(original)
+++ trunk/pgp/seahorse-pgp-signature.c	Tue Dec 16 18:11:28 2008
@@ -189,7 +189,7 @@
 
 	g_return_val_if_fail (SEAHORSE_IS_PGP_SIGNATURE (self), 0);
     
-	id = seahorse_pgp_key_get_cannonical_id (self->pv->keyid);
+	id = seahorse_pgp_key_calc_cannonical_id (self->pv->keyid);
 	sobj = seahorse_context_find_object (SCTX_APP (), id, SEAHORSE_LOCATION_LOCAL);
     
 	if (sobj) {

Modified: trunk/pgp/seahorse-server-source.c
==============================================================================
--- trunk/pgp/seahorse-server-source.c	(original)
+++ trunk/pgp/seahorse-server-source.c	Tue Dec 16 18:11:28 2008
@@ -33,6 +33,8 @@
 #include "seahorse-util.h"
 #include "seahorse-pgp-key.h"
 
+#include "common/seahorse-registry.h"
+
 enum {
     PROP_0,
     PROP_KEY_TYPE,
@@ -98,7 +100,7 @@
                                  "Key Server full URI", "",
                                  G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
     
-	seahorse_registry_register_function (NULL, seahorse_pgp_key_get_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
+	seahorse_registry_register_function (NULL, seahorse_pgp_key_calc_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
 }
 
 static void 

Modified: trunk/ssh/seahorse-ssh-key.c
==============================================================================
--- trunk/ssh/seahorse-ssh-key.c	(original)
+++ trunk/ssh/seahorse-ssh-key.c	Tue Dec 16 18:11:28 2008
@@ -72,6 +72,7 @@
 	SeahorseUsage usage;
 	const gchar *description = NULL;
 	const gchar *display = NULL;
+	gchar *identifier;
 	gchar *simple = NULL;
     
 	if (self->keydata) {
@@ -117,17 +118,22 @@
 		usage = SEAHORSE_USAGE_PUBLIC_KEY;
 		description = _("Public Secure Shell Key");
 	}
+	
+	identifier = seahorse_ssh_key_calc_identifier (self->keydata->fingerprint);
 
 	g_object_set (obj,
-	              "id", seahorse_ssh_key_get_cannonical_id (self->keydata->fingerprint),
+	              "id", seahorse_ssh_key_calc_cannonical_id (self->keydata->fingerprint),
 	              "label", display,
 	              "icon", SEAHORSE_STOCK_KEY_SSH,
 	              "usage", usage,
 	              "nickname", simple,
 	              "description", description,
 	              "location", SEAHORSE_LOCATION_LOCAL,
+	              "identifier", identifier,
 	              "flags", (self->keydata->authorized ? SEAHORSE_FLAG_TRUSTED : 0) | SEAHORSE_FLAG_EXPORTABLE,
 	              NULL);
+	
+	g_free (identifier);
 }
 
 static guint 
@@ -360,7 +366,7 @@
 }
 
 GQuark
-seahorse_ssh_key_get_cannonical_id (const gchar *id)
+seahorse_ssh_key_calc_cannonical_id (const gchar *id)
 {
     #define SSH_ID_SIZE 16
     gchar *hex, *canonical_id = g_malloc0 (SSH_ID_SIZE + 1);
@@ -385,6 +391,26 @@
     return ret;
 }
 
+
+gchar*
+seahorse_ssh_key_calc_identifier (const gchar *id)
+{
+	#define SSH_IDENTIFIER_SIZE 8
+	gchar *canonical_id = g_malloc0 (SSH_IDENTIFIER_SIZE + 1);
+	gint i, off, len = strlen (id);
+
+	/* Strip out all non alpha numeric chars and limit length to SSH_ID_SIZE */
+	for (i = len, off = SSH_IDENTIFIER_SIZE; i >= 0 && off > 0; --i) {
+		if (g_ascii_isalnum (id[i]))
+			canonical_id[--off] = g_ascii_toupper (id[i]);
+	}
+    
+	/* Not enough characters */
+	g_return_val_if_fail (off == 0, NULL);
+
+	return canonical_id;
+}
+
 gchar*
 seahorse_ssh_key_get_fingerprint (SeahorseSSHKey *self)
 {

Modified: trunk/ssh/seahorse-ssh-key.h
==============================================================================
--- trunk/ssh/seahorse-ssh-key.h	(original)
+++ trunk/ssh/seahorse-ssh-key.h	Tue Dec 16 18:11:28 2008
@@ -76,10 +76,12 @@
                                                                    
 SeahorseOperation*      seahorse_ssh_key_op_change_passphrase (SeahorseSSHKey *skey);
 
-GQuark                  seahorse_ssh_key_get_cannonical_id    (const gchar *id);
-
 SeahorseValidity        seahorse_ssh_key_get_trust            (SeahorseSSHKey *self);
 
 gchar*                  seahorse_ssh_key_get_fingerprint      (SeahorseSSHKey *self);
 
+GQuark                  seahorse_ssh_key_calc_cannonical_id    (const gchar *id);
+
+gchar*                  seahorse_ssh_key_calc_identifier      (const gchar *id);
+
 #endif /* __SEAHORSE_KEY_H__ */

Modified: trunk/ssh/seahorse-ssh-source.c
==============================================================================
--- trunk/ssh/seahorse-ssh-source.c	(original)
+++ trunk/ssh/seahorse-ssh-source.c	Tue Dec 16 18:11:28 2008
@@ -255,7 +255,7 @@
     }
 
     /* Make sure it's valid */
-    keyid = seahorse_ssh_key_get_cannonical_id (keydata->fingerprint);
+    keyid = seahorse_ssh_key_calc_cannonical_id (keydata->fingerprint);
     g_return_val_if_fail (keyid, NULL);
 
     /* Does this key exist in the context? */
@@ -713,7 +713,7 @@
     
 	seahorse_registry_register_type (NULL, SEAHORSE_TYPE_SSH_SOURCE, "source", "local", SEAHORSE_SSH_STR, NULL);
 	
-	seahorse_registry_register_function (NULL, seahorse_ssh_key_get_cannonical_id, "canonize", SEAHORSE_SSH_STR, NULL);
+	seahorse_registry_register_function (NULL, seahorse_ssh_key_calc_cannonical_id, "canonize", SEAHORSE_SSH_STR, NULL);
 }
 
 static void 



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