static void access_point_added_proxy (DBusGProxy *proxy, char *path, gpointer user_data) { NMDeviceWifi *self = NM_DEVICE_WIFI (user_data); NMDeviceWifiPrivate *priv; GObject *ap; g_return_if_fail (self != NULL); ap = G_OBJECT (nm_device_wifi_get_access_point_by_path (self, path)); if (!ap) { DBusGConnection *connection = nm_object_get_connection (NM_OBJECT (self)); priv = NM_DEVICE_WIFI_GET_PRIVATE (self); ap = G_OBJECT (_nm_object_cache_get (path)); if (ap) { g_ptr_array_add (priv->aps, g_object_ref (ap)); } else { ap = G_OBJECT (nm_access_point_new (connection, path)); if (ap) g_ptr_array_add (priv->aps, ap); } } if (ap) g_signal_emit (self, signals[ACCESS_POINT_ADDED], 0, NM_ACCESS_POINT (ap)); }
gboolean _nm_object_array_demarshal (GValue *value, GPtrArray **dest, DBusGConnection *connection, NMObjectCreatorFunc func) { GPtrArray *temp = NULL; GPtrArray *array; if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH)) return FALSE; array = (GPtrArray *) g_value_get_boxed (value); if (array && array->len) { int i; temp = g_ptr_array_sized_new (array->len); for (i = 0; i < array->len; i++) { const char *path; GObject *object; path = g_ptr_array_index (array, i); object = G_OBJECT (_nm_object_cache_get (path)); if (object) g_ptr_array_add (temp, object); else { object = (*func) (connection, path); if (object) g_ptr_array_add (temp, object); else g_warning ("%s: couldn't create object for %s", __func__, path); } } } 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. */ if (*dest) g_boxed_free (NM_TYPE_OBJECT_ARRAY, *dest); *dest = temp; return TRUE; }
static gboolean demarshal_active_ap (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object); const char *path; NMAccessPoint *ap = NULL; DBusGConnection *connection; 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) { if (!strcmp (path, "/")) priv->null_active_ap = TRUE; else { 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)); } } } if (priv->active_ap) { g_object_unref (priv->active_ap); priv->active_ap = NULL; } if (ap) priv->active_ap = ap; _nm_object_queue_notify (object, NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT); return TRUE; }
static gboolean demarshal_ip6_config (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (object); const char *path; NMIP6Config *config = NULL; DBusGConnection *connection; if (!G_VALUE_HOLDS (value, DBUS_TYPE_G_OBJECT_PATH)) return FALSE; priv->null_ip6_config = FALSE; path = g_value_get_boxed (value); if (path) { if (!strcmp (path, "/")) priv->null_ip6_config = TRUE; else { config = NM_IP6_CONFIG (_nm_object_cache_get (path)); if (config) config = g_object_ref (config); else { connection = nm_object_get_connection (object); config = NM_IP6_CONFIG (nm_ip6_config_new (connection, path)); } } } if (priv->ip6_config) { g_object_unref (priv->ip6_config); priv->ip6_config = NULL; } if (config) priv->ip6_config = config; _nm_object_queue_notify (object, NM_DEVICE_IP6_CONFIG); return TRUE; }