diff options
author | walters <walters@517b70f8-ed25-0410-8bf6-f5db08f7b76e> | 2008-03-22 05:07:06 +0000 |
---|---|---|
committer | walters <walters@517b70f8-ed25-0410-8bf6-f5db08f7b76e> | 2008-03-22 05:07:06 +0000 |
commit | 41088319589c9fe510d39a32cefea5a04a72a97f (patch) | |
tree | 501d4342f0d04588cdc57a1a1b0b42ef237a624a /src | |
parent | c4e18dbd69b9c01c73c5757c860ee8373bd3d071 (diff) |
2008-03-22 Colin Walters <walters@verbum.org>
+ * src/krb5-auth-dialog.c: Grab a name on the
+ session bus to be doubly sure we don't have
+ multiple copies. Also don't connect to the
+ session manager, since it's not needed.
+
git-svn-id: http://svn.gnome.org/svn/krb5-auth-dialog/trunk@71 517b70f8-ed25-0410-8bf6-f5db08f7b76e
Diffstat (limited to 'src')
-rw-r--r-- | src/krb5-auth-dialog.c | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c index 36387a9..a836480 100644 --- a/src/krb5-auth-dialog.c +++ b/src/krb5-auth-dialog.c @@ -572,6 +572,9 @@ main (int argc, char *argv[]) GtkWidget *dialog; GnomeClient *client; DBusGConnection *session; + DBusGProxy *bus_proxy; + guint request_name_reply; + unsigned int flags; GError *error = NULL; int run_auto = 0, run_always = 0; struct poptOption options[] = { @@ -589,21 +592,51 @@ main (int argc, char *argv[]) gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_POPT_TABLE, options, - GNOME_PARAM_NONE); - - client = gnome_master_client (); - gnome_client_set_restart_style (client, GNOME_RESTART_ANYWAY); + GNOME_CLIENT_PARAM_SM_CONNECT, FALSE, GNOME_PARAM_NONE); /* Connect to the session bus so we get exit-on-disconnect semantics. */ session = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (session == NULL) { + g_error ("couldn't connect to session bus: %s", (error) ? error->message : "(null)"); + exit(1); + } + flags = DBUS_NAME_FLAG_DO_NOT_QUEUE; + bus_proxy = dbus_g_proxy_new_for_name (session, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus"); + + if (!dbus_g_proxy_call (bus_proxy, + "RequestName", + &error, + G_TYPE_STRING, + "org.gnome.KrbAuthDialog", + G_TYPE_UINT, + flags, + G_TYPE_INVALID, + G_TYPE_UINT, + &request_name_reply, + G_TYPE_INVALID)) { + g_warning ("Failed to invoke RequestName: %s", + error->message); + } + g_clear_error (&error); + g_object_unref (bus_proxy); + + if (request_name_reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER + || request_name_reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) + ; + else if (request_name_reply == DBUS_REQUEST_NAME_REPLY_EXISTS + || request_name_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE) + exit(0); + else { + g_assert_not_reached(); + } if (run_always && !run_auto) { always_run++; } if (using_krb5 () || always_run) { - g_signal_connect (G_OBJECT (client), "die", - G_CALLBACK (gtk_main_quit), NULL); - g_set_application_name (_("Network Authentication")); #ifdef ENABLE_NETWORK_MANAGER |