Commit 38273a88 authored by Thomas Haller's avatar Thomas Haller

settings: use delegation instead of inheritance for NMSettingsConnection and NMConnection

NMConnection is an interface, which is implemented by the types
NMSimpleConnection (libnm-core), NMSettingsConnection (src) and
NMRemoteConnection (libnm).

NMSettingsConnection does a lot of things already:

  1) it "is-a" NMDBusObject and exports the API of a connection profile
     on D-Bus
  2) it interacts with NMSettings and contains functionality
     for tracking the profiles.
  3) it is the base-class of types like NMSKeyfileConnection and
     NMIfcfgConnection. These handle how the profile is persisted
     on disk.
  4) it implements NMConnection interface, to itself track the
     settings of the profile.

3) and 4) would be better implemented via delegation than inheritance.

Address 4) and don't let NMSettingsConnection implemente the NMConnection
interface. Instead, a settings-connection references now a NMSimpleConnection
instance, to which it delegates for keeping the actual profiles.

Advantages:

  - by delegating, there is a clearer separation of what
    NMSettingsConnection does. For example, in C we often required
    casts from NMSettingsConnection to NMConnection. NMConnection
    is a very trivial object with very little logic. When we have
    a NMConnection instance at hand, it's good to know that it is
    *only* that simple instead of also being an entire
    NMSettingsConnection instance.

    The main purpose of this patch is to simplify the code by separating
    the NMConnection from the NMSettingsConnection. We should generally
    be aware whether we handle a NMSettingsConnection or a trivial
    NMConnection instance. Now, because NMSettingsConnection no longer
    "is-a" NMConnection, this distinction is apparent.

  - NMConnection is implemented as an interface and we create
    NMSimpleConnection instances whenever we need a real instance.
    In GLib, interfaces have a performance overhead, that we needlessly
    pay all the time. With this change, we no longer require
    NMConnection to be an interface. Thus, in the future we could compile
    a version of libnm-core for the daemon, where NMConnection is not an
    interface but a GObject implementation akin to NMSimpleConnection.

  - In the previous implementation, we cannot treat NMConnection immutable
    and copy-on-write.
    For example, when NMDevice needs a snapshot of the activated
    profile as applied-connection, all it can do is clone the entire
    NMSettingsConnection as a NMSimpleConnection.
    Likewise, when we get a NMConnection instance and want to keep
    a reference to it, we cannot do that, because we never know
    who also references and modifies the instance.
    By separating NMSettingsConnection we could in the future have
    NMConnection immutable and copy-on-write, to avoid all unnecessary
    clones.
parent 3a99c343
......@@ -805,9 +805,11 @@ nm_utils_match_connection (NMConnection *const*connections,
return NULL;
for (; *connections; connections++) {
NMConnection *candidate = NM_CONNECTION (*connections);
NMConnection *candidate = *connections;
GHashTable *diffs = NULL;
nm_assert (NM_IS_CONNECTION (candidate));
if (match_filter_func) {
if (!match_filter_func (candidate, match_filter_data))
continue;
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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 */
......@@ -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;
......
This diff is collapsed.
......@@ -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,
......
......@@ -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), &timestamp)) {
if (nm_settings_connection_get_timestamp (sett_conn, &timestamp)) {
if (timestamp == 0)
return FALSE;
}
......
......@@ -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), &timestamp)) {
if (nm_settings_connection_get_timestamp (sett_conn, &timestamp)) {
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;
}
......
......@@ -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)
......
This diff is collapsed.
......@@ -265,8 +265,8 @@ nm_checkpoint_manager_lookup_by_path (NMCheckpointManager *self, const char *pat
g_return_val_if_fail (self, NULL);
checkpoint = (NMCheckpoint *) nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (GET_MANAGER (self))),
path);
checkpoint = nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (GET_MANAGER (self))),
path);
if ( !checkpoint
|| !NM_IS_CHECKPOINT (checkpoint)) {
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INVALID_ARGUMENTS,
......
......@@ -159,7 +159,7 @@ find_settings_connection (NMCheckpoint *self,
{
NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self);
NMActiveConnection *active;
NMSettingsConnection *connection;
NMSettingsConnection *sett_conn;
const char *uuid, *ac_uuid;
const CList *tmp_clist;
......@@ -167,14 +167,14 @@ find_settings_connection (NMCheckpoint *self,
*need_update = FALSE;
uuid = nm_connection_get_uuid (dev_checkpoint->settings_connection);
connection = nm_settings_get_connection_by_uuid (nm_settings_get (), uuid);
sett_conn = nm_settings_get_connection_by_uuid (nm_settings_get (), uuid);
if (!connection)
if (!sett_conn)
return NULL;
/* Now check if the connection changed, ... */
if (!nm_connection_compare (dev_checkpoint->settings_connection,
NM_CONNECTION (connection),
nm_settings_connection_get_connection (sett_conn),
NM_SETTING_COMPARE_FLAG_EXACT)) {
_LOGT ("rollback: settings connection %s changed", uuid);
*need_update = TRUE;
......@@ -193,7 +193,7 @@ find_settings_connection (NMCheckpoint *self,
if (!active) {
_LOGT ("rollback: connection %s is not active", uuid);
*need_activation = TRUE;
return connection;
return sett_conn;
}
/* ... or if the connection was reactivated/reapplied */
......@@ -202,7 +202,7 @@ find_settings_connection (NMCheckpoint *self,
*need_activation = TRUE;
}
return connection;
return sett_conn;
}
GVariant *
......@@ -337,8 +337,8 @@ activate:
dev_checkpoint->activation_reason,
&local_error)) {
_LOGW ("rollback: reactivation of connection %s/%s failed: %s",
nm_connection_get_id ((NMConnection *) connection),
nm_connection_get_uuid ((NMConnection *) connection),
nm_settings_connection_get_id (connection),
nm_settings_connection_get_uuid (connection),
local_error->message);
g_clear_error (&local_error);
result = NM_ROLLBACK_RESULT_ERR_FAILED;
......@@ -436,12 +436,9 @@ device_checkpoint_create (NMDevice *device)
applied_connection = nm_act_request_get_applied_connection (act_request);
dev_checkpoint->applied_connection = nm_simple_connection_new_clone (applied_connection);
dev_checkpoint->settings_connection =
nm_simple_connection_new_clone (NM_CONNECTION (settings_connection));
dev_checkpoint->ac_version_id =
nm_active_connection_version_id_get (NM_ACTIVE_CONNECTION (act_request));
dev_checkpoint->activation_reason =
nm_active_connection_get_activation_reason (NM_ACTIVE_CONNECTION (act_request));
dev_checkpoint->settings_connection = nm_simple_connection_new_clone (nm_settings_connection_get_connection (settings_connection));
dev_checkpoint->ac_version_id = nm_active_connection_version_id_get (NM_ACTIVE_CONNECTION (act_request));
dev_checkpoint->activation_reason = nm_active_connection_get_activation_reason (NM_ACTIVE_CONNECTION (act_request));
}
return dev_checkpoint;
......
......@@ -1084,7 +1084,7 @@ _obj_unregister (NMDBusManager *self,
NULL);
}
NMDBusObject *
gpointer
nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path)
{
NMDBusManagerPrivate *priv;
......
......@@ -61,7 +61,7 @@ gboolean nm_dbus_manager_is_stopping (NMDBusManager *self);
GDBusConnection *nm_dbus_manager_get_connection (NMDBusManager *self);
NMDBusObject *nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path);
gpointer nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path);
void _nm_dbus_manager_obj_export (NMDBusObject *obj);
void _nm_dbus_manager_obj_unexport (NMDBusObject *obj);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -139,6 +139,8 @@ struct _NMSettingsConnectionClass {
GType nm_settings_connection_get_type (void);
NMConnection *nm_settings_connection_get_connection (NMSettingsConnection *self);
guint64 nm_settings_connection_get_last_secret_agent_version_id (NMSettingsConnection *self);
gboolean nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection *self,
......@@ -268,7 +270,13 @@ void nm_settings_connection_set_filename (NMSettingsConnection *self,
const char *filename);
const char *nm_settings_connection_get_filename (NMSettingsConnection *self);
const char *nm_settings_connection_get_id (NMSettingsConnection *connection);
const char *nm_settings_connection_get_uuid (NMSettingsConnection *connection);
const char *nm_settings_connection_get_id (NMSettingsConnection *connection);
const char *nm_settings_connection_get_uuid (NMSettingsConnection *connection);
const char *nm_settings_connection_get_connection_type (NMSettingsConnection *connection);
/*****************************************************************************/
NMConnection **nm_settings_connections_array_to_connections (NMSettingsConnection *const*connections,
gssize n_connections);
#endif /* __NETWORKMANAGER_SETTINGS_CONNECTION_H__ */
This diff is collapsed.
......@@ -85,7 +85,7 @@ void nm_settings_add_connection_dbus (NMSettings *self,
NMSettingsAddCallback callback,
gpointer user_data);
NMSettingsConnection *const* nm_settings_get_connections (NMSettings *settings, guint *out_len);
NMSettingsConnection *const*nm_settings_get_connections (NMSettings *settings, guint *out_len);
NMSettingsConnection **nm_settings_get_connections_clone (NMSettings *self,
guint *out_len,
......
......@@ -84,9 +84,9 @@ read_connections (NMSIbftPlugin *self)
connection = nms_ibft_connection_new (iter->data, &error);
if (connection) {
nm_log_info (LOGD_SETTINGS, "ibft: read connection '%s'",
nm_connection_get_id (NM_CONNECTION (connection)));
nm_settings_connection_get_id (NM_SETTINGS_CONNECTION (connection)));
g_hash_table_insert (priv->connections,
g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))),
g_strdup (nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection))),
connection);
} else {
nm_log_warn (LOGD_SETTINGS, "ibft: failed to read iscsiadm record: %s", error->message);
......
......@@ -143,7 +143,7 @@ devtimeout_expired (gpointer user_data)
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self);
nm_log_info (LOGD_SETTINGS, "Device for connection '%s' did not appear before timeout",
nm_connection_get_id (NM_CONNECTION (self)));
nm_settings_connection_get_id (NM_SETTINGS_CONNECTION (self)));
g_signal_handler_disconnect (NM_PLATFORM_GET, priv->devtimeout_link_changed_handler);
priv->devtimeout_link_changed_handler = 0;
......@@ -163,7 +163,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
guint devtimeout;
const NMPlatformLink *pllink;
s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (self)));
if (!nm_setting_connection_get_autoconnect (s_con))
return;
......@@ -186,7 +186,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), FALSE);
nm_log_info (LOGD_SETTINGS, "Waiting %u seconds for %s to appear for connection '%s'",
devtimeout, ifname, nm_connection_get_id (NM_CONNECTION (self)));
devtimeout, ifname, nm_settings_connection_get_id (NM_SETTINGS_CONNECTION (self)));
priv->devtimeout_link_changed_handler =
g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED,
......
......@@ -139,7 +139,7 @@ static void
connection_removed_cb (NMSettingsConnection *obj, gpointer user_data)
{
g_hash_table_remove (SETTINGS_PLUGIN_IFCFG_GET_PRIVATE ((SettingsPluginIfcfg *) user_data)->connections,
nm_connection_get_uuid (NM_CONNECTION (obj)));
nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (obj)));
}
static void
......@@ -157,7 +157,7 @@ remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection)
unrecognized = !!nm_ifcfg_connection_get_unrecognized_spec (connection);
g_object_ref (connection);
g_hash_table_remove (priv->connections, nm_connection_get_uuid (NM_CONNECTION (connection)));
g_hash_table_remove (priv->connections, nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection)));
if (!unmanaged && !unrecognized)
nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection));
g_object_unref (connection);
......@@ -228,7 +228,7 @@ update_connection (SettingsPluginIfcfg *self,
return NULL;
}
uuid = nm_connection_get_uuid (NM_CONNECTION (connection_new));
uuid = nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection_new));
connection_by_uuid = g_hash_table_lookup (priv->connections, uuid);
if ( connection
......@@ -285,12 +285,16 @@ update_connection (SettingsPluginIfcfg *self,
if ( !unmanaged_changed
&& !unrecognized_changed
&& nm_connection_compare (NM_CONNECTION (connection_by_uuid),
NM_CONNECTION (connection_new),
&& nm_connection_compare (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (connection_by_uuid)),
nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (connection_new)),
NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) {
if (old_path && g_strcmp0 (old_path, full_path) != 0)
_LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT" without other changes", nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)), NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
if ( old_path