gnome-keyring r1716 - in branches/gnome-2-26: . daemon tests
- From: stefw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-keyring r1716 - in branches/gnome-2-26: . daemon tests
- Date: Fri, 10 Apr 2009 21:33:41 +0000 (UTC)
Author: stefw
Date: Fri Apr 10 21:33:40 2009
New Revision: 1716
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1716&view=rev
Log:
Add DBus method for getting the important environment variables
that the gnome-keyring daemon wants to set. See bug #577614
Added:
branches/gnome-2-26/tests/dbus-test.py
Modified:
branches/gnome-2-26/ChangeLog
branches/gnome-2-26/daemon/gkr-daemon-dbus.c
Modified: branches/gnome-2-26/daemon/gkr-daemon-dbus.c
==============================================================================
--- branches/gnome-2-26/daemon/gkr-daemon-dbus.c (original)
+++ branches/gnome-2-26/daemon/gkr-daemon-dbus.c Fri Apr 10 21:33:40 2009
@@ -43,7 +43,6 @@
#define IFACE_SESSION_PRIVATE "org.gnome.SessionManager.ClientPrivate"
static DBusConnection *dbus_conn = NULL;
-static const char* socket_path = NULL;
static gchar *client_session_path = NULL;
static gchar *client_session_rule = NULL;
static gboolean dbus_initialized = FALSE;
@@ -302,22 +301,57 @@
*/
DBusMessageIter args;
- DBusMessage *reply;
+ DBusMessage *reply = NULL;
- if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_CALL ||
- !dbus_message_is_method_call (message, GNOME_KEYRING_DAEMON_INTERFACE, "GetSocketPath") ||
- !g_str_equal (dbus_message_get_signature (message), "")) {
+ /* GetSocketPath */
+ if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL &&
+ dbus_message_is_method_call (message, GNOME_KEYRING_DAEMON_INTERFACE, "GetSocketPath") &&
+ g_str_equal (dbus_message_get_signature (message), "")) {
+
+ const gchar *socket_path = gkr_daemon_io_get_socket_path ();
+ g_return_val_if_fail (socket_path, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+
+ /* Setup the result */
+ reply = dbus_message_new_method_return (message);
+ dbus_message_iter_init_append (reply, &args);
+ if (!dbus_message_iter_append_basic (&args, DBUS_TYPE_STRING, &socket_path))
+ g_return_val_if_reached (DBUS_HANDLER_RESULT_NEED_MEMORY);
+
+ /* GetEnvironment */
+ } else if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL &&
+ dbus_message_is_method_call (message, GNOME_KEYRING_DAEMON_INTERFACE, "GetEnvironment") &&
+ g_str_equal (dbus_message_get_signature (message), "")) {
+
+ const gchar **env;
+ DBusMessageIter items, entry;
+ gchar **parts;
+
+ env = gkr_daemon_util_get_environment ();
+ g_return_val_if_fail (env, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+
+ /* Setup the result */
+ reply = dbus_message_new_method_return (message);
+ dbus_message_iter_init_append (reply, &args);
+ if (!dbus_message_iter_open_container (&args, DBUS_TYPE_ARRAY, "{ss}", &items))
+ g_return_val_if_reached (DBUS_HANDLER_RESULT_NEED_MEMORY);
+ while (*env) {
+ parts = g_strsplit (*env, "=", 2);
+ g_return_val_if_fail (parts && parts[0] && parts[1], DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+ if (!dbus_message_iter_open_container (&items, DBUS_TYPE_DICT_ENTRY, NULL, &entry) ||
+ !dbus_message_iter_append_basic (&entry, DBUS_TYPE_STRING, &parts[0]) ||
+ !dbus_message_iter_append_basic (&entry, DBUS_TYPE_STRING, &parts[1]) ||
+ !dbus_message_iter_close_container (&items, &entry))
+ g_return_val_if_reached (DBUS_HANDLER_RESULT_NEED_MEMORY);
+ ++env;
+ }
+ if (!dbus_message_iter_close_container (&args, &items))
+ g_return_val_if_reached (DBUS_HANDLER_RESULT_NEED_MEMORY);
+
+ /* Unknown call */
+ } else {
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-
- g_return_val_if_fail (socket_path, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
-
- /* Setup the result */
- reply = dbus_message_new_method_return (message);
- dbus_message_iter_init_append (reply, &args);
- if (!dbus_message_iter_append_basic (&args, DBUS_TYPE_STRING, &socket_path))
- g_return_val_if_reached (DBUS_HANDLER_RESULT_NEED_MEMORY);
-
+
/* Send the reply */
if (!dbus_connection_send (dbus_conn, reply, NULL))
g_return_val_if_reached (DBUS_HANDLER_RESULT_NEED_MEMORY);
@@ -356,19 +390,19 @@
{
dbus_uint32_t res = 0;
DBusError derr = { 0 };
- const gchar *env;
if (dbus_initialized)
return;
#ifdef WITH_TESTS
- /* If running as a test, don't do DBUS stuff */
- env = g_getenv ("GNOME_KEYRING_TEST_PATH");
- if (env && env[0])
- return;
+ {
+ /* If running as a test, don't do DBUS stuff */
+ const gchar *env = g_getenv ("GNOME_KEYRING_TEST_PATH");
+ if (env && env[0])
+ return;
+ }
#endif
- socket_path = gkr_daemon_io_get_socket_path ();
dbus_error_init (&derr);
/* Get the dbus bus and hook up */
Added: branches/gnome-2-26/tests/dbus-test.py
==============================================================================
--- (empty file)
+++ branches/gnome-2-26/tests/dbus-test.py Fri Apr 10 21:33:40 2009
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+
+import dbus
+
+bus = dbus.SessionBus()
+
+proxy_obj = bus.get_object('org.gnome.keyring', '/org/gnome/keyring/daemon')
+service = dbus.Interface(proxy_obj, 'org.gnome.keyring.Daemon')
+
+print "Socket Path: "
+print service.GetSocketPath()
+
+print "\nEnvironment: "
+env = service.GetEnvironment()
+for (name, value) in env.items():
+ print "%s=%s" % (name, value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]