mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-23 11:14:29 +00:00
2008-03-27 Dan Williams <dcbw@redhat.com>
* nm-object.c - (nm_object_queue_notify): don't notify multiple times for the same property * nm-object-private.h - (handle_ptr_array_return): return NULL if the given array is NULL or if it has zero elements * nm-ip4-config.c - (finalize): use g_ptr_array_foreach() when freeing domains - (nm_ip4_config_get_domains): use handle_ptr_array_return() * nm-active-connection.c - (nm_active_connection_get_devices): use handle_ptr_array_return() * nm-device-802-11-wireless.c nm-device-802-11-wireless.h - (nm_device_802_11_wireless_get_access_points): return const; use handle_ptr_array_return() * nm-types.c - (nm_object_array_demarshal): always create an array, even of length zero, to distinguish between "NM returned no items" and "haven't asked NM yet" * nm-client.c - (dispose): free active connections too - (proxy_name_owner_changed): free active connections too when NM goes away - (nm_client_get_devices): return const; use handle_ptr_array_return() - (nm_client_get_active_connections): use handle_ptr_array_return() git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3506 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
ec89663e7d
commit
c01b4c9e2e
34
ChangeLog
34
ChangeLog
|
@ -1,3 +1,37 @@
|
|||
2008-03-27 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* nm-object.c
|
||||
- (nm_object_queue_notify): don't notify multiple times for the same
|
||||
property
|
||||
|
||||
* nm-object-private.h
|
||||
- (handle_ptr_array_return): return NULL if the given array is NULL or
|
||||
if it has zero elements
|
||||
|
||||
* nm-ip4-config.c
|
||||
- (finalize): use g_ptr_array_foreach() when freeing domains
|
||||
- (nm_ip4_config_get_domains): use handle_ptr_array_return()
|
||||
|
||||
* nm-active-connection.c
|
||||
- (nm_active_connection_get_devices): use handle_ptr_array_return()
|
||||
|
||||
* nm-device-802-11-wireless.c
|
||||
nm-device-802-11-wireless.h
|
||||
- (nm_device_802_11_wireless_get_access_points): return const; use
|
||||
handle_ptr_array_return()
|
||||
|
||||
* nm-types.c
|
||||
- (nm_object_array_demarshal): always create an array, even of length
|
||||
zero, to distinguish between "NM returned no items" and "haven't
|
||||
asked NM yet"
|
||||
|
||||
* nm-client.c
|
||||
- (dispose): free active connections too
|
||||
- (proxy_name_owner_changed): free active connections too when NM goes
|
||||
away
|
||||
- (nm_client_get_devices): return const; use handle_ptr_array_return()
|
||||
- (nm_client_get_active_connections): use handle_ptr_array_return()
|
||||
|
||||
2008-03-26 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Rework VPN connection handling for a more consistent D-Bus API. The
|
||||
|
|
|
@ -138,7 +138,7 @@ static void
|
|||
dump_wireless (NMDevice80211Wireless *device)
|
||||
{
|
||||
const char *str;
|
||||
GPtrArray *aps;
|
||||
const GPtrArray *aps;
|
||||
int i;
|
||||
|
||||
g_print ("Mode: %d\n", nm_device_802_11_wireless_get_mode (device));
|
||||
|
@ -202,7 +202,7 @@ dump_device (NMDevice *device)
|
|||
static gboolean
|
||||
test_devices (NMClient *client)
|
||||
{
|
||||
GPtrArray *devices;
|
||||
const GPtrArray *devices;
|
||||
int i;
|
||||
|
||||
devices = nm_client_get_devices (client);
|
||||
|
|
|
@ -179,7 +179,7 @@ nm_active_connection_get_devices (NMActiveConnection *connection)
|
|||
|
||||
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (connection);
|
||||
if (priv->devices)
|
||||
return priv->devices;
|
||||
return handle_ptr_array_return (priv->devices);
|
||||
|
||||
if (!nm_object_get_property (NM_OBJECT (connection),
|
||||
NM_DBUS_INTERFACE,
|
||||
|
@ -191,7 +191,7 @@ nm_active_connection_get_devices (NMActiveConnection *connection)
|
|||
demarshal_devices (NM_OBJECT (connection), NULL, &value, &priv->devices);
|
||||
g_value_unset (&value);
|
||||
|
||||
return priv->devices;
|
||||
return handle_ptr_array_return (priv->devices);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -278,16 +278,15 @@ constructor (GType type,
|
|||
}
|
||||
|
||||
static void
|
||||
free_device_list (NMClient *client)
|
||||
free_object_array (GPtrArray **array)
|
||||
{
|
||||
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
|
||||
g_return_if_fail (array != NULL);
|
||||
|
||||
if (!priv->devices)
|
||||
return;
|
||||
|
||||
g_ptr_array_foreach (priv->devices, (GFunc) g_object_unref, NULL);
|
||||
g_ptr_array_free (priv->devices, TRUE);
|
||||
priv->devices = NULL;
|
||||
if (*array) {
|
||||
g_ptr_array_foreach (*array, (GFunc) g_object_unref, NULL);
|
||||
g_ptr_array_free (*array, TRUE);
|
||||
*array = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -303,7 +302,8 @@ dispose (GObject *object)
|
|||
g_object_unref (priv->client_proxy);
|
||||
g_object_unref (priv->bus_proxy);
|
||||
|
||||
free_device_list (NM_CLIENT (object));
|
||||
free_object_array (&priv->devices);
|
||||
free_object_array (&priv->active_connections);
|
||||
|
||||
G_OBJECT_CLASS (nm_client_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -490,7 +490,8 @@ proxy_name_owner_changed (DBusGProxy *proxy,
|
|||
if (!priv->manager_running) {
|
||||
priv->state = NM_STATE_UNKNOWN;
|
||||
nm_object_queue_notify (NM_OBJECT (client), NM_CLIENT_MANAGER_RUNNING);
|
||||
free_device_list (client);
|
||||
free_object_array (&priv->devices);
|
||||
free_object_array (&priv->active_connections);
|
||||
priv->wireless_enabled = FALSE;
|
||||
priv->wireless_hw_enabled = FALSE;
|
||||
poke_wireless_devices_with_rf_status (client);
|
||||
|
@ -540,7 +541,7 @@ client_device_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data)
|
|||
}
|
||||
}
|
||||
|
||||
GPtrArray *
|
||||
const GPtrArray *
|
||||
nm_client_get_devices (NMClient *client)
|
||||
{
|
||||
NMClientPrivate *priv;
|
||||
|
@ -553,7 +554,7 @@ nm_client_get_devices (NMClient *client)
|
|||
|
||||
priv = NM_CLIENT_GET_PRIVATE (client);
|
||||
if (priv->devices)
|
||||
return priv->devices;
|
||||
return handle_ptr_array_return (priv->devices);
|
||||
|
||||
if (!org_freedesktop_NetworkManager_get_devices (priv->client_proxy, &temp, &error)) {
|
||||
g_warning ("%s: error getting devices: %s\n", __func__, error->message);
|
||||
|
@ -567,13 +568,13 @@ nm_client_get_devices (NMClient *client)
|
|||
nm_object_array_demarshal (&value, &priv->devices, connection, nm_device_new);
|
||||
g_value_unset (&value);
|
||||
|
||||
return priv->devices;
|
||||
return handle_ptr_array_return (priv->devices);
|
||||
}
|
||||
|
||||
NMDevice *
|
||||
nm_client_get_device_by_path (NMClient *client, const char *object_path)
|
||||
{
|
||||
GPtrArray *devices;
|
||||
const GPtrArray *devices;
|
||||
int i;
|
||||
NMDevice *device = NULL;
|
||||
|
||||
|
@ -683,7 +684,7 @@ nm_client_get_active_connections (NMClient *client)
|
|||
|
||||
priv = NM_CLIENT_GET_PRIVATE (client);
|
||||
if (priv->active_connections)
|
||||
return priv->active_connections;
|
||||
return handle_ptr_array_return (priv->active_connections);
|
||||
|
||||
if (!nm_object_get_property (NM_OBJECT (client),
|
||||
"org.freedesktop.DBus.Properties",
|
||||
|
@ -695,7 +696,7 @@ nm_client_get_active_connections (NMClient *client)
|
|||
demarshal_active_connections (NM_OBJECT (client), NULL, &value, &priv->active_connections);
|
||||
g_value_unset (&value);
|
||||
|
||||
return priv->active_connections;
|
||||
return handle_ptr_array_return (priv->active_connections);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
@ -42,7 +42,7 @@ GType nm_client_get_type (void);
|
|||
|
||||
NMClient *nm_client_new (void);
|
||||
|
||||
GPtrArray *nm_client_get_devices (NMClient *client);
|
||||
const GPtrArray *nm_client_get_devices (NMClient *client);
|
||||
NMDevice *nm_client_get_device_by_path (NMClient *client, const char *object_path);
|
||||
|
||||
typedef void (*NMClientActivateDeviceFn) (gpointer user_data, GError *error);
|
||||
|
|
|
@ -198,7 +198,7 @@ nm_device_802_11_wireless_get_active_access_point (NMDevice80211Wireless *self)
|
|||
return priv->active_ap;
|
||||
}
|
||||
|
||||
GPtrArray *
|
||||
const GPtrArray *
|
||||
nm_device_802_11_wireless_get_access_points (NMDevice80211Wireless *self)
|
||||
{
|
||||
NMDevice80211WirelessPrivate *priv;
|
||||
|
@ -211,7 +211,7 @@ nm_device_802_11_wireless_get_access_points (NMDevice80211Wireless *self)
|
|||
|
||||
priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
|
||||
if (priv->aps)
|
||||
return priv->aps;
|
||||
return handle_ptr_array_return (priv->aps);
|
||||
|
||||
if (!org_freedesktop_NetworkManager_Device_Wireless_get_access_points (priv->proxy, &temp, &error)) {
|
||||
g_warning ("%s: error getting access points: %s", __func__, error->message);
|
||||
|
@ -225,14 +225,14 @@ nm_device_802_11_wireless_get_access_points (NMDevice80211Wireless *self)
|
|||
nm_object_array_demarshal (&value, &priv->aps, connection, nm_access_point_new);
|
||||
g_value_unset (&value);
|
||||
|
||||
return priv->aps;
|
||||
return handle_ptr_array_return (priv->aps);
|
||||
}
|
||||
|
||||
NMAccessPoint *
|
||||
nm_device_802_11_wireless_get_access_point_by_path (NMDevice80211Wireless *self,
|
||||
const char *path)
|
||||
{
|
||||
GPtrArray *aps;
|
||||
const GPtrArray *aps;
|
||||
int i;
|
||||
NMAccessPoint *ap = NULL;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ NMAccessPoint * nm_device_802_11_wireless_get_active_access_point (NMDevice8021
|
|||
NMAccessPoint * nm_device_802_11_wireless_get_access_point_by_path (NMDevice80211Wireless *device,
|
||||
const char *path);
|
||||
|
||||
GPtrArray * nm_device_802_11_wireless_get_access_points (NMDevice80211Wireless *device);
|
||||
const GPtrArray *nm_device_802_11_wireless_get_access_points (NMDevice80211Wireless *device);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -120,7 +120,6 @@ static void
|
|||
finalize (GObject *object)
|
||||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
||||
int i;
|
||||
|
||||
g_free (priv->hostname);
|
||||
g_free (priv->nis_domain);
|
||||
|
@ -130,8 +129,7 @@ finalize (GObject *object)
|
|||
g_array_free (priv->nis_servers, TRUE);
|
||||
|
||||
if (priv->domains) {
|
||||
for (i = 0; i < priv->domains->len; i++)
|
||||
g_free (g_ptr_array_index (priv->domains, i));
|
||||
g_ptr_array_foreach (priv->domains, (GFunc) g_free, NULL);
|
||||
g_ptr_array_free (priv->domains, TRUE);
|
||||
}
|
||||
|
||||
|
@ -396,24 +394,25 @@ nm_ip4_config_get_domains (NMIP4Config *config)
|
|||
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||
|
||||
priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
if (!priv->domains) {
|
||||
if (nm_object_get_property (NM_OBJECT (config),
|
||||
NM_DBUS_INTERFACE_IP4_CONFIG,
|
||||
"Domains",
|
||||
&value)) {
|
||||
char **array = NULL, **p;
|
||||
if (priv->domains)
|
||||
return handle_ptr_array_return (priv->domains);
|
||||
|
||||
array = (char **) g_value_get_boxed (&value);
|
||||
if (array && g_strv_length (array)) {
|
||||
priv->domains = g_ptr_array_sized_new (g_strv_length (array));
|
||||
for (p = array; *p; p++)
|
||||
g_ptr_array_add (priv->domains, g_strdup (*p));
|
||||
}
|
||||
g_value_unset (&value);
|
||||
if (nm_object_get_property (NM_OBJECT (config),
|
||||
NM_DBUS_INTERFACE_IP4_CONFIG,
|
||||
"Domains",
|
||||
&value)) {
|
||||
char **array = NULL, **p;
|
||||
|
||||
array = (char **) g_value_get_boxed (&value);
|
||||
if (array && g_strv_length (array)) {
|
||||
priv->domains = g_ptr_array_sized_new (g_strv_length (array));
|
||||
for (p = array; *p; p++)
|
||||
g_ptr_array_add (priv->domains, g_strdup (*p));
|
||||
}
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
return priv->domains;
|
||||
return handle_ptr_array_return (priv->domains);
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
|
@ -67,4 +67,13 @@ GByteArray *nm_object_get_byte_array_property (NMObject *object,
|
|||
const char *interface,
|
||||
const char *prop_name);
|
||||
|
||||
static inline const GPtrArray *
|
||||
handle_ptr_array_return (GPtrArray *array)
|
||||
{
|
||||
/* zero-length is special-case; return NULL */
|
||||
if (!array || !array->len)
|
||||
return NULL;
|
||||
return array;
|
||||
}
|
||||
|
||||
#endif /* NM_OBJECT_PRIVATE_H */
|
||||
|
|
|
@ -210,6 +210,7 @@ deferred_notify_cb (gpointer data)
|
|||
|
||||
priv->notify_id = 0;
|
||||
|
||||
priv->notify_props = g_slist_reverse (priv->notify_props);
|
||||
for (iter = priv->notify_props; iter; iter = g_slist_next (iter)) {
|
||||
g_object_notify (G_OBJECT (object), (const char *) iter->data);
|
||||
g_free (iter->data);
|
||||
|
@ -224,6 +225,8 @@ void
|
|||
nm_object_queue_notify (NMObject *object, const char *property)
|
||||
{
|
||||
NMObjectPrivate *priv;
|
||||
gboolean found = FALSE;
|
||||
GSList *iter;
|
||||
|
||||
g_return_if_fail (NM_IS_OBJECT (object));
|
||||
g_return_if_fail (property != NULL);
|
||||
|
@ -232,7 +235,15 @@ nm_object_queue_notify (NMObject *object, const char *property)
|
|||
if (!priv->notify_id)
|
||||
priv->notify_id = g_idle_add_full (G_PRIORITY_LOW, deferred_notify_cb, object, NULL);
|
||||
|
||||
priv->notify_props = g_slist_append (priv->notify_props, g_strdup (property));
|
||||
for (iter = priv->notify_props; iter; iter = g_slist_next (iter)) {
|
||||
if (!strcmp ((char *) iter->data, property)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
priv->notify_props = g_slist_prepend (priv->notify_props, g_strdup (property));
|
||||
}
|
||||
|
||||
/* Stolen from dbus-glib */
|
||||
|
|
|
@ -241,11 +241,8 @@ nm_object_array_demarshal (GValue *value,
|
|||
g_warning ("%s: couldn't create object for %s", __func__, path);
|
||||
}
|
||||
}
|
||||
if (temp->len == 0) {
|
||||
g_ptr_array_free (temp, TRUE);
|
||||
temp = NULL;
|
||||
}
|
||||
}
|
||||
} else
|
||||
temp = g_ptr_array_new ();
|
||||
|
||||
/* Deallocate after to ensure that an object that might already
|
||||
* be in the array doesn't get destroyed due to refcounting.
|
||||
|
|
Loading…
Reference in a new issue