network-manager-applet r612 - in trunk: . src src/gconf-helpers src/utils
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r612 - in trunk: . src src/gconf-helpers src/utils
- Date: Mon, 24 Mar 2008 15:18:31 +0000 (GMT)
Author: dcbw
Date: Mon Mar 24 15:18:30 2008
New Revision: 612
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=612&view=rev
Log:
2008-03-24 Dan Williams <dcbw redhat com>
Fixup to match libnm-glib changes in NM r3491
Modified:
trunk/ChangeLog
trunk/src/applet-device-cdma.c
trunk/src/applet-device-gsm.c
trunk/src/applet-device-wired.c
trunk/src/applet-device-wireless.c
trunk/src/applet-dialogs.c
trunk/src/applet.c
trunk/src/applet.h
trunk/src/gconf-helpers/Makefile.am
trunk/src/utils/Makefile.am
trunk/src/wireless-dialog.c
Modified: trunk/src/applet-device-cdma.c
==============================================================================
--- trunk/src/applet-device-cdma.c (original)
+++ trunk/src/applet-device-cdma.c Mon Mar 24 15:18:30 2008
@@ -167,8 +167,13 @@
cdma_menu_item_deactivate (GtkMenuItem *item, gpointer user_data)
{
CdmaMenuItemInfo *info = (CdmaMenuItemInfo *) user_data;
+ NMActiveConnection *active = NULL;
- nm_device_deactivate (info->device);
+ applet_find_active_connection_for_device (info->device, info->applet, &active);
+ if (active)
+ nm_client_deactivate_connection (info->applet->nm_client, active);
+ else
+ g_warning ("%s: couldn't find active connection to deactive", __func__);
}
static void
@@ -219,21 +224,17 @@
g_slist_free (all);
if (n_devices > 1) {
- const char *desc;
- char *dev_name = NULL;
+ char *desc;
- desc = utils_get_device_description (device);
- if (desc)
- dev_name = g_strdup (desc);
- if (!dev_name)
- dev_name = nm_device_get_iface (device);
- g_assert (dev_name);
+ desc = (char *) utils_get_device_description (device);
+ if (!desc)
+ desc = (char *) nm_device_get_iface (device);
+ g_assert (desc);
if (g_slist_length (connections) > 1)
- text = g_strdup_printf (_("CDMA Connections (%s)"), dev_name);
+ text = g_strdup_printf (_("CDMA Connections (%s)"), desc);
else
- text = g_strdup_printf (_("CDMA Network (%s)"), dev_name);
- g_free (dev_name);
+ text = g_strdup_printf (_("CDMA Network (%s)"), desc);
} else {
if (g_slist_length (connections) > 1)
text = g_strdup (_("CDMA Connections"));
@@ -284,7 +285,7 @@
NMApplet *applet)
{
GdkPixbuf *pixbuf = NULL;
- char *iface;
+ const char *iface;
iface = nm_device_get_iface (NM_DEVICE (device));
@@ -303,7 +304,6 @@
break;
}
- g_free (iface);
return pixbuf;
}
Modified: trunk/src/applet-device-gsm.c
==============================================================================
--- trunk/src/applet-device-gsm.c (original)
+++ trunk/src/applet-device-gsm.c Mon Mar 24 15:18:30 2008
@@ -167,8 +167,13 @@
gsm_menu_item_deactivate (GtkMenuItem *item, gpointer user_data)
{
GSMMenuItemInfo *info = (GSMMenuItemInfo *) user_data;
+ NMActiveConnection *active = NULL;
- nm_device_deactivate (info->device);
+ applet_find_active_connection_for_device (info->device, info->applet, &active);
+ if (active)
+ nm_client_deactivate_connection (info->applet->nm_client, active);
+ else
+ g_warning ("%s: couldn't find active connection to deactive", __func__);
}
static void
@@ -219,21 +224,17 @@
g_slist_free (all);
if (n_devices > 1) {
- const char *desc;
- char *dev_name = NULL;
+ char *desc;
- desc = utils_get_device_description (device);
- if (desc)
- dev_name = g_strdup (desc);
- if (!dev_name)
- dev_name = nm_device_get_iface (device);
- g_assert (dev_name);
+ desc = (char *) utils_get_device_description (device);
+ if (!desc)
+ desc = (char *) nm_device_get_iface (device);
+ g_assert (desc);
if (g_slist_length (connections) > 1)
- text = g_strdup_printf (_("GSM Connections (%s)"), dev_name);
+ text = g_strdup_printf (_("GSM Connections (%s)"), desc);
else
- text = g_strdup_printf (_("GSM Network (%s)"), dev_name);
- g_free (dev_name);
+ text = g_strdup_printf (_("GSM Network (%s)"), desc);
} else {
if (g_slist_length (connections) > 1)
text = g_strdup (_("GSM Connections"));
@@ -284,7 +285,7 @@
NMApplet *applet)
{
GdkPixbuf *pixbuf = NULL;
- char *iface;
+ const char *iface;
iface = nm_device_get_iface (NM_DEVICE (device));
@@ -303,7 +304,6 @@
break;
}
- g_free (iface);
return pixbuf;
}
Modified: trunk/src/applet-device-wired.c
==============================================================================
--- trunk/src/applet-device-wired.c (original)
+++ trunk/src/applet-device-wired.c Mon Mar 24 15:18:30 2008
@@ -180,21 +180,17 @@
g_slist_free (all);
if (n_devices > 1) {
- const char *desc;
- char *dev_name = NULL;
+ char *desc = NULL;
- desc = utils_get_device_description (device);
- if (desc)
- dev_name = g_strdup (desc);
- if (!dev_name)
- dev_name = nm_device_get_iface (device);
- g_assert (dev_name);
+ desc = (char *) utils_get_device_description (device);
+ if (!desc)
+ desc = (char *) nm_device_get_iface (device);
+ g_assert (desc);
if (g_slist_length (connections) > 1)
- text = g_strdup_printf (_("Wired Networks (%s)"), dev_name);
+ text = g_strdup_printf (_("Wired Networks (%s)"), desc);
else
- text = g_strdup_printf (_("Wired Network (%s)"), dev_name);
- g_free (dev_name);
+ text = g_strdup_printf (_("Wired Network (%s)"), desc);
} else {
if (g_slist_length (connections) > 1)
text = g_strdup (_("Wired Networks"));
@@ -249,7 +245,7 @@
NMApplet *applet)
{
GdkPixbuf *pixbuf = NULL;
- char *iface;
+ const char *iface;
iface = nm_device_get_iface (NM_DEVICE (device));
@@ -271,7 +267,6 @@
break;
}
- g_free (iface);
return pixbuf;
}
Modified: trunk/src/applet-device-wireless.c
==============================================================================
--- trunk/src/applet-device-wireless.c (original)
+++ trunk/src/applet-device-wireless.c Mon Mar 24 15:18:30 2008
@@ -635,10 +635,10 @@
NMDevice80211Wireless *wdev;
char *text;
GtkWidget *item;
- GSList *aps;
- GSList *iter;
+ const GPtrArray *aps;
+ int i;
NMAccessPoint *active_ap = NULL;
- GSList *connections = NULL, *all;
+ GSList *connections = NULL, *all, *sorted_aps = NULL, *iter;
GtkWidget *label;
char *bold_text;
@@ -650,23 +650,19 @@
g_slist_free (all);
if (n_devices > 1) {
- const char *desc;
- char *dev_name = NULL;
+ char *desc;
- desc = utils_get_device_description (device);
- if (desc)
- dev_name = g_strdup (desc);
- if (!dev_name)
- dev_name = nm_device_get_iface (device);
- g_assert (dev_name);
+ desc = (char *) utils_get_device_description (device);
+ if (!desc)
+ desc = (char *) nm_device_get_iface (device);
+ g_assert (desc);
- if (g_slist_length (aps) > 1)
- text = g_strdup_printf (_("Wireless Networks (%s)"), dev_name);
+ if (aps && aps->len > 1)
+ text = g_strdup_printf (_("Wireless Networks (%s)"), desc);
else
- text = g_strdup_printf (_("Wireless Network (%s)"), dev_name);
- g_free (dev_name);
+ text = g_strdup_printf (_("Wireless Network (%s)"), desc);
} else
- text = g_strdup (ngettext ("Wireless Network", "Wireless Networks", g_slist_length (aps)));
+ text = g_strdup (ngettext ("Wireless Network", "Wireless Networks", aps ? aps->len : 0));
item = gtk_menu_item_new_with_mnemonic (text);
g_free (text);
@@ -685,17 +681,19 @@
if (!nm_client_wireless_get_enabled (applet->nm_client))
goto out;
- aps = nm_device_802_11_wireless_get_access_points (wdev);
active_ap = nm_device_802_11_wireless_get_active_access_point (wdev);
/* Add all networks in our network list to the menu */
- aps = g_slist_sort (aps, sort_wireless_networks);
- for (iter = aps; iter; iter = g_slist_next (iter))
+ for (i = 0; aps && (i < aps->len); i++)
+ sorted_aps = g_slist_append (sorted_aps, g_ptr_array_index (aps, i));
+
+ sorted_aps = g_slist_sort (sorted_aps, sort_wireless_networks);
+ for (iter = sorted_aps; iter; iter = g_slist_next (iter))
add_one_ap_menu_item (wdev, NM_ACCESS_POINT (iter->data), connections, active_ap, active, menu, applet);
out:
g_slist_free (connections);
- g_slist_free (aps);
+ g_slist_free (sorted_aps);
}
static gboolean
@@ -889,7 +887,8 @@
wireless_device_added (NMDevice *device, NMApplet *applet)
{
NMDevice80211Wireless *wdev = NM_DEVICE_802_11_WIRELESS (device);
- GSList *aps, *iter;
+ const GPtrArray *aps;
+ int i;
g_signal_connect (wdev,
"notify::" NM_DEVICE_802_11_WIRELESS_ACTIVE_ACCESS_POINT,
@@ -903,11 +902,8 @@
/* Hash all APs this device knows about */
aps = nm_device_802_11_wireless_get_access_points (wdev);
- for (iter = aps; iter; iter = g_slist_next (iter)) {
- NMAccessPoint *ap = NM_ACCESS_POINT (iter->data);
- add_hash_to_ap (ap);
- }
- g_slist_free (aps);
+ for (i = 0; aps && (i < aps->len); i++)
+ add_hash_to_ap (g_ptr_array_index (aps, i));
}
static void
@@ -982,7 +978,7 @@
NMApplet *applet)
{
GdkPixbuf *pixbuf = NULL;
- char *iface;
+ const char *iface;
char *esc_ssid = _("(none)");
iface = nm_device_get_iface (device);
@@ -1037,7 +1033,6 @@
break;
}
- g_free (iface);
return pixbuf;
}
Modified: trunk/src/applet-dialogs.c
==============================================================================
--- trunk/src/applet-dialogs.c (original)
+++ trunk/src/applet-dialogs.c Mon Mar 24 15:18:30 2008
@@ -120,9 +120,9 @@
GtkWidget *label2;
NMIP4Config *cfg;
guint32 speed;
- char *str;
- char *iface_and_type;
- GArray *dns;
+ char *str, *iface_and_type;
+ const char *iface;
+ const GArray *dns;
g_return_val_if_fail (xml != NULL, NULL);
g_return_val_if_fail (device != NULL, NULL);
@@ -145,19 +145,17 @@
speed /= 1000;
}
- str = nm_device_get_iface (device);
+ iface = nm_device_get_iface (device);
if (NM_IS_DEVICE_802_3_ETHERNET (device))
- iface_and_type = g_strdup_printf (_("Ethernet (%s)"), str);
+ iface_and_type = g_strdup_printf (_("Ethernet (%s)"), iface);
else if (NM_IS_DEVICE_802_11_WIRELESS (device))
- iface_and_type = g_strdup_printf (_("802.11 WiFi (%s)"), str);
+ iface_and_type = g_strdup_printf (_("802.11 WiFi (%s)"), iface);
else if (NM_IS_GSM_DEVICE (device))
- iface_and_type = g_strdup_printf (_("GSM (%s)"), str);
+ iface_and_type = g_strdup_printf (_("GSM (%s)"), iface);
else if (NM_IS_CDMA_DEVICE (device))
- iface_and_type = g_strdup_printf (_("CDMA (%s)"), str);
+ iface_and_type = g_strdup_printf (_("CDMA (%s)"), iface);
else
- iface_and_type = g_strdup (str);
-
- g_free (str);
+ iface_and_type = g_strdup (iface);
label = glade_xml_get_widget (xml, "label-interface");
gtk_label_set_text (GTK_LABEL (label), iface_and_type);
@@ -217,10 +215,8 @@
} else
gtk_label_set_text (GTK_LABEL (label), _("Unknown"));
- str = nm_device_get_driver (device);
label = glade_xml_get_widget (xml, "label-driver");
- gtk_label_set_text (GTK_LABEL (label), str);
- g_free (str);
+ gtk_label_set_text (GTK_LABEL (label), nm_device_get_driver (device));
label = glade_xml_get_widget (xml, "label-ip-address");
gtk_label_set_text (GTK_LABEL (label),
@@ -239,7 +235,7 @@
ip4_address_as_string (nm_ip4_config_get_gateway (cfg)));
dns = nm_ip4_config_get_nameservers (cfg);
- if (dns) {
+ if (dns && dns->len) {
label = glade_xml_get_widget (xml, "label-primary-dns");
if (dns->len > 0) {
gtk_label_set_text (GTK_LABEL (label),
@@ -259,7 +255,6 @@
gtk_widget_hide (label);
gtk_widget_hide (label2);
}
- g_array_free (dns, TRUE);
}
return dialog;
@@ -274,7 +269,7 @@
device = applet_get_first_active_device (applet);
if (device)
- connection = applet_find_active_connection_for_device (device, applet);
+ connection = applet_find_active_connection_for_device (device, applet, NULL);
if (!connection || !device) {
info_dialog_show_error (_("No active connections!"));
Modified: trunk/src/applet.c
==============================================================================
--- trunk/src/applet.c (original)
+++ trunk/src/applet.c Mon Mar 24 15:18:30 2008
@@ -50,6 +50,7 @@
#include <nm-setting-connection.h>
#include <nm-setting-vpn.h>
#include <nm-setting-vpn-properties.h>
+#include <nm-active-connection.h>
#include <glade/glade.h>
#include <gconf/gconf-client.h>
@@ -75,19 +76,17 @@
NMDevice *
applet_get_first_active_device (NMApplet *applet)
{
- GSList *iter;
-
- if (g_slist_length (applet->active_connections) == 0)
- return NULL;
-
- for (iter = applet->active_connections; iter; iter = g_slist_next (iter)) {
- GSList *devices;
+ const GPtrArray *connections;
+ int i;
- devices = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_DEVICES);
- if (devices)
- return g_slist_nth_data (devices, 0);
+ connections = nm_client_get_active_connections (applet->nm_client);
+ for (i = 0; connections && (i < connections->len); i++) {
+ const GPtrArray *devices;
+
+ devices = nm_active_connection_get_devices (g_ptr_array_index (connections, i));
+ if (devices && devices->len)
+ return g_ptr_array_index (devices, 0);
}
-
return NULL;
}
@@ -487,41 +486,27 @@
bb_type = G_OBJECT_TYPE (G_OBJECT (bb));
if (aa_type == bb_type) {
- const char *foo;
char *aa_desc = NULL;
char *bb_desc = NULL;
- gint ret;
- foo = utils_get_device_description (aa);
- if (foo)
- aa_desc = g_strdup (foo);
+ aa_desc = (char *) utils_get_device_description (aa);
if (!aa_desc)
- aa_desc = nm_device_get_iface (aa);
+ aa_desc = (char *) nm_device_get_iface (aa);
- foo = utils_get_device_description (bb);
- if (foo)
- bb_desc = g_strdup (foo);
+ bb_desc = (char *) utils_get_device_description (bb);
if (!bb_desc)
- bb_desc = nm_device_get_iface (bb);
+ bb_desc = (char *) nm_device_get_iface (bb);
- if (!aa_desc && bb_desc) {
- g_free (bb_desc);
+ if (!aa_desc && bb_desc)
return -1;
- } else if (aa_desc && !bb_desc) {
- g_free (aa_desc);
+ else if (aa_desc && !bb_desc)
return 1;
- } else if (!aa_desc && !bb_desc) {
+ else if (!aa_desc && !bb_desc)
return 0;
- }
g_assert (aa_desc);
g_assert (bb_desc);
- ret = strcmp (aa_desc, bb_desc);
-
- g_free (aa_desc);
- g_free (bb_desc);
-
- return ret;
+ return strcmp (aa_desc, bb_desc);
}
if (aa_type == NM_TYPE_DEVICE_802_3_ETHERNET && bb_type == NM_TYPE_DEVICE_802_11_WIRELESS)
@@ -542,25 +527,45 @@
return 1;
}
+static gboolean
+nm_g_ptr_array_contains (const GPtrArray *haystack, gpointer needle)
+{
+ int i;
+
+ for (i = 0; haystack && (i < haystack->len); i++) {
+ if (g_ptr_array_index (haystack, i) == needle)
+ return TRUE;
+ }
+ return FALSE;
+}
+
NMConnection *
-applet_find_active_connection_for_device (NMDevice *device, NMApplet *applet)
+applet_find_active_connection_for_device (NMDevice *device,
+ NMApplet *applet,
+ NMActiveConnection **out_active)
{
+ const GPtrArray *active_connections;
NMConnection *connection = NULL;
- GSList *iter;
+ int i;
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
g_return_val_if_fail (NM_IS_APPLET (applet), NULL);
+ if (out_active)
+ g_return_val_if_fail (*out_active == NULL, NULL);
- for (iter = applet->active_connections; iter; iter = g_slist_next (iter)) {
+ active_connections = nm_client_get_active_connections (applet->nm_client);
+ for (i = 0; active_connections && (i < active_connections->len); i++) {
+ NMActiveConnection *active;
const char *service_name;
const char *connection_path;
- GSList *devices;
+ const GPtrArray *devices;
- devices = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_DEVICES);
- service_name = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_SERVICE_NAME);
- connection_path = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_CONNECTION);
+ active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_connections, i));
+ devices = nm_active_connection_get_devices (active);
+ service_name = nm_active_connection_get_service_name (active);
+ connection_path = nm_active_connection_get_connection (active);
- if (!g_slist_find (devices, device))
+ if (!nm_g_ptr_array_contains (devices, device))
continue;
if (!strcmp (service_name, NM_DBUS_SERVICE_SYSTEM_SETTINGS)) {
@@ -571,6 +576,8 @@
tmp = applet_dbus_settings_user_get_by_dbus_path (APPLET_DBUS_SETTINGS (applet->settings), connection_path);
if (tmp) {
connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (tmp));
+ if (out_active)
+ *out_active = active;
break;
}
}
@@ -582,13 +589,15 @@
static guint32
nma_menu_add_devices (GtkWidget *menu, NMApplet *applet)
{
- GSList *devices = NULL;
- GSList *iter;
+ GPtrArray *temp = NULL;
+ GSList *devices = NULL, *iter = NULL;
gint n_wireless_interfaces = 0;
gint n_wired_interfaces = 0;
+ int i;
- devices = nm_client_get_devices (applet->nm_client);
-
+ temp = nm_client_get_devices (applet->nm_client);
+ for (i = 0; temp && (i < temp->len); i++)
+ devices = g_slist_append (devices, g_ptr_array_index (temp, i));
if (devices)
devices = g_slist_sort (devices, sort_devices);
@@ -627,7 +636,7 @@
else if (NM_IS_DEVICE_802_3_ETHERNET (device))
n_devices = n_wired_interfaces++;
- active = applet_find_active_connection_for_device (device, applet);
+ active = applet_find_active_connection_for_device (device, applet, NULL);
dclass = get_device_class (device, applet);
if (dclass)
@@ -782,7 +791,7 @@
gtk_status_icon_set_tooltip (applet->status_icon, NULL);
- if (!nm_client_manager_is_running (applet->nm_client)) {
+ if (!nm_client_get_manager_running (applet->nm_client)) {
nma_menu_add_text_item (menu, _("NetworkManager is not running..."));
return;
}
@@ -869,17 +878,16 @@
state == NM_STATE_CONNECTED);
if (state != NM_STATE_ASLEEP) {
- GSList *list;
- GSList *iter;
-
- list = nm_client_get_devices (applet->nm_client);
- for (iter = list; iter; iter = iter->next) {
- if (NM_IS_DEVICE_802_11_WIRELESS (iter->data)) {
+ GPtrArray *devices;
+ int i;
+
+ devices = nm_client_get_devices (applet->nm_client);
+ for (i = 0; devices && (i < devices->len); i++) {
+ if (NM_IS_DEVICE_802_11_WIRELESS (g_ptr_array_index (devices, i))) {
have_wireless = TRUE;
break;
}
}
- g_slist_free (list);
}
if (have_wireless)
@@ -1043,22 +1051,26 @@
AppletExportedConnection *
applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
{
- GSList *iter;
+ const GPtrArray *active_connections;
+ int i;
- for (iter = applet->active_connections; iter; iter = g_slist_next (iter)) {
+ active_connections = nm_client_get_active_connections (applet->nm_client);
+ for (i = 0; active_connections && (i < active_connections->len); i++) {
+ NMActiveConnection *active;
AppletExportedConnection *exported;
const char *service_name;
const char *connection_path;
- GSList *devices;
+ const GPtrArray *devices;
- devices = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_DEVICES);
- service_name = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_SERVICE_NAME);
- connection_path = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_CONNECTION);
+ active = g_ptr_array_index (active_connections, i);
+ devices = nm_active_connection_get_devices (active);
+ service_name = nm_active_connection_get_service_name (active);
+ connection_path = nm_active_connection_get_connection (active);
if (strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS) != 0)
continue;
- if (!g_slist_find (devices, device))
+ if (!nm_g_ptr_array_contains (devices, device))
continue;
exported = applet_dbus_settings_user_get_by_dbus_path (applet->settings, connection_path);
@@ -1095,27 +1107,16 @@
}
static void
-clear_active_connections (NMApplet *applet)
-{
- g_slist_foreach (applet->active_connections,
- (GFunc) nm_client_free_active_connections_element,
- NULL);
- g_slist_free (applet->active_connections);
- applet->active_connections = NULL;
-}
-
-static void
-foo_device_state_changed_cb (NMDevice *device, NMDeviceState state, gpointer user_data)
+foo_device_state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
{
NMApplet *applet = NM_APPLET (user_data);
NMADeviceClass *dclass;
-
- clear_active_connections (applet);
- applet->active_connections = nm_client_get_active_connections (applet->nm_client);
+ NMDeviceState state;
dclass = get_device_class (device, applet);
g_assert (dclass);
+ state = nm_device_get_state (device);
dclass->device_state_changed (device, state, applet);
applet_common_device_state_change (device, state, applet);
@@ -1134,19 +1135,19 @@
if (dclass->device_added)
dclass->device_added (device, applet);
- g_signal_connect (device, "state-changed",
+ g_signal_connect (device, "notify::state",
G_CALLBACK (foo_device_state_changed_cb),
user_data);
- foo_device_state_changed_cb (device, nm_device_get_state (device), applet);
+ foo_device_state_changed_cb (device, NULL, applet);
}
static void
-foo_client_state_change_cb (NMClient *client, NMState state, gpointer user_data)
+foo_client_state_change_cb (NMClient *client, GParamSpec *pspec, gpointer user_data)
{
NMApplet *applet = NM_APPLET (user_data);
- switch (state) {
+ switch (nm_client_get_state (client)) {
case NM_STATE_DISCONNECTED:
applet_do_notify (applet, NOTIFY_URGENCY_NORMAL, _("Disconnected"),
_("The network connection has been disconnected."),
@@ -1156,7 +1157,6 @@
/* Clear any VPN connections */
if (applet->vpn_connections)
g_hash_table_remove_all (applet->vpn_connections);
- clear_active_connections (applet);
break;
default:
break;
@@ -1167,19 +1167,18 @@
static void
foo_manager_running_cb (NMClient *client,
- gboolean running,
+ GParamSpec *pspec,
gpointer user_data)
{
NMApplet *applet = NM_APPLET (user_data);
- if (running) {
+ if (nm_client_get_manager_running (client)) {
g_message ("NM appeared");
} else {
g_message ("NM disappeared");
clear_animation_timeout (applet);
}
- applet->nm_running = running;
applet_schedule_update_icon (applet);
}
@@ -1187,12 +1186,13 @@
foo_set_initial_state (gpointer data)
{
NMApplet *applet = NM_APPLET (data);
- GSList *list, *iter;
+ GSList *list;
+ const GPtrArray *devices;
+ int i;
- list = nm_client_get_devices (applet->nm_client);
- for (iter = list; iter; iter = g_slist_next (iter))
- foo_device_added_cb (applet->nm_client, NM_DEVICE (iter->data), applet);
- g_slist_free (list);
+ devices = nm_client_get_devices (applet->nm_client);
+ for (i = 0; devices && (i < devices->len); i++)
+ foo_device_added_cb (applet->nm_client, NM_DEVICE (g_ptr_array_index (devices, i)), applet);
list = nm_vpn_manager_get_connections (applet->vpn_manager);
if (list) {
@@ -1212,18 +1212,17 @@
if (!applet->nm_client)
return;
- g_signal_connect (applet->nm_client, "state-changed",
+ g_signal_connect (applet->nm_client, "notify::state",
G_CALLBACK (foo_client_state_change_cb),
applet);
g_signal_connect (applet->nm_client, "device-added",
G_CALLBACK (foo_device_added_cb),
applet);
- g_signal_connect (applet->nm_client, "manager-running",
+ g_signal_connect (applet->nm_client, "notify::manager-running",
G_CALLBACK (foo_manager_running_cb),
applet);
- applet->nm_running = nm_client_manager_is_running (applet->nm_client);
- if (applet->nm_running)
+ if (nm_client_get_manager_running (applet->nm_client))
g_idle_add (foo_set_initial_state, applet);
}
@@ -1328,15 +1327,17 @@
char *tip = NULL;
NMVPNConnection *vpn_connection;
NMVPNConnectionState vpn_state = NM_VPN_SERVICE_STATE_UNKNOWN;
+ gboolean nm_running;
applet->update_icon_id = 0;
- gtk_status_icon_set_visible (applet->status_icon, applet->nm_running);
+ nm_running = nm_client_get_manager_running (applet->nm_client);
+ gtk_status_icon_set_visible (applet->status_icon, nm_running);
/* Handle device state first */
state = nm_client_get_state (applet->nm_client);
- if (!applet->nm_running)
+ if (!nm_running)
state = NM_STATE_UNKNOWN;
switch (state) {
@@ -1397,37 +1398,37 @@
NMApplet *applet,
const char **out_specific_object)
{
- GSList *iter;
+ const GPtrArray *active_connections;
+ int i;
g_return_val_if_fail (exported != NULL, NULL);
g_return_val_if_fail (applet != NULL, NULL);
- /* Ensure the active connection list is up-to-date */
- if (g_slist_length (applet->active_connections) == 0)
- applet->active_connections = nm_client_get_active_connections (applet->nm_client);
-
/* Look through the active connection list trying to find the D-Bus
* object path of applet_connection.
*/
- for (iter = applet->active_connections; iter; iter = g_slist_next (iter)) {
+ active_connections = nm_client_get_active_connections (applet->nm_client);
+ for (i = 0; active_connections && (i < active_connections->len); i++) {
+ NMActiveConnection *active;
NMConnection *connection;
const char *service_name;
const char *connection_path;
const char *specific_object;
- GSList *devices;
-
- devices = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_DEVICES);
- service_name = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_SERVICE_NAME);
- connection_path = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_CONNECTION);
- specific_object = g_hash_table_lookup ((GHashTable *) iter->data, NM_AC_KEY_SPECIFIC_OBJECT);
+ const GPtrArray *devices;
+ active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_connections, i));
+ service_name = nm_active_connection_get_service_name (active);
if (strcmp (service_name, NM_DBUS_SERVICE_USER_SETTINGS))
continue;
+ connection_path = nm_active_connection_get_connection (active);
+ specific_object = nm_active_connection_get_specific_object (active);
+
connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (exported));
if (!strcmp (connection_path, nm_connection_get_path (connection))) {
+ devices = nm_active_connection_get_devices (active);
*out_specific_object = specific_object;
- return NM_DEVICE (g_slist_nth_data (devices, 0));
+ return devices ? NM_DEVICE (g_ptr_array_index (devices, 0)) : NULL;
}
}
@@ -1762,8 +1763,6 @@
goto error;
nma_icons_init (applet);
- applet->active_connections = NULL;
-
dbus_mgr = applet_dbus_manager_get ();
if (dbus_mgr == NULL) {
nm_warning ("Couldn't initialize the D-Bus manager.");
@@ -1840,8 +1839,6 @@
g_object_unref (applet->vpn_manager);
g_object_unref (applet->nm_client);
- clear_active_connections (applet);
-
crypto_deinit ();
G_OBJECT_CLASS (nma_parent_class)->finalize (object);
Modified: trunk/src/applet.h
==============================================================================
--- trunk/src/applet.h (original)
+++ trunk/src/applet.h Mon Mar 24 15:18:30 2008
@@ -46,6 +46,7 @@
#include <nm-vpn-manager.h>
#include <nm-device.h>
#include <NetworkManager.h>
+#include <nm-active-connection.h>
#include "applet-dbus-manager.h"
#include "applet-dbus-settings.h"
@@ -90,7 +91,6 @@
GHashTable *vpn_connections;
AppletDbusSettings *settings;
- GSList * active_connections;
GConfClient * gconf_client;
char * glade_file;
@@ -103,7 +103,6 @@
/* Data model elements */
guint update_icon_id;
- gboolean nm_running;
gboolean icons_loaded;
GtkIconTheme * icon_theme;
@@ -186,6 +185,8 @@
const char *message,
const char *icon);
-NMConnection * applet_find_active_connection_for_device (NMDevice *device, NMApplet *applet);
+NMConnection * applet_find_active_connection_for_device (NMDevice *device,
+ NMApplet *applet,
+ NMActiveConnection **out_active);
#endif
Modified: trunk/src/gconf-helpers/Makefile.am
==============================================================================
--- trunk/src/gconf-helpers/Makefile.am (original)
+++ trunk/src/gconf-helpers/Makefile.am Mon Mar 24 15:18:30 2008
@@ -6,7 +6,9 @@
gconf-upgrade.h \
gconf-upgrade.c
-libgconf_helpers_la_CPPFLAGS = $(NMA_CFLAGS)
+libgconf_helpers_la_CPPFLAGS = \
+ $(NMA_CFLAGS) \
+ -I${top_srcdir}/src
libgconf_helpers_la_LIBADD = $(NMA_LIBS)
Modified: trunk/src/utils/Makefile.am
==============================================================================
--- trunk/src/utils/Makefile.am (original)
+++ trunk/src/utils/Makefile.am Mon Mar 24 15:18:30 2008
@@ -10,7 +10,8 @@
libutils_la_CPPFLAGS = \
$(NMA_CFLAGS) \
- -I${top_srcdir}/src/gconf-helpers
+ -I${top_srcdir}/src/gconf-helpers \
+ -I${top_srcdir}/src
libutils_la_LIBADD = $(NMA_LIBS)
Modified: trunk/src/wireless-dialog.c
==============================================================================
--- trunk/src/wireless-dialog.c (original)
+++ trunk/src/wireless-dialog.c Mon Mar 24 15:18:30 2008
@@ -277,27 +277,24 @@
GtkTreeIter *iter,
NMDevice *device)
{
- const char *desc;
- char *name = NULL;
+ char *desc;
- desc = utils_get_device_description (device);
- if (desc)
- name = g_strdup (desc);
- if (!name)
- name = nm_device_get_iface (device);
+ desc = (char *) utils_get_device_description (device);
+ if (!desc)
+ desc = (char *) nm_device_get_iface (device);
+ g_assert (desc);
gtk_list_store_append (model, iter);
- gtk_list_store_set (model, iter, D_NAME_COLUMN, name, D_DEV_COLUMN, device, -1);
- g_free (name);
+ gtk_list_store_set (model, iter, D_NAME_COLUMN, g_strdup (desc), D_DEV_COLUMN, device, -1);
}
static GtkTreeModel *
create_device_model (NMClient *client, NMDevice *use_this_device, guint32 *num)
{
GtkListStore *model;
- GSList *devices;
- GSList *iter;
+ const GPtrArray *devices;
GtkTreeIter tree_iter;
+ int i;
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (num != NULL, NULL);
@@ -310,8 +307,8 @@
*num = 1;
} else {
devices = nm_client_get_devices (client);
- for (iter = devices; iter; iter = g_slist_next (iter)) {
- NMDevice *dev = (NMDevice *) iter->data;
+ for (i = 0; devices && (i < devices->len); i++) {
+ NMDevice *dev = NM_DEVICE (g_ptr_array_index (devices, i));
/* Ignore unsupported devices */
if (!(nm_device_get_capabilities (dev) & NM_DEVICE_CAP_NM_SUPPORTED))
@@ -323,7 +320,6 @@
add_device_to_model (model, &tree_iter, dev);
*num += 1;
}
- g_slist_free (devices);
}
return GTK_TREE_MODEL (model);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]