seahorse r2192 - in trunk: . common daemon gkr libseahorse pgp src ssh
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2192 - in trunk: . common daemon gkr libseahorse pgp src ssh
- Date: Tue, 29 Apr 2008 02:59:53 +0100 (BST)
Author: nnielsen
Date: Tue Apr 29 01:59:52 2008
New Revision: 2192
URL: http://svn.gnome.org/viewvc/seahorse?rev=2192&view=rev
Log:
* Refactoring: Remove gnome-vfs dependency. Use gio instead.
Remove most of the hard dependency on gpgme.
Added:
trunk/gkr/seahorse-gkr.c
trunk/gkr/seahorse-gkr.h
trunk/pgp/seahorse-gpgme-io.c
trunk/pgp/seahorse-gpgme-io.h
trunk/pgp/seahorse-pgp-dialogs.h
- copied, changed from r2188, /trunk/pgp/sea-pgp-dialogs.h
trunk/pgp/seahorse-pgp-error.c
Removed:
trunk/libseahorse/seahorse-vfs-data.c
trunk/libseahorse/seahorse-vfs-data.h
trunk/pgp/sea-pgp-dialogs.h
Modified:
trunk/ChangeLog
trunk/INSTALL
trunk/common/sea-registry.c
trunk/common/sea-registry.h
trunk/configure.in
trunk/daemon/seahorse-daemon.c
trunk/daemon/seahorse-service-crypto.c
trunk/daemon/seahorse-service.c
trunk/gkr/Makefile.am
trunk/gkr/seahorse-gkeyring-item.c
trunk/gkr/seahorse-gkeyring-item.h
trunk/gkr/seahorse-gkeyring-operation.c
trunk/gkr/seahorse-gkeyring-source.c
trunk/gkr/seahorse-gkeyring-source.h
trunk/libseahorse/Makefile.am
trunk/libseahorse/seahorse-key-source.c
trunk/libseahorse/seahorse-key-source.h
trunk/libseahorse/seahorse-passphrase.c
trunk/libseahorse/seahorse-passphrase.h
trunk/libseahorse/seahorse-prefs-keyrings.c
trunk/libseahorse/seahorse-transfer-operation.c
trunk/libseahorse/seahorse-unknown-source.c
trunk/libseahorse/seahorse-util.c
trunk/libseahorse/seahorse-util.h
trunk/pgp/Makefile.am
trunk/pgp/seahorse-gpg-options.c
trunk/pgp/seahorse-gpgmex-util.c
trunk/pgp/seahorse-gpgmex.h
trunk/pgp/seahorse-hkp-source.c
trunk/pgp/seahorse-ldap-source.c
trunk/pgp/seahorse-pgp-operation.c
trunk/pgp/seahorse-pgp-source.c
trunk/pgp/seahorse-pgp-source.h
trunk/pgp/seahorse-server-source.c
trunk/pgp/seahorse-server-source.h
trunk/src/Makefile.am
trunk/src/main.c
trunk/src/seahorse-add-subkey.c
trunk/src/seahorse-add-uid.c
trunk/src/seahorse-delete.c
trunk/src/seahorse-expires.c
trunk/src/seahorse-key-manager-store.c
trunk/src/seahorse-key-manager.c
trunk/src/seahorse-key-properties.c
trunk/src/seahorse-keyserver-results.c
trunk/src/seahorse-keyserver-search.c
trunk/src/seahorse-keyserver-sync.c
trunk/src/seahorse-pgp-generate.c
trunk/src/seahorse-photos.c
trunk/src/seahorse-revoke.c
trunk/src/seahorse-sign.c
trunk/src/seahorse-ssh-key-properties.c
trunk/ssh/ (props changed)
trunk/ssh/seahorse-ssh-operation.c
trunk/ssh/seahorse-ssh-source.c
Modified: trunk/INSTALL
==============================================================================
--- trunk/INSTALL (original)
+++ trunk/INSTALL Tue Apr 29 01:59:52 2008
@@ -11,7 +11,7 @@
Seahorse. You may need to install 'devel' or 'dev' versions of these packages
if your distro requires this.
- - GTK 2.10 (or a later 2.x version)
+ - GTK 2.16 (or a later 2.x version)
- DBUS 0.35 (or later)
- GPGME 1.x
- GnuPG 1.2.x or 1.4.x
@@ -19,7 +19,6 @@
- libgnomeui 2.x
- libglade 2.x
- GConf 2.x
- - GnomeVFS 2.x
- gnome-keyring 2.19.4 (or later)
Optional Dependencies
@@ -30,16 +29,10 @@
to install 'devel' or 'dev' versions of these packages if your distro requires.
- OpenLDAP 2.x (client libraries)
- - Gedit 2.6 (or later 2.x version)
- - libnautilus-extension 2.9 (or a later 2.x version)
- - gnome-keyring
- libsoup 2.4
- - libpanelapplet
- Avahi 0.6 (or later)
- libnotify 0.3 (or later)
- OpenSSH
- - Gecko (from Firefox 1.5 or later)
- - Epiphany 2.14 (or later)
A summary of which features are enabled will be displayed after you run
'./configure' (see below).
Modified: trunk/common/sea-registry.c
==============================================================================
--- trunk/common/sea-registry.c (original)
+++ trunk/common/sea-registry.c Tue Apr 29 01:59:52 2008
@@ -163,7 +163,7 @@
}
void
-sea_registry_load_types (SeaRegistry *registry, SeaRegisterType *types)
+sea_registry_load_types (SeaRegistry *registry, const SeaRegisterType *types)
{
GType type;
gpointer klass;
@@ -174,6 +174,8 @@
klass = g_type_class_ref (type);
g_type_class_unref (klass);
+
+ ++types;
}
}
Modified: trunk/common/sea-registry.h
==============================================================================
--- trunk/common/sea-registry.h (original)
+++ trunk/common/sea-registry.h Tue Apr 29 01:59:52 2008
@@ -31,7 +31,7 @@
SeaRegistry* sea_registry_get (void);
void sea_registry_load_types (SeaRegistry *registry,
- SeaRegisterType *types);
+ const SeaRegisterType *types);
void sea_registry_register_type (SeaRegistry *registry,
GType type, const gchar *category,
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue Apr 29 01:59:52 2008
@@ -41,8 +41,8 @@
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
-PKG_CHECK_MODULES(SEAHORSE, libgnome-2.0 >= 2.14 libgnomeui-2.0
- libglade-2.0 gconf-2.0 gtk+-2.0 >= 2.10.0 gnome-vfs-2.0)
+PKG_CHECK_MODULES(SEAHORSE, libgnome-2.0 >= 2.14 libgnomeui-2.0
+ libglade-2.0 gconf-2.0 gtk+-2.0 >= 2.10.0 gio-2.0)
AC_MSG_CHECKING([for some Win32 platform])
case "$host" in
Modified: trunk/daemon/seahorse-daemon.c
==============================================================================
--- trunk/daemon/seahorse-daemon.c (original)
+++ trunk/daemon/seahorse-daemon.c Tue Apr 29 01:59:52 2008
@@ -19,6 +19,26 @@
* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
+#include "seahorse-context.h"
+#include "seahorse-daemon.h"
+#include "seahorse-gconf.h"
+#include "seahorse-gtkstock.h"
+#include "seahorse-secure-memory.h"
+#include "seahorse-unix-signal.h"
+
+#include "common/sea-cleanup.h"
+#include "common/sea-registry.h"
+
+#include "pgp/sea-pgp.h"
+
+#ifdef WITH_SSH
+#include "ssh/sea-ssh.h"
+#endif
+
+#include <gnome.h>
+
#include <sys/types.h>
#include <sys/signal.h>
@@ -30,16 +50,6 @@
#include <syslog.h>
#include <fcntl.h>
-#include <gnome.h>
-
-#include "config.h"
-#include "seahorse-daemon.h"
-#include "seahorse-secure-memory.h"
-#include "seahorse-gconf.h"
-#include "seahorse-gtkstock.h"
-#include "seahorse-context.h"
-#include "seahorse-unix-signal.h"
-
static gboolean daemon_no_daemonize = FALSE;
static gboolean daemon_running = FALSE;
static gboolean daemon_quit = FALSE;
@@ -212,6 +222,10 @@
seahorse_gtkstock_init ();
seahorse_gtkstock_add_icons (daemon_icons);
+ /* Load the various components */
+ sea_registry_load_types (NULL, SEA_PGP_REGISTRY);
+ sea_registry_load_types (NULL, SEA_SSH_REGISTRY);
+
/* Make the default SeahorseContext */
seahorse_context_new (SEAHORSE_CONTEXT_APP | SEAHORSE_CONTEXT_DAEMON, 0);
op = seahorse_context_load_local_keys (SCTX_APP ());
@@ -239,6 +253,7 @@
seahorse_dbus_server_cleanup ();
seahorse_context_destroy (SCTX_APP ());
+ sea_cleanup_perform ();
return 0;
}
Modified: trunk/daemon/seahorse-service-crypto.c
==============================================================================
--- trunk/daemon/seahorse-service-crypto.c (original)
+++ trunk/daemon/seahorse-service-crypto.c Tue Apr 29 01:59:52 2008
@@ -19,7 +19,7 @@
* Boston, MA 02111-1307, USA.
*/
-#include <glib.h>
+#include "config.h"
#include "seahorse-service.h"
#include "seahorse-key.h"
@@ -27,9 +27,12 @@
#include "seahorse-util.h"
#include "seahorse-libdialogs.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key.h"
#include "pgp/seahorse-pgp-operation.h"
+#include <glib.h>
+
/* flags from seahorse-service-cyrpto.xml */
#define FLAG_QUIET 0x01
@@ -173,7 +176,7 @@
return;
default:
if (!GPG_IS_OK (status->signatures->status))
- seahorse_util_handle_gpgme (status->signatures->status,
+ seahorse_pgp_handle_gpgme_error (status->signatures->status,
_("Couldn't verify signature."));
return;
};
@@ -303,7 +306,7 @@
plain, cipher);
}
- seahorse_util_free_keys (recips);
+ gpgmex_free_keys (recips);
/* Frees cipher */
ret = process_crypto_result (pop, gerr, cipher, crypttext, error);
Modified: trunk/daemon/seahorse-service.c
==============================================================================
--- trunk/daemon/seahorse-service.c (original)
+++ trunk/daemon/seahorse-service.c Tue Apr 29 01:59:52 2008
@@ -32,6 +32,8 @@
#include "pgp/seahorse-gpgmex.h"
+#include <gio/gio.h>
+
#define KEYSET_PATH "/org/gnome/seahorse/keys/%s"
#define KEYSET_PATH_LOCAL "/org/gnome/seahorse/keys/%s/local"
@@ -115,8 +117,7 @@
{
SeahorseKeySource *sksrc;
SeahorseOperation *op;
- gpgme_data_t gdata;
- gpgme_error_t gerr;
+ GInputStream *input;
GArray *a;
GList *l;
gchar *t;
@@ -130,14 +131,11 @@
return FALSE;
}
- /* TODO: We should be doing base64 on these */
- gerr = gpgme_data_new_from_mem (&gdata, data, strlen (data), 0);
- if (!GPG_IS_OK (gerr)) {
- seahorse_util_gpgme_to_error (gerr, error);
- return FALSE;
- }
+ /* TODO: We should be doing base64 on these */
+ input = g_memory_input_stream_new_from_data (data, strlen (data), NULL);
+ g_return_val_if_fail (input, FALSE);
- op = seahorse_key_source_import (sksrc, gdata);
+ op = seahorse_key_source_import (sksrc, G_INPUT_STREAM (input));
seahorse_operation_wait (op);
a = g_array_new (TRUE, TRUE, sizeof (gchar*));
@@ -150,11 +148,13 @@
*keys = (gchar**)g_array_free (a, FALSE);
- if (keynum > 0)
- seahorse_notify_import (keynum, *keys);
+ if (keynum > 0)
+ seahorse_notify_import (keynum, *keys);
- g_object_unref (op);
- return TRUE;
+ g_object_unref (op);
+ g_object_unref (input);
+
+ return TRUE;
}
gboolean
@@ -164,25 +164,17 @@
SeahorseKeySource *sksrc;
SeahorseOperation *op;
SeahorseKey *skey;
- gpgme_data_t gdata;
- gpgme_error_t gerr;
+ GMemoryOutputStream *output;
GList *next;
GList *l = NULL;
GQuark type;
type = g_quark_from_string (ktype);
- gerr = gpgme_data_new (&gdata);
- if (!GPG_IS_OK (gerr)) {
- seahorse_util_gpgme_to_error (gerr, error);
- return FALSE;
- }
-
while (*keys) {
skey = seahorse_context_key_from_dbus (SCTX_APP (), *keys, 0);
if (!skey || seahorse_key_get_ktype (skey) != type) {
- gpgme_data_release (gdata);
g_set_error (error, SEAHORSE_DBUS_ERROR, SEAHORSE_DBUS_ERROR_INVALID,
_("Invalid or unrecognized key: %s"), *keys);
return FALSE;
@@ -192,6 +184,9 @@
keys++;
}
+ output = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (NULL, 0, g_realloc, NULL));
+ g_return_val_if_fail (output, FALSE);
+
/* Sort by key source */
l = seahorse_util_keylist_sort (l);
@@ -207,7 +202,7 @@
g_return_val_if_fail (sksrc != NULL, FALSE);
/* We pass our own data object, to which data is appended */
- op = seahorse_key_source_export (sksrc, l, FALSE, gdata);
+ op = seahorse_key_source_export (sksrc, l, FALSE, G_OUTPUT_STREAM (output));
g_return_val_if_fail (op != NULL, FALSE);
g_list_free (l);
@@ -223,7 +218,7 @@
seahorse_operation_copy_error (op, error);
g_object_unref (op);
- gpgme_data_release (gdata);
+ g_object_unref (output);
return FALSE;
}
@@ -231,8 +226,10 @@
}
/* TODO: We should be base64 encoding this */
- *data = seahorse_util_write_data_to_text (gdata, NULL);
- gpgmex_data_release (gdata);
+ *data = g_memory_output_stream_get_data (output);
+
+ /* The above pointer is not freed, because we passed null to g_memory_output_stream_new() */
+ g_object_unref (output);
return TRUE;
}
Modified: trunk/gkr/Makefile.am
==============================================================================
--- trunk/gkr/Makefile.am (original)
+++ trunk/gkr/Makefile.am Tue Apr 29 01:59:52 2008
@@ -14,10 +14,15 @@
-DEXECDIR=\""$(seahorselibexecbindir)"\" \
-DLIBCRYPTUI_API_SUBJECT_TO_CHANGE
-noinst_LTLIBRARIES = libsea-gkr.la
+noinst_LTLIBRARIES = libseahorse-gkr.la
-libsea_gkr_la_SOURCES = \
+libseahorse_gkr_la_SOURCES = \
+ seahorse-gkr.c seahorse-gkr.h \
seahorse-gkeyring-item.c seahorse-gkeyring-item.h \
seahorse-gkeyring-source.c seahorse-gkeyring-source.h \
seahorse-gkeyring-operation.c seahorse-gkeyring-operation.h
-
\ No newline at end of file
+
+libseahorse_gkr_la_LIBADD = \
+ $(top_builddir)/libseahorse/libseahorse.la \
+ $(top_builddir)/common/libsea-common.la \
+ $(top_builddir)/libcryptui/libcryptui.la
Modified: trunk/gkr/seahorse-gkeyring-item.c
==============================================================================
--- trunk/gkr/seahorse-gkeyring-item.c (original)
+++ trunk/gkr/seahorse-gkeyring-item.c Tue Apr 29 01:59:52 2008
@@ -239,7 +239,7 @@
skey->loaded = (secret == NULL) ? SKEY_INFO_BASIC : SKEY_INFO_COMPLETE;
g_free (secret);
- skey->ktype = SKEY_GKEYRING;
+ skey->ktype = SEAHORSE_GKR;
skey->location = SKEY_LOC_LOCAL;
skey->etype = SKEY_CREDENTIALS;
skey->flags = 0;
@@ -588,10 +588,10 @@
GQuark
seahorse_gkeyring_item_get_cannonical (guint32 item_id)
{
- #define BUF_LEN (G_N_ELEMENTS (SKEY_GKEYRING_STR) + 16)
+ #define BUF_LEN (G_N_ELEMENTS (SEAHORSE_GKR_STR) + 16)
gchar buf[BUF_LEN];
- snprintf(buf, BUF_LEN - 1, "%s:%08X", SKEY_GKEYRING_STR, item_id);
+ snprintf(buf, BUF_LEN - 1, "%s:%08X", SEAHORSE_GKR_STR, item_id);
buf[BUF_LEN - 1] = 0;
return g_quark_from_string (buf);
}
Modified: trunk/gkr/seahorse-gkeyring-item.h
==============================================================================
--- trunk/gkr/seahorse-gkeyring-item.h (original)
+++ trunk/gkr/seahorse-gkeyring-item.h Tue Apr 29 01:59:52 2008
@@ -42,7 +42,10 @@
#include <gtk/gtk.h>
#include <gnome-keyring.h>
+#include "seahorse-gkr.h"
+
#include "seahorse-key.h"
+#include "seahorse-key-source.h"
typedef enum {
SEAHORSE_GKEYRING_USE_OTHER,
@@ -52,9 +55,6 @@
SEAHORSE_GKEYRING_USE_SSH,
} SeahorseGKeyringUse;
-#define SKEY_GKEYRING_STR "gnome-keyring"
-#define SKEY_GKEYRING (g_quark_from_static_string (SKEY_GKEYRING_STR))
-
#define SEAHORSE_TYPE_GKEYRING_ITEM (seahorse_gkeyring_item_get_type ())
#define SEAHORSE_GKEYRING_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_GKEYRING_ITEM, SeahorseGKeyringItem))
#define SEAHORSE_GKEYRING_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_GKEYRING_ITEM, SeahorseGKeyringItemClass))
Modified: trunk/gkr/seahorse-gkeyring-operation.c
==============================================================================
--- trunk/gkr/seahorse-gkeyring-operation.c (original)
+++ trunk/gkr/seahorse-gkeyring-operation.c Tue Apr 29 01:59:52 2008
@@ -29,8 +29,6 @@
#include "seahorse-util.h"
#include "seahorse-passphrase.h"
-#include "pgp/seahorse-gpgmex.h"
-
#include <gnome-keyring.h>
#ifndef DEBUG_OPERATION_ENABLE
Modified: trunk/gkr/seahorse-gkeyring-source.c
==============================================================================
--- trunk/gkr/seahorse-gkeyring-source.c (original)
+++ trunk/gkr/seahorse-gkeyring-source.c Tue Apr 29 01:59:52 2008
@@ -542,7 +542,7 @@
g_value_set_string (value, gsrc->pv->keyring_name);
break;
case PROP_KEY_TYPE:
- g_value_set_uint (value, SKEY_GKEYRING);
+ g_value_set_uint (value, SEAHORSE_GKR);
break;
case PROP_KEY_DESC:
g_value_set_string (value, _("Password"));
@@ -611,24 +611,30 @@
static SeahorseOperation*
-seahorse_gkeyring_source_import (SeahorseKeySource *sksrc, gpgme_data_t data)
+seahorse_gkeyring_source_import (SeahorseKeySource *sksrc, GInputStream *input)
{
- GError *err = NULL;
-
- /* TODO: Implement properly */
- g_set_error (&err, 0, 0, "gnome-keyring import support not implemented");
- return seahorse_operation_new_complete (err);
+ GError *err = NULL;
+
+ g_return_val_if_fail (SEAHORSE_IS_GKEYRING_SOURCE (sksrc), NULL);
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
+
+ /* TODO: Implement properly */
+ g_set_error (&err, 0, 0, "gnome-keyring import support not implemented");
+ return seahorse_operation_new_complete (err);
}
static SeahorseOperation*
seahorse_gkeyring_source_export (SeahorseKeySource *sksrc, GList *keys,
- gboolean complete, gpgme_data_t data)
+ gboolean complete, GOutputStream *output)
{
- GError *err = NULL;
+ GError *err = NULL;
+
+ g_return_val_if_fail (SEAHORSE_IS_GKEYRING_SOURCE (sksrc), NULL);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), NULL);
- /* TODO: Implement properly */
- g_set_error (&err, 0, 0, "gnome-keyring export support not implemented");
- return seahorse_operation_new_complete (err);
+ /* TODO: Implement properly */
+ g_set_error (&err, 0, 0, "gnome-keyring export support not implemented");
+ return seahorse_operation_new_complete (err);
}
static gboolean
@@ -743,7 +749,7 @@
0, G_MAXUINT, SKEY_LOC_INVALID, G_PARAM_READABLE));
- sea_registry_register_type (NULL, SEAHORSE_TYPE_GKEYRING_SOURCE, "key-source", "local", SKEY_GKEYRING_STR, NULL);
+ sea_registry_register_type (NULL, SEAHORSE_TYPE_GKEYRING_SOURCE, "key-source", "local", SEAHORSE_GKR_STR, NULL);
}
/* --------------------------------------------------------------------------
Modified: trunk/gkr/seahorse-gkeyring-source.h
==============================================================================
--- trunk/gkr/seahorse-gkeyring-source.h (original)
+++ trunk/gkr/seahorse-gkeyring-source.h Tue Apr 29 01:59:52 2008
@@ -26,7 +26,7 @@
* - Adds the keys it loads to the SeahorseContext.
*
* Properties:
- * ktype: (GQuark) The ktype (ie: SKEY_GKEYRING) of keys originating from this
+ * ktype: (GQuark) The ktype (ie: SEAHORSE_GKR) of keys originating from this
key source.
* location: (SeahorseKeyLoc) The location of keys that come from this
* source. (ie: SKEY_LOC_LOCAL)
Added: trunk/gkr/seahorse-gkr.c
==============================================================================
--- (empty file)
+++ trunk/gkr/seahorse-gkr.c Tue Apr 29 01:59:52 2008
@@ -0,0 +1,11 @@
+
+#include "config.h"
+
+#include "seahorse-gkr.h"
+
+#include "seahorse-gkeyring-source.h"
+
+const SeaRegisterType SEAHORSE_GKR_REGISTRY[] = {
+ seahorse_gkeyring_source_get_type,
+ NULL
+};
Added: trunk/gkr/seahorse-gkr.h
==============================================================================
--- (empty file)
+++ trunk/gkr/seahorse-gkr.h Tue Apr 29 01:59:52 2008
@@ -0,0 +1,11 @@
+#ifndef SEAHORSEGKR_H_
+#define SEAHORSEGKR_H_
+
+#include "common/sea-registry.h"
+
+#define SEAHORSE_GKR_STR "gnome-keyring"
+#define SEAHORSE_GKR (g_quark_from_static_string (SEAHORSE_GKR_STR))
+
+extern const SeaRegisterType SEAHORSE_GKR_REGISTRY[];
+
+#endif /*SEAHORSEGKR_H_*/
Modified: trunk/libseahorse/Makefile.am
==============================================================================
--- trunk/libseahorse/Makefile.am (original)
+++ trunk/libseahorse/Makefile.am Tue Apr 29 01:59:52 2008
@@ -41,7 +41,6 @@
seahorse-combo-keys.c seahorse-combo-keys.h \
seahorse-passphrase.c seahorse-passphrase.h \
seahorse-libdialogs.h \
- seahorse-vfs-data.c seahorse-vfs-data.h \
seahorse-prefs.c seahorse-prefs.h \
seahorse-prefs-keyrings.c \
seahorse-operation.c seahorse-operation.h \
Modified: trunk/libseahorse/seahorse-key-source.c
==============================================================================
--- trunk/libseahorse/seahorse-key-source.c (original)
+++ trunk/libseahorse/seahorse-key-source.c Tue Apr 29 01:59:52 2008
@@ -182,51 +182,52 @@
}
SeahorseOperation*
-seahorse_key_source_import (SeahorseKeySource *sksrc, gpgme_data_t data)
+seahorse_key_source_import (SeahorseKeySource *sksrc, GInputStream *input)
{
- SeahorseKeySourceClass *klass;
+ SeahorseKeySourceClass *klass;
+
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
- g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (sksrc), NULL);
- klass = SEAHORSE_KEY_SOURCE_GET_CLASS (sksrc);
- g_return_val_if_fail (klass->import != NULL, NULL);
+ g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (sksrc), NULL);
+ klass = SEAHORSE_KEY_SOURCE_GET_CLASS (sksrc);
+ g_return_val_if_fail (klass->import != NULL, NULL);
- return (*klass->import) (sksrc, data);
+ return (*klass->import) (sksrc, input);
}
gboolean
-seahorse_key_source_import_sync (SeahorseKeySource *sksrc, gpgme_data_t data,
+seahorse_key_source_import_sync (SeahorseKeySource *sksrc, GInputStream *input,
GError **err)
{
- SeahorseOperation *op;
- gboolean ret;
+ SeahorseOperation *op;
+ gboolean ret;
- op = seahorse_key_source_import (sksrc, data);
- g_return_val_if_fail (op != NULL, FALSE);
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
+
+ op = seahorse_key_source_import (sksrc, input);
+ g_return_val_if_fail (op != NULL, FALSE);
- seahorse_operation_wait (op);
- ret = seahorse_operation_is_successful (op);
- if (!ret)
- seahorse_operation_copy_error (op, err);
+ seahorse_operation_wait (op);
+ ret = seahorse_operation_is_successful (op);
+ if (!ret)
+ seahorse_operation_copy_error (op, err);
- g_object_unref (op);
- return ret;
+ g_object_unref (op);
+ return ret;
}
SeahorseOperation*
-seahorse_key_source_export_keys (GList *keys, gpgme_data_t data)
+seahorse_key_source_export_keys (GList *keys, GOutputStream *output)
{
SeahorseOperation *op = NULL;
SeahorseMultiOperation *mop = NULL;
SeahorseKeySource *sksrc;
SeahorseKey *skey;
- gboolean allocated = FALSE;
GList *next;
- if (!data) {
- data = gpgmex_data_new ();
- allocated = TRUE;
- }
-
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), NULL);
+ g_object_ref (output);
+
/* Sort by key source */
keys = g_list_copy (keys);
keys = seahorse_util_keylist_sort (keys);
@@ -250,7 +251,7 @@
}
/* We pass our own data object, to which data is appended */
- op = seahorse_key_source_export (sksrc, keys, FALSE, data);
+ op = seahorse_key_source_export (sksrc, keys, FALSE, output);
g_return_val_if_fail (op != NULL, FALSE);
g_list_free (keys);
@@ -264,8 +265,7 @@
* Setup the result data properly, as we would if it was a
* single export operation.
*/
- seahorse_operation_mark_result (op, data,
- allocated ? (GDestroyNotify)gpgmex_data_release : NULL);
+ seahorse_operation_mark_result (op, output, g_object_unref);
}
if (!op)
@@ -276,62 +276,66 @@
SeahorseOperation*
seahorse_key_source_export (SeahorseKeySource *sksrc, GList *keys,
- gboolean complete, gpgme_data_t data)
+ gboolean complete, GOutputStream *output)
{
- 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, GUINT_TO_POINTER (seahorse_key_get_keyid (l->data)));
-
- keyids = g_slist_reverse (keyids);
- op = (*klass->export_raw) (sksrc, keyids, data);
- g_slist_free (keyids);
- return op;
-
+ SeahorseKeySourceClass *klass;
+ SeahorseOperation *op;
+ GSList *keyids = NULL;
+ GList *l;
+
+ g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (sksrc), NULL);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), NULL);
+
+ klass = SEAHORSE_KEY_SOURCE_GET_CLASS (sksrc);
+ if (klass->export)
+ return (*klass->export) (sksrc, keys, complete, output);
+
+ /* 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, GUINT_TO_POINTER (seahorse_key_get_keyid (l->data)));
+
+ keyids = g_slist_reverse (keyids);
+ op = (*klass->export_raw) (sksrc, keyids, output);
+ g_slist_free (keyids);
+ return op;
}
SeahorseOperation*
seahorse_key_source_export_raw (SeahorseKeySource *sksrc, GSList *keyids,
- gpgme_data_t data)
+ GOutputStream *output)
{
- 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);
+ SeahorseKeySourceClass *klass;
+ SeahorseOperation *op;
+ SeahorseKey *skey;
+ GList *keys = NULL;
+ gboolean owned = FALSE;
+ GSList *l;
+
+ g_return_val_if_fail (SEAHORSE_IS_KEY_SOURCE (sksrc), NULL);
+ g_return_val_if_fail (output == NULL || G_IS_OUTPUT_STREAM (output), 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, output);
- g_return_val_if_fail (klass->export != NULL, NULL);
+ 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, GPOINTER_TO_UINT (l->data));
+ for (l = keyids; l; l = g_slist_next (l)) {
+ skey = seahorse_context_get_key (SCTX_APP (), sksrc, GPOINTER_TO_UINT (l->data));
- /* TODO: A proper error message here 'not found' */
- if (skey)
- keys = g_list_prepend (keys, skey);
- }
-
- keys = g_list_reverse (keys);
- op = (*klass->export) (sksrc, keys, FALSE, data);
- g_list_free (keys);
- return op;
+ /* TODO: A proper error message here 'not found' */
+ if (skey)
+ keys = g_list_prepend (keys, skey);
+ }
+
+ keys = g_list_reverse (keys);
+ op = (*klass->export) (sksrc, keys, FALSE, output);
+ g_list_free (keys);
+ return op;
}
gboolean
Modified: trunk/libseahorse/seahorse-key-source.h
==============================================================================
--- trunk/libseahorse/seahorse-key-source.h (original)
+++ trunk/libseahorse/seahorse-key-source.h Tue Apr 29 01:59:52 2008
@@ -42,12 +42,11 @@
#ifndef __SEAHORSE_KEY_SOURCE_H__
#define __SEAHORSE_KEY_SOURCE_H__
-#include <gnome.h>
-
#include "seahorse-key.h"
#include "seahorse-operation.h"
-#include "pgp/seahorse-gpgmex.h"
+#include <gio/gio.h>
+#include <glib-object.h>
#define SEAHORSE_TYPE_KEY_SOURCE (seahorse_key_source_get_type ())
#define SEAHORSE_KEY_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_KEY_SOURCE, SeahorseKeySource))
@@ -117,43 +116,43 @@
/**
* import
* @sksrc: The #SeahorseKeySource to import into.
- * @data: The data to import (takes ownership).
+ * @input: The data to import.
*
* Import keys into the key source. When operation is 'done' a GList of
* updated keys may be found as the operation result.
*
* Returns: The import operation
*/
- SeahorseOperation* (*import) (SeahorseKeySource *sksrc, gpgme_data_t data);
+ SeahorseOperation* (*import) (SeahorseKeySource *sksrc, GInputStream *input);
/**
* export
* @sksrc: The #SeahorseKeySource to export from.
* @keys: A list of keys to export.
* @complete: Whether to export the secret key too.
- * @data: Optional data object to export to (not freed).
+ * @data: Output stream to export to.
*
* Import keys into the key source. When operation is 'done' the result
- * of the operation will be a gpgme_data_t
+ * of the operation will be a GOutputStream
*
* Returns: The export operation
*/
SeahorseOperation* (*export) (SeahorseKeySource *sksrc, GList *keys,
- gboolean complete, gpgme_data_t data);
+ gboolean complete, GOutputStream *output);
/**
* 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).
+ * @data: output stream to export to.
*
* Import keys into the key source. When operation is 'done' the result
- * of the operation will be a gpgme_data_t
+ * of the operation will be a GOutputStream
*
* Returns: The export operation
*/
SeahorseOperation* (*export_raw) (SeahorseKeySource *sksrc, GSList *keyids,
- gpgme_data_t data);
+ GOutputStream *output);
/**
* remove
@@ -192,24 +191,24 @@
/* Takes ownership of |data| */
SeahorseOperation* seahorse_key_source_import (SeahorseKeySource *sksrc,
- gpgme_data_t data);
+ GInputStream *input);
/* Takes ownership of |data| */
gboolean seahorse_key_source_import_sync (SeahorseKeySource *sksrc,
- gpgme_data_t data,
+ GInputStream *input,
GError **err);
SeahorseOperation* seahorse_key_source_export_keys (GList *keys,
- gpgme_data_t data);
+ GOutputStream *output);
SeahorseOperation* seahorse_key_source_export (SeahorseKeySource *sksrc,
GList *keys,
gboolean complete,
- gpgme_data_t data);
+ GOutputStream *output);
SeahorseOperation* seahorse_key_source_export_raw (SeahorseKeySource *sksrc,
GSList *keyids,
- gpgme_data_t data);
+ GOutputStream *output);
void seahorse_key_source_stop (SeahorseKeySource *sksrc);
Modified: trunk/libseahorse/seahorse-passphrase.c
==============================================================================
--- trunk/libseahorse/seahorse-passphrase.c (original)
+++ trunk/libseahorse/seahorse-passphrase.c Tue Apr 29 01:59:52 2008
@@ -46,8 +46,6 @@
#include "seahorse-passphrase.h"
#include "seahorse-secure-entry.h"
-#include "pgp/seahorse-gpgmex.h"
-
#define HIG_SMALL 6 /* gnome hig small space in pixels */
#define HIG_LARGE 12 /* gnome hig large space in pixels */
Modified: trunk/libseahorse/seahorse-passphrase.h
==============================================================================
--- trunk/libseahorse/seahorse-passphrase.h (original)
+++ trunk/libseahorse/seahorse-passphrase.h Tue Apr 29 01:59:52 2008
@@ -35,9 +35,4 @@
gboolean seahorse_passphrase_prompt_checked (GtkDialog *dialog);
-gpgme_error_t seahorse_passphrase_get (gconstpointer dummy,
- const gchar *passphrase_hint,
- const char* passphrase_info,
- int prev_bad, int fd);
-
#endif /* __SEAHORSE_PASSPHRASE__ */
Modified: trunk/libseahorse/seahorse-prefs-keyrings.c
==============================================================================
--- trunk/libseahorse/seahorse-prefs-keyrings.c (original)
+++ trunk/libseahorse/seahorse-prefs-keyrings.c Tue Apr 29 01:59:52 2008
@@ -307,7 +307,7 @@
/*
* Update the main seahorse gkeyring source
- * TODO: We shouldn't have to define SKEY_GKEYRING here again
+ * TODO: We shouldn't have to define SEAHORSE_GKR here again
*/
src = seahorse_context_find_key_source (SCTX_APP (),
g_quark_from_static_string ("gnome-keyring"),
Modified: trunk/libseahorse/seahorse-transfer-operation.c
==============================================================================
--- trunk/libseahorse/seahorse-transfer-operation.c (original)
+++ trunk/libseahorse/seahorse-transfer-operation.c Tue Apr 29 01:59:52 2008
@@ -25,9 +25,6 @@
#include "seahorse-transfer-operation.h"
#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
-#include "pgp/seahorse-pgp-source.h"
-
#ifndef DEBUG_OPERATION_ENABLE
#if _DEBUG
#define DEBUG_OPERATION_ENABLE 1
@@ -49,7 +46,7 @@
typedef struct _SeahorseTransferOperationPrivate {
SeahorseOperation *operation; /* The current operation in progress */
gchar *message; /* A progress message to display */
- gpgme_data_t data; /* Hold onto the data */
+ GMemoryOutputStream *output; /* Hold onto the data */
gboolean individually; /* Individually export keys, not as one block */
} SeahorseTransferOperationPrivate;
@@ -158,10 +155,9 @@
SeahorseTransferOperationPrivate *pv = SEAHORSE_TRANSFER_OPERATION_GET_PRIVATE (top);
GError *err = NULL;
gboolean done = FALSE;
- gpgme_data_t data;
- gpgme_error_t gerr;
- size_t len;
- gchar *raw;
+ GInputStream *input;
+ gpointer data;
+ gsize size;
g_assert (op == pv->operation);
DEBUG_OPERATION (("[transfer] export done\n"));
@@ -192,25 +188,20 @@
DEBUG_OPERATION (("[transfer] starting import\n"));
- /*
- * HACK: Strange bug in GPGME. It won't accept our gpgme_data_t unless
- * we rebuild it.
- */
-
- raw = gpgme_data_release_and_get_mem (pv->data, &len);
- pv->data = NULL;
-
- gerr = gpgme_data_new_from_mem (&data, raw, len, 0);
- g_return_if_fail (GPG_IS_OK (gerr));
-
- /* This frees data */
- pv->operation = seahorse_key_source_import (top->to, data);
- g_return_if_fail (pv->operation != NULL);
-
- /* Free this data with the operation */
- g_object_set_data_full (G_OBJECT (pv->operation), "raw-data",
- raw, (GDestroyNotify)free);
-
+ /* Build an input stream for this */
+ data = g_memory_output_stream_get_data (pv->output);
+ size = seahorse_util_memory_output_length (pv->output);
+ g_return_if_fail (data);
+
+ input = g_memory_input_stream_new_from_data (g_memdup (data, size), size, g_free);
+ g_return_if_fail (input);
+
+ /* This frees data */
+ pv->operation = seahorse_key_source_import (top->to, input);
+ g_return_if_fail (pv->operation != NULL);
+
+ g_object_unref (input);
+
/* And mark us as started */
seahorse_operation_mark_start (SEAHORSE_OPERATION (top));
seahorse_operation_mark_progress (SEAHORSE_OPERATION (top), pv->message ? pv->message :
@@ -235,7 +226,7 @@
g_assert (keyids && from);
pv = SEAHORSE_TRANSFER_OPERATION_GET_PRIVATE (top);
- pv->operation = seahorse_key_source_export_raw (from, keyids, pv->data);
+ pv->operation = seahorse_key_source_export_raw (from, keyids, G_OUTPUT_STREAM (pv->output));
g_return_val_if_fail (pv->operation != NULL, FALSE);
seahorse_operation_watch (pv->operation, G_CALLBACK (export_done),
@@ -250,8 +241,8 @@
static void
seahorse_transfer_operation_init (SeahorseTransferOperation *top)
{
- SeahorseTransferOperationPrivate *pv = SEAHORSE_TRANSFER_OPERATION_GET_PRIVATE (top);
- pv->data = gpgmex_data_new ();
+ SeahorseTransferOperationPrivate *pv = SEAHORSE_TRANSFER_OPERATION_GET_PRIVATE (top);
+ pv->output = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (NULL, 0, g_realloc, g_free));
}
static void
@@ -331,9 +322,9 @@
g_object_unref (top->to);
top->to = NULL;
- if (pv->data)
- gpgme_data_release (pv->data);
- pv->data = NULL;
+ if (pv->output)
+ g_object_unref (pv->output);
+ pv->output = NULL;
g_free (pv->message);
pv->message = NULL;
Modified: trunk/libseahorse/seahorse-unknown-source.c
==============================================================================
--- trunk/libseahorse/seahorse-unknown-source.c (original)
+++ trunk/libseahorse/seahorse-unknown-source.c Tue Apr 29 01:59:52 2008
@@ -26,6 +26,8 @@
#include "seahorse-unknown-source.h"
#include "seahorse-unknown-key.h"
+#include "common/sea-registry.h"
+
enum {
PROP_0,
PROP_KEY_TYPE,
@@ -78,7 +80,7 @@
}
static SeahorseOperation*
-seahorse_unknown_source_import (SeahorseKeySource *sksrc, gpgme_data_t data)
+seahorse_unknown_source_import (SeahorseKeySource *sksrc, GInputStream *input)
{
g_return_val_if_reached (NULL);
return NULL;
@@ -86,7 +88,7 @@
static SeahorseOperation*
seahorse_unknown_source_export_raw (SeahorseKeySource *sksrc, GSList *keyids,
- gpgme_data_t data)
+ GOutputStream *output)
{
g_return_val_if_reached (NULL);
return NULL;
@@ -169,7 +171,7 @@
g_param_spec_uint ("location", "Key Location", "Where the key is stored. See SeahorseKeyLoc",
0, G_MAXUINT, SKEY_LOC_INVALID, G_PARAM_READABLE));
- sea_registry_register_type (SEAHORSE_TYPE_UNKNOWN_SOURCE, "key-source", NULL);
+ sea_registry_register_type (NULL, SEAHORSE_TYPE_UNKNOWN_SOURCE, "key-source", NULL);
}
/* -----------------------------------------------------------------------------
Modified: trunk/libseahorse/seahorse-util.c
==============================================================================
--- trunk/libseahorse/seahorse-util.c (original)
+++ trunk/libseahorse/seahorse-util.c Tue Apr 29 01:59:52 2008
@@ -21,30 +21,30 @@
*/
#include "config.h"
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <time.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs.h>
-
-#ifdef WITH_SHARING
-#include <avahi-glib/glib-watch.h>
-#include <avahi-glib/glib-malloc.h>
-#endif
#include "seahorse-util.h"
#include "seahorse-key.h"
#include "seahorse-gconf.h"
-#include "seahorse-vfs-data.h"
#include "pgp/sea-pgp.h"
+
#include "ssh/sea-ssh.h"
-#include "pgp/seahorse-gpgmex.h"
+
+#include <gio/gio.h>
+#include <glib/gstdio.h>
+
+#ifdef WITH_SHARING
+#include <avahi-glib/glib-watch.h>
+#include <avahi-glib/glib-malloc.h>
+#endif
+
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
static const gchar *bad_filename_chars = "/\\<>|";
@@ -69,38 +69,6 @@
gtk_widget_destroy (error);
}
-/**
- * seahorse_util_handle_gpgme:
- * @err: Error value
- *
- * Shows an error dialog for @err.
- **/
-void
-seahorse_util_handle_gpgme (gpgme_error_t err, const char* desc, ...)
-{
- gchar *t = NULL;
-
- switch (gpgme_err_code(err)) {
- case GPG_ERR_CANCELED:
- case GPG_ERR_NO_ERROR:
- case GPG_ERR_ECANCELED:
- return;
- default:
- break;
- }
-
- va_list ap;
- va_start(ap, desc);
-
- if (desc)
- t = g_strdup_vprintf (desc, ap);
-
- va_end(ap);
-
- seahorse_util_show_error (NULL, t, gpgme_strerror (err));
- g_free(t);
-}
-
void
seahorse_util_handle_error (GError* err, const char* desc, ...)
{
@@ -125,19 +93,6 @@
}
/**
- * seahorse_util_gpgme_error_domain
- * Returns: The GError domain for gpgme errors
- **/
-GQuark
-seahorse_util_gpgme_error_domain ()
-{
- static GQuark q = 0;
- if(q == 0)
- q = g_quark_from_static_string ("seahorse-gpgme-error");
- return q;
-}
-
-/**
* seahorse_util_error_domain
* Returns: The GError domain for generic seahorse errors
**/
@@ -150,29 +105,6 @@
return q;
}
-/**
- * seahorse_util_gpgme_to_error
- * @gerr GPGME error
- * @err Resulting GError object
- **/
-void
-seahorse_util_gpgme_to_error (gpgme_error_t gerr, GError** err)
-{
- gpgme_err_code_t code;
-
- /* Make sure this is actually an error */
- g_assert (!GPG_IS_OK(gerr));
- code = gpgme_err_code (gerr);
-
- /* Special case some error messages */
- if (code == GPG_ERR_DECRYPT_FAILED) {
- g_set_error (err, SEAHORSE_GPGME_ERROR, code, "%s",
- _("Decryption failed. You probably do not have the decryption key."));
- } else {
- g_set_error (err, SEAHORSE_GPGME_ERROR, code, "%s",
- gpgme_strerror (gerr));
- }
-}
/**
* seahorse_util_get_date_string:
* @time: Time value to parse
@@ -248,7 +180,7 @@
}
/**
- * seahorse_util_write_data_to_text:
+ * seahorse_util_read_to_text:
* @data: Data to write
* @len: Length of the data
*
@@ -257,29 +189,33 @@
* Returns: The string read from data
**/
gchar*
-seahorse_util_write_data_to_text (gpgme_data_t data, guint *len)
+seahorse_util_read_to_text (GInputStream *input, guint *len)
{
- gint size = 128;
- gchar *buffer, *text;
- guint nread = 0;
- GString *string;
-
- gpgme_data_seek (data, 0, SEEK_SET);
-
- string = g_string_new ("");
- buffer = g_new (gchar, size);
-
- while ((nread = gpgme_data_read (data, buffer, size)) > 0)
- string = g_string_append_len (string, buffer, nread);
-
- if (len)
- *len = string->len;
-
- text = string->str;
- g_string_free (string, FALSE);
- g_free (buffer);
-
- return text;
+ gint size = 128;
+ gchar *buffer, *text;
+ gsize nread = 0;
+ GString *string;
+ GSeekable *seek;
+
+ if (G_IS_SEEKABLE (input)) {
+ seek = G_SEEKABLE (input);
+ g_seekable_seek (seek, 0, SEEK_SET, NULL, NULL);
+ }
+
+ string = g_string_new ("");
+ buffer = g_new (gchar, size);
+
+ while (g_input_stream_read_all (input, buffer, size, &nread, NULL, NULL) && nread == size)
+ string = g_string_append_len (string, buffer, nread);
+
+ if (len)
+ *len = string->len;
+
+ text = string->str;
+ g_string_free (string, FALSE);
+ g_free (buffer);
+
+ return text;
}
/**
@@ -288,23 +224,24 @@
* Breaks out one block of data (usually a key)
*
* @buf: A string buffer to write the data to.
- * @data: The GPGME data block to read from.
+ * @input: The input stream to read from.
* @start: The start signature to look for.
* @end: The end signature to look for.
*
* Returns: The number of bytes copied.
*/
guint
-seahorse_util_read_data_block (GString *buf, gpgme_data_t data,
+seahorse_util_read_data_block (GString *buf, GInputStream *input,
const gchar *start, const gchar* end)
{
const gchar *t;
guint copied = 0;
gchar ch;
+ gsize read;
/* Look for the beginning */
t = start;
- while (gpgme_data_read (data, &ch, 1) == 1) {
+ while (g_input_stream_read_all (input, &ch, 1, &read, NULL, NULL) && read == 1) {
/* Match next char */
if (*t == ch)
@@ -320,7 +257,7 @@
/* Look for the end */
t = end;
- while (gpgme_data_read (data, &ch, 1) == 1) {
+ while (g_input_stream_read_all (input, &ch, 1, &read, NULL, NULL) && read == 1) {
/* Match next char */
if (*t == ch)
@@ -337,6 +274,36 @@
return copied;
}
+gsize
+seahorse_util_memory_output_length (GMemoryOutputStream *output)
+{
+ GSeekable *seekable;
+ goffset offset, end;
+
+ /*
+ * This is a replacement for g_memory_output_stream_get_data_size()
+ * which is not available in current version of glib.
+ */
+
+ g_return_val_if_fail (G_IS_MEMORY_OUTPUT_STREAM (output), 0);
+ g_return_val_if_fail (G_IS_SEEKABLE (output), 0);
+
+ seekable = G_SEEKABLE (output);
+ offset = g_seekable_tell (seekable);
+
+ if (!g_seekable_seek (seekable, 0, G_SEEK_END, NULL, NULL))
+ g_return_val_if_reached (0);
+
+ end = g_seekable_tell (seekable);
+
+ if (offset != end) {
+ if (!g_seekable_seek (seekable, offset, G_SEEK_SET, NULL, NULL))
+ g_return_val_if_reached (0);
+ }
+
+ return (gsize)end;
+}
+
/**
* seahorse_util_printf_fd:
* @fd: The file descriptor to write to
@@ -481,16 +448,16 @@
gboolean
seahorse_util_uri_exists (const gchar* uri)
{
- GnomeVFSURI* vuri;
- gboolean exists;
+ GFile *file;
+ gboolean exists;
- vuri = gnome_vfs_uri_new (uri);
- g_return_val_if_fail (vuri != NULL, FALSE);
-
- exists = gnome_vfs_uri_exists (vuri);
- gnome_vfs_uri_unref (vuri);
-
- return exists;
+ file = g_file_new_for_uri (uri);
+ g_return_val_if_fail (file, FALSE);
+
+ exists = g_file_query_exists (file, NULL);
+ g_object_unref (file);
+
+ return exists;
}
/**
@@ -595,78 +562,6 @@
return ret;
}
-/* Context for callback below */
-typedef struct _VisitUriCtx
-{
- GArray* files;
- const gchar* base_uri;
-}
-VisitUriCtx;
-
-/* Called for each sub file or directory */
-static gboolean
-visit_uri (const gchar *rel_path, GnomeVFSFileInfo *info, gboolean recursing_will_loop,
- gpointer data, gboolean *recurse)
-{
- VisitUriCtx* ctx = (VisitUriCtx*)data;
- gchar* t = g_strconcat (ctx->base_uri, "/", rel_path, NULL);
- gchar* uri = gnome_vfs_make_uri_canonical (t);
- g_free (t);
-
- if(info->type != GNOME_VFS_FILE_TYPE_DIRECTORY)
- g_array_append_val (ctx->files, uri);
-
- *recurse = !recursing_will_loop;
- return TRUE;
-}
-
-/**
- * seahorse_util_uris_expand
- * @uris: The null-terminated vector of URIs to enumerate
- *
- * Find all files in the given set of uris.
- *
- * Returns: Newly allocated null-terminated string vector of URIs.
- */
-gchar**
-seahorse_util_uris_expand (const gchar** uris)
-{
- GnomeVFSFileInfo* info;
- GArray* files = NULL;
- const gchar** u;
- gchar* uri;
-
- files = g_array_new (TRUE, FALSE, sizeof(gchar*));
- info = gnome_vfs_file_info_new ();
-
- for(u = uris; *u; u++) {
-
- uri = gnome_vfs_make_uri_canonical (*u);
-
- if (gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_DEFAULT) == GNOME_VFS_OK &&
- info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
- {
- VisitUriCtx ctx;
- ctx.files = files;
- ctx.base_uri = uri;
-
- gnome_vfs_directory_visit (uri, GNOME_VFS_FILE_INFO_DEFAULT,
- GNOME_VFS_DIRECTORY_VISIT_DEFAULT | GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK,
- visit_uri, &ctx);
-
- /* Not a directory */
- } else {
-
- g_array_append_val (files, uri);
- uri = NULL; /* To prevent freeing below */
- }
-
- g_free (uri);
- }
-
- return (gchar**)g_array_free (files, FALSE);
-}
-
/**
* seahorse_util_uris_package
* @package: Package uri
@@ -687,41 +582,51 @@
gchar *cmd;
gchar *t;
gchar *x;
- GnomeVFSFileInfo *info;
- GnomeVFSResult result;
+ GFile *file, *fpackage;
- t = gnome_vfs_get_local_path_from_uri (package);
- x = g_shell_quote(t);
- g_free(t);
-
- /* create execution */
- str = g_string_new ("");
- g_string_printf (str, "file-roller --add-to=%s", x);
- g_free(x);
-
- while(*uris) {
- /* We should never be passed any remote uris at this point */
- x = gnome_vfs_make_uri_canonical (*uris);
-
- t = gnome_vfs_get_local_path_from_uri (x);
- g_free(x);
-
- g_return_val_if_fail (t != NULL, FALSE);
-
- x = g_shell_quote(t);
- g_free(t);
+ fpackage = g_file_new_for_uri (package);
+ t = g_file_get_path (fpackage);
+ x = g_shell_quote (t);
+ g_free (t);
+
+ /* create execution */
+ str = g_string_new ("");
+ g_string_printf (str, "file-roller --add-to=%s", x);
+ g_free (x);
+
+ while(*uris) {
+ /* We should never be passed any remote uris at this point */
+ x = g_uri_parse_scheme (*uris);
+ if (x)
+ file = g_file_new_for_uri (*uris);
+ else
+ file = g_file_new_for_path (*uris);
+ g_free (x);
+
+ t = g_file_get_path (file);
+ g_object_unref (file);
+ g_return_val_if_fail (t != NULL, FALSE);
+
+ x = g_shell_quote (t);
+ g_free (t);
+
+ g_string_append_printf (str, " %s", x);
+ g_free (x);
+
+ uris++;
+ }
+
+ /* Execute the command */
+ cmd = g_string_free (str, FALSE);
+ r = g_spawn_command_line_sync (cmd, &out, NULL, &status, &err);
+ g_free (cmd);
+
+ /* TODO: This won't work for remote packages if we support them in the future */
+ t = g_file_get_path (fpackage);
+ g_chmod (t, S_IRUSR | S_IWUSR);
+ g_free (t);
+ g_object_unref (fpackage);
- g_string_append_printf (str, " %s", x);
- g_free(x);
-
- uris++;
- }
-
- /* Execute the command */
- cmd = g_string_free (str, FALSE);
- r = g_spawn_command_line_sync (cmd, &out, NULL, &status, &err);
- g_free (cmd);
-
if (out) {
g_print (out);
g_free (out);
@@ -738,67 +643,62 @@
return FALSE;
}
- info = gnome_vfs_file_info_new ();
- info->permissions = GNOME_VFS_PERM_USER_READ | GNOME_VFS_PERM_USER_WRITE;
- result = gnome_vfs_set_file_info (package, info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS);
- gnome_vfs_file_info_unref (info);
-
- if (result != GNOME_VFS_OK) {
- seahorse_util_handle_error (err, _("Couldn't set permissions on backup file."));
- return FALSE;
- }
-
return TRUE;
}
GQuark
seahorse_util_detect_mime_type (const gchar *mime)
{
- if (!mime || g_ascii_strcasecmp (mime, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0) {
- g_warning ("couldn't get mime type for data");
- return 0;
- }
-
- if (g_ascii_strcasecmp (mime, "application/pgp-keys") == 0)
- return SEA_PGP;
+ if (!mime || g_ascii_strcasecmp (mime, "application/octet-stream") == 0) {
+ g_warning ("couldn't get mime type for data");
+ return 0;
+ }
+
+ if (g_ascii_strcasecmp (mime, "application/pgp-encrypted") == 0 ||
+ g_ascii_strcasecmp (mime, "application/pgp-keys") == 0)
+ return SEA_PGP;
#ifdef WITH_SSH
- /* TODO: For now all PEM keys are treated as SSH keys */
- else if (g_ascii_strcasecmp (mime, "application/x-ssh-key") == 0 ||
- g_ascii_strcasecmp (mime, "application/x-pem-key") == 0)
- return SEA_SSH;
+ /* TODO: For now all PEM keys are treated as SSH keys */
+ else if (g_ascii_strcasecmp (mime, "application/x-ssh-key") == 0 ||
+ g_ascii_strcasecmp (mime, "application/x-pem-key") == 0)
+ return SEA_SSH;
#endif
- g_warning ("unsupported type of key data: %s", mime);
- return 0;
+ g_warning ("unsupported type of key data: %s", mime);
+ return 0;
}
GQuark
seahorse_util_detect_data_type (const gchar *data, guint length)
{
- const gchar* mime = gnome_vfs_get_mime_type_for_data (data, length);
- return seahorse_util_detect_mime_type (mime);
+ gboolean uncertain;
+ gchar *mime;
+ GQuark type;
+
+ mime = g_content_type_guess (NULL, (const guchar*)data, length, &uncertain);
+ g_return_val_if_fail (mime, 0);
+
+ type = seahorse_util_detect_mime_type (mime);
+ g_free (mime);
+
+ return type;
}
GQuark
seahorse_util_detect_file_type (const gchar *uri)
{
- GnomeVFSResult res;
- GnomeVFSFileInfo *info;
- GQuark ret = 0;
-
- info = gnome_vfs_file_info_new ();
- res = gnome_vfs_get_file_info (uri, info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE);
-
- if (res == GNOME_VFS_OK)
- ret = seahorse_util_detect_mime_type (info->mime_type);
- else
- g_warning ("couldn't get mime type for: %s: %s", uri,
- gnome_vfs_result_to_string (res));
-
- gnome_vfs_file_info_unref (info);
- return ret;
+ gboolean uncertain;
+ gchar *mime;
+ GQuark type;
+
+ mime = g_content_type_guess (uri, NULL, 0, &uncertain);
+ g_return_val_if_fail (mime, 0);
+
+ type = seahorse_util_detect_mime_type (mime);
+ g_free (mime);
+
+ return type;
}
gboolean
@@ -1102,17 +1002,6 @@
return len;
}
-void
-seahorse_util_free_keys (gpgme_key_t* keys)
-{
- gpgme_key_t* k = keys;
- if (!keys)
- return;
- while (*k)
- gpgmex_key_unref (*(k++));
- g_free (keys);
-}
-
static gint
sort_keys_by_source (SeahorseKey *k1, SeahorseKey *k2)
{
Modified: trunk/libseahorse/seahorse-util.h
==============================================================================
--- trunk/libseahorse/seahorse-util.h (original)
+++ trunk/libseahorse/seahorse-util.h Tue Apr 29 01:59:52 2008
@@ -52,35 +52,27 @@
gchar* seahorse_util_get_display_date_string (const time_t time);
-#define SEAHORSE_GPGME_ERROR (seahorse_util_gpgme_error_domain ())
-
-GQuark seahorse_util_gpgme_error_domain ();
-
#define SEAHORSE_ERROR (seahorse_util_error_domain ())
GQuark seahorse_util_error_domain ();
-void seahorse_util_gpgme_to_error (gpgme_error_t gerr,
- GError** err);
-
void seahorse_util_show_error (GtkWindow *parent,
const gchar *heading,
const gchar *message);
-void seahorse_util_handle_gpgme (gpgme_error_t err,
- const gchar* desc, ...);
-
void seahorse_util_handle_error (GError* err,
const char* desc, ...);
-gchar* seahorse_util_write_data_to_text (gpgme_data_t data,
+gchar* seahorse_util_read_to_text (GInputStream * input,
guint *len);
guint seahorse_util_read_data_block (GString *buf,
- gpgme_data_t data,
+ GInputStream* input,
const gchar *start,
const gchar* end);
+gsize seahorse_util_memory_output_length (GMemoryOutputStream *output);
+
gboolean seahorse_util_print_fd (int fd,
const char* data);
@@ -100,8 +92,6 @@
const gchar* seahorse_util_uri_split_last (gchar* uri);
-gchar** seahorse_util_uris_expand (const gchar **uris);
-
gboolean seahorse_util_uris_package (const gchar* package,
const gchar** uris);
@@ -151,8 +141,6 @@
GList* seahorse_util_keylist_splice (GList *keys);
-void seahorse_util_free_keys (gpgme_key_t* keys);
-
gboolean seahorse_util_string_equals (const gchar *s1, const gchar *s2);
gchar* seahorse_util_string_up_first (const gchar *orig);
Modified: trunk/pgp/Makefile.am
==============================================================================
--- trunk/pgp/Makefile.am (original)
+++ trunk/pgp/Makefile.am Tue Apr 29 01:59:52 2008
@@ -35,15 +35,17 @@
endif
libsea_pgp_la_SOURCES = \
+ seahorse-gpgme-io.c seahorse-gpgme-io.h \
seahorse-gpgmex.h seahorse-gpgmex-op.c seahorse-gpgmex-util.c \
seahorse-gpg-options.c seahorse-gpg-options.h \
sea-pgp.c sea-pgp.h \
sea-pgp-keysets.c sea-pgp-keysets.h \
+ seahorse-pgp-error.c \
seahorse-pgp-key.c seahorse-pgp-key.h \
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-signer.c sea-pgp-dialogs.h \
+ seahorse-signer.c seahorse-pgp-dialogs.h \
$(KEYSERVER_SRCS) \
$(LDAP_SRCS) \
$(HKP_SRCS)
Modified: trunk/pgp/seahorse-gpg-options.c
==============================================================================
--- trunk/pgp/seahorse-gpg-options.c (original)
+++ trunk/pgp/seahorse-gpg-options.c Tue Apr 29 01:59:52 2008
@@ -238,7 +238,7 @@
gerr = gpgme_get_engine_info (&engine);
g_return_val_if_fail (GPG_IS_OK (gerr),
- (seahorse_util_gpgme_to_error (gerr, err), FALSE));
+ (seahorse_gpgme_to_error (gerr, err), FALSE));
/* Look for the OpenPGP engine */
while (engine && engine->protocol != GPGME_PROTOCOL_OpenPGP)
@@ -251,7 +251,7 @@
g_return_val_if_fail (engine && engine->version && engine->file_name &&
(g_str_has_prefix (engine->version, GPG_VERSION_PREFIX1) ||
g_str_has_prefix (engine->version, GPG_VERSION_PREFIX2)),
- (seahorse_util_gpgme_to_error (GPG_E (GPG_ERR_INV_ENGINE), err), FALSE));
+ (seahorse_gpgme_to_error (GPG_E (GPG_ERR_INV_ENGINE), err), FALSE));
/* Now run the binary and read in the home directory */
if (!parse_home_directory (engine, err))
Added: trunk/pgp/seahorse-gpgme-io.c
==============================================================================
--- (empty file)
+++ trunk/pgp/seahorse-gpgme-io.c Tue Apr 29 01:59:52 2008
@@ -0,0 +1,334 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * 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 "config.h"
+
+#include "seahorse-gpgme-io.h"
+
+#include "seahorse-gpgmex.h"
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <gpgme.h>
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <errno.h>
+
+static int
+handle_gio_error (GError *err)
+{
+ g_return_val_if_fail (err, -1);
+
+ if (err->message)
+ g_message (err->message);
+
+ switch (err->code) {
+ case G_IO_ERROR_FAILED:
+ errno = EIO;
+ break;
+ case G_IO_ERROR_NOT_FOUND:
+ errno = ENOENT;
+ break;
+ case G_IO_ERROR_EXISTS:
+ errno = EEXIST;
+ break;
+ case G_IO_ERROR_IS_DIRECTORY:
+ errno = EISDIR;
+ break;
+ case G_IO_ERROR_NOT_DIRECTORY:
+ errno = ENOTDIR;
+ break;
+ case G_IO_ERROR_NOT_EMPTY:
+ errno = ENOTEMPTY;
+ break;
+ case G_IO_ERROR_NOT_REGULAR_FILE:
+ case G_IO_ERROR_NOT_SYMBOLIC_LINK:
+ case G_IO_ERROR_NOT_MOUNTABLE_FILE:
+ errno = EBADF;
+ break;
+ case G_IO_ERROR_FILENAME_TOO_LONG:
+ errno = ENAMETOOLONG;
+ break;
+ case G_IO_ERROR_INVALID_FILENAME:
+ errno = EINVAL;
+ break;
+ case G_IO_ERROR_TOO_MANY_LINKS:
+ errno = EMLINK;
+ break;
+ case G_IO_ERROR_NO_SPACE:
+ errno = ENOSPC;
+ break;
+ case G_IO_ERROR_INVALID_ARGUMENT:
+ errno = EINVAL;
+ break;
+ case G_IO_ERROR_PERMISSION_DENIED:
+ errno = EPERM;
+ break;
+ case G_IO_ERROR_NOT_SUPPORTED:
+ errno = ENOTSUP;
+ break;
+ case G_IO_ERROR_NOT_MOUNTED:
+ errno = ENOENT;
+ break;
+ case G_IO_ERROR_ALREADY_MOUNTED:
+ errno = EALREADY;
+ break;
+ case G_IO_ERROR_CLOSED:
+ errno = EBADF;
+ break;
+ case G_IO_ERROR_CANCELLED:
+ errno = EINTR;
+ break;
+ case G_IO_ERROR_PENDING:
+ errno = EALREADY;
+ break;
+ case G_IO_ERROR_READ_ONLY:
+ errno = EACCES;
+ break;
+ case G_IO_ERROR_CANT_CREATE_BACKUP:
+ errno = EIO;
+ break;
+ case G_IO_ERROR_WRONG_ETAG:
+ errno = EACCES;
+ break;
+ case G_IO_ERROR_TIMED_OUT:
+ errno = EIO;
+ break;
+ case G_IO_ERROR_WOULD_RECURSE:
+ errno = ELOOP;
+ break;
+ case G_IO_ERROR_BUSY:
+ errno = EBUSY;
+ break;
+ case G_IO_ERROR_WOULD_BLOCK:
+ errno = EWOULDBLOCK;
+ break;
+ case G_IO_ERROR_HOST_NOT_FOUND:
+ errno = EHOSTDOWN;
+ break;
+ case G_IO_ERROR_WOULD_MERGE:
+ errno = EIO;
+ break;
+ case G_IO_ERROR_FAILED_HANDLED:
+ errno = 0;
+ break;
+ default:
+ errno = EIO;
+ break;
+ };
+
+ g_error_free (err);
+ return -1;
+}
+
+/* ----------------------------------------------------------------------------------------
+ * OUTPUT
+ */
+
+/* Called by gpgme to read data */
+static ssize_t
+output_write(void *handle, const void *buffer, size_t size)
+{
+ GOutputStream* output = handle;
+ GError *err = NULL;
+ gsize written;
+
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), -1);
+
+ if (!g_output_stream_write_all (output, buffer, size, &written, NULL, &err))
+ return handle_gio_error (err);
+
+ if (!g_output_stream_flush (output, NULL, &err))
+ return handle_gio_error (err);
+
+ return written;
+}
+
+/* Called from gpgme to seek a file */
+static off_t
+output_seek (void *handle, off_t offset, int whence)
+{
+ GSeekable *seek;
+ GSeekType from;
+ GError *err = NULL;
+ GOutputStream* output = handle;
+
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), -1);
+
+ if (!G_IS_SEEKABLE (output)) {
+ errno = EOPNOTSUPP;
+ return -1;
+ }
+
+ switch(whence)
+ {
+ case SEEK_SET:
+ from = G_SEEK_SET;
+ break;
+ case SEEK_CUR:
+ from = G_SEEK_CUR;
+ break;
+ case SEEK_END:
+ from = G_SEEK_END;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ };
+
+ seek = G_SEEKABLE (output);
+ if (!g_seekable_seek (seek, offset, from, NULL, &err))
+ return handle_gio_error (err);
+
+ return offset;
+}
+
+/* Called by gpgme to close a file */
+static void
+output_release (void *handle)
+{
+ GOutputStream* output = handle;
+ g_return_if_fail (G_IS_OUTPUT_STREAM (output));
+
+ g_object_unref (output);
+}
+
+/* GPGME vfs file operations */
+static struct gpgme_data_cbs output_cbs =
+{
+ NULL,
+ output_write,
+ output_seek,
+ output_release
+};
+
+gpgme_data_t
+sea_gpgme_output_data (GOutputStream* output)
+{
+ gpgme_error_t gerr;
+ gpgme_data_t ret = NULL;
+
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), NULL);
+
+ gerr = gpgme_data_new_from_cbs (&ret, &output_cbs, output);
+ if (!GPG_IS_OK (gerr))
+ return NULL;
+
+ g_object_ref (output);
+ return ret;
+}
+
+/* -------------------------------------------------------------------------------------
+ * INPUT STREAMS
+ */
+
+/* Called by gpgme to read data */
+static ssize_t
+input_read (void *handle, void *buffer, size_t size)
+{
+ GInputStream* input = handle;
+ GError *err = NULL;
+ gsize nread;
+
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), -1);
+
+ if (!g_input_stream_read_all (input, buffer, size, &nread, NULL, &err))
+ return handle_gio_error (err);
+
+ return nread;
+}
+
+/* Called from gpgme to seek a file */
+static off_t
+input_seek (void *handle, off_t offset, int whence)
+{
+ GSeekable *seek;
+ GSeekType from;
+ GError *err = NULL;
+ GInputStream* input = handle;
+
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), -1);
+
+ if (!G_IS_SEEKABLE (input)) {
+ errno = EOPNOTSUPP;
+ return -1;
+ }
+
+ switch(whence)
+ {
+ case SEEK_SET:
+ from = G_SEEK_SET;
+ break;
+ case SEEK_CUR:
+ from = G_SEEK_CUR;
+ break;
+ case SEEK_END:
+ from = G_SEEK_END;
+ break;
+ default:
+ g_assert_not_reached();
+ break;
+ };
+
+ seek = G_SEEKABLE (input);
+ if (!g_seekable_seek (seek, offset, from, NULL, &err))
+ return handle_gio_error (err);
+
+ return offset;
+}
+
+/* Called by gpgme to close a file */
+static void
+input_release (void *handle)
+{
+ GInputStream* input = handle;
+ g_return_if_fail (G_IS_INPUT_STREAM (input));
+
+ g_object_unref (input);
+}
+
+/* GPGME vfs file operations */
+static struct gpgme_data_cbs input_cbs =
+{
+ input_read,
+ NULL,
+ input_seek,
+ input_release
+};
+
+gpgme_data_t
+sea_gpgme_input_data (GInputStream* input)
+{
+ gpgme_error_t gerr;
+ gpgme_data_t ret = NULL;
+
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
+
+ gerr = gpgme_data_new_from_cbs (&ret, &input_cbs, input);
+ if (!GPG_IS_OK (gerr))
+ return NULL;
+
+ g_object_ref (input);
+ return ret;
+}
Added: trunk/pgp/seahorse-gpgme-io.h
==============================================================================
--- (empty file)
+++ trunk/pgp/seahorse-gpgme-io.h Tue Apr 29 01:59:52 2008
@@ -0,0 +1,36 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * 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.
+ */
+
+/**
+ * A gpgme_data_t implementation which maps to a gio handle.
+ * Allows for accessing data on remote machines (ie: smb, sftp)
+ */
+
+#ifndef __SEA_GPGME_IO__
+#define __SEA_GPGME_IO__
+
+#include <gpgme.h>
+#include <gio/gio.h>
+
+gpgme_data_t sea_gpgme_input_data (GInputStream* input);
+gpgme_data_t sea_gpgme_output_data (GOutputStream* output);
+
+#endif /* __SEA_GPGME_IO__ */
Modified: trunk/pgp/seahorse-gpgmex-util.c
==============================================================================
--- trunk/pgp/seahorse-gpgmex-util.c (original)
+++ trunk/pgp/seahorse-gpgmex-util.c Tue Apr 29 01:59:52 2008
@@ -19,16 +19,45 @@
* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
+#include "pgp/seahorse-gpgmex.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
-#include "config.h"
-#include <glib.h>
-
-#include "pgp/seahorse-gpgmex.h"
-
+GQuark
+seahorse_gpgme_error_domain (void)
+{
+ static GQuark q = 0;
+ if (q == 0)
+ q = g_quark_from_static_string ("seahorse-gpgme-error");
+ return q;
+}
+
+void
+seahorse_gpgme_to_error (gpgme_error_t gerr, GError** err)
+{
+ gpgme_err_code_t code;
+
+ /* Make sure this is actually an error */
+ g_assert (!GPG_IS_OK(gerr));
+ code = gpgme_err_code (gerr);
+
+ /* Special case some error messages */
+ if (code == GPG_ERR_DECRYPT_FAILED) {
+ g_set_error (err, SEAHORSE_GPGME_ERROR, code, "%s",
+ _("Decryption failed. You probably do not have the decryption key."));
+ } else {
+ g_set_error (err, SEAHORSE_GPGME_ERROR, code, "%s",
+ gpgme_strerror (gerr));
+ }
+}
/* -----------------------------------------------------------------------------
* DATA
*/
@@ -459,6 +488,17 @@
}
}
+void
+gpgmex_free_keys (gpgme_key_t* keys)
+{
+ gpgme_key_t* k = keys;
+ if (!keys)
+ return;
+ while (*k)
+ gpgmex_key_unref (*(k++));
+ g_free (keys);
+}
+
gpgmex_photo_id_t
gpgmex_photo_id_alloc (guint uid)
{
Modified: trunk/pgp/seahorse-gpgmex.h
==============================================================================
--- trunk/pgp/seahorse-gpgmex.h (original)
+++ trunk/pgp/seahorse-gpgmex.h Tue Apr 29 01:59:52 2008
@@ -40,6 +40,12 @@
#define GPG_OK (gpgme_error (GPG_ERR_NO_ERROR))
#define GPG_E(e) (gpgme_error (e))
+#define SEAHORSE_GPGME_ERROR (seahorse_gpgme_error_domain ())
+
+GQuark seahorse_gpgme_error_domain (void);
+
+void seahorse_gpgme_to_error (gpgme_error_t gerr, GError** err);
+
/* -----------------------------------------------------------------------------
* DATA ALLOCATION
*/
@@ -113,6 +119,8 @@
void gpgmex_combine_keys (gpgme_key_t k, gpgme_key_t key);
+void gpgmex_free_keys (gpgme_key_t* keys);
+
gpgmex_photo_id_t
gpgmex_photo_id_alloc (guint uid);
Modified: trunk/pgp/seahorse-hkp-source.c
==============================================================================
--- trunk/pgp/seahorse-hkp-source.c (original)
+++ trunk/pgp/seahorse-hkp-source.c Tue Apr 29 01:59:52 2008
@@ -19,19 +19,18 @@
* Boston, MA 02111-1307, USA.
*/
-#include <stdlib.h>
-#include <config.h>
-#include <gnome.h>
-#include <libsoup/soup.h>
+#include "config.h"
-#include "seahorse-operation.h"
#include "seahorse-hkp-source.h"
-#include "seahorse-util.h"
+
+#include "seahorse-gpgmex.h"
+#include "seahorse-pgp-key.h"
+
#include "seahorse-gconf.h"
-#include "seahorse-vfs-data.h"
+#include "seahorse-operation.h"
+#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
-#include "pgp/seahorse-pgp-key.h"
+#include <libsoup/soup.h>
#ifdef WITH_HKP
@@ -647,10 +646,11 @@
GError *err = NULL;
const gchar *start;
const gchar *end;
- gpgme_data_t data;
+ GOutputStream *output;
const gchar *text;
gboolean ret;
guint len;
+ gsize written;
if (hop->cancelling)
return;
@@ -671,28 +671,29 @@
if(!detect_key (text, len, &start, &end))
break;
- /* Any key blocks get written to our result data */
- data = (gpgme_data_t)seahorse_operation_get_result (SEAHORSE_OPERATION (hop));
- g_return_if_fail (data != NULL);
-
- ret = gpgmex_data_write_all (data, start, end - start) > 0 &&
- gpgmex_data_write_all (data, "\n", -1) > 0;
-
- if (!ret)
- g_set_error (&err, G_FILE_ERROR, g_file_error_from_errno (errno),
- "%s", strerror (errno));
-
- if (!ret) {
- seahorse_operation_mark_done (SEAHORSE_OPERATION (hop), FALSE, err);
- return;
- }
- }
-
- if (--hop->requests <= 0)
- seahorse_operation_mark_done (SEAHORSE_OPERATION (hop), FALSE, NULL);
- else
- seahorse_operation_mark_progress_full (SEAHORSE_OPERATION (hop), _("Retrieving keys..."),
- hop->requests, hop->total);
+ /* Any key blocks get written to our result data */
+ output = seahorse_operation_get_result (SEAHORSE_OPERATION (hop));
+ g_return_if_fail (G_IS_OUTPUT_STREAM (output));
+
+ ret = g_output_stream_write_all (output, start, end - start, &written, NULL, &err) &&
+ g_output_stream_write_all (output, "\n", 1, &written, NULL, &err) &&
+ g_output_stream_flush (output, NULL, &err);
+
+ if (!ret) {
+ seahorse_operation_mark_done (SEAHORSE_OPERATION (hop), FALSE, err);
+ return;
+ }
+ }
+
+ if (--hop->requests <= 0) {
+ output = seahorse_operation_get_result (SEAHORSE_OPERATION (hop));
+ g_return_if_fail (G_IS_OUTPUT_STREAM (output));
+ g_output_stream_close (output, NULL, &err);
+ seahorse_operation_mark_done (SEAHORSE_OPERATION (hop), FALSE, err);
+ } else {
+ seahorse_operation_mark_progress_full (SEAHORSE_OPERATION (hop), _("Retrieving keys..."),
+ hop->requests, hop->total);
+ }
}
@@ -790,7 +791,7 @@
}
static SeahorseOperation*
-seahorse_hkp_source_import (SeahorseKeySource *sksrc, gpgme_data_t data)
+seahorse_hkp_source_import (SeahorseKeySource *sksrc, GInputStream *input)
{
SeahorseHKPOperation *hop;
SeahorseHKPSource *hsrc;
@@ -803,13 +804,16 @@
GSList *l;
guint len;
- g_assert (SEAHORSE_IS_HKP_SOURCE (sksrc));
+ g_return_val_if_fail (SEAHORSE_IS_HKP_SOURCE (sksrc), NULL);
hsrc = SEAHORSE_HKP_SOURCE (sksrc);
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
+ g_object_ref (input);
+
for (;;) {
buf = g_string_sized_new (2048);
- len = seahorse_util_read_data_block (buf, data, "-----BEGIN PGP PUBLIC KEY BLOCK-----",
+ len = seahorse_util_read_data_block (buf, input, "-----BEGIN PGP PUBLIC KEY BLOCK-----",
"-----END PGP PUBLIC KEY BLOCK-----");
if (len > 0) {
@@ -820,8 +824,10 @@
}
}
- if (g_slist_length (keydata) == 0)
- return seahorse_operation_new_complete (NULL);
+ if (g_slist_length (keydata) == 0) {
+ g_object_unref (input);
+ return seahorse_operation_new_complete (NULL);
+ }
/* Figure out the URI we're sending to */
uri = get_http_server_uri (sksrc, "/pks/add");
@@ -855,15 +861,15 @@
soup_uri_free (uri);
- seahorse_util_string_slist_free (keydata);
- gpgmex_data_release (data);
+ seahorse_util_string_slist_free (keydata);
+ g_object_unref (input);
return SEAHORSE_OPERATION (hop);
}
static SeahorseOperation*
seahorse_hkp_source_export_raw (SeahorseKeySource *sksrc, GSList *keyids,
- gpgme_data_t data)
+ GOutputStream *output)
{
SeahorseHKPOperation *hop;
SeahorseHKPSource *hsrc;
@@ -877,6 +883,8 @@
GSList *l;
g_return_val_if_fail (SEAHORSE_IS_HKP_SOURCE (sksrc), NULL);
+ g_return_val_if_fail (output == NULL || G_IS_OUTPUT_STREAM (output), NULL);
+
hsrc = SEAHORSE_HKP_SOURCE (sksrc);
if (g_slist_length (keyids) == 0)
@@ -888,16 +896,9 @@
/* New operation started */
hop = setup_hkp_operation (hsrc);
- if (data) {
- /* Note that we don't auto-free this */
- seahorse_operation_mark_result (SEAHORSE_OPERATION (hop), data, NULL);
- } else {
- /* But when we auto create a data object then we free it */
- data = gpgmex_data_new ();
- seahorse_operation_mark_result (SEAHORSE_OPERATION (hop), data,
- (GDestroyNotify)gpgmex_data_release);
- }
-
+ g_object_ref (output);
+ seahorse_operation_mark_result (SEAHORSE_OPERATION (hop), output, g_object_unref);
+
/* prepend the hex prefix (0x) to make keyservers happy */
strncpy(hexfpr, "0x", 3);
@@ -946,6 +947,7 @@
gobject_class->get_property = seahorse_hkp_source_get_property;
key_class = SEAHORSE_KEY_SOURCE_CLASS (klass);
+ key_class->canonize_keyid = seahorse_pgp_key_get_cannonical_id;
key_class->load = seahorse_hkp_source_load;
key_class->search = seahorse_hkp_source_search;
key_class->import = seahorse_hkp_source_import;
Modified: trunk/pgp/seahorse-ldap-source.c
==============================================================================
--- trunk/pgp/seahorse-ldap-source.c (original)
+++ trunk/pgp/seahorse-ldap-source.c Tue Apr 29 01:59:52 2008
@@ -20,22 +20,20 @@
*/
#include "config.h"
-#include <stdlib.h>
-#include <libintl.h>
-#include <gnome.h>
-#include <ldap.h>
-#ifdef WITH_SOUP
-#include <libsoup/soup-address.h>
-#endif
+#include "seahorse-ldap-source.h"
+
+#include "seahorse-gpgmex.h"
+#include "seahorse-pgp-key.h"
-#include "config.h"
#include "seahorse-operation.h"
-#include "seahorse-ldap-source.h"
#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
-#include "pgp/seahorse-pgp-key.h"
+#include <ldap.h>
+
+#ifdef WITH_SOUP
+#include <libsoup/soup-address.h>
+#endif
#ifdef WITH_LDAP
@@ -951,11 +949,12 @@
{
SeahorseLDAPOperation *lop = SEAHORSE_LDAP_OPERATION (op);
LDAPServerInfo *sinfo;
- gpgme_data_t data;
+ GOutputStream *output;
char *message;
GError *err = NULL;
gboolean ret;
gchar *key;
+ gsize written;
int code;
int r;
@@ -977,16 +976,13 @@
fail_ldap_operation (lop, LDAP_NO_SUCH_OBJECT);
}
- data = (gpgme_data_t)seahorse_operation_get_result (SEAHORSE_OPERATION (lop));
- g_return_val_if_fail (data != NULL, FALSE);
-
- ret = gpgmex_data_write_all (data, key, -1) > 0 &&
- gpgmex_data_write_all (data, "\n", -1) > 0;
+ output = seahorse_operation_get_result (SEAHORSE_OPERATION (lop));
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), FALSE);
+
+ ret = g_output_stream_write_all (output, key, strlen (key), &written, NULL, &err) &&
+ g_output_stream_write_all (output, "\n", 1, &written, NULL, &err) &&
+ g_output_stream_flush (output, NULL, &err);
- if(!ret)
- g_set_error (&err, G_FILE_ERROR, g_file_error_from_errno (errno),
- "%s", strerror (errno));
-
g_free (key);
if (!ret) {
@@ -1024,10 +1020,12 @@
{
SeahorseLDAPOperation *lop = SEAHORSE_LDAP_OPERATION (op);
LDAPServerInfo *sinfo;
+ GOutputStream *output;
GSList *fingerprints, *fprfull;
gchar *filter;
char *attrs[2];
const gchar *fpr;
+ GError *err = NULL;
int l, r;
g_assert (lop->ldap != NULL);
@@ -1073,40 +1071,39 @@
lop->ldap_cb = get_callback;
return TRUE;
}
+
+ /* At this point we're done */
+ output = seahorse_operation_get_result (op);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), FALSE);
+ g_output_stream_close (output, NULL, &err);
+ seahorse_operation_mark_done (op, FALSE, err);
- /* At this point we're done */
- seahorse_operation_mark_done (op, FALSE, NULL);
- return FALSE;
+ return FALSE;
}
/* Starts a get operation for multiple keys */
static SeahorseLDAPOperation *
start_get_operation_multiple (SeahorseLDAPSource *lsrc, GSList *fingerprints,
- gpgme_data_t data)
+ GOutputStream *output)
{
- SeahorseLDAPOperation *lop;
+ SeahorseLDAPOperation *lop;
- g_assert (g_slist_length (fingerprints) > 0);
+ g_assert (g_slist_length (fingerprints) > 0);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), NULL);
- lop = seahorse_ldap_operation_start (lsrc, get_key_from_ldap,
- g_slist_length(fingerprints));
- g_return_val_if_fail (lop != NULL, NULL);
+ lop = seahorse_ldap_operation_start (lsrc, get_key_from_ldap,
+ g_slist_length (fingerprints));
+ g_return_val_if_fail (lop != NULL, NULL);
- if (data) {
- /* Note that we don't auto-free this */
- seahorse_operation_mark_result (SEAHORSE_OPERATION (lop), data, NULL);
- } else {
- /* But when we auto create a data object then we free it */
- data = gpgmex_data_new ();
- seahorse_operation_mark_result (SEAHORSE_OPERATION (lop), data,
- (GDestroyNotify)gpgmex_data_release);
- }
-
- g_object_set_data (G_OBJECT (lop), "fingerprints", fingerprints);
- g_object_set_data_full (G_OBJECT (lop), "fingerprints-full", fingerprints,
- (GDestroyNotify)seahorse_util_string_slist_free);
+ g_object_ref (output);
+ seahorse_operation_mark_result (SEAHORSE_OPERATION (lop), output,
+ g_object_unref);
- return lop;
+ g_object_set_data (G_OBJECT (lop), "fingerprints", fingerprints);
+ g_object_set_data_full (G_OBJECT (lop), "fingerprints-full", fingerprints,
+ (GDestroyNotify)seahorse_util_string_slist_free);
+
+ return lop;
}
/* -----------------------------------------------------------------------------
@@ -1314,7 +1311,7 @@
}
static SeahorseOperation*
-seahorse_ldap_source_import (SeahorseKeySource *sksrc, gpgme_data_t data)
+seahorse_ldap_source_import (SeahorseKeySource *sksrc, GInputStream *input)
{
SeahorseLDAPOperation *lop;
SeahorseLDAPSource *lsrc;
@@ -1322,13 +1319,16 @@
GString *buf = NULL;
guint len;
- g_assert (SEAHORSE_IS_LDAP_SOURCE (sksrc));
- lsrc = SEAHORSE_LDAP_SOURCE (sksrc);
+ g_return_val_if_fail (SEAHORSE_IS_LDAP_SOURCE (sksrc), NULL);
+ lsrc = SEAHORSE_LDAP_SOURCE (sksrc);
+
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
+ g_object_ref (input);
for (;;) {
buf = g_string_sized_new (2048);
- len = seahorse_util_read_data_block (buf, data, "-----BEGIN PGP PUBLIC KEY BLOCK-----",
+ len = seahorse_util_read_data_block (buf, input, "-----BEGIN PGP PUBLIC KEY BLOCK-----",
"-----END PGP PUBLIC KEY BLOCK-----");
if (len > 0) {
@@ -1344,19 +1344,21 @@
lop = start_send_operation_multiple (lsrc, keydata);
g_return_val_if_fail (lop != NULL, NULL);
- gpgmex_data_release (data);
- return SEAHORSE_OPERATION (lop);
+ g_object_unref (input);
+ return SEAHORSE_OPERATION (lop);
}
static SeahorseOperation*
seahorse_ldap_source_export_raw (SeahorseKeySource *sksrc, GSList *keyids,
- gpgme_data_t data)
+ GOutputStream *output)
{
SeahorseLDAPOperation *lop;
SeahorseLDAPSource *lsrc;
GSList *l, *fingerprints = NULL;
- g_assert (SEAHORSE_IS_LDAP_SOURCE (sksrc));
+ g_return_val_if_fail (SEAHORSE_IS_LDAP_SOURCE (sksrc), NULL);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), NULL);
+
lsrc = SEAHORSE_LDAP_SOURCE (sksrc);
for (l = keyids; l; l = g_slist_next (l))
@@ -1364,7 +1366,7 @@
g_strdup (seahorse_key_get_rawid (GPOINTER_TO_UINT (l->data))));
fingerprints = g_slist_reverse (fingerprints);
- lop = start_get_operation_multiple (lsrc, fingerprints, data);
+ lop = start_get_operation_multiple (lsrc, fingerprints, output);
g_return_val_if_fail (lop != NULL, NULL);
return SEAHORSE_OPERATION (lop);
@@ -1381,6 +1383,7 @@
gobject_class->get_property = seahorse_ldap_source_get_property;
key_class = SEAHORSE_KEY_SOURCE_CLASS (klass);
+ key_class->canonize_keyid = seahorse_pgp_key_get_cannonical_id;
key_class->load = seahorse_ldap_source_load;
key_class->search = seahorse_ldap_source_search;
key_class->import = seahorse_ldap_source_import;
Copied: trunk/pgp/seahorse-pgp-dialogs.h (from r2188, /trunk/pgp/sea-pgp-dialogs.h)
==============================================================================
--- /trunk/pgp/sea-pgp-dialogs.h (original)
+++ trunk/pgp/seahorse-pgp-dialogs.h Tue Apr 29 01:59:52 2008
@@ -33,4 +33,6 @@
SeahorsePGPKey* seahorse_signer_get (GtkWindow *parent);
+void seahorse_pgp_handle_gpgme_error (gpgme_error_t err, const gchar* desc, ...);
+
#endif /* __SEA_PGP_DIALOGS_H__ */
Added: trunk/pgp/seahorse-pgp-error.c
==============================================================================
--- (empty file)
+++ trunk/pgp/seahorse-pgp-error.c Tue Apr 29 01:59:52 2008
@@ -0,0 +1,34 @@
+
+#include "config.h"
+
+#include "seahorse-pgp-dialogs.h"
+
+#include "seahorse-util.h"
+
+#include <gpgme.h>
+
+void
+seahorse_pgp_handle_gpgme_error (gpgme_error_t err, const char* desc, ...)
+{
+ gchar *t = NULL;
+
+ switch (gpgme_err_code(err)) {
+ case GPG_ERR_CANCELED:
+ case GPG_ERR_NO_ERROR:
+ case GPG_ERR_ECANCELED:
+ return;
+ default:
+ break;
+ }
+
+ va_list ap;
+ va_start(ap, desc);
+
+ if (desc)
+ t = g_strdup_vprintf (desc, ap);
+
+ va_end(ap);
+
+ seahorse_util_show_error (NULL, t, gpgme_strerror (err));
+ g_free(t);
+}
Modified: trunk/pgp/seahorse-pgp-operation.c
==============================================================================
--- trunk/pgp/seahorse-pgp-operation.c (original)
+++ trunk/pgp/seahorse-pgp-operation.c Tue Apr 29 01:59:52 2008
@@ -288,7 +288,7 @@
/* Other Errors */
if (*gerr)
- seahorse_util_gpgme_to_error (*gerr, &error);
+ seahorse_gpgme_to_error (*gerr, &error);
/* No error, results available */
else
@@ -445,6 +445,6 @@
if (!seahorse_operation_is_running (op))
seahorse_operation_mark_start (op);
- seahorse_util_gpgme_to_error (gerr, &err);
+ seahorse_gpgme_to_error (gerr, &err);
seahorse_operation_mark_done (op, FALSE, err);
}
Modified: trunk/pgp/seahorse-pgp-source.c
==============================================================================
--- trunk/pgp/seahorse-pgp-source.c (original)
+++ trunk/pgp/seahorse-pgp-source.c Tue Apr 29 01:59:52 2008
@@ -19,23 +19,26 @@
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-#include <stdlib.h>
-#include <libintl.h>
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include "config.h"
+
+#include "seahorse-pgp-source.h"
+
+#include "seahorse-gpgme-io.h"
+#include "seahorse-gpgmex.h"
+#include "seahorse-gpg-options.h"
+#include "seahorse-pgp-key.h"
+#include "seahorse-pgp-key-op.h"
+#include "seahorse-pgp-operation.h"
#include "seahorse-operation.h"
#include "seahorse-util.h"
#include "seahorse-libdialogs.h"
#include "seahorse-passphrase.h"
-#include "pgp/seahorse-gpgmex.h"
-#include "pgp/seahorse-gpg-options.h"
-#include "pgp/seahorse-pgp-key.h"
-#include "pgp/seahorse-pgp-key-op.h"
-#include "pgp/seahorse-pgp-operation.h"
-#include "pgp/seahorse-pgp-source.h"
+#include <gio/gio.h>
+
+#include <stdlib.h>
+#include <libintl.h>
/* TODO: Verify properly that all keys we deal with are PGP keys */
@@ -197,6 +200,7 @@
ExportContext *ctx = (ExportContext*)p;
if (!ctx)
return;
+ gpgme_data_release (ctx->data);
g_array_free (ctx->keyids, TRUE);
g_free (ctx);
}
@@ -205,14 +209,21 @@
export_key_callback (SeahorsePGPOperation *pop, ExportContext *ctx)
{
gpgme_error_t gerr;
+ GError *err = NULL;
+ GOutputStream *output;
if (seahorse_operation_is_running (SEAHORSE_OPERATION (pop)))
seahorse_operation_mark_progress_full (SEAHORSE_OPERATION (pop), NULL,
ctx->at, ctx->keyids->len);
- /* Done, no need to do anything further */
- if (ctx->at >= ctx->keyids->len)
- return;
+ /* Done, close the output stream */
+ if (ctx->at >= ctx->keyids->len) {
+ output = seahorse_operation_get_result (SEAHORSE_OPERATION (pop));
+ g_return_if_fail (G_IS_OUTPUT_STREAM (output));
+ if (!g_output_stream_close (output, NULL, &err))
+ seahorse_operation_mark_done (SEAHORSE_OPERATION (pop), FALSE, err);
+ return;
+ }
/* Do the next key in the list */
gerr = gpgme_op_export_start (pop->gctx, g_array_index (ctx->keyids, const char*, ctx->at),
@@ -230,7 +241,7 @@
struct _SeahorsePGPSourcePrivate {
guint scheduled_refresh; /* Source for refresh timeout */
- GnomeVFSMonitorHandle *monitor_handle; /* For monitoring the .gnupg directory */
+ GFileMonitor *monitor_handle; /* For monitoring the .gnupg directory */
SeahorseMultiOperation *operations; /* A list of all current operations */
GList *orphan_secret; /* Orphan secret keys */
};
@@ -251,21 +262,21 @@
static SeahorseOperation* seahorse_pgp_source_load (SeahorseKeySource *src,
GQuark keyid);
static SeahorseOperation* seahorse_pgp_source_import (SeahorseKeySource *sksrc,
- gpgme_data_t data);
+ GInputStream *input);
static SeahorseOperation* seahorse_pgp_source_export (SeahorseKeySource *sksrc,
GList *keys,
gboolean complete,
- gpgme_data_t data);
+ GOutputStream *output);
static gboolean seahorse_pgp_source_remove (SeahorseKeySource *sksrc,
SeahorseKey *skey,
guint name,
GError **error);
/* Other forward decls */
-static void monitor_gpg_homedir (GnomeVFSMonitorHandle *handle,
- const gchar *monitor_uri,
- const gchar *info_uri,
- GnomeVFSMonitorEventType event_type,
+static void monitor_gpg_homedir (GFileMonitor *handle,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
gpointer user_data);
static void cancel_scheduled_refresh (SeahorsePGPSource *psrc);
@@ -285,7 +296,8 @@
gobject_class->set_property = seahorse_pgp_source_set_property;
gobject_class->get_property = seahorse_pgp_source_get_property;
- key_class = SEAHORSE_KEY_SOURCE_CLASS (klass);
+ key_class = SEAHORSE_KEY_SOURCE_CLASS (klass);
+ key_class->canonize_keyid = seahorse_pgp_key_get_cannonical_id;
key_class->load = seahorse_pgp_source_load;
key_class->stop = seahorse_pgp_source_stop;
key_class->get_state = seahorse_pgp_source_get_state;
@@ -313,35 +325,36 @@
static void
seahorse_pgp_source_init (SeahorsePGPSource *psrc)
{
- gpgme_error_t err;
- const gchar *gpg_homedir;
- GnomeVFSResult res;
- gchar *uri;
-
- err = init_gpgme (&(psrc->gctx));
- g_return_if_fail (GPG_IS_OK (err));
-
- /* init private vars */
- psrc->pv = g_new0 (SeahorsePGPSourcePrivate, 1);
-
- psrc->pv->operations = seahorse_multi_operation_new ();
-
- psrc->pv->scheduled_refresh = 0;
- psrc->pv->monitor_handle = NULL;
-
- gpg_homedir = seahorse_gpg_homedir ();
- uri = gnome_vfs_make_uri_canonical (gpg_homedir);
- g_return_if_fail (uri != NULL);
-
- res = gnome_vfs_monitor_add (&(psrc->pv->monitor_handle), uri,
- GNOME_VFS_MONITOR_DIRECTORY,
- monitor_gpg_homedir, psrc);
- g_free (uri);
-
- if (res != GNOME_VFS_OK) {
- psrc->pv->monitor_handle = NULL;
- g_warning ("couldn't monitor the GPG home directory: %s", gpg_homedir);
- }
+ gpgme_error_t gerr;
+ GError *err = NULL;
+ const gchar *gpg_homedir;
+ GFile *file;
+
+ gerr = init_gpgme (&(psrc->gctx));
+ g_return_if_fail (GPG_IS_OK (gerr));
+
+ /* init private vars */
+ psrc->pv = g_new0 (SeahorsePGPSourcePrivate, 1);
+
+ psrc->pv->operations = seahorse_multi_operation_new ();
+
+ psrc->pv->scheduled_refresh = 0;
+ psrc->pv->monitor_handle = NULL;
+
+ gpg_homedir = seahorse_gpg_homedir ();
+ file = g_file_new_for_path (gpg_homedir);
+ g_return_if_fail (file != NULL);
+
+ psrc->pv->monitor_handle = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, &err);
+ g_object_unref (file);
+
+ if (psrc->pv->monitor_handle) {
+ g_signal_connect (psrc->pv->monitor_handle, "changed",
+ G_CALLBACK (monitor_gpg_homedir), psrc);
+ } else {
+ g_warning ("couldn't monitor the GPG home directory: %s: %s",
+ gpg_homedir, err && err->message ? err->message : "");
+ }
}
/* dispose of all our internal references */
@@ -372,10 +385,10 @@
cancel_scheduled_refresh (psrc);
- if (psrc->pv->monitor_handle) {
- gnome_vfs_monitor_cancel (psrc->pv->monitor_handle);
- psrc->pv->monitor_handle = NULL;
- }
+ if (psrc->pv->monitor_handle) {
+ g_object_unref (psrc->pv->monitor_handle);
+ psrc->pv->monitor_handle = NULL;
+ }
for (l = psrc->pv->orphan_secret; l; l = g_list_next (l))
g_object_unref (l->data);
@@ -622,21 +635,25 @@
}
static void
-monitor_gpg_homedir (GnomeVFSMonitorHandle *handle, const gchar *monitor_uri,
- const gchar *info_uri, GnomeVFSMonitorEventType event_type,
- gpointer user_data)
-{
- SeahorsePGPSource *psrc = SEAHORSE_PGP_SOURCE (user_data);
-
- if (g_str_has_suffix (info_uri, SEAHORSE_EXT_GPG) &&
- (event_type == GNOME_VFS_MONITOR_EVENT_CREATED ||
- event_type == GNOME_VFS_MONITOR_EVENT_CHANGED ||
- event_type == GNOME_VFS_MONITOR_EVENT_DELETED)) {
- if (psrc->pv->scheduled_refresh == 0) {
- DEBUG_REFRESH ("scheduling refresh event due to file changes\n");
- psrc->pv->scheduled_refresh = g_timeout_add (500, scheduled_refresh, psrc);
- }
- }
+monitor_gpg_homedir (GFileMonitor *handle, GFile *file, GFile *other_file,
+ GFileMonitorEvent event_type, gpointer user_data)
+{
+ SeahorsePGPSource *psrc = SEAHORSE_PGP_SOURCE (user_data);
+ gchar *name;
+
+ if (event_type == G_FILE_MONITOR_EVENT_CHANGED ||
+ event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT ||
+ event_type == G_FILE_MONITOR_EVENT_DELETED ||
+ event_type == G_FILE_MONITOR_EVENT_CREATED) {
+
+ name = g_file_get_basename (file);
+ if (g_str_has_suffix (name, SEAHORSE_EXT_GPG)) {
+ if (psrc->pv->scheduled_refresh == 0) {
+ DEBUG_REFRESH ("scheduling refresh event due to file changes\n");
+ psrc->pv->scheduled_refresh = g_timeout_add (500, scheduled_refresh, psrc);
+ }
+ }
+ }
}
/* --------------------------------------------------------------------------
@@ -988,35 +1005,40 @@
}
static SeahorseOperation*
-seahorse_pgp_source_import (SeahorseKeySource *sksrc, gpgme_data_t data)
+seahorse_pgp_source_import (SeahorseKeySource *sksrc, GInputStream *input)
{
- SeahorsePGPOperation *pop;
- SeahorsePGPSource *psrc;
- gpgme_error_t gerr;
+ SeahorsePGPOperation *pop;
+ SeahorsePGPSource *psrc;
+ gpgme_error_t gerr;
+ gpgme_data_t data;
- g_return_val_if_fail (SEAHORSE_IS_PGP_SOURCE (sksrc), NULL);
- psrc = SEAHORSE_PGP_SOURCE (sksrc);
+ g_return_val_if_fail (SEAHORSE_IS_PGP_SOURCE (sksrc), NULL);
+ psrc = SEAHORSE_PGP_SOURCE (sksrc);
- pop = seahorse_pgp_operation_new (_("Importing Keys"));
- g_return_val_if_fail (pop != NULL, NULL);
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
- gpgme_data_seek (data, 0, SEEK_SET);
- gerr = gpgme_op_import_start (pop->gctx, data);
+ pop = seahorse_pgp_operation_new (_("Importing Keys"));
+ g_return_val_if_fail (pop != NULL, NULL);
- g_signal_connect (pop, "results", G_CALLBACK (prepare_import_results), psrc);
- g_object_set_data_full (G_OBJECT (pop), "source-data", data,
- (GDestroyNotify)gpgmex_data_release);
+ data = sea_gpgme_input_data (input);
+ g_return_val_if_fail (data, NULL);
- /* Couldn't start import */
- if (!GPG_IS_OK (gerr))
- seahorse_pgp_operation_mark_failed (pop, gerr);
+ gerr = gpgme_op_import_start (pop->gctx, data);
- return SEAHORSE_OPERATION (pop);
+ g_signal_connect (pop, "results", G_CALLBACK (prepare_import_results), psrc);
+ g_object_set_data_full (G_OBJECT (pop), "source-data", data,
+ (GDestroyNotify)gpgmex_data_release);
+
+ /* Couldn't start import */
+ if (!GPG_IS_OK (gerr))
+ seahorse_pgp_operation_mark_failed (pop, gerr);
+
+ return SEAHORSE_OPERATION (pop);
}
static SeahorseOperation*
seahorse_pgp_source_export (SeahorseKeySource *sksrc, GList *keys,
- gboolean complete, gpgme_data_t data)
+ gboolean complete, GOutputStream *output)
{
SeahorsePGPOperation *pop;
SeahorsePGPSource *psrc;
@@ -1024,36 +1046,34 @@
SeahorseKey *skey;
ExportContext *ctx;
gpgme_error_t gerr = GPG_OK;
+ gpgme_data_t data;
const gchar *keyid;
GList *l;
- g_return_val_if_fail (SEAHORSE_IS_PGP_SOURCE (sksrc), NULL);
- psrc = SEAHORSE_PGP_SOURCE (sksrc);
-
- pop = seahorse_pgp_operation_new (_("Exporting Keys"));
- g_return_val_if_fail (pop != NULL, NULL);
-
- if (data == NULL) {
-
- /* Tie to operation when we create our own (auto-free) */
- data = gpgmex_data_new ();
- seahorse_operation_mark_result (SEAHORSE_OPERATION (pop), data,
- (GDestroyNotify)gpgmex_data_release);
- } else {
-
- /* Don't free when people pass us their own data */
- seahorse_operation_mark_result (SEAHORSE_OPERATION (pop), data, NULL);
- }
+ g_return_val_if_fail (SEAHORSE_IS_PGP_SOURCE (sksrc), NULL);
+ g_return_val_if_fail (output == NULL || G_IS_OUTPUT_STREAM (output), NULL);
- gpgme_set_armor (pop->gctx, TRUE);
- gpgme_set_textmode (pop->gctx, TRUE);
+ psrc = SEAHORSE_PGP_SOURCE (sksrc);
+
+ pop = seahorse_pgp_operation_new (_("Exporting Keys"));
+ g_return_val_if_fail (pop != NULL, NULL);
- /* Export context for asynchronous export */
- ctx = g_new0(ExportContext, 1);
- ctx->keyids = g_array_new (TRUE, TRUE, sizeof (gchar*));
- ctx->at = 0;
- ctx->data = data;
- g_object_set_data_full (G_OBJECT (pop), "export-context", ctx, free_export_context);
+ g_object_ref (output);
+ seahorse_operation_mark_result (SEAHORSE_OPERATION (pop), output,
+ (GDestroyNotify)g_object_unref);
+
+ gpgme_set_armor (pop->gctx, TRUE);
+ gpgme_set_textmode (pop->gctx, TRUE);
+
+ data = sea_gpgme_output_data (output);
+ g_return_val_if_fail (data, NULL);
+
+ /* Export context for asynchronous export */
+ ctx = g_new0 (ExportContext, 1);
+ ctx->keyids = g_array_new (TRUE, TRUE, sizeof (gchar*));
+ ctx->at = 0;
+ ctx->data = data;
+ g_object_set_data_full (G_OBJECT (pop), "export-context", ctx, free_export_context);
for (l = keys; l != NULL; l = g_list_next (l)) {
@@ -1106,7 +1126,7 @@
gerr = seahorse_pgp_key_op_delete (SEAHORSE_PGP_KEY (skey));
if (!GPG_IS_OK (gerr)) {
- seahorse_util_gpgme_to_error (gerr, error);
+ seahorse_gpgme_to_error (gerr, error);
return FALSE;
}
Modified: trunk/pgp/seahorse-pgp-source.h
==============================================================================
--- trunk/pgp/seahorse-pgp-source.h (original)
+++ trunk/pgp/seahorse-pgp-source.h Tue Apr 29 01:59:52 2008
@@ -42,6 +42,8 @@
#include "seahorse-key-source.h"
+#include <gpgme.h>
+
#define SEAHORSE_TYPE_PGP_SOURCE (seahorse_pgp_source_get_type ())
#define SEAHORSE_PGP_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_PGP_SOURCE, SeahorsePGPSource))
#define SEAHORSE_PGP_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SEAHORSE_TYPE_PGP_SOURCE, SeahorsePGPSourceClass))
Modified: trunk/pgp/seahorse-server-source.c
==============================================================================
--- trunk/pgp/seahorse-server-source.c (original)
+++ trunk/pgp/seahorse-server-source.c Tue Apr 29 01:59:52 2008
@@ -79,6 +79,7 @@
key_class = SEAHORSE_KEY_SOURCE_CLASS (klass);
+ key_class->canonize_keyid = seahorse_pgp_key_get_cannonical_id;
key_class->load = seahorse_server_source_load;
key_class->stop = seahorse_server_source_stop;
key_class->get_state = seahorse_server_source_get_state;
Modified: trunk/pgp/seahorse-server-source.h
==============================================================================
--- trunk/pgp/seahorse-server-source.h (original)
+++ trunk/pgp/seahorse-server-source.h Tue Apr 29 01:59:52 2008
@@ -67,9 +67,6 @@
GType seahorse_server_source_get_type (void);
-void seahorse_server_source_add_key (SeahorseServerSource *ssrc,
- gpgme_key_t key);
-
void seahorse_server_source_take_operation (SeahorseServerSource *ssrc,
SeahorseOperation *operation);
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Apr 29 01:59:52 2008
@@ -55,7 +55,7 @@
$(top_builddir)/libseahorse/libseahorse.la \
$(top_builddir)/pgp/libsea-pgp.la \
$(top_builddir)/ssh/libsea-ssh.la \
- $(top_builddir)/gkr/libsea-gkr.la \
+ $(top_builddir)/gkr/libseahorse-gkr.la \
$(top_builddir)/common/libsea-common.la \
$(top_builddir)/libcryptui/libcryptui.la \
$(SEAHORSE_LIBS)
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Tue Apr 29 01:59:52 2008
@@ -20,10 +20,7 @@
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <locale.h>
+#include "config.h"
#include "seahorse-context.h"
#include "seahorse-windows.h"
@@ -32,9 +29,22 @@
#include "seahorse-gtkstock.h"
#include "seahorse-secure-memory.h"
+#include "common/sea-cleanup.h"
+#include "common/sea-registry.h"
+
+#include "pgp/sea-pgp.h"
#include "pgp/seahorse-pgp-key.h"
#include "pgp/seahorse-pgp-source.h"
+#ifdef WITH_SSH
+#include "ssh/sea-ssh.h"
+#endif
+
+#include "gkr/seahorse-gkr.h"
+
+#include <gnome.h>
+#include <locale.h>
+
/* Initializes context and preferences, then loads key manager */
int
main (int argc, char **argv)
@@ -63,7 +73,11 @@
GNOME_PARAM_APP_DATADIR, DATA_DIR, NULL);
/* Insert Icons into Stock */
- seahorse_gtkstock_init();
+ seahorse_gtkstock_init ();
+
+ /* Initialize the various components */
+ sea_registry_load_types (NULL, SEA_PGP_REGISTRY);
+ sea_registry_load_types (NULL, SEA_SSH_REGISTRY);
/* Make the default SeahorseContext */
seahorse_context_new (SEAHORSE_CONTEXT_APP, 0);
@@ -74,8 +88,6 @@
gtk_main ();
- if (gnome_vfs_initialized ())
- gnome_vfs_shutdown ();
-
+ sea_cleanup_perform ();
return ret;
}
Modified: trunk/src/seahorse-add-subkey.c
==============================================================================
--- trunk/src/seahorse-add-subkey.c (original)
+++ trunk/src/seahorse-add-subkey.c Tue Apr 29 01:59:52 2008
@@ -19,14 +19,13 @@
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-#include <gnome.h>
+#include "config.h"
#include "seahorse-key-dialogs.h"
#include "seahorse-key-widget.h"
#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key-op.h"
#define EXPIRES "expires"
@@ -132,7 +131,7 @@
gtk_widget_set_sensitive (widget, TRUE);
if (!GPG_IS_OK (err))
- seahorse_util_handle_gpgme (err, _("Couldn't add subkey"));
+ seahorse_pgp_handle_gpgme_error (err, _("Couldn't add subkey"));
seahorse_widget_destroy (swidget);
}
Modified: trunk/src/seahorse-add-uid.c
==============================================================================
--- trunk/src/seahorse-add-uid.c (original)
+++ trunk/src/seahorse-add-uid.c Tue Apr 29 01:59:52 2008
@@ -19,14 +19,13 @@
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-#include <gnome.h>
+#include "config.h"
#include "seahorse-key-dialogs.h"
#include "seahorse-key-widget.h"
#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key-op.h"
#define NAME "name"
@@ -80,7 +79,7 @@
err = seahorse_pgp_key_pair_op_add_uid (SEAHORSE_PGP_KEY (skey),
name, email, comment);
if (!GPG_IS_OK (err))
- seahorse_util_handle_gpgme (err, _("Couldn't add user id"));
+ seahorse_pgp_handle_gpgme_error (err, _("Couldn't add user id"));
else
seahorse_widget_destroy (swidget);
}
Modified: trunk/src/seahorse-delete.c
==============================================================================
--- trunk/src/seahorse-delete.c (original)
+++ trunk/src/seahorse-delete.c Tue Apr 29 01:59:52 2008
@@ -19,13 +19,12 @@
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-#include <gnome.h>
+#include "config.h"
#include "seahorse-windows.h"
#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key-op.h"
static gboolean
@@ -160,7 +159,7 @@
err = seahorse_pgp_key_op_del_subkey (pkey, index);
if (!GPG_IS_OK (err))
- seahorse_util_handle_gpgme (err, _("Couldn't delete subkey"));
+ seahorse_pgp_handle_gpgme_error (err, _("Couldn't delete subkey"));
}
void
Modified: trunk/src/seahorse-expires.c
==============================================================================
--- trunk/src/seahorse-expires.c (original)
+++ trunk/src/seahorse-expires.c Tue Apr 29 01:59:52 2008
@@ -19,15 +19,14 @@
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-#include <gnome.h>
+#include "config.h"
#include "seahorse-key-dialogs.h"
#include "seahorse-key-widget.h"
#include "seahorse-libdialogs.h"
#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key-op.h"
static void
@@ -65,7 +64,7 @@
err = seahorse_pgp_key_pair_op_set_expires (pkey, index, expiry);
if (!GPG_IS_OK (err))
- seahorse_util_handle_gpgme (err, _("Couldn't change expiry date"));
+ seahorse_pgp_handle_gpgme_error (err, _("Couldn't change expiry date"));
}
seahorse_widget_destroy (swidget);
Modified: trunk/src/seahorse-key-manager-store.c
==============================================================================
--- trunk/src/seahorse-key-manager-store.c (original)
+++ trunk/src/seahorse-key-manager-store.c Tue Apr 29 01:59:52 2008
@@ -29,9 +29,7 @@
#include "seahorse-util.h"
#include "seahorse-gconf.h"
#include "eggtreemultidnd.h"
-#include "seahorse-vfs-data.h"
-#include "pgp/seahorse-gpgmex.h"
#include "pgp/seahorse-pgp-key.h"
#ifdef WITH_SSH
@@ -584,7 +582,7 @@
SeahorseMultiOperation *mop = NULL;
SeahorseOperation *op = NULL;
GList *next, *keys, *sel_keys = NULL;
- gpgme_data_t data = NULL;
+ GOutputStream *output = NULL;
SeahorseKey *skey;
DBG_PRINT (("drag_begin -->\n"));
@@ -611,16 +609,16 @@
if (!mop)
mop = seahorse_multi_operation_new ();
- /* The data object where we export to */
- if (!data) {
- data = gpgmex_data_new ();
- g_object_set_data_full (G_OBJECT (mop), "result-data", data,
- (GDestroyNotify)gpgmex_data_release);
- }
-
- /* We pass our own data object, to which data is appended */
- op = seahorse_key_source_export (sksrc, keys, FALSE, data);
- g_return_if_fail (op != NULL);
+ /* The data object where we export to */
+ if (!output) {
+ output = g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
+ g_object_set_data_full (G_OBJECT (mop), "result-data", output,
+ (GDestroyNotify)g_object_unref);
+ }
+
+ /* We pass our own data object, to which data is appended */
+ op = seahorse_key_source_export (sksrc, keys, FALSE, output);
+ g_return_if_fail (op != NULL);
g_list_free (keys);
keys = next;
@@ -668,7 +666,7 @@
gchar *t, *n;
GList *keys;
GError *err = NULL;
- gpgme_data_t data;
+ GMemoryOutputStream *output;
gchar *text;
DBG_PRINT (("drag_data_get %d -->\n", info));
@@ -689,10 +687,10 @@
return;
}
- data = (gpgme_data_t)g_object_get_data (G_OBJECT (op), "result-data");
- g_return_if_fail (data != NULL);
+ output = g_object_get_data (G_OBJECT (op), "result-data");
+ g_return_if_fail (G_IS_MEMORY_OUTPUT_STREAM (output));
- text = seahorse_util_write_data_to_text (data, NULL);
+ text = g_memory_output_stream_get_data (output);
g_return_if_fail (text != NULL);
if (info == TEXT_PLAIN) {
@@ -715,7 +713,7 @@
DBG_PRINT (("writing to temp file: %s\n", t));
- if (!seahorse_vfs_set_file_contents (t, text, strlen (text), &err)) {
+ if (!g_file_set_contents (t, text, strlen (text), &err)) {
seahorse_util_handle_error (err, _("Couldn't write key to file"));
g_object_set_data (G_OBJECT (widget), "drag-file", NULL);
t = NULL;
Modified: trunk/src/seahorse-key-manager.c
==============================================================================
--- trunk/src/seahorse-key-manager.c (original)
+++ trunk/src/seahorse-key-manager.c Tue Apr 29 01:59:52 2008
@@ -23,7 +23,6 @@
#include "config.h"
#include <gnome.h>
#include <gconf/gconf-client.h>
-#include <libgnomevfs/gnome-vfs.h>
#include "seahorse-windows.h"
#include "seahorse-widget.h"
@@ -38,9 +37,7 @@
#include "seahorse-gconf.h"
#include "seahorse-gtkstock.h"
#include "seahorse-key-source.h"
-#include "seahorse-vfs-data.h"
-#include "pgp/seahorse-gpgmex.h"
#include "pgp/seahorse-gpg-options.h"
#include "pgp/seahorse-pgp-key-op.h"
@@ -404,9 +401,10 @@
SeahorseKeySource *sksrc;
SeahorseMultiOperation *mop;
SeahorseOperation *op;
- gpgme_data_t data;
GString *errmsg = NULL;
GError *err = NULL;
+ GFile *file;
+ GFileInputStream *input;
const gchar **u;
GQuark ktype;
@@ -429,18 +427,24 @@
sksrc = seahorse_context_find_key_source (SCTX_APP (), ktype, SKEY_LOC_LOCAL);
g_return_if_fail (sksrc);
- /* Load up the file */
- data = seahorse_vfs_data_create (*u, SEAHORSE_VFS_READ, &err);
- if (!data) {
- g_string_append_printf (errmsg, "%s: %s", *u,
- err && err->message ? err->message : _("Couldn't read file"));
- continue;
- }
+ /* Load up the file */
+ file = g_file_new_for_uri (*u);
+ g_return_if_fail (file);
+ input = g_file_read (file, NULL, &err);
+ g_object_unref (file);
+
+ if (!input) {
+ g_string_append_printf (errmsg, "%s: %s", *u,
+ err && err->message ? err->message : _("Couldn't read file"));
+ continue;
+ }
+
+ /* data is freed here */
+ op = seahorse_key_source_import (sksrc, G_INPUT_STREAM (input));
+ g_return_if_fail (op != NULL);
- /* data is freed here */
- op = seahorse_key_source_import (sksrc, data);
- g_return_if_fail (op != NULL);
- seahorse_multi_operation_take (mop, op);
+ g_object_unref (input);
+ seahorse_multi_operation_take (mop, op);
}
if (seahorse_operation_is_running (SEAHORSE_OPERATION (mop))) {
@@ -464,7 +468,7 @@
{
SeahorseKeySource *sksrc;
SeahorseOperation *op;
- gpgme_data_t data;
+ GInputStream *input;
GQuark ktype;
guint len;
@@ -484,12 +488,11 @@
sksrc = seahorse_context_find_key_source (SCTX_APP (), ktype, SKEY_LOC_LOCAL);
g_return_if_fail (sksrc && SEAHORSE_IS_PGP_SOURCE (sksrc));
- data = gpgmex_data_new_from_mem (text, strlen (text), TRUE);
- g_return_if_fail (data != NULL);
-
- /* data is freed here */
- op = seahorse_key_source_import (sksrc, data);
- g_return_if_fail (op != NULL);
+ input = g_memory_input_stream_new_from_data (g_strdup (text), strlen (text), g_free);
+ g_return_if_fail (input);
+
+ op = seahorse_key_source_import (sksrc, input);
+ g_return_if_fail (op != NULL);
seahorse_operation_watch (op, G_CALLBACK (imported_keys), NULL, swidget);
seahorse_progress_show (op, _("Importing Keys"), TRUE);
@@ -543,26 +546,29 @@
{
GdkAtom atom;
GtkClipboard *board;
+ GMemoryOutputStream *output;
gchar *text;
GError *err = NULL;
- gpgme_data_t data;
guint num;
+ gsize size;
if (!seahorse_operation_is_successful (op)) {
seahorse_operation_copy_error (op, &err);
seahorse_util_handle_error (err, _("Couldn't retrieve data from key server"));
}
- data = (gpgme_data_t)seahorse_operation_get_result (op);
- g_return_if_fail (data != NULL);
-
- text = seahorse_util_write_data_to_text (data, NULL);
- g_return_if_fail (text != NULL);
-
- atom = gdk_atom_intern ("CLIPBOARD", FALSE);
- board = gtk_clipboard_get (atom);
- gtk_clipboard_set_text (board, text, strlen (text));
- g_free (text);
+ output = G_MEMORY_OUTPUT_STREAM (seahorse_operation_get_result (op));
+ g_return_if_fail (G_IS_MEMORY_OUTPUT_STREAM (output));
+
+ text = g_memory_output_stream_get_data (output);
+ g_return_if_fail (text != NULL);
+
+ size = seahorse_util_memory_output_length (output);
+ g_return_if_fail (size >= 0);
+
+ atom = gdk_atom_intern ("CLIPBOARD", FALSE);
+ board = gtk_clipboard_get (atom);
+ gtk_clipboard_set_text (board, text, size);
num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (op), "num-keys"));
if (num > 0) {
@@ -576,6 +582,7 @@
copy_activate (GtkWidget *widget, SeahorseWidget *swidget)
{
SeahorseOperation *op;
+ GOutputStream *output;
GList *keys;
guint num;
@@ -585,10 +592,14 @@
if (num == 0)
return;
- op = seahorse_key_source_export_keys (keys, NULL);
- g_return_if_fail (op != NULL);
-
- g_object_set_data (G_OBJECT (op), "num-keys", GINT_TO_POINTER (num));
+ output = g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
+ g_return_if_fail (output);
+
+ op = seahorse_key_source_export_keys (keys, output);
+ g_return_if_fail (op != NULL);
+
+ g_object_set_data_full (G_OBJECT (op), "output-stream", output, g_object_unref);
+ g_object_set_data (G_OBJECT (op), "num-keys", GINT_TO_POINTER (num));
seahorse_progress_show (op, _("Retrieving keys"), TRUE);
seahorse_operation_watch (op, G_CALLBACK (copy_done), NULL, swidget);
@@ -629,7 +640,8 @@
GtkWidget *dialog;
gchar* uri = NULL;
GError *err = NULL;
- gpgme_data_t data;
+ GFile *file;
+ GFileOutputStream *output;
GList *keys;
keys = get_selected_keys (swidget);
@@ -644,19 +656,24 @@
uri = seahorse_util_chooser_save_prompt (dialog);
if(uri) {
- data = seahorse_vfs_data_create (uri, SEAHORSE_VFS_WRITE, &err);
- if (!data) {
- seahorse_util_handle_error (err, _("Couldn't export key to \"%s\""),
- seahorse_util_uri_get_last (uri));
- return;
- }
-
- op = seahorse_key_source_export_keys (keys, data);
- g_return_if_fail (op != NULL);
-
- g_object_set_data_full (G_OBJECT (op), "exported-file-uri", uri, g_free);
- g_object_set_data_full (G_OBJECT (op), "exported-file-data", data,
- (GDestroyNotify)gpgmex_data_release);
+ file = g_file_new_for_uri (uri);
+ g_return_if_fail (file);
+ output = g_file_replace (file, NULL, FALSE, 0, NULL, &err);
+ g_object_unref (file);
+
+ if (!output) {
+ seahorse_util_handle_error (err, _("Couldn't export key to \"%s\""),
+ seahorse_util_uri_get_last (uri));
+ return;
+ }
+
+ op = seahorse_key_source_export_keys (keys, G_OUTPUT_STREAM (output));
+ g_return_if_fail (op != NULL);
+ g_object_unref (output);
+
+ g_object_set_data_full (G_OBJECT (op), "exported-file-uri", uri, g_free);
+ g_object_set_data_full (G_OBJECT (op), "exported-file-stream", output,
+ (GDestroyNotify)g_object_unref);
seahorse_progress_show (op, _("Exporting keys"), TRUE);
seahorse_operation_watch (op, G_CALLBACK (export_done), NULL, swidget);
Modified: trunk/src/seahorse-key-properties.c
==============================================================================
--- trunk/src/seahorse-key-properties.c (original)
+++ trunk/src/seahorse-key-properties.c Tue Apr 29 01:59:52 2008
@@ -24,20 +24,18 @@
/* TODO: Make sure to free when getting text from seahorse_pgp_key_* */
#include "config.h"
-#include <gnome.h>
-#include <time.h>
#include "seahorse-key-dialogs.h"
+
+#include "seahorse-gconf.h"
+#include "seahorse-gtkstock.h"
+#include "seahorse-key.h"
+#include "seahorse-key-model.h"
#include "seahorse-key-widget.h"
#include "seahorse-util.h"
-#include "seahorse-key.h"
-#include "seahorse-gtkstock.h"
#include "seahorse-windows.h"
-#include "seahorse-vfs-data.h"
-#include "seahorse-key-model.h"
-#include "seahorse-gconf.h"
-#include "pgp/seahorse-gpgmex.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key.h"
#include "pgp/seahorse-pgp-key-op.h"
@@ -45,6 +43,8 @@
#include "seahorse-keyserver-sync.h"
#endif
+#include <time.h>
+
#define NOTEBOOK "notebook"
static void
@@ -206,7 +206,7 @@
if (index > 0) {
err = seahorse_pgp_key_op_primary_uid (SEAHORSE_PGP_KEY (skey), index);
if (!GPG_IS_OK (err))
- seahorse_util_handle_gpgme (err, _("Couldn't change primary user ID"));
+ seahorse_pgp_handle_gpgme_error (err, _("Couldn't change primary user ID"));
}
}
@@ -556,7 +556,7 @@
gerr = seahorse_pgp_key_op_photoid_primary (pkey, uid);
if (!GPG_IS_OK (gerr))
- seahorse_util_handle_gpgme (gerr, _("Couldn't change primary photo"));
+ seahorse_pgp_handle_gpgme_error (gerr, _("Couldn't change primary photo"));
}
static void
@@ -990,7 +990,7 @@
if (seahorse_key_get_trust (skey) != trust) {
err = seahorse_pgp_key_op_set_trust (SEAHORSE_PGP_KEY (skey), trust);
if (err) {
- seahorse_util_handle_gpgme (err, _("Unable to change trust"));
+ seahorse_pgp_handle_gpgme_error (err, _("Unable to change trust"));
}
}
}
@@ -1005,7 +1005,8 @@
GtkWidget *dialog;
gchar* uri = NULL;
GError *err = NULL;
- gpgme_data_t data;
+ GFile *file;
+ GFileOutputStream *output;
GList *keys = NULL;
skey = SEAHORSE_KEY_WIDGET (swidget)->skey;
@@ -1023,21 +1024,23 @@
sksrc = seahorse_key_get_source (skey);
g_assert (SEAHORSE_IS_KEY_SOURCE (sksrc));
- data = seahorse_vfs_data_create (uri, SEAHORSE_VFS_WRITE, &err);
+ file = g_file_new_for_uri (uri);
+ output = g_file_replace (file, NULL, FALSE, 0, NULL, &err);
+ g_object_unref (file);
- if (data) {
- op = seahorse_key_source_export (sksrc, keys, TRUE, data);
+ if (output) {
+ op = seahorse_key_source_export (sksrc, keys, TRUE, G_OUTPUT_STREAM (output));
- seahorse_operation_wait (op);
- gpgmex_data_release (data);
+ seahorse_operation_wait (op);
+ g_object_unref (output);
- if (!seahorse_operation_is_successful (op))
- seahorse_operation_copy_error (op, &err);
- }
+ if (!seahorse_operation_is_successful (op))
+ seahorse_operation_copy_error (op, &err);
+ }
- if (err)
- seahorse_util_handle_error (err, _("Couldn't export key to \"%s\""),
- seahorse_util_uri_get_last (uri));
+ if (err)
+ seahorse_util_handle_error (err, _("Couldn't export key to \"%s\""),
+ seahorse_util_uri_get_last (uri));
g_list_free (keys);
g_free (uri);
@@ -1384,7 +1387,7 @@
if (seahorse_key_get_trust (skey) != trust) {
err = seahorse_pgp_key_op_set_trust (SEAHORSE_PGP_KEY (skey), trust);
if (err)
- seahorse_util_handle_gpgme (err, _("Unable to change trust"));
+ seahorse_pgp_handle_gpgme_error (err, _("Unable to change trust"));
}
}
@@ -1403,7 +1406,7 @@
if (seahorse_key_get_trust (skey) != trust) {
err = seahorse_pgp_key_op_set_trust (SEAHORSE_PGP_KEY (skey), trust);
if (err)
- seahorse_util_handle_gpgme (err, _("Unable to change trust"));
+ seahorse_pgp_handle_gpgme_error (err, _("Unable to change trust"));
}
}
Modified: trunk/src/seahorse-keyserver-results.c
==============================================================================
--- trunk/src/seahorse-keyserver-results.c (original)
+++ trunk/src/seahorse-keyserver-results.c Tue Apr 29 01:59:52 2008
@@ -33,9 +33,7 @@
#include "seahorse-key-manager-store.h"
#include "seahorse-key-widget.h"
#include "seahorse-key-dialogs.h"
-#include "seahorse-vfs-data.h"
-#include "pgp/seahorse-gpgmex.h"
#include "pgp/seahorse-pgp-key.h"
#define KEY_LIST "key_list"
@@ -158,8 +156,9 @@
GtkWidget *dialog;
gchar* uri = NULL;
GError *err = NULL;
- gpgme_data_t data;
+ GFileOutputStream *output;
GList *keys;
+ GFile *file;
keys = seahorse_key_manager_store_get_selected_keys (GTK_TREE_VIEW (
glade_xml_get_widget (swidget->xml, KEY_LIST)));
@@ -175,29 +174,33 @@
uri = seahorse_util_chooser_save_prompt (dialog);
- if(uri) {
-
- data = seahorse_vfs_data_create (uri, SEAHORSE_VFS_WRITE, &err);
- if (!data) {
- seahorse_util_handle_error (err, _("Couldn't write keys to file: %s"),
- seahorse_util_uri_get_last (uri));
- g_free (uri);
+ if(uri) {
+ file = g_file_new_for_uri (uri);
+ g_return_if_fail (file);
+
+ output = g_file_replace (file, NULL, FALSE, 0, NULL, &err);
+ g_object_unref (file);
+
+ if (!output) {
+ seahorse_util_handle_error (err, _("Couldn't write keys to file: %s"),
+ seahorse_util_uri_get_last (uri));
+ g_free (uri);
- } else {
+ } else {
- op = seahorse_key_source_export_keys (keys, data);
- g_return_if_fail (op != NULL);
+ op = seahorse_key_source_export_keys (keys, G_OUTPUT_STREAM (output));
+ g_return_if_fail (op != NULL);
- g_object_set_data_full (G_OBJECT (op), "export-uri", uri, g_free);
- g_object_set_data_full (G_OBJECT (op), "export-data", data,
- (GDestroyNotify)gpgmex_data_release);
+ g_object_set_data_full (G_OBJECT (op), "export-uri", uri, g_free);
+ g_object_set_data_full (G_OBJECT (op), "export-data", output,
+ (GDestroyNotify)g_object_unref);
- seahorse_progress_show (op, _("Retrieving keys"), TRUE);
- seahorse_operation_watch (op, G_CALLBACK (export_done), NULL, swidget);
+ seahorse_progress_show (op, _("Retrieving keys"), TRUE);
+ seahorse_operation_watch (op, G_CALLBACK (export_done), NULL, swidget);
- /* Running operation refs itself */
- g_object_unref (op);
- }
+ /* Running operation refs itself */
+ g_object_unref (op);
+ }
}
/* uri is freed with op */
@@ -209,26 +212,29 @@
{
GdkAtom atom;
GtkClipboard *board;
+ GMemoryOutputStream *output;
gchar *text;
GError *err = NULL;
- gpgme_data_t data;
guint num;
+ gsize size;
if (!seahorse_operation_is_successful (op)) {
seahorse_operation_copy_error (op, &err);
seahorse_util_handle_error (err, _("Couldn't retrieve data from key server"));
}
- data = (gpgme_data_t)seahorse_operation_get_result (op);
- g_return_if_fail (data != NULL);
+ output = G_MEMORY_OUTPUT_STREAM (seahorse_operation_get_result (op));
+ g_return_if_fail (G_IS_MEMORY_OUTPUT_STREAM (output));
+
+ text = g_memory_output_stream_get_data (output);
+ g_return_if_fail (text != NULL);
- text = seahorse_util_write_data_to_text (data, NULL);
- g_return_if_fail (text != NULL);
+ size = seahorse_util_memory_output_length (output);
+ g_return_if_fail (size >= 0);
- atom = gdk_atom_intern ("CLIPBOARD", FALSE);
- board = gtk_clipboard_get (atom);
- gtk_clipboard_set_text (board, text, strlen (text));
- g_free (text);
+ atom = gdk_atom_intern ("CLIPBOARD", FALSE);
+ board = gtk_clipboard_get (atom);
+ gtk_clipboard_set_text (board, text, size);
num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (op), "num-keys"));
if (num > 0) {
@@ -242,6 +248,7 @@
copy_activate (GtkWidget *widget, SeahorseWidget *swidget)
{
SeahorseOperation *op;
+ GOutputStream *output;
GList *keys;
guint num;
@@ -252,10 +259,14 @@
if (num == 0)
return;
- op = seahorse_key_source_export_keys (keys, NULL);
- g_return_if_fail (op != NULL);
+ output = g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
+ g_return_if_fail (output);
+
+ op = seahorse_key_source_export_keys (keys, output);
+ g_return_if_fail (op != NULL);
- g_object_set_data (G_OBJECT (op), "num-keys", GINT_TO_POINTER (num));
+ g_object_set_data_full (G_OBJECT (op), "output-stream", output, g_object_unref);
+ g_object_set_data (G_OBJECT (op), "num-keys", GINT_TO_POINTER (num));
seahorse_progress_show (op, _("Retrieving keys"), TRUE);
seahorse_operation_watch (op, G_CALLBACK (copy_done), NULL, swidget);
Modified: trunk/src/seahorse-keyserver-search.c
==============================================================================
--- trunk/src/seahorse-keyserver-search.c (original)
+++ trunk/src/seahorse-keyserver-search.c Tue Apr 29 01:59:52 2008
@@ -30,7 +30,6 @@
#include "seahorse-context.h"
#include "seahorse-dns-sd.h"
-#include "pgp/seahorse-gpgmex.h"
#include "pgp/seahorse-server-source.h"
typedef struct _KeyserverSelection {
Modified: trunk/src/seahorse-keyserver-sync.c
==============================================================================
--- trunk/src/seahorse-keyserver-sync.c (original)
+++ trunk/src/seahorse-keyserver-sync.c Tue Apr 29 01:59:52 2008
@@ -32,7 +32,6 @@
#include "seahorse-transfer-operation.h"
#include "seahorse-keyserver-sync.h"
-#include "pgp/seahorse-gpgmex.h"
#include "pgp/seahorse-server-source.h"
static void
Modified: trunk/src/seahorse-pgp-generate.c
==============================================================================
--- trunk/src/seahorse-pgp-generate.c (original)
+++ trunk/src/seahorse-pgp-generate.c Tue Apr 29 01:59:52 2008
@@ -20,7 +20,6 @@
*/
#include "config.h"
-#include <gnome.h>
#include "seahorse-widget.h"
#include "seahorse-util.h"
@@ -29,6 +28,7 @@
#include "seahorse-gtkstock.h"
#include "seahorse-passphrase.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key.h"
#include "pgp/seahorse-pgp-key-op.h"
#include "pgp/seahorse-pgp-source.h"
@@ -146,7 +146,7 @@
pass, type, bits, expires, &gerr);
if (!GPG_IS_OK (gerr)) {
- seahorse_util_handle_gpgme (gerr, _("Couldn't generate key"));
+ seahorse_pgp_handle_gpgme_error (gerr, _("Couldn't generate key"));
} else {
seahorse_progress_show (op, _("Generating key"), TRUE);
seahorse_operation_watch (op, G_CALLBACK (completion_handler), NULL, NULL);
Modified: trunk/src/seahorse-photos.c
==============================================================================
--- trunk/src/seahorse-photos.c (original)
+++ trunk/src/seahorse-photos.c Tue Apr 29 01:59:52 2008
@@ -31,6 +31,7 @@
#include "seahorse-util.h"
#include "seahorse-key-dialogs.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key-op.h"
#define DEFAULT_WIDTH 120
@@ -287,7 +288,7 @@
_("The file could not be loaded. It may be in an invalid format"));
else
- seahorse_util_handle_gpgme (gerr, _("Couldn't add photo"));
+ seahorse_pgp_handle_gpgme_error (gerr, _("Couldn't add photo"));
res = FALSE;
}
@@ -327,7 +328,7 @@
gerr = seahorse_pgp_key_op_photoid_delete (pkey, photo->uid);
if (!GPG_IS_OK (gerr)) {
- seahorse_util_handle_gpgme (gerr, _("Couldn't delete photo"));
+ seahorse_pgp_handle_gpgme_error (gerr, _("Couldn't delete photo"));
return FALSE;
}
Modified: trunk/src/seahorse-revoke.c
==============================================================================
--- trunk/src/seahorse-revoke.c (original)
+++ trunk/src/seahorse-revoke.c Tue Apr 29 01:59:52 2008
@@ -19,15 +19,14 @@
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-#include <gnome.h>
+#include "config.h"
#include "seahorse-key-dialogs.h"
#include "seahorse-key-widget.h"
#include "seahorse-libdialogs.h"
#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key-op.h"
enum {
@@ -70,7 +69,7 @@
err = seahorse_pgp_key_op_revoke_subkey (SEAHORSE_PGP_KEY (skwidget->skey),
skwidget->index, reason, description);
if (!GPG_IS_OK (err))
- seahorse_util_handle_gpgme (err, _("Couldn't revoke subkey"));
+ seahorse_pgp_handle_gpgme_error (err, _("Couldn't revoke subkey"));
}
seahorse_widget_destroy (swidget);
}
@@ -186,5 +185,5 @@
err = seahorse_pgp_key_pair_op_add_revoker (pkey, revoker);
if (!GPG_IS_OK (err))
- seahorse_util_handle_gpgme (err, _("Couldn't add revoker"));
+ seahorse_pgp_handle_gpgme_error (err, _("Couldn't add revoker"));
}
Modified: trunk/src/seahorse-sign.c
==============================================================================
--- trunk/src/seahorse-sign.c (original)
+++ trunk/src/seahorse-sign.c Tue Apr 29 01:59:52 2008
@@ -20,7 +20,7 @@
* Boston, MA 02111-1307, USA.
*/
-#include <gnome.h>
+#include "config.h"
#include "seahorse-windows.h"
#include "seahorse-key-widget.h"
@@ -30,7 +30,7 @@
#include "seahorse-combo-keys.h"
#include "seahorse-gconf.h"
-#include "pgp/seahorse-gpgmex.h"
+#include "pgp/seahorse-pgp-dialogs.h"
#include "pgp/seahorse-pgp-key-op.h"
#ifdef WITH_KEYSERVER
@@ -95,7 +95,7 @@
SEAHORSE_PGP_KEY (signer),
skwidget->index + 1, check, options);
if (!GPG_IS_OK (err))
- seahorse_util_handle_gpgme (err, _("Couldn't sign key"));
+ seahorse_pgp_handle_gpgme_error (err, _("Couldn't sign key"));
seahorse_widget_destroy (swidget);
Modified: trunk/src/seahorse-ssh-key-properties.c
==============================================================================
--- trunk/src/seahorse-ssh-key-properties.c (original)
+++ trunk/src/seahorse-ssh-key-properties.c Tue Apr 29 01:59:52 2008
@@ -18,16 +18,13 @@
* 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
-#include <gnome.h>
+#include "config.h"
#include "seahorse-key-widget.h"
-#include "seahorse-util.h"
-#include "seahorse-key.h"
-#include "seahorse-vfs-data.h"
-#include "seahorse-gtkstock.h"
-#include "pgp/seahorse-gpgmex.h"
+#include "seahorse-gtkstock.h"
+#include "seahorse-key.h"
+#include "seahorse-util.h"
#include "ssh/seahorse-ssh-key.h"
#include "ssh/seahorse-ssh-operation.h"
@@ -205,7 +202,8 @@
SeahorseKeySource *sksrc;
SeahorseOperation *op;
SeahorseKey *skey;
- gpgme_data_t data;
+ GFileOutputStream *output;
+ GFile *file;
GtkWidget *dialog;
gchar* uri = NULL;
GError *err = NULL;
@@ -226,17 +224,19 @@
sksrc = seahorse_key_get_source (skey);
g_assert (SEAHORSE_IS_KEY_SOURCE (sksrc));
- data = seahorse_vfs_data_create (uri, SEAHORSE_VFS_WRITE, &err);
-
- if (data) {
- op = seahorse_key_source_export (sksrc, keys, TRUE, data);
-
- seahorse_operation_wait (op);
- gpgmex_data_release (data);
-
- if (!seahorse_operation_is_successful (op))
- seahorse_operation_copy_error (op, &err);
- }
+ file = g_file_new_for_uri (uri);
+ output = g_file_replace (file, NULL, FALSE, 0, NULL, &err);
+ g_object_unref (file);
+
+ if (output) {
+ op = seahorse_key_source_export (sksrc, keys, TRUE, G_OUTPUT_STREAM (output));
+
+ seahorse_operation_wait (op);
+ g_object_unref (output);
+
+ if (!seahorse_operation_is_successful (op))
+ seahorse_operation_copy_error (op, &err);
+ }
if (err)
seahorse_util_handle_error (err, _("Couldn't export key to \"%s\""),
Modified: trunk/ssh/seahorse-ssh-operation.c
==============================================================================
--- trunk/ssh/seahorse-ssh-operation.c (original)
+++ trunk/ssh/seahorse-ssh-operation.c Tue Apr 29 01:59:52 2008
@@ -29,8 +29,6 @@
#include "seahorse-util.h"
#include "seahorse-passphrase.h"
-#include "pgp/seahorse-gpgmex.h"
-
#include <gnome-keyring.h>
#ifndef DEBUG_OPERATION_ENABLE
@@ -732,9 +730,8 @@
{
SeahorseSSHOperationPrivate *pv;
SeahorseOperation *op;
- gpgme_data_t data;
- gpgme_error_t gerr;
- gchar *input;
+ GMemoryOutputStream *output;
+ gchar *data;
size_t length;
gchar *cmd;
@@ -745,12 +742,12 @@
if (port && !port[0])
port = NULL;
- gerr = gpgme_data_new (&data);
- g_return_val_if_fail (GPG_IS_OK (gerr), NULL);
-
- /* Buffer for what we send to the server */
- op = seahorse_key_source_export (SEAHORSE_KEY_SOURCE (ssrc), keys, FALSE, data);
- g_return_val_if_fail (op != NULL, NULL);
+ output = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (NULL, 0, g_realloc, NULL));
+ g_return_val_if_fail (output, NULL);
+
+ /* Buffer for what we send to the server */
+ op = seahorse_key_source_export (SEAHORSE_KEY_SOURCE (ssrc), keys, FALSE, G_OUTPUT_STREAM (output));
+ g_return_val_if_fail (op != NULL, NULL);
/*
* We happen to know that seahorse_ssh_source_export always returns
@@ -761,7 +758,7 @@
/* Return any errors */
if (!seahorse_operation_is_successful (op)) {
- gpgme_data_release (data);
+ g_object_unref (output);
return op;
}
@@ -778,12 +775,15 @@
username, hostname,
port ? "-p" : "",
port ? port : "");
- input = gpgme_data_release_and_get_mem (data, &length);
- op = seahorse_ssh_operation_new (ssrc, cmd, input, length, NULL);
+ data = g_memory_output_stream_get_data (output);
+ length = seahorse_util_memory_output_length (output);
+ g_object_unref (output);
- g_free (cmd);
- free (input);
+ op = seahorse_ssh_operation_new (ssrc, cmd, data, length, NULL);
+
+ g_free (cmd);
+ g_free (data);
pv = SEAHORSE_SSH_OPERATION_GET_PRIVATE (op);
pv->password_cb = upload_password_cb;
Modified: trunk/ssh/seahorse-ssh-source.c
==============================================================================
--- trunk/ssh/seahorse-ssh-source.c (original)
+++ trunk/ssh/seahorse-ssh-source.c Tue Apr 29 01:59:52 2008
@@ -20,21 +20,20 @@
*/
#include "config.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <gnome.h>
-#include <fcntl.h>
-#include <glib/gstdio.h>
-#include <libgnomevfs/gnome-vfs.h>
+
#include "seahorse-ssh-source.h"
+
+#include "seahorse-ssh-key.h"
+#include "seahorse-ssh-operation.h"
+
#include "seahorse-operation.h"
#include "seahorse-util.h"
-#include "pgp/seahorse-gpgmex.h"
+#include <glib/gstdio.h>
-#include "seahorse-ssh-key.h"
-#include "seahorse-ssh-operation.h"
+#include <unistd.h>
+#include <fcntl.h>
/* Override DEBUG switches here */
#define DEBUG_REFRESH_ENABLE 0
@@ -65,7 +64,7 @@
struct _SeahorseSSHSourcePrivate {
gchar *ssh_homedir; /* Home directory for SSH keys */
guint scheduled_refresh; /* Source for refresh timeout */
- GnomeVFSMonitorHandle *monitor_handle; /* For monitoring the .ssh directory */
+ GFileMonitor *monitor_handle; /* For monitoring the .ssh directory */
};
typedef struct _LoadContext {
@@ -204,31 +203,34 @@
}
static void
-monitor_ssh_homedir (GnomeVFSMonitorHandle *handle, const gchar *monitor_uri,
- const gchar *info_uri, GnomeVFSMonitorEventType event_type,
- SeahorseSSHSource *ssrc)
-{
- gchar *path;
-
- if (ssrc->priv->scheduled_refresh != 0 ||
- (event_type != GNOME_VFS_MONITOR_EVENT_CREATED &&
- event_type != GNOME_VFS_MONITOR_EVENT_CHANGED &&
- event_type != GNOME_VFS_MONITOR_EVENT_DELETED))
- return;
-
- path = gnome_vfs_get_local_path_from_uri (info_uri);
- if (path == NULL)
- return;
-
- /* Filter out any noise */
- if (event_type != GNOME_VFS_MONITOR_EVENT_DELETED &&
- !ends_with (path, AUTHORIZED_KEYS_FILE) &&
- !ends_with (path, OTHER_KEYS_FILE) &&
- !check_file_for_ssh_private (ssrc, path))
- return;
+monitor_ssh_homedir (GFileMonitor *handle, GFile *file, GFile *other_file,
+ GFileMonitorEvent event_type, SeahorseSSHSource *ssrc)
+{
+ gchar *path;
- DEBUG_REFRESH ("scheduling refresh event due to file changes\n");
- ssrc->priv->scheduled_refresh = g_timeout_add (500, (GSourceFunc)scheduled_refresh, ssrc);
+ if (ssrc->priv->scheduled_refresh != 0 ||
+ (event_type != G_FILE_MONITOR_EVENT_CHANGED &&
+ event_type != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT &&
+ event_type != G_FILE_MONITOR_EVENT_DELETED &&
+ event_type != G_FILE_MONITOR_EVENT_CREATED))
+ return;
+
+ path = g_file_get_path (file);
+ if (path == NULL)
+ return;
+
+ /* Filter out any noise */
+ if (event_type != G_FILE_MONITOR_EVENT_DELETED &&
+ !ends_with (path, AUTHORIZED_KEYS_FILE) &&
+ !ends_with (path, OTHER_KEYS_FILE) &&
+ !check_file_for_ssh_private (ssrc, path)) {
+ g_free (path);
+ return;
+ }
+
+ g_free (path);
+ DEBUG_REFRESH ("scheduling refresh event due to file changes\n");
+ ssrc->priv->scheduled_refresh = g_timeout_add (500, (GSourceFunc)scheduled_refresh, ssrc);
}
static void
@@ -432,15 +434,6 @@
return TRUE;
}
-static gboolean
-write_gpgme_data (gpgme_data_t data, const gchar *str)
-{
- int len = strlen (str);
- int r = gpgme_data_write (data, str, len);
-
- return len == r;
-}
-
/* -----------------------------------------------------------------------------
* OBJECT
*/
@@ -573,13 +566,16 @@
}
static SeahorseOperation*
-seahorse_ssh_source_import (SeahorseKeySource *sksrc, gpgme_data_t data)
+seahorse_ssh_source_import (SeahorseKeySource *sksrc, GInputStream *input)
{
SeahorseSSHSource *ssrc = SEAHORSE_SSH_SOURCE (sksrc);
ImportContext ctx;
gchar *contents;
+
+ g_return_val_if_fail (SEAHORSE_IS_SSH_SOURCE (ssrc), NULL);
+ g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
- contents = seahorse_util_write_data_to_text (data, NULL);
+ contents = seahorse_util_read_to_text (input, NULL);
memset (&ctx, 0, sizeof (ctx));
ctx.ssrc = ssrc;
@@ -595,16 +591,19 @@
static SeahorseOperation*
seahorse_ssh_source_export (SeahorseKeySource *sksrc, GList *keys,
- gboolean complete, gpgme_data_t data)
+ gboolean complete, GOutputStream *output)
{
SeahorseSSHKeyData *keydata;
+ SeahorseOperation *op;
gchar *results = NULL;
gchar *raw = NULL;
GError *error = NULL;
SeahorseKey *skey;
GList *l;
+ gsize written;
g_return_val_if_fail (SEAHORSE_IS_SSH_SOURCE (sksrc), NULL);
+ g_return_val_if_fail (G_IS_OUTPUT_STREAM (output), NULL);
for (l = keys; l; l = g_list_next (l)) {
skey = SEAHORSE_KEY (l->data);
@@ -646,25 +645,27 @@
g_warning ("private key without public, not exporting: %s", keydata->privfile);
}
- if (results) {
-
- /* Write the data out */
- if (write_gpgme_data (data, results) == FALSE) {
- g_set_error (&error, G_FILE_ERROR, g_file_error_from_errno (errno),
- strerror (errno));
- }
-
- g_free (results);
- }
-
- g_free (raw);
-
- if (error != NULL)
- break;
-
- }
-
- return seahorse_operation_new_complete (error);
+ /* Write the data out */
+ if (results) {
+ if (g_output_stream_write_all (output, results, strlen (results),
+ &written, NULL, &error))
+ g_output_stream_flush (output, NULL, &error);
+ g_free (results);
+ }
+
+ g_free (raw);
+
+ if (error != NULL)
+ break;
+ }
+
+ if (error == NULL)
+ g_output_stream_close (output, NULL, &error);
+
+ op = seahorse_operation_new_complete (error);
+ g_object_ref (output);
+ seahorse_operation_mark_result (op, output, g_object_unref);
+ return op;
}
static gboolean
@@ -759,18 +760,18 @@
static void
seahorse_ssh_source_dispose (GObject *gobject)
{
- SeahorseSSHSource *ssrc = SEAHORSE_SSH_SOURCE (gobject);
+ SeahorseSSHSource *ssrc = SEAHORSE_SSH_SOURCE (gobject);
- g_assert (ssrc->priv);
+ g_assert (ssrc->priv);
- cancel_scheduled_refresh (ssrc);
+ cancel_scheduled_refresh (ssrc);
- if (ssrc->priv->monitor_handle) {
- gnome_vfs_monitor_cancel (ssrc->priv->monitor_handle);
- ssrc->priv->monitor_handle = NULL;
- }
-
- G_OBJECT_CLASS (seahorse_ssh_source_parent_class)->dispose (gobject);
+ if (ssrc->priv->monitor_handle) {
+ g_object_unref (ssrc->priv->monitor_handle);
+ ssrc->priv->monitor_handle = NULL;
+ }
+
+ G_OBJECT_CLASS (seahorse_ssh_source_parent_class)->dispose (gobject);
}
static void
@@ -791,35 +792,36 @@
static void
seahorse_ssh_source_init (SeahorseSSHSource *ssrc)
{
- GnomeVFSResult res;
- gchar *uri;
-
- /* init private vars */
- ssrc->priv = g_new0 (SeahorseSSHSourcePrivate, 1);
-
- ssrc->priv->scheduled_refresh = 0;
- ssrc->priv->monitor_handle = NULL;
+ GError *err = NULL;
+ GFile *file;
- ssrc->priv->ssh_homedir = g_strdup_printf ("%s/.ssh/", g_get_home_dir ());
+ /* init private vars */
+ ssrc->priv = g_new0 (SeahorseSSHSourcePrivate, 1);
- /* Make the .ssh directory if it doesn't exist */
- if (!g_file_test (ssrc->priv->ssh_homedir, G_FILE_TEST_EXISTS)) {
- if (g_mkdir (ssrc->priv->ssh_homedir, 0700) == -1)
- g_warning ("couldn't create .ssh directory: %s", ssrc->priv->ssh_homedir);
- return;
- }
-
- uri = gnome_vfs_make_uri_canonical (ssrc->priv->ssh_homedir);
- g_return_if_fail (uri != NULL);
- res = gnome_vfs_monitor_add (&(ssrc->priv->monitor_handle), uri,
- GNOME_VFS_MONITOR_DIRECTORY,
- (GnomeVFSMonitorCallback)monitor_ssh_homedir, ssrc);
- g_free (uri);
-
- if (res != GNOME_VFS_OK) {
- ssrc->priv->monitor_handle = NULL;
- g_return_if_reached ();
- }
+ ssrc->priv->scheduled_refresh = 0;
+ ssrc->priv->monitor_handle = NULL;
+
+ ssrc->priv->ssh_homedir = g_strdup_printf ("%s/.ssh/", g_get_home_dir ());
+
+ /* Make the .ssh directory if it doesn't exist */
+ if (!g_file_test (ssrc->priv->ssh_homedir, G_FILE_TEST_EXISTS)) {
+ if (g_mkdir (ssrc->priv->ssh_homedir, 0700) == -1)
+ g_warning ("couldn't create .ssh directory: %s", ssrc->priv->ssh_homedir);
+ return;
+ }
+
+ file = g_file_new_for_path (ssrc->priv->ssh_homedir);
+ g_return_if_fail (file != NULL);
+
+ ssrc->priv->monitor_handle = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, &err);
+ g_object_unref (file);
+
+ if (ssrc->priv->monitor_handle)
+ g_signal_connect (ssrc->priv->monitor_handle, "changed",
+ G_CALLBACK (monitor_ssh_homedir), ssrc);
+ else
+ g_warning ("couldn't monitor ssh directory: %s: %s",
+ ssrc->priv->ssh_homedir, err && err->message ? err->message : "");
}
static void
@@ -835,6 +837,7 @@
gobject_class->set_property = seahorse_ssh_source_set_property;
gobject_class->get_property = seahorse_ssh_source_get_property;
+ parent_class->canonize_keyid = seahorse_ssh_key_get_cannonical_id;
parent_class->load = seahorse_ssh_source_load;
parent_class->stop = seahorse_ssh_source_stop;
parent_class->get_state = seahorse_ssh_source_get_state;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]