2008-03-22 Colin Walters <walters@verbum.org>
authorwalters <walters@517b70f8-ed25-0410-8bf6-f5db08f7b76e>
Sat, 22 Mar 2008 05:07:06 +0000 (05:07 +0000)
committerwalters <walters@517b70f8-ed25-0410-8bf6-f5db08f7b76e>
Sat, 22 Mar 2008 05:07:06 +0000 (05:07 +0000)
+ * 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

ChangeLog
src/krb5-auth-dialog.c

index 45ce8f6f757d6dd49914274fe7703c9e68e2ea62..79950d5b664db021ee1c71027d650564a97c5ddf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
 2008-03-22  Colin Walters  <walters@verbum.org>
 
        * MAINTAINERS: New file.
index 36387a9453de7c405aad1304196f957a4615db36..a836480f7cb68eb004f117a5c814f69c47f72d11 100644 (file)
@@ -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