static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data) { NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); switch (nm_device_get_state (device)) { case NM_DEVICE_STATE_UNKNOWN: case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNAVAILABLE: case NM_DEVICE_STATE_DISCONNECTED: case NM_DEVICE_STATE_FAILED: /* 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; } _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT); priv->rate = 0; _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIFI_BITRATE); break; default: break; } }
static void clear_link_status (NMDeviceWimax *self) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); if (priv->center_freq) { priv->center_freq = 0; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CENTER_FREQUENCY); } if (priv->rssi) { priv->rssi = 0; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_RSSI); } if (priv->cinr) { priv->cinr = 0; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_CINR); } if (priv->tx_power) { priv->tx_power = 0; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_TX_POWER); } if (priv->bsid) { g_free (priv->bsid); priv->bsid = NULL; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_BSID); } }
static void access_point_removed_proxy (DBusGProxy *proxy, char *path, gpointer user_data) { NMDeviceWifi *self = NM_DEVICE_WIFI (user_data); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMAccessPoint *ap; g_return_if_fail (self != NULL); ap = nm_device_wifi_get_access_point_by_path (self, path); if (ap) { if (ap == priv->active_ap) { g_object_unref (priv->active_ap); priv->active_ap = NULL; priv->null_active_ap = FALSE; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT); priv->rate = 0; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_BITRATE); } g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap); g_ptr_array_remove (priv->aps, ap); g_object_unref (G_OBJECT (ap)); } }
static gboolean demarshal_ip4_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { if (!_nm_uint_array_demarshal (value, (GArray **) field)) return FALSE; if (!strcmp (pspec->name, NM_IP4_CONFIG_NAMESERVERS)) _nm_object_queue_notify (object, NM_IP4_CONFIG_NAMESERVERS); else if (!strcmp (pspec->name, NM_IP4_CONFIG_WINS_SERVERS)) _nm_object_queue_notify (object, NM_IP4_CONFIG_WINS_SERVERS); return TRUE; }
static void access_point_removed (NMDeviceWifi *self, NMAccessPoint *ap) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); if (ap == priv->active_ap) { g_object_unref (priv->active_ap); priv->active_ap = NULL; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT); priv->rate = 0; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_BITRATE); } }
static void state_changed_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data) { NMDeviceWimax *self = NM_DEVICE_WIMAX (device); NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); NMDeviceState state; state = nm_device_get_state (device); switch (state) { case NM_DEVICE_STATE_UNKNOWN: case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNAVAILABLE: case NM_DEVICE_STATE_DISCONNECTED: case NM_DEVICE_STATE_FAILED: if (priv->active_nsp) { g_object_unref (priv->active_nsp); priv->active_nsp = NULL; } _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_WIMAX_ACTIVE_NSP); clear_link_status (self); break; case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: case NM_DEVICE_STATE_IP_CONFIG: clear_link_status (self); break; default: break; } }
static gboolean demarshal_string_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { if (!_nm_string_array_demarshal (value, (GPtrArray **) field)) return FALSE; _nm_object_queue_notify (object, pspec->name); return TRUE; }
static gboolean demarshal_ssid (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { if (!_nm_ssid_demarshal (value, (GByteArray **) field)) return FALSE; _nm_object_queue_notify (object, NM_ACCESS_POINT_SSID); return TRUE; }
static void access_point_removed (NMObject *self_obj, NMObject *ap_obj) { NMDeviceWifi *self = NM_DEVICE_WIFI (self_obj); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMAccessPoint *ap = NM_ACCESS_POINT (ap_obj); if (ap == priv->active_ap) { g_object_unref (priv->active_ap); priv->active_ap = NULL; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT); priv->rate = 0; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIFI_BITRATE); } g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap); }
static gboolean demarshal_searches (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { if (!_nm_string_array_demarshal (value, (GPtrArray **) field)) return FALSE; _nm_object_queue_notify (object, NM_IP6_CONFIG_SEARCHES); return TRUE; }
static void nsp_removed (NMDeviceWimax *self, NMWimaxNsp *nsp) { NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self); if (nsp == priv->active_nsp) { g_object_unref (priv->active_nsp); priv->active_nsp = NULL; _nm_object_queue_notify (NM_OBJECT (self), NM_DEVICE_WIMAX_ACTIVE_NSP); } }
static gboolean demarshal_ip6_nameserver_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { if (!_nm_ip6_address_array_demarshal (value, (GSList **) field)) return FALSE; if (pspec && !strcmp (pspec->name, NM_IP6_CONFIG_NAMESERVERS)) _nm_object_queue_notify (object, NM_IP6_CONFIG_NAMESERVERS); return TRUE; }
static gboolean demarshal_devices (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { DBusGConnection *connection; connection = nm_object_get_connection (object); if (!_nm_object_array_demarshal (value, (GPtrArray **) field, connection, nm_device_new)) return FALSE; _nm_object_queue_notify (object, NM_ACTIVE_CONNECTION_DEVICES); return TRUE; }
static gboolean demarshal_ip6_address_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref); priv->addresses = NULL; priv->addresses = nm_utils_ip6_addresses_from_gvalue (value); _nm_object_queue_notify (object, NM_IP6_CONFIG_ADDRESSES); return TRUE; }
static gboolean demarshal_ip4_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); g_slist_foreach (priv->routes, (GFunc) g_free, NULL); g_slist_free (priv->routes); priv->routes = NULL; priv->routes = nm_utils_ip4_routes_from_gvalue (value); _nm_object_queue_notify (object, NM_IP4_CONFIG_ROUTES); return TRUE; }
static gboolean demarshal_dhcp6_options (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMDHCP6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object); GHashTable *new_options; g_hash_table_remove_all (priv->options); new_options = g_value_get_boxed (value); if (new_options) g_hash_table_foreach (new_options, copy_options, priv->options); _nm_object_queue_notify (object, NM_DHCP6_CONFIG_OPTIONS); return TRUE; }
static gboolean demarshal_ip_address_data (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field) { NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (object); priv->new_style_data = TRUE; g_ptr_array_unref (priv->addresses); if (NM_IS_IP4_CONFIG (object)) priv->addresses = nm_utils_ip_addresses_from_variant (value, AF_INET); else priv->addresses = nm_utils_ip_addresses_from_variant (value, AF_INET6); _nm_object_queue_notify (object, NM_IP_CONFIG_ADDRESSES); return TRUE; }
static void device_state_changed (DBusGProxy *proxy, NMDeviceState new_state, NMDeviceState old_state, NMDeviceStateReason reason, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); if (priv->state != new_state) { priv->state = new_state; g_signal_emit (self, signals[STATE_CHANGED], 0, new_state, old_state, reason); _nm_object_queue_notify (NM_OBJECT (self), "state"); } }
static gboolean demarshal_ip_routes (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field) { NMIPConfigPrivate *priv = NM_IP_CONFIG_GET_PRIVATE (object); if (priv->new_style_data) return TRUE; g_ptr_array_unref (priv->routes); if (NM_IS_IP4_CONFIG (object)) priv->routes = nm_utils_ip4_routes_from_variant (value); else priv->routes = nm_utils_ip6_routes_from_variant (value); _nm_object_queue_notify (object, NM_IP_CONFIG_ROUTES); return TRUE; }
static gboolean demarshal_ip_array (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field) { char ***obj_field; obj_field = field; if (*obj_field) g_strfreev (*obj_field); if (NM_IS_IP4_CONFIG (object)) *obj_field = nm_utils_ip4_dns_from_variant (value); else *obj_field = nm_utils_ip6_dns_from_variant (value); _nm_object_queue_notify (object, pspec->name); return TRUE; }
static gboolean demarshal_dhcp_options (NMObject *object, GParamSpec *pspec, GVariant *value, gpointer field) { NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (object); GVariantIter iter; const char *key; GVariant *opt; g_hash_table_remove_all (priv->options); g_variant_iter_init (&iter, value); while (g_variant_iter_next (&iter, "{&sv}", &key, &opt)) { g_hash_table_insert (priv->options, g_strdup (key), g_variant_dup_string (opt, NULL)); g_variant_unref (opt); } _nm_object_queue_notify (object, NM_DHCP_CONFIG_OPTIONS); return TRUE; }
static gboolean demarshal_dhcp4_options (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMDHCP4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object); GHashTable *new_options; GHashTableIter iter; const char *key; GValue *opt; g_hash_table_remove_all (priv->options); new_options = g_value_get_boxed (value); if (new_options) { g_hash_table_iter_init (&iter, new_options); while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &opt)) g_hash_table_insert (priv->options, g_strdup (key), g_value_dup_string (opt)); } _nm_object_queue_notify (object, NM_DHCP4_CONFIG_OPTIONS); 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; }
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 void nm_device_update_description (NMDevice *device) { NMDevicePrivate *priv; const char *subsys[3] = { "net", "tty", NULL }; GUdevDevice *udev_device = NULL, *tmpdev; const char *ifname; guint32 count = 0; const char *vendor, *model; g_return_if_fail (NM_IS_DEVICE (device)); priv = NM_DEVICE_GET_PRIVATE (device); if (!priv->client) { priv->client = g_udev_client_new (subsys); if (!priv->client) return; } ifname = nm_device_get_iface (device); if (!ifname) return; if (NM_IS_DEVICE_ETHERNET (device) || NM_IS_DEVICE_WIFI (device)) udev_device = g_udev_client_query_by_subsystem_and_name (priv->client, "net", ifname); else if (NM_IS_GSM_DEVICE (device) || NM_IS_CDMA_DEVICE (device)) udev_device = g_udev_client_query_by_subsystem_and_name (priv->client, "tty", ifname); if (!udev_device) return; g_free (priv->product); priv->product = NULL; g_free (priv->vendor); priv->vendor = NULL; /* Walk up the chain of the device and its parents a few steps to grab * vendor and device ID information off it. */ tmpdev = udev_device; while ((count++ < 3) && tmpdev && (!priv->vendor || !priv->product)) { if (!priv->vendor) priv->vendor = get_decoded_property (tmpdev, "ID_VENDOR_ENC"); if (!priv->product) priv->product = get_decoded_property (tmpdev, "ID_MODEL_ENC"); tmpdev = g_udev_device_get_parent (tmpdev); } /* If we didn't get strings directly from the device, try database strings */ tmpdev = udev_device; count = 0; while ((count++ < 3) && tmpdev && (!priv->vendor || !priv->product)) { if (!priv->vendor) { vendor = g_udev_device_get_property (tmpdev, "ID_VENDOR_FROM_DATABASE"); if (vendor) priv->vendor = g_strdup (vendor); } if (!priv->product) { model = g_udev_device_get_property (tmpdev, "ID_MODEL_FROM_DATABASE"); if (model) priv->product = g_strdup (model); } tmpdev = g_udev_device_get_parent (tmpdev); } _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_VENDOR); _nm_object_queue_notify (NM_OBJECT (device), NM_DEVICE_PRODUCT); }