Commit 00f95f5b authored by Stefan Walter's avatar Stefan Walter

Added DBUS service for simple text crypto operations

    * daemon/Makefile.am:
    * daemon/seahorse-daemon.c:
    * daemon/seahorse-dbus-server.c:
    * daemon/seahorse-service-crypto.c (added):
    * daemon/seahorse-service-crypto.xml (added):
    * daemon/seahorse-service.c:
    * daemon/seahorse-service.h:
    * libcryptui/cryptui-keyset.c:
    * tests/dbus-test-crypto.py (added):
    * tests/dbus-test.py: Added DBUS service for simple text crypto
    operations
parent d042c0db
2006-04-12 Nate Nielsen <nielsen@memberwebs.com>
* daemon/Makefile.am:
* daemon/seahorse-daemon.c:
* daemon/seahorse-dbus-server.c:
* daemon/seahorse-service-crypto.c (added):
* daemon/seahorse-service-crypto.xml (added):
* daemon/seahorse-service.c:
* daemon/seahorse-service.h:
* libcryptui/cryptui-keyset.c:
* tests/dbus-test-crypto.py (added):
* tests/dbus-test.py: Added DBUS service for simple text crypto
operations
2006-04-12 Nate Nielsen <nielsen@memberwebs.com>
* libseahorse/seahorse-util.c: Fix memory leak in
......
......@@ -7,3 +7,5 @@ Makefile
seahorse-daemon
seahorse-service-bindings.h
seahorse-service-keyset-bindings.h
seahorse-service-crypto-bindings.h
......@@ -32,8 +32,9 @@ endif
if WITH_DBUS
DBUS_SRCS = seahorse-dbus-server.c seahorse-service.c seahorse-service.h
DBUS_SRCS += seahorse-service-keyset.c
DBUS_SRCS += seahorse-service-keyset.c seahorse-service-crypto.c
BUILT_SOURCES += seahorse-service-bindings.h seahorse-service-keyset-bindings.h
BUILT_SOURCES += seahorse-service-crypto-bindings.h
else
DBUS_SRCS =
endif
......@@ -64,6 +65,8 @@ 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)/$<
seahorse-service-crypto-bindings.h: seahorse-service-crypto.xml
dbus-binding-tool --prefix=seahorse_service_crypto --mode=glib-server --output=$@ $(srcdir)/$<
install-exec-hook:
chmod u+s $(DESTDIR)$(bindir)/seahorse-daemon
......@@ -24,13 +24,18 @@
#include "seahorse-service-bindings.h"
#include "seahorse-service-keyset-bindings.h"
#include "seahorse-service-crypto-bindings.h"
#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus.h>
#include <dbus/dbus-glib-bindings.h>
#include <dbus/dbus-glib-lowlevel.h>
#define APPLICATION_SERVICE_NAME "org.gnome.seahorse.KeyService"
#define APPLICATION_SERVICE_NAME "org.gnome.seahorse"
/* The main service object */
/* The main service objects */
SeahorseService *the_service = NULL;
SeahorseServiceCrypto *the_crypto = NULL;
DBusGConnection *connection = NULL;
void
......@@ -47,22 +52,24 @@ seahorse_dbus_server_init ()
if (connection == NULL) {
g_warning ("DBUS Service registration failed: %s", err ? err->message : "");
g_error_free (err);
return;
}
return;
}
dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (connection), FALSE);
driver_proxy = dbus_g_proxy_new_for_name (connection, DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
if (!org_freedesktop_DBus_request_name (driver_proxy, APPLICATION_SERVICE_NAME,
0, &request_name_result, &err)) {
g_warning ("DBUS Service name request failed.");
g_clear_error (&err);
}
if (!org_freedesktop_DBus_request_name (driver_proxy, APPLICATION_SERVICE_NAME,
0, &request_name_result, &err)) {
g_warning ("DBUS Service name request failed.");
g_clear_error (&err);
}
if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS) {
g_warning ("DBUS Service already started elsewhere");
return;
}
return;
}
dbus_g_object_type_install_info (SEAHORSE_TYPE_SERVICE,
......@@ -71,9 +78,16 @@ seahorse_dbus_server_init ()
dbus_g_object_type_install_info (SEAHORSE_TYPE_SERVICE_KEYSET,
&dbus_glib_seahorse_service_keyset_object_info);
dbus_g_object_type_install_info (SEAHORSE_TYPE_SERVICE_CRYPTO,
&dbus_glib_seahorse_service_crypto_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));
the_crypto = g_object_new (SEAHORSE_TYPE_SERVICE_CRYPTO, NULL);
dbus_g_connection_register_g_object (connection, "/org/gnome/seahorse/crypto",
G_OBJECT (the_crypto));
}
DBusGConnection*
......@@ -91,6 +105,10 @@ seahorse_dbus_server_cleanup ()
g_object_unref (the_service);
the_service = NULL;
if (the_crypto)
g_object_unref (the_crypto);
the_crypto = NULL;
if (connection)
dbus_g_connection_unref (connection);
connection = NULL;
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/org/gnome/seahorse/crypto">
<interface name="org.gnome.seahorse.CryptoService">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="seahorse_service_crypto"/>
<method name="EncryptText">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_crypto_encrypt_text"/>
<arg type="as" name="recipients" direction="in"/>
<arg type="s" name="signer" direction="in"/>
<arg type="i" name="flags" direction="in"/>
<arg type="s" name="cleartext" direction="in"/>
<arg type="s" name="crypttext" direction="out"/>
</method>
<method name="SignText">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_crypto_sign_text"/>
<arg type="s" name="signer" direction="in"/>
<arg type="i" name="flags" direction="in"/>
<arg type="s" name="cleartext" direction="in"/>
<arg type="s" name="crypttext" direction="out"/>
</method>
<method name="DecryptText">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_crypto_decrypt_text"/>
<arg type="i" name="flags" direction="in"/>
<arg type="s" name="crypttext" direction="in"/>
<arg type="s" name="cleartext" direction="out"/>
<arg type="s" name="signer" direction="out"/>
</method>
<method name="VerifyText">
<annotation name="org.freedesktop.DBus.GLib.CSymbol"
value="seahorse_service_crypto_verify_text"/>
<arg type="i" name="flags" direction="in"/>
<arg type="s" name="crypttext" direction="in"/>
<arg type="s" name="cleartext" direction="out"/>
<arg type="s" name="signer" direction="out"/>
</method>
</interface>
</node>
......@@ -149,12 +149,18 @@ seahorse_service_key_from_dbus (const gchar *key, guint *uid)
gchar*
seahorse_service_key_to_dbus (SeahorseKey *skey, guint uid)
{
if (uid == 0)
return g_strdup_printf ("%s:%s", g_quark_to_string (seahorse_key_get_ktype (skey)),
seahorse_key_get_keyid (skey));
return seahorse_service_keyid_to_dbus (seahorse_key_get_ktype (skey),
seahorse_key_get_keyid (skey), uid);
}
gchar*
seahorse_service_keyid_to_dbus (GQuark ktype, const gchar *keyid, guint uid)
{
if (uid == 0)
return g_strdup_printf ("%s:%s", g_quark_to_string (ktype), keyid);
else
return g_strdup_printf ("%s:%s:%d", g_quark_to_string (seahorse_key_get_ktype (skey)),
seahorse_key_get_keyid (skey), uid);
return g_strdup_printf ("%s:%s:%d", g_quark_to_string (ktype), keyid, uid);
}
/* -----------------------------------------------------------------------------
......
......@@ -32,6 +32,7 @@ G_BEGIN_DECLS
/* TODO: This needs to be refined */
enum {
SEAHORSE_DBUS_ERROR_INVALID = 1,
SEAHORSE_DBUS_ERROR_CRYPTO = 2,
SEAHORSE_DBUS_ERROR_NOTIMPLEMENTED = 100
};
......@@ -101,6 +102,12 @@ SeahorseKey* seahorse_service_key_from_dbus (const gchar *key, guint *ui
gchar* seahorse_service_key_to_dbus (SeahorseKey *skey, guint uid);
gchar* seahorse_service_keyid_to_dbus (GQuark ktype, const gchar *keyid, guint uid);
/* -----------------------------------------------------------------------------
* KEYSET SERVICE
*/
typedef struct _SeahorseServiceKeyset SeahorseServiceKeyset;
typedef struct _SeahorseServiceKeysetClass SeahorseServiceKeysetClass;
......@@ -137,6 +144,53 @@ SeahorseKeyset* seahorse_service_keyset_new (GQuark keytype);
gboolean seahorse_service_keyset_list_keys (SeahorseServiceKeyset *keyset,
gchar ***keys, GError **error);
/* -----------------------------------------------------------------------------
* CRYPTO SERVICE
*/
typedef struct _SeahorseServiceCrypto SeahorseServiceCrypto;
typedef struct _SeahorseServiceCryptoClass SeahorseServiceCryptoClass;
#define SEAHORSE_TYPE_SERVICE_CRYPTO (seahorse_service_crypto_get_type ())
#define SEAHORSE_SERVICE_CRYPTO(object) (G_TYPE_CHECK_INSTANCE_CAST((object), SEAHORSE_TYPE_SERVICE_CRYPTO, SeahorseServiceCrypto))
#define SEAHORSE_SERVICE_CRYPTO_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), SEAHORSE_TYPE_SERVICE_CRYPTO, SeahorseServiceCryptoClass))
#define SEAHORSE_IS_SERVICE_CRYPTO(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), SEAHORSE_TYPE_SERVICE_CRYPTO))
#define SEAHORSE_IS_SERVICE_CRYPTO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SEAHORSE_TYPE_SERVICE_CRYPTO))
#define SEAHORSE_SERVICE_CRYPTO_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), SEAHORSE_TYPE_SERVICE_CRYPTO, SeahorseServiceCryptoClass))
struct _SeahorseServiceCrypto {
GObject base;
};
struct _SeahorseServiceCryptoClass {
GObjectClass base;
};
GType seahorse_service_crypto_get_type (void);
SeahorseServiceCrypto* seahorse_service_crypto_new ();
gboolean seahorse_service_crypto_encrypt_text (SeahorseServiceCrypto *crypto,
const char **recipients,
const char *signer, int flags,
const char *cleartext,
char **crypttext, GError **error);
gboolean seahorse_service_crypto_sign_text (SeahorseServiceCrypto *crypto,
const char *signer, int flags,
const char *cleartext,
char **crypttext, GError **error);
gboolean seahorse_service_crypto_decrypt_text (SeahorseServiceCrypto *crypto,
int flags, const char *crypttext,
char **cleartext, char **signer,
GError **error);
gboolean seahorse_service_crypto_verify_text (SeahorseServiceCrypto *crypto,
int flags, const char *crypttext,
char **cleartext, char **signer,
GError **error);
G_END_DECLS
#endif /* __SEAHORSE_SERVICE_H__ */
......@@ -237,9 +237,9 @@ cryptui_keyset_constructor (GType type, guint n_props, GObjectConstructParam* pr
path = g_strdup_printf("/org/gnome/seahorse/keys/%s", keyset->priv->keytype);
keyset->priv->remote_keyset = dbus_g_proxy_new_for_name (bus,
"org.gnome.seahorse.KeyService", path, "org.gnome.seahorse.Keys");
"org.gnome.seahorse", path, "org.gnome.seahorse.Keys");
keyset->priv->remote_service = dbus_g_proxy_new_for_name (bus,
"org.gnome.seahorse.KeyService", "/org/gnome/seahorse/keys", "org.gnome.seahorse.KeyService");
"org.gnome.seahorse", "/org/gnome/seahorse/keys", "org.gnome.seahorse.KeyService");
g_free (path);
......
Makefile
Makefile.in
cryptui-test-keyset
cryptui-test-ui
*.o
2006-04-12 Nate Nielsen <nielsen@memberwebs.com>
POTFILES.in Added daemon/seahorse-service-crypto.c
2006-03-25 Nate Nielsen <nielsen@memberwebs.com>
POTFILES.in Added src/seahorse-photos.c
......
......@@ -9,6 +9,7 @@ agent/seahorse-agent.c
bonobo/Seahorse_PGP_File_Listener.server.in.in
daemon/seahorse-daemon.c
daemon/seahorse-service.c
daemon/seahorse-service-crypto.c
daemon/seahorse-sharing.c
data/seahorse.schemas.in
libseahorse/eggtrayicon.c
......
#!/usr/bin/python
import dbus
bus = dbus.SessionBus()
proxy_obj = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
dbus_iface = dbus.Interface(proxy_obj, 'org.freedesktop.DBus')
print "\n\nSEAHORSE DBUS CALL ------------------------------------"
proxy_obj = bus.get_object('org.gnome.seahorse', '/org/gnome/seahorse/crypto')
service = dbus.Interface(proxy_obj, 'org.gnome.seahorse.CryptoService')
#encrypted = service.EncryptText(["openpgp:78C25AFC0BEE1BAD", "openpgp:FAD3A86D2505A4D5"], "openpgp:78C25AFC0BEE1BAD", 123, "cleartext")
#print "Encrypted: ", encrypted
#(decrypted, signer) = service.DecryptText(123, encrypted)
#print "Decrypted: ", decrypted
#print "Signer: ", signer
signed = service.SignText("openpgp:78C25AFC0BEE1BAD", 123, "cleartext")
print "Signed: ", signed
(verified, signer) = service.VerifyText(123, signed)
print "Verified: ", verified
print "Signer: ", signer
......@@ -11,7 +11,7 @@ print dbus_iface.ListNames()
print "\n\nSEAHORSE DBUS CALL ------------------------------------"
proxy_obj = bus.get_object('org.gnome.seahorse.KeyService', '/org/gnome/seahorse/keys')
proxy_obj = bus.get_object('org.gnome.seahorse', '/org/gnome/seahorse/keys')
service = dbus.Interface(proxy_obj, 'org.gnome.seahorse.KeyService')
types = service.GetKeyTypes()
......@@ -24,7 +24,7 @@ if not len(types):
path = service.GetKeyset(types[0])
print "GetKeySet(): ", path
proxy_obj = bus.get_object('org.gnome.seahorse.KeyService', path)
proxy_obj = bus.get_object('org.gnome.seahorse', path)
keyset = dbus.Interface(proxy_obj, "org.gnome.seahorse.Keys")
keys = keyset.ListKeys()
......
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