diff options
author | Thomas Haller <thaller@redhat.com> | 2014-07-29 00:20:30 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-09-24 16:32:11 +0200 |
commit | ec6d8385d3811bc565ca0d232f289e05855b91a5 (patch) | |
tree | 9525e7ba3d868fdbeb8112b12d538b16a3cce058 | |
parent | 388d4d9030affaf05ea76bfc92cd300e61808109 (diff) | |
download | NetworkManager-ec6d8385d3811bc565ca0d232f289e05855b91a5.tar.gz |
settings: add NMSettingsConnection:flags
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | src/settings/nm-settings-connection.c | 73 | ||||
-rw-r--r-- | src/settings/nm-settings-connection.h | 22 |
2 files changed, 93 insertions, 2 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index db382adb82..1eaf713f71 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -82,6 +82,7 @@ enum { PROP_0 = 0, PROP_VISIBLE, PROP_UNSAVED, + PROP_FLAGS, }; enum { @@ -97,6 +98,8 @@ typedef struct { NMSessionMonitor *session_monitor; guint session_changed_id; + NMSettingsConnectionFlags flags; + /* TRUE if the connection has not yet been saved to disk, * or if it contains changes that have not been saved to disk. */ @@ -1602,6 +1605,50 @@ nm_settings_connection_get_unsaved (NMSettingsConnection *self) /**************************************************************/ +NMSettingsConnectionFlags +nm_settings_connection_get_flags (NMSettingsConnection *self) +{ + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NM_SETTINGS_CONNECTION_FLAGS_NONE); + + return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->flags; +} + +NMSettingsConnectionFlags +nm_settings_connection_set_flags (NMSettingsConnection *self, NMSettingsConnectionFlags flags, gboolean set) +{ + NMSettingsConnectionFlags new_flags; + + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NM_SETTINGS_CONNECTION_FLAGS_NONE); + g_return_val_if_fail ((flags & ~NM_SETTINGS_CONNECTION_FLAGS_ALL) == 0, NM_SETTINGS_CONNECTION_FLAGS_NONE); + + new_flags = NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->flags; + if (set) + new_flags |= flags; + else + new_flags &= ~flags; + return nm_settings_connection_set_flags_all (self, new_flags); +} + +NMSettingsConnectionFlags +nm_settings_connection_set_flags_all (NMSettingsConnection *self, NMSettingsConnectionFlags flags) +{ + NMSettingsConnectionPrivate *priv; + NMSettingsConnectionFlags old_flags; + + g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NM_SETTINGS_CONNECTION_FLAGS_NONE); + g_return_val_if_fail ((flags & ~NM_SETTINGS_CONNECTION_FLAGS_ALL) == 0, NM_SETTINGS_CONNECTION_FLAGS_NONE); + priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); + + old_flags = priv->flags; + if (old_flags != flags) { + priv->flags = flags; + g_object_notify (G_OBJECT (self), NM_SETTINGS_CONNECTION_FLAGS); + } + return old_flags; +} + +/*************************************************************/ + /** * nm_settings_connection_get_timestamp: * @connection: the #NMSettingsConnection @@ -2064,7 +2111,8 @@ static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (object); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object); + NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self); switch (prop_id) { case PROP_VISIBLE: @@ -2073,6 +2121,9 @@ get_property (GObject *object, guint prop_id, case PROP_UNSAVED: g_value_set_boolean (value, priv->unsaved); break; + case PROP_FLAGS: + g_value_set_uint (value, nm_settings_connection_get_flags (self)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2083,7 +2134,16 @@ static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + NMSettingsConnection *self = NM_SETTINGS_CONNECTION (object); + + switch (prop_id) { + case PROP_FLAGS: + nm_settings_connection_set_flags_all (self, g_value_get_uint (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } static void @@ -2117,6 +2177,15 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property + (object_class, PROP_FLAGS, + g_param_spec_uint (NM_SETTINGS_CONNECTION_FLAGS, "", "", + NM_SETTINGS_CONNECTION_FLAGS_NONE, + NM_SETTINGS_CONNECTION_FLAGS_ALL, + NM_SETTINGS_CONNECTION_FLAGS_NONE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + /* Signals */ /* Emitted when the connection is changed for any reason */ diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 3ee62465fd..3e3f202b3f 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -48,6 +48,24 @@ G_BEGIN_DECLS /* Properties */ #define NM_SETTINGS_CONNECTION_VISIBLE "visible" #define NM_SETTINGS_CONNECTION_UNSAVED "unsaved" +#define NM_SETTINGS_CONNECTION_FLAGS "flags" + + +/** + * NMSettingsConnectionFlags: + * @NM_SETTINGS_CONNECTION_FLAGS_NONE: no flag set + * @NM_SETTINGS_CONNECTION_FLAGS_ALL: special mask, for all known flags + * + * #NMSettingsConnection flags. + **/ +typedef enum +{ + NM_SETTINGS_CONNECTION_FLAGS_NONE = 0x00, + + __NM_SETTINGS_CONNECTION_FLAGS_LAST, + NM_SETTINGS_CONNECTION_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_FLAGS_LAST - 1) << 1) - 1, +} NMSettingsConnectionFlags; + typedef struct _NMSettingsConnectionClass NMSettingsConnectionClass; @@ -129,6 +147,10 @@ void nm_settings_connection_signal_remove (NMSettingsConnection *self); gboolean nm_settings_connection_get_unsaved (NMSettingsConnection *self); +NMSettingsConnectionFlags nm_settings_connection_get_flags (NMSettingsConnection *connection); +NMSettingsConnectionFlags nm_settings_connection_set_flags (NMSettingsConnection *connection, NMSettingsConnectionFlags flags, gboolean set); +NMSettingsConnectionFlags nm_settings_connection_set_flags_all (NMSettingsConnection *connection, NMSettingsConnectionFlags flags); + gboolean nm_settings_connection_get_timestamp (NMSettingsConnection *connection, guint64 *out_timestamp); |