NetworkManager r3502 - in trunk: . libnm-glib
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3502 - in trunk: . libnm-glib
- Date: Tue, 25 Mar 2008 12:41:18 +0000 (GMT)
Author: dcbw
Date: Tue Mar 25 12:41:17 2008
New Revision: 3502
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3502&view=rev
Log:
2008-03-25 Dan Williams <dcbw redhat com>
* libnm-glib/nm-ip4-config.c
libnm-glib/nm-active-connection.c
libnm-glib/nm-access-point.c
- Use nm_object_queue_notify() instead of g_object_notify()
* libnm-glib/nm-device.c
- (demarshal_ip4_config): distinguish between successful but missing
ip4-config request, and unsuccessful and missing ip4-config request
- (nm_device_get_ip4_config): don't try to demarshal a NULL ip4-config
path
- Use nm_object_queue_notify() instead of g_object_notify()
* libnm-glib/nm-device-802-11-wireless.c
- (demarshal_active_ap): distinguish between successfull but missing
active-ap request, and unsuccessful and missing active-ap request
- (dispose, clean_up_aps): consolidate AP list and active AP clearing
code
- (nm_device_802_11_wireless_set_wireless_enabled): add a private hook
for the NMClient to notify the device that wireless is disabled,
and therefore to clear the AP list and active AP
- Use nm_object_queue_notify() instead of g_object_notify()
* libnm-glib/nm-client.c
- (poke_wireless_devices_with_rf_status): new function
- (update_wireless_status): notify wireless devices of the rfkill status
so they can clean up if needed
- Use nm_object_queue_notify() instead of g_object_notify()
Modified:
trunk/ChangeLog
trunk/libnm-glib/nm-access-point.c
trunk/libnm-glib/nm-active-connection.c
trunk/libnm-glib/nm-client.c
trunk/libnm-glib/nm-device-802-11-wireless.c
trunk/libnm-glib/nm-device.c
trunk/libnm-glib/nm-ip4-config.c
Modified: trunk/libnm-glib/nm-access-point.c
==============================================================================
--- trunk/libnm-glib/nm-access-point.c (original)
+++ trunk/libnm-glib/nm-access-point.c Tue Mar 25 12:41:17 2008
@@ -306,7 +306,7 @@
if (!nm_ssid_demarshal (value, (GByteArray **) field))
return FALSE;
- g_object_notify (G_OBJECT (object), NM_ACCESS_POINT_SSID);
+ nm_object_queue_notify (object, NM_ACCESS_POINT_SSID);
return TRUE;
}
Modified: trunk/libnm-glib/nm-active-connection.c
==============================================================================
--- trunk/libnm-glib/nm-active-connection.c (original)
+++ trunk/libnm-glib/nm-active-connection.c Tue Mar 25 12:41:17 2008
@@ -252,7 +252,7 @@
if (!nm_object_array_demarshal (value, (GPtrArray **) field, connection, nm_device_new))
return FALSE;
- g_object_notify (G_OBJECT (object), NM_ACTIVE_CONNECTION_DEVICES);
+ nm_object_queue_notify (object, NM_ACTIVE_CONNECTION_DEVICES);
return TRUE;
}
Modified: trunk/libnm-glib/nm-client.c
==============================================================================
--- trunk/libnm-glib/nm-client.c (original)
+++ trunk/libnm-glib/nm-client.c Tue Mar 25 12:41:17 2008
@@ -19,6 +19,9 @@
#include "nm-client-bindings.h"
+void nm_device_802_11_wireless_set_wireless_enabled (NMDevice80211Wireless *device, gboolean enabled);
+
+
G_DEFINE_TYPE (NMClient, nm_client, NM_TYPE_OBJECT)
#define NM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_CLIENT, NMClientPrivate))
@@ -75,27 +78,57 @@
}
static void
+poke_wireless_devices_with_rf_status (NMClient *client)
+{
+ NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
+ int i;
+
+ for (i = 0; priv->devices && (i < priv->devices->len); i++) {
+ NMDevice *device = g_ptr_array_index (priv->devices, i);
+
+ if (NM_IS_DEVICE_802_11_WIRELESS (device))
+ nm_device_802_11_wireless_set_wireless_enabled (NM_DEVICE_802_11_WIRELESS (device), priv->wireless_enabled);
+ }
+}
+
+static void
update_wireless_status (NMClient *client, gboolean notify)
{
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
gboolean val;
+ gboolean poke = FALSE;
val = nm_object_get_boolean_property (NM_OBJECT (client),
NM_DBUS_INTERFACE,
"WirelessHardwareEnabled");
if (val != priv->wireless_hw_enabled) {
priv->wireless_hw_enabled = val;
- g_object_notify (G_OBJECT (client), NM_CLIENT_WIRELESS_HARDWARE_ENABLED);
+ poke = TRUE;
+ if (notify)
+ nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_WIRELESS_HARDWARE_ENABLED);
}
- val = priv->wireless_hw_enabled ? TRUE :
- nm_object_get_boolean_property (NM_OBJECT (client),
- NM_DBUS_INTERFACE,
- "WirelessEnabled");
+ if (priv->wireless_hw_enabled == FALSE)
+ val = FALSE;
+ else
+ val = nm_object_get_boolean_property (NM_OBJECT (client),
+ NM_DBUS_INTERFACE,
+ "WirelessEnabled");
if (val != priv->wireless_enabled) {
priv->wireless_enabled = val;
- g_object_notify (G_OBJECT (client), NM_CLIENT_WIRELESS_ENABLED);
+ poke = TRUE;
+ if (notify)
+ nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_WIRELESS_ENABLED);
}
+
+ if (poke)
+ poke_wireless_devices_with_rf_status (client);
+}
+
+static void
+wireless_enabled_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
+{
+ poke_wireless_devices_with_rf_status (NM_CLIENT (object));
}
static gboolean
@@ -110,7 +143,7 @@
if (!nm_object_array_demarshal (value, (GPtrArray **) field, connection, nm_active_connection_new))
return FALSE;
- g_object_notify (G_OBJECT (object), NM_CLIENT_ACTIVE_CONNECTIONS);
+ nm_object_queue_notify (object, NM_CLIENT_ACTIVE_CONNECTIONS);
return TRUE;
}
@@ -197,6 +230,9 @@
g_error_free (err);
}
+ g_signal_connect (G_OBJECT (object), "notify::" NM_CLIENT_WIRELESS_ENABLED,
+ G_CALLBACK (wireless_enabled_cb), NULL);
+
return G_OBJECT (object);
}
@@ -243,14 +279,14 @@
b = g_value_get_boolean (value);
if (priv->wireless_enabled != b) {
priv->wireless_enabled = b;
- g_object_notify (object, NM_CLIENT_WIRELESS_ENABLED);
+ nm_object_queue_notify (NM_OBJECT (object), NM_CLIENT_WIRELESS_ENABLED);
}
break;
case PROP_WIRELESS_HARDWARE_ENABLED:
b = g_value_get_boolean (value);
if (priv->wireless_hw_enabled != b) {
priv->wireless_hw_enabled = b;
- g_object_notify (object, NM_CLIENT_WIRELESS_HARDWARE_ENABLED);
+ nm_object_queue_notify (NM_OBJECT (object), NM_CLIENT_WIRELESS_HARDWARE_ENABLED);
}
break;
default:
@@ -412,12 +448,13 @@
priv->manager_running = new_running;
if (!priv->manager_running) {
priv->state = NM_STATE_UNKNOWN;
- g_object_notify (G_OBJECT (client), NM_CLIENT_MANAGER_RUNNING);
+ nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING);
free_device_list (client);
priv->wireless_enabled = FALSE;
priv->wireless_hw_enabled = FALSE;
+ poke_wireless_devices_with_rf_status (client);
} else {
- g_object_notify (G_OBJECT (client), NM_CLIENT_MANAGER_RUNNING);
+ nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING);
update_wireless_status (client, TRUE);
}
}
Modified: trunk/libnm-glib/nm-device-802-11-wireless.c
==============================================================================
--- trunk/libnm-glib/nm-device-802-11-wireless.c (original)
+++ trunk/libnm-glib/nm-device-802-11-wireless.c Tue Mar 25 12:41:17 2008
@@ -19,6 +19,8 @@
static gboolean demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field);
+void nm_device_802_11_wireless_set_wireless_enabled (NMDevice80211Wireless *device, gboolean enabled);
+
typedef struct {
gboolean disposed;
DBusGProxy *proxy;
@@ -27,8 +29,11 @@
int mode;
guint32 rate;
NMAccessPoint *active_ap;
+ gboolean null_active_ap;
guint32 wireless_caps;
GPtrArray *aps;
+
+ gboolean wireless_enabled;
} NMDevice80211WirelessPrivate;
enum {
@@ -177,6 +182,8 @@
priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
if (priv->active_ap)
return priv->active_ap;
+ if (priv->null_active_ap)
+ return NULL;
path = nm_object_get_object_path_property (NM_OBJECT (self),
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
@@ -276,6 +283,44 @@
}
}
+static void
+clean_up_aps (NMDevice80211Wireless *self, gboolean notify)
+{
+ NMDevice80211WirelessPrivate *priv;
+
+ g_return_if_fail (NM_IS_DEVICE_802_11_WIRELESS (self));
+
+ priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
+
+ if (priv->active_ap)
+ g_object_unref (priv->active_ap);
+
+ if (priv->aps) {
+ while (priv->aps->len) {
+ NMAccessPoint *ap = NM_ACCESS_POINT (g_ptr_array_index (priv->aps, 0));
+
+ if (notify)
+ g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap);
+ g_ptr_array_remove (priv->aps, ap);
+ g_object_unref (ap);
+ }
+ g_ptr_array_foreach (priv->aps, (GFunc) g_object_unref, NULL);
+ g_ptr_array_free (priv->aps, TRUE);
+ priv->aps = NULL;
+ }
+}
+
+void
+nm_device_802_11_wireless_set_wireless_enabled (NMDevice80211Wireless *device,
+ gboolean enabled)
+{
+ g_return_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device));
+
+ if (!enabled)
+ clean_up_aps (device, TRUE);
+}
+
+
/**************************************************************/
static void
@@ -335,13 +380,15 @@
case NM_DEVICE_STATE_FAILED:
case NM_DEVICE_STATE_CANCELLED:
default:
+ /* Just clear active AP; don't clear the AP list unless wireless is disabled completely */
if (priv->active_ap) {
g_object_unref (priv->active_ap);
priv->active_ap = NULL;
+ priv->null_active_ap = FALSE;
}
- g_object_notify (G_OBJECT (device), NM_DEVICE_802_11_WIRELESS_ACTIVE_ACCESS_POINT);
+ nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_802_11_WIRELESS_ACTIVE_ACCESS_POINT);
priv->rate = 0;
- g_object_notify (G_OBJECT (device), NM_DEVICE_802_11_WIRELESS_BITRATE);
+ nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_802_11_WIRELESS_BITRATE);
break;
}
}
@@ -357,14 +404,20 @@
if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
return FALSE;
+ priv->null_active_ap = FALSE;
+
path = g_value_get_boxed (value);
- if (path && strcmp (path, "/")) {
- ap = NM_ACCESS_POINT (nm_object_cache_get (path));
- if (ap)
- ap = g_object_ref (ap);
+ if (path) {
+ if (!strcmp (path, "/"))
+ priv->null_active_ap = TRUE;
else {
- connection = nm_object_get_connection (object);
- ap = NM_ACCESS_POINT (nm_access_point_new (connection, path));
+ ap = NM_ACCESS_POINT (nm_object_cache_get (path));
+ if (ap)
+ ap = g_object_ref (ap);
+ else {
+ connection = nm_object_get_connection (object);
+ ap = NM_ACCESS_POINT (nm_access_point_new (connection, path));
+ }
}
}
@@ -376,7 +429,7 @@
if (ap)
priv->active_ap = ap;
- g_object_notify (G_OBJECT (object), NM_DEVICE_802_11_WIRELESS_ACTIVE_ACCESS_POINT);
+ nm_object_queue_notify (object, NM_DEVICE_802_11_WIRELESS_ACTIVE_ACCESS_POINT);
return TRUE;
}
@@ -455,15 +508,7 @@
priv->disposed = TRUE;
- if (priv->active_ap)
- g_object_unref (priv->active_ap);
-
- if (priv->aps) {
- g_ptr_array_foreach (priv->aps, (GFunc) g_object_unref, NULL);
- g_ptr_array_free (priv->aps, TRUE);
- priv->aps = NULL;
- }
-
+ clean_up_aps (NM_DEVICE_802_11_WIRELESS (object), FALSE);
g_object_unref (priv->proxy);
G_OBJECT_CLASS (nm_device_802_11_wireless_parent_class)->dispose (object);
Modified: trunk/libnm-glib/nm-device.c
==============================================================================
--- trunk/libnm-glib/nm-device.c (original)
+++ trunk/libnm-glib/nm-device.c Tue Mar 25 12:41:17 2008
@@ -25,6 +25,7 @@
char *driver;
guint32 capabilities;
NMIP4Config *ip4_config;
+ gboolean null_ip4_config;
NMDeviceState state;
char *product;
char *vendor;
@@ -65,14 +66,20 @@
if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH))
return FALSE;
+ priv->null_ip4_config = FALSE;
+
path = g_value_get_boxed (value);
- if (strcmp (path, "/")) {
- config = NM_IP4_CONFIG (nm_object_cache_get (path));
- if (config)
- config = g_object_ref (config);
+ if (path) {
+ if (!strcmp (path, "/"))
+ priv->null_ip4_config = TRUE;
else {
- connection = nm_object_get_connection (object);
- config = NM_IP4_CONFIG (nm_ip4_config_new (connection, path));
+ config = NM_IP4_CONFIG (nm_object_cache_get (path));
+ if (config)
+ config = g_object_ref (config);
+ else {
+ connection = nm_object_get_connection (object);
+ config = NM_IP4_CONFIG (nm_ip4_config_new (connection, path));
+ }
}
}
@@ -84,7 +91,7 @@
if (config)
priv->ip4_config = config;
- g_object_notify (G_OBJECT (object), NM_DEVICE_IP4_CONFIG);
+ nm_object_queue_notify (object, NM_DEVICE_IP4_CONFIG);
return TRUE;
}
@@ -426,13 +433,17 @@
priv = NM_DEVICE_GET_PRIVATE (device);
if (priv->ip4_config)
return priv->ip4_config;
+ if (priv->null_ip4_config)
+ return NULL;
path = nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE, "Ip4Config");
+ if (path) {
+ g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
+ g_value_take_boxed (&value, path);
+ demarshal_ip4_config (NM_OBJECT (device), NULL, &value, &priv->ip4_config);
+ g_value_unset (&value);
+ }
- g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH);
- g_value_take_boxed (&value, path);
- demarshal_ip4_config (NM_OBJECT (device), NULL, &value, &priv->ip4_config);
- g_value_unset (&value);
return priv->ip4_config;
}
@@ -593,8 +604,8 @@
}
g_free (pd_parent_udi);
- g_object_notify (G_OBJECT (device), NM_DEVICE_VENDOR);
- g_object_notify (G_OBJECT (device), NM_DEVICE_PRODUCT);
+ nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_VENDOR);
+ nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_PRODUCT);
}
const char *
Modified: trunk/libnm-glib/nm-ip4-config.c
==============================================================================
--- trunk/libnm-glib/nm-ip4-config.c (original)
+++ trunk/libnm-glib/nm-ip4-config.c Tue Mar 25 12:41:17 2008
@@ -50,9 +50,9 @@
return FALSE;
if (!strcmp (pspec->name, NM_IP4_CONFIG_NAMESERVERS))
- g_object_notify (G_OBJECT (object), NM_IP4_CONFIG_NAMESERVERS);
+ nm_object_queue_notify (object, NM_IP4_CONFIG_NAMESERVERS);
else if (!strcmp (pspec->name, NM_IP4_CONFIG_NIS_SERVERS))
- g_object_notify (G_OBJECT (object), NM_IP4_CONFIG_NAMESERVERS);
+ nm_object_queue_notify (object, NM_IP4_CONFIG_NAMESERVERS);
return TRUE;
}
@@ -62,7 +62,7 @@
if (!nm_string_array_demarshal (value, (GPtrArray **) field))
return FALSE;
- g_object_notify (G_OBJECT (object), NM_IP4_CONFIG_DOMAINS);
+ nm_object_queue_notify (object, NM_IP4_CONFIG_DOMAINS);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]