static void availability_changed (NMSupplicantManager *self, gboolean available) { NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); GList *ifaces, *iter; /* priv->ifaces may be modified if availability changes; can't use GHashTableIter */ ifaces = g_hash_table_get_values (priv->ifaces); for (iter = ifaces; iter; iter = iter->next) nm_supplicant_interface_set_supplicant_available (NM_SUPPLICANT_INTERFACE (iter->data), available); g_list_free (ifaces); }
static void availability_changed (NMSupplicantManager *self, gboolean available) { NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); GSList *ifaces, *iter; if (!priv->ifaces) return; /* setting the supplicant as unavailable might cause the caller to unref * the supplicant (and thus remove the instance from the list of interfaces. * Delay that by taking an additional reference first. */ ifaces = g_slist_copy (priv->ifaces); for (iter = ifaces; iter; iter = iter->next) g_object_ref (iter->data); for (iter = ifaces; iter; iter = iter->next) nm_supplicant_interface_set_supplicant_available (iter->data, available); g_slist_free_full (ifaces, g_object_unref); }
/** * nm_supplicant_manager_create_interface: * @self: the #NMSupplicantManager * @ifname: the interface for which to obtain the supplicant interface * @is_wireless: whether the interface is supposed to be wireless. * * Note: the manager owns a reference to the instance and the only way to * get the manager to release it, is by dropping all other references * to the supplicant-interface (or destroying the manager). * * Retruns: (transfer-full): returns a #NMSupplicantInterface or %NULL. * Must be unrefed at the end. * */ NMSupplicantInterface * nm_supplicant_manager_create_interface (NMSupplicantManager *self, const char *ifname, gboolean is_wireless) { NMSupplicantManagerPrivate *priv; NMSupplicantInterface *iface; GSList *ifaces; g_return_val_if_fail (NM_IS_SUPPLICANT_MANAGER (self), NULL); g_return_val_if_fail (ifname != NULL, NULL); priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self); nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname); /* assert against not requesting duplicate interfaces. */ for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) { if (g_strcmp0 (nm_supplicant_interface_get_ifname (ifaces->data), ifname) == 0) g_return_val_if_reached (NULL); } iface = nm_supplicant_interface_new (ifname, is_wireless, priv->fast_supported, priv->ap_support); priv->ifaces = g_slist_prepend (priv->ifaces, iface); g_object_add_toggle_ref ((GObject *) iface, _sup_iface_last_ref, self); /* If we're making the supplicant take a time out for a bit, don't * let the supplicant interface start immediately, just let it hang * around in INIT state until we're ready to talk to the supplicant * again. */ if (is_available (self)) nm_supplicant_interface_set_supplicant_available (iface, TRUE); return iface; }