Commit 5bf8c029 authored by Stefan Walter's avatar Stefan Walter

Add support for unknown keys and the support for the 'DiscoverKeys' dbus

    * daemon/seahorse-service-keyset.c:
    * daemon/seahorse-service-keyset.xml:
    * daemon/seahorse-service.c:
    * daemon/seahorse-service.h:
    * daemon/seahorse-service.xml:
    * libseahorse/Makefile.am:
    * libseahorse/seahorse-context.c:
    * libseahorse/seahorse-context.h:
    * libseahorse/seahorse-hkp-source.c:
    * libseahorse/seahorse-key-source.c:
    * libseahorse/seahorse-key-source.h:
    * libseahorse/seahorse-key.c:
    * libseahorse/seahorse-key.h:
    * libseahorse/seahorse-ldap-source.c:
    * libseahorse/seahorse-pgp-source.c:
    * libseahorse/seahorse-pgp-source.h:
    * libseahorse/seahorse-server-source.c:
    * libseahorse/seahorse-ssh-key.c:
    * libseahorse/seahorse-ssh-key.h:
    * libseahorse/seahorse-ssh-source.c:
    * libseahorse/seahorse-transfer-operation.c (added):
    * libseahorse/seahorse-transfer-operation.h (added):
    * libseahorse/seahorse-unknown-key.c (added):
    * libseahorse/seahorse-unknown-key.h (added):
    * libseahorse/seahorse-unknown-source.c (added):
    * libseahorse/seahorse-unknown-source.h (added):
    * tests/dbus-discover-test.py (added):
    * tests/dbus-import.py (added):
    * tests/dbus-listen-keyset.py (added):
    * tests/dbus-test.py (added): Add support for unknown keys and
    the support for the 'DiscoverKeys' dbus API.
parent f0912e8a
2006-04-17 Nate Nielsen <nielsen@memberwebs.com>
* daemon/seahorse-service-keyset.c:
* daemon/seahorse-service-keyset.xml:
* daemon/seahorse-service.c:
* daemon/seahorse-service.h:
* daemon/seahorse-service.xml:
* libseahorse/Makefile.am:
* libseahorse/seahorse-context.c:
* libseahorse/seahorse-context.h:
* libseahorse/seahorse-hkp-source.c:
* libseahorse/seahorse-key-source.c:
* libseahorse/seahorse-key-source.h:
* libseahorse/seahorse-key.c:
* libseahorse/seahorse-key.h:
* libseahorse/seahorse-ldap-source.c:
* libseahorse/seahorse-pgp-source.c:
* libseahorse/seahorse-pgp-source.h:
* libseahorse/seahorse-server-source.c:
* libseahorse/seahorse-ssh-key.c:
* libseahorse/seahorse-ssh-key.h:
* libseahorse/seahorse-ssh-source.c:
* libseahorse/seahorse-transfer-operation.c (added):
* libseahorse/seahorse-transfer-operation.h (added):
* libseahorse/seahorse-unknown-key.c (added):
* libseahorse/seahorse-unknown-key.h (added):
* libseahorse/seahorse-unknown-source.c (added):
* libseahorse/seahorse-unknown-source.h (added):
* tests/dbus-discover-test.py (added):
* tests/dbus-import.py (added):
* tests/dbus-listen-keyset.py (added):
* tests/dbus-test.py (added): Add support for unknown keys and
the support for the 'DiscoverKeys' dbus API.
2006-04-17 Nate Nielsen <nielsen@memberwebs.com>
* libseahorse/seahorse-key-store.c: Fix crasher when
......
......@@ -31,27 +31,8 @@ enum {
};
G_DEFINE_TYPE (SeahorseServiceKeyset, seahorse_service_keyset, SEAHORSE_TYPE_KEYSET);
static SeahorseKeysetClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
/* -----------------------------------------------------------------------------
* PUBLIC METHODS
*/
SeahorseKeyset*
seahorse_service_keyset_new (GQuark ktype)
{
SeahorseServiceKeyset *skset;
SeahorseKeyPredicate *pred = g_new0(SeahorseKeyPredicate, 1);
pred->ktype = ktype;
skset = g_object_new (SEAHORSE_TYPE_SERVICE_KEYSET, "predicate", pred, NULL);
g_object_set_data_full (G_OBJECT (skset), "quick-predicate", pred, g_free);
return SEAHORSE_KEYSET (skset);
}
/* -----------------------------------------------------------------------------
* DBUS METHODS
*/
......@@ -83,12 +64,124 @@ seahorse_service_keyset_list_keys (SeahorseServiceKeyset *keyset, gchar ***keys,
return TRUE;
}
gboolean
seahorse_service_keyset_discover_keys (SeahorseServiceKeyset *keyset, const gchar **keyids,
gint flags, gchar ***keys, GError **error)
{
GArray *akeys = NULL;
gchar *keyid = NULL;
GSList *todiscover = NULL;
GList *toimport = NULL;
SeahorseKey* skey;
SeahorseKeyLoc loc;
SeahorseOperation *op;
const gchar **k;
gchar *t;
GSList *l;
gboolean ret = FALSE;
akeys = g_array_new (TRUE, TRUE, sizeof (gchar*));
/* Check all the keyids */
for (k = keyids; *k; k++) {
g_free (keyid);
keyid = seahorse_key_source_cannonical_keyid (keyset->ktype, *k);
if (!keyid) {
g_set_error (error, SEAHORSE_DBUS_ERROR, SEAHORSE_DBUS_ERROR_INVALID,
_("Invalid key id: %s"), *k);
goto finally;
}
/* Do we know about this key? */
skey = seahorse_context_find_key (SCTX_APP (), keyset->ktype,
SKEY_LOC_INVALID, keyid);
/* Add to the return value */
t = seahorse_service_keyid_to_dbus (keyset->ktype, keyid, 0);
g_array_append_val (akeys, t);
/* No such key anywhere, discover it */
if (!skey) {
todiscover = g_slist_prepend (todiscover, keyid);
keyid = NULL;
continue;
}
g_free (keyid);
keyid = NULL;
/* We know about this key, check where it is */
loc = seahorse_key_get_location (skey);
g_assert (loc != SKEY_LOC_INVALID);
/* Do nothing for local keys */
if (loc >= SKEY_LOC_LOCAL)
continue;
/* Remote keys get imported */
else if (loc >= SKEY_LOC_REMOTE)
toimport = g_list_prepend (toimport, skey);
/* Searching keys are ignored */
else if (loc >= SKEY_LOC_SEARCHING)
continue;
/* Not found keys are tried again */
else if (loc >= SKEY_LOC_UNKNOWN) {
todiscover = g_slist_prepend (todiscover, keyid);
keyid = NULL;
}
}
/* Start an import process on all toimport */
if (toimport) {
op = seahorse_context_transfer_keys (SCTX_APP (), toimport, NULL);
/* Running operations ref themselves */
g_object_unref (op);
}
/* Start a discover process on all todiscover */
if (todiscover) {
op = seahorse_context_retrieve_keys (SCTX_APP (), keyset->ktype,
todiscover, NULL);
/* Running operations ref themselves */
g_object_unref (op);
}
ret = TRUE;
finally:
if (todiscover) {
for (l = todiscover; l; l = g_slist_next (l))
g_free (l->data);
g_slist_free (todiscover);
}
if (toimport)
g_list_free (toimport);
if (keyid)
g_free (keyid);
if (ret) {
g_assert (akeys);
*keys = (gchar**)g_array_free (akeys, FALSE);
} else if (akeys) {
g_strfreev ((gchar**)g_array_free (akeys, FALSE));
}
return ret;
}
/* -----------------------------------------------------------------------------
* DBUS SIGNALS
*/
static void
seahorse_service_keyset_added (SeahorseKeyset *skset, SeahorseKey *skey)
seahorse_service_keyset_added (SeahorseKeyset *skset, SeahorseKey *skey,
gpointer userdata)
{
gchar *id;
guint uids, i;
......@@ -107,11 +200,11 @@ seahorse_service_keyset_added (SeahorseKeyset *skset, SeahorseKey *skey)
static void
seahorse_service_keyset_removed (SeahorseKeyset *skset, SeahorseKey *skey,
gpointer closure)
gpointer closure, gpointer userdata)
{
gchar *id;
guint uids, i;
uids = GPOINTER_TO_UINT (closure);
uids = (uids == 0) ? 1 : uids;
......@@ -124,7 +217,8 @@ seahorse_service_keyset_removed (SeahorseKeyset *skset, SeahorseKey *skey,
static void
seahorse_service_keyset_changed (SeahorseKeyset *skset, SeahorseKey *skey,
SeahorseKeyChange change, gpointer closure)
SeahorseKeyChange change, gpointer closure,
gpointer userdata)
{
gchar *id;
guint uids, euids, i;
......@@ -135,8 +229,8 @@ seahorse_service_keyset_changed (SeahorseKeyset *skset, SeahorseKey *skey,
euids = GPOINTER_TO_UINT (closure);
if (euids > 0 && euids != uids) {
seahorse_service_keyset_removed (skset, skey, closure);
seahorse_service_keyset_added (skset, skey);
seahorse_service_keyset_removed (skset, skey, closure, NULL);
seahorse_service_keyset_added (skset, skey, NULL);
return;
}
......@@ -154,31 +248,47 @@ seahorse_service_keyset_changed (SeahorseKeyset *skset, SeahorseKey *skey,
static void
seahorse_service_keyset_init (SeahorseServiceKeyset *keyset)
{
g_signal_connect_after (keyset, "added", G_CALLBACK (seahorse_service_keyset_added), NULL);
g_signal_connect_after (keyset, "removed", G_CALLBACK (seahorse_service_keyset_removed), NULL);
g_signal_connect_after (keyset, "added", G_CALLBACK (seahorse_service_keyset_changed), NULL);
}
static void
seahorse_service_keyset_class_init (SeahorseServiceKeysetClass *klass)
{
GObjectClass *gclass;
parent_class = g_type_class_peek_parent (klass);
parent_class->added = seahorse_service_keyset_added;
parent_class->removed = seahorse_service_keyset_removed;
parent_class->changed = seahorse_service_keyset_changed;
gclass = G_OBJECT_CLASS (klass);
signals[KEY_ADDED] = g_signal_new ("key_added", SEAHORSE_TYPE_SERVICE_KEYSET,
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (SeahorseServiceKeysetClass, key_added),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, G_STRUCT_OFFSET (SeahorseServiceKeysetClass, key_added),
NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
signals[KEY_REMOVED] = g_signal_new ("key_removed", SEAHORSE_TYPE_SERVICE_KEYSET,
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (SeahorseServiceKeysetClass, key_removed),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, G_STRUCT_OFFSET (SeahorseServiceKeysetClass, key_removed),
NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
signals[KEY_CHANGED] = g_signal_new ("key_changed", SEAHORSE_TYPE_SERVICE_KEYSET,
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (SeahorseServiceKeysetClass, key_changed),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, G_STRUCT_OFFSET (SeahorseServiceKeysetClass, key_changed),
NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}
/* -----------------------------------------------------------------------------
* PUBLIC METHODS
*/
SeahorseKeyset*
seahorse_service_keyset_new (GQuark ktype, SeahorseKeyLoc location)
{
SeahorseServiceKeyset *skset;
SeahorseKeyPredicate *pred = g_new0(SeahorseKeyPredicate, 1);
pred->ktype = ktype;
pred->location = location;
skset = g_object_new (SEAHORSE_TYPE_SERVICE_KEYSET, "predicate", pred, NULL);
g_object_set_data_full (G_OBJECT (skset), "quick-predicate", pred, g_free);
skset->ktype = ktype;
return SEAHORSE_KEYSET (skset);
}
......@@ -10,6 +10,14 @@
<arg type="as" name="keys" direction="out"/>
</method>
<method name="DiscoverKeys">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_keyset_discover_keys"/>
<arg type="as" name="keyids" direction="in"/>
<arg type="i" name="flags" direction="in"/>
<arg type="as" name="keys" direction="out"/>
</method>
<signal name="KeyAdded">
<arg type="s" name="key" direction="out"/>
</signal>
......
......@@ -30,6 +30,7 @@
#include "seahorse-util.h"
#define KEYSET_PATH "/org/gnome/seahorse/keys/%s"
#define KEYSET_PATH_LOCAL "/org/gnome/seahorse/keys/%s/local"
/* Special fields */
enum {
......@@ -94,18 +95,26 @@ void
add_key_source (SeahorseService *svc, GQuark ktype)
{
const gchar *keytype = g_quark_to_string (ktype);
SeahorseKeyset *keyset;
gchar *dbus_id;
/* Check if we have a keyset for this key type, and add if not */
if (svc->keysets && !g_hash_table_lookup (svc->keysets, keytype)) {
SeahorseKeyset *keyset = seahorse_service_keyset_new (ktype);
/* Register it with DBUS */
/* Keyset for all keys */
keyset = seahorse_service_keyset_new (ktype, SKEY_LOC_INVALID);
dbus_id = g_strdup_printf (KEYSET_PATH, keytype);
dbus_g_connection_register_g_object (seahorse_dbus_server_get_connection (),
dbus_id, G_OBJECT (keyset));
g_free (dbus_id);
/* Keyset for local keys */
keyset = seahorse_service_keyset_new (ktype, SKEY_LOC_LOCAL);
dbus_id = g_strdup_printf (KEYSET_PATH_LOCAL, keytype);
dbus_g_connection_register_g_object (seahorse_dbus_server_get_connection (),
dbus_id, G_OBJECT (keyset));
g_free (dbus_id);
g_hash_table_replace (svc->keysets, g_strdup (keytype), keyset);
}
}
......@@ -125,8 +134,9 @@ seahorse_service_key_from_dbus (const gchar *key, guint *uid)
if (!vec[0] || !vec[1])
return NULL;
/* This will always get the most preferred key */
skey = seahorse_context_find_key (SCTX_APP (), g_quark_from_string (vec[0]),
SKEY_LOC_UNKNOWN, vec[1]);
SKEY_LOC_INVALID, vec[1]);
if (uid)
*uid = 0;
......@@ -421,15 +431,6 @@ seahorse_service_match_save (SeahorseService *svc, gchar *ktype, gint flags,
return FALSE;
}
gboolean
seahorse_service_discover_keys (SeahorseService *svc, gchar *ktype, gint flags,
gchar **patterns, gchar **keys, GError **error)
{
/* TODO: Implement discover keys */
g_set_error (error, SEAHORSE_DBUS_ERROR, SEAHORSE_DBUS_ERROR_NOTIMPLEMENTED, "TODO");
return FALSE;
}
/* -----------------------------------------------------------------------------
* SIGNAL HANDLERS
*/
......
......@@ -94,10 +94,6 @@ gboolean seahorse_service_match_save (SeahorseService *svc, gchar
gint flags, gchar **patterns,
gchar **keys, GError **error);
gboolean seahorse_service_discover_keys (SeahorseService *svc, gchar *ktype,
gint flags, gchar **patterns, gchar **keys,
GError **error);
SeahorseKey* seahorse_service_key_from_dbus (const gchar *key, guint *uid);
gchar* seahorse_service_key_to_dbus (SeahorseKey *skey, guint uid);
......@@ -120,6 +116,9 @@ typedef struct _SeahorseServiceKeysetClass SeahorseServiceKeysetClass;
struct _SeahorseServiceKeyset {
SeahorseKeyset base;
/* <public> */
GQuark ktype;
};
struct _SeahorseServiceKeysetClass {
......@@ -139,11 +138,16 @@ struct _SeahorseServiceKeysetClass {
GType seahorse_service_keyset_get_type (void);
SeahorseKeyset* seahorse_service_keyset_new (GQuark keytype);
SeahorseKeyset* seahorse_service_keyset_new (GQuark keytype,
SeahorseKeyLoc location);
gboolean seahorse_service_keyset_list_keys (SeahorseServiceKeyset *keyset,
gchar ***keys, GError **error);
gboolean seahorse_service_keyset_discover_keys (SeahorseServiceKeyset *keyset,
const gchar **keyids, gint flags,
gchar ***keys, GError **error);
/* -----------------------------------------------------------------------------
* CRYPTO SERVICE
*/
......
......@@ -60,7 +60,7 @@
<arg type="as" name="keys" direction="in"/>
<arg type="s" name="data" direction="out"/>
</method>
<method name="MatchKeys">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_match_keys"/>
......@@ -80,15 +80,6 @@
<arg type="as" name="keys" direction="in"/>
</method>
<method name="DiscoverKeys">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_discover_keys"/>
<arg type="s" name="keytype" direction="in"/>
<arg type="i" name="flags" direction="in"/>
<arg type="as" name="patterns" direction="in"/>
<arg type="as" name="keys" direction="in"/>
</method>
</interface>
</node>
......@@ -62,6 +62,8 @@ libseahorse_internal_la_SOURCES = \
seahorse-pgp-key-op.c seahorse-pgp-key-op.h \
seahorse-pgp-source.c seahorse-pgp-source.h \
seahorse-pgp-operation.c seahorse-pgp-operation.h \
seahorse-unknown-key.c seahorse-unknown-key.h \
seahorse-unknown-source.c seahorse-unknown-source.h \
seahorse-context.c seahorse-context.h \
seahorse-widget.c seahorse-widget.h \
seahorse-op.c seahorse-op.h \
......@@ -83,6 +85,7 @@ libseahorse_internal_la_SOURCES = \
seahorse-gpgmex.h seahorse-gpgmex-op.c seahorse-gpgmex-util.c \
seahorse-prefs.c seahorse-prefs.h \
seahorse-operation.c seahorse-operation.h \
seahorse-transfer-operation.c seahorse-transfer-operation.h \
seahorse-progress.c seahorse-progress.h \
seahorse-gconf.c seahorse-gconf.h \
seahorse-dns-sd.c seahorse-dns-sd.h \
......@@ -122,4 +125,4 @@ glade_DATA = \
seahorse-progress.glade
EXTRA_DIST = $(glade_DATA) \
seahorse-marshal.list
seahorse-marshal.list
This diff is collapsed.
......@@ -155,4 +155,13 @@ SeahorseOperation* seahorse_context_load_remote_key (SeahorseContext *sct
SeahorseOperation* seahorse_context_load_remote_keys (SeahorseContext *sctx,
const gchar *search);
SeahorseOperation* seahorse_context_transfer_keys (SeahorseContext *sctx,
GList *keys,
SeahorseKeySource *to);
SeahorseOperation* seahorse_context_retrieve_keys (SeahorseContext *sctx,
GQuark ktype,
GSList *keyids,
SeahorseKeySource *to);
#endif /* __SEAHORSE_CONTEXT_H__ */
......@@ -707,9 +707,8 @@ static SeahorseOperation* seahorse_hkp_source_load (SeahorseKeySource *sr
const gchar *key);
static SeahorseOperation* seahorse_hkp_source_import (SeahorseKeySource *sksrc,
gpgme_data_t data);
static SeahorseOperation* seahorse_hkp_source_export (SeahorseKeySource *sksrc,
GList *keys,
gboolean complete,
static SeahorseOperation* seahorse_hkp_source_export_raw (SeahorseKeySource *sksrc,
GSList *keys,
gpgme_data_t data);
static SeahorseKeySourceClass *parent_class = NULL;
......@@ -743,7 +742,7 @@ seahorse_hkp_source_class_init (SeahorseHKPSourceClass *klass)
key_class = SEAHORSE_KEY_SOURCE_CLASS (klass);
key_class->load = seahorse_hkp_source_load;
key_class->import = seahorse_hkp_source_import;
key_class->export = seahorse_hkp_source_export;
key_class->export_raw = seahorse_hkp_source_export_raw;
parent_class = g_type_class_peek_parent (klass);
}
......@@ -883,21 +882,22 @@ seahorse_hkp_source_import (SeahorseKeySource *sksrc, gpgme_data_t data)
return SEAHORSE_OPERATION (hop);
}
static SeahorseOperation*
seahorse_hkp_source_export (SeahorseKeySource *sksrc, GList *keys,
gboolean complete, gpgme_data_t data)
static SeahorseOperation*
seahorse_hkp_source_export_raw (SeahorseKeySource *sksrc, GSList *keyids,
gpgme_data_t data)
{
SeahorseHKPOperation *hop;
SeahorseHKPSource *hsrc;
SoupMessage *message;
gchar *t, *server, *uri;
const gchar *fpr;
guint l;
guint len;
GSList *l;
g_return_val_if_fail (SEAHORSE_IS_HKP_SOURCE (sksrc), NULL);
hsrc = SEAHORSE_HKP_SOURCE (sksrc);
if (g_list_length (keys) == 0)
if (g_slist_length (keyids) == 0)
return seahorse_operation_new_complete (NULL);
server = get_http_server_address (sksrc);
......@@ -917,14 +917,13 @@ seahorse_hkp_source_export (SeahorseKeySource *sksrc, GList *keys,
(GDestroyNotify)gpgme_data_release);
}
for ( ; keys; keys = g_list_next (keys)) {
g_assert (SEAHORSE_IS_KEY (keys->data));
for (l = keyids; l; l = g_slist_next (l)) {
/* Get the key id and limit it to 8 characters */
fpr = seahorse_key_get_keyid (SEAHORSE_KEY (keys->data));
l = strlen (fpr);
if (l > 8)
fpr += (l - 8);
fpr = (const char*)(l->data);
len = strlen (fpr);
if (len > 8)
fpr += (len - 8);
/* The get key URI */
uri = g_strdup_printf ("http://%s/pks/lookup?op=get&search=0x%s",
......
......@@ -19,10 +19,17 @@
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gnome.h>
#include "seahorse-key-source.h"
#include "seahorse-marshal.h"
#include "seahorse-context.h"
#include "seahorse-pgp-key.h"
#ifdef WITH_SSH
#include "seahorse-ssh-key.h"
#endif
G_DEFINE_TYPE (SeahorseKeySource, seahorse_key_source, G_TYPE_OBJECT);
......@@ -194,12 +201,59 @@ seahorse_key_source_export (SeahorseKeySource *sksrc, GList *keys,
gboolean complete, gpgme_data_t data)
{
SeahorseKeySourceClass *klass;
SeahorseOperation *op;
GSList *keyids = NULL;
GList *l;
g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (sksrc), NULL);
klass = SEAHORSE_KEY_SOURCE_GET_CLASS (sksrc);
if (klass->export)
return (*klass->export) (sksrc, keys, complete, data);
/* Either export or export_raw must be implemented */
g_return_val_if_fail (klass->export_raw != NULL, NULL);
for (l = keys; l; l = g_list_next (l))
keyids = g_slist_prepend (keyids, (gpointer)seahorse_key_get_keyid (l->data));
keyids = g_slist_reverse (keyids);
op = (*klass->export_raw) (sksrc, keyids, data);
g_slist_free (keyids);
return op;
}
SeahorseOperation*
seahorse_key_source_export_raw (SeahorseKeySource *sksrc, GSList *keyids,
gpgme_data_t data)
{
SeahorseKeySourceClass *klass;
SeahorseOperation *op;
SeahorseKey *skey;
GList *keys = NULL;
GSList *l;
g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (sksrc), NULL);
klass = SEAHORSE_KEY_SOURCE_GET_CLASS (sksrc);
/* Either export or export_raw must be implemented */
if (klass->export_raw)
return (*klass->export_raw)(sksrc, keyids, data);
g_return_val_if_fail (klass->export != NULL, NULL);
for (l = keyids; l; l = g_slist_next (l)) {
skey = seahorse_context_get_key (SCTX_APP (), sksrc, l->data);
/* TODO: A proper error message here 'not found' */
if (skey)
keys = g_list_prepend (keys, skey);
}
return (*klass->export) (sksrc, keys, complete, data);
keys = g_list_reverse (keys);
op = (*klass->export) (sksrc, keys, FALSE, data);
g_list_free (keys);
return op;
}
gboolean
......@@ -234,3 +288,25 @@ seahorse_key_source_get_location (SeahorseKeySource *sksrc)
return loc;
}
/* -----------------------------------------------------------------------------
* CANONICAL KEYIDS
*/
gchar*
seahorse_key_source_cannonical_keyid (GQuark ktype, const gchar *keyid)
{
g_return_val_if_fail (keyid != NULL, NULL);
if (ktype == SKEY_PGP)
return seahorse_pgp_key_get_cannonical_id (keyid);
#ifdef WITH_SSH
else if(ktype == SKEY_SSH)
return seahorse_ssh_key_get_cannonical_id (keyid);
#endif
else
g_return_val_if_reached (NULL);
return NULL;
}
......@@ -127,7 +127,21 @@ typedef struct _SeahorseKeySourceClass {
*/
SeahorseOperation* (*export) (SeahorseKeySource *sksrc, GList *keys,
gboolean complete, gpgme_data_t data);
/**
* export_raw
* @sksrc: The #SeahorseKeySource to export from.
* @keys: A list of key ids to export.
* @data: Optional data object to export to (not freed).
*
* Import keys into the key source. When operation is 'done' the result
* of the operation will be a gpgme_data_t
*
* Returns: The export operation
*/
SeahorseOperation* (*export_raw) (SeahorseKeySource *sksrc, GSList *keyids,
gpgme_data_t data);
/**
* remove
* @sksrc: The #SeahorseKeySource to delete the key from.
......@@ -175,6 +189,10 @@ SeahorseOperation* seahorse_key_source_export (SeahorseKeySource *sks
gboolean complete,
gpgme_data_t data);
SeahorseOperation* seahorse_key_source_export_raw (SeahorseKeySource *sksrc,
GSList *keyids,
gpgme_data_t data);
void seahorse_key_source_stop (SeahorseKeySource *sksrc);
gboolean seahorse_key_source_remove (SeahorseKeySource *sksrc,
......@@ -186,4 +204,7 @@ GQuark seahorse_key_source_get_ktype (SeahorseKeySource *sks
SeahorseKeyLoc seahorse_key_source_get_location (SeahorseKeySource *sksrc);
gchar* seahorse_key_source_cannonical_keyid (GQuark ktype,
const gchar *keyid);
#endif /* __SEAHORSE_KEY_SOURCE_H__ */
......@@ -132,7 +132,7 @@ class_init (SeahorseKeyClass *klass)
g_object_class_install_property (gobject_class, PROP_LOCATION,
g_param_spec_uint ("location", "Key Location", "Where the key is stored. See SeahorseKeyLoc",
0, G_MAXUINT, SKEY_LOC_UNKNOWN, G_PARAM_READABLE));
0, G_MAXUINT, SKEY_LOC_INVALID, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, PROP_LOADED,
g_param_spec_uint ("loaded", "Loaded Information", "Which parts of the key are loaded. See SeahorseKeyLoaded",
......@@ -291,7 +291,7 @@ seahorse_key_get_loaded (SeahorseKey *skey)
SeahorseKeyLoc
seahorse_key_get_location (SeahorseKey *skey)
{
g_return_val_if_fail (SEAHORSE_IS_KEY (skey), SKEY_LOC_UNKNOWN);
g_return_val_if_fail (SEAHORSE_IS_KEY (skey), SKEY_LOC_INVALID);
return skey->location;
}
......@@ -385,3 +385,17 @@ seahorse_key_get_expires (SeahorseKey *skey)
g_object_get (skey, "expires", &expires, NULL);
return expires;
}
void
seahorse_key_set_preferred (SeahorseKey *skey, SeahorseKey *preferred)
{
/*
* We don't ref, because the SeahorseContext takes care of
* keeping things sane.
*/
if (preferred != skey->preferred) {
skey->preferred = preferred;
seahorse_key_changed (skey, SKEY_CHANGE_PREFERRED);
}
}
......@@ -40,6 +40,8 @@
* flags: (guint) Flags on the capabilities of the key (ie: SeahorseKeyFlags)
* location: (SeahorseKeyLoc) The location this key is stored. (ie: SKEY_LOC_REMOTE)
* loaded: (SeahorseKeyInfo) How much of the key is loaded (ie: SKEY_INFO_COMPLETE)
* preferred: (SeahorseKey) Another representation of this key, that is better suited
* for use. (eg: for a remote key could point to it's local counterpart)
*
* Properties derived classes must implement:
* display-name: (gchar*) The display name for the key.
......@@ -49,6 +51,7 @@
* validity: (SeahorseValidity) The key validity.
* trust: (SeahorseValidity) Trust for the key.
* expires: (gulong) Date this key expires or 0.
*
*/