[gvfs/gdbus-core: 9/17] gdbus: Port the sftp backend
- From: Tomas Bzatek <tbzatek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/gdbus-core: 9/17] gdbus: Port the sftp backend
- Date: Mon, 4 Jun 2012 17:40:21 +0000 (UTC)
commit d1c9518b5e64195948391f7a6638e53d25b48079
Author: Tomas Bzatek <tbzatek redhat com>
Date: Tue Apr 17 12:16:48 2012 +0200
gdbus: Port the sftp backend
Traces of gnome-keyring GetEnvironment() call.
daemon/gvfsbackendsftp.c | 108 ++++++++++++++++++++++-----------------------
1 files changed, 53 insertions(+), 55 deletions(-)
---
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index 4bd44a8..7dd90eb 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -344,81 +344,79 @@ look_for_stderr_errors (GVfsBackend *backend, GError **error)
}
static gchar*
-read_dbus_string_dict_value (DBusMessageIter *args, const gchar *key)
+read_dbus_string_dict_value (GVariant *args, const gchar *key)
{
- DBusMessageIter items, entry;
- gchar *str, *sig;
-
- sig = dbus_message_iter_get_signature (args);
- if (!sig || strcmp (sig, "a{ss}") != 0)
+ GVariant *a;
+ GVariantIter iter;
+ const gchar *str, *val;
+ gchar *res;
+
+ if (g_strcmp0 (g_variant_get_type_string (args), "(a{ss})") != 0)
return NULL;
-
- dbus_message_iter_recurse (args, &items);
-
- if (dbus_message_iter_has_next (&items))
+
+ g_variant_get (args, "(@a{ss})", &a);
+
+ res = NULL;
+ g_variant_iter_init (&iter, a);
+ while (g_variant_iter_next (&iter, "{&s&s}", &str, &val))
{
- do
- {
- dbus_message_iter_recurse (&items, &entry);
- dbus_message_iter_get_basic (&entry, &str);
- if (str && strcmp (key, str) == 0)
- {
- dbus_message_iter_next (&entry);
- dbus_message_iter_get_basic (&entry, &str);
- return g_strdup (str);
- }
- }
- while (dbus_message_iter_next (&items));
+ if (g_strcmp0 (str, key) == 0)
+ {
+ res = g_strdup (val);
+ break;
+ }
}
-
- return NULL;
+
+ g_variant_unref (a);
+
+ return res;
}
static void
setup_ssh_environment (void)
{
- DBusConnection *dconn;
- DBusMessage *reply;
- DBusMessage *msg;
- DBusMessageIter args;
- DBusError derr;
+ GDBusConnection *conn;
+ GError *error;
+ GVariant *iter;
gchar *env;
-
- dbus_error_init (&derr);
- dconn = dbus_bus_get (DBUS_BUS_SESSION, &derr);
- if (!dconn)
- return;
-
- msg = dbus_message_new_method_call ("org.gnome.keyring",
- "/org/gnome/keyring/daemon",
- "org.gnome.keyring.Daemon",
- "GetEnvironment");
- if (!msg)
+
+ error = NULL;
+ conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ if (! conn)
{
- dbus_connection_unref (dconn);
+ g_warning ("Failed to setup ssh evironment: %s (%s, %d)",
+ error->message, g_quark_to_string (error->domain), error->code);
+ g_error_free (error);
return;
}
- /* Send message and get a handle for a reply */
- reply = dbus_connection_send_with_reply_and_block (dconn, msg, 1000, &derr);
- dbus_message_unref (msg);
- if (!reply)
- {
- dbus_connection_unref (dconn);
- return;
+ iter = g_dbus_connection_call_sync (conn,
+ "org.gnome.keyring",
+ "/org/gnome/keyring/daemon",
+ "org.gnome.keyring.Daemon",
+ "GetEnvironment",
+ NULL,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ 1000,
+ NULL,
+ &error);
+ if (! iter)
+ {
+ g_warning ("Failed to setup ssh evironment: %s (%s, %d)",
+ error->message, g_quark_to_string (error->domain), error->code);
+ g_error_free (error);
}
-
- /* Read the return value */
- if (dbus_message_iter_init (reply, &args))
+ else
{
- env = read_dbus_string_dict_value (&args, "SSH_AUTH_SOCK");
+ env = read_dbus_string_dict_value (iter, "SSH_AUTH_SOCK");
if (env && env[0])
- g_setenv ("SSH_AUTH_SOCK", env, TRUE);
+ g_setenv ("SSH_AUTH_SOCK", env, TRUE);
g_free (env);
+ g_variant_unref (iter);
}
-
- dbus_message_unref (reply);
- dbus_connection_unref (dconn);
+
+ g_object_unref (conn);
}
static char **
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]