network-manager-applet r487 - in branches/network-manager-applet-0-6: . src



Author: tambeti
Date: Wed Jan 30 03:29:40 2008
New Revision: 487
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=487&view=rev

Log:
2008-01-29  Tambet Ingo  <tambet gmail com>

        * src/nm-gconf-wso.c (real_write_secrets): Don't use a blocking
        * gnome-keyring
        call when writing the secrets, it grabs the X pointer if the
menu happens to
        be expanded at the time keyring asks for the master password,
deadlocking the
        whole session.

        * src/nm-gconf-wso-wpa-eap.c (real_write_secrets): Ditto.

        * src/Makefile.am: Remove the 'DISABLE_DEPRECATED' define,
        * otherwise it does
        not compile on GTK 2.12 anymore (GtkTooltips is deprecated
there).

2008-01-29  Tambet Ingo  <tambet gmail com>

        * src/applet.c (nma_show_info_cb): Remove a warning.
        (nma_set_wireless_enabled_cb): Save the wireless state in gconf.
        (nma_set_networking_enabled_cb): Save the network
enabled/disabled state in
        gconf.
        (update_network_state): Update the state of wireless and network
to what's
        saved in gconf.
        (nma_get_instance): On startup, restore the wireless and network
state to
        what was used the last time.

2008-01-29  Tambet Ingo  <tambet gmail com>

        * nm-disconnect-wireless-on-exit.sh: Stand alone utility to
        * control whether
        the wireless connections are closed on exit.

        * src/applet.c (nma_get_disconnect_wireless_on_exit)
        (nma_set_disconnect_wireless_on_exit): Implement.

        * src/main.c (session_die): Deactivate the wireless connection
        * if needed.




Modified:
   branches/network-manager-applet-0-6/ChangeLog
   branches/network-manager-applet-0-6/Makefile.am
   branches/network-manager-applet-0-6/src/Makefile.am
   branches/network-manager-applet-0-6/src/applet.c
   branches/network-manager-applet-0-6/src/applet.h
   branches/network-manager-applet-0-6/src/main.c
   branches/network-manager-applet-0-6/src/nm-gconf-wso-wpa-eap.c
   branches/network-manager-applet-0-6/src/nm-gconf-wso.c

Modified: branches/network-manager-applet-0-6/Makefile.am
==============================================================================
--- branches/network-manager-applet-0-6/Makefile.am	(original)
+++ branches/network-manager-applet-0-6/Makefile.am	Wed Jan 30 03:29:40 2008
@@ -6,13 +6,17 @@
 	intltool-merge.in		\
 	intltool-update.in		\
 	COPYING.LIB
-	
+
 dbusservicedir = $(DBUS_SYS_DIR)
 dbusservice_DATA = nm-applet.conf
 
+toolsdir = $(datadir)/nm-applet
+tools_DATA = nm-disconnect-wireless-on-exit.sh
+
 EXTRA_DIST +=				\
 	$(dbusservice_DATA)		\
-	nm-applet.desktop
+	nm-applet.desktop		\
+	$(tools_DATA)
 
 DISTCLEANFILES = intltool-extract intltool-merge intltool-update
 

Modified: branches/network-manager-applet-0-6/src/Makefile.am
==============================================================================
--- branches/network-manager-applet-0-6/src/Makefile.am	(original)
+++ branches/network-manager-applet-0-6/src/Makefile.am	Wed Jan 30 03:29:40 2008
@@ -21,7 +21,6 @@
 	-DVPN_NAME_FILES_DIR=\""$(sysconfdir)/NetworkManager/VPN"\"	\
 	-DDBUS_API_SUBJECT_TO_CHANGE							\
 	-DGNOMELOCALEDIR=\"$(datadir)/locale\"					\
-	$(DISABLE_DEPRECATED)	\
 	$(NULL)
 
 if WITH_NOTIFY

Modified: branches/network-manager-applet-0-6/src/applet.c
==============================================================================
--- branches/network-manager-applet-0-6/src/applet.c	(original)
+++ branches/network-manager-applet-0-6/src/applet.c	Wed Jan 30 03:29:40 2008
@@ -285,7 +285,7 @@
 	if (!nma_update_info (applet))
 		return;
 
-	g_signal_connect(info_dialog, "delete-event", gtk_widget_hide_on_delete, info_dialog);
+	g_signal_connect (info_dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), info_dialog);
 	g_signal_connect_swapped (info_dialog, "response", G_CALLBACK (gtk_widget_hide), info_dialog);
 	gtk_window_present (GTK_WINDOW (info_dialog));
 }
@@ -1181,6 +1181,48 @@
 }
 
 
+gboolean nma_get_disconnect_wireless_on_exit (NMApplet *applet)
+{
+	GConfValue *value;
+	gboolean ret = FALSE;
+
+	g_return_val_if_fail (applet != NULL, FALSE);
+	g_return_val_if_fail (applet->gconf_client != NULL, FALSE);
+
+	value = gconf_client_get (applet->gconf_client,
+						 GCONF_PATH_PREFS "/disconnect_wireless_on_exit",
+						 NULL);
+
+	if (value)
+	{
+		if (value->type == GCONF_VALUE_BOOL)
+			ret = gconf_value_get_bool (value);
+
+		gconf_value_free (value);
+	}
+
+	return ret;
+}
+
+
+void nma_set_disconnect_wireless_on_exit (NMApplet *applet, gboolean disconnect)
+{
+	gboolean current;
+
+	g_return_if_fail (applet != NULL);
+	g_return_if_fail (applet->gconf_client != NULL);
+
+	current = nma_get_disconnect_wireless_on_exit (applet);
+	if (current != disconnect)
+	{
+		gconf_client_set_bool (applet->gconf_client,
+						   GCONF_PATH_PREFS "/disconnect_wireless_on_exit",
+						   disconnect,
+						   NULL);
+	}
+}
+
+
 /*
  * nma_redraw_timeout
  *
@@ -1930,7 +1972,13 @@
 
 	state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
 	if (applet->wireless_enabled != state)
+	{
+		gconf_client_set_bool (applet->gconf_client,
+						   GCONF_PATH_PREFS "/wireless_enabled",
+						   state,
+						   NULL);
 		nma_dbus_enable_wireless (applet, state);
+	}
 }
 
 
@@ -1942,7 +1990,13 @@
 
 	state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget));
 	if ((applet->nm_state == NM_STATE_ASLEEP && state) || (applet->nm_state != NM_STATE_ASLEEP && !state))
+	{
+		gconf_client_set_bool (applet->gconf_client,
+						   GCONF_PATH_PREFS "/networking_enabled",
+						   state,
+						   NULL);
 		nma_dbus_enable_networking (applet, state);
+	}
 }
 
 
@@ -2523,6 +2577,36 @@
 }
 
 
+static gboolean
+update_network_state (gpointer data)
+{
+	NMApplet *applet = data;
+	GConfValue *value;
+
+	value = gconf_client_get (applet->gconf_client,
+						 GCONF_PATH_PREFS "/networking_enabled",
+						 NULL);
+	if (value)
+	{
+		if (value->type == GCONF_VALUE_BOOL)
+			nma_dbus_enable_networking (applet, gconf_value_get_bool (value));
+		gconf_value_free (value);
+	}
+
+	value = gconf_client_get (applet->gconf_client,
+						 GCONF_PATH_PREFS "/wireless_enabled",
+						 NULL);
+	if (value)
+	{
+		if (value->type == GCONF_VALUE_BOOL)
+			nma_dbus_enable_wireless	(applet, gconf_value_get_bool (value));
+		gconf_value_free (value);
+	}
+
+	return FALSE;
+}
+
+
 /*
  * nma_get_instance
  *
@@ -2591,6 +2675,11 @@
 	g_signal_connect (applet, "destroy", G_CALLBACK (nma_destroy), NULL);
 	g_signal_connect (applet, "style-set", G_CALLBACK (nma_theme_change_cb), NULL);
 
+	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+				  update_network_state,
+				  g_object_ref (applet),
+				  (GDestroyNotify) g_object_unref);
+
 	return GTK_WIDGET (applet);
 }
 

Modified: branches/network-manager-applet-0-6/src/applet.h
==============================================================================
--- branches/network-manager-applet-0-6/src/applet.h	(original)
+++ branches/network-manager-applet-0-6/src/applet.h	Wed Jan 30 03:29:40 2008
@@ -161,6 +161,9 @@
 void				nma_set_running						(NMApplet *applet, gboolean running);
 void				nma_update_state					(NMApplet *applet);
 
+gboolean nma_get_disconnect_wireless_on_exit (NMApplet *applet);
+void nma_set_disconnect_wireless_on_exit (NMApplet *applet, gboolean disconnect);
+
 int				nm_null_safe_strcmp					(const char *s1, const char *s2);
 
 #endif

Modified: branches/network-manager-applet-0-6/src/main.c
==============================================================================
--- branches/network-manager-applet-0-6/src/main.c	(original)
+++ branches/network-manager-applet-0-6/src/main.c	Wed Jan 30 03:29:40 2008
@@ -36,7 +36,14 @@
 static void session_die (GnomeClient *client, gpointer client_data)
 {
 	NMApplet *applet = client_data;
+
+	/* Deactivate VPN */
 	nma_dbus_vpn_deactivate_connection (applet->connection);
+
+	/* Deactivate wireless devices if required */
+	if (nma_get_disconnect_wireless_on_exit (applet))
+		nma_dbus_enable_wireless (applet, FALSE);
+
 	gtk_main_quit ();
 }
 

Modified: branches/network-manager-applet-0-6/src/nm-gconf-wso-wpa-eap.c
==============================================================================
--- branches/network-manager-applet-0-6/src/nm-gconf-wso-wpa-eap.c	(original)
+++ branches/network-manager-applet-0-6/src/nm-gconf-wso-wpa-eap.c	Wed Jan 30 03:29:40 2008
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 /* NetworkManager -- Network link manager
  *
  * Dan Williams <dcbw redhat com>
@@ -316,6 +318,15 @@
 }
 
 static void
+real_write_secrets_cb (GnomeKeyringResult result,
+				   guint32 val,
+				   gpointer user_data)
+{
+	if (result != GNOME_KEYRING_RESULT_OK)
+		nm_warning ("Error saving secret for wireless network '%s' in keyring: %d", (char *) user_data, result);
+}
+
+static void
 real_write_secrets (NMGConfWSO *instance,
                     const char *ssid)
 {
@@ -323,8 +334,6 @@
 	GnomeKeyringAttributeList *attributes;
 	GnomeKeyringAttribute attr;		
 	char *display_name;
-	GnomeKeyringResult ret;
-	guint32 item_id;
 
 	NM_GCONF_WSO_CLASS (g_type_class_peek (NM_TYPE_GCONF_WSO))->write_secrets_func (instance, ssid);
 
@@ -339,15 +348,15 @@
 	attr.value.string = g_strdup (ssid);
 	g_array_append_val (attributes, attr);
 
-	ret = gnome_keyring_item_create_sync (NULL,
-								   GNOME_KEYRING_ITEM_GENERIC_SECRET,
-								   display_name,
-								   attributes,
-								   self->priv->private_key_passwd,
-								   TRUE,
-								   &item_id);
-	if (ret != GNOME_KEYRING_RESULT_OK)
-		nm_warning ("Error saving secret for wireless network '%s' in keyring: %d", ssid, ret);
+	gnome_keyring_item_create (NULL,
+						  GNOME_KEYRING_ITEM_GENERIC_SECRET,
+						  display_name,
+						  attributes,
+						  self->priv->private_key_passwd,
+						  TRUE,
+						  real_write_secrets_cb,
+						  g_strdup (ssid),
+						  g_free);
 
 	g_free (display_name);
 	gnome_keyring_attribute_list_free (attributes);

Modified: branches/network-manager-applet-0-6/src/nm-gconf-wso.c
==============================================================================
--- branches/network-manager-applet-0-6/src/nm-gconf-wso.c	(original)
+++ branches/network-manager-applet-0-6/src/nm-gconf-wso.c	Wed Jan 30 03:29:40 2008
@@ -1,3 +1,5 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
 /* NetworkManager -- Network link manager
  *
  * Dan Williams <dcbw redhat com>
@@ -339,14 +341,21 @@
 }
 
 static void
+real_write_secrets_cb (GnomeKeyringResult result,
+				   guint32 val,
+				   gpointer user_data)
+{
+	if (result != GNOME_KEYRING_RESULT_OK)
+		nm_warning ("Error saving secret for wireless network '%s' in keyring: %d", (char *) user_data, result);
+}
+
+static void
 real_write_secrets (NMGConfWSO *self,
                     const char *ssid)
 {
 	GnomeKeyringAttributeList *attributes;
 	GnomeKeyringAttribute attr;		
 	char *display_name;
-	GnomeKeyringResult ret;
-	guint32 item_id;
 
 	if (nm_gconf_wso_get_we_cipher (self) == IW_AUTH_CIPHER_NONE)
 		return;
@@ -359,15 +368,15 @@
 	attr.value.string = g_strdup (ssid);
 	g_array_append_val (attributes, attr);
 
-	ret = gnome_keyring_item_create_sync (NULL,
-								   GNOME_KEYRING_ITEM_GENERIC_SECRET,
-								   display_name,
-								   attributes,
-								   nm_gconf_wso_get_key (self),
-								   TRUE,
-								   &item_id);
-	if (ret != GNOME_KEYRING_RESULT_OK)
-		nm_warning ("Error saving secret for wireless network '%s' in keyring: %d", ssid, ret);
+	gnome_keyring_item_create (NULL,
+						  GNOME_KEYRING_ITEM_GENERIC_SECRET,
+						  display_name,
+						  attributes,
+						  nm_gconf_wso_get_key (self),
+						  TRUE,
+						  real_write_secrets_cb,
+						  g_strdup (ssid),
+						  g_free);
 
 	g_free (display_name);
 	gnome_keyring_attribute_list_free (attributes);



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