network-manager-applet r1127 - in branches/NETWORKMANAGER_APPLET_0_7: . src/gconf-helpers
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r1127 - in branches/NETWORKMANAGER_APPLET_0_7: . src/gconf-helpers
- Date: Mon, 2 Feb 2009 07:20:48 +0000 (UTC)
Author: dcbw
Date: Mon Feb 2 07:20:48 2009
New Revision: 1127
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=1127&view=rev
Log:
2009-02-01 Dan Williams <dcbw redhat com>
* src/gconf-helpers/gconf-helpers.c
src/gconf-helpers/gconf-helpers.h
- (nm_gconf_get_all_connections): implement applet GConf stamping to help
upgrades; upgrade 'never-default' in some cases
* src/gconf-helpers/gconf-upgrade.c
src/gconf-helpers/gconf-upgrade.h
- (nm_gconf_migrate_0_7_vpn_never_default): new function; if there were
static routes assigned to the VPN connection, set 'never-default'
to TRUE on upgrade to match 0.7.0 behavior
Modified:
branches/NETWORKMANAGER_APPLET_0_7/ChangeLog
branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-helpers.c
branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-helpers.h
branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-upgrade.c
branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-upgrade.h
Modified: branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-helpers.c
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-helpers.c (original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-helpers.c Mon Feb 2 07:20:48 2009
@@ -932,6 +932,14 @@
nm_gconf_get_all_connections (GConfClient *client)
{
GSList *connections;
+ guint32 stamp = 0;
+ GError *error = NULL;
+
+ stamp = (guint32) gconf_client_get_int (client, APPLET_PREFS_STAMP, &error);
+ if (error) {
+ g_error_free (error);
+ stamp = 0;
+ }
nm_gconf_migrate_0_7_connection_uuid (client);
nm_gconf_migrate_0_7_keyring_items (client);
@@ -943,12 +951,19 @@
nm_gconf_migrate_0_7_vpn_properties (client);
nm_gconf_migrate_0_7_openvpn_properties (client);
+ if (stamp < 1)
+ nm_gconf_migrate_0_7_vpn_never_default (client);
+
connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
if (!connections) {
nm_gconf_migrate_0_6_connections (client);
connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
}
+ /* Update the applet GConf stamp */
+ if (stamp != APPLET_CURRENT_STAMP)
+ gconf_client_set_int (client, APPLET_PREFS_STAMP, APPLET_CURRENT_STAMP, NULL);
+
return connections;
}
Modified: branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-helpers.h
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-helpers.h (original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-helpers.h Mon Feb 2 07:20:48 2009
@@ -29,6 +29,13 @@
#define GCONF_PATH_CONNECTIONS "/system/networking/connections"
+/* The stamp is a mechanism for determining which applet version last
+ * updated GConf for various GConf update tasks in newer applet versions.
+ */
+#define APPLET_CURRENT_STAMP 1
+#define APPLET_PREFS_STAMP "/apps/nm-applet/stamp"
+
+
/*
ATTENTION: Make sure to update nm_gconf_connection_duplicate()
when new connection tag is added! Otherwise duplicating connection
Modified: branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-upgrade.c
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-upgrade.c (original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-upgrade.c Mon Feb 2 07:20:48 2009
@@ -1724,3 +1724,60 @@
gconf_client_suggest_sync (client, NULL);
}
+void
+nm_gconf_migrate_0_7_vpn_never_default (GConfClient *client)
+{
+ GSList *connections, *iter;
+
+ /* Between 0.7.0 and 0.7.1, the 'never-default' key was added to
+ * make which connections receive the default route less complicated
+ * and more reliable. Previous to 0.7.1, a VPN connection whose
+ * server returned static routes, or for which the user had entered
+ * manual static routes, was never chosen as the default connection.
+ * With 0.7.1, all connections are candidates for the default connection
+ * unless 'never-default' is TRUE. For 0.7.0 VPN connections, try to
+ * set 'never-default' when possible. This doesn't cover all cases
+ * since we certainly don't know if the VPN server is returning
+ * any routes here, but it will work for some.
+ */
+
+ connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
+ for (iter = connections; iter; iter = iter->next) {
+ char *service = NULL;
+ GArray *array = NULL;
+
+ if (!nm_gconf_get_string_helper (client, (const char *) iter->data,
+ NM_SETTING_VPN_SERVICE_TYPE,
+ NM_SETTING_VPN_SETTING_NAME,
+ &service))
+ continue;
+
+ g_free (service);
+
+ /* If the user entered manual static routes, NetworkManager 0.7.0
+ * would have never set this VPN connection as the default, so
+ * set 'never-default' to TRUE.
+ */
+
+ if (!nm_gconf_get_uint_array_helper (client, iter->data,
+ NM_SETTING_IP4_CONFIG_ROUTES,
+ NM_SETTING_IP4_CONFIG_SETTING_NAME,
+ &array))
+ continue;
+
+ if (!array->len) {
+ g_array_free (array, TRUE);
+ continue;
+ }
+
+ /* Static routes found; set 'never-default' */
+ nm_gconf_set_bool_helper (client, iter->data,
+ NM_SETTING_IP4_CONFIG_NEVER_DEFAULT,
+ NM_SETTING_IP4_CONFIG_SETTING_NAME,
+ TRUE);
+ g_array_free (array, TRUE);
+ }
+ nm_utils_slist_free (connections, g_free);
+ gconf_client_suggest_sync (client, NULL);
+}
+
Modified: branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-upgrade.h
==============================================================================
--- branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-upgrade.h (original)
+++ branches/NETWORKMANAGER_APPLET_0_7/src/gconf-helpers/gconf-upgrade.h Mon Feb 2 07:20:48 2009
@@ -44,5 +44,7 @@
void nm_gconf_migrate_0_7_connection_uuid (GConfClient *client);
+void nm_gconf_migrate_0_7_vpn_never_default (GConfClient *client);
+
#endif /* GCONF_UPGRADE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]