diff --git a/callouts/tests/test-dispatcher-envp.c b/callouts/tests/test-dispatcher-envp.c index c2f1b41df7..a8c65f8413 100644 --- a/callouts/tests/test-dispatcher-envp.c +++ b/callouts/tests/test-dispatcher-envp.c @@ -25,11 +25,9 @@ #include #include -#include "nm-connection.h" -#include "nm-setting-connection.h" +#include "nm-core-internal.h" #include "nm-dispatcher-utils.h" #include "nm-dispatcher-api.h" -#include "nm-utils.h" /*******************************************/ diff --git a/clients/cli/common.c b/clients/cli/common.c index 7b6a9fc9f8..0a7541c976 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -993,7 +993,7 @@ nmc_team_check_config (const char *config, char **out_config, GError **error) /* * nmc_find_connection: - * @list: list of NMConnections to search in + * @connections: array of NMConnections to search in * @filter_type: "id", "uuid", "path" or %NULL * @filter_val: connection to find (connection name, UUID or path) * @start: where to start in @list. The location is updated so that the function @@ -1008,21 +1008,20 @@ nmc_team_check_config (const char *config, char **out_config, GError **error) * Returns: found connection, or %NULL */ NMConnection * -nmc_find_connection (GSList *list, +nmc_find_connection (const GPtrArray *connections, const char *filter_type, const char *filter_val, - GSList **start) + int *start) { NMConnection *connection; NMConnection *found = NULL; - GSList *iterator; + int i; const char *id; const char *uuid; const char *path, *path_num; - iterator = (start && *start) ? *start : list; - while (iterator) { - connection = NM_CONNECTION (iterator->data); + for (i = start ? *start : 0; i < connections->len; i++) { + connection = NM_CONNECTION (connections->pdata[i]); id = nm_connection_get_id (connection); uuid = nm_connection_get_uuid (connection); @@ -1043,17 +1042,15 @@ nmc_find_connection (GSList *list, if (!start) return connection; if (found) { - *start = iterator; + *start = i; return found; } found = connection; } - - iterator = g_slist_next (iterator); } if (start) - *start = NULL; + *start = 0; return found; } diff --git a/clients/cli/common.h b/clients/cli/common.h index a1a45e3ad3..4f43674793 100644 --- a/clients/cli/common.h +++ b/clients/cli/common.h @@ -46,10 +46,10 @@ nmc_vlan_parse_priority_maps (const char *priority_map, const char *nmc_bond_validate_mode (const char *mode, GError **error); gboolean nmc_team_check_config (const char *config, char **out_config, GError **error); -NMConnection *nmc_find_connection (GSList *list, +NMConnection *nmc_find_connection (const GPtrArray *connections, const char *filter_type, const char *filter_val, - GSList **start); + int *start); void nmc_cleanup_readline (void); char *nmc_readline (const char *prompt_fmt, ...) G_GNUC_PRINTF (1, 2); diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 5c239563bf..d9f5f295fa 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -683,7 +683,7 @@ nmc_connection_profile_details (NMConnection *connection, NmCli *nmc) static NMActiveConnection * find_active_connection (const GPtrArray *active_cons, - const GSList *cons, + const GPtrArray *cons, const char *filter_type, const char *filter_val, int *idx) @@ -905,19 +905,18 @@ static void fill_output_for_all_invisible (NmCli *nmc) { const GPtrArray *acons; - GSList *iter; - int i; + int a, c; g_return_if_fail (nmc != NULL); acons = nm_client_get_active_connections (nmc->client); - for (i = 0; i < acons->len; i++) { + for (a = 0; a < acons->len; a++) { gboolean found = FALSE; - NMActiveConnection *acon = g_ptr_array_index (acons, i); + NMActiveConnection *acon = g_ptr_array_index (acons, a); const char *a_uuid = nm_active_connection_get_uuid (acon); - for (iter = nmc->connections; iter; iter = g_slist_next (iter)) { - NMConnection *con = NM_CONNECTION (iter->data); + for (c = 0; c < nmc->connections->len; c++) { + NMConnection *con = g_ptr_array_index (nmc->connections, c); const char *c_uuid = nm_connection_get_uuid (con); if (strcmp (a_uuid, c_uuid) == 0) { @@ -1326,7 +1325,7 @@ do_connections_show (NmCli *nmc, gboolean active_only, int argc, char **argv) char *fields_common = NMC_FIELDS_CON_SHOW_COMMON; NmcOutputField *tmpl, *arr; size_t tmpl_len; - GSList *iter; + int i; if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0) fields_str = fields_common; @@ -1351,8 +1350,8 @@ do_connections_show (NmCli *nmc, gboolean active_only, int argc, char **argv) g_ptr_array_add (nmc->output_data, arr); /* Add values */ - for (iter = nmc->connections; iter; iter = g_slist_next (iter)) { - NMConnection *con = NM_CONNECTION (iter->data); + for (i = 0; i < nmc->connections->len; i++) { + NMConnection *con = NM_CONNECTION (nmc->connections->pdata[i]); fill_output_connection (con, nmc, active_only); } /* Some active connections may not be in connection list, show them here. */ @@ -1362,7 +1361,7 @@ do_connections_show (NmCli *nmc, gboolean active_only, int argc, char **argv) gboolean new_line = FALSE; gboolean without_fields = (nmc->required_fields == NULL); const GPtrArray *active_cons = nm_client_get_active_connections (nmc->client); - GSList *pos = NULL; + int pos = 0; /* multiline mode is default for 'connection show ' */ if (!nmc->mode_specified) @@ -2680,25 +2679,25 @@ add_ip6_address_to_connection (NMIP6Address *ip6addr, NMConnection *connection) } static char * -unique_master_iface_ifname (GSList *list, +unique_master_iface_ifname (const GPtrArray *connections, const char *try_name) { NMConnection *connection; char *new_name; unsigned int num = 1; - GSList *iterator = list; + int i = 0; const char *ifname = NULL; new_name = g_strdup (try_name); - while (iterator) { - connection = NM_CONNECTION (iterator->data); + while (i < connections->len) { + connection = NM_CONNECTION (connections->pdata[i]); ifname = nm_connection_get_interface_name (connection); if (g_strcmp0 (new_name, ifname) == 0) { g_free (new_name); new_name = g_strdup_printf ("%s%d", try_name, num++); - iterator = list; + i = 0; } else - iterator = g_slist_next (iterator); + i++; } return new_name; } @@ -2737,14 +2736,14 @@ _strip_master_prefix (const char *master, const char *(**func)(NMConnection *)) * Returns: identifier of master connection if found, %NULL otherwise */ static const char * -verify_master_for_slave (GSList *connections, +verify_master_for_slave (const GPtrArray *connections, const char *master, const char *type) { NMConnection *connection; NMSettingConnection *s_con; const char *con_type, *id, *uuid, *ifname; - GSList *iterator = connections; + int i; const char *found_by_id = NULL; const char *out_master = NULL; const char *(*func) (NMConnection *) = NULL; @@ -2753,15 +2752,13 @@ verify_master_for_slave (GSList *connections, return NULL; master = _strip_master_prefix (master, &func); - while (iterator) { - connection = NM_CONNECTION (iterator->data); + for (i = 0; i < connections->len; i++) { + connection = NM_CONNECTION (connections->pdata[i]); s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); con_type = nm_setting_connection_get_connection_type (s_con); - if (g_strcmp0 (con_type, type) != 0) { - iterator = g_slist_next (iterator); + if (g_strcmp0 (con_type, type) != 0) continue; - } if (func) { /* There was a prefix; only compare to that type. */ if (g_strcmp0 (master, func (connection)) == 0) { @@ -2783,8 +2780,6 @@ verify_master_for_slave (GSList *connections, if (!found_by_id && g_strcmp0 (master, id) == 0) found_by_id = uuid; } - - iterator = g_slist_next (iterator); } return out_master ? out_master : found_by_id; } @@ -3633,7 +3628,7 @@ do_questionnaire_ip (NMConnection *connection) static gboolean complete_connection_by_type (NMConnection *connection, const char *con_type, - GSList *all_connections, + const GPtrArray *all_connections, gboolean ask, int argc, char **argv, @@ -4917,25 +4912,25 @@ cleanup_olpc: } static char * -unique_connection_name (GSList *list, const char *try_name) +unique_connection_name (const GPtrArray *connections, const char *try_name) { NMConnection *connection; const char *name; char *new_name; unsigned int num = 1; - GSList *iterator = list; + int i = 0; new_name = g_strdup (try_name); - while (iterator) { - connection = NM_CONNECTION (iterator->data); + while (i < connections->len) { + connection = NM_CONNECTION (connections->pdata[i]); name = nm_connection_get_id (connection); if (g_strcmp0 (new_name, name) == 0) { g_free (new_name); new_name = g_strdup_printf ("%s-%d", try_name, num++); - iterator = list; - } - iterator = g_slist_next (iterator); + i = 0; + } else + i++; } return new_name; } @@ -5039,7 +5034,7 @@ gen_func_bond_mon_mode (const char *text, int state) static char * gen_func_master_ifnames (const char *text, int state) { - GSList *iter; + int i; GPtrArray *ifnames; char *ret; NMConnection *con; @@ -5053,8 +5048,8 @@ gen_func_master_ifnames (const char *text, int state) rl_completion_append_character = '\0'; ifnames = g_ptr_array_sized_new (20); - for (iter = nm_cli.connections; iter; iter = g_slist_next (iter)) { - con = NM_CONNECTION (iter->data); + for (i = 0; i < nm_cli.connections->len; i++) { + con = NM_CONNECTION (nm_cli.connections->pdata[i]); s_con = nm_connection_get_setting_connection (con); g_assert (s_con); con_type = nm_setting_connection_get_connection_type (s_con); @@ -5566,24 +5561,23 @@ gen_compat_devices (const char *text, int state) static char * gen_vpn_uuids (const char *text, int state) { - GSList *iter; - guint len; - int i = 0; + const GPtrArray *connections = nmc_tab_completion.nmc->connections; + int c, u = 0; const char **uuids; char *ret; - len = g_slist_length (nmc_tab_completion.nmc->connections); - if (len < 1) + if (connections->len < 1) return NULL; - uuids = g_new (const char *, len + 1); - for (iter = nmc_tab_completion.nmc->connections; iter; iter = g_slist_next (iter)) { - const char *type = nm_connection_get_connection_type (NM_CONNECTION (iter->data)); + uuids = g_new (const char *, connections->len + 1); + for (c = 0; c < connections->len; c++) { + NMConnection *connection = NM_CONNECTION (connections->pdata[c]); + const char *type = nm_connection_get_connection_type (connection); if (g_strcmp0 (type, NM_SETTING_VPN_SETTING_NAME) == 0) - uuids[i++] = nm_connection_get_uuid (NM_CONNECTION (iter->data)); + uuids[u++] = nm_connection_get_uuid (connection); } - uuids[i] = NULL; + uuids[u] = NULL; ret = nmc_rl_gen_func_basic (text, state, uuids); @@ -8235,7 +8229,7 @@ do_connection_delete (NmCli *nmc, int argc, char **argv) int arg_num = argc; GString *invalid_cons = NULL; gboolean del_info_free = FALSE; - GSList *pos = NULL; + int pos = 0; nmc->return_value = NMC_RESULT_SUCCESS; nmc->should_wait = FALSE; @@ -8421,17 +8415,16 @@ connection_editor_thread_func (gpointer data) static char * gen_func_connection_names (const char *text, int state) { - int i = 0; - GSList *iter; + int i; const char **connections; char *ret; - if (!nm_cli.connections) + if (nm_cli.connections->len == 0) return NULL; - connections = g_new (const char *, g_slist_length (nm_cli.connections) + 1); - for (iter = nm_cli.connections; iter; iter = g_slist_next (iter)) { - NMConnection *con = NM_CONNECTION (iter->data); + connections = g_new (const char *, nm_cli.connections->len + 1); + for (i = 0; i < nm_cli.connections->len; i++) { + NMConnection *con = NM_CONNECTION (nm_cli.connections->pdata[i]); const char *id = nm_connection_get_id (con); connections[i++] = id; } @@ -8500,7 +8493,7 @@ do_connections (NmCli *nmc, int argc, char **argv) return nmc->return_value; /* Get the connection list */ - nmc->connections = nm_client_list_connections (nmc->client); + nmc->connections = nm_client_get_connections (nmc->client); /* Now parse the command line and perform the required operation */ if (argc == 0) { diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index f6ca11e935..ca71abf936 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -524,8 +524,6 @@ nmc_cleanup (NmCli *nmc) g_string_free (nmc->return_text, TRUE); - g_slist_free (nmc->connections); - g_free (nmc->required_fields); nmc_empty_output_fields (nmc); g_ptr_array_unref (nmc->output_data); diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index 2d67320cbd..34beb92298 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -110,7 +110,7 @@ typedef struct _NmCli { int timeout; /* Operation timeout */ - GSList *connections; /* List of connections */ + const GPtrArray *connections; /* List of connections */ gboolean should_wait; /* Indication that nmcli should not end yet */ gboolean nowait_flag; /* '--nowait' option; used for passing to callbacks */ diff --git a/clients/tui/nm-editor-utils.c b/clients/tui/nm-editor-utils.c index e7b47e1a0d..a98278bc09 100644 --- a/clients/tui/nm-editor-utils.c +++ b/clients/tui/nm-editor-utils.c @@ -257,19 +257,19 @@ static char * get_available_connection_name (const char *format, NMClient *client) { - GSList *connections, *iter, *names = NULL; + const GPtrArray *conns; + GSList *names = NULL, *iter; char *cname = NULL; int i = 0; - connections = nm_client_list_connections (client); - for (iter = connections; iter; iter = iter->next) { + conns = nm_client_get_connections (client); + for (i = 0; i < conns->len; i++) { const char *id; - id = nm_connection_get_id (NM_CONNECTION (iter->data)); + id = nm_connection_get_id (NM_CONNECTION (conns->pdata[i])); g_assert (id); names = g_slist_append (names, (gpointer) id); } - g_slist_free (connections); /* Find the next available unique connection name */ while (!cname && (i++ < 10000)) { diff --git a/clients/tui/nmt-connect-connection-list.c b/clients/tui/nmt-connect-connection-list.c index 4b80a807ed..bd54af22cd 100644 --- a/clients/tui/nmt-connect-connection-list.c +++ b/clients/tui/nmt-connect-connection-list.c @@ -183,12 +183,12 @@ sort_connections (gconstpointer a, static void add_connections_for_device (NmtConnectDevice *nmtdev, - GSList *connections) + const GPtrArray *connections) { - GSList *iter; + int i; - for (iter = connections; iter; iter = iter->next) { - NMConnection *conn = iter->data; + for (i = 0; i < connections->len; i++) { + NMConnection *conn = connections->pdata[i]; NMSettingConnection *s_con; s_con = nm_connection_get_setting_connection (conn); @@ -257,7 +257,7 @@ hash_ap (NMAccessPoint *ap) static void add_connections_for_aps (NmtConnectDevice *nmtdev, - GSList *connections) + const GPtrArray *connections) { NmtConnectConnection *nmtconn; NMConnection *conn; @@ -266,8 +266,7 @@ add_connections_for_aps (NmtConnectDevice *nmtdev, GHashTable *seen_ssids; GBytes *ssid; char *ap_hash; - GSList *iter; - int i; + int i, c; aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (nmtdev->device)); if (!aps->len) @@ -296,8 +295,8 @@ add_connections_for_aps (NmtConnectDevice *nmtdev, nmtconn->ssid = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); - for (iter = connections; iter; iter = iter->next) { - conn = iter->data; + for (c = 0; c < connections->len; c++) { + conn = connections->pdata[c]; if ( nm_device_connection_valid (nmtdev->device, conn) && nm_access_point_connection_valid (ap, conn)) { nmtconn->name = nm_connection_get_id (conn); @@ -306,7 +305,7 @@ add_connections_for_aps (NmtConnectDevice *nmtdev, } } - if (!iter) + if (!nmtconn->name) nmtconn->name = nmtconn->ssid ? nmtconn->ssid : ""; nmtdev->conns = g_slist_prepend (nmtdev->conns, nmtconn); @@ -319,7 +318,7 @@ static GSList * append_nmt_devices_for_devices (GSList *nmt_devices, const GPtrArray *devices, char **names, - GSList *connections) + const GPtrArray *connections) { NmtConnectDevice *nmtdev; NMDevice *device; @@ -350,11 +349,11 @@ append_nmt_devices_for_devices (GSList *nmt_devices, } static GSList * -append_nmt_devices_for_virtual_devices (GSList *nmt_devices, - GSList *connections) +append_nmt_devices_for_virtual_devices (GSList *nmt_devices, + const GPtrArray *connections) { NmtConnectDevice *nmtdev = NULL; - GSList *iter; + int i; GHashTable *devices_by_name; char *name; NMConnection *conn; @@ -363,8 +362,8 @@ append_nmt_devices_for_virtual_devices (GSList *nmt_devices, devices_by_name = g_hash_table_new (g_str_hash, g_str_equal); - for (iter = connections; iter; iter = iter->next) { - conn = iter->data; + for (i = 0; i < connections->len; i++) { + conn = connections->pdata[i]; sort_order = get_sort_order_for_connection (conn); if (sort_order == -1) continue; @@ -395,11 +394,11 @@ append_nmt_devices_for_virtual_devices (GSList *nmt_devices, } static GSList * -append_nmt_devices_for_vpns (GSList *nmt_devices, - GSList *connections) +append_nmt_devices_for_vpns (GSList *nmt_devices, + const GPtrArray *connections) { NmtConnectDevice *nmtdev; - GSList *iter; + int i; NMConnection *conn; NmtConnectConnection *nmtconn; @@ -407,8 +406,8 @@ append_nmt_devices_for_vpns (GSList *nmt_devices, nmtdev->name = g_strdup (_("VPN")); nmtdev->sort_order = 100; - for (iter = connections; iter; iter = iter->next) { - conn = iter->data; + for (i = 0; i < connections->len; i++) { + conn = connections->pdata[i]; if (!nm_connection_is_type (conn, NM_SETTING_VPN_SETTING_NAME)) continue; @@ -464,11 +463,10 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list) { NmtConnectConnectionListPrivate *priv = NMT_CONNECT_CONNECTION_LIST_GET_PRIVATE (list); NmtNewtListbox *listbox = NMT_NEWT_LISTBOX (list); - const GPtrArray *devices, *acs; + const GPtrArray *devices, *acs, *connections; int max_width; char **names, *row, active_col; const char *strength_col; - GSList *connections; GSList *nmt_devices, *diter, *citer; NmtConnectDevice *nmtdev; NmtConnectConnection *nmtconn; @@ -479,7 +477,7 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list) devices = nm_client_get_devices (nm_client); acs = nm_client_get_active_connections (nm_client); - connections = nm_client_list_connections (nm_client); + connections = nm_client_get_connections (nm_client); nmt_devices = NULL; @@ -491,7 +489,6 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list) nmt_devices = append_nmt_devices_for_vpns (nmt_devices, connections); nmt_devices = g_slist_sort (nmt_devices, sort_nmt_devices); - g_slist_free (connections); max_width = 0; for (diter = nmt_devices; diter; diter = diter->next) { diff --git a/clients/tui/nmt-edit-connection-list.c b/clients/tui/nmt-edit-connection-list.c index 9afe44164f..e1b982dde9 100644 --- a/clients/tui/nmt-edit-connection-list.c +++ b/clients/tui/nmt-edit-connection-list.c @@ -83,23 +83,6 @@ static void edit_clicked (NmtNewtButton *button, gpointer list); static void delete_clicked (NmtNewtButton *button, gpointer list); static void listbox_activated (NmtNewtWidget *listbox, gpointer list); -/** - * nmt_edit_connection_list_get_connections: - * @list: an #NmtEditConnectionList - * - * Gets the list's list of connections - * - * Returns: (transfer none) (element-type #NMConnection): the - * list of connections. - */ -GSList * -nmt_edit_connection_list_get_connections (NmtEditConnectionList *list) -{ - NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE (list); - - return priv->connections; -} - static void nmt_edit_connection_list_init (NmtEditConnectionList *list) { @@ -175,13 +158,15 @@ free_connections (NmtEditConnectionList *list) g_object_unref (conn); } g_slist_free (priv->connections); + priv->connections = NULL; } static void nmt_edit_connection_list_rebuild (NmtEditConnectionList *list) { NmtEditConnectionListPrivate *priv = NMT_EDIT_CONNECTION_LIST_GET_PRIVATE (list); - GSList *iter, *next; + const GPtrArray *connections; + GSList *iter; gboolean did_header = FALSE, did_vpn = FALSE; NMEditorConnectionTypeData **types; NMConnection *conn, *selected_conn; @@ -191,20 +176,17 @@ nmt_edit_connection_list_rebuild (NmtEditConnectionList *list) selected_conn = nmt_newt_listbox_get_active_key (priv->listbox); free_connections (list); - priv->connections = nm_client_list_connections (nm_client); - for (iter = priv->connections; iter; iter = next) { - conn = iter->data; - next = iter->next; + connections = nm_client_get_connections (nm_client); + for (i = 0; i < connections->len; i++) { + conn = connections->pdata[i]; if ( priv->connection_filter - && !priv->connection_filter (list, conn, priv->connection_filter_data)) { - priv->connections = g_slist_delete_link (priv->connections, iter); + && !priv->connection_filter (list, conn, priv->connection_filter_data)) continue; - } g_signal_connect (conn, NM_CONNECTION_CHANGED, G_CALLBACK (rebuild_on_connection_changed), list); - g_object_ref (iter->data); + priv->connections = g_slist_prepend (priv->connections, g_object_ref (conn)); } priv->connections = g_slist_sort (priv->connections, sort_by_timestamp); g_object_notify (G_OBJECT (list), "connections"); diff --git a/clients/tui/nmt-edit-connection-list.h b/clients/tui/nmt-edit-connection-list.h index a359170a1b..c31c0a8cb5 100644 --- a/clients/tui/nmt-edit-connection-list.h +++ b/clients/tui/nmt-edit-connection-list.h @@ -54,8 +54,6 @@ typedef gboolean (*NmtEditConnectionListFilter) (NmtEditConnectionList *list, NMConnection *connection, gpointer user_data); -GSList *nmt_edit_connection_list_get_connections (NmtEditConnectionList *list); - G_END_DECLS #endif /* NMT_EDIT_CONNECTION_LIST_H */ diff --git a/clients/tui/nmtui-edit.c b/clients/tui/nmtui-edit.c index d32da817cd..2cc6b773aa 100644 --- a/clients/tui/nmtui-edit.c +++ b/clients/tui/nmtui-edit.c @@ -72,7 +72,8 @@ edit_connection_list_filter (NmtEditConnectionList *list, NMSettingConnection *s_con; const char *master, *slave_type; const char *uuid, *ifname; - GSList *conns, *iter; + const GPtrArray *conns; + int i; gboolean found_master = FALSE; s_con = nm_connection_get_setting_connection (connection); @@ -87,16 +88,17 @@ edit_connection_list_filter (NmtEditConnectionList *list, && g_strcmp0 (slave_type, NM_SETTING_BRIDGE_SETTING_NAME) != 0) return TRUE; - conns = nm_client_list_connections (nm_client); - for (iter = conns; iter; iter = iter->next) { - uuid = nm_connection_get_uuid (iter->data); - ifname = nm_connection_get_interface_name (iter->data); + conns = nm_client_get_connections (nm_client); + for (i = 0; i < conns->len; i++) { + NMConnection *candidate = conns->pdata[i]; + + uuid = nm_connection_get_uuid (candidate); + ifname = nm_connection_get_interface_name (candidate); if (!g_strcmp0 (master, uuid) || !g_strcmp0 (master, ifname)) { found_master = TRUE; break; } } - g_slist_free (conns); return !found_master; } @@ -513,7 +515,8 @@ remove_one_connection (NMRemoteConnection *connection) void nmt_remove_connection (NMRemoteConnection *connection) { - GSList *conns, *iter; + const GPtrArray *conns; + int i; NMRemoteConnection *slave; NMSettingConnection *s_con; const char *uuid, *iface, *master; @@ -532,9 +535,9 @@ nmt_remove_connection (NMRemoteConnection *connection) uuid = nm_connection_get_uuid (NM_CONNECTION (connection)); iface = nm_connection_get_interface_name (NM_CONNECTION (connection)); - conns = nm_client_list_connections (nm_client); - for (iter = conns; iter; iter = iter->next) { - slave = iter->data; + conns = nm_client_get_connections (nm_client); + for (i = 0; i < conns->len; i++) { + slave = conns->pdata[i]; s_con = nm_connection_get_setting_connection (NM_CONNECTION (slave)); master = nm_setting_connection_get_master (s_con); if (master) { @@ -542,7 +545,6 @@ nmt_remove_connection (NMRemoteConnection *connection) remove_one_connection (slave); } } - g_slist_free (conns); g_object_unref (connection); } diff --git a/examples/C/glib/list-connections-libnm.c b/examples/C/glib/list-connections-libnm.c index f761bfd77f..f09c028b6b 100644 --- a/examples/C/glib/list-connections-libnm.c +++ b/examples/C/glib/list-connections-libnm.c @@ -34,9 +34,8 @@ /* Print details of connection */ static void -show_connection (gpointer data, gpointer user_data) +show_connection (NMConnection *connection) { - NMConnection *connection = (NMConnection *) data; NMSettingConnection *s_con; guint64 timestamp; char *timestamp_str; @@ -67,7 +66,8 @@ main (int argc, char *argv[]) { NMClient *client; GError *error = NULL; - GSList *connections; + const GPtrArray *connections; + int i; #if !GLIB_CHECK_VERSION (2, 35, 0) /* Initialize GType system */ @@ -86,13 +86,13 @@ main (int argc, char *argv[]) } /* Now the connections can be listed. */ - connections = nm_client_list_connections (client); + connections = nm_client_get_connections (client); printf ("Connections:\n===================\n"); - g_slist_foreach (connections, show_connection, NULL); + for (i = 0; i < connections->len; i++) + show_connection (connections->pdata[i]); - g_slist_free (connections); g_object_unref (client); return EXIT_SUCCESS; diff --git a/libnm-core/Makefile.libnm-core b/libnm-core/Makefile.libnm-core index c79665e9f5..481fc806ac 100644 --- a/libnm-core/Makefile.libnm-core +++ b/libnm-core/Makefile.libnm-core @@ -9,6 +9,7 @@ libnm_core_headers = \ $(core_build)/nm-core-enum-types.h \ $(core_build)/nm-version.h \ $(core)/nm-connection.h \ + $(core)/nm-core-types.h \ $(core)/nm-dbus-interface.h \ $(core)/nm-errors.h \ $(core)/nm-setting-8021x.h \ @@ -44,6 +45,7 @@ libnm_core_headers = \ libnm_core_private_headers = \ $(core)/crypto.h \ + $(core)/nm-connection-private.h \ $(core)/nm-core-internal.h \ $(core)/nm-property-compare.h \ $(core)/nm-setting-private.h \ diff --git a/libnm-core/nm-connection-private.h b/libnm-core/nm-connection-private.h new file mode 100644 index 0000000000..620e6a81ec --- /dev/null +++ b/libnm-core/nm-connection-private.h @@ -0,0 +1,35 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#ifndef __NM_CONNECTION_PRIVATE_H__ +#define __NM_CONNECTION_PRIVATE_H__ + +#include "nm-setting.h" +#include "nm-connection.h" + +NMSetting *_nm_connection_find_base_type_setting (NMConnection *connection); + +const char *_nm_connection_detect_slave_type (NMConnection *connection, + NMSetting **out_s_port); + +gboolean _nm_connection_verify_required_interface_name (NMConnection *connection, + GError **error); + +#endif /* __NM_CONNECTION_PRIVATE_H__ */ diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 3429ec2232..a6789b3195 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -24,34 +24,10 @@ #include #include #include "nm-connection.h" +#include "nm-connection-private.h" #include "nm-utils.h" #include "nm-setting-private.h" - -#include "nm-setting-8021x.h" -#include "nm-setting-bluetooth.h" -#include "nm-setting-connection.h" -#include "nm-setting-infiniband.h" -#include "nm-setting-ip4-config.h" -#include "nm-setting-ip6-config.h" -#include "nm-setting-ppp.h" -#include "nm-setting-pppoe.h" -#include "nm-setting-wimax.h" -#include "nm-setting-wired.h" -#include "nm-setting-adsl.h" -#include "nm-setting-wireless.h" -#include "nm-setting-wireless-security.h" -#include "nm-setting-serial.h" -#include "nm-setting-vpn.h" -#include "nm-setting-olpc-mesh.h" -#include "nm-setting-bond.h" -#include "nm-setting-team.h" -#include "nm-setting-team-port.h" -#include "nm-setting-bridge.h" -#include "nm-setting-bridge-port.h" -#include "nm-setting-vlan.h" -#include "nm-setting-serial.h" -#include "nm-setting-gsm.h" -#include "nm-setting-cdma.h" +#include "nm-core-internal.h" /** * SECTION:nm-connection @@ -525,13 +501,35 @@ nm_connection_diff (NMConnection *a, return *out_settings ? FALSE : TRUE; } +NMSetting * +_nm_connection_find_base_type_setting (NMConnection *connection) +{ + NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection); + GHashTableIter iter; + NMSetting *setting = NULL, *s_iter; + + g_hash_table_iter_init (&iter, priv->settings); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &s_iter)) { + if (!_nm_setting_is_base_type (s_iter)) + continue; + + if (setting) { + /* FIXME: currently, if there is more than one matching base type, + * we cannot detect the base setting. + * See: https://bugzilla.gnome.org/show_bug.cgi?id=696936#c8 */ + return NULL; + } + setting = s_iter; + } + return setting; +} + static gboolean _normalize_connection_type (NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection (self); NMSetting *s_base = NULL; const char *type; - GSList *all_settings; type = nm_setting_connection_get_connection_type (s_con); @@ -546,26 +544,57 @@ _normalize_connection_type (NMConnection *self) return TRUE; } } else { - all_settings = _nm_utils_hash_values_to_slist (NM_CONNECTION_GET_PRIVATE (self)->settings); - - s_base = _nm_setting_find_in_list_base_type (all_settings); + s_base = _nm_connection_find_base_type_setting (self); g_return_val_if_fail (s_base, FALSE); type = nm_setting_get_name (s_base); g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, type, NULL); - g_slist_free (all_settings); return TRUE; } return FALSE; } +const char * +_nm_connection_detect_slave_type (NMConnection *connection, NMSetting **out_s_port) +{ + NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection); + GHashTableIter iter; + const char *slave_type = NULL; + NMSetting *s_port = NULL, *s_iter; + + g_hash_table_iter_init (&iter, priv->settings); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &s_iter)) { + const char *name = nm_setting_get_name (s_iter); + const char *i_slave_type = NULL; + + if (!strcmp (name, NM_SETTING_BRIDGE_PORT_SETTING_NAME)) + i_slave_type = NM_SETTING_BRIDGE_SETTING_NAME; + else if (!strcmp (name, NM_SETTING_TEAM_PORT_SETTING_NAME)) + i_slave_type = NM_SETTING_TEAM_SETTING_NAME; + else + continue; + + if (slave_type) { + /* there are more then one matching port types, cannot detect the slave type. */ + slave_type = NULL; + s_port = NULL; + break; + } + slave_type = i_slave_type; + s_port = s_iter; + } + + if (out_s_port) + *out_s_port = s_port; + return slave_type; +} + static gboolean _normalize_connection_slave_type (NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection (self); const char *slave_type, *port_type; - GSList *all_settings; if (!s_con) return FALSE; @@ -588,14 +617,10 @@ _normalize_connection_slave_type (NMConnection *self) } } } else { - all_settings = _nm_utils_hash_values_to_slist (NM_CONNECTION_GET_PRIVATE (self)->settings); - - if ((slave_type = _nm_setting_slave_type_detect_from_settings (all_settings, NULL))) { + if ((slave_type = _nm_connection_detect_slave_type (self, NULL))) { g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, slave_type, NULL); - g_slist_free (all_settings); return TRUE; } - g_slist_free (all_settings); } return FALSE; } @@ -746,8 +771,7 @@ _nm_connection_verify (NMConnection *connection, GError **error) /* Order NMSettingConnection so that it will be verified first. * The reason is, that errors in this setting might be more fundamental * and should be checked and reported with higher priority. - * Another reason is, that some settings look especially at the - * NMSettingConnection, so they find it first in the all_settings list. */ + */ if (value == s_con) all_settings = g_slist_append (all_settings, value); else @@ -767,7 +791,7 @@ _nm_connection_verify (NMConnection *connection, GError **error) * @NM_SETTING_VERIFY_NORMALIZABLE, so, if we encounter such an error type, * we remember it instead (to return it as output). **/ - verify_result = _nm_setting_verify (NM_SETTING (setting_i->data), all_settings, &verify_error); + verify_result = _nm_setting_verify (NM_SETTING (setting_i->data), connection, &verify_error); if (verify_result == NM_SETTING_VERIFY_NORMALIZABLE || verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR) { if ( verify_result == NM_SETTING_VERIFY_NORMALIZABLE_ERROR @@ -1359,6 +1383,24 @@ nm_connection_get_interface_name (NMConnection *connection) return s_con ? nm_setting_connection_get_interface_name (s_con) : NULL; } +gboolean +_nm_connection_verify_required_interface_name (NMConnection *connection, + GError **error) +{ + const char *interface_name; + + interface_name = nm_connection_get_interface_name (connection); + if (interface_name) + return TRUE; + + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("property is missing")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME); + return FALSE; +} + /** * nm_connection_get_uuid: * @connection: the #NMConnection diff --git a/libnm-core/nm-connection.h b/libnm-core/nm-connection.h index 28254c33fa..ec5db7fa2b 100644 --- a/libnm-core/nm-connection.h +++ b/libnm-core/nm-connection.h @@ -27,38 +27,10 @@ #error "Only can be included directly." #endif -#include -#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - G_BEGIN_DECLS #define NM_TYPE_CONNECTION (nm_connection_get_type ()) @@ -84,7 +56,6 @@ G_BEGIN_DECLS * NMConnection is the interface implemented by #NMRemoteConnection on the * client side, and #NMSettingsConnection on the daemon side. */ -typedef struct _NMConnection NMConnection; typedef struct { GTypeInterface parent; diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index 6a3130ed8b..48295f7821 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -33,11 +33,40 @@ * and some test programs. **/ -#include - -#include "nm-utils.h" - +#include "nm-connection.h" +#include "nm-core-enum-types.h" +#include "nm-dbus-interface.h" +#include "nm-setting-8021x.h" +#include "nm-setting-adsl.h" +#include "nm-setting-bluetooth.h" +#include "nm-setting-bond.h" +#include "nm-setting-bridge-port.h" +#include "nm-setting-bridge.h" +#include "nm-setting-cdma.h" +#include "nm-setting-connection.h" +#include "nm-setting-dcb.h" +#include "nm-setting-generic.h" +#include "nm-setting-gsm.h" +#include "nm-setting-infiniband.h" #include "nm-setting-ip4-config.h" +#include "nm-setting-ip6-config.h" +#include "nm-setting-olpc-mesh.h" +#include "nm-setting-ppp.h" +#include "nm-setting-pppoe.h" +#include "nm-setting-serial.h" +#include "nm-setting-team-port.h" +#include "nm-setting-team.h" +#include "nm-setting-vlan.h" +#include "nm-setting-vpn.h" +#include "nm-setting-wimax.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless-security.h" +#include "nm-setting-wireless.h" +#include "nm-setting.h" +#include "nm-simple-connection.h" +#include "nm-utils.h" +#include "nm-version.h" +#include "nm-vpn-dbus-interface.h" const char *_nm_setting_ip4_config_get_address_label (NMSettingIP4Config *setting, guint32 i); diff --git a/libnm-core/nm-core-types.h b/libnm-core/nm-core-types.h new file mode 100644 index 0000000000..a6fc529fae --- /dev/null +++ b/libnm-core/nm-core-types.h @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* NetworkManager -- Network link manager + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright 2014 Red Hat, Inc. + */ + +#ifndef __NM_CORE_TYPES_H__ +#define __NM_CORE_TYPES_H__ + +#include + +#include +#include + +typedef struct _NMConnection NMConnection; +typedef struct _NMSetting NMSetting; +typedef struct _NMSetting8021x NMSetting8021x; +typedef struct _NMSettingAdsl NMSettingAdsl; +typedef struct _NMSettingBluetooth NMSettingBluetooth; +typedef struct _NMSettingBond NMSettingBond; +typedef struct _NMSettingBridge NMSettingBridge; +typedef struct _NMSettingBridgePort NMSettingBridgePort; +typedef struct _NMSettingCdma NMSettingCdma; +typedef struct _NMSettingConnection NMSettingConnection; +typedef struct _NMSettingDcb NMSettingDcb; +typedef struct _NMSettingGeneric NMSettingGeneric; +typedef struct _NMSettingGsm NMSettingGsm; +typedef struct _NMSettingInfiniband NMSettingInfiniband; +typedef struct _NMSettingIP4Config NMSettingIP4Config; +typedef struct _NMSettingIP6Config NMSettingIP6Config; +typedef struct _NMSettingOlpcMesh NMSettingOlpcMesh; +typedef struct _NMSettingPpp NMSettingPpp; +typedef struct _NMSettingPppoe NMSettingPppoe; +typedef struct _NMSettingSerial NMSettingSerial; +typedef struct _NMSettingTeam NMSettingTeam; +typedef struct _NMSettingTeamPort NMSettingTeamPort; +typedef struct _NMSettingVlan NMSettingVlan; +typedef struct _NMSettingVpn NMSettingVpn; +typedef struct _NMSettingWimax NMSettingWimax; +typedef struct _NMSettingWired NMSettingWired; +typedef struct _NMSettingWireless NMSettingWireless; +typedef struct _NMSettingWirelessSecurity NMSettingWirelessSecurity; +typedef struct _NMSimpleConnection NMSimpleConnection; + +#endif /* __NM_CORE_TYPES_H__ */ diff --git a/libnm-core/nm-setting-8021x.c b/libnm-core/nm-setting-8021x.c index fc1b46fb67..a1019060d1 100644 --- a/libnm-core/nm-setting-8021x.c +++ b/libnm-core/nm-setting-8021x.c @@ -2601,7 +2601,7 @@ verify_cert (GBytes *bytes, const char *prop_name, GError **error) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSetting8021x *self = NM_SETTING_802_1X (setting); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self); diff --git a/libnm-core/nm-setting-8021x.h b/libnm-core/nm-setting-8021x.h index ab6cde4401..10338de998 100644 --- a/libnm-core/nm-setting-8021x.h +++ b/libnm-core/nm-setting-8021x.h @@ -132,9 +132,9 @@ typedef enum { /*< underscore_name=nm_setting_802_1x_ck_scheme >*/ * properties to the paths to their respective objects. */ -typedef struct { +struct _NMSetting8021x { NMSetting parent; -} NMSetting8021x; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-adsl.c b/libnm-core/nm-setting-adsl.c index 3ba569231f..dfd1e0107c 100644 --- a/libnm-core/nm-setting-adsl.c +++ b/libnm-core/nm-setting-adsl.c @@ -177,7 +177,7 @@ nm_setting_adsl_get_vci (NMSettingAdsl *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting); diff --git a/libnm-core/nm-setting-adsl.h b/libnm-core/nm-setting-adsl.h index 57237f1e1b..2b44d68687 100644 --- a/libnm-core/nm-setting-adsl.h +++ b/libnm-core/nm-setting-adsl.h @@ -54,9 +54,9 @@ G_BEGIN_DECLS #define NM_SETTING_ADSL_ENCAPSULATION_VCMUX "vcmux" #define NM_SETTING_ADSL_ENCAPSULATION_LLC "llc" -typedef struct { +struct _NMSettingAdsl { NMSetting parent; -} NMSettingAdsl; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-bluetooth.c b/libnm-core/nm-setting-bluetooth.c index 4bc7e156a8..952dd61b51 100644 --- a/libnm-core/nm-setting-bluetooth.c +++ b/libnm-core/nm-setting-bluetooth.c @@ -107,7 +107,7 @@ nm_setting_bluetooth_get_bdaddr (NMSettingBluetooth *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (setting); @@ -148,12 +148,12 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } /* Make sure the corresponding 'type' setting is present */ - if ( all_settings + if ( connection && !strcmp (priv->type, NM_SETTING_BLUETOOTH_TYPE_DUN)) { gboolean gsm = FALSE, cdma = FALSE; - gsm = !!nm_setting_find_in_list (all_settings, NM_SETTING_GSM_SETTING_NAME); - cdma = !!nm_setting_find_in_list (all_settings, NM_SETTING_CDMA_SETTING_NAME); + gsm = !!nm_connection_get_setting_gsm (connection); + cdma = !!nm_connection_get_setting_cdma (connection); if (!gsm && !cdma) { /* We can't return MISSING_SETTING here, because we don't know diff --git a/libnm-core/nm-setting-bluetooth.h b/libnm-core/nm-setting-bluetooth.h index ca0c17110a..6bb5ce80a4 100644 --- a/libnm-core/nm-setting-bluetooth.h +++ b/libnm-core/nm-setting-bluetooth.h @@ -59,9 +59,9 @@ G_BEGIN_DECLS */ #define NM_SETTING_BLUETOOTH_TYPE_PANU "panu" -typedef struct { +struct _NMSettingBluetooth { NMSetting parent; -} NMSettingBluetooth; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index 19eee1edf4..ab026aac78 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -29,7 +29,8 @@ #include "nm-setting-bond.h" #include "nm-utils.h" #include "nm-utils-private.h" -#include "nm-setting-private.h" +#include "nm-connection-private.h" +#include "nm-setting-infiniband.h" /** * SECTION:nm-setting-bond @@ -431,7 +432,7 @@ nm_setting_bond_get_option_default (NMSettingBond *setting, const char *name) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting); GHashTableIter iter; @@ -538,7 +539,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } } - if (nm_setting_find_in_list (all_settings, NM_SETTING_INFINIBAND_SETTING_NAME)) { + if (nm_connection_get_setting_infiniband (connection)) { if (strcmp (value, "active-backup") != 0) { g_set_error (error, NM_CONNECTION_ERROR, @@ -641,7 +642,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } - return _nm_setting_verify_required_virtual_interface_name (all_settings, error); + return _nm_connection_verify_required_interface_name (connection, error); } static void diff --git a/libnm-core/nm-setting-bond.h b/libnm-core/nm-setting-bond.h index e656ca887b..055801a594 100644 --- a/libnm-core/nm-setting-bond.h +++ b/libnm-core/nm-setting-bond.h @@ -58,9 +58,9 @@ G_BEGIN_DECLS #define NM_SETTING_BOND_OPTION_RESEND_IGMP "resend_igmp" #define NM_SETTING_BOND_OPTION_LACP_RATE "lacp_rate" -typedef struct { +struct _NMSettingBond { NMSetting parent; -} NMSettingBond; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-bridge-port.c b/libnm-core/nm-setting-bridge-port.c index 05d394721c..d1ffdca3d3 100644 --- a/libnm-core/nm-setting-bridge-port.c +++ b/libnm-core/nm-setting-bridge-port.c @@ -27,7 +27,9 @@ #include "nm-setting-bridge-port.h" #include "nm-utils.h" #include "nm-utils-private.h" -#include "nm-setting-private.h" +#include "nm-connection-private.h" +#include "nm-setting-connection.h" +#include "nm-setting-bridge.h" /** * SECTION:nm-setting-bridge-port @@ -110,7 +112,7 @@ nm_setting_bridge_port_get_hairpin_mode (NMSettingBridgePort *setting) #define BR_MAX_PATH_COST 65535 static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting); @@ -139,15 +141,19 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } - if (all_settings) { + if (connection) { NMSettingConnection *s_con; const char *slave_type; - s_con = NM_SETTING_CONNECTION (_nm_setting_find_in_list_required (all_settings, - NM_SETTING_CONNECTION_SETTING_NAME, - error)); - if (!s_con) - return FALSE; + s_con = nm_connection_get_setting_connection (connection); + if (!s_con) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("missing setting")); + g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME); + return FALSE; + } slave_type = nm_setting_connection_get_slave_type (s_con); if ( slave_type diff --git a/libnm-core/nm-setting-bridge-port.h b/libnm-core/nm-setting-bridge-port.h index 87fd898dbd..49ca38b34e 100644 --- a/libnm-core/nm-setting-bridge-port.h +++ b/libnm-core/nm-setting-bridge-port.h @@ -43,9 +43,9 @@ G_BEGIN_DECLS #define NM_SETTING_BRIDGE_PORT_PATH_COST "path-cost" #define NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE "hairpin-mode" -typedef struct { +struct _NMSettingBridgePort { NMSetting parent; -} NMSettingBridgePort; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-bridge.c b/libnm-core/nm-setting-bridge.c index 1c43208847..100804a017 100644 --- a/libnm-core/nm-setting-bridge.c +++ b/libnm-core/nm-setting-bridge.c @@ -25,7 +25,7 @@ #include #include "nm-setting-bridge.h" -#include "nm-setting-private.h" +#include "nm-connection-private.h" #include "nm-utils.h" #include "nm-utils-private.h" @@ -210,7 +210,7 @@ check_range (guint32 val, } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting); @@ -251,7 +251,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) error)) return FALSE; - return _nm_setting_verify_required_virtual_interface_name (all_settings, error); + return _nm_connection_verify_required_interface_name (connection, error); } static void diff --git a/libnm-core/nm-setting-bridge.h b/libnm-core/nm-setting-bridge.h index 68eb10458a..b4fe747726 100644 --- a/libnm-core/nm-setting-bridge.h +++ b/libnm-core/nm-setting-bridge.h @@ -47,9 +47,9 @@ G_BEGIN_DECLS #define NM_SETTING_BRIDGE_MAX_AGE "max-age" #define NM_SETTING_BRIDGE_AGEING_TIME "ageing-time" -typedef struct { +struct _NMSettingBridge { NMSetting parent; -} NMSettingBridge; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-cdma.c b/libnm-core/nm-setting-cdma.c index 02e7e28928..f611cc601c 100644 --- a/libnm-core/nm-setting-cdma.c +++ b/libnm-core/nm-setting-cdma.c @@ -129,7 +129,7 @@ nm_setting_cdma_get_password_flags (NMSettingCdma *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (setting); diff --git a/libnm-core/nm-setting-cdma.h b/libnm-core/nm-setting-cdma.h index 49f77a6ad6..6e333dccc9 100644 --- a/libnm-core/nm-setting-cdma.h +++ b/libnm-core/nm-setting-cdma.h @@ -45,9 +45,9 @@ G_BEGIN_DECLS #define NM_SETTING_CDMA_PASSWORD "password" #define NM_SETTING_CDMA_PASSWORD_FLAGS "password-flags" -typedef struct { +struct _NMSettingCdma { NMSetting parent; -} NMSettingCdma; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index b060345b6a..e7f8518d43 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -26,7 +26,11 @@ #include "nm-utils.h" #include "nm-utils-private.h" #include "nm-setting-connection.h" -#include "nm-setting-private.h" +#include "nm-connection-private.h" +#include "nm-setting-bond.h" +#include "nm-setting-bridge.h" +#include "nm-setting-team.h" +#include "nm-setting-vlan.h" /** * SECTION:nm-setting-connection @@ -744,7 +748,7 @@ _set_error_missing_base_setting (GError **error, const char *type) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting); gboolean is_slave; @@ -801,7 +805,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } if (!priv->type) { - if (!(normerr_base_type = _nm_setting_find_in_list_base_type (all_settings))) { + if (!connection || !(normerr_base_type = _nm_connection_find_base_type_setting (connection))) { g_set_error_literal (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY, @@ -833,18 +837,18 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } /* Make sure the corresponding 'type' item is present */ - if ( all_settings - && !nm_setting_find_in_list (all_settings, priv->type)) { + if ( connection + && !nm_connection_get_setting_by_name (connection, priv->type)) { NMSetting *s_base; - GSList *all_settings2; + NMConnection *connection2; s_base = g_object_new (base_type, NULL); - all_settings2 = g_slist_prepend (all_settings, s_base); + connection2 = nm_simple_connection_new_clone (connection); + nm_connection_add_setting (connection2, s_base); - normerr_base_setting = nm_setting_verify (s_base, all_settings2, NULL); + normerr_base_setting = nm_setting_verify (s_base, connection2, NULL); - g_slist_free_1 (all_settings2); - g_object_unref (s_base); + g_object_unref (connection2); if (!normerr_base_setting) { _set_error_missing_base_setting (error, priv->type); @@ -876,16 +880,16 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } if ( slave_setting_type - && all_settings /* only check for an existing slave-setting when having @all_settings */ - && !nm_setting_find_in_list (all_settings, slave_setting_type)) + && connection + && !nm_connection_get_setting_by_name (connection, slave_setting_type)) normerr_slave_setting_type = slave_setting_type; } else { if (priv->master) { const char *slave_type; NMSetting *s_port; - if ( all_settings - && (slave_type = _nm_setting_slave_type_detect_from_settings (all_settings, &s_port))) { + if ( connection + && (slave_type = _nm_connection_detect_slave_type (connection, &s_port))) { normerr_missing_slave_type = slave_type; normerr_missing_slave_type_port = nm_setting_get_name (s_port); } else { diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h index 13890c32a1..d1ad0fe1e5 100644 --- a/libnm-core/nm-setting-connection.h +++ b/libnm-core/nm-setting-connection.h @@ -65,9 +65,9 @@ G_BEGIN_DECLS * The NMSettingConnection struct contains only private data. * It should only be accessed through the functions described below. */ -typedef struct { +struct _NMSettingConnection { NMSetting parent; -} NMSettingConnection; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-dcb.c b/libnm-core/nm-setting-dcb.c index e68be5e108..8a99ec07bb 100644 --- a/libnm-core/nm-setting-dcb.c +++ b/libnm-core/nm-setting-dcb.c @@ -619,7 +619,7 @@ check_priority (gint val, } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (setting); diff --git a/libnm-core/nm-setting-dcb.h b/libnm-core/nm-setting-dcb.h index 089d266cf6..e5bc4bcfa7 100644 --- a/libnm-core/nm-setting-dcb.h +++ b/libnm-core/nm-setting-dcb.h @@ -93,9 +93,9 @@ typedef enum { /*< flags >*/ #define NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS "priority-traffic-class" -typedef struct { +struct _NMSettingDcb { NMSetting parent; -} NMSettingDcb; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-generic.h b/libnm-core/nm-setting-generic.h index db12b80491..7a209da259 100644 --- a/libnm-core/nm-setting-generic.h +++ b/libnm-core/nm-setting-generic.h @@ -39,9 +39,9 @@ G_BEGIN_DECLS #define NM_SETTING_GENERIC_SETTING_NAME "generic" -typedef struct { +struct _NMSettingGeneric { NMSetting parent; -} NMSettingGeneric; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-gsm.c b/libnm-core/nm-setting-gsm.c index 7661db6557..d537376db5 100644 --- a/libnm-core/nm-setting-gsm.c +++ b/libnm-core/nm-setting-gsm.c @@ -213,7 +213,7 @@ nm_setting_gsm_get_home_only (NMSettingGsm *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting); diff --git a/libnm-core/nm-setting-gsm.h b/libnm-core/nm-setting-gsm.h index 21e3c92b6e..907567381a 100644 --- a/libnm-core/nm-setting-gsm.h +++ b/libnm-core/nm-setting-gsm.h @@ -50,9 +50,9 @@ G_BEGIN_DECLS #define NM_SETTING_GSM_PIN_FLAGS "pin-flags" #define NM_SETTING_GSM_HOME_ONLY "home-only" -typedef struct { +struct _NMSettingGsm { NMSetting parent; -} NMSettingGsm; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-infiniband.c b/libnm-core/nm-setting-infiniband.c index 61e532e357..ed80a13609 100644 --- a/libnm-core/nm-setting-infiniband.c +++ b/libnm-core/nm-setting-infiniband.c @@ -178,7 +178,7 @@ nm_setting_infiniband_get_virtual_interface_name (NMSettingInfiniband *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingConnection *s_con; NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (setting); @@ -237,7 +237,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) } } - s_con = NM_SETTING_CONNECTION (nm_setting_find_in_list (all_settings, NM_SETTING_CONNECTION_SETTING_NAME)); + s_con = nm_connection_get_setting_connection (connection); if (s_con) { const char *interface_name = nm_setting_connection_get_interface_name (s_con); diff --git a/libnm-core/nm-setting-infiniband.h b/libnm-core/nm-setting-infiniband.h index 35a576b3bd..c5ad418b22 100644 --- a/libnm-core/nm-setting-infiniband.h +++ b/libnm-core/nm-setting-infiniband.h @@ -45,9 +45,9 @@ G_BEGIN_DECLS #define NM_SETTING_INFINIBAND_P_KEY "p-key" #define NM_SETTING_INFINIBAND_PARENT "parent" -typedef struct { +struct _NMSettingInfiniband { NMSetting parent; -} NMSettingInfiniband; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c index c1384bb54f..00f2df502e 100644 --- a/libnm-core/nm-setting-ip4-config.c +++ b/libnm-core/nm-setting-ip4-config.c @@ -22,6 +22,7 @@ #include #include +#include #include "nm-setting-ip4-config.h" #include "nm-utils.h" @@ -867,7 +868,7 @@ verify_label (const char *label) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting); GSList *iter, *l_iter; diff --git a/libnm-core/nm-setting-ip4-config.h b/libnm-core/nm-setting-ip4-config.h index 004024113f..369e1d46d2 100644 --- a/libnm-core/nm-setting-ip4-config.h +++ b/libnm-core/nm-setting-ip4-config.h @@ -148,9 +148,9 @@ void nm_ip4_route_set_metric (NMIP4Route *route, guint32 metric); -typedef struct { +struct _NMSettingIP4Config { NMSetting parent; -} NMSettingIP4Config; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c index ca08ad8bb9..cbc5e2c8be 100644 --- a/libnm-core/nm-setting-ip6-config.c +++ b/libnm-core/nm-setting-ip6-config.c @@ -786,7 +786,7 @@ nm_setting_ip6_config_get_ip6_privacy (NMSettingIP6Config *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting); GSList *iter; diff --git a/libnm-core/nm-setting-ip6-config.h b/libnm-core/nm-setting-ip6-config.h index ec6299f3f0..831f212bb6 100644 --- a/libnm-core/nm-setting-ip6-config.h +++ b/libnm-core/nm-setting-ip6-config.h @@ -178,9 +178,9 @@ guint32 nm_ip6_route_get_metric (NMIP6Route *route); void nm_ip6_route_set_metric (NMIP6Route *route, guint32 metric); -typedef struct { +struct _NMSettingIP6Config { NMSetting parent; -} NMSettingIP6Config; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-olpc-mesh.c b/libnm-core/nm-setting-olpc-mesh.c index 92d1045792..968be898bb 100644 --- a/libnm-core/nm-setting-olpc-mesh.c +++ b/libnm-core/nm-setting-olpc-mesh.c @@ -94,7 +94,7 @@ nm_setting_olpc_mesh_get_dhcp_anycast_address (NMSettingOlpcMesh *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (setting); gsize length; diff --git a/libnm-core/nm-setting-olpc-mesh.h b/libnm-core/nm-setting-olpc-mesh.h index a3e202adf0..6a1656514b 100644 --- a/libnm-core/nm-setting-olpc-mesh.h +++ b/libnm-core/nm-setting-olpc-mesh.h @@ -44,9 +44,9 @@ G_BEGIN_DECLS #define NM_SETTING_OLPC_MESH_CHANNEL "channel" #define NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS "dhcp-anycast-address" -typedef struct { +struct _NMSettingOlpcMesh { NMSetting parent; -} NMSettingOlpcMesh; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-ppp.c b/libnm-core/nm-setting-ppp.c index d150fe7783..c3511fb896 100644 --- a/libnm-core/nm-setting-ppp.c +++ b/libnm-core/nm-setting-ppp.c @@ -352,7 +352,7 @@ nm_setting_ppp_get_lcp_echo_interval (NMSettingPpp *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingPppPrivate *priv = NM_SETTING_PPP_GET_PRIVATE (setting); diff --git a/libnm-core/nm-setting-ppp.h b/libnm-core/nm-setting-ppp.h index a1d2b62811..2e0162cc59 100644 --- a/libnm-core/nm-setting-ppp.h +++ b/libnm-core/nm-setting-ppp.h @@ -59,9 +59,9 @@ G_BEGIN_DECLS #define NM_SETTING_PPP_LCP_ECHO_FAILURE "lcp-echo-failure" #define NM_SETTING_PPP_LCP_ECHO_INTERVAL "lcp-echo-interval" -typedef struct { +struct _NMSettingPpp { NMSetting parent; -} NMSettingPpp; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-pppoe.c b/libnm-core/nm-setting-pppoe.c index 488e4ba404..403560221a 100644 --- a/libnm-core/nm-setting-pppoe.c +++ b/libnm-core/nm-setting-pppoe.c @@ -130,7 +130,7 @@ nm_setting_pppoe_get_password_flags (NMSettingPppoe *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (setting); diff --git a/libnm-core/nm-setting-pppoe.h b/libnm-core/nm-setting-pppoe.h index 8595baf14d..b1e0d92feb 100644 --- a/libnm-core/nm-setting-pppoe.h +++ b/libnm-core/nm-setting-pppoe.h @@ -45,9 +45,9 @@ G_BEGIN_DECLS #define NM_SETTING_PPPOE_PASSWORD "password" #define NM_SETTING_PPPOE_PASSWORD_FLAGS "password-flags" -typedef struct { +struct _NMSettingPppoe { NMSetting parent; -} NMSettingPppoe; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h index 7940a161e2..56c4f46c48 100644 --- a/libnm-core/nm-setting-private.h +++ b/libnm-core/nm-setting-private.h @@ -91,26 +91,15 @@ gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting, static void __attribute__((constructor)) register_setting (void) \ { g_type_init (); g_type_ensure (x); } -NMSetting *nm_setting_find_in_list (GSList *settings_list, const char *setting_name); - -NMSetting * _nm_setting_find_in_list_required (GSList *all_settings, - const char *setting_name, - GError **error); - -NMSettingVerifyResult _nm_setting_verify_required_virtual_interface_name (GSList *all_settings, - GError **error); - GVariant *_nm_setting_get_deprecated_virtual_interface_name (NMSetting *setting, NMConnection *connection, const char *property); NMSettingVerifyResult _nm_setting_verify (NMSetting *setting, - GSList *all_settings, - GError **error); + NMConnection *connection, + GError **error); -NMSetting *_nm_setting_find_in_list_base_type (GSList *all_settings); gboolean _nm_setting_slave_type_is_valid (const char *slave_type, const char **out_port_type); -const char * _nm_setting_slave_type_detect_from_settings (GSList *all_settings, NMSetting **out_s_port); GVariant *_nm_setting_to_dbus (NMSetting *setting, NMConnection *connection, diff --git a/libnm-core/nm-setting-serial.c b/libnm-core/nm-setting-serial.c index 23a37fe86a..8676cb4e6a 100644 --- a/libnm-core/nm-setting-serial.c +++ b/libnm-core/nm-setting-serial.c @@ -146,7 +146,7 @@ nm_setting_serial_get_send_delay (NMSettingSerial *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { return TRUE; } diff --git a/libnm-core/nm-setting-serial.h b/libnm-core/nm-setting-serial.h index 15b18150b2..582892277b 100644 --- a/libnm-core/nm-setting-serial.h +++ b/libnm-core/nm-setting-serial.h @@ -60,9 +60,9 @@ typedef enum { #define NM_SETTING_SERIAL_STOPBITS "stopbits" #define NM_SETTING_SERIAL_SEND_DELAY "send-delay" -typedef struct { +struct _NMSettingSerial { NMSetting parent; -} NMSettingSerial; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-team-port.c b/libnm-core/nm-setting-team-port.c index dceab5c746..cbdae158e1 100644 --- a/libnm-core/nm-setting-team-port.c +++ b/libnm-core/nm-setting-team-port.c @@ -26,7 +26,9 @@ #include "nm-setting-team-port.h" #include "nm-utils.h" #include "nm-utils-private.h" -#include "nm-setting-private.h" +#include "nm-connection-private.h" +#include "nm-setting-connection.h" +#include "nm-setting-team.h" /** * SECTION:nm-setting-team-port @@ -80,17 +82,21 @@ nm_setting_team_port_get_config (NMSettingTeamPort *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { - if (all_settings) { + if (connection) { NMSettingConnection *s_con; const char *slave_type; - s_con = NM_SETTING_CONNECTION (_nm_setting_find_in_list_required (all_settings, - NM_SETTING_CONNECTION_SETTING_NAME, - error)); - if (!s_con) + s_con = nm_connection_get_setting_connection (connection); + if (!s_con) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("missing setting")); + g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME); return FALSE; + } slave_type = nm_setting_connection_get_slave_type (s_con); if ( slave_type diff --git a/libnm-core/nm-setting-team-port.h b/libnm-core/nm-setting-team-port.h index 644b0b5bd8..86efb97c40 100644 --- a/libnm-core/nm-setting-team-port.h +++ b/libnm-core/nm-setting-team-port.h @@ -40,9 +40,9 @@ G_BEGIN_DECLS #define NM_SETTING_TEAM_PORT_CONFIG "config" -typedef struct { +struct _NMSettingTeamPort { NMSetting parent; -} NMSettingTeamPort; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c index ab2d65eb60..91d80b178b 100644 --- a/libnm-core/nm-setting-team.c +++ b/libnm-core/nm-setting-team.c @@ -25,7 +25,7 @@ #include "nm-setting-team.h" #include "nm-utils.h" #include "nm-utils-private.h" -#include "nm-setting-private.h" +#include "nm-connection-private.h" /** * SECTION:nm-setting-team @@ -79,9 +79,9 @@ nm_setting_team_get_config (NMSettingTeam *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { - return _nm_setting_verify_required_virtual_interface_name (all_settings, error); + return _nm_connection_verify_required_interface_name (connection, error); } static void diff --git a/libnm-core/nm-setting-team.h b/libnm-core/nm-setting-team.h index 0c7fd1f940..d66eb6858a 100644 --- a/libnm-core/nm-setting-team.h +++ b/libnm-core/nm-setting-team.h @@ -40,9 +40,9 @@ G_BEGIN_DECLS #define NM_SETTING_TEAM_CONFIG "config" -typedef struct { +struct _NMSettingTeam { NMSetting parent; -} NMSettingTeam; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c index 31fa51d852..b0d19c7520 100644 --- a/libnm-core/nm-setting-vlan.c +++ b/libnm-core/nm-setting-vlan.c @@ -27,7 +27,8 @@ #include "nm-utils.h" #include "nm-setting-connection.h" #include "nm-setting-private.h" -#include "nm-core-enum-types.h" +#include "nm-setting-wired.h" +#include "nm-connection-private.h" /** * SECTION:nm-setting-vlan @@ -479,18 +480,18 @@ nm_setting_vlan_init (NMSettingVlan *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting); - NMSettingConnection *s_con = NULL; - NMSettingWired *s_wired = NULL; - GSList *iter; + NMSettingConnection *s_con; + NMSettingWired *s_wired; - for (iter = all_settings; iter; iter = iter->next) { - if (NM_IS_SETTING_CONNECTION (iter->data)) - s_con = iter->data; - else if (NM_IS_SETTING_WIRED (iter->data)) - s_wired = iter->data; + if (connection) { + s_con = nm_connection_get_setting_connection (connection); + s_wired = nm_connection_get_setting_wired (connection); + } else { + s_con = NULL; + s_wired = NULL; } if (priv->parent) { @@ -529,7 +530,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) /* If parent is NULL, the parent must be specified via * NMSettingWired:mac-address. */ - if ( all_settings + if ( connection && (!s_wired || !nm_setting_wired_get_mac_address (s_wired))) { g_set_error (error, NM_CONNECTION_ERROR, diff --git a/libnm-core/nm-setting-vlan.h b/libnm-core/nm-setting-vlan.h index 68f73b8151..30305d327c 100644 --- a/libnm-core/nm-setting-vlan.h +++ b/libnm-core/nm-setting-vlan.h @@ -46,9 +46,9 @@ G_BEGIN_DECLS #define NM_SETTING_VLAN_INGRESS_PRIORITY_MAP "ingress-priority-map" #define NM_SETTING_VLAN_EGRESS_PRIORITY_MAP "egress-priority-map" -typedef struct { +struct _NMSettingVlan { NMSetting parent; -} NMSettingVlan; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-vpn.c b/libnm-core/nm-setting-vpn.c index 07f815716e..2e68ac9a67 100644 --- a/libnm-core/nm-setting-vpn.c +++ b/libnm-core/nm-setting-vpn.c @@ -367,7 +367,7 @@ nm_setting_vpn_foreach_secret (NMSettingVpn *setting, } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting); diff --git a/libnm-core/nm-setting-vpn.h b/libnm-core/nm-setting-vpn.h index 7a6fed86cb..aa4264fdd9 100644 --- a/libnm-core/nm-setting-vpn.h +++ b/libnm-core/nm-setting-vpn.h @@ -45,9 +45,9 @@ G_BEGIN_DECLS #define NM_SETTING_VPN_DATA "data" #define NM_SETTING_VPN_SECRETS "secrets" -typedef struct { +struct _NMSettingVpn { NMSetting parent; -} NMSettingVpn; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-wimax.c b/libnm-core/nm-setting-wimax.c index 9de966f3fd..ccc46fe4ef 100644 --- a/libnm-core/nm-setting-wimax.c +++ b/libnm-core/nm-setting-wimax.c @@ -104,7 +104,7 @@ nm_setting_wimax_get_mac_address (NMSettingWimax *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (setting); diff --git a/libnm-core/nm-setting-wimax.h b/libnm-core/nm-setting-wimax.h index fe262a5a73..0a58504669 100644 --- a/libnm-core/nm-setting-wimax.h +++ b/libnm-core/nm-setting-wimax.h @@ -42,9 +42,9 @@ G_BEGIN_DECLS #define NM_SETTING_WIMAX_NETWORK_NAME "network-name" #define NM_SETTING_WIMAX_MAC_ADDRESS "mac-address" -typedef struct { +struct _NMSettingWimax { NMSetting parent; -} NMSettingWimax; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 45c0827d6b..7bf1ae2f26 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -555,7 +555,7 @@ nm_setting_wired_get_valid_s390_options (NMSettingWired *setting) } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting); const char *valid_ports[] = { "tp", "aui", "bnc", "mii", NULL }; diff --git a/libnm-core/nm-setting-wired.h b/libnm-core/nm-setting-wired.h index 0439291cc5..4189b68967 100644 --- a/libnm-core/nm-setting-wired.h +++ b/libnm-core/nm-setting-wired.h @@ -52,9 +52,9 @@ G_BEGIN_DECLS #define NM_SETTING_WIRED_S390_NETTYPE "s390-nettype" #define NM_SETTING_WIRED_S390_OPTIONS "s390-options" -typedef struct { +struct _NMSettingWired { NMSetting parent; -} NMSettingWired; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-wireless-security.c b/libnm-core/nm-setting-wireless-security.c index c6171869cc..35ef2fdcbe 100644 --- a/libnm-core/nm-setting-wireless-security.c +++ b/libnm-core/nm-setting-wireless-security.c @@ -29,7 +29,7 @@ #include "nm-utils.h" #include "nm-utils-private.h" #include "nm-setting-private.h" -#include "nm-core-enum-types.h" +#include "nm-setting-wireless.h" /** * SECTION:nm-setting-wireless-security @@ -844,7 +844,7 @@ no_secrets: } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self); @@ -904,7 +904,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0) || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) { /* Need an 802.1x setting too */ - if (!nm_setting_find_in_list (all_settings, NM_SETTING_802_1X_SETTING_NAME)) { + if (connection && !nm_connection_get_setting_802_1x (connection)) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING, diff --git a/libnm-core/nm-setting-wireless-security.h b/libnm-core/nm-setting-wireless-security.h index 7c9e7ec472..8c4e1f0382 100644 --- a/libnm-core/nm-setting-wireless-security.h +++ b/libnm-core/nm-setting-wireless-security.h @@ -89,9 +89,9 @@ typedef enum { #define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD "leap-password" #define NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS "leap-password-flags" -typedef struct { +struct _NMSettingWirelessSecurity { NMSetting parent; -} NMSettingWirelessSecurity; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c index 5ca1169116..d374d91b7c 100644 --- a/libnm-core/nm-setting-wireless.c +++ b/libnm-core/nm-setting-wireless.c @@ -676,7 +676,7 @@ nm_setting_wireless_get_seen_bssid (NMSettingWireless *setting, } static gboolean -verify (NMSetting *setting, GSList *all_settings, GError **error) +verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting); const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NULL }; diff --git a/libnm-core/nm-setting-wireless.h b/libnm-core/nm-setting-wireless.h index e9e6ae7dab..98fa98dc6c 100644 --- a/libnm-core/nm-setting-wireless.h +++ b/libnm-core/nm-setting-wireless.h @@ -79,9 +79,9 @@ G_BEGIN_DECLS */ #define NM_SETTING_WIRELESS_MODE_INFRA "infrastructure" -typedef struct { +struct _NMSettingWireless { NMSetting parent; -} NMSettingWireless; +}; typedef struct { NMSettingClass parent; diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index aac29fa428..645d8d3a8f 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -26,12 +26,20 @@ #include "nm-setting.h" #include "nm-setting-private.h" -#include "nm-setting-connection.h" #include "nm-utils.h" #include "nm-core-internal.h" #include "nm-utils-private.h" #include "nm-property-compare.h" +#include "nm-setting-connection.h" +#include "nm-setting-bond.h" +#include "nm-setting-bridge.h" +#include "nm-setting-bridge-port.h" +#include "nm-setting-pppoe.h" +#include "nm-setting-team.h" +#include "nm-setting-team-port.h" +#include "nm-setting-vpn.h" + /** * SECTION:nm-setting * @short_description: Describes related configuration information @@ -275,64 +283,6 @@ _nm_setting_slave_type_is_valid (const char *slave_type, const char **out_port_t return found; } - -NMSetting * -_nm_setting_find_in_list_base_type (GSList *all_settings) -{ - GSList *iter; - NMSetting *setting = NULL; - - for (iter = all_settings; iter; iter = iter->next) { - NMSetting *s_iter = NM_SETTING (iter->data); - - if (!_nm_setting_is_base_type (s_iter)) - continue; - - if (setting) { - /* FIXME: currently, if there is more than one matching base type, - * we cannot detect the base setting. - * See: https://bugzilla.gnome.org/show_bug.cgi?id=696936#c8 */ - return NULL; - } - setting = s_iter; - } - return setting; -} - -const char * -_nm_setting_slave_type_detect_from_settings (GSList *all_settings, NMSetting **out_s_port) -{ - GSList *iter; - const char *slave_type = NULL; - NMSetting *s_port = NULL; - - for (iter = all_settings; iter; iter = iter->next) { - NMSetting *s_iter = NM_SETTING (iter->data); - const char *name = nm_setting_get_name (s_iter); - const char *i_slave_type = NULL; - - if (!strcmp (name, NM_SETTING_BRIDGE_PORT_SETTING_NAME)) - i_slave_type = NM_SETTING_BRIDGE_SETTING_NAME; - else if (!strcmp (name, NM_SETTING_TEAM_PORT_SETTING_NAME)) - i_slave_type = NM_SETTING_TEAM_SETTING_NAME; - else - continue; - - if (slave_type) { - /* there are more then one matching port types, cannot detect the slave type. */ - slave_type = NULL; - s_port = NULL; - break; - } - slave_type = i_slave_type; - s_port = s_iter; - } - - if (out_s_port) - *out_s_port = s_port; - return slave_type; -} - /*************************************************************/ typedef struct { @@ -892,28 +842,6 @@ nm_setting_duplicate (NMSetting *setting) return NM_SETTING (dup); } -static gint -find_setting_by_name (gconstpointer a, gconstpointer b) -{ - NMSetting *setting = NM_SETTING (a); - const char *str = (const char *) b; - - return strcmp (nm_setting_get_name (setting), str); -} - -NMSetting * -nm_setting_find_in_list (GSList *settings_list, - const char *setting_name) -{ - GSList *found; - - found = g_slist_find_custom (settings_list, setting_name, find_setting_by_name); - if (found) - return found->data; - else - return NULL; -} - /** * nm_setting_get_name: * @setting: the #NMSetting @@ -937,21 +865,21 @@ nm_setting_get_name (NMSetting *setting) /** * nm_setting_verify: * @setting: the #NMSetting to verify - * @all_settings: (element-type NMSetting): a #GSList of all settings - * in the connection from which @setting came + * @connection: (allow-none): the #NMConnection that @setting came from, or + * %NULL if @setting is being verified in isolation. * @error: location to store error, or %NULL * * Validates the setting. Each setting's properties have allowed values, and - * some are dependent on other values (hence the need for @all_settings). The + * some are dependent on other values (hence the need for @connection). The * returned #GError contains information about which property of the setting * failed validation, and in what way that property failed validation. * * Returns: %TRUE if the setting is valid, %FALSE if it is not **/ gboolean -nm_setting_verify (NMSetting *setting, GSList *all_settings, GError **error) +nm_setting_verify (NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingVerifyResult result = _nm_setting_verify (setting, all_settings, error); + NMSettingVerifyResult result = _nm_setting_verify (setting, connection, error); if (result == NM_SETTING_VERIFY_NORMALIZABLE) g_clear_error (error); @@ -960,13 +888,14 @@ nm_setting_verify (NMSetting *setting, GSList *all_settings, GError **error) } NMSettingVerifyResult -_nm_setting_verify (NMSetting *setting, GSList *all_settings, GError **error) +_nm_setting_verify (NMSetting *setting, NMConnection *connection, GError **error) { g_return_val_if_fail (NM_IS_SETTING (setting), NM_SETTING_VERIFY_ERROR); + g_return_val_if_fail (!connection || NM_IS_CONNECTION (connection), NM_SETTING_VERIFY_ERROR); g_return_val_if_fail (!error || *error == NULL, NM_SETTING_VERIFY_ERROR); if (NM_SETTING_GET_CLASS (setting)->verify) - return NM_SETTING_GET_CLASS (setting)->verify (setting, all_settings, error); + return NM_SETTING_GET_CLASS (setting)->verify (setting, connection, error); return NM_SETTING_VERIFY_SUCCESS; } @@ -1726,49 +1655,6 @@ nm_setting_to_string (NMSetting *setting) return g_string_free (string, FALSE); } -NMSetting * -_nm_setting_find_in_list_required (GSList *all_settings, - const char *setting_name, - GError **error) -{ - NMSetting *setting; - - g_return_val_if_fail (!error || !*error, NULL); - g_return_val_if_fail (all_settings, NULL); - g_return_val_if_fail (setting_name, NULL); - - setting = nm_setting_find_in_list (all_settings, setting_name); - if (!setting) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_SETTING, - _("missing setting")); - g_prefix_error (error, "%s: ", setting_name); - } - return setting; -} - -NMSettingVerifyResult -_nm_setting_verify_required_virtual_interface_name (GSList *all_settings, - GError **error) -{ - NMSettingConnection *s_con; - const char *interface_name; - - s_con = NM_SETTING_CONNECTION (nm_setting_find_in_list (all_settings, NM_SETTING_CONNECTION_SETTING_NAME)); - interface_name = s_con ? nm_setting_connection_get_interface_name (s_con) : NULL; - if (!interface_name) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("property is missing")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME); - return NM_SETTING_VERIFY_ERROR; - } - - return NM_SETTING_VERIFY_SUCCESS; -} - GVariant * _nm_setting_get_deprecated_virtual_interface_name (NMSetting *setting, NMConnection *connection, diff --git a/libnm-core/nm-setting.h b/libnm-core/nm-setting.h index 68cb1d5e01..30a2c577d9 100644 --- a/libnm-core/nm-setting.h +++ b/libnm-core/nm-setting.h @@ -27,10 +27,7 @@ #error "Only can be included directly." #endif -#include -#include - -#include +#include G_BEGIN_DECLS @@ -138,9 +135,9 @@ typedef enum { * The NMSetting struct contains only private data. * It should only be accessed through the functions described below. */ -typedef struct { +struct _NMSetting { GObject parent; -} NMSetting; +}; /** @@ -161,9 +158,9 @@ typedef struct { GObjectClass parent; /* Virtual functions */ - gint (*verify) (NMSetting *setting, - GSList *all_settings, - GError **error); + gint (*verify) (NMSetting *setting, + NMConnection *connection, + GError **error); GPtrArray *(*need_secrets) (NMSetting *setting); @@ -223,9 +220,9 @@ NMSetting *nm_setting_duplicate (NMSetting *setting); const char *nm_setting_get_name (NMSetting *setting); -gboolean nm_setting_verify (NMSetting *setting, - GSList *all_settings, - GError **error); +gboolean nm_setting_verify (NMSetting *setting, + NMConnection *connection, + GError **error); gboolean nm_setting_compare (NMSetting *a, NMSetting *b, diff --git a/libnm-core/nm-simple-connection.h b/libnm-core/nm-simple-connection.h index aea04e3a67..da6030a882 100644 --- a/libnm-core/nm-simple-connection.h +++ b/libnm-core/nm-simple-connection.h @@ -36,9 +36,9 @@ G_BEGIN_DECLS #define NM_IS_SIMPLE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SIMPLE_CONNECTION)) #define NM_SIMPLE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SIMPLE_CONNECTION, NMSimpleConnectionClass)) -typedef struct { +struct _NMSimpleConnection { GObject parent; -} NMSimpleConnection; +}; typedef struct { GObjectClass parent_class; diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 017c343b0d..dfa0d7cf81 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -33,6 +33,15 @@ #include "nm-setting-private.h" #include "crypto.h" +#include "nm-setting-bond.h" +#include "nm-setting-bridge.h" +#include "nm-setting-infiniband.h" +#include "nm-setting-ip6-config.h" +#include "nm-setting-team.h" +#include "nm-setting-vlan.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" + /** * SECTION:nm-utils * @short_description: Utility functions diff --git a/libnm-core/nm-utils.h b/libnm-core/nm-utils.h index a94730793e..5dd3a84342 100644 --- a/libnm-core/nm-utils.h +++ b/libnm-core/nm-utils.h @@ -27,13 +27,15 @@ #include +#include + /* For ETH_ALEN and INFINIBAND_ALEN */ #include #include -#include "nm-connection.h" -#include "nm-simple-connection.h" +#include "nm-dbus-interface.h" #include "nm-core-enum-types.h" +#include "nm-setting-wireless-security.h" G_BEGIN_DECLS diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 88a296640e..bc8b0925ea 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -25,21 +25,36 @@ #include #include "nm-setting-private.h" -#include "nm-setting-connection.h" -#include "nm-setting-vpn.h" -#include "nm-setting-gsm.h" -#include "nm-setting-cdma.h" -#include "nm-setting-wired.h" -#include "nm-setting-wireless-security.h" -#include "nm-setting-ip6-config.h" -#include "nm-setting-ip4-config.h" -#include "nm-setting-pppoe.h" -#include "nm-setting-serial.h" -#include "nm-setting-vlan.h" -#include "nm-setting-bond.h" #include "nm-utils.h" #include "nm-core-internal.h" +#include "nm-setting-8021x.h" +#include "nm-setting-adsl.h" +#include "nm-setting-bluetooth.h" +#include "nm-setting-bond.h" +#include "nm-setting-bridge.h" +#include "nm-setting-bridge-port.h" +#include "nm-setting-cdma.h" +#include "nm-setting-connection.h" +#include "nm-setting-generic.h" +#include "nm-setting-gsm.h" +#include "nm-setting-infiniband.h" +#include "nm-setting-ip4-config.h" +#include "nm-setting-ip6-config.h" +#include "nm-setting-olpc-mesh.h" +#include "nm-setting-ppp.h" +#include "nm-setting-pppoe.h" +#include "nm-setting-serial.h" +#include "nm-setting-team.h" +#include "nm-setting-team-port.h" +#include "nm-setting-vlan.h" +#include "nm-setting-vpn.h" +#include "nm-setting-wimax.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless.h" +#include "nm-setting-wireless-security.h" +#include "nm-simple-connection.h" + #include "nm-test-utils.h" static void diff --git a/libnm-core/tests/test-secrets.c b/libnm-core/tests/test-secrets.c index eec22524fd..b93a1ba155 100644 --- a/libnm-core/tests/test-secrets.c +++ b/libnm-core/tests/test-secrets.c @@ -22,17 +22,18 @@ #include #include -#include "nm-setting-connection.h" -#include "nm-setting-wired.h" #include "nm-setting-8021x.h" -#include "nm-setting-ip4-config.h" -#include "nm-setting-wireless.h" -#include "nm-setting-wireless-security.h" #include "nm-setting-cdma.h" +#include "nm-setting-connection.h" #include "nm-setting-gsm.h" +#include "nm-setting-ip4-config.h" #include "nm-setting-ppp.h" #include "nm-setting-pppoe.h" #include "nm-setting-vpn.h" +#include "nm-setting-wired.h" +#include "nm-setting-wireless-security.h" +#include "nm-setting-wireless.h" +#include "nm-simple-connection.h" #include "nm-utils.h" #include "nm-test-utils.h" diff --git a/libnm-core/tests/test-setting-dcb.c b/libnm-core/tests/test-setting-dcb.c index 8e2872aeee..8d861a0390 100644 --- a/libnm-core/tests/test-setting-dcb.c +++ b/libnm-core/tests/test-setting-dcb.c @@ -24,6 +24,8 @@ #include #include #include "nm-setting-dcb.h" +#include "nm-connection.h" +#include "nm-errors.h" #define DCB_FLAGS_ALL (NM_SETTING_DCB_FLAG_ENABLE | \ NM_SETTING_DCB_FLAG_ADVERTISE | \ diff --git a/libnm/libnm.ver b/libnm/libnm.ver index bc08e7fd01..d735a30e38 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -54,6 +54,7 @@ global: nm_client_get_connection_by_id; nm_client_get_connection_by_path; nm_client_get_connection_by_uuid; + nm_client_get_connections; nm_client_get_connectivity; nm_client_get_device_by_iface; nm_client_get_device_by_path; @@ -66,7 +67,6 @@ global: nm_client_get_state; nm_client_get_type; nm_client_get_version; - nm_client_list_connections; nm_client_load_connections; nm_client_load_connections_async; nm_client_load_connections_finish; diff --git a/libnm/nm-access-point.c b/libnm/nm-access-point.c index 0bb2c21409..dfc7240192 100644 --- a/libnm/nm-access-point.c +++ b/libnm/nm-access-point.c @@ -323,39 +323,38 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection) /** * nm_access_point_filter_connections: * @ap: an #NMAccessPoint to filter connections for - * @connections: (element-type NMConnection): a list of - * #NMConnection objects to filter + * @connections: (element-type NMConnection): an array of #NMConnections to + * filter * - * Filters a given list of connections for a given #NMAccessPoint object and - * return connections which may be activated with the access point. Any + * Filters a given array of connections for a given #NMAccessPoint object and + * returns connections which may be activated with the access point. Any * returned connections will match the @ap's SSID and (if given) BSSID and * other attributes like security settings, channel, etc. * * To obtain the list of connections that are compatible with this access point, - * use nm_remote_settings_list_connections() and then filter the returned list - * for a given #NMDevice using nm_device_filter_connections() and finally - * filter that list with this function. + * use nm_client_get_connections() and then filter the returned list for a given + * #NMDevice using nm_device_filter_connections() and finally filter that list + * with this function. * - * Returns: (transfer container) (element-type NMConnection): a - * list of #NMConnection objects that could be activated with the given @ap. - * The elements of the list are owned by their creator and should not be freed - * by the caller, but the returned list itself is owned by the caller and should - * be freed with g_slist_free() when it is no longer required. + * Returns: (transfer container) (element-type NMConnection): an array of + * #NMConnections that could be activated with the given @ap. The array should + * be freed with g_ptr_array_unref() when it is no longer required. **/ -GSList * -nm_access_point_filter_connections (NMAccessPoint *ap, const GSList *connections) +GPtrArray * +nm_access_point_filter_connections (NMAccessPoint *ap, const GPtrArray *connections) { - GSList *filtered = NULL; - const GSList *iter; + GPtrArray *filtered; + int i; - for (iter = connections; iter; iter = g_slist_next (iter)) { - NMConnection *candidate = NM_CONNECTION (iter->data); + filtered = g_ptr_array_new_with_free_func (g_object_unref); + for (i = 0; i < connections->len; i++) { + NMConnection *candidate = connections->pdata[i]; if (nm_access_point_connection_valid (ap, candidate)) - filtered = g_slist_prepend (filtered, candidate); + g_ptr_array_add (filtered, g_object_ref (candidate)); } - return g_slist_reverse (filtered); + return filtered; } /************************************************************/ diff --git a/libnm/nm-access-point.h b/libnm/nm-access-point.h index 53935e5fa9..6991c19ac6 100644 --- a/libnm/nm-access-point.h +++ b/libnm/nm-access-point.h @@ -74,8 +74,8 @@ NM80211Mode nm_access_point_get_mode (NMAccessPoint *ap); guint32 nm_access_point_get_max_bitrate (NMAccessPoint *ap); guint8 nm_access_point_get_strength (NMAccessPoint *ap); -GSList * nm_access_point_filter_connections (NMAccessPoint *ap, - const GSList *connections); +GPtrArray * nm_access_point_filter_connections (NMAccessPoint *ap, + const GPtrArray *connections); gboolean nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection); diff --git a/libnm/nm-client.c b/libnm/nm-client.c index dad101b00b..f6a2256709 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -1150,22 +1150,19 @@ nm_client_deactivate_connection_finish (NMClient *client, /****************************************************************/ /** - * nm_client_list_connections: + * nm_client_get_connections: * @client: the %NMClient * - * Returns: (transfer container) (element-type NMRemoteConnection): a - * list containing all connections provided by the remote settings service. - * Each element of the returned list is a %NMRemoteConnection instance, which is - * owned by the %NMClient object and should not be freed by the caller. - * The returned list is, however, owned by the caller and should be freed - * using g_slist_free() when no longer required. + * Returns: (transfer none) (element-type NMRemoteConnection): an array + * containing all connections provided by the remote settings service. The + * returned array is owned by the #NMClient object and should not be modified. **/ -GSList * -nm_client_list_connections (NMClient *client) +const GPtrArray * +nm_client_get_connections (NMClient *client) { g_return_val_if_fail (NM_IS_CLIENT (client), NULL); - return nm_remote_settings_list_connections (NM_CLIENT_GET_PRIVATE (client)->settings); + return nm_remote_settings_get_connections (NM_CLIENT_GET_PRIVATE (client)->settings); } /** diff --git a/libnm/nm-client.h b/libnm/nm-client.h index 2f22289c1f..619ad8585f 100644 --- a/libnm/nm-client.h +++ b/libnm/nm-client.h @@ -294,7 +294,7 @@ gboolean nm_client_deactivate_connection_finish (NMClient *client, /* Connections */ -GSList *nm_client_list_connections (NMClient *client); +const GPtrArray *nm_client_get_connections (NMClient *client); NMRemoteConnection *nm_client_get_connection_by_id (NMClient *client, const char *id); NMRemoteConnection *nm_client_get_connection_by_path (NMClient *client, const char *path); diff --git a/libnm/nm-device-adsl.c b/libnm/nm-device-adsl.c index dbf1cb406f..af0afa52d1 100644 --- a/libnm/nm-device-adsl.c +++ b/libnm/nm-device-adsl.c @@ -24,6 +24,7 @@ #include "nm-object-private.h" #include "nm-setting-adsl.h" +#include "nm-setting-connection.h" #include #include diff --git a/libnm/nm-device-generic.c b/libnm/nm-device-generic.c index 999bb802dd..a2a4935361 100644 --- a/libnm/nm-device-generic.c +++ b/libnm/nm-device-generic.c @@ -27,6 +27,7 @@ #include "nm-device-private.h" #include "nm-object-private.h" #include "nm-setting-generic.h" +#include "nm-setting-connection.h" G_DEFINE_TYPE (NMDeviceGeneric, nm_device_generic, NM_TYPE_DEVICE) diff --git a/libnm/nm-device-vlan.c b/libnm/nm-device-vlan.c index 9796c4523d..51bf901364 100644 --- a/libnm/nm-device-vlan.c +++ b/libnm/nm-device-vlan.c @@ -26,6 +26,7 @@ #include #include +#include #include #include "nm-device-vlan.h" diff --git a/libnm/nm-device.c b/libnm/nm-device.c index bf7cbe9357..5999ed23d2 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -52,6 +52,7 @@ #include "nm-glib-compat.h" #include "nm-utils.h" #include "nm-dbus-helpers.h" +#include "nm-setting-connection.h" #include "nmdbus-device.h" @@ -2167,38 +2168,37 @@ nm_device_connection_compatible (NMDevice *device, NMConnection *connection, GEr /** * nm_device_filter_connections: * @device: an #NMDevice to filter connections for - * @connections: (element-type NMConnection): a list of #NMConnection objects to filter + * @connections: (element-type NMConnection): an array of #NMConnections to filter * - * Filters a given list of connections for a given #NMDevice object and return + * Filters a given array of connections for a given #NMDevice object and returns * connections which may be activated with the device. For example if @device - * is a Wi-Fi device that supports only WEP encryption, the returned list will + * is a Wi-Fi device that supports only WEP encryption, the returned array will * contain any Wi-Fi connections in @connections that allow connection to - * unencrypted or WEP-enabled SSIDs. The returned list will not contain + * unencrypted or WEP-enabled SSIDs. The returned array will not contain * Ethernet, Bluetooth, Wi-Fi WPA connections, or any other connection that is * incompatible with the device. To get the full list of connections see - * nm_remote_settings_list_connections(). + * nm_client_get_connections(). * - * Returns: (transfer container) (element-type NMConnection): a - * list of #NMConnection objects that could be activated with the given @device. - * The elements of the list are owned by their creator and should not be freed - * by the caller, but the returned list itself is owned by the caller and should - * be freed with g_slist_free() when it is no longer required. + * Returns: (transfer container) (element-type NMConnection): an array of + * #NMConnections that could be activated with the given @device. The array + * should be freed with g_ptr_array_unref() when it is no longer required. **/ -GSList * -nm_device_filter_connections (NMDevice *device, const GSList *connections) +GPtrArray * +nm_device_filter_connections (NMDevice *device, const GPtrArray *connections) { - GSList *filtered = NULL; - const GSList *iter; + GPtrArray *filtered; + int i; - for (iter = connections; iter; iter = g_slist_next (iter)) { - NMConnection *candidate = NM_CONNECTION (iter->data); + filtered = g_ptr_array_new_with_free_func (g_object_unref); + for (i = 0; i < connections->len; i++) { + NMConnection *candidate = connections->pdata[i]; /* Connection applies to this device */ if (nm_device_connection_valid (device, candidate)) - filtered = g_slist_prepend (filtered, candidate); + g_ptr_array_add (filtered, g_object_ref (candidate)); } - return g_slist_reverse (filtered); + return filtered; } /** diff --git a/libnm/nm-device.h b/libnm/nm-device.h index cbfe6d4309..412dff3f96 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -144,8 +144,8 @@ gboolean nm_device_delete_finish (NMDevice *device, GAsyncResult *result, GError **error); -GSList * nm_device_filter_connections (NMDevice *device, - const GSList *connections); +GPtrArray * nm_device_filter_connections (NMDevice *device, + const GPtrArray *connections); gboolean nm_device_connection_valid (NMDevice *device, NMConnection *connection); diff --git a/libnm/nm-remote-settings.c b/libnm/nm-remote-settings.c index 62a3853d69..351fbc1bd2 100644 --- a/libnm/nm-remote-settings.c +++ b/libnm/nm-remote-settings.c @@ -261,24 +261,12 @@ object_creation_failed (NMObject *object, const char *failed_path) } } -GSList * -nm_remote_settings_list_connections (NMRemoteSettings *settings) +const GPtrArray * +nm_remote_settings_get_connections (NMRemoteSettings *settings) { - NMRemoteSettingsPrivate *priv; - GSList *list = NULL; - int i; - g_return_val_if_fail (NM_IS_REMOTE_SETTINGS (settings), NULL); - priv = NM_REMOTE_SETTINGS_GET_PRIVATE (settings); - - if (_nm_object_get_nm_running (NM_OBJECT (settings))) { - for (i = 0; i < priv->visible_connections->len; i++) - list = g_slist_prepend (list, priv->visible_connections->pdata[i]); - list = g_slist_reverse (list); - } - - return list; + return NM_REMOTE_SETTINGS_GET_PRIVATE (settings)->visible_connections; } static void diff --git a/libnm/nm-remote-settings.h b/libnm/nm-remote-settings.h index dbe39abe5e..1ffc0bf20b 100644 --- a/libnm/nm-remote-settings.h +++ b/libnm/nm-remote-settings.h @@ -62,13 +62,13 @@ struct _NMRemoteSettingsClass { GType nm_remote_settings_get_type (void); -GSList *nm_remote_settings_list_connections (NMRemoteSettings *settings); +const GPtrArray *nm_remote_settings_get_connections (NMRemoteSettings *settings); -NMRemoteConnection *nm_remote_settings_get_connection_by_id (NMRemoteSettings *settings, - const char *id); +NMRemoteConnection *nm_remote_settings_get_connection_by_id (NMRemoteSettings *settings, + const char *id); -NMRemoteConnection * nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, - const char *path); +NMRemoteConnection *nm_remote_settings_get_connection_by_path (NMRemoteSettings *settings, + const char *path); NMRemoteConnection *nm_remote_settings_get_connection_by_uuid (NMRemoteSettings *settings, const char *uuid); diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c index 28e6b7a587..e43dbacb1f 100644 --- a/libnm/nm-vpn-plugin-old.c +++ b/libnm/nm-vpn-plugin-old.c @@ -37,6 +37,7 @@ #include "nm-connection.h" #include "nm-dbus-helpers.h" #include "nm-core-internal.h" +#include "nm-simple-connection.h" #include "nmdbus-vpn-plugin.h" diff --git a/libnm/nm-wimax-nsp.c b/libnm/nm-wimax-nsp.c index 2387000569..9532b17627 100644 --- a/libnm/nm-wimax-nsp.c +++ b/libnm/nm-wimax-nsp.c @@ -145,33 +145,32 @@ nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp, NMConnection *connection) /** * nm_wimax_nsp_filter_connections: * @nsp: an #NMWimaxNsp to filter connections for - * @connections: (element-type NMConnection): a list of - * #NMConnection objects to filter + * @connections: (element-type NMConnection): an array of #NMConnections to + * filter * - * Filters a given list of connections for a given #NMWimaxNsp object and - * return connections which may be activated with the access point. Any - * returned connections will match the @nsp's network name and other attributes. + * Filters a given array of connections for a given #NMWimaxNsp object and + * return connections which may be activated with the NSP. Any returned + * connections will match the @nsp's network name and other attributes. * - * Returns: (transfer container) (element-type NMConnection): a - * list of #NMConnection objects that could be activated with the given @nsp. - * The elements of the list are owned by their creator and should not be freed - * by the caller, but the returned list itself is owned by the caller and should - * be freed with g_slist_free() when it is no longer required. + * Returns: (transfer container) (element-type NMConnection): an array of + * #NMConnections that could be activated with the given @nsp. The array should + * be freed with g_ptr_array_unref() when it is no longer required. **/ -GSList * -nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp, const GSList *connections) +GPtrArray * +nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp, const GPtrArray *connections) { - GSList *filtered = NULL; - const GSList *iter; + GPtrArray *filtered; + int i; - for (iter = connections; iter; iter = g_slist_next (iter)) { - NMConnection *candidate = NM_CONNECTION (iter->data); + filtered = g_ptr_array_new_with_free_func (g_object_unref); + for (i = 0; i < connections->len; i++) { + NMConnection *candidate = connections->pdata[i]; if (nm_wimax_nsp_connection_valid (nsp, candidate)) - filtered = g_slist_prepend (filtered, candidate); + g_ptr_array_add (filtered, g_object_ref (candidate)); } - return g_slist_reverse (filtered); + return filtered; } /************************************************************/ diff --git a/libnm/nm-wimax-nsp.h b/libnm/nm-wimax-nsp.h index 710639e784..a8f9105268 100644 --- a/libnm/nm-wimax-nsp.h +++ b/libnm/nm-wimax-nsp.h @@ -65,8 +65,8 @@ const char * nm_wimax_nsp_get_name (NMWimaxNsp *nsp); guint32 nm_wimax_nsp_get_signal_quality (NMWimaxNsp *nsp); NMWimaxNspNetworkType nm_wimax_nsp_get_network_type (NMWimaxNsp *nsp); -GSList * nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp, - const GSList *connections); +GPtrArray * nm_wimax_nsp_filter_connections (NMWimaxNsp *nsp, + const GPtrArray *connections); gboolean nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp, NMConnection *connection); diff --git a/libnm/tests/test-remote-settings-client.c b/libnm/tests/test-remote-settings-client.c index f521dbc1c0..d3af020526 100644 --- a/libnm/tests/test-remote-settings-client.c +++ b/libnm/tests/test-remote-settings-client.c @@ -133,7 +133,8 @@ static void test_make_invisible (void) { time_t start, now; - GSList *list, *iter; + const GPtrArray *conns; + int i; GDBusProxy *proxy; gboolean visible_changed = FALSE, connection_removed = FALSE; gboolean has_settings = FALSE; @@ -177,9 +178,9 @@ test_make_invisible (void) g_signal_handlers_disconnect_by_func (client, G_CALLBACK (connection_removed_cb), &connection_removed); /* Ensure NMClient no longer has the connection */ - list = nm_client_list_connections (client); - for (iter = list; iter; iter = g_slist_next (iter)) { - NMConnection *candidate = NM_CONNECTION (iter->data); + conns = nm_client_get_connections (client); + for (i = 0; i < conns->len; i++) { + NMConnection *candidate = NM_CONNECTION (conns->pdata[i]); g_assert ((gpointer) remote != (gpointer) candidate); g_assert (strcmp (path, nm_connection_get_path (candidate)) != 0); @@ -210,7 +211,8 @@ static void test_make_visible (void) { time_t start, now; - GSList *list, *iter; + const GPtrArray *conns; + int i; GDBusProxy *proxy; gboolean found = FALSE; char *path; @@ -255,9 +257,9 @@ test_make_visible (void) g_signal_handlers_disconnect_by_func (client, G_CALLBACK (vis_new_connection_cb), &new); /* Ensure NMClient has the connection */ - list = nm_client_list_connections (client); - for (iter = list; iter; iter = g_slist_next (iter)) { - NMConnection *candidate = NM_CONNECTION (iter->data); + conns = nm_client_get_connections (client); + for (i = 0; i < conns->len; i++) { + NMConnection *candidate = NM_CONNECTION (conns->pdata[i]); if ((gpointer) remote == (gpointer) candidate) { g_assert_cmpstr (path, ==, nm_connection_get_path (candidate)); @@ -299,16 +301,17 @@ test_remove_connection (void) { NMRemoteConnection *connection; time_t start, now; - GSList *list, *iter; + const GPtrArray *conns; + int i; GDBusProxy *proxy; gboolean done = FALSE; char *path; /* Find a connection to delete */ - list = nm_client_list_connections (client); - g_assert_cmpint (g_slist_length (list), >, 0); + conns = nm_client_get_connections (client); + g_assert_cmpint (conns->len, >, 0); - connection = NM_REMOTE_CONNECTION (list->data); + connection = NM_REMOTE_CONNECTION (conns->pdata[0]); g_assert (connection); g_assert (remote == connection); path = g_strdup (nm_connection_get_path (NM_CONNECTION (connection))); @@ -342,9 +345,9 @@ test_remove_connection (void) g_assert (!remote); /* Ensure NMClient no longer has the connection */ - list = nm_client_list_connections (client); - for (iter = list; iter; iter = g_slist_next (iter)) { - NMConnection *candidate = NM_CONNECTION (iter->data); + conns = nm_client_get_connections (client); + for (i = 0; i < conns->len; i++) { + NMConnection *candidate = NM_CONNECTION (conns->pdata[i]); g_assert ((gpointer) connection != (gpointer) candidate); g_assert_cmpstr (path, ==, nm_connection_get_path (candidate)); diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index 6c1693533c..74a89a5f64 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -24,13 +24,11 @@ #include #include -#include "nm-dbus-interface.h" -#include "nm-setting-bluetooth.h" +#include "nm-core-internal.h" #include "nm-bluez-common.h" #include "nm-bluez-device.h" #include "nm-logging.h" -#include "nm-utils.h" #include "nm-settings-connection.h" #include "nm-bluez5-dun.h" #include "NetworkManagerUtils.h" diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index e029aafa06..9d9fe426b2 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -29,7 +29,6 @@ #include "gsystem-local-alloc.h" #include "nm-device-bond.h" #include "nm-logging.h" -#include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-platform.h" @@ -37,6 +36,7 @@ #include "nm-dbus-manager.h" #include "nm-enum-types.h" #include "nm-device-factory.h" +#include "nm-core-internal.h" #include "nm-device-bond-glue.h" diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 7a3c373c47..a70cfd9571 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -28,7 +28,6 @@ #include "gsystem-local-alloc.h" #include "nm-device-bridge.h" #include "nm-logging.h" -#include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-dbus-glib-types.h" @@ -36,6 +35,7 @@ #include "nm-enum-types.h" #include "nm-platform.h" #include "nm-device-factory.h" +#include "nm-core-internal.h" #include "nm-device-bridge-glue.h" diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 1ee689261c..eb1f75b455 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -42,14 +42,8 @@ #include "nm-supplicant-manager.h" #include "nm-supplicant-interface.h" #include "nm-supplicant-config.h" -#include "nm-setting-connection.h" -#include "nm-setting-wired.h" -#include "nm-setting-8021x.h" -#include "nm-setting-pppoe.h" -#include "nm-setting-bond.h" #include "ppp-manager/nm-ppp-manager.h" #include "nm-logging.h" -#include "nm-utils.h" #include "nm-enum-types.h" #include "nm-dbus-manager.h" #include "nm-platform.h" @@ -59,6 +53,7 @@ #include "nm-device-ethernet-utils.h" #include "nm-connection-provider.h" #include "nm-device-factory.h" +#include "nm-core-internal.h" #include "nm-device-ethernet-glue.h" diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index c5aadb8f20..f103ef8303 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -24,9 +24,9 @@ #include "nm-device-private.h" #include "nm-enum-types.h" #include "nm-platform.h" -#include "nm-utils.h" #include "nm-glib-compat.h" #include "nm-dbus-manager.h" +#include "nm-core-internal.h" #include "nm-device-generic-glue.h" diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c index 2f432c18f0..e7df12e3f8 100644 --- a/src/devices/nm-device-gre.c +++ b/src/devices/nm-device-gre.c @@ -29,6 +29,7 @@ #include "nm-manager.h" #include "nm-platform.h" #include "nm-device-factory.h" +#include "nm-core-internal.h" #include "nm-device-gre-glue.h" diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 69cdc6715e..e1af899507 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -27,7 +27,6 @@ #include "nm-device-infiniband.h" #include "nm-logging.h" -#include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-enum-types.h" @@ -36,6 +35,7 @@ #include "nm-ip4-config.h" #include "nm-platform.h" #include "nm-device-factory.h" +#include "nm-core-internal.h" #include "nm-device-infiniband-glue.h" diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 1c78dd1ea2..555180f4e7 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -37,9 +37,9 @@ #include "nm-activation-request.h" #include "nm-ip4-config.h" #include "nm-platform.h" -#include "nm-utils.h" #include "nm-device-factory.h" #include "nm-manager.h" +#include "nm-core-internal.h" #include "nm-device-vlan-glue.h" diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index c31536e614..af5e52750c 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -48,14 +48,10 @@ #include "nm-lndp-rdisc.h" #include "nm-dhcp-manager.h" #include "nm-dbus-manager.h" -#include "nm-utils.h" #include "nm-logging.h" #include "nm-activation-request.h" -#include "nm-setting-ip4-config.h" #include "nm-ip4-config.h" -#include "nm-setting-ip6-config.h" #include "nm-ip6-config.h" -#include "nm-setting-connection.h" #include "nm-dnsmasq-manager.h" #include "nm-dhcp4-config.h" #include "nm-dhcp6-config.h" diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 6778d46dc6..df27562019 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -32,7 +32,6 @@ #include "nm-device-team.h" #include "nm-logging.h" -#include "nm-utils.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" #include "nm-platform.h" @@ -41,6 +40,7 @@ #include "nm-enum-types.h" #include "nm-team-enum-types.h" #include "nm-posix-signals.h" +#include "nm-core-internal.h" #include "nm-device-team-glue.h" diff --git a/src/devices/team/nm-team-factory.c b/src/devices/team/nm-team-factory.c index 6743660015..8f6930aa23 100644 --- a/src/devices/team/nm-team-factory.c +++ b/src/devices/team/nm-team-factory.c @@ -27,6 +27,7 @@ #include "nm-device-team.h" #include "nm-logging.h" #include "nm-platform.h" +#include "nm-core-internal.h" static GType nm_team_factory_get_type (void); diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 094b78ca01..51cc8c0358 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1013,17 +1013,7 @@ complete_connection (NMDevice *device, * if the network isn't broadcasting the SSID for example. */ if (!ap) { - GSList *settings = NULL; - gboolean valid; - - settings = g_slist_prepend (settings, s_wifi); - if (s_wsec) - settings = g_slist_prepend (settings, s_wsec); - if (s_8021x) - settings = g_slist_prepend (settings, s_8021x); - valid = nm_setting_verify (NM_SETTING (s_wifi), settings, error); - g_slist_free (settings); - if (!valid) + if (!nm_setting_verify (NM_SETTING (s_wifi), connection, error)) return FALSE; hidden = TRUE; diff --git a/src/devices/wifi/tests/test-wifi-ap-utils.c b/src/devices/wifi/tests/test-wifi-ap-utils.c index 8a17722935..35920e932e 100644 --- a/src/devices/wifi/tests/test-wifi-ap-utils.c +++ b/src/devices/wifi/tests/test-wifi-ap-utils.c @@ -24,11 +24,7 @@ #include "nm-wifi-ap-utils.h" #include "nm-dbus-glib-types.h" -#include "nm-setting-connection.h" -#include "nm-setting-wireless.h" -#include "nm-setting-wireless-security.h" -#include "nm-setting-8021x.h" -#include "nm-utils.h" +#include "nm-core-internal.h" #define DEBUG 1 diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index ea331a7948..3eb570c465 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -32,6 +32,7 @@ #include "nm-settings-connection.h" #include "nm-modem-broadband.h" #include "NetworkManagerUtils.h" +#include "nm-core-internal.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceModem); diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index a9ed5d5a82..e896cbc10a 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -21,8 +21,9 @@ #include #include #include + #include "nm-modem-broadband.h" -#include "nm-setting-connection.h" +#include "nm-core-internal.h" #include "nm-logging.h" #include "NetworkManagerUtils.h" #include "nm-device-private.h" diff --git a/src/nm-manager.c b/src/nm-manager.c index 9012e0be2e..63ef38822e 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -40,9 +40,6 @@ #include "nm-vpn-manager.h" #include "nm-device.h" #include "nm-device-generic.h" -#include "nm-setting-connection.h" -#include "nm-setting-wireless.h" -#include "nm-setting-vpn.h" #include "nm-dbus-glib-types.h" #include "nm-platform.h" #include "nm-rfkill-manager.h" @@ -52,7 +49,6 @@ #include "nm-auth-utils.h" #include "nm-auth-manager.h" #include "NetworkManagerUtils.h" -#include "nm-utils.h" #include "nm-device-factory.h" #include "nm-enum-types.h" #include "nm-sleep-monitor.h" @@ -61,6 +57,7 @@ #include "nm-connection-provider.h" #include "nm-session-monitor.h" #include "nm-activation-request.h" +#include "nm-core-internal.h" #define NM_AUTOIP_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd" #define NM_AUTOIP_DBUS_IFACE "org.freedesktop.nm_avahi_autoipd" diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index a7bb62569e..2118589ffe 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -40,20 +40,14 @@ #endif #include -#include "nm-dbus-interface.h" #include "NetworkManagerUtils.h" #include "nm-glib-compat.h" #include "nm-ppp-manager.h" -#include "nm-setting-connection.h" -#include "nm-setting-ppp.h" -#include "nm-setting-pppoe.h" -#include "nm-setting-adsl.h" -#include "nm-setting-gsm.h" -#include "nm-setting-cdma.h" #include "nm-dbus-manager.h" #include "nm-logging.h" #include "nm-posix-signals.h" #include "nm-platform.h" +#include "nm-core-internal.h" static void impl_ppp_manager_need_secrets (NMPPPManager *manager, DBusGMethodInvocation *context); diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 6fc158b182..6a71c02036 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -25,10 +25,6 @@ #include #include -#include -#include -#include -#include #include "nm-settings-connection.h" #include "nm-session-monitor.h" @@ -40,6 +36,7 @@ #include "nm-agent-manager.h" #include "NetworkManagerUtils.h" #include "nm-properties-changed-signal.h" +#include "nm-core-internal.h" #define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps" #define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids" diff --git a/src/settings/plugins/ibft/reader.c b/src/settings/plugins/ibft/reader.c index f7e845231f..aac7715a7a 100644 --- a/src/settings/plugins/ibft/reader.c +++ b/src/settings/plugins/ibft/reader.c @@ -32,14 +32,8 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include "nm-core-internal.h" #include "nm-platform.h" #include "nm-posix-signals.h" #include "NetworkManagerUtils.h" diff --git a/src/settings/plugins/ibft/tests/test-ibft.c b/src/settings/plugins/ibft/tests/test-ibft.c index 8cf705a05a..3fb64ac4bd 100644 --- a/src/settings/plugins/ibft/tests/test-ibft.c +++ b/src/settings/plugins/ibft/tests/test-ibft.c @@ -27,12 +27,7 @@ #include #include -#include -#include -#include -#include -#include - +#include "nm-core-internal.h" #include "NetworkManagerUtils.h" #include "reader.h" diff --git a/src/settings/plugins/ifcfg-rh/utils.c b/src/settings/plugins/ifcfg-rh/utils.c index 8ec7c0a131..919a048438 100644 --- a/src/settings/plugins/ifcfg-rh/utils.c +++ b/src/settings/plugins/ifcfg-rh/utils.c @@ -21,6 +21,9 @@ #include #include #include + +#include "nm-core-internal.h" + #include "utils.h" #include "shvar.h" diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c index 8fcc6a62b8..380fc4d3b4 100644 --- a/src/settings/plugins/ifnet/connection_parser.c +++ b/src/settings/plugins/ifnet/connection_parser.c @@ -27,17 +27,9 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "nm-system-config-interface.h" +#include "nm-logging.h" +#include "nm-core-internal.h" #include "net_utils.h" #include "wpa_parser.h" diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c index 18b8932494..415cfcc755 100644 --- a/src/settings/plugins/ifupdown/parser.c +++ b/src/settings/plugins/ifupdown/parser.c @@ -25,20 +25,12 @@ #include #include #include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include "nm-core-internal.h" +#include "nm-system-config-interface.h" +#include "nm-logging.h" + #include "parser.h" #include "plugin.h" diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 10c07f1ca9..8100676d79 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -21,8 +21,7 @@ #include #include -#include - +#include "nm-core-internal.h" #include "nm-logging.h" #include "interface_parser.h" #include "parser.h" diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c index 4be044c716..ac7c36ecf6 100644 --- a/src/settings/plugins/keyfile/reader.c +++ b/src/settings/plugins/keyfile/reader.c @@ -24,19 +24,10 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include "nm-core-internal.h" #include "nm-dbus-glib-types.h" #include "nm-glib-compat.h" #include "nm-system-config-interface.h" diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index ceb48fc42e..a0d6e3b2c4 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -26,19 +26,8 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "nm-core-internal.h" +#include "nm-logging.h" #include "reader.h" #include "writer.h" diff --git a/src/supplicant-manager/tests/test-supplicant-config.c b/src/supplicant-manager/tests/test-supplicant-config.c index 93de8bb5c8..2d16eecfd6 100644 --- a/src/supplicant-manager/tests/test-supplicant-config.c +++ b/src/supplicant-manager/tests/test-supplicant-config.c @@ -30,13 +30,7 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include "nm-core-internal.h" #include "nm-supplicant-config.h" #include "nm-supplicant-settings-verify.h" diff --git a/src/tests/test-general.c b/src/tests/test-general.c index f61732bb47..93a2500650 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -24,7 +24,7 @@ #include "NetworkManagerUtils.h" #include "nm-logging.h" -#include "nm-utils.h" +#include "nm-core-internal.h" #include "nm-test-utils.h" diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 5ddf22e771..45ddb79bba 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -27,19 +27,12 @@ #include #include -#include "nm-dbus-interface.h" -#include "nm-vpn-dbus-interface.h" #include "nm-vpn-connection.h" -#include "nm-setting-connection.h" -#include "nm-setting-vpn.h" -#include "nm-setting-ip4-config.h" #include "nm-ip4-config.h" -#include "nm-setting-ip6-config.h" #include "nm-ip6-config.h" #include "nm-dbus-manager.h" #include "nm-platform.h" #include "nm-logging.h" -#include "nm-utils.h" #include "nm-active-connection.h" #include "nm-dbus-glib-types.h" #include "NetworkManagerUtils.h" @@ -47,6 +40,7 @@ #include "settings/nm-settings-connection.h" #include "nm-dispatcher.h" #include "nm-agent-manager.h" +#include "nm-core-internal.h" #include "nm-vpn-connection-glue.h"