libnm-core, libnm: remove GSLists in APIs (bgo #739023)

This commit is contained in:
Dan Winship 2014-10-28 17:23:51 -04:00
commit 85030d9131
123 changed files with 685 additions and 762 deletions

View file

@ -25,11 +25,9 @@
#include <glib.h>
#include <glib-object.h>
#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"
/*******************************************/

View file

@ -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;
}

View file

@ -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);

View file

@ -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 <ID>' */
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) {

View file

@ -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);

View file

@ -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 */

View file

@ -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)) {

View file

@ -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 : "<unknown>";
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) {

View file

@ -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");

View file

@ -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 */

View file

@ -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);
}

View file

@ -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;

View file

@ -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 \

View file

@ -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__ */

View file

@ -24,34 +24,10 @@
#include <glib/gi18n.h>
#include <string.h>
#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

View file

@ -27,38 +27,10 @@
#error "Only <NetworkManager.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <nm-core-types.h>
#include <nm-setting.h>
#include <nm-errors.h>
#include <nm-setting-8021x.h>
#include <nm-setting-bluetooth.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-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-vpn.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-vlan.h>
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;

View file

@ -33,11 +33,40 @@
* and some test programs.
**/
#include <glib.h>
#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);

View file

@ -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 <glib-object.h>
#include <nm-dbus-interface.h>
#include <nm-core-enum-types.h>
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__ */

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -25,7 +25,7 @@
#include <glib/gi18n.h>
#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

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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 {

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -22,6 +22,7 @@
#include <string.h>
#include <glib/gi18n.h>
#include <arpa/inet.h>
#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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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,

View file

@ -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;
}

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -40,9 +40,9 @@ G_BEGIN_DECLS
#define NM_SETTING_TEAM_CONFIG "config"
typedef struct {
struct _NMSettingTeam {
NMSetting parent;
} NMSettingTeam;
};
typedef struct {
NMSettingClass parent;

View file

@ -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,

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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 };

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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 };

View file

@ -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;

View file

@ -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,

View file

@ -27,10 +27,7 @@
#error "Only <NetworkManager.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <nm-version.h>
#include <nm-core-types.h>
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,

View file

@ -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;

View file

@ -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

View file

@ -27,13 +27,15 @@
#include <glib.h>
#include <netinet/in.h>
/* For ETH_ALEN and INFINIBAND_ALEN */
#include <linux/if_ether.h>
#include <linux/if_infiniband.h>
#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

View file

@ -25,21 +25,36 @@
#include <nm-utils.h>
#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

View file

@ -22,17 +22,18 @@
#include <glib.h>
#include <string.h>
#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"

View file

@ -24,6 +24,8 @@
#include <nm-utils.h>
#include <nm-glib-compat.h>
#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 | \

View file

@ -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;

View file

@ -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;
}
/************************************************************/

View file

@ -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);

View file

@ -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);
}
/**

View file

@ -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);

View file

@ -24,6 +24,7 @@
#include "nm-object-private.h"
#include "nm-setting-adsl.h"
#include "nm-setting-connection.h"
#include <string.h>
#include <glib/gi18n.h>

View file

@ -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)

View file

@ -26,6 +26,7 @@
#include <nm-setting-connection.h>
#include <nm-setting-vlan.h>
#include <nm-setting-wired.h>
#include <nm-utils.h>
#include "nm-device-vlan.h"

View file

@ -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;
}
/**

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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"

View file

@ -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;
}
/************************************************************/

View file

@ -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);

View file

@ -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));

View file

@ -24,13 +24,11 @@
#include <gio/gio.h>
#include <string.h>
#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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

Some files were not shown because too many files have changed in this diff Show more