/*
* 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
* 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);
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;
}
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);
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)
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) {
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;
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. */
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)
}
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;
}
* 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;
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) {
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;
}
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,
}
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;
}
static char *
gen_func_master_ifnames (const char *text, int state)
{
- GSList *iter;
+ int i;
GPtrArray *ifnames;
char *ret;
NMConnection *con;
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);
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);
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;
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;
}
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) {
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);
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 */
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)) {
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);
static void
add_connections_for_aps (NmtConnectDevice *nmtdev,
- GSList *connections)
+ const GPtrArray *connections)
{
NmtConnectConnection *nmtconn;
NMConnection *conn;
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)
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);
}
}
- if (!iter)
+ if (!nmtconn->name)
nmtconn->name = nmtconn->ssid ? nmtconn->ssid : "<unknown>";
nmtdev->conns = g_slist_prepend (nmtdev->conns, nmtconn);
append_nmt_devices_for_devices (GSList *nmt_devices,
const GPtrArray *devices,
char **names,
- GSList *connections)
+ const GPtrArray *connections)
{
NmtConnectDevice *nmtdev;
NMDevice *device;
}
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;
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;
}
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;
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;
{
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;
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;
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) {
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)
{
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;
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");
NMConnection *connection,
gpointer user_data);
-GSList *nmt_edit_connection_list_get_connections (NmtEditConnectionList *list);
-
G_END_DECLS
#endif /* NMT_EDIT_CONNECTION_LIST_H */
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);
&& 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;
}
void
nmt_remove_connection (NMRemoteConnection *connection)
{
- GSList *conns, *iter;
+ const GPtrArray *conns;
+ int i;
NMRemoteConnection *slave;
NMSettingConnection *s_con;
const char *uuid, *iface, *master;
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) {
remove_one_connection (slave);
}
}
- g_slist_free (conns);
g_object_unref (connection);
}
/* 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;
{
NMClient *client;
GError *error = NULL;
- GSList *connections;
+ const GPtrArray *connections;
+ int i;
#if !GLIB_CHECK_VERSION (2, 35, 0)
/* Initialize GType system */
}
/* 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;
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;
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;
/**
* 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;
}
/************************************************************/
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);
/****************************************************************/
/**
- * 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);
}
/**
/* 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);
/**
* 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;
}
/**
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);
}
}
-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
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);
/**
* 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;
}
/************************************************************/
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);
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;
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);
test_make_visible (void)
{
time_t start, now;
- GSList *list, *iter;
+ const GPtrArray *conns;
+ int i;
GDBusProxy *proxy;
gboolean found = FALSE;
char *path;
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));
{
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)));
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));