mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 21:48:08 +02:00
cli: get rid of client-global connections list
Caching it in the NmCli object is unnecessary, ugly and would be cumbersome in future when we'll be creating the client object only when needed.
This commit is contained in:
parent
0cde514252
commit
6499bb893f
6 changed files with 67 additions and 47 deletions
|
|
@ -1217,6 +1217,7 @@ nmc_secrets_requested (NMSecretAgentSimple *agent,
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
char *path, *p;
|
char *path, *p;
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
|
const GPtrArray *connections;
|
||||||
|
|
||||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||||
nmc_terminal_erase_line ();
|
nmc_terminal_erase_line ();
|
||||||
|
|
@ -1227,7 +1228,8 @@ nmc_secrets_requested (NMSecretAgentSimple *agent,
|
||||||
p = strrchr (path, '/');
|
p = strrchr (path, '/');
|
||||||
if (p)
|
if (p)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
connection = nmc_find_connection (nmc->connections, "path", path, NULL, FALSE);
|
connections = nm_client_get_connections (nmc->client);
|
||||||
|
connection = nmc_find_connection (connections, "path", path, NULL, FALSE);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1579,6 +1579,7 @@ static GPtrArray *
|
||||||
get_invisible_active_connections (NmCli *nmc)
|
get_invisible_active_connections (NmCli *nmc)
|
||||||
{
|
{
|
||||||
const GPtrArray *acons;
|
const GPtrArray *acons;
|
||||||
|
const GPtrArray *connections;
|
||||||
GPtrArray *invisibles;
|
GPtrArray *invisibles;
|
||||||
int a, c;
|
int a, c;
|
||||||
|
|
||||||
|
|
@ -1586,13 +1587,14 @@ get_invisible_active_connections (NmCli *nmc)
|
||||||
|
|
||||||
invisibles = g_ptr_array_new ();
|
invisibles = g_ptr_array_new ();
|
||||||
acons = nm_client_get_active_connections (nmc->client);
|
acons = nm_client_get_active_connections (nmc->client);
|
||||||
|
connections = nm_client_get_connections (nmc->client);
|
||||||
for (a = 0; a < acons->len; a++) {
|
for (a = 0; a < acons->len; a++) {
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
NMActiveConnection *acon = g_ptr_array_index (acons, a);
|
NMActiveConnection *acon = g_ptr_array_index (acons, a);
|
||||||
const char *a_uuid = nm_active_connection_get_uuid (acon);
|
const char *a_uuid = nm_active_connection_get_uuid (acon);
|
||||||
|
|
||||||
for (c = 0; c < nmc->connections->len; c++) {
|
for (c = 0; c < connections->len; c++) {
|
||||||
NMConnection *con = g_ptr_array_index (nmc->connections, c);
|
NMConnection *con = g_ptr_array_index (connections, c);
|
||||||
const char *c_uuid = nm_connection_get_uuid (con);
|
const char *c_uuid = nm_connection_get_uuid (con);
|
||||||
|
|
||||||
if (strcmp (a_uuid, c_uuid) == 0) {
|
if (strcmp (a_uuid, c_uuid) == 0) {
|
||||||
|
|
@ -1671,6 +1673,7 @@ parse_preferred_connection_order (const char *order, GError **error)
|
||||||
static NMConnection *
|
static NMConnection *
|
||||||
get_connection (NmCli *nmc, int *argc, char ***argv, int *pos, GError **error)
|
get_connection (NmCli *nmc, int *argc, char ***argv, int *pos, GError **error)
|
||||||
{
|
{
|
||||||
|
const GPtrArray *connections;
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
const char *selector = NULL;
|
const char *selector = NULL;
|
||||||
|
|
||||||
|
|
@ -1694,7 +1697,8 @@ get_connection (NmCli *nmc, int *argc, char ***argv, int *pos, GError **error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connection = nmc_find_connection (nmc->connections, selector, **argv, pos,
|
connections = nm_client_get_connections (nmc->client);
|
||||||
|
connection = nmc_find_connection (connections, selector, **argv, pos,
|
||||||
*argc == 1 && nmc->complete);
|
*argc == 1 && nmc->complete);
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_NOT_FOUND,
|
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_NOT_FOUND,
|
||||||
|
|
@ -1754,6 +1758,7 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
||||||
show_secrets = nmc->show_secrets || show_secrets;
|
show_secrets = nmc->show_secrets || show_secrets;
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
|
const GPtrArray *connections;
|
||||||
char *fields_str;
|
char *fields_str;
|
||||||
char *fields_all = NMC_FIELDS_CON_SHOW_ALL;
|
char *fields_all = NMC_FIELDS_CON_SHOW_ALL;
|
||||||
char *fields_common = NMC_FIELDS_CON_SHOW_COMMON;
|
char *fields_common = NMC_FIELDS_CON_SHOW_COMMON;
|
||||||
|
|
@ -1793,7 +1798,8 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
||||||
g_ptr_array_free (invisibles, TRUE);
|
g_ptr_array_free (invisibles, TRUE);
|
||||||
|
|
||||||
/* Sort the connections and fill the output data */
|
/* Sort the connections and fill the output data */
|
||||||
sorted_cons = sort_connections (nmc->connections, nmc, order);
|
connections = nm_client_get_connections (nmc->client);
|
||||||
|
sorted_cons = sort_connections (connections, nmc, order);
|
||||||
for (i = 0; i < sorted_cons->len; i++)
|
for (i = 0; i < sorted_cons->len; i++)
|
||||||
fill_output_connection (sorted_cons->pdata[i], nmc, active_only);
|
fill_output_connection (sorted_cons->pdata[i], nmc, active_only);
|
||||||
g_ptr_array_free (sorted_cons, TRUE);
|
g_ptr_array_free (sorted_cons, TRUE);
|
||||||
|
|
@ -1816,6 +1822,7 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
||||||
nmc->required_fields = NULL;
|
nmc->required_fields = NULL;
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
|
const GPtrArray *connections;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
NMConnection *con;
|
NMConnection *con;
|
||||||
NMActiveConnection *acon = NULL;
|
NMActiveConnection *acon = NULL;
|
||||||
|
|
@ -1837,11 +1844,12 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to find connection by id, uuid or path first */
|
/* Try to find connection by id, uuid or path first */
|
||||||
con = nmc_find_connection (nmc->connections, selector, *argv, &pos,
|
connections = nm_client_get_connections (nmc->client);
|
||||||
|
con = nmc_find_connection (connections, selector, *argv, &pos,
|
||||||
argc == 1 && nmc->complete);
|
argc == 1 && nmc->complete);
|
||||||
if (!con && (!selector || strcmp (selector, "apath") == 0)) {
|
if (!con && (!selector || strcmp (selector, "apath") == 0)) {
|
||||||
/* Try apath too */
|
/* Try apath too */
|
||||||
acon = find_active_connection (active_cons, nmc->connections, "apath", *argv, NULL,
|
acon = find_active_connection (active_cons, connections, "apath", *argv, NULL,
|
||||||
argc == 1 && nmc->complete);
|
argc == 1 && nmc->complete);
|
||||||
if (acon)
|
if (acon)
|
||||||
con = NM_CONNECTION (nm_active_connection_get_connection (acon));
|
con = NM_CONNECTION (nm_active_connection_get_connection (acon));
|
||||||
|
|
@ -2784,6 +2792,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
|
||||||
/* Get active connections */
|
/* Get active connections */
|
||||||
active_cons = nm_client_get_active_connections (nmc->client);
|
active_cons = nm_client_get_active_connections (nmc->client);
|
||||||
while (arg_num > 0) {
|
while (arg_num > 0) {
|
||||||
|
const GPtrArray *connections;
|
||||||
const char *selector = NULL;
|
const char *selector = NULL;
|
||||||
|
|
||||||
if (arg_num == 1)
|
if (arg_num == 1)
|
||||||
|
|
@ -2802,7 +2811,8 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
active = find_active_connection (active_cons, nmc->connections, selector, *arg_ptr, &idx,
|
connections = nm_client_get_connections (nmc->client);
|
||||||
|
active = find_active_connection (active_cons, connections, selector, *arg_ptr, &idx,
|
||||||
arg_num == 1 && nmc->complete);
|
arg_num == 1 && nmc->complete);
|
||||||
if (active) {
|
if (active) {
|
||||||
/* Check if the connection is unique. */
|
/* Check if the connection is unique. */
|
||||||
|
|
@ -3522,19 +3532,22 @@ unique_master_iface_ifname (const GPtrArray *connections,
|
||||||
static void
|
static void
|
||||||
set_default_interface_name (NmCli *nmc, NMSettingConnection *s_con)
|
set_default_interface_name (NmCli *nmc, NMSettingConnection *s_con)
|
||||||
{
|
{
|
||||||
|
const GPtrArray *connections;
|
||||||
char *ifname = NULL;
|
char *ifname = NULL;
|
||||||
const char *con_type = nm_setting_connection_get_connection_type (s_con);
|
const char *con_type = nm_setting_connection_get_connection_type (s_con);
|
||||||
|
|
||||||
if (nm_setting_connection_get_interface_name (s_con))
|
if (nm_setting_connection_get_interface_name (s_con))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
connections = nm_client_get_connections (nmc->client);
|
||||||
|
|
||||||
/* Set a sensible bond/team/bridge interface name by default */
|
/* Set a sensible bond/team/bridge interface name by default */
|
||||||
if (g_strcmp0 (con_type, NM_SETTING_BOND_SETTING_NAME) == 0)
|
if (g_strcmp0 (con_type, NM_SETTING_BOND_SETTING_NAME) == 0)
|
||||||
ifname = unique_master_iface_ifname (nmc->connections, "nm-bond");
|
ifname = unique_master_iface_ifname (connections, "nm-bond");
|
||||||
else if (g_strcmp0 (con_type, NM_SETTING_TEAM_SETTING_NAME) == 0)
|
else if (g_strcmp0 (con_type, NM_SETTING_TEAM_SETTING_NAME) == 0)
|
||||||
ifname = unique_master_iface_ifname (nmc->connections, "nm-team");
|
ifname = unique_master_iface_ifname (connections, "nm-team");
|
||||||
else if (g_strcmp0 (con_type, NM_SETTING_BRIDGE_SETTING_NAME) == 0)
|
else if (g_strcmp0 (con_type, NM_SETTING_BRIDGE_SETTING_NAME) == 0)
|
||||||
ifname = unique_master_iface_ifname (nmc->connections, "nm-bridge");
|
ifname = unique_master_iface_ifname (connections, "nm-bridge");
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -3880,16 +3893,16 @@ gen_func_master_ifnames (const char *text, int state)
|
||||||
NMConnection *con;
|
NMConnection *con;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
const char *con_type, *ifname;
|
const char *con_type, *ifname;
|
||||||
|
const GPtrArray *connections;
|
||||||
|
|
||||||
if (!nm_cli.connections)
|
connections = nm_client_get_connections (nm_cli.client);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Disable appending space after completion */
|
/* Disable appending space after completion */
|
||||||
rl_completion_append_character = '\0';
|
rl_completion_append_character = '\0';
|
||||||
|
|
||||||
ifnames = g_ptr_array_sized_new (20);
|
ifnames = g_ptr_array_sized_new (20);
|
||||||
for (i = 0; i < nm_cli.connections->len; i++) {
|
for (i = 0; i < connections->len; i++) {
|
||||||
con = NM_CONNECTION (nm_cli.connections->pdata[i]);
|
con = NM_CONNECTION (connections->pdata[i]);
|
||||||
s_con = nm_connection_get_setting_connection (con);
|
s_con = nm_connection_get_setting_connection (con);
|
||||||
g_assert (s_con);
|
g_assert (s_con);
|
||||||
con_type = nm_setting_connection_get_connection_type (s_con);
|
con_type = nm_setting_connection_get_connection_type (s_con);
|
||||||
|
|
@ -3992,6 +4005,7 @@ set_connection_iface (NmCli *nmc, NMConnection *con, OptionInfo *option, const c
|
||||||
static gboolean
|
static gboolean
|
||||||
set_connection_master (NmCli *nmc, NMConnection *con, OptionInfo *option, const char *value, GError **error)
|
set_connection_master (NmCli *nmc, NMConnection *con, OptionInfo *option, const char *value, GError **error)
|
||||||
{
|
{
|
||||||
|
const GPtrArray *connections;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
const char *slave_type;
|
const char *slave_type;
|
||||||
|
|
||||||
|
|
@ -4005,7 +4019,8 @@ set_connection_master (NmCli *nmc, NMConnection *con, OptionInfo *option, const
|
||||||
}
|
}
|
||||||
|
|
||||||
slave_type = nm_setting_connection_get_slave_type (s_con);
|
slave_type = nm_setting_connection_get_slave_type (s_con);
|
||||||
value = normalized_master_for_slave (nmc->connections, value, slave_type, &slave_type);
|
connections = nm_client_get_connections (nmc->client);
|
||||||
|
value = normalized_master_for_slave (connections, value, slave_type, &slave_type);
|
||||||
|
|
||||||
if (!set_property (con, NM_SETTING_CONNECTION_SETTING_NAME,
|
if (!set_property (con, NM_SETTING_CONNECTION_SETTING_NAME,
|
||||||
NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type,
|
NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type,
|
||||||
|
|
@ -4944,9 +4959,12 @@ read_properties:
|
||||||
/* If only bother when there's a type, which is not guaranteed at this point.
|
/* If only bother when there's a type, which is not guaranteed at this point.
|
||||||
* Otherwise the validation will fail anyway. */
|
* Otherwise the validation will fail anyway. */
|
||||||
if (type) {
|
if (type) {
|
||||||
|
const GPtrArray *connections;
|
||||||
|
|
||||||
|
connections = nm_client_get_connections (nmc->client);
|
||||||
try_name = ifname ? g_strdup_printf ("%s-%s", get_name_alias (type, slave_type, nmc_valid_connection_types), ifname)
|
try_name = ifname ? g_strdup_printf ("%s-%s", get_name_alias (type, slave_type, nmc_valid_connection_types), ifname)
|
||||||
: g_strdup (get_name_alias (type, slave_type, nmc_valid_connection_types));
|
: g_strdup (get_name_alias (type, slave_type, nmc_valid_connection_types));
|
||||||
default_name = nmc_unique_connection_name (nmc->connections, try_name);
|
default_name = nmc_unique_connection_name (connections, try_name);
|
||||||
g_free (try_name);
|
g_free (try_name);
|
||||||
g_object_set (s_con, NM_SETTING_CONNECTION_ID, default_name, NULL);
|
g_object_set (s_con, NM_SETTING_CONNECTION_ID, default_name, NULL);
|
||||||
g_free (default_name);
|
g_free (default_name);
|
||||||
|
|
@ -5004,12 +5022,14 @@ finish:
|
||||||
static void
|
static void
|
||||||
uuid_display_hook (char **array, int len, int max_len)
|
uuid_display_hook (char **array, int len, int max_len)
|
||||||
{
|
{
|
||||||
|
const GPtrArray *connections;
|
||||||
NMConnection *con;
|
NMConnection *con;
|
||||||
int i, max = 0;
|
int i, max = 0;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
const char *id;
|
const char *id;
|
||||||
for (i = 1; i <= len; i++) {
|
for (i = 1; i <= len; i++) {
|
||||||
con = nmc_find_connection (nmc_tab_completion.nmc->connections, "uuid", array[i], NULL, FALSE);
|
connections = nm_client_get_connections (nmc_tab_completion.nmc->client);
|
||||||
|
con = nmc_find_connection (connections, "uuid", array[i], NULL, FALSE);
|
||||||
id = con ? nm_connection_get_id (con) : NULL;
|
id = con ? nm_connection_get_id (con) : NULL;
|
||||||
if (id) {
|
if (id) {
|
||||||
tmp = g_strdup_printf ("%s (%s)", array[i], id);
|
tmp = g_strdup_printf ("%s (%s)", array[i], id);
|
||||||
|
|
@ -5313,10 +5333,11 @@ _create_vpn_array (const GPtrArray *connections, gboolean uuid)
|
||||||
static char *
|
static char *
|
||||||
gen_vpn_uuids (const char *text, int state)
|
gen_vpn_uuids (const char *text, int state)
|
||||||
{
|
{
|
||||||
const GPtrArray *connections = nm_cli.connections;
|
const GPtrArray *connections;
|
||||||
const char **uuids;
|
const char **uuids;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
|
connections = nm_client_get_connections (nm_cli.client);
|
||||||
if (connections->len < 1)
|
if (connections->len < 1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -5329,10 +5350,11 @@ gen_vpn_uuids (const char *text, int state)
|
||||||
static char *
|
static char *
|
||||||
gen_vpn_ids (const char *text, int state)
|
gen_vpn_ids (const char *text, int state)
|
||||||
{
|
{
|
||||||
const GPtrArray *connections = nm_cli.connections;
|
const GPtrArray *connections;
|
||||||
const char **ids;
|
const char **ids;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
|
connections = nm_client_get_connections (nm_cli.client);
|
||||||
if (connections->len < 1)
|
if (connections->len < 1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -7783,6 +7805,7 @@ editor_init_existing_connection (NMConnection *connection)
|
||||||
static NMCResultCode
|
static NMCResultCode
|
||||||
do_connection_edit (NmCli *nmc, int argc, char **argv)
|
do_connection_edit (NmCli *nmc, int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
const GPtrArray *connections;
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
const char *connection_type;
|
const char *connection_type;
|
||||||
|
|
@ -7829,6 +7852,8 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
|
||||||
/* Use ' ' and '.' as word break characters */
|
/* Use ' ' and '.' as word break characters */
|
||||||
rl_completer_word_break_characters = ". ";
|
rl_completer_word_break_characters = ". ";
|
||||||
|
|
||||||
|
connections = nm_client_get_connections (nmc->client);
|
||||||
|
|
||||||
if (!con) {
|
if (!con) {
|
||||||
if (con_id && !con_uuid && !con_path) {
|
if (con_id && !con_uuid && !con_path) {
|
||||||
con = con_id;
|
con = con_id;
|
||||||
|
|
@ -7853,7 +7878,7 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
|
||||||
/* Existing connection */
|
/* Existing connection */
|
||||||
NMConnection *found_con;
|
NMConnection *found_con;
|
||||||
|
|
||||||
found_con = nmc_find_connection (nmc->connections, selector, con, NULL, FALSE);
|
found_con = nmc_find_connection (connections, selector, con, NULL, FALSE);
|
||||||
if (!found_con) {
|
if (!found_con) {
|
||||||
g_string_printf (nmc->return_text, _("Error: Unknown connection '%s'."), con);
|
g_string_printf (nmc->return_text, _("Error: Unknown connection '%s'."), con);
|
||||||
nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND;
|
nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND;
|
||||||
|
|
@ -7911,7 +7936,7 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
|
||||||
if (con_name)
|
if (con_name)
|
||||||
default_name = g_strdup (con_name);
|
default_name = g_strdup (con_name);
|
||||||
else
|
else
|
||||||
default_name = nmc_unique_connection_name (nmc->connections,
|
default_name = nmc_unique_connection_name (connections,
|
||||||
get_name_alias (connection_type, NULL, nmc_valid_connection_types));
|
get_name_alias (connection_type, NULL, nmc_valid_connection_types));
|
||||||
|
|
||||||
g_object_set (s_con,
|
g_object_set (s_con,
|
||||||
|
|
@ -8344,14 +8369,15 @@ do_connection_monitor (NmCli *nmc, int argc, char **argv)
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
/* No connections specified. Monitor all. */
|
/* No connections specified. Monitor all. */
|
||||||
|
const GPtrArray *connections;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* nmc_do_cmd() should not call this with argc=0. */
|
/* nmc_do_cmd() should not call this with argc=0. */
|
||||||
g_assert (!nmc->complete);
|
g_assert (!nmc->complete);
|
||||||
|
|
||||||
nmc->connections = nm_client_get_connections (nmc->client);
|
connections = nm_client_get_connections (nmc->client);
|
||||||
for (i = 0; i < nmc->connections->len; i++)
|
for (i = 0; i < connections->len; i++)
|
||||||
connection_watch (nmc, g_ptr_array_index (nmc->connections, i));
|
connection_watch (nmc, g_ptr_array_index (connections, i));
|
||||||
|
|
||||||
/* We'll watch the connection additions too, never exit. */
|
/* We'll watch the connection additions too, never exit. */
|
||||||
nmc->should_wait++;
|
nmc->should_wait++;
|
||||||
|
|
@ -8688,23 +8714,22 @@ static char *
|
||||||
gen_func_connection_names (const char *text, int state)
|
gen_func_connection_names (const char *text, int state)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char **connections;
|
const GPtrArray *connections;
|
||||||
|
const char **connection_names;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
if (nm_cli.connections->len == 0)
|
connections = nm_client_get_connections (nm_cli.client);
|
||||||
|
if (connections->len == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
connections = g_new (const char *, nm_cli.connections->len + 1);
|
connection_names = g_new (const char *, connections->len + 1);
|
||||||
for (i = 0; i < nm_cli.connections->len; i++) {
|
for (i = 0; i < connections->len; i++)
|
||||||
NMConnection *con = NM_CONNECTION (nm_cli.connections->pdata[i]);
|
connection_names[i] = nm_connection_get_id (NM_CONNECTION (connections->pdata[i]));
|
||||||
const char *id = nm_connection_get_id (con);
|
connection_names[i] = NULL;
|
||||||
connections[i] = id;
|
|
||||||
}
|
|
||||||
connections[i] = NULL;
|
|
||||||
|
|
||||||
ret = nmc_rl_gen_func_basic (text, state, connections);
|
ret = nmc_rl_gen_func_basic (text, state, connection_names);
|
||||||
|
|
||||||
g_free (connections);
|
g_free (connection_names);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8809,9 +8834,6 @@ do_connections (NmCli *nmc, int argc, char **argv)
|
||||||
return nmc->return_value;
|
return nmc->return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the connection list */
|
|
||||||
nmc->connections = nm_client_get_connections (nmc->client);
|
|
||||||
|
|
||||||
return nmc_do_cmd (nmc, connection_cmds, *argv, argc, argv);
|
return nmc_do_cmd (nmc, connection_cmds, *argv, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1856,8 +1856,6 @@ do_device_connect (NmCli *nmc, int argc, char **argv)
|
||||||
nmc->nowait_flag = (nmc->timeout == 0);
|
nmc->nowait_flag = (nmc->timeout == 0);
|
||||||
nmc->should_wait++;
|
nmc->should_wait++;
|
||||||
|
|
||||||
nmc->connections = nm_client_get_connections (nmc->client);
|
|
||||||
|
|
||||||
/* Create secret agent */
|
/* Create secret agent */
|
||||||
nmc->secret_agent = nm_secret_agent_simple_new ("nmcli-connect");
|
nmc->secret_agent = nm_secret_agent_simple_new ("nmcli-connect");
|
||||||
if (nmc->secret_agent) {
|
if (nmc->secret_agent) {
|
||||||
|
|
|
||||||
|
|
@ -541,8 +541,6 @@ nmc_init (NmCli *nmc)
|
||||||
|
|
||||||
nmc->timeout = -1;
|
nmc->timeout = -1;
|
||||||
|
|
||||||
nmc->connections = NULL;
|
|
||||||
|
|
||||||
nmc->secret_agent = NULL;
|
nmc->secret_agent = NULL;
|
||||||
nmc->pwds_hash = NULL;
|
nmc->pwds_hash = NULL;
|
||||||
nmc->pk_listener = NULL;
|
nmc->pk_listener = NULL;
|
||||||
|
|
|
||||||
|
|
@ -139,8 +139,6 @@ typedef struct _NmCli {
|
||||||
|
|
||||||
int timeout; /* Operation timeout */
|
int timeout; /* Operation timeout */
|
||||||
|
|
||||||
const GPtrArray *connections; /* List of connections */
|
|
||||||
|
|
||||||
NMSecretAgentOld *secret_agent; /* Secret agent */
|
NMSecretAgentOld *secret_agent; /* Secret agent */
|
||||||
GHashTable *pwds_hash; /* Hash table with passwords in passwd-file */
|
GHashTable *pwds_hash; /* Hash table with passwords in passwd-file */
|
||||||
NMPolkitListener *pk_listener ; /* polkit agent listener */
|
NMPolkitListener *pk_listener ; /* polkit agent listener */
|
||||||
|
|
|
||||||
|
|
@ -3355,19 +3355,21 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_con_allowed_slave_type, con_valid_slave_ty
|
||||||
static gboolean
|
static gboolean
|
||||||
nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, const char *val, GError **error)
|
nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||||
{
|
{
|
||||||
|
const GPtrArray *connections;
|
||||||
NMConnection *con;
|
NMConnection *con;
|
||||||
char **strv = NULL, **iter;
|
char **strv = NULL, **iter;
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
connections = nm_client_get_connections (nm_cli.client);
|
||||||
strv = nmc_strsplit_set (val, " \t,", 0);
|
strv = nmc_strsplit_set (val, " \t,", 0);
|
||||||
for (iter = strv; iter && *iter; iter++) {
|
for (iter = strv; iter && *iter; iter++) {
|
||||||
if (**iter == '\0')
|
if (**iter == '\0')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (nm_utils_is_uuid (*iter)) {
|
if (nm_utils_is_uuid (*iter)) {
|
||||||
con = nmc_find_connection (nm_cli.connections, "uuid", *iter, NULL, FALSE);
|
con = nmc_find_connection (connections, "uuid", *iter, NULL, FALSE);
|
||||||
if (!con)
|
if (!con)
|
||||||
g_print (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
|
g_print (_("Warning: %s is not an UUID of any existing connection profile\n"), *iter);
|
||||||
else {
|
else {
|
||||||
|
|
@ -3379,7 +3381,7 @@ nmc_property_connection_set_secondaries (NMSetting *setting, const char *prop, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
con = nmc_find_connection (nm_cli.connections, "id", *iter, NULL, FALSE);
|
con = nmc_find_connection (connections, "id", *iter, NULL, FALSE);
|
||||||
if (!con) {
|
if (!con) {
|
||||||
g_set_error (error, 1, 0, _("'%s' is not a name of any exiting profile"), *iter);
|
g_set_error (error, 1, 0, _("'%s' is not a name of any exiting profile"), *iter);
|
||||||
g_strfreev (strv);
|
g_strfreev (strv);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue