diff options
Diffstat (limited to 'src/devices')
| -rw-r--r-- | src/devices/bluetooth/nm-bluez-device.c | 73 | ||||
| -rw-r--r-- | src/devices/bluetooth/nm-device-bt.c | 7 | ||||
| -rw-r--r-- | src/devices/nm-device-ethernet-utils.c | 22 | ||||
| -rw-r--r-- | src/devices/nm-device-ethernet-utils.h | 2 | ||||
| -rw-r--r-- | src/devices/nm-device-ethernet.c | 11 | ||||
| -rw-r--r-- | src/devices/nm-device.c | 115 | ||||
| -rw-r--r-- | src/devices/nm-device.h | 5 | ||||
| -rw-r--r-- | src/devices/wifi/nm-device-iwd.c | 9 | ||||
| -rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 30 | ||||
| -rw-r--r-- | src/devices/wifi/nm-wifi-ap.c | 4 |
10 files changed, 152 insertions, 126 deletions
diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c index d8e40d6f38..b69b432039 100644 --- a/src/devices/bluetooth/nm-bluez-device.c +++ b/src/devices/bluetooth/nm-bluez-device.c @@ -94,7 +94,7 @@ typedef struct { NMSettings *settings; GSList *connections; - NMConnection *pan_connection; + NMSettingsConnection *pan_connection; gboolean pan_connection_no_autocreate; } NMBluezDevicePrivate; @@ -114,8 +114,9 @@ G_DEFINE_TYPE (NMBluezDevice, nm_bluez_device, G_TYPE_OBJECT) /*****************************************************************************/ static void cp_connection_added (NMSettings *settings, - NMConnection *connection, NMBluezDevice *self); -static gboolean connection_compatible (NMBluezDevice *self, NMConnection *connection); + NMSettingsConnection *sett_conn, + NMBluezDevice *self); +static gboolean connection_compatible (NMBluezDevice *self, NMSettingsConnection *sett_conn); /*****************************************************************************/ @@ -181,10 +182,10 @@ nm_bluez_device_get_connected (NMBluezDevice *self) static void pan_connection_check_create (NMBluezDevice *self) { - NMConnection *connection; - NMConnection *added; + gs_unref_object NMConnection *connection = NULL; + NMSettingsConnection *added; NMSetting *setting; - char *id; + gs_free char *id = NULL; char uuid[37]; GError *error = NULL; NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); @@ -246,15 +247,14 @@ pan_connection_check_create (NMBluezDevice *self) * which then already finds the suitable connection in priv->connections. This is confusing, * so block the signal. check_emit_usable will succeed after this function call returns. */ g_signal_handlers_block_by_func (priv->settings, cp_connection_added, self); - added = NM_CONNECTION (nm_settings_add_connection (priv->settings, connection, FALSE, &error)); + added = nm_settings_add_connection (priv->settings, connection, FALSE, &error); g_signal_handlers_unblock_by_func (priv->settings, cp_connection_added, self); if (added) { - g_assert (!g_slist_find (priv->connections, added)); - g_assert (connection_compatible (self, added)); - g_assert (nm_connection_compare (added, connection, NM_SETTING_COMPARE_FLAG_EXACT)); + nm_assert (!g_slist_find (priv->connections, added)); + nm_assert (connection_compatible (self, added)); - nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added), NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED, TRUE); + nm_settings_connection_set_flags (added, NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED, TRUE); priv->connections = g_slist_prepend (priv->connections, g_object_ref (added)); priv->pan_connection = added; @@ -263,11 +263,7 @@ pan_connection_check_create (NMBluezDevice *self) nm_log_warn (LOGD_BT, "bluez[%s] couldn't add new Bluetooth connection for NAP device: '%s' (%s): %s", priv->path, id, uuid, error->message); g_clear_error (&error); - } - g_object_unref (connection); - - g_free (id); } static gboolean @@ -321,9 +317,10 @@ check_emit_usable_schedule (NMBluezDevice *self) /*****************************************************************************/ static gboolean -connection_compatible (NMBluezDevice *self, NMConnection *connection) +connection_compatible (NMBluezDevice *self, NMSettingsConnection *sett_conn) { NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); + NMConnection *connection = nm_settings_connection_get_connection (sett_conn); NMSettingBluetooth *s_bt; const char *bt_type; const char *bdaddr; @@ -361,22 +358,24 @@ connection_compatible (NMBluezDevice *self, NMConnection *connection) } static gboolean -_internal_track_connection (NMBluezDevice *self, NMConnection *connection, gboolean tracked) +_internal_track_connection (NMBluezDevice *self, + NMSettingsConnection *sett_conn, + gboolean tracked) { NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); gboolean was_tracked; - was_tracked = !!g_slist_find (priv->connections, connection); + was_tracked = !!g_slist_find (priv->connections, sett_conn); if (was_tracked == !!tracked) return FALSE; if (tracked) - priv->connections = g_slist_prepend (priv->connections, g_object_ref (connection)); + priv->connections = g_slist_prepend (priv->connections, g_object_ref (sett_conn)); else { - priv->connections = g_slist_remove (priv->connections, connection); - if (priv->pan_connection == connection) + priv->connections = g_slist_remove (priv->connections, sett_conn); + if (priv->pan_connection == sett_conn) priv->pan_connection = NULL; - g_object_unref (connection); + g_object_unref (sett_conn); } return TRUE; @@ -384,32 +383,32 @@ _internal_track_connection (NMBluezDevice *self, NMConnection *connection, gbool static void cp_connection_added (NMSettings *settings, - NMConnection *connection, + NMSettingsConnection *sett_conn, NMBluezDevice *self) { - if (connection_compatible (self, connection)) { - if (_internal_track_connection (self, connection, TRUE)) + if (connection_compatible (self, sett_conn)) { + if (_internal_track_connection (self, sett_conn, TRUE)) check_emit_usable (self); } } static void cp_connection_removed (NMSettings *settings, - NMConnection *connection, + NMSettingsConnection *sett_conn, NMBluezDevice *self) { - if (_internal_track_connection (self, connection, FALSE)) + if (_internal_track_connection (self, sett_conn, FALSE)) check_emit_usable (self); } static void cp_connection_updated (NMSettings *settings, - NMConnection *connection, + NMSettingsConnection *sett_conn, gboolean by_user, NMBluezDevice *self) { - if (_internal_track_connection (self, connection, - connection_compatible (self, connection))) + if (_internal_track_connection (self, sett_conn, + connection_compatible (self, sett_conn))) check_emit_usable_schedule (self); } @@ -423,10 +422,8 @@ load_connections (NMBluezDevice *self) connections = nm_settings_get_connections (priv->settings, NULL); for (i = 0; connections[i]; i++) { - NMConnection *connection = (NMConnection *) connections[i]; - - if (connection_compatible (self, connection)) - changed |= _internal_track_connection (self, connection, TRUE); + if (connection_compatible (self, connections[i])) + changed |= _internal_track_connection (self, connections[i], TRUE); } if (changed) check_emit_usable (self); @@ -1178,14 +1175,14 @@ dispose (GObject *object) { NMBluezDevice *self = NM_BLUEZ_DEVICE (object); NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); - NMConnection *to_delete = NULL; + NMSettingsConnection *to_delete = NULL; nm_clear_g_source (&priv->check_emit_usable_id); if (priv->pan_connection) { /* Check whether we want to remove the created connection. If so, we take a reference * and delete it at the end of dispose(). */ - if (NM_FLAGS_HAS (nm_settings_connection_get_flags (NM_SETTINGS_CONNECTION (priv->pan_connection)), + if (NM_FLAGS_HAS (nm_settings_connection_get_flags (priv->pan_connection), NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED)) to_delete = g_object_ref (priv->pan_connection); @@ -1219,8 +1216,8 @@ dispose (GObject *object) if (to_delete) { nm_log_dbg (LOGD_BT, "bluez[%s] removing Bluetooth connection for NAP device: '%s' (%s)", priv->path, - nm_connection_get_id (to_delete), nm_connection_get_uuid (to_delete)); - nm_settings_connection_delete (NM_SETTINGS_CONNECTION (to_delete), NULL); + nm_settings_connection_get_id (to_delete), nm_settings_connection_get_uuid (to_delete)); + nm_settings_connection_delete (to_delete, NULL); g_object_unref (to_delete); } diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index a11c798698..1f650d339f 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -36,6 +36,7 @@ #include "nm-setting-serial.h" #include "nm-setting-ppp.h" #include "NetworkManagerUtils.h" +#include "settings/nm-settings-connection.h" #include "nm-utils.h" #include "nm-bt-error.h" #include "platform/nm-platform.h" @@ -137,7 +138,7 @@ get_generic_capabilities (NMDevice *device) static gboolean can_auto_connect (NMDevice *device, - NMConnection *connection, + NMSettingsConnection *sett_conn, char **specific_object) { NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device); @@ -145,11 +146,11 @@ can_auto_connect (NMDevice *device, nm_assert (!specific_object || !*specific_object); - if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, connection, NULL)) + if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, sett_conn, NULL)) return FALSE; /* Can't auto-activate a DUN connection without ModemManager */ - bt_type = get_connection_bt_type (connection); + bt_type = get_connection_bt_type (nm_settings_connection_get_connection (sett_conn)); if (bt_type == NM_BT_CAPABILITY_DUN && priv->mm_running == FALSE) return FALSE; diff --git a/src/devices/nm-device-ethernet-utils.c b/src/devices/nm-device-ethernet-utils.c index 0963803573..8bdb19917a 100644 --- a/src/devices/nm-device-ethernet-utils.c +++ b/src/devices/nm-device-ethernet-utils.c @@ -18,31 +18,23 @@ #include "nm-default.h" -#include <string.h> - -#include "nm-connection.h" - #include "nm-device-ethernet-utils.h" +#include "settings/nm-settings-connection.h" + char * -nm_device_ethernet_utils_get_default_wired_name (NMConnection *const *connections) +nm_device_ethernet_utils_get_default_wired_name (GHashTable *existing_ids) { char *temp; - guint j; int i; /* Find the next available unique connection name */ for (i = 1; i <= G_MAXINT; i++) { temp = g_strdup_printf (_("Wired connection %d"), i); - for (j = 0; connections[j]; j++) { - if (nm_streq0 (nm_connection_get_id (connections[j]), temp)) { - g_free (temp); - goto next; - } - } - return temp; -next: - ; + if ( !existing_ids + || !g_hash_table_contains (existing_ids, temp)) + return temp; + g_free (temp); } return NULL; } diff --git a/src/devices/nm-device-ethernet-utils.h b/src/devices/nm-device-ethernet-utils.h index 197d0a9ea4..7e5c8b313c 100644 --- a/src/devices/nm-device-ethernet-utils.h +++ b/src/devices/nm-device-ethernet-utils.h @@ -19,6 +19,6 @@ #ifndef __NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H__ #define __NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H__ -char *nm_device_ethernet_utils_get_default_wired_name (NMConnection *const *connections); +char *nm_device_ethernet_utils_get_default_wired_name (GHashTable *existing_ids); #endif /* NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H */ diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 0d9038983c..4d4624b7f8 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -1443,12 +1443,14 @@ new_default_connection (NMDevice *self) NMConnection *connection; NMSettingsConnection *const*connections; NMSetting *setting; + gs_unref_hashtable GHashTable *existing_ids = NULL; struct udev_device *dev; const char *perm_hw_addr; const char *uprop = "0"; gs_free char *defname = NULL; gs_free char *uuid = NULL; gs_free char *machine_id = NULL; + guint i, n_connections; if (nm_config_get_no_auto_default_for_device (nm_config_get (), self)) return NULL; @@ -1461,8 +1463,13 @@ new_default_connection (NMDevice *self) setting = nm_setting_connection_new (); nm_connection_add_setting (connection, setting); - connections = nm_settings_get_connections (nm_device_get_settings (self), NULL); - defname = nm_device_ethernet_utils_get_default_wired_name ((NMConnection *const*) connections); + connections = nm_settings_get_connections (nm_device_get_settings (self), &n_connections); + if (n_connections > 0) { + existing_ids = g_hash_table_new (nm_str_hash, g_str_equal); + for (i = 0; i < n_connections; i++) + g_hash_table_add (existing_ids, (char *) nm_settings_connection_get_id (connections[i])); + } + defname = nm_device_ethernet_utils_get_default_wired_name (existing_ids); if (!defname) return NULL; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index b1faf13e15..55a81e4f34 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1736,7 +1736,7 @@ nm_device_parent_find_for_connection (NMDevice *self, current_setting_parent); if ( parent_connection && nm_device_check_connection_compatible (parent_device, - NM_CONNECTION (parent_connection), + nm_settings_connection_get_connection (parent_connection), NULL)) return current_setting_parent; } @@ -2346,6 +2346,22 @@ nm_device_get_settings_connection (NMDevice *self) } NMConnection * +nm_device_get_settings_connection_get_connection (NMDevice *self) +{ + NMSettingsConnection *sett_con; + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + if (!priv->act_request.obj) + return NULL; + + sett_con = nm_act_request_get_settings_connection (priv->act_request.obj); + if (!sett_con) + return NULL; + + return nm_settings_connection_get_connection (sett_con); +} + +NMConnection * nm_device_get_applied_connection (NMDevice *self) { NMDevicePrivate *priv; @@ -5193,7 +5209,7 @@ nm_device_autoconnect_allowed (NMDevice *self) static gboolean can_auto_connect (NMDevice *self, - NMConnection *connection, + NMSettingsConnection *sett_conn, char **specific_object) { nm_assert (!specific_object || !*specific_object); @@ -5203,27 +5219,27 @@ can_auto_connect (NMDevice *self, /** * nm_device_can_auto_connect: * @self: an #NMDevice - * @connection: a #NMConnection + * @sett_conn: a #NMSettingsConnection * @specific_object: (out) (transfer full): on output, the path of an * object associated with the returned connection, to be passed to * nm_manager_activate_connection(), or %NULL. * - * Checks if @connection can be auto-activated on @self right now. + * Checks if @sett_conn can be auto-activated on @self right now. * This requires, at a minimum, that the connection be compatible with * @self, and that it have the #NMSettingConnection:autoconnect property * set, and that the device allow auto connections. Some devices impose * additional requirements. (Eg, a Wi-Fi connection can only be activated * if its SSID was seen in the last scan.) * - * Returns: %TRUE, if the @connection can be auto-activated. + * Returns: %TRUE, if the @sett_conn can be auto-activated. **/ gboolean nm_device_can_auto_connect (NMDevice *self, - NMConnection *connection, + NMSettingsConnection *sett_conn, char **specific_object) { g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); - g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE); + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (sett_conn), FALSE); g_return_val_if_fail (!specific_object || !*specific_object, FALSE); /* the caller must ensure that nm_device_autoconnect_allowed() returns @@ -5235,10 +5251,14 @@ nm_device_can_auto_connect (NMDevice *self, * over and over again. The caller is supposed to do that. */ nm_assert (nm_device_autoconnect_allowed (self)); - if (!nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL, NULL)) + if (!nm_device_check_connection_available (self, + nm_settings_connection_get_connection (sett_conn), + NM_DEVICE_CHECK_CON_AVAILABLE_NONE, + NULL, + NULL)) return FALSE; - if (!NM_DEVICE_GET_CLASS (self)->can_auto_connect (self, connection, specific_object)) + if (!NM_DEVICE_GET_CLASS (self)->can_auto_connect (self, sett_conn, specific_object)) return FALSE; return TRUE; @@ -11095,7 +11115,7 @@ reapply_cb (NMDevice *self, nm_device_sys_iface_state_set (self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); if (!check_and_reapply_connection (self, - connection ?: (NMConnection *) nm_device_get_settings_connection (self), + connection ?: nm_device_get_settings_connection_get_connection (self), version_id, &audit_args, &local)) { @@ -11883,7 +11903,8 @@ nm_device_set_ip_config (NMDevice *self, NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED) && nm_active_connection_get_activation_type (NM_ACTIVE_CONNECTION (priv->act_request.obj)) == NM_ACTIVATION_TYPE_EXTERNAL) { g_object_freeze_notify (G_OBJECT (settings_connection)); - nm_connection_add_setting (NM_CONNECTION (settings_connection), + /* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */ + nm_connection_add_setting (nm_settings_connection_get_connection (settings_connection), IS_IPv4 ? nm_ip4_config_create_setting (priv->ip_config_4) : nm_ip6_config_create_setting (priv->ip_config_6)); @@ -13342,7 +13363,7 @@ nm_device_reapply_settings_immediately (NMDevice *self) NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY)) return; - s_con_settings = nm_connection_get_setting_connection ((NMConnection *) settings_connection); + s_con_settings = nm_connection_get_setting_connection (nm_settings_connection_get_connection (settings_connection)); s_con_applied = nm_connection_get_setting_connection (applied_connection); if (g_strcmp0 ((zone = nm_setting_connection_get_zone (s_con_settings)), @@ -13603,15 +13624,15 @@ available_connections_del_all (NMDevice *self) } static gboolean -available_connections_add (NMDevice *self, NMConnection *connection) +available_connections_add (NMDevice *self, NMSettingsConnection *sett_conn) { - return g_hash_table_add (self->_priv->available_connections, g_object_ref (connection)); + return g_hash_table_add (self->_priv->available_connections, g_object_ref (sett_conn)); } static gboolean -available_connections_del (NMDevice *self, NMConnection *connection) +available_connections_del (NMDevice *self, NMSettingsConnection *sett_conn) { - return g_hash_table_remove (self->_priv->available_connections, connection); + return g_hash_table_remove (self->_priv->available_connections, sett_conn); } static gboolean @@ -13657,7 +13678,7 @@ nm_device_recheck_available_connections (NMDevice *self) NMSettingsConnection *const*connections; gboolean changed = FALSE; GHashTableIter h_iter; - NMConnection *connection; + NMSettingsConnection *sett_conn; guint i; gs_unref_hashtable GHashTable *prune_list = NULL; @@ -13668,30 +13689,30 @@ nm_device_recheck_available_connections (NMDevice *self) if (g_hash_table_size (priv->available_connections) > 0) { prune_list = g_hash_table_new (nm_direct_hash, NULL); g_hash_table_iter_init (&h_iter, priv->available_connections); - while (g_hash_table_iter_next (&h_iter, (gpointer *) &connection, NULL)) - g_hash_table_add (prune_list, connection); + while (g_hash_table_iter_next (&h_iter, (gpointer *) &sett_conn, NULL)) + g_hash_table_add (prune_list, sett_conn); } connections = nm_settings_get_connections (priv->settings, NULL); for (i = 0; connections[i]; i++) { - connection = (NMConnection *) connections[i]; + sett_conn = connections[i]; if (nm_device_check_connection_available (self, - connection, + nm_settings_connection_get_connection (sett_conn), NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL, NULL)) { - if (available_connections_add (self, connection)) + if (available_connections_add (self, sett_conn)) changed = TRUE; if (prune_list) - g_hash_table_remove (prune_list, connection); + g_hash_table_remove (prune_list, sett_conn); } } if (prune_list) { g_hash_table_iter_init (&h_iter, prune_list); - while (g_hash_table_iter_next (&h_iter, (gpointer *) &connection, NULL)) { - if (available_connections_del (self, connection)) + while (g_hash_table_iter_next (&h_iter, (gpointer *) &sett_conn, NULL)) { + if (available_connections_del (self, sett_conn)) changed = TRUE; } } @@ -13718,7 +13739,7 @@ nm_device_get_best_connection (NMDevice *self, GError **error) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - NMSettingsConnection *connection = NULL; + NMSettingsConnection *sett_conn = NULL; NMSettingsConnection *candidate; guint64 best_timestamp = 0; GHashTableIter iter; @@ -13732,44 +13753,44 @@ nm_device_get_best_connection (NMDevice *self, */ if ( specific_object /* << Optimization: we know that the connection is available without @specific_object. */ && !nm_device_check_connection_available (self, - NM_CONNECTION (candidate), + nm_settings_connection_get_connection (candidate), _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, specific_object, NULL)) continue; nm_settings_connection_get_timestamp (candidate, &candidate_timestamp); - if (!connection || (candidate_timestamp > best_timestamp)) { - connection = candidate; + if (!sett_conn || (candidate_timestamp > best_timestamp)) { + sett_conn = candidate; best_timestamp = candidate_timestamp; } } - if (!connection) { + if (!sett_conn) { g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION, "The device '%s' has no connections available for activation.", nm_device_get_iface (self)); } - return connection; + return sett_conn; } static void -cp_connection_added_or_updated (NMDevice *self, NMConnection *connection) +cp_connection_added_or_updated (NMDevice *self, NMSettingsConnection *sett_conn) { gboolean changed; g_return_if_fail (NM_IS_DEVICE (self)); - g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection)); + g_return_if_fail (NM_IS_SETTINGS_CONNECTION (sett_conn)); if (nm_device_check_connection_available (self, - connection, + nm_settings_connection_get_connection (sett_conn), _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL, NULL)) - changed = available_connections_add (self, connection); + changed = available_connections_add (self, sett_conn); else - changed = available_connections_del (self, connection); + changed = available_connections_del (self, sett_conn); if (changed) { _notify (self, PROP_AVAILABLE_CONNECTIONS); @@ -13778,25 +13799,25 @@ cp_connection_added_or_updated (NMDevice *self, NMConnection *connection) } static void -cp_connection_added (NMSettings *settings, NMConnection *connection, gpointer user_data) +cp_connection_added (NMSettings *settings, NMSettingsConnection *sett_conn, gpointer user_data) { - cp_connection_added_or_updated (user_data, connection); + cp_connection_added_or_updated (user_data, sett_conn); } static void -cp_connection_updated (NMSettings *settings, NMConnection *connection, gboolean by_user, gpointer user_data) +cp_connection_updated (NMSettings *settings, NMSettingsConnection *sett_conn, gboolean by_user, gpointer user_data) { - cp_connection_added_or_updated (user_data, connection); + cp_connection_added_or_updated (user_data, sett_conn); } static void -cp_connection_removed (NMSettings *settings, NMConnection *connection, gpointer user_data) +cp_connection_removed (NMSettings *settings, NMSettingsConnection *sett_conn, gpointer user_data) { NMDevice *self = user_data; g_return_if_fail (NM_IS_DEVICE (self)); - if (available_connections_del (self, connection)) { + if (available_connections_del (self, sett_conn)) { _notify (self, PROP_AVAILABLE_CONNECTIONS); available_connections_check_delete_unrealized (self); } @@ -14436,7 +14457,7 @@ _set_state_full (NMDevice *self, NMDeviceState old_state; NMActRequest *req; gboolean no_firmware = FALSE; - NMSettingsConnection *connection; + NMSettingsConnection *sett_conn; g_return_if_fail (NM_IS_DEVICE (self)); @@ -14695,10 +14716,10 @@ _set_state_full (NMDevice *self, break; } - connection = nm_device_get_settings_connection (self); + sett_conn = nm_device_get_settings_connection (self); _LOGW (LOGD_DEVICE | LOGD_WIFI, "Activation: failed for connection '%s'", - connection ? nm_settings_connection_get_id (connection) : "<unknown>"); + sett_conn ? nm_settings_connection_get_id (sett_conn) : "<unknown>"); /* Notify any slaves of the unexpected failure */ nm_device_master_release_slaves (self); @@ -14708,8 +14729,8 @@ _set_state_full (NMDevice *self, * failed (zero timestamp), connections that succeeded (non-zero timestamp), * and those we haven't tried yet (no timestamp). */ - if (connection && !nm_settings_connection_get_timestamp (connection, NULL)) - nm_settings_connection_update_timestamp (connection, (guint64) 0, TRUE); + if (sett_conn && !nm_settings_connection_get_timestamp (sett_conn, NULL)) + nm_settings_connection_update_timestamp (sett_conn, (guint64) 0, TRUE); /* Schedule the transition to DISCONNECTED. The device can't transition * immediately because we can't change states again from the state diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 9660ee3eb2..7d74e5b91d 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -297,7 +297,7 @@ typedef struct _NMDeviceClass { gboolean (* get_autoconnect_allowed) (NMDevice *self); gboolean (* can_auto_connect) (NMDevice *self, - NMConnection *connection, + NMSettingsConnection *sett_conn, char **specific_object); guint32 (*get_configured_mtu) (NMDevice *self, NMDeviceMtuSource *out_source); @@ -512,6 +512,7 @@ NMDevice * nm_device_get_master (NMDevice *dev); NMActRequest * nm_device_get_act_request (NMDevice *dev); NMSettingsConnection *nm_device_get_settings_connection (NMDevice *dev); +NMConnection * nm_device_get_settings_connection_get_connection (NMDevice *self); NMConnection * nm_device_get_applied_connection (NMDevice *dev); gboolean nm_device_has_unmodified_applied_connection (NMDevice *self, NMSettingCompareFlags compare_flags); @@ -535,7 +536,7 @@ gboolean nm_device_master_update_slave_connection (NMDevice *master, GError **error); gboolean nm_device_can_auto_connect (NMDevice *self, - NMConnection *connection, + NMSettingsConnection *sett_conn, char **specific_object); gboolean nm_device_complete_connection (NMDevice *device, diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c index 3a6855cbad..3be6159f24 100644 --- a/src/devices/wifi/nm-device-iwd.c +++ b/src/devices/wifi/nm-device-iwd.c @@ -797,11 +797,12 @@ get_autoconnect_allowed (NMDevice *device) static gboolean can_auto_connect (NMDevice *device, - NMConnection *connection, + NMSettingsConnection *sett_conn, char **specific_object) { NMDeviceIwd *self = NM_DEVICE_IWD (device); NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self); + NMConnection *connection; NMSettingWireless *s_wifi; NMWifiAP *ap; const char *mode; @@ -809,9 +810,11 @@ can_auto_connect (NMDevice *device, nm_assert (!specific_object || !*specific_object); - if (!NM_DEVICE_CLASS (nm_device_iwd_parent_class)->can_auto_connect (device, connection, NULL)) + if (!NM_DEVICE_CLASS (nm_device_iwd_parent_class)->can_auto_connect (device, sett_conn, NULL)) return FALSE; + connection = nm_settings_connection_get_connection (sett_conn); + s_wifi = nm_connection_get_setting_wireless (connection); g_return_val_if_fail (s_wifi, FALSE); @@ -824,7 +827,7 @@ can_auto_connect (NMDevice *device, * but haven't been successful, since these are often accidental choices * from the menu and the user may not know the password. */ - if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), ×tamp)) { + if (nm_settings_connection_get_timestamp (sett_conn, ×tamp)) { if (timestamp == 0) return FALSE; } diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 5190faf742..e4b105eb32 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -958,11 +958,12 @@ get_autoconnect_allowed (NMDevice *device) static gboolean can_auto_connect (NMDevice *device, - NMConnection *connection, + NMSettingsConnection *sett_conn, char **specific_object) { NMDeviceWifi *self = NM_DEVICE_WIFI (device); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); + NMConnection *connection; NMSettingWireless *s_wifi; NMWifiAP *ap; const char *method, *mode; @@ -970,26 +971,28 @@ can_auto_connect (NMDevice *device, nm_assert (!specific_object || !*specific_object); - if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, NULL)) + if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, sett_conn, NULL)) return FALSE; + connection = nm_settings_connection_get_connection (sett_conn); + s_wifi = nm_connection_get_setting_wireless (connection); g_return_val_if_fail (s_wifi, FALSE); /* Always allow autoconnect for AP and non-autoconf Ad-Hoc */ method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG); mode = nm_setting_wireless_get_mode (s_wifi); - if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_AP) == 0) + if (nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_AP)) return TRUE; - else if ( g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0 - && g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) != 0) + else if ( nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) + && !nm_streq0 (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) return TRUE; /* Don't autoconnect to networks that have been tried at least once * but haven't been successful, since these are often accidental choices * from the menu and the user may not know the password. */ - if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), ×tamp)) { + if (nm_settings_connection_get_timestamp (sett_conn, ×tamp)) { if (timestamp == 0) return FALSE; } @@ -1264,14 +1267,15 @@ check_scanning_prohibited (NMDeviceWifi *self, gboolean periodic) static gboolean hidden_filter_func (NMSettings *settings, - NMSettingsConnection *connection, + NMSettingsConnection *set_con, gpointer user_data) { + NMConnection *connection = nm_settings_connection_get_connection (set_con); NMSettingWireless *s_wifi; - if (!nm_connection_is_type (NM_CONNECTION (connection), NM_SETTING_WIRELESS_SETTING_NAME)) + if (!nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME)) return FALSE; - s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (connection)); + s_wifi = nm_connection_get_setting_wireless (connection); if (!s_wifi) return FALSE; if (nm_streq0 (nm_setting_wireless_get_mode (s_wifi), NM_SETTING_WIRELESS_MODE_AP)) @@ -1316,7 +1320,7 @@ build_hidden_probe_list (NMDeviceWifi *self) if (i >= max_scan_ssids - 1) break; - s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (NM_CONNECTION (connections[i])); + s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (nm_settings_connection_get_connection (connections[i])); ssid = nm_setting_wireless_get_ssid (s_wifi); g_ptr_array_add (ssids, g_bytes_ref (ssid)); } @@ -1509,12 +1513,12 @@ try_fill_ssid_for_hidden_ap (NMDeviceWifi *self, * and if a match is found, copy over the SSID */ connections = nm_settings_get_connections (nm_device_get_settings ((NMDevice *) self), NULL); for (i = 0; connections[i]; i++) { - NMConnection *connection = (NMConnection *) connections[i]; + NMSettingsConnection *sett_conn = connections[i]; NMSettingWireless *s_wifi; - s_wifi = nm_connection_get_setting_wireless (connection); + s_wifi = nm_connection_get_setting_wireless (nm_settings_connection_get_connection (sett_conn)); if (s_wifi) { - if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) { + if (nm_settings_connection_has_seen_bssid (sett_conn, bssid)) { nm_wifi_ap_set_ssid (ap, nm_setting_wireless_get_ssid (s_wifi)); break; } diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index 7cfc659875..1dbc054af4 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -1544,8 +1544,8 @@ nm_wifi_ap_lookup_for_device (NMDevice *device, const char *exported_path) g_return_val_if_fail (NM_IS_DEVICE (device), NULL); - ap = (NMWifiAP *) nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (device)), - exported_path); + ap = nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (device)), + exported_path); if ( !ap || !NM_IS_WIFI_AP (ap) || ap->wifi_device != device) |
