seahorse r2765 - in trunk: . daemon pgp
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2765 - in trunk: . daemon pgp
- Date: Thu, 5 Feb 2009 04:06:20 +0000 (UTC)
Author: nnielsen
Date: Thu Feb 5 04:06:20 2009
New Revision: 2765
URL: http://svn.gnome.org/viewvc/seahorse?rev=2765&view=rev
Log:
Rework functions for converting pgp keyids into object ids, including
the canonize id function.
Modified:
trunk/ChangeLog
trunk/daemon/seahorse-service-crypto.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
Modified: trunk/daemon/seahorse-service-crypto.c
==============================================================================
--- trunk/daemon/seahorse-service-crypto.c (original)
+++ trunk/daemon/seahorse-service-crypto.c Thu Feb 5 04:06:20 2009
@@ -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_calc_cannonical_id (status->signatures->fpr);
+ keyid = seahorse_pgp_key_canonize_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_calc_cannonical_id (status->signatures->fpr);
+ keyid = seahorse_pgp_key_canonize_id (status->signatures->fpr);
*signer = seahorse_context_id_to_dbus (SCTX_APP (), keyid);
}
}
Modified: trunk/pgp/seahorse-gpgme-key.c
==============================================================================
--- trunk/pgp/seahorse-gpgme-key.c (original)
+++ trunk/pgp/seahorse-gpgme-key.c Thu Feb 5 04:06:20 2009
@@ -673,7 +673,7 @@
memset (&pred, 0, sizeof (pred));
pred.type = SEAHORSE_TYPE_GPGME_KEY;
- pred.id = seahorse_pgp_key_calc_cannonical_id (key->subkeys->keyid);
+ pred.id = seahorse_pgp_key_canonize_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 Thu Feb 5 04:06:20 2009
@@ -307,7 +307,7 @@
seahorse_registry_register_type (NULL, SEAHORSE_TYPE_GPGME_SOURCE, "source", "local", SEAHORSE_PGP_STR, NULL);
- seahorse_registry_register_function (NULL, seahorse_pgp_key_calc_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
+ seahorse_registry_register_function (NULL, seahorse_pgp_key_canonize_id, "canonize", SEAHORSE_PGP_STR, NULL);
}
static void
@@ -469,7 +469,7 @@
g_return_val_if_fail (key->subkeys && key->subkeys->keyid, NULL);
id = key->subkeys->keyid;
- keyid = seahorse_pgp_key_calc_cannonical_id (id);
+ keyid = seahorse_pgp_key_canonize_id (id);
g_return_val_if_fail (keyid, NULL);
g_assert (SEAHORSE_IS_GPGME_SOURCE (psrc));
@@ -683,7 +683,7 @@
}
g_return_val_if_fail (key->subkeys && key->subkeys->keyid, FALSE);
- keyid = seahorse_pgp_key_calc_cannonical_id (key->subkeys->keyid);
+ keyid = seahorse_pgp_key_canonize_id (key->subkeys->keyid);
/* Invalid id from GPG ? */
if (!keyid) {
@@ -841,7 +841,7 @@
if (!GPG_IS_OK (import->result))
continue;
- keyid = seahorse_pgp_key_calc_cannonical_id (import->fpr);
+ keyid = seahorse_pgp_key_canonize_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 Thu Feb 5 04:06:20 2009
@@ -534,7 +534,7 @@
SeahorseObject *prev;
GQuark keyid;
- keyid = seahorse_pgp_key_calc_cannonical_id (seahorse_pgp_key_get_keyid (key));
+ keyid = seahorse_pgp_key_canonize_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));
@@ -1001,7 +1001,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_calc_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
+ seahorse_registry_register_function (NULL, seahorse_pgp_key_canonize_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 Thu Feb 5 04:06:20 2009
@@ -756,7 +756,7 @@
SeahorseObject *prev;
GQuark keyid;
- keyid = seahorse_pgp_key_calc_cannonical_id (seahorse_pgp_key_get_keyid (key));
+ keyid = seahorse_pgp_key_canonize_id (seahorse_pgp_key_get_keyid (key));
prev = seahorse_context_get_object (SCTX_APP (), SEAHORSE_SOURCE (ssrc), keyid);
if (prev != NULL) {
@@ -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_calc_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
+ seahorse_registry_register_function (NULL, seahorse_pgp_key_canonize_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 Thu Feb 5 04:06:20 2009
@@ -140,7 +140,7 @@
seahorse_object_list_free (self->pv->subkeys);
self->pv->subkeys = seahorse_object_list_copy (subkeys);
- id = seahorse_pgp_key_calc_cannonical_id (seahorse_pgp_subkey_get_keyid (subkeys->data));
+ id = seahorse_pgp_key_canonize_id (seahorse_pgp_subkey_get_keyid (subkeys->data));
g_object_set (self, "id", id, NULL);
g_object_notify (G_OBJECT (self), "subkeys");
@@ -401,38 +401,50 @@
*/
GQuark
-seahorse_pgp_key_calc_cannonical_id (const gchar *id)
+seahorse_pgp_key_canonize_id (const gchar *keyid)
+{
+ gchar *str;
+ GQuark id;
+
+ str = seahorse_pgp_key_calc_id (keyid, 0);
+ g_return_val_if_fail (str, 0);
+
+ id = g_quark_from_string (str);
+ g_free (str);
+
+ return id;
+}
+
+gchar*
+seahorse_pgp_key_calc_id (const gchar *keyid, guint index)
{
guint len;
- GQuark keyid;
- gchar *t;
- g_return_val_if_fail (id, 0);
- len = strlen (id);
+ g_return_val_if_fail (keyid, 0);
+ len = strlen (keyid);
if (len < 16)
- g_message ("invalid keyid (less than 16 chars): %s", id);
+ g_message ("invalid keyid (less than 16 chars): %s", keyid);
if (len > 16)
- id += len - 16;
-
- t = g_strdup_printf ("%s:%s", SEAHORSE_PGP_STR, id);
- keyid = g_quark_from_string (t);
- g_free (t);
+ keyid += len - 16;
- return keyid;
+ if (index == 0)
+ return g_strdup_printf ("%s:%s", SEAHORSE_PGP_STR, keyid);
+ else
+ return g_strdup_printf ("%s:%s:%u", SEAHORSE_PGP_STR, keyid, index);
}
const gchar*
-seahorse_pgp_key_calc_rawid (GQuark keyid)
+seahorse_pgp_key_calc_rawid (GQuark id)
{
- const gchar* id, *rawid;
+ const gchar* keyid, *strid;
- id = g_quark_to_string (keyid);
- g_return_val_if_fail (id != NULL, NULL);
+ strid = g_quark_to_string (id);
+ g_return_val_if_fail (strid != NULL, NULL);
- rawid = strchr (id, ':');
- return rawid ? rawid + 1 : id;
+ keyid = strchr (strid, ':');
+ return keyid ? keyid + 1 : strid;
}
gchar*
Modified: trunk/pgp/seahorse-pgp-key.h
==============================================================================
--- trunk/pgp/seahorse-pgp-key.h (original)
+++ trunk/pgp/seahorse-pgp-key.h Thu Feb 5 04:06:20 2009
@@ -109,8 +109,11 @@
gchar* seahorse_pgp_key_calc_identifier (const gchar *keyid);
-GQuark seahorse_pgp_key_calc_cannonical_id (const gchar *id);
+gchar* seahorse_pgp_key_calc_id (const gchar *keyid,
+ guint index);
-const gchar* seahorse_pgp_key_calc_rawid (GQuark keyid);
+const gchar* seahorse_pgp_key_calc_rawid (GQuark id);
+
+GQuark seahorse_pgp_key_canonize_id (const gchar *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 Thu Feb 5 04:06:20 2009
@@ -190,7 +190,7 @@
g_return_val_if_fail (SEAHORSE_IS_PGP_SIGNATURE (self), 0);
- id = seahorse_pgp_key_calc_cannonical_id (self->pv->keyid);
+ id = seahorse_pgp_key_canonize_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 Thu Feb 5 04:06:20 2009
@@ -98,7 +98,7 @@
"Key Server full URI", "",
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
- seahorse_registry_register_function (NULL, seahorse_pgp_key_calc_cannonical_id, "canonize", SEAHORSE_PGP_STR, NULL);
+ seahorse_registry_register_function (NULL, seahorse_pgp_key_canonize_id, "canonize", SEAHORSE_PGP_STR, NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]