krb5-auth-dialog r71 - in trunk: . src



Author: walters
Date: Sat Mar 22 05:07:06 2008
New Revision: 71
URL: http://svn.gnome.org/viewvc/krb5-auth-dialog?rev=71&view=rev

Log:
 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.
+


Modified:
   trunk/ChangeLog
   trunk/src/krb5-auth-dialog.c

Modified: trunk/src/krb5-auth-dialog.c
==============================================================================
--- trunk/src/krb5-auth-dialog.c	(original)
+++ trunk/src/krb5-auth-dialog.c	Sat Mar 22 05:07:06 2008
@@ -572,6 +572,9 @@
 	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 @@
 
 	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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]