summaryrefslogtreecommitdiff
path: root/src/settings/nm-settings-storage.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-07-01 18:28:48 +0200
committerThomas Haller <thaller@redhat.com>2019-07-08 14:23:15 +0200
commit852e0c5ee2ec9b2ac92401707a6ab8e2fd92c1d4 (patch)
tree91cc6b3cc83087153e8e2ca47b9a0eac3e2ce1ef /src/settings/nm-settings-storage.c
parente356fde636324f3fbb4ff3387dc6af1c9748517c (diff)
downloadNetworkManager-852e0c5ee2ec9b2ac92401707a6ab8e2fd92c1d4.tar.gz
fixup! settings: rework tracking settings connections and settings pluginsth/settings-delegate-storage-1
Diffstat (limited to 'src/settings/nm-settings-storage.c')
-rw-r--r--src/settings/nm-settings-storage.c73
1 files changed, 14 insertions, 59 deletions
diff --git a/src/settings/nm-settings-storage.c b/src/settings/nm-settings-storage.c
index d07da2ca39..2d1303ddb3 100644
--- a/src/settings/nm-settings-storage.c
+++ b/src/settings/nm-settings-storage.c
@@ -48,8 +48,8 @@ nm_settings_storage_cmp (NMSettingsStorage *a,
nm_assert (nm_streq (nm_settings_storage_get_uuid (a), nm_settings_storage_get_uuid (b)));
/* in-memory has always higher priority */
- NM_CMP_DIRECT (nm_settings_storage_is_in_memory (a),
- nm_settings_storage_is_in_memory (b));
+ NM_CMP_DIRECT (nm_settings_storage_is_keyfile_run (a),
+ nm_settings_storage_is_keyfile_run (b));
plugin_a = nm_settings_storage_get_plugin (a);
plugin_b = nm_settings_storage_get_plugin (b);
@@ -58,6 +58,7 @@ nm_settings_storage_cmp (NMSettingsStorage *a,
int idx_a = g_slist_index ((GSList *) plugin_list, plugin_a);
int idx_b = g_slist_index ((GSList *) plugin_list, plugin_b);
+ /* the plugins must be found in the list. */
nm_assert (idx_a >= 0);
nm_assert (idx_b >= 0);
nm_assert (idx_a != idx_b);
@@ -70,19 +71,17 @@ nm_settings_storage_cmp (NMSettingsStorage *a,
return 0;
}
- /* a hidden storage (tombstone) has higher priority... */
- NM_CMP_DIRECT (nm_settings_storage_is_tombstone (a),
- nm_settings_storage_is_tombstone (b));
-
klass = NM_SETTINGS_STORAGE_GET_CLASS (a);
if (klass != NM_SETTINGS_STORAGE_GET_CLASS (b)) {
+ /* one plugin must return storages of the same type. Otherwise, it's
+ * unclear how cmp_fcn() should compare them. */
nm_assert_not_reached ();
return 0;
}
- if (klass->storage_cmp)
- NM_CMP_RETURN (klass->storage_cmp (a, b));
+ if (klass->cmp_fcn)
+ NM_CMP_RETURN (klass->cmp_fcn (a, b));
return 0;
}
@@ -99,54 +98,6 @@ G_DEFINE_TYPE (NMSettingsStorage, nm_settings_storage, G_TYPE_OBJECT)
/*****************************************************************************/
-void
-_nm_settings_storage_set_filename (NMSettingsStorage *self,
- const char *filename)
-{
- g_return_if_fail (NM_IS_SETTINGS_STORAGE (self));
-
- if (nm_streq0 (self->_filename, filename))
- return;
-
- g_free (self->_filename);
- self->_filename = g_strdup (filename);
- _notify (self, PROP_FILENAME);
-}
-
-void
-_nm_settings_storage_set_filename_take (NMSettingsStorage *self,
- char *filename)
-{
- g_return_if_fail (NM_IS_SETTINGS_STORAGE (self));
-
- if (nm_streq0 (self->_filename, filename)) {
- g_free (filename);
- return;
- }
-
- g_free (self->_filename);
- self->_filename = filename;
- _notify (self, PROP_FILENAME);
-}
-
-/*****************************************************************************/
-
-static void
-get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
-{
- NMSettingsStorage *self = NM_SETTINGS_STORAGE (object);
-
- switch (prop_id) {
- case PROP_FILENAME:
- g_value_set_string (value, nm_settings_storage_get_filename (self));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
@@ -162,7 +113,7 @@ set_property (GObject *object, guint prop_id,
case PROP_UUID:
/* construct-only */
self->_uuid = g_value_dup_string (value);
- nm_assert (nm_utils_is_uuid (self->_uuid));
+ nm_assert (!self->_uuid || nm_utils_is_uuid (self->_uuid));
break;
case PROP_FILENAME:
/* construct-only */
@@ -179,6 +130,8 @@ set_property (GObject *object, guint prop_id,
static void
nm_settings_storage_init (NMSettingsStorage *self)
{
+ c_list_init (&self->_storage_lst);
+ c_list_init (&self->_storage_by_uuid_lst);
}
NMSettingsStorage *
@@ -201,6 +154,9 @@ finalize (GObject *object)
{
NMSettingsStorage *self = NM_SETTINGS_STORAGE (object);
+ c_list_unlink_stale (&self->_storage_lst);
+ c_list_unlink_stale (&self->_storage_by_uuid_lst);
+
g_object_unref (self->_plugin);
g_free (self->_uuid);
g_free (self->_filename);
@@ -213,7 +169,6 @@ nm_settings_storage_class_init (NMSettingsStorageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
@@ -234,7 +189,7 @@ nm_settings_storage_class_init (NMSettingsStorageClass *klass)
obj_properties[PROP_FILENAME] =
g_param_spec_string (NM_SETTINGS_STORAGE_FILENAME, "", "",
NULL,
- G_PARAM_READWRITE |
+ G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);