static void update_switches_visibility (NmnApplet *applet) { NmnAppletPrivate *priv = GET_PRIVATE (applet); GtkTable *table; gboolean visible; int ethernet; int wifi; int modem; int wimax; int bt; ethernet = wifi = modem = wimax = bt = 0; if (!nmn_model_offline_mode_get_active (priv->model)) { const GPtrArray *devices; int i; devices = nm_client_get_devices (nmn_model_get_client (priv->model)); for (i = 0; devices && i < devices->len; i++) { NMDevice *device = NM_DEVICE (g_ptr_array_index (devices, i)); if (NM_IS_DEVICE_ETHERNET (device)) ethernet++; else if (NM_IS_DEVICE_WIFI (device)) wifi++; else if (NM_IS_SERIAL_DEVICE (device)) modem++; else if (NM_IS_DEVICE_BT (device)) bt++; } } table = GTK_TABLE (priv->switches_table); visible = wifi > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_WIFI, visible ? 6 : 0); g_object_set (priv->enable_wifi_label, "visible", visible, NULL); g_object_set (priv->enable_wifi, "visible", visible, NULL); visible = ethernet > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_ETHERNET, visible ? 6 : 0); g_object_set (priv->enable_ethernet_label, "visible", visible, NULL); g_object_set (priv->enable_ethernet, "visible", visible, NULL); visible = modem > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_3G, visible ? 6 : 0); g_object_set (priv->enable_3g_label, "visible", visible, NULL); g_object_set (priv->enable_3g, "visible", visible, NULL); visible = wimax > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_WIMAX, visible ? 6 : 0); g_object_set (priv->enable_wimax_label, "visible", visible, NULL); g_object_set (priv->enable_wimax, "visible", visible, NULL); visible = bt > 0; gtk_table_set_row_spacing (table, SWITCHES_ROW_BT, visible ? 6 : 0); g_object_set (priv->enable_bt_label, "visible", visible, NULL); g_object_set (priv->enable_bt, "visible", visible, NULL); }
/** * nm_device_wifi_get_access_points: * @device: a #NMDeviceWifi * * Gets all the scanned access points of the #NMDeviceWifi. * * Returns: a #GPtrArray containing all the scanned #NMAccessPoint<!-- -->s. * The returned array is owned by the client and should not be modified. **/ const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi *device) { NMDeviceWifiPrivate *priv; DBusGConnection *connection; GValue value = { 0, }; GError *error = NULL; GPtrArray *temp; g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); priv = NM_DEVICE_WIFI_GET_PRIVATE (device); if (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); g_error_free (error); return NULL; } g_value_init (&value, DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH); g_value_take_boxed (&value, temp); connection = nm_object_get_connection (NM_OBJECT (device)); _nm_object_array_demarshal (&value, &priv->aps, connection, nm_access_point_new); g_value_unset (&value); return handle_ptr_array_return (priv->aps); }
/** * nm_device_wifi_get_bitrate: * @device: a #NMDeviceWifi * * Gets the bit rate of the #NMDeviceWifi. * * Returns: the bit rate **/ guint32 nm_device_wifi_get_bitrate (NMDeviceWifi *device) { NMDeviceWifiPrivate *priv; NMDeviceState state; g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); state = nm_device_get_state (NM_DEVICE (device)); switch (state) { case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: case NM_DEVICE_STATE_IP_CONFIG: case NM_DEVICE_STATE_ACTIVATED: break; default: return 0; break; } priv = NM_DEVICE_WIFI_GET_PRIVATE (device); if (!priv->rate) { priv->rate = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, DBUS_PROP_BITRATE); } return priv->rate; }
/** * nm_device_wifi_get_access_points: * @device: a #NMDeviceWifi * * Gets all the scanned access points of the #NMDeviceWifi. * * Returns: (element-type NMAccessPoint): a #GPtrArray containing all the * scanned #NMAccessPoints. * The returned array is owned by the client and should not be modified. **/ const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); return NM_DEVICE_WIFI_GET_PRIVATE (device)->aps; }
static void refresh_wireless_list (GisNetworkPage *page) { GisNetworkPagePrivate *priv = page->priv; NMDeviceState state = NM_DEVICE_STATE_UNAVAILABLE; NMAccessPoint *active_ap = NULL; NMAccessPoint *ap; const GPtrArray *aps; GPtrArray *unique_aps; guint i; GtkWidget *label; GtkWidget *spinner; GtkWidget *swin; priv->refreshing = TRUE; if (NM_IS_DEVICE_WIFI (priv->nm_device)) { state = nm_device_get_state (priv->nm_device); active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (priv->nm_device)); gtk_tree_view_set_model (OBJ(GtkTreeView*, "network-list"), NULL); gtk_list_store_clear (priv->ap_list); if (priv->row) { gtk_tree_row_reference_free (priv->row); priv->row = NULL; } aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (priv->nm_device)); }
static void device_added (NMManager *manager, NMDevice *device, gpointer user_data) { NMPolicy *policy = (NMPolicy *) user_data; gulong id; id = g_signal_connect (device, "state-changed", G_CALLBACK (device_state_changed), policy); policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device); id = g_signal_connect (device, "notify::" NM_DEVICE_INTERFACE_IP4_CONFIG, G_CALLBACK (device_ip_config_changed), policy); policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device); id = g_signal_connect (device, "notify::" NM_DEVICE_INTERFACE_IP6_CONFIG, G_CALLBACK (device_ip_config_changed), policy); policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device); if (NM_IS_DEVICE_WIFI (device)) { id = g_signal_connect (device, "access-point-added", G_CALLBACK (wireless_networks_changed), policy); policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device); id = g_signal_connect (device, "access-point-removed", G_CALLBACK (wireless_networks_changed), policy); policy->dev_signal_ids = add_device_signal_id (policy->dev_signal_ids, id, device); } }
/** * nm_device_wifi_get_capabilities: * @device: a #NMDeviceWifi * * Gets the Wi-Fi capabilities of the #NMDeviceWifi. * * Returns: the capabilities **/ NMDeviceWifiCapabilities nm_device_wifi_get_capabilities (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); return NM_DEVICE_WIFI_GET_PRIVATE (device)->wireless_caps; }
/** * nm_device_wifi_get_active_access_point: * @device: a #NMDeviceWifi * * Gets the active #NMAccessPoint. * * Returns: (transfer none): the access point or %NULL if none is active **/ NMAccessPoint * nm_device_wifi_get_active_access_point (NMDeviceWifi *device) { NMDeviceState state; g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); state = nm_device_get_state (NM_DEVICE (device)); switch (state) { case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: case NM_DEVICE_STATE_IP_CONFIG: case NM_DEVICE_STATE_IP_CHECK: case NM_DEVICE_STATE_SECONDARIES: case NM_DEVICE_STATE_ACTIVATED: case NM_DEVICE_STATE_DEACTIVATING: break; default: return NULL; break; } return NM_DEVICE_WIFI_GET_PRIVATE (device)->active_ap; }
/** * nm_device_wifi_get_permanent_hw_address: * @device: a #NMDeviceWifi * * Gets the permanent hardware (MAC) address of the #NMDeviceWifi * * Returns: the permanent hardware address. This is the internal string used by the * device, and must not be modified. **/ const char * nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); return NM_DEVICE_WIFI_GET_PRIVATE (device)->perm_hw_address; }
/** * nm_device_wifi_get_mode: * @device: a #NMDeviceWifi * * Gets the #NMDeviceWifi mode. * * Returns: the mode **/ NM80211Mode nm_device_wifi_get_mode (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); return NM_DEVICE_WIFI_GET_PRIVATE (device)->mode; }
/** * nm_device_wifi_request_scan_simple: * @device: a #NMDeviceWifi * @callback: (scope async) (allow-none): the function to call when the call is done * @user_data: (closure): user data to pass to the callback function * * Request NM to scan for access points on the #NMDeviceWifi. This function only * instructs NM to perform scanning. Use nm_device_wifi_get_access_points() * to get available access points. **/ void nm_device_wifi_request_scan_simple (NMDeviceWifi *device, NMDeviceWifiRequestScanFn callback, gpointer user_data) { RequestScanInfo *info; GHashTable *options; NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device); g_return_if_fail (NM_IS_DEVICE_WIFI (device)); /* If a scan is in progress, just return */ if (priv->scan_call) return; options = g_hash_table_new (g_str_hash, g_str_equal); info = g_slice_new0 (RequestScanInfo); info->device = device; info->callback = callback; info->user_data = user_data; priv->scan_info = info; priv->scan_call = dbus_g_proxy_begin_call (NM_DEVICE_WIFI_GET_PRIVATE (device)->proxy, "RequestScan", request_scan_cb, info, NULL, DBUS_TYPE_G_MAP_OF_VARIANT, options, G_TYPE_INVALID); g_hash_table_unref (options); }
static void clean_up_aps (NMDeviceWifi *self, gboolean notify) { NMDeviceWifiPrivate *priv; g_return_if_fail (NM_IS_DEVICE_WIFI (self)); priv = NM_DEVICE_WIFI_GET_PRIVATE (self); if (priv->active_ap) { g_object_unref (priv->active_ap); priv->active_ap = NULL; } 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_free (priv->aps, TRUE); priv->aps = NULL; } }
static void clean_up_aps (NMDeviceWifi *self, gboolean in_dispose) { NMDeviceWifiPrivate *priv; GPtrArray *aps; int i; g_return_if_fail (NM_IS_DEVICE_WIFI (self)); priv = NM_DEVICE_WIFI_GET_PRIVATE (self); if (priv->active_ap) { g_object_unref (priv->active_ap); priv->active_ap = NULL; } aps = priv->aps; if (in_dispose) priv->aps = NULL; else { priv->aps = g_ptr_array_new (); for (i = 0; i < aps->len; i++) { NMAccessPoint *ap = NM_ACCESS_POINT (g_ptr_array_index (aps, i)); g_signal_emit (self, signals[ACCESS_POINT_REMOVED], 0, ap); } } g_ptr_array_unref (aps); }
static void show_device_type_specific_info (NMDevice * device) { g_return_if_fail (NM_IS_DEVICE (device)); if (NM_IS_DEVICE_ETHERNET (device)) { show_ethernet_specific_info (device); } else if (NM_IS_DEVICE_WIFI (device)) { show_wifi_specific_info (device); } else if (NM_IS_DEVICE_BT (device)) { show_bt_specific_info (device); } else if (NM_IS_GSM_DEVICE (device)) { show_gsm_specific_info (device); } else if (NM_IS_CDMA_DEVICE (device)) { show_cdma_specific_info (device); } else { g_printerr ("Unsupported device type: %s\n", g_type_name (G_TYPE_FROM_INSTANCE (device))); } }
/** * nm_device_wifi_get_access_point_by_path: * @device: a #NMDeviceWifi * @path: the object path of the access point * * Gets a #NMAccessPoint by path. * * Returns: (transfer none): the access point or %NULL if none is found. **/ NMAccessPoint * nm_device_wifi_get_access_point_by_path (NMDeviceWifi *device, const char *path) { const GPtrArray *aps; int i; NMAccessPoint *ap = NULL; g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); g_return_val_if_fail (path != NULL, NULL); aps = nm_device_wifi_get_access_points (device); if (!aps) return NULL; for (i = 0; i < aps->len; i++) { NMAccessPoint *candidate = g_ptr_array_index (aps, i); if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), path)) { ap = candidate; break; } } return ap; }
static void dump_device (NMDevice *device) { const char *str; NMDeviceState state; str = nm_device_get_iface (device); g_print ("Interface: %s\n", str); str = nm_device_get_udi (device); g_print ("Udi: %s\n", str); str = nm_device_get_driver (device); g_print ("Driver: %s\n", str); str = nm_device_get_vendor (device); g_print ("Vendor: %s\n", str); str = nm_device_get_product (device); g_print ("Product: %s\n", str); state = nm_device_get_state (device); g_print ("State: %d\n", state); if (state == NM_DEVICE_STATE_ACTIVATED) dump_ip4_config (nm_device_get_ip4_config (device)); if (NM_IS_DEVICE_ETHERNET (device)) dump_wired (NM_DEVICE_ETHERNET (device)); else if (NM_IS_DEVICE_WIFI (device)) dump_wireless (NM_DEVICE_WIFI (device)); dump_dhcp4_config (nm_device_get_dhcp4_config (device)); }
static GSList * append_nmt_devices_for_devices (GSList *nmt_devices, const GPtrArray *devices, char **names, const GPtrArray *connections) { NmtConnectDevice *nmtdev; NMDevice *device; int i, sort_order; for (i = 0; i < devices->len; i++) { device = devices->pdata[i]; sort_order = get_sort_order_for_device (device); if (sort_order == -1) continue; nmtdev = g_slice_new0 (NmtConnectDevice); nmtdev->name = g_strdup (names[i]); nmtdev->device = g_object_ref (device); nmtdev->sort_order = sort_order; if (NM_IS_DEVICE_WIFI (device)) add_connections_for_aps (nmtdev, connections); else add_connections_for_device (nmtdev, connections); nmtdev->conns = g_slist_sort (nmtdev->conns, sort_connections); nmt_devices = g_slist_prepend (nmt_devices, nmtdev); } return nmt_devices; }
/** * nm_device_wifi_get_permanent_hw_address: * @device: a #NMDeviceWifi * * Gets the permanent hardware (MAC) address of the #NMDeviceWifi * * Returns: the permanent hardware address. This is the internal string used by the * device, and must not be modified. **/ const char * nm_device_wifi_get_permanent_hw_address (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); _nm_object_ensure_inited (NM_OBJECT (device)); return NM_DEVICE_WIFI_GET_PRIVATE (device)->perm_hw_address; }
/** * nm_device_wifi_get_mode: * @device: a #NMDeviceWifi * * Gets the #NMDeviceWifi mode. * * Returns: the mode **/ NM80211Mode nm_device_wifi_get_mode (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); _nm_object_ensure_inited (NM_OBJECT (device)); return NM_DEVICE_WIFI_GET_PRIVATE (device)->mode; }
/** * nm_device_wifi_get_access_points: * @device: a #NMDeviceWifi * * Gets all the scanned access points of the #NMDeviceWifi. * * Returns: (element-type NMClient.AccessPoint): a #GPtrArray containing all the * scanned #NMAccessPoint<!-- -->s. * The returned array is owned by the client and should not be modified. **/ const GPtrArray * nm_device_wifi_get_access_points (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); _nm_object_ensure_inited (NM_OBJECT (device)); return handle_ptr_array_return (NM_DEVICE_WIFI_GET_PRIVATE (device)->aps); }
/** * nm_device_wifi_get_capabilities: * @device: a #NMDeviceWifi * * Gets the WIFI capabilities of the #NMDeviceWifi. * * Returns: the capabilities **/ NMDeviceWifiCapabilities nm_device_wifi_get_capabilities (NMDeviceWifi *device) { g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); _nm_object_ensure_inited (NM_OBJECT (device)); return NM_DEVICE_WIFI_GET_PRIVATE (device)->wireless_caps; }
/** * _nm_device_wifi_set_wireless_enabled: * @device: a #NMDeviceWifi * @enabled: %TRUE to enable the device * * Enables or disables the wireless device. **/ void _nm_device_wifi_set_wireless_enabled (NMDeviceWifi *device, gboolean enabled) { g_return_if_fail (NM_IS_DEVICE_WIFI (device)); if (!enabled) clean_up_aps (device, FALSE); }
static gboolean is_companion (NMDeviceOlpcMesh *self, NMDevice *other) { NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); struct ether_addr their_addr; NMManager *manager; if (!NM_IS_DEVICE_WIFI (other)) return FALSE; nm_device_wifi_get_address (NM_DEVICE_WIFI (other), &their_addr); if (memcmp (priv->hw_addr.ether_addr_octet, their_addr.ether_addr_octet, ETH_ALEN) != 0) { return FALSE; } /* FIXME detect when our companion leaves */ priv->companion = other; /* When we've found the companion, stop listening for other devices */ manager = nm_manager_get (); if (priv->device_added_id) { g_signal_handler_disconnect (manager, priv->device_added_id); priv->device_added_id = 0; } g_object_unref (manager); nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE); nm_log_info (LOGD_OLPC_MESH, "(%s): found companion WiFi device %s", nm_device_get_iface (NM_DEVICE (self)), nm_device_get_iface (other)); g_signal_connect (G_OBJECT (other), "state-changed", G_CALLBACK (companion_state_changed_cb), self); g_signal_connect (G_OBJECT (other), "notify::scanning", G_CALLBACK (companion_notify_cb), self); g_signal_connect (G_OBJECT (other), "scanning-allowed", G_CALLBACK (companion_scan_allowed_cb), self); g_signal_connect (G_OBJECT (other), "autoconnect-allowed", G_CALLBACK (companion_autoconnect_allowed_cb), self); g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_COMPANION); return TRUE; }
static gboolean can_use_device (NMDevice *device) { /* Ignore unsupported devices */ if (!(nm_device_get_capabilities (device) & NM_DEVICE_CAP_NM_SUPPORTED)) return FALSE; if (!NM_IS_DEVICE_WIFI (device)) return FALSE; if (nm_device_get_state (device) < NM_DEVICE_STATE_DISCONNECTED) return FALSE; return TRUE; }
/** * nm_device_wifi_get_capabilities: * @device: a #NMDeviceWifi * * Gets the WIFI capabilities of the #NMDeviceWifi. * * Returns: the capabilities **/ guint32 nm_device_wifi_get_capabilities (NMDeviceWifi *device) { NMDeviceWifiPrivate *priv; g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); priv = NM_DEVICE_WIFI_GET_PRIVATE (device); if (!priv->wireless_caps) { priv->wireless_caps = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, DBUS_PROP_WIRELESS_CAPABILITIES); } return priv->wireless_caps; }
/** * nm_device_wifi_get_hw_address: * @device: a #NMDeviceWifi * * Gets the hardware (MAC) address of the #NMDeviceWifi * * Returns: the hardware address. This is the internal string used by the * device, and must not be modified. **/ const char * nm_device_wifi_get_hw_address (NMDeviceWifi *device) { NMDeviceWifiPrivate *priv; g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); priv = NM_DEVICE_WIFI_GET_PRIVATE (device); if (!priv->hw_address) { priv->hw_address = _nm_object_get_string_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, DBUS_PROP_HW_ADDRESS); } return priv->hw_address; }
/** * nm_device_wifi_get_mode: * @device: a #NMDeviceWifi * * Gets the #NMDeviceWifi mode. * * Returns: the mode **/ NM80211Mode nm_device_wifi_get_mode (NMDeviceWifi *device) { NMDeviceWifiPrivate *priv; g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), 0); priv = NM_DEVICE_WIFI_GET_PRIVATE (device); if (!priv->mode) { priv->mode = _nm_object_get_uint_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, DBUS_PROP_MODE); } return priv->mode; }
NMListItem * nm_wifi_item_new (NMClient *client, NMDeviceWifi *device, NMAccessPoint *ap, NMSettingsConnectionInterface *connection) { g_return_val_if_fail (NM_IS_CLIENT (client), NULL); g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL); return (NMListItem *) g_object_new (NM_TYPE_WIFI_ITEM, NM_LIST_ITEM_TYPE_NAME, _("WiFi"), NM_CONNECTION_ITEM_CLIENT, client, NM_CONNECTION_ITEM_CONNECTION, connection, NM_DEVICE_ITEM_DEVICE, device, NM_WIFI_ITEM_AP, ap, NULL); }
static gboolean nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); if (NM_IS_DEVICE_ETHERNET (device)) return check_ethernet_compatible (NM_DEVICE_ETHERNET (device), connection, error); else if (NM_IS_DEVICE_WIFI (device)) return check_wifi_compatible (NM_DEVICE_WIFI (device), connection, error); else if (NM_IS_DEVICE_BT (device)) return check_bt_compatible (NM_DEVICE_BT (device), connection, error); // else if (NM_IS_DEVICE_OLPC_MESH (device)) // return check_olpc_mesh_compatible (NM_DEVICE_OLPC_MESH (device), connection, error); g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device)); return FALSE; }
/** * nm_device_wifi_get_active_access_point: * @device: a #NMDeviceWifi * * Gets the active #NMAccessPoint. * * Returns: the access point or %NULL if none is active **/ NMAccessPoint * nm_device_wifi_get_active_access_point (NMDeviceWifi *device) { NMDeviceWifiPrivate *priv; NMDeviceState state; char *path; GValue value = { 0, }; g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); state = nm_device_get_state (NM_DEVICE (device)); switch (state) { case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: case NM_DEVICE_STATE_IP_CONFIG: case NM_DEVICE_STATE_ACTIVATED: break; default: return NULL; break; } priv = NM_DEVICE_WIFI_GET_PRIVATE (device); if (priv->active_ap) return priv->active_ap; if (priv->null_active_ap) return NULL; path = _nm_object_get_object_path_property (NM_OBJECT (device), NM_DBUS_INTERFACE_DEVICE_WIRELESS, DBUS_PROP_ACTIVE_ACCESS_POINT); if (path) { g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); g_value_take_boxed (&value, path); demarshal_active_ap (NM_OBJECT (device), NULL, &value, &priv->active_ap); g_value_unset (&value); } return priv->active_ap; }