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()



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3502 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-03-25 12:41:17 +00:00
parent 9a163be59a
commit 56010ad03a
7 changed files with 170 additions and 47 deletions

View file

@ -1,3 +1,33 @@
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()
2008-03-25 Dan Williams <dcbw@redhat.com>
* libnm-glib/nm-object.c

View file

@ -306,7 +306,7 @@ demarshal_ssid (NMObject *object, GParamSpec *pspec, GValue *value, gpointer fie
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;
}

View file

@ -252,7 +252,7 @@ demarshal_devices (NMObject *object, GParamSpec *pspec, GValue *value, gpointer
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;
}

View file

@ -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))
@ -74,28 +77,58 @@ nm_client_init (NMClient *client)
priv->state = NM_STATE_UNKNOWN;
}
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 @@ demarshal_active_connections (NMObject *object,
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 @@ constructor (GType type,
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 @@ set_property (GObject *object, guint prop_id,
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 @@ proxy_name_owner_changed (DBusGProxy *proxy,
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);
}
}

View file

@ -19,6 +19,8 @@ G_DEFINE_TYPE (NMDevice80211Wireless, nm_device_802_11_wireless, NM_TYPE_DEVICE)
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 @@ typedef struct {
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 @@ nm_device_802_11_wireless_get_active_access_point (NMDevice80211Wireless *self)
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 @@ access_point_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
}
}
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 @@ state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data)
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 @@ demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointe
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 @@ demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointe
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 @@ dispose (GObject *object)
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);

View file

@ -25,6 +25,7 @@ typedef struct {
char *driver;
guint32 capabilities;
NMIP4Config *ip4_config;
gboolean null_ip4_config;
NMDeviceState state;
char *product;
char *vendor;
@ -65,14 +66,20 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
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 @@ demarshal_ip4_config (NMObject *object, GParamSpec *pspec, GValue *value, gpoint
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 @@ nm_device_get_ip4_config (NMDevice *device)
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 @@ nm_device_update_description (NMDevice *device)
}
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 *

View file

@ -50,9 +50,9 @@ demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointe
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 @@ demarshal_domains (NMObject *object, GParamSpec *pspec, GValue *value, gpointer
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;
}