network-manager-applet r986 - in trunk: . src src/gconf-helpers



Author: dcbw
Date: Tue Oct 28 03:18:51 2008
New Revision: 986
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=986&view=rev

Log:
2008-10-27  Dan Williams  <dcbw redhat com>

	* src/gconf-helpers/gconf-helpers.c
	  src/gconf-helpers/gconf-helpers.h
		- (nm_gconf_set_pre_keyring_callback): set a function to be called when
			doing synchronous keyring operations
		- (nm_gconf_add_keyring_item, nm_gconf_get_keyring_items): call that
			function if the keyring is locked

	* src/applet.c
		- (applet_pre_keyring_callback): close the menu before showing accessing
			the keyring (bgo #546034, rh #353451)



Modified:
   trunk/ChangeLog
   trunk/src/applet.c
   trunk/src/gconf-helpers/gconf-helpers.c
   trunk/src/gconf-helpers/gconf-helpers.h

Modified: trunk/src/applet.c
==============================================================================
--- trunk/src/applet.c	(original)
+++ trunk/src/applet.c	Tue Oct 28 03:18:51 2008
@@ -2177,6 +2177,18 @@
 	return TRUE;
 }
 
+static void
+applet_pre_keyring_callback (gpointer user_data)
+{
+	NMApplet *applet = NM_APPLET (user_data);
+
+	if (applet->menu) {
+		gtk_widget_hide (applet->menu);
+		gtk_widget_destroy (applet->menu);
+		applet->menu = NULL;
+	}
+}
+
 static GObject *
 constructor (GType type,
              guint n_props,
@@ -2255,6 +2267,8 @@
 	applet->update_timestamps_id = g_timeout_add (300000,
 			(GSourceFunc) periodic_update_active_connection_timestamps, applet);
 
+	nm_gconf_set_pre_keyring_callback (applet_pre_keyring_callback, applet);
+
 	return G_OBJECT (applet);
 
 error:
@@ -2266,6 +2280,8 @@
 {
 	NMApplet *applet = NM_APPLET (object);
 
+	nm_gconf_set_pre_keyring_callback (NULL, NULL);
+
 	if (applet->update_timestamps_id)
 		g_source_remove (applet->update_timestamps_id);
 

Modified: trunk/src/gconf-helpers/gconf-helpers.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-helpers.c	(original)
+++ trunk/src/gconf-helpers/gconf-helpers.c	Tue Oct 28 03:18:51 2008
@@ -64,6 +64,37 @@
 	NULL
 };
 
+static PreKeyringCallback pre_keyring_cb = NULL;
+static gpointer pre_keyring_user_data = NULL;
+
+/* Sets a function to be called before each keyring access */
+void
+nm_gconf_set_pre_keyring_callback (PreKeyringCallback func, gpointer user_data)
+{
+	pre_keyring_cb = func;
+	pre_keyring_user_data = user_data;
+}
+
+static void
+pre_keyring_callback (void)
+{
+	GnomeKeyringInfo *info = NULL;
+
+	if (!pre_keyring_cb)
+		return;
+
+	/* Call the pre keyring callback if the keyring is locked or if there
+	 * was an error talking to the keyring.
+	 */
+	if (gnome_keyring_get_info_sync (NULL, &info) == GNOME_KEYRING_RESULT_OK) {
+		if (gnome_keyring_info_get_is_locked (info))
+			(*pre_keyring_cb) (pre_keyring_user_data);
+		gnome_keyring_info_free (info);
+	} else
+		(*pre_keyring_cb) (pre_keyring_user_data);
+}
+
+
 gboolean
 nm_gconf_get_int_helper (GConfClient *client,
                          const char *path,
@@ -1217,6 +1248,8 @@
 	                                            KEYRING_SK_TAG,
 	                                            setting_key);
 
+	pre_keyring_callback ();
+
 	ret = gnome_keyring_item_create_sync (NULL,
 	                                      GNOME_KEYRING_ITEM_GENERIC_SECRET,
 	                                      display_name,
@@ -1671,6 +1704,8 @@
 	connection_name = nm_setting_connection_get_id (s_con);
 	g_assert (connection_name);
 
+	pre_keyring_callback ();
+
 	ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
 	                                      &found_list,
 	                                      KEYRING_UUID_TAG,
@@ -1799,3 +1834,4 @@
 
 	return dup;
 }
+

Modified: trunk/src/gconf-helpers/gconf-helpers.h
==============================================================================
--- trunk/src/gconf-helpers/gconf-helpers.h	(original)
+++ trunk/src/gconf-helpers/gconf-helpers.h	Tue Oct 28 03:18:51 2008
@@ -221,5 +221,8 @@
                             gboolean include_private_passwords,
                             GError **error);
 
+typedef void (*PreKeyringCallback) (gpointer user_data);
+void nm_gconf_set_pre_keyring_callback (PreKeyringCallback func, gpointer user_data);
+
 #endif	/* GCONF_HELPERS_H */
 



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