network-manager-applet r980 - in trunk: . src src/connection-editor src/gconf-helpers src/utils src/wireless-security
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r980 - in trunk: . src src/connection-editor src/gconf-helpers src/utils src/wireless-security
- Date: Mon, 27 Oct 2008 01:17:39 +0000 (UTC)
Author: dcbw
Date: Mon Oct 27 01:17:39 2008
New Revision: 980
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=980&view=rev
Log:
2008-10-26 Dan Williams <dcbw redhat com>
Patch from Tambet Ingo <tambet gmail com>
* src/applet-device-cdma.c
src/applet-device-gsm.c
src/applet-device-wifi.c
src/applet-device-wired.c
src/applet-dialogs.c
src/applet.c
src/connection-editor/nm-connection-editor.c
src/connection-editor/nm-connection-list.c
src/connection-editor/page-ip4.c
src/connection-editor/vpn-helpers.c
src/gconf-helpers/gconf-helpers.c
src/gconf-helpers/gconf-upgrade.c
src/gconf-helpers/nma-gconf-connection.c
src/utils/utils.c
src/vpn-password-dialog.c
src/wired-dialog.c
src/wireless-dialog.c
src/wireless-security/wireless-security.c
- Update connection setting accessors
Modified:
trunk/ChangeLog
trunk/src/applet-device-cdma.c
trunk/src/applet-device-gsm.c
trunk/src/applet-device-wifi.c
trunk/src/applet-device-wired.c
trunk/src/applet-dialogs.c
trunk/src/applet.c
trunk/src/connection-editor/nm-connection-editor.c
trunk/src/connection-editor/nm-connection-list.c
trunk/src/connection-editor/page-ip4.c
trunk/src/connection-editor/vpn-helpers.c
trunk/src/gconf-helpers/gconf-helpers.c
trunk/src/gconf-helpers/gconf-upgrade.c
trunk/src/gconf-helpers/nma-gconf-connection.c
trunk/src/utils/utils.c
trunk/src/vpn-password-dialog.c
trunk/src/wired-dialog.c
trunk/src/wireless-dialog.c
trunk/src/wireless-security/wireless-security.c
Modified: trunk/src/applet-device-cdma.c
==============================================================================
--- trunk/src/applet-device-cdma.c (original)
+++ trunk/src/applet-device-cdma.c Mon Oct 27 01:17:39 2008
@@ -64,6 +64,7 @@
NMSettingSerial *s_serial;
NMSettingPPP *s_ppp;
NMSettingConnection *s_con;
+ char *uuid;
connection = nm_connection_new ();
@@ -87,10 +88,14 @@
nm_connection_add_setting (connection, NM_SETTING (s_ppp));
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
- s_con->id = g_strdup (DEFAULT_CDMA_NAME);
- s_con->type = g_strdup (NM_SETTING (s_cdma)->name);
- s_con->autoconnect = FALSE;
- s_con->uuid = nm_utils_uuid_generate ();
+ uuid = nm_utils_uuid_generate ();
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, DEFAULT_CDMA_NAME,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING (s_cdma)->name,
+ NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NULL);
+ g_free (uuid);
nm_connection_add_setting (connection, NM_SETTING (s_con));
return connection;
@@ -124,7 +129,7 @@
GtkWidget *item;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- item = gtk_check_menu_item_new_with_label (s_con->id);
+ item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
if (connection == active)
@@ -287,9 +292,12 @@
connection = applet_find_active_connection_for_device (device, applet, NULL);
if (connection) {
+ const char *id;
+
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (s_con && s_con->id)
- str = g_strdup_printf (_("You are now connected to '%s'."), s_con->id);
+ id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+ if (id)
+ str = g_strdup_printf (_("You are now connected to '%s'."), id);
}
applet_do_notify (applet, NOTIFY_URGENCY_LOW,
@@ -326,10 +334,15 @@
*tip = g_strdup_printf (_("Waiting for user authentication on device '%s'..."), iface);
break;
case NM_DEVICE_STATE_ACTIVATED:
- if (s_con && s_con->id)
- *tip = g_strdup_printf (_("Mobile broadband connection '%s'"), s_con->id);
- else
+ if (s_con) {
+ const char *id = nm_setting_connection_get_id (s_con);
+ if (id)
+ *tip = g_strdup_printf (_("Mobile broadband connection '%s'"), id);
+ }
+
+ if (!*tip)
*tip = g_strdup (_("Mobile broadband connection"));
+
pixbuf = applet->wwan_icon;
break;
default:
@@ -431,6 +444,7 @@
NMCdmaInfo *info;
NMSettingConnection *s_con;
char *tmp;
+ const char *id;
info = g_new (NMCdmaInfo, 1);
info->context = context;
@@ -448,8 +462,9 @@
gtk_window_set_default (GTK_WINDOW (dialog), info->ok_button);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- g_assert (s_con->id);
- tmp = g_strdup_printf (_("A password is required to connect to '%s'."), s_con->id);
+ id = nm_setting_connection_get_id (s_con);
+ g_assert (id);
+ tmp = g_strdup_printf (_("A password is required to connect to '%s'."), id);
w = gtk_label_new (tmp);
g_free (tmp);
gtk_box_pack_start (GTK_BOX (dialog->vbox), w, TRUE, TRUE, 0);
Modified: trunk/src/applet-device-gsm.c
==============================================================================
--- trunk/src/applet-device-gsm.c (original)
+++ trunk/src/applet-device-gsm.c Mon Oct 27 01:17:39 2008
@@ -65,6 +65,7 @@
NMSettingSerial *s_serial;
NMSettingPPP *s_ppp;
NMSettingConnection *s_con;
+ char *uuid;
connection = nm_connection_new ();
@@ -88,10 +89,14 @@
nm_connection_add_setting (connection, NM_SETTING (s_ppp));
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
- s_con->id = g_strdup (DEFAULT_GSM_NAME);
- s_con->type = g_strdup (NM_SETTING (s_gsm)->name);
- s_con->autoconnect = FALSE;
- s_con->uuid = nm_utils_uuid_generate ();
+ uuid = nm_utils_uuid_generate ();
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, DEFAULT_GSM_NAME,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING (s_gsm)->name,
+ NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NULL);
+ g_free (uuid);
nm_connection_add_setting (connection, NM_SETTING (s_con));
return connection;
@@ -125,7 +130,7 @@
GtkWidget *item;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- item = gtk_check_menu_item_new_with_label (s_con->id);
+ item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
if (connection == active)
@@ -288,9 +293,12 @@
connection = applet_find_active_connection_for_device (device, applet, NULL);
if (connection) {
+ const char *id;
+
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (s_con && s_con->id)
- str = g_strdup_printf (_("You are now connected to '%s'."), s_con->id);
+ id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+ if (id)
+ str = g_strdup_printf (_("You are now connected to '%s'."), id);
}
applet_do_notify (applet, NOTIFY_URGENCY_LOW,
@@ -327,9 +335,13 @@
*tip = g_strdup_printf (_("Waiting for user authentication on device '%s'..."), iface);
break;
case NM_DEVICE_STATE_ACTIVATED:
- if (s_con && s_con->id)
- *tip = g_strdup_printf (_("Mobile broadband connection '%s'"), s_con->id);
- else
+ if (s_con) {
+ const char *id;
+
+ id = nm_setting_connection_get_id (s_con);
+ if (id)
+ *tip = g_strdup_printf (_("Mobile broadband connection '%s'"), id);
+ } else
*tip = g_strdup (_("Mobile broadband connection"));
pixbuf = applet->wwan_icon;
break;
@@ -527,6 +539,7 @@
NMGsmInfo *info;
NMSettingConnection *s_con;
char *tmp;
+ const char *id;
info = g_new (NMGsmInfo, 1);
info->context = context;
@@ -544,8 +557,9 @@
gtk_window_set_default (GTK_WINDOW (dialog), info->ok_button);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- g_assert (s_con->id);
- tmp = g_strdup_printf (_("A password is required to connect to '%s'."), s_con->id);
+ id = nm_setting_connection_get_id (s_con);
+ g_assert (id);
+ tmp = g_strdup_printf (_("A password is required to connect to '%s'."), id);
w = gtk_label_new (tmp);
g_free (tmp);
gtk_box_pack_start (GTK_BOX (dialog->vbox), w, TRUE, TRUE, 0);
Modified: trunk/src/applet-device-wifi.c
==============================================================================
--- trunk/src/applet-device-wifi.c (original)
+++ trunk/src/applet-device-wifi.c Mon Oct 27 01:17:39 2008
@@ -323,6 +323,7 @@
NMSettingWirelessSecurity *s_wireless_sec = NULL;
NMSetting8021x *s_8021x = NULL;
const GByteArray *ap_ssid;
+ char *id;
char buf[33];
int buf_len;
NM80211Mode mode;
@@ -365,17 +366,21 @@
nm_connection_add_setting (connection, NM_SETTING (s_8021x));
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
- s_con->type = g_strdup (NM_SETTING (s_wireless)->name);
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING (s_wireless)->name,
+ NM_SETTING_CONNECTION_AUTOCONNECT, !is_manufacturer_default_ssid (ap_ssid),
+ NULL);
memset (buf, 0, sizeof (buf));
buf_len = MIN(ap_ssid->len, sizeof (buf) - 1);
memcpy (buf, ap_ssid->data, buf_len);
- s_con->id = g_strdup_printf ("Auto %s", nm_utils_ssid_to_utf8 (buf, buf_len));
-
- /* Only utoconnect APs that don't use the manufacturer default SSID. */
- s_con->autoconnect = !is_manufacturer_default_ssid (ap_ssid);
-
- s_con->uuid = nm_utils_uuid_generate ();
+ id = g_strdup_printf ("Auto %s", nm_utils_ssid_to_utf8 (buf, buf_len));
+ g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, NULL);
+ g_free (id);
+
+ id = nm_utils_uuid_generate ();
+ g_object_set (s_con, NM_SETTING_CONNECTION_UUID, id, NULL);
+ g_free (id);
nm_connection_add_setting (connection, NM_SETTING (s_con));
@@ -496,7 +501,7 @@
GtkWidget *subitem;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- subitem = gtk_menu_item_new_with_label (s_con->id);
+ subitem = gtk_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
info = g_slice_new0 (WirelessMenuItemInfo);
info->applet = applet;
@@ -977,7 +982,7 @@
NMSettingConnection *s_con;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (s_con->autoconnect) {
+ if (nm_setting_connection_get_autoconnect (s_con)) {
is_autoconnect = TRUE;
break;
}
@@ -1391,19 +1396,24 @@
} else {
/* Entirely new connection */
NMSettingConnection *s_con;
+ char *id;
/* Update a new connection's name and autoconnect status */
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (!s_con->id) {
+ id = (char *) nm_setting_connection_get_id (s_con);
+
+ if (!id) {
NMSettingWireless *s_wireless;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
- s_con->id = nm_utils_ssid_to_utf8 ((const char *) s_wireless->ssid->data, s_wireless->ssid->len);
+ id = nm_utils_ssid_to_utf8 ((const char *) s_wireless->ssid->data, s_wireless->ssid->len);
+ g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, NULL);
+ g_free (id);
// FIXME: don't autoconnect until the connection is successful at least once
/* Don't autoconnect adhoc networks by default for now */
if (!s_wireless->mode || !strcmp (s_wireless->mode, "infrastructure"))
- s_con->autoconnect = TRUE;
+ g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
}
/* Export it over D-Bus */
Modified: trunk/src/applet-device-wired.c
==============================================================================
--- trunk/src/applet-device-wired.c (original)
+++ trunk/src/applet-device-wired.c Mon Oct 27 01:17:39 2008
@@ -72,6 +72,7 @@
NMConnection *connection;
NMSettingWired *s_wired = NULL;
NMSettingConnection *s_con;
+ char *uuid;
connection = nm_connection_new ();
@@ -79,10 +80,15 @@
nm_connection_add_setting (connection, NM_SETTING (s_wired));
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
- s_con->id = g_strdup (DEFAULT_WIRED_NAME);
- s_con->type = g_strdup (NM_SETTING (s_wired)->name);
- s_con->autoconnect = TRUE;
- s_con->uuid = nm_utils_uuid_generate ();
+ uuid = nm_utils_uuid_generate ();
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, DEFAULT_WIRED_NAME,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING (s_wired)->name,
+ NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NULL);
+ g_free (uuid);
+
nm_connection_add_setting (connection, NM_SETTING (s_con));
return connection;
@@ -117,7 +123,7 @@
GtkWidget *item;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- item = gtk_check_menu_item_new_with_label (s_con->id);
+ item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
@@ -251,9 +257,11 @@
connection = applet_find_active_connection_for_device (device, applet, NULL);
if (connection) {
+ const char *id;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (s_con && s_con->id)
- str = g_strdup_printf (_("You are now connected to '%s'."), s_con->id);
+ id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+ if (id)
+ str = g_strdup_printf (_("You are now connected to '%s'."), id);
}
applet_do_notify (applet, NOTIFY_URGENCY_LOW,
@@ -692,6 +700,7 @@
GError **error)
{
NMSettingConnection *s_con;
+ const char *connection_type;
gboolean success = FALSE;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
@@ -702,9 +711,10 @@
return FALSE;
}
- if (!strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME)) {
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
success = nm_8021x_get_secrets (device, connection, specific_object, setting_name, context, applet, error);
- } else if (!strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME))
+ } else if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
success = pppoe_get_secrets (device, connection, specific_object, setting_name, context, applet, error);
return success;
Modified: trunk/src/applet-dialogs.c
==============================================================================
--- trunk/src/applet-dialogs.c (original)
+++ trunk/src/applet-dialogs.c Mon Oct 27 01:17:39 2008
@@ -159,11 +159,13 @@
NMSettingConnection *s_con;
char *label = NULL;
GtkWidget *w;
+ const char *connection_type;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if (!strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME)) {
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ if (!strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME)) {
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
NMSetting8021x *s_8021x;
@@ -188,7 +190,7 @@
} else {
label = g_strdup (_("None"));
}
- } else if (!strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME)) {
+ } else if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
NMSetting8021x *s_8021x;
s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
@@ -214,7 +216,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- str = g_string_new (s_con->id);
+ str = g_string_new (nm_setting_connection_get_id (s_con));
if (is_default)
str = g_string_append (str, " (default)");
Modified: trunk/src/applet.c
==============================================================================
--- trunk/src/applet.c (original)
+++ trunk/src/applet.c Mon Oct 27 01:17:39 2008
@@ -451,7 +451,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- s_con->timestamp = (guint64) time (NULL);
+ g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL), NULL);
nma_gconf_connection_save (gconf_connection);
}
@@ -470,27 +470,35 @@
switch (reason) {
case NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED:
- return g_strdup_printf (_("\nThe VPN connection '%s' failed because the network connection was interrupted."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed because the network connection was interrupted."),
+ nm_setting_connection_get_id (s_con));
case NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED:
- return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service stopped unexpectedly."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service stopped unexpectedly."),
+ nm_setting_connection_get_id (s_con));
case NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID:
- return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service returned invalid configuration."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service returned invalid configuration."),
+ nm_setting_connection_get_id (s_con));
case NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT:
- return g_strdup_printf (_("\nThe VPN connection '%s' failed because the connection attempt timed out."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed because the connection attempt timed out."),
+ nm_setting_connection_get_id (s_con));
case NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT:
- return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service did not start in time."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service did not start in time."),
+ nm_setting_connection_get_id (s_con));
case NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED:
- return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service failed to start."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service failed to start."),
+ nm_setting_connection_get_id (s_con));
case NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS:
- return g_strdup_printf (_("\nThe VPN connection '%s' failed because there were no valid VPN secrets."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed because there were no valid VPN secrets."),
+ nm_setting_connection_get_id (s_con));
case NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED:
- return g_strdup_printf (_("\nThe VPN connection '%s' failed because of invalid VPN secrets."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed because of invalid VPN secrets."),
+ nm_setting_connection_get_id (s_con));
default:
break;
}
- return g_strdup_printf (_("\nThe VPN connection '%s' failed."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' failed."), nm_setting_connection_get_id (s_con));
}
static char *
@@ -508,14 +516,16 @@
switch (reason) {
case NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED:
- return g_strdup_printf (_("\nThe VPN connection '%s' disconnected because the network connection was interrupted."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' disconnected because the network connection was interrupted."),
+ nm_setting_connection_get_id (s_con));
case NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED:
- return g_strdup_printf (_("\nThe VPN connection '%s' disconnected because the VPN service stopped."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' disconnected because the VPN service stopped."),
+ nm_setting_connection_get_id (s_con));
default:
break;
}
- return g_strdup_printf (_("\nThe VPN connection '%s' disconnected."), s_con->id);
+ return g_strdup_printf (_("\nThe VPN connection '%s' disconnected."), nm_setting_connection_get_id (s_con));
}
static void
@@ -588,7 +598,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_return_val_if_fail (s_con != NULL, NULL);
- return s_con->id;
+ return nm_setting_connection_get_id (s_con);
}
typedef struct {
@@ -661,7 +671,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
info = g_malloc0 (sizeof (VPNActivateInfo));
info->applet = applet;
- info->vpn_name = g_strdup (s_con->id);
+ info->vpn_name = g_strdup (nm_setting_connection_get_id (s_con));
/* Connection inactive, activate */
is_system = is_system_connection (connection);
@@ -716,7 +726,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME)) {
+ if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
if (out_state)
*out_state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (candidate));
return candidate;
@@ -992,7 +1002,7 @@
NMSettingConnection *s_con;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME))
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME))
/* Not a VPN connection */
continue;
@@ -1838,10 +1848,9 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_return_if_fail (s_con != NULL);
- g_return_if_fail (s_con->type != NULL);
/* VPN secrets get handled a bit differently */
- if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME)) {
+ if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
nma_vpn_request_password (NM_EXPORTED_CONNECTION (exported), ask_user, context);
return;
}
@@ -1927,7 +1936,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- s_con->timestamp = (guint64) time (NULL);
+ g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) time (NULL), NULL);
nma_gconf_connection_save (gconf_connection);
break;
}
Modified: trunk/src/connection-editor/nm-connection-editor.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-editor.c (original)
+++ trunk/src/connection-editor/nm-connection-editor.c Mon Oct 27 01:17:39 2008
@@ -86,14 +86,16 @@
nm_connection_editor_update_title (NMConnectionEditor *editor)
{
NMSettingConnection *s_con;
+ const char *id;
g_return_if_fail (editor != NULL);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if (s_con->id && strlen (s_con->id)) {
- char *title = g_strdup_printf (_("Editing %s"), s_con->id);
+ id = nm_setting_connection_get_id (s_con);
+ if (id && strlen (id)) {
+ char *title = g_strdup_printf (_("Editing %s"), id);
gtk_window_set_title (GTK_WINDOW (editor->window), title);
g_free (title);
} else
@@ -420,8 +422,11 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
if (s_con) {
- gtk_entry_set_text (GTK_ENTRY (name), s_con->id);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoconnect), s_con->autoconnect);
+ const char *id = nm_setting_connection_get_id (s_con);
+
+ gtk_entry_set_text (GTK_ENTRY (name), id);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoconnect),
+ nm_setting_connection_get_autoconnect (s_con));
} else {
gtk_entry_set_text (GTK_ENTRY (name), NULL);
}
@@ -470,6 +475,7 @@
nm_connection_editor_set_connection (NMConnectionEditor *editor, NMConnection *connection)
{
NMSettingConnection *s_con;
+ const char *connection_type;
g_return_if_fail (NM_IS_CONNECTION_EDITOR (editor));
g_return_if_fail (NM_IS_CONNECTION (connection));
@@ -485,27 +491,28 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if (!strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME)) {
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ if (!strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME)) {
add_page (editor, CE_PAGE (ce_page_wired_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_wired_security_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_ip4_new (editor->connection)));
- } else if (!strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME)) {
+ } else if (!strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME)) {
add_page (editor, CE_PAGE (ce_page_wireless_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_wireless_security_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_ip4_new (editor->connection)));
- } else if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME)) {
+ } else if (!strcmp (connection_type, NM_SETTING_VPN_SETTING_NAME)) {
add_page (editor, CE_PAGE (ce_page_vpn_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_ip4_new (editor->connection)));
- } else if (!strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME)) {
+ } else if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) {
add_page (editor, CE_PAGE (ce_page_dsl_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_wired_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_ppp_new (editor->connection)));
- } else if (!strcmp (s_con->type, NM_SETTING_GSM_SETTING_NAME) ||
- !strcmp (s_con->type, NM_SETTING_CDMA_SETTING_NAME)) {
+ } else if (!strcmp (connection_type, NM_SETTING_GSM_SETTING_NAME) ||
+ !strcmp (connection_type, NM_SETTING_CDMA_SETTING_NAME)) {
add_page (editor, CE_PAGE (ce_page_mobile_new (editor->connection)));
add_page (editor, CE_PAGE (ce_page_ppp_new (editor->connection)));
} else {
- g_warning ("Unhandled setting type '%s'", s_con->type);
+ g_warning ("Unhandled setting type '%s'", connection_type);
}
/* set the UI */
Modified: trunk/src/connection-editor/nm-connection-list.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.c (original)
+++ trunk/src/connection-editor/nm-connection-list.c Mon Oct 27 01:17:39 2008
@@ -137,17 +137,20 @@
NMSettingConnection *s_con;
GtkTreeView *treeview;
GtkTreeModel *model;
+ const char *connection_type;
connection = nm_exported_connection_get_connection (exported);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (!s_con || !s_con->type) {
+ connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+
+ if (!connection_type) {
g_warning ("Ignoring incomplete connection");
return NULL;
}
- treeview = (GtkTreeView *) g_hash_table_lookup (list->treeviews, s_con->type);
+ treeview = (GtkTreeView *) g_hash_table_lookup (list->treeviews, connection_type);
if (!treeview) {
- g_warning ("No registered treeview for connection type '%s'", s_con->type);
+ g_warning ("No registered treeview for connection type '%s'", connection_type);
return NULL;
}
@@ -268,11 +271,11 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- last_used = format_last_used (s_con->timestamp);
+ last_used = format_last_used (nm_setting_connection_get_timestamp (s_con));
gtk_list_store_set (store, iter,
- COL_ID, s_con->id,
+ COL_ID, nm_setting_connection_get_id (s_con),
COL_LAST_USED, last_used,
- COL_TIMESTAMP, s_con->timestamp,
+ COL_TIMESTAMP, nm_setting_connection_get_timestamp (s_con),
COL_CONNECTION, exported,
-1);
g_free (last_used);
@@ -409,12 +412,11 @@
connection = nm_exported_connection_get_connection (exported);
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
- g_assert (s_con->type);
/* FIXME: clean up any left-over connection secrets here */
/* Clean up VPN secrets and any plugin-specific data */
- if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME)) {
+ if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) {
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
if (s_vpn) {
plugin = vpn_get_plugin_by_service (s_vpn->service_type);
@@ -710,12 +712,14 @@
NMExportedConnection *exported = NM_EXPORTED_CONNECTION (data);
NMConnection *connection;
NMSettingConnection *s_con;
+ const char *id;
GSList **list = (GSList **) user_data;
connection = nm_exported_connection_get_connection (exported);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- g_assert (s_con->id);
- *list = g_slist_append (*list, s_con->id);
+ id = nm_setting_connection_get_id (s_con);
+ g_assert (id);
+ *list = g_slist_append (*list, (gpointer) id);
}
static char *
@@ -780,6 +784,7 @@
NMConnection *connection = NULL;
NMSettingConnection *s_con;
NMSetting *type_setting = NULL;
+ char *id, *uuid;
GType mb_type;
ctype = nm_connection_lookup_setting_type (connection_type);
@@ -787,25 +792,35 @@
connection = nm_connection_new ();
nm_connection_set_scope (connection, NM_CONNECTION_SCOPE_USER);
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
- s_con->uuid = nm_utils_uuid_generate ();
+ uuid = nm_utils_uuid_generate ();
+ g_object_set (s_con, NM_SETTING_CONNECTION_UUID, uuid, NULL);
+ g_free (uuid);
nm_connection_add_setting (connection, NM_SETTING (s_con));
if (ctype == NM_TYPE_SETTING_WIRED) {
- s_con->id = get_next_available_name (list, _("Wired connection %d"));
- s_con->type = g_strdup (NM_SETTING_WIRED_SETTING_NAME);
- s_con->autoconnect = TRUE;
+ id = get_next_available_name (list, _("Wired connection %d"));
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, id,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
+ NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
+ NULL);
+ g_free (id);
type_setting = nm_setting_wired_new ();
} else if (ctype == NM_TYPE_SETTING_WIRELESS) {
NMSettingWireless *s_wireless;
- s_con->id = get_next_available_name (list, _("Wireless connection %d"));
- s_con->type = g_strdup (NM_SETTING_WIRELESS_SETTING_NAME);
- s_con->autoconnect = TRUE;
+ id = get_next_available_name (list, _("Wireless connection %d"));
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, id,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME,
+ NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
+ NULL);
+ g_free (id);
type_setting = nm_setting_wireless_new ();
s_wireless = NM_SETTING_WIRELESS (type_setting);
- s_wireless->mode = g_strdup ("infrastructure");
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
} else if ((ctype == NM_TYPE_SETTING_GSM) || (ctype == NM_TYPE_SETTING_CDMA)) {
/* Since GSM is a placeholder for both GSM and CDMA; ask the user which
* one they really want.
@@ -814,24 +829,32 @@
if (mb_type == NM_TYPE_SETTING_GSM) {
NMSettingGsm *s_gsm;
- s_con->id = get_next_available_name (list, _("GSM connection %d"));
- s_con->type = g_strdup (NM_SETTING_GSM_SETTING_NAME);
- s_con->autoconnect = FALSE;
+ id = get_next_available_name (list, _("GSM connection %d"));
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, id,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_GSM_SETTING_NAME,
+ NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
+ NULL);
+ g_free (id);
add_default_serial_setting (connection);
type_setting = nm_setting_gsm_new ();
s_gsm = NM_SETTING_GSM (type_setting);
- /* De-facto standard for GSM */
+ /* De-facto standard for GSM */
g_object_set (s_gsm, NM_SETTING_GSM_NUMBER, "*99#", NULL);
nm_connection_add_setting (connection, nm_setting_ppp_new ());
} else if (mb_type == NM_TYPE_SETTING_CDMA) {
NMSettingCdma *s_cdma;
- s_con->id = get_next_available_name (list, _("CDMA connection %d"));
- s_con->type = g_strdup (NM_SETTING_CDMA_SETTING_NAME);
- s_con->autoconnect = FALSE;
+ id = get_next_available_name (list, _("CDMA connection %d"));
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, id,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_CDMA_SETTING_NAME,
+ NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
+ NULL);
+ g_free (id);
add_default_serial_setting (connection);
@@ -852,16 +875,26 @@
if (service) {
NMSettingVPN *s_vpn;
- s_con->id = get_next_available_name (list, _("VPN connection %d"));
- s_con->type = g_strdup (NM_SETTING_VPN_SETTING_NAME);
+ id = get_next_available_name (list, _("VPN connection %d"));
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, id,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_VPN_SETTING_NAME,
+ NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
+ NULL);
+ g_free (id);
type_setting = nm_setting_vpn_new ();
s_vpn = NM_SETTING_VPN (type_setting);
s_vpn->service_type = service;
}
} else if (ctype == NM_TYPE_SETTING_PPPOE) {
- s_con->id = get_next_available_name (list, _("DSL connection %d"));
- s_con->type = g_strdup (NM_SETTING_PPPOE_SETTING_NAME);
+ id = get_next_available_name (list, _("DSL connection %d"));
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, id,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_PPPOE_SETTING_NAME,
+ NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
+ NULL);
+ g_free (id);
type_setting = nm_setting_pppoe_new ();
@@ -1051,13 +1084,16 @@
NMConnection *connection;
NMSettingConnection *s_con;
GtkWidget *dialog;
+ const char *id;
guint result;
exported = get_active_connection (info->treeview);
g_return_if_fail (exported != NULL);
connection = nm_exported_connection_get_connection (exported);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (!s_con || !s_con->id)
+ id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+
+ if (!id)
return;
dialog = gtk_message_dialog_new (GTK_WINDOW (info->list->dialog),
@@ -1065,7 +1101,7 @@
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
_("Are you sure you wish to delete the connection %s?"),
- s_con->id);
+ id);
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_DELETE, GTK_RESPONSE_YES,
@@ -1136,6 +1172,7 @@
NMConnectionEditor *editor;
NMSettingConnection *s_con;
NMSettingVPN *s_vpn;
+ char *s;
/* Basic sanity checks of the connection */
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
@@ -1143,14 +1180,24 @@
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
nm_connection_add_setting (connection, NM_SETTING (s_con));
}
- if (!s_con->id)
- s_con->id = get_next_available_name (info->list, _("VPN connection %d"));
- if (!s_con->type || strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME)) {
- g_free (s_con->type);
- s_con->type = g_strdup (NM_SETTING_VPN_SETTING_NAME);
+
+ s = (char *) nm_setting_connection_get_id (s_con);
+ if (!s) {
+ s = get_next_available_name (info->list, _("VPN connection %d"));
+ g_object_set (s_con, NM_SETTING_CONNECTION_ID, s, NULL);
+ g_free (s);
+ }
+
+ s = (char *) nm_setting_connection_get_connection_type (s_con);
+ if (!s || strcmp (s, NM_SETTING_VPN_SETTING_NAME))
+ g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, NM_SETTING_VPN_SETTING_NAME, NULL);
+
+ s = (char *) nm_setting_connection_get_uuid (s_con);
+ if (!s) {
+ s = nm_utils_uuid_generate ();
+ g_object_set (s_con, NM_SETTING_CONNECTION_UUID, s, NULL);
+ g_free (s);
}
- if (!s_con->uuid)
- s_con->uuid = nm_utils_uuid_generate ();
s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
if (!s_vpn || !s_vpn->service_type || !strlen (s_vpn->service_type)) {
@@ -1535,13 +1582,13 @@
connection = nm_exported_connection_get_connection (exported);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- last_used = format_last_used (s_con->timestamp);
+ last_used = format_last_used (nm_setting_connection_get_timestamp (s_con));
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- COL_ID, s_con->id,
+ COL_ID, nm_setting_connection_get_id (s_con),
COL_LAST_USED, last_used,
- COL_TIMESTAMP, s_con->timestamp,
+ COL_TIMESTAMP, nm_setting_connection_get_timestamp (s_con),
COL_CONNECTION, exported,
-1);
Modified: trunk/src/connection-editor/page-ip4.c
==============================================================================
--- trunk/src/connection-editor/page-ip4.c (original)
+++ trunk/src/connection-editor/page-ip4.c Mon Oct 27 01:17:39 2008
@@ -96,23 +96,26 @@
GladeXML *xml;
GtkTreeIter iter;
NMSettingConnection *s_con;
+ const char *connection_type;
char *str_auto = NULL, *str_auto_only = NULL;
gboolean is_vpn = FALSE;
xml = CE_PAGE (self)->xml;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- g_assert (s_con && s_con->type);
+ g_assert (s_con);
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ g_assert (connection_type);
- if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME)) {
+ if (!strcmp (connection_type, NM_SETTING_VPN_SETTING_NAME)) {
str_auto = _("Automatic (VPN)");
str_auto_only = _("Automatic (VPN) addresses only");
is_vpn = TRUE;
- } else if ( !strcmp (s_con->type, NM_SETTING_GSM_SETTING_NAME)
- || !strcmp (s_con->type, NM_SETTING_CDMA_SETTING_NAME)) {
+ } else if ( !strcmp (connection_type, NM_SETTING_GSM_SETTING_NAME)
+ || !strcmp (connection_type, NM_SETTING_CDMA_SETTING_NAME)) {
str_auto = _("Automatic (PPP)");
str_auto_only = _("Automatic (PPP) addresses only");
- } else if (!strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME)) {
+ } else if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) {
str_auto = _("Automatic (PPPoE)");
str_auto_only = _("Automatic (PPPoE) addresses only");
} else {
@@ -594,7 +597,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- priv->connection_id = g_strdup (s_con->id);
+ priv->connection_id = g_strdup (nm_setting_connection_get_id (s_con));
priv->setting = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
if (!priv->setting) {
Modified: trunk/src/connection-editor/vpn-helpers.c
==============================================================================
--- trunk/src/connection-editor/vpn-helpers.c (original)
+++ trunk/src/connection-editor/vpn-helpers.c Mon Oct 27 01:17:39 2008
@@ -283,6 +283,7 @@
NMVpnPluginUiInterface *plugin;
NMSettingConnection *s_con = NULL;
NMSettingVPN *s_vpn = NULL;
+ const char *id = NULL;
gboolean success = FALSE;
if (response != GTK_RESPONSE_ACCEPT)
@@ -317,7 +318,8 @@
}
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (!s_con || !s_con->id) {
+ id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+ if (!id) {
g_set_error (&error, 0, 0, "connection setting invalid");
goto done;
}
@@ -336,7 +338,6 @@
if (!success) {
GtkWidget *err_dialog;
char *basename = filename ? g_path_get_basename (filename) : g_strdup ("(none)");
- char *id = s_con ? s_con->id : "(unknown)";
err_dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
Modified: trunk/src/gconf-helpers/gconf-helpers.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-helpers.c (original)
+++ trunk/src/gconf-helpers/gconf-helpers.c Mon Oct 27 01:17:39 2008
@@ -1508,8 +1508,8 @@
info.connection = connection;
info.client = client;
info.dir = dir;
- info.connection_uuid = s_con->uuid;
- info.connection_name = s_con->id;
+ info.connection_uuid = nm_setting_connection_get_uuid (s_con);
+ info.connection_name = nm_setting_connection_get_id (s_con);
nm_connection_for_each_setting_value (connection,
copy_one_setting_value_to_gconf,
&info);
@@ -1587,7 +1587,7 @@
} else {
g_set_error (error, NM_SETTINGS_ERROR, 1,
"%s.%d - %s/%s Unknown private key password type '%s'.",
- __FILE__, __LINE__, s_con->id, setting_name, tag);
+ __FILE__, __LINE__, nm_setting_connection_get_id (s_con), setting_name, tag);
return FALSE;
}
@@ -1609,7 +1609,7 @@
} else if (!array || !array->len) {
g_set_error (error, NM_SETTINGS_ERROR, 1,
"%s.%d - %s/%s couldn't read private key.",
- __FILE__, __LINE__, s_con->id, setting_name);
+ __FILE__, __LINE__, nm_setting_connection_get_id (s_con), setting_name);
goto out;
}
@@ -1647,15 +1647,15 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- g_assert (s_con->id);
- g_assert (s_con->uuid);
- connection_name = s_con->id;
+
+ connection_name = nm_setting_connection_get_id (s_con);
+ g_assert (connection_name);
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
&found_list,
KEYRING_UUID_TAG,
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
- s_con->uuid,
+ nm_setting_connection_get_uuid (s_con),
KEYRING_SN_TAG,
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
setting_name,
Modified: trunk/src/gconf-helpers/gconf-upgrade.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-upgrade.c (original)
+++ trunk/src/gconf-helpers/gconf-upgrade.c Mon Oct 27 01:17:39 2008
@@ -337,6 +337,7 @@
NMSettingWirelessSecurity *s_wireless_sec;
NMSetting8021x *s_8021x = NULL;
char *path, *network, *essid = NULL;
+ char *s;
int timestamp, we_cipher;
GSList *bssids = NULL;
char *private_key_path = NULL, *client_cert_path = NULL, *ca_cert_path = NULL;
@@ -358,11 +359,19 @@
we_cipher = NM_AUTH_TYPE_NONE;
s_con = (NMSettingConnection *)nm_setting_connection_new ();
- s_con->id = g_strdup_printf ("Auto %s", essid);
- s_con->type = g_strdup ("802-11-wireless");
- s_con->autoconnect = (timestamp != 0);
- s_con->timestamp = timestamp;
- s_con->uuid = nm_utils_uuid_generate ();
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME,
+ NM_SETTING_CONNECTION_AUTOCONNECT, (timestamp != 0),
+ NM_SETTING_CONNECTION_TIMESTAMP, timestamp,
+ NULL);
+
+ s = g_strdup_printf ("Auto %s", essid);
+ g_object_set (s_con, NM_SETTING_CONNECTION_ID, s, NULL);
+ g_free (s);
+
+ s = nm_utils_uuid_generate ();
+ g_object_set (s_con, NM_SETTING_CONNECTION_UUID, s, NULL);
+ g_free (s);
s_wireless = (NMSettingWireless *)nm_setting_wireless_new ();
s_wireless->ssid = g_byte_array_new ();
@@ -554,9 +563,15 @@
vpn_data = NULL;
s_con = (NMSettingConnection *)nm_setting_connection_new ();
- s_con->id = id;
- s_con->type = g_strdup ("vpn");
- s_con->uuid = nm_utils_uuid_generate ();
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, id,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_VPN_SETTING_NAME,
+ NULL);
+
+ g_free (id);
+ id = nm_utils_uuid_generate ();
+ g_object_set (s_con, NM_SETTING_CONNECTION_UUID, id, NULL);
+ g_free (id);
s_vpn = (NMSettingVPN *)nm_setting_vpn_new ();
s_vpn->service_type = service_name;
Modified: trunk/src/gconf-helpers/nma-gconf-connection.c
==============================================================================
--- trunk/src/gconf-helpers/nma-gconf-connection.c (original)
+++ trunk/src/gconf-helpers/nma-gconf-connection.c Mon Oct 27 01:17:39 2008
@@ -227,6 +227,8 @@
GHashTable *secrets = NULL;
NMSettingConnection *s_con;
NMSetting *setting;
+ const char *connection_id;
+ const char *connection_type;
connection = nm_exported_connection_get_connection (exported);
@@ -240,7 +242,10 @@
}
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- if (!s_con || !s_con->id || !strlen (s_con->id) || !s_con->type) {
+ connection_id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
+ connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+
+ if (!s_con || !connection_id || !strlen (connection_id) || !connection_type) {
g_set_error (&error, NM_SETTINGS_ERROR, 1,
"%s.%d - Connection didn't have required '"
NM_SETTING_CONNECTION_SETTING_NAME
@@ -251,12 +256,12 @@
}
/* VPN passwords are handled by the VPN plugin's auth dialog */
- if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME))
+ if (!strcmp (connection_type, NM_SETTING_VPN_SETTING_NAME))
goto get_secrets;
if (request_new) {
nm_info ("New secrets for %s/%s requested; ask the user",
- s_con->id, setting_name);
+ connection_id, setting_name);
nm_connection_clear_secrets (connection);
goto get_secrets;
}
@@ -268,7 +273,7 @@
return;
}
nm_info ("No keyring secrets found for %s/%s; asking user.",
- s_con->id, setting_name);
+ connection_id, setting_name);
goto get_secrets;
}
Modified: trunk/src/utils/utils.c
==============================================================================
--- trunk/src/utils/utils.c (original)
+++ trunk/src/utils/utils.c Mon Oct 27 01:17:39 2008
@@ -529,13 +529,15 @@
NMSettingWired *s_wired;
const char *str_mac;
struct ether_addr *bin_mac;
+ const char *connection_type;
const GByteArray *setting_mac;
gboolean is_pppoe = FALSE;
- if (!strcmp (s_con->type, NM_SETTING_PPPOE_SETTING_NAME))
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
is_pppoe = TRUE;
- if (!is_pppoe && strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME))
+ if (!is_pppoe && strcmp (connection_type, NM_SETTING_WIRED_SETTING_NAME))
return FALSE;
s_wired = NM_SETTING_WIRED (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED));
@@ -573,7 +575,7 @@
guint32 wcaps;
NMAccessPoint *ap;
- if (strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME))
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRELESS_SETTING_NAME))
return FALSE;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
@@ -655,7 +657,7 @@
{
NMSettingGsm *s_gsm;
- if (strcmp (s_con->type, NM_SETTING_GSM_SETTING_NAME))
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME))
return FALSE;
s_gsm = NM_SETTING_GSM (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM));
@@ -672,7 +674,7 @@
{
NMSettingCdma *s_cdma;
- if (strcmp (s_con->type, NM_SETTING_CDMA_SETTING_NAME))
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME))
return FALSE;
s_cdma = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA));
@@ -693,7 +695,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_return_val_if_fail (s_con != NULL, FALSE);
- g_return_val_if_fail (s_con->type != NULL, FALSE);
+ g_return_val_if_fail (nm_setting_connection_get_connection_type (s_con) != NULL, FALSE);
if (NM_IS_DEVICE_ETHERNET (device))
return connection_valid_for_wired (connection, s_con, device, specific_object);
Modified: trunk/src/vpn-password-dialog.c
==============================================================================
--- trunk/src/vpn-password-dialog.c (original)
+++ trunk/src/vpn-password-dialog.c Mon Oct 27 01:17:39 2008
@@ -190,22 +190,28 @@
gboolean success = FALSE;
GError *error = NULL;
NMConnection *connection;
+ const char *id;
+ const char *connection_type;
g_return_val_if_fail (NM_IS_EXPORTED_CONNECTION (exported), FALSE);
connection = nm_exported_connection_get_connection (exported);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_return_val_if_fail (s_con != NULL, FALSE);
- g_return_val_if_fail (s_con->id != NULL, FALSE);
- g_return_val_if_fail (s_con->type != NULL, FALSE);
- g_return_val_if_fail (strcmp (s_con->type, "vpn") == 0, FALSE);
+
+ id = nm_setting_connection_get_id (s_con);
+ g_return_val_if_fail (id != NULL, FALSE);
+
+ connection_type = nm_setting_connection_get_connection_type (s_con);
+ g_return_val_if_fail (connection_type != NULL, FALSE);
+ g_return_val_if_fail (strcmp (connection_type, NM_SETTING_VPN_SETTING_NAME) == 0, FALSE);
s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
g_return_val_if_fail (s_vpn != NULL, FALSE);
g_return_val_if_fail (s_vpn->service_type != NULL, FALSE);
/* find the auth-dialog binary */
- auth_dialog_binary = find_auth_dialog_binary (s_vpn->service_type, s_con->id);
+ auth_dialog_binary = find_auth_dialog_binary (s_vpn->service_type, id);
if (!auth_dialog_binary) {
g_set_error (&error, NM_SETTINGS_ERROR, 1,
"%s.%d (%s): couldn't find VPN auth dialog helper program '%s'.",
@@ -215,8 +221,8 @@
/* Fix up parameters with what we got */
argv[0] = auth_dialog_binary;
- argv[2] = s_con->uuid;
- argv[4] = s_con->id;
+ argv[2] = nm_setting_connection_get_uuid (s_con);
+ argv[4] = id;
argv[6] = s_vpn->service_type;
if (!retry)
argv[7] = NULL;
@@ -242,7 +248,7 @@
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Cannot start VPN connection '%s'"),
- s_con->id);
+ id);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
_("There was a problem launching the authentication dialog for VPN connection type '%s'. Contact your system administrator."),
s_vpn->service_type);
Modified: trunk/src/wired-dialog.c
==============================================================================
--- trunk/src/wired-dialog.c (original)
+++ trunk/src/wired-dialog.c Mon Oct 27 01:17:39 2008
@@ -30,7 +30,7 @@
setting = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
gtk_widget_set_sensitive (GTK_WIDGET (entry), FALSE);
- gtk_entry_set_text (entry, setting->id);
+ gtk_entry_set_text (entry, nm_setting_connection_get_id (setting));
}
static WirelessSecurity *
Modified: trunk/src/wireless-dialog.c
==============================================================================
--- trunk/src/wireless-dialog.c (original)
+++ trunk/src/wireless-dialog.c Mon Oct 27 01:17:39 2008
@@ -368,7 +368,8 @@
asc = NM_SETTING_CONNECTION (nm_connection_get_setting (a, NM_TYPE_SETTING_CONNECTION));
bsc = NM_SETTING_CONNECTION (nm_connection_get_setting (b, NM_TYPE_SETTING_CONNECTION));
- return strcmp (asc->id, bsc->id);
+ return strcmp (nm_setting_connection_get_id (asc),
+ nm_setting_connection_get_id (bsc));
}
static gboolean
@@ -381,6 +382,7 @@
GtkWidget *widget;
NMSettingConnection *s_con;
GtkCellRenderer *renderer;
+ const char *id;
g_return_val_if_fail (priv->connection == NULL, FALSE);
@@ -394,11 +396,13 @@
if (connection) {
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- g_assert (s_con->id);
+
+ id = nm_setting_connection_get_id (s_con);
+ g_assert (id);
gtk_list_store_append (store, &tree_iter);
gtk_list_store_set (store, &tree_iter,
- C_NAME_COLUMN, g_strdup (s_con->id),
+ C_NAME_COLUMN, id,
C_CON_COLUMN, connection, -1);
} else {
GSList *connections, *iter, *to_add = NULL;
@@ -415,12 +419,14 @@
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = NM_CONNECTION (iter->data);
NMSettingWireless *s_wireless;
+ const char *connection_type;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
- if (!s_con || !s_con->type)
+ connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+ if (connection_type)
continue;
- if (strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME))
+ if (strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME))
continue;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRELESS));
@@ -466,7 +472,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
gtk_list_store_append (store, &tree_iter);
gtk_list_store_set (store, &tree_iter,
- C_NAME_COLUMN, g_strdup (s_con->id),
+ C_NAME_COLUMN, nm_setting_connection_get_id (s_con),
C_CON_COLUMN, candidate, -1);
num_added++;
}
@@ -980,12 +986,17 @@
if (!priv->connection) {
NMSettingConnection *s_con;
+ char *uuid;
connection = nm_connection_new ();
s_con = (NMSettingConnection *) nm_setting_connection_new ();
- s_con->type = g_strdup (NM_SETTING_WIRELESS_SETTING_NAME);
- s_con->uuid = nm_utils_uuid_generate ();
+ uuid = nm_utils_uuid_generate ();
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRELESS_SETTING_NAME,
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NULL);
+ g_free (uuid);
nm_connection_add_setting (connection, (NMSetting *) s_con);
s_wireless = (NMSettingWireless *) nm_setting_wireless_new ();
Modified: trunk/src/wireless-security/wireless-security.c
==============================================================================
--- trunk/src/wireless-security/wireless-security.c (original)
+++ trunk/src/wireless-security/wireless-security.c Mon Oct 27 01:17:39 2008
@@ -299,9 +299,8 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- g_assert (s_con->type);
- g_assert (s_con->uuid);
- if (!strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME))
+
+ if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRED_SETTING_NAME))
wired = TRUE;
s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]