static void remove_connections_read (NMRemoteSettings *settings, gpointer user_data) { RemoveInfo *info = user_data; GSList *list, *iter; g_source_remove (info->timeout_id); g_message ("Removing Bluetooth connections for %s", info->str_bdaddr); list = nm_remote_settings_list_connections (settings); for (iter = list; iter != NULL; iter = g_slist_next (iter)) { NMConnection *connection = iter->data; NMSettingBluetooth *s_bt; const GByteArray *tmp; s_bt = nm_connection_get_setting_bluetooth (connection); if (s_bt) { tmp = nm_setting_bluetooth_get_bdaddr (s_bt); if (tmp && memcmp (tmp->data, info->bdaddr->data, tmp->len) == 0) nm_remote_connection_delete (NM_REMOTE_CONNECTION (connection), delete_cb, NULL); } } g_slist_free (list); remove_cleanup (info); }
static void delete_slaves_of_connection (NMConnectionList *list, NMConnection *connection) { const char *uuid, *iface; GtkTreeIter iter, types_iter; if (!gtk_tree_model_get_iter_first (list->model, &types_iter)) return; uuid = nm_connection_get_uuid (connection); iface = nm_connection_get_virtual_iface_name (connection); do { if (!gtk_tree_model_iter_children (list->model, &iter, &types_iter)) continue; do { NMRemoteConnection *candidate = NULL; NMSettingConnection *s_con; const char *master; gtk_tree_model_get (list->model, &iter, COL_CONNECTION, &candidate, -1); s_con = nm_connection_get_setting_connection (NM_CONNECTION (candidate)); master = nm_setting_connection_get_master (s_con); if (master) { if (!g_strcmp0 (master, uuid) || !g_strcmp0 (master, iface)) nm_remote_connection_delete (candidate, NULL, NULL); } g_object_unref (candidate); } while (gtk_tree_model_iter_next (list->model, &iter)); } while (gtk_tree_model_iter_next (list->model, &types_iter)); }
static void delete_connections_of_type (NMRemoteSettings *settings, const GByteArray *bdaddr, gboolean pan) { GSList *list, *iter; list = nm_remote_settings_list_connections (settings); for (iter = list; iter != NULL; iter = g_slist_next (iter)) { NMRemoteConnection *remote = iter->data; if (match_connection_service (NM_CONNECTION (remote), bdaddr, pan)) nm_remote_connection_delete (remote, delete_cb, NULL); } g_slist_free (list); }
void removeNMConnection(NMDevice *nmdevice, NMActiveConnection *conn) { if (conn) { const char *ac_uuid = nm_active_connection_get_uuid(conn); const GPtrArray *avail_cons = nm_device_get_available_connections(nmdevice); for (int i = 0; avail_cons && (i < avail_cons->len); i++) { NMRemoteConnection *candidate = (NMRemoteConnection *) g_ptr_array_index(avail_cons, i); const char *test_uuid = nm_connection_get_uuid(NM_CONNECTION(candidate)); if (g_strcmp0(ac_uuid, test_uuid) == 0) { GError *err = NULL; nm_remote_connection_delete(candidate, NULL, &err); if (err) { DBG("WifiStatusNM: failed to remove active connection!"); DBG("WifiStatusNM::" << __func__ << ": " << err->message); g_error_free(err); } break; } } } }