Commit de9c87de authored by Stefan Walter's avatar Stefan Walter

Initial rough DBUS interface implementation.

    * daemon/Makefile.am:
    * daemon/seahorse-daemon.c:
    * daemon/seahorse-daemon.h:
    * daemon/seahorse-dbus-bindings.xml: (removed)
    * daemon/seahorse-dbus-server.c:
    * daemon/seahorse-service-keyset.c:
    * daemon/seahorse-service-keyset.xml:
    * daemon/seahorse-service.c:
    * daemon/seahorse-service.h:
    * daemon/seahorse-service.xml:
    * libseahorse/seahorse-key.c:
    * libseahorse/seahorse-key.h:
    * libseahorse/seahorse-pgp-key.c:
    * tests/dbus-test.py: Initial rough DBUS interface implementation.
parent 546c457c
......@@ -3,6 +3,20 @@
* libseahorse/seahorse-context.c: Fix bug with not returning
key sources properly.
* configure.in: Require DBUS 0.35 (earlier glib bindings seem broken)
* daemon/Makefile.am:
* daemon/seahorse-daemon.c:
* daemon/seahorse-daemon.h:
* daemon/seahorse-dbus-bindings.xml: (removed)
* daemon/seahorse-dbus-server.c:
* daemon/seahorse-service-keyset.c:
* daemon/seahorse-service-keyset.xml:
* daemon/seahorse-service.c:
* daemon/seahorse-service.h:
* daemon/seahorse-service.xml:
* libseahorse/seahorse-key.c:
* libseahorse/seahorse-key.h:
* libseahorse/seahorse-pgp-key.c:
* tests/dbus-test.py: Initial rough DBUS interface implementation.
2005-08-23 Adam Schreiber <sadam@clemson.edu>
* libseahorse/seahorse-pgp-key.c:
......
......@@ -5,4 +5,5 @@ Makefile
*.la
*.lo
seahorse-daemon
seahorse-dbus-bindings.h
seahorse-service-bindings.h
seahorse-service-keyset-bindings.h
......@@ -30,8 +30,9 @@ SHARING_SRCS =
endif
if WITH_DBUS
DBUS_SRCS = seahorse-dbus-server.c seahorse-service.c seahorse-service.h
BUILT_SOURCES += seahorse-dbus-bindings.h
DBUS_SRCS = seahorse-dbus-server.c seahorse-service.c seahorse-service.h
DBUS_SRCS += seahorse-service-keyset.c
BUILT_SOURCES += seahorse-service-bindings.h seahorse-service-keyset-bindings.h
else
DBUS_SRCS =
endif
......@@ -55,9 +56,10 @@ EXTRA_DIST = \
CLEANFILES = *.gladep* *.bak
# TODO: Look at evince to see what they did here. Something about --prefix
seahorse-dbus-bindings.h: seahorse-dbus-bindings.xml
dbus-binding-tool --mode=glib-server --output=$@ $(srcdir)/$<
seahorse-service-bindings.h: seahorse-service.xml
dbus-binding-tool --prefix=seahorse_service --mode=glib-server --output=$@ $(srcdir)/$<
seahorse-service-keyset-bindings.h: seahorse-service-keyset.xml
dbus-binding-tool --prefix=seahorse_service_keyset --mode=glib-server --output=$@ $(srcdir)/$<
install-exec-hook:
chmod u+s $(bindir)/seahorse-daemon
......@@ -35,6 +35,7 @@
#include "config.h"
#include "seahorse-daemon.h"
#include "seahorse-gtkstock.h"
#include "seahorse-context.h"
#ifdef WITH_AGENT
#include "seahorse-agent.h"
......@@ -188,6 +189,7 @@ prepare_logging ()
int main(int argc, char* argv[])
{
SeahorseOperation *op;
GnomeProgram *program = NULL;
#ifdef WITH_AGENT
......@@ -234,6 +236,11 @@ int main(int argc, char* argv[])
/* Insert Icons into Stock */
seahorse_gtk_stock_init();
/* Make the default SeahorseContext */
seahorse_context_new (TRUE);
op = seahorse_context_load_local_keys (SCTX_APP ());
g_object_unref (op);
/* Initialize the various daemon components */
#ifdef WITH_DBUS
seahorse_dbus_server_init ();
......@@ -258,5 +265,7 @@ int main(int argc, char* argv[])
seahorse_dbus_server_cleanup ();
#endif
seahorse_context_destroy (SCTX_APP ());
return 0;
}
......@@ -54,11 +54,14 @@ GQuark seahorse_hkp_server_error_domain ();
/* seahorse-dbus-server.c --------------------------------------------------- */
#ifdef WITH_DBUS
#include <dbus/dbus-glib-bindings.h>
gboolean seahorse_dbus_server_init ();
gboolean seahorse_dbus_server_cleanup ();
DBusGConnection* seahorse_dbus_server_get_connection ();
#endif
#endif /* _SEAHORSE_DAEMON_H_ */
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/org/gnome/seahorse/Crypto/Service">
<interface name="org.gnome.seahorse.CryptoService">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="seahorse_service"/>
<method name="GetKeyTypes">
<!-- This is optional, and in this case is redunundant -->
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="seahorse_service_get_key_types"/>
<arg type="s" name="str_ret" direction="out" />
</method>
</interface>
</node>
......@@ -22,25 +22,30 @@
#include "config.h"
#include "seahorse-service.h"
#include "seahorse-dbus-bindings.h"
#include "seahorse-service-bindings.h"
#include "seahorse-service-keyset-bindings.h"
#include <dbus/dbus-glib-bindings.h>
#define APPLICATION_SERVICE_NAME "org.gnome.seahorse.CryptoService"
#define APPLICATION_SERVICE_NAME "org.gnome.seahorse.KeyService"
/* The main service object */
SeahorseService *the_service = NULL;
DBusGConnection *connection = NULL;
void
seahorse_dbus_server_init ()
{
DBusGConnection *connection;
DBusGProxy *driver_proxy;
GError *err = NULL;
guint request_name_result;
g_return_if_fail (connection == NULL);
g_return_if_fail (the_service == NULL);
connection = dbus_g_bus_get (DBUS_BUS_STARTER, &err);
if (connection == NULL) {
g_warning ("DBUS Service registration failed.");
g_warning ("DBUS Service registration failed: %s", err ? err->message : "");
g_error_free (err);
return;
}
......@@ -59,25 +64,34 @@ seahorse_dbus_server_init ()
return;
}
if (!the_service)
the_service = g_object_new (SEAHORSE_TYPE_SERVICE, NULL);
#if DBUS_VERSION == 33
dbus_g_object_class_install_info (G_OBJECT_GET_CLASS (the_service),
&dbus_glib_seahorse_service_object_info);
#else
dbus_g_object_type_install_info (SEAHORSE_TYPE_SERVICE,
&dbus_glib_seahorse_service_object_info);
#endif
dbus_g_connection_register_g_object (connection, "/org/gnome/seahorse/Crypto/Service",
dbus_g_object_type_install_info (SEAHORSE_TYPE_SERVICE_KEYSET,
&dbus_glib_seahorse_service_keyset_object_info);
the_service = g_object_new (SEAHORSE_TYPE_SERVICE, NULL);
dbus_g_connection_register_g_object (connection, "/org/gnome/seahorse/keys",
G_OBJECT (the_service));
}
DBusGConnection*
seahorse_dbus_server_get_connection ()
{
return connection;
}
void
seahorse_dbus_server_cleanup ()
{
/* TODO: Cleanup the_service object here. Need to check that DBUS
glib bindings are okay with just destroying the object. */
/* The DBUS Glib bindings (apparently) note when this goes
away and unregister it for incoming calls */
if (the_service)
g_object_unref (the_service);
the_service = NULL;
if (connection)
dbus_g_connection_unref (connection);
connection = NULL;
}
/*
* Seahorse
*
* Copyright (C) 2005 Nate Nielsen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <glib.h>
#include "seahorse-service.h"
enum {
KEY_ADDED,
KEY_REMOVED,
KEY_CHANGED,
LAST_SIGNAL
};
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
*/
gboolean
seahorse_service_keyset_list_keys (SeahorseServiceKeyset *keyset, gchar ***keys,
GError **error)
{
GList *k, *l;
GArray *a;
gchar *id;
k = seahorse_keyset_get_keys (SEAHORSE_KEYSET (keyset));
a = g_array_new (TRUE, TRUE, sizeof (gchar*));
for (l = k; l; l = g_list_next (l)) {
id = seahorse_service_key_to_dbus (SEAHORSE_KEY (l->data));
g_array_append_val (a, id);
}
*keys = (gchar**)g_array_free (a, FALSE);
return TRUE;
}
/* -----------------------------------------------------------------------------
* DBUS SIGNALS
*/
static void
seahorse_service_keyset_added (SeahorseKeyset *skset, SeahorseKey *skey)
{
gchar *id = seahorse_service_key_to_dbus (skey);
g_signal_emit (SEAHORSE_SERVICE_KEYSET (skset), signals[KEY_ADDED], 0, id);
g_free (id);
}
static void
seahorse_service_keyset_removed (SeahorseKeyset *skset, SeahorseKey *skey,
gpointer closure)
{
gchar *id = seahorse_service_key_to_dbus (skey);
g_signal_emit (SEAHORSE_SERVICE_KEYSET (skset), signals[KEY_REMOVED], 0, id);
g_free (id);
}
static void
seahorse_service_keyset_changed (SeahorseKeyset *skset, SeahorseKey *skey,
SeahorseKeyChange change, gpointer closure)
{
gchar *id = seahorse_service_key_to_dbus (skey);
g_signal_emit (SEAHORSE_SERVICE_KEYSET (skset), signals[KEY_CHANGED], 0, id);
g_free (id);
}
/* -----------------------------------------------------------------------------
* OBJECT
*/
static void
seahorse_service_keyset_class_init (SeahorseServiceKeysetClass *klass)
{
GObjectClass *gobject_class;
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;
gobject_class = 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),
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),
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),
NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}
static void
seahorse_service_keyset_init (SeahorseServiceKeyset *keyset)
{
}
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/org/gnome/seahorse/keys/openpgp">
<interface name="org.gnome.seahorse.Keys">
<method name="ListKeys">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_keyset_list_keys"/>
<arg type="as" name="keys" direction="out"/>
</method>
<signal name="KeyAdded">
<arg type="s" name="key" direction="out"/>
</signal>
<signal name="KeyRemoved">
<arg type="s" name="key" direction="out"/>
</signal>
<signal name="KeyChanged">
<arg type="s" name="key" direction="out"/>
</signal>
</interface>
</node>
This diff is collapsed.
......@@ -25,8 +25,18 @@
#include <glib/gerror.h>
#include <glib-object.h>
#include "seahorse-keyset.h"
G_BEGIN_DECLS
/* TODO: This needs to be refined */
enum {
SEAHORSE_DBUS_ERROR_INVALID = 1,
SEAHORSE_DBUS_ERROR_NOTIMPLEMENTED = 100
};
#define SEAHORSE_DBUS_ERROR g_quark_from_static_string ("seahorse")
typedef struct _SeahorseService SeahorseService;
typedef struct _SeahorseServiceClass SeahorseServiceClass;
......@@ -39,17 +49,94 @@ typedef struct _SeahorseServiceClass SeahorseServiceClass;
struct _SeahorseService {
GObject base;
/* <public> */
GHashTable *keysets;
};
struct _SeahorseServiceClass {
GObjectClass base;
};
GType
seahorse_service_get_type ();
GType seahorse_service_get_type (void);
gboolean seahorse_service_get_key_types (SeahorseService *svc, gchar*** ret,
GError **error);
gboolean seahorse_service_get_keyset (SeahorseService *svc, gchar *ktype,
gchar **path, GError **error);
gboolean seahorse_service_has_key_field (SeahorseService *svc, gchar *key,
gchar *field, gboolean *has, GError **error);
gboolean seahorse_service_get_key_field (SeahorseService *svc, gchar *key,
gchar *field, GValue *value, GError **error);
gboolean seahorse_service_get_key_fields (SeahorseService *svc, gchar *key,
gchar **fields, GHashTable **values, GError **error);
gboolean seahorse_service_get_key_names (SeahorseService *svc, gchar *key,
gchar ***names, gchar ***cns, GError **error);
gboolean seahorse_service_import_keys (SeahorseService *svc, gchar *ktype,
gchar *data, gchar ***keys, GError **error);
gboolean seahorse_service_export_keys (SeahorseService *svc, gchar *ktype,
gchar **keys, gchar **data, GError **error);
gboolean seahorse_service_match_keys (SeahorseService *svc, gchar *ktype,
gint flags, gchar **patterns, gchar ***keys,
gchar***unmatched, GError **error);
gboolean seahorse_service_match_save (SeahorseService *svc, gchar *ktype,
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);
gchar* seahorse_service_key_to_dbus (SeahorseKey *skey);
typedef struct _SeahorseServiceKeyset SeahorseServiceKeyset;
typedef struct _SeahorseServiceKeysetClass SeahorseServiceKeysetClass;
#define SEAHORSE_TYPE_SERVICE_KEYSET (seahorse_service_keyset_get_type ())
#define SEAHORSE_SERVICE_KEYSET(object) (G_TYPE_CHECK_INSTANCE_CAST((object), SEAHORSE_TYPE_SERVICE_KEYSET, SeahorseServiceKeyset))
#define SEAHORSE_SERVICE_KEYSET_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), SEAHORSE_TYPE_SERVICE_KEYSET, SeahorseServiceKeysetClass))
#define SEAHORSE_IS_SERVICE_KEYSET(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), SEAHORSE_TYPE_SERVICE_KEYSET))
#define SEAHORSE_IS_SERVICE_KEYSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SEAHORSE_TYPE_SERVICE_KEYSET))
#define SEAHORSE_SERVICE_KEYSET_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SEAHORSE_TYPE_SERVICE_KEYSET, SeahorseServiceKeysetClass))
struct _SeahorseServiceKeyset {
SeahorseKeyset base;
};
struct _SeahorseServiceKeysetClass {
SeahorseKeysetClass base;
/* signals --------------------------------------------------------- */
/* A key was added to this view */
void (*key_added) (SeahorseServiceKeyset *skset, const gchar *key);
/* Removed a key from this view */
void (*key_removed) (SeahorseServiceKeyset *skset, const gchar *key);
/* One of the key's attributes has changed */
void (*key_changed) (SeahorseServiceKeyset *skset, const gchar *key);
};
GType seahorse_service_keyset_get_type (void);
SeahorseKeyset* seahorse_service_keyset_new (GQuark keytype);
gboolean seahorse_service_keyset_list_keys (SeahorseServiceKeyset *keyset,
gchar ***keys, GError **error);
gboolean
seahorse_service_get_key_types (SeahorseService *svc, gchar** ret,
GError **error);
G_END_DECLS
#endif /* __SEAHORSE_SERVICE_H__ */
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/org/gnome/seahorse/keys">
<interface name="org.gnome.seahorse.KeyService">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="seahorse_service"/>
<method name="GetKeyTypes">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_get_key_types"/>
<arg type="as" name="keytypes" direction="out"/>
</method>
<method name="GetKeyset">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_get_keyset"/>
<arg type="s" name="ktype" direction="in"/>
<arg type="o" name="keyset" direction="out"/>
</method>
<!-- A less than shiny hack around the fact that variants
don't support NULL! -->
<method name="HasKeyField">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_has_key_field"/>
<arg type="s" name="key" direction="in"/>
<arg type="s" name="field" direction="in"/>
<arg type="b" name="has" direction="out"/>
</method>
<method name="GetKeyField">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_get_key_field"/>
<arg type="s" name="key" direction="in"/>
<arg type="s" name="field" direction="in"/>
<arg type="v" name="info" direction="out"/>
</method>
<method name="GetKeyFields">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_get_key_fields"/>
<arg type="s" name="key" direction="in"/>
<arg type="as" name="fields" direction="in"/>
<!-- array {field, value} -->
<arg type="a{sv}" name="info" direction="out"/>
</method>
<method name="GetKeyNames">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_get_key_names"/>
<arg type="s" name="key" direction="in"/>
<arg type="as" name="names" direction="out"/>
<arg type="as" name="cns" direction="out"/>
</method>
<method name="ImportKeys">
<annotation name="org.freedesktop.DBus.Glib.CSymbol"
value="seahorse_service_import_keys"/>
<arg type="s" name="ktype" direction="in"/>
<arg type="s" name="data" direction="in"/>
<arg type="as" name="keys" direction="out"/>
</method>
<method name="ExportKeys">
<annotation name="org.freedesktop.DBus.Glib.CSymbol"
value="seahorse_service_export_keys"/>
<arg type="s" name="ktype" direction="in"/>
<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"/>
<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="out"/>
<arg type="as" name="unmatched" direction="out"/>
</method>
<method name="MatchSave">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_match_save"/>
<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>
<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>
......@@ -310,6 +310,18 @@ seahorse_key_get_name (SeahorseKey *skey, guint uid)
return (*klass->get_name) (skey, uid);
}
gchar*
seahorse_key_get_name_cn (SeahorseKey *skey, guint uid)
{
SeahorseKeyClass *klass;
g_return_val_if_fail (SEAHORSE_IS_KEY (skey), NULL);
klass = SEAHORSE_KEY_GET_CLASS (skey);
g_return_val_if_fail (klass->get_name_cn, NULL);
return (*klass->get_name_cn) (skey, uid);
}
gchar*
seahorse_key_get_display_name (SeahorseKey *skey)
{
......
......@@ -142,6 +142,10 @@ struct _SeahorseKeyClass {
/* Get the display name for the specified UID */
gchar* (*get_name) (SeahorseKey *skey,
guint uid);
/* Get the CN for the specified UID */
gchar* (*get_name_cn) (SeahorseKey *skey,
guint uid);
};
GType seahorse_key_get_type (void);
......@@ -169,7 +173,10 @@ guint seahorse_key_get_flags (SeahorseKey *skey);
guint seahorse_key_get_num_names (SeahorseKey *skey);
gchar* seahorse_key_get_name (SeahorseKey *skey,
guint uid);
guint name);
gchar* seahorse_key_get_name_cn (SeahorseKey *skey,
guint name);
gchar* seahorse_key_get_display_name (SeahorseKey *skey);
......
......@@ -48,6 +48,7 @@ static void get_property (GObject *object, guint prop_id,
/* SeahorseKey methods */
static guint key_get_num_names (SeahorseKey *skey);
static gchar* key_get_name (SeahorseKey *skey, guint uid);
static gchar* key_get_name_cn (SeahorseKey *skey, guint uid);
/* Other forward declarations */
static gchar* calc_fingerprint (SeahorsePGPKey *skey);
......@@ -93,6 +94,7 @@ class_init (SeahorsePGPKeyClass *klass)
key_class->get_num_names = key_get_num_names;
key_class->get_name = key_get_name;
key_class->get_name_cn = key_get_name_cn;
g_object_class_install_property (gobject_class, PROP_PUBKEY,
g_param_spec_pointer ("pubkey", "Gpgme Public Key", "Gpgme Public Key that this object represents",
......@@ -274,6 +276,19 @@ key_get_name (SeahorseKey *skey, guint index)
return uid ? convert_string (uid->uid) : NULL;
}
static gchar*
key_get_name_cn (SeahorseKey *skey, guint index)
{
SeahorsePGPKey *pkey;
gpgme_user_id_t uid;
g_return_val_if_fail (SEAHORSE_IS_PGP_KEY (skey), NULL);
pkey = SEAHORSE_PGP_KEY (skey);
uid = seahorse_pgp_key_get_nth_userid (pkey, index);
return uid && uid->email ? g_strdup (uid->email) : NULL;
}
static gchar*
calc_fingerprint (SeahorsePGPKey *pkey)
{
......
......@@ -11,7 +11,31 @@ print dbus_iface.ListNames()
print "\n\nSEAHORSE DBUS CALL ------------------------------------"
proxy_obj = bus.get_object('org.gnome.seahorse.CryptoService', '/org/gnome/seahorse/Crypto/Service')
iface = dbus.Interface(proxy_obj, 'org.gnome.seahorse.CryptoService')
proxy_obj = bus.get_object('org.gnome.seahorse.KeyService', '/org/gnome/seahorse/keys')
service = dbus.Interface(proxy_obj, 'org.gnome.seahorse.KeyService')
print iface.GetKeyTypes()
types = service.GetKeyTypes()
print "GetKeyTypes(): ", types
if not len(types):
print "No key types found"
sys.exit(0)
path = service.GetKeyset(types[0])
print "GetKeySet(): ", path
proxy_obj = bus.get_object('org.gnome.seahorse.KeyService', path)
keyset = dbus.Interface(proxy_obj, "org.gnome.seahorse.Keys")
keys = keyset.ListKeys()
if not len(keys):
print "No keys found"
sys.exit(0)
print service.GetKeyField(keys[0], "display-name")
print service.GetKeyFields(keys[0], [ "display-name", "simple-name", "fingerprint" ])
print service.GetKeyNames(keys[0])
print service.ExportKeys("openpgp", [ keys[0] ])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment