tui: when deleting a bridge/bond/team, delete its slaves too (rh #1131574)

This commit is contained in:
Dan Winship 2014-10-03 16:50:18 -04:00
parent 27650c2198
commit 66f19feef9

View file

@ -486,20 +486,12 @@ connection_removed_signal (NMRemoteSettings *settings,
}
}
void
nmt_remove_connection (NMRemoteConnection *connection)
static void
remove_one_connection (NMRemoteConnection *connection)
{
ConnectionDeleteData data;
int choice;
GError *error = NULL;
choice = nmt_newt_choice_dialog (_("Cancel"),
_("Delete"),
_("Are you sure you want to delete the connection '%s'?"),
nm_connection_get_id (NM_CONNECTION (connection)));
if (choice == 1)
return;
data.got_callback = data.got_signal = FALSE;
nmt_sync_op_init (&data.op);
@ -509,7 +501,8 @@ nmt_remove_connection (NMRemoteConnection *connection)
nm_remote_connection_delete_async (connection, NULL, connection_deleted_callback, &data);
if (!nmt_sync_op_wait_boolean (&data.op, &error)) {
nmt_newt_message_dialog (_("Could not delete connection: %s"),
nmt_newt_message_dialog (_("Could not delete connection '%s': %s"),
nm_connection_get_id (NM_CONNECTION (connection)),
error->message);
g_error_free (error);
}
@ -517,6 +510,42 @@ nmt_remove_connection (NMRemoteConnection *connection)
g_signal_handlers_disconnect_by_func (nm_settings, G_CALLBACK (connection_removed_signal), &data);
}
void
nmt_remove_connection (NMRemoteConnection *connection)
{
GSList *conns, *iter;
NMRemoteConnection *slave;
NMSettingConnection *s_con;
const char *uuid, *iface, *master;
int choice;
choice = nmt_newt_choice_dialog (_("Cancel"),
_("Delete"),
_("Are you sure you want to delete the connection '%s'?"),
nm_connection_get_id (NM_CONNECTION (connection)));
if (choice == 1)
return;
g_object_ref (connection);
remove_one_connection (connection);
uuid = nm_connection_get_uuid (NM_CONNECTION (connection));
iface = nm_connection_get_interface_name (NM_CONNECTION (connection));
conns = nm_remote_settings_list_connections (nm_settings);
for (iter = conns; iter; iter = iter->next) {
slave = iter->data;
s_con = nm_connection_get_setting_connection (NM_CONNECTION (slave));
master = nm_setting_connection_get_master (s_con);
if (master) {
if (!g_strcmp0 (master, uuid) || !g_strcmp0 (master, iface))
remove_one_connection (slave);
}
}
g_slist_free (conns);
g_object_unref (connection);
}
NmtNewtForm *
nmtui_edit (int argc, char **argv)
{