summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-16 15:30:23 +0200
committerThomas Haller <thaller@redhat.com>2018-04-16 15:30:23 +0200
commit313f47c9155846950602351330f2f25c299775d5 (patch)
treed533f262a7aa7a8f709303900d1903f50fe550f2
parent95340f6c6d4f5b7a2afd3d4f1beadf1e107e1298 (diff)
parentaae483c0a95813ceccfb466f7e5dfbc894af6b20 (diff)
downloadNetworkManager-313f47c9155846950602351330f2f25c299775d5.tar.gz
all: merge branch 'th/settings-flags-rh1460295'
https://bugzilla.redhat.com/show_bug.cgi?id=1460295 https://github.com/NetworkManager/NetworkManager/pull/88
-rw-r--r--introspection/org.freedesktop.NetworkManager.Settings.Connection.xml11
-rw-r--r--libnm-core/nm-dbus-interface.h28
-rw-r--r--libnm/libnm.ver2
-rw-r--r--libnm/nm-remote-connection.c37
-rw-r--r--libnm/nm-remote-connection.h4
-rw-r--r--src/devices/bluetooth/nm-bluez-device.c4
-rw-r--r--src/devices/nm-device.c2
-rw-r--r--src/nm-active-connection.c20
-rw-r--r--src/nm-manager.c10
-rw-r--r--src/nm-policy.c2
-rw-r--r--src/settings/nm-settings-connection.c100
-rw-r--r--src/settings/nm-settings-connection.h50
-rw-r--r--src/settings/nm-settings.c3
13 files changed, 192 insertions, 81 deletions
diff --git a/introspection/org.freedesktop.NetworkManager.Settings.Connection.xml b/introspection/org.freedesktop.NetworkManager.Settings.Connection.xml
index ec596fd1e9..13f626c339 100644
--- a/introspection/org.freedesktop.NetworkManager.Settings.Connection.xml
+++ b/introspection/org.freedesktop.NetworkManager.Settings.Connection.xml
@@ -160,6 +160,17 @@
<property name="Unsaved" type="b" access="read"/>
<!--
+ Flags:
+
+ Additional flags of the connection profile.
+
+ Returns: <link linkend="NMSettingsConnectionFlags">NMSettingsConnectionFlags</link>
+
+ Since: 1.12
+ -->
+ <property name="Flags" type="u" access="read"/>
+
+ <!--
PropertiesChanged:
@properties: A dictionary mapping property names to variant boxed values.
diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h
index ec9c7f1aee..6c1e97fe87 100644
--- a/libnm-core/nm-dbus-interface.h
+++ b/libnm-core/nm-dbus-interface.h
@@ -886,6 +886,34 @@ typedef enum { /*< skip >*/
} NMRollbackResult;
/**
+ * NMSettingsConnectionFlags:
+ * @NM_SETTINGS_CONNECTION_FLAG_NONE: an alias for numeric zero, no flags set.
+ * @NM_SETTINGS_CONNECTION_FLAG_UNSAVED: the connection is not saved to disk.
+ * That either means, that the connection is in-memory only and currently
+ * is not backed by a file. Or, that the connection is backed by a file,
+ * but has modifications in-memory that were not persisted to disk.
+ * @NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED: A connection is "nm-generated" if
+ * it was generated by NetworkManger. If the connection gets modified or saved
+ * by the user, the flag gets cleared. A nm-generated is also unsaved
+ * and has no backing file as it is in-memory only.
+ * @NM_SETTINGS_CONNECTION_FLAG_VOLATILE: The connection will be deleted
+ * when it disconnects. That is for in-memory connections (unsaved), which are
+ * currently active but deleted on disconnect. Volatile connections are
+ * always unsaved, but they are also no backing file on disk and are entirely
+ * in-memory only.
+ *
+ * Flags describing the current activation state.
+ *
+ * Since: 1.12
+ **/
+typedef enum { /*< flags >*/
+ NM_SETTINGS_CONNECTION_FLAG_NONE = 0,
+ NM_SETTINGS_CONNECTION_FLAG_UNSAVED = 0x01,
+ NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED = 0x02,
+ NM_SETTINGS_CONNECTION_FLAG_VOLATILE = 0x04,
+} NMSettingsConnectionFlags;
+
+/**
* NMActivationStateFlags:
* @NM_ACTIVATION_STATE_FLAG_NONE: an alias for numeric zero, no flags set.
* @NM_ACTIVATION_STATE_FLAG_IS_MASTER: the device is a master.
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 386216184e..564cdb39fb 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1350,6 +1350,7 @@ global:
nm_client_get_checkpoints;
nm_device_ip_tunnel_get_flags;
nm_ip_tunnel_flags_get_type;
+ nm_remote_connection_get_flags;
nm_setting_connection_get_mdns;
nm_setting_connection_mdns_get_type;
nm_setting_ip_tunnel_get_flags;
@@ -1357,5 +1358,6 @@ global:
nm_setting_vpn_get_secret_keys;
nm_setting_wireless_security_get_fils;
nm_setting_wireless_security_fils_get_type;
+ nm_settings_connection_flags_get_type;
nm_vpn_service_plugin_shutdown;
} libnm_1_10_0;
diff --git a/libnm/nm-remote-connection.c b/libnm/nm-remote-connection.c
index 312b17ebe3..bd60c41329 100644
--- a/libnm/nm-remote-connection.c
+++ b/libnm/nm-remote-connection.c
@@ -50,6 +50,7 @@ G_DEFINE_TYPE_WITH_CODE (NMRemoteConnection, nm_remote_connection, NM_TYPE_OBJEC
enum {
PROP_0,
PROP_UNSAVED,
+ PROP_FLAGS,
PROP_VISIBLE,
LAST_PROP
@@ -59,6 +60,7 @@ typedef struct {
NMDBusSettingsConnection *proxy;
gboolean unsaved;
+ guint32 flags;
gboolean visible;
} NMRemoteConnectionPrivate;
@@ -652,6 +654,22 @@ nm_remote_connection_get_unsaved (NMRemoteConnection *connection)
}
/**
+ * nm_remote_connection_get_flags:
+ * @connection: the #NMRemoteConnection
+ *
+ * Returns: the flags of the connection of type #NMSettingsConnectionFlags.
+ *
+ * Since: 1.12
+ **/
+NMSettingsConnectionFlags
+nm_remote_connection_get_flags (NMRemoteConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_REMOTE_CONNECTION (connection), FALSE);
+
+ return (NMSettingsConnectionFlags) NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->flags;
+}
+
+/**
* nm_remote_connection_get_visible:
* @connection: the #NMRemoteConnection
*
@@ -741,6 +759,7 @@ init_dbus (NMObject *object)
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (object);
const NMPropertiesInfo property_info[] = {
{ NM_REMOTE_CONNECTION_UNSAVED, &priv->unsaved },
+ { NM_REMOTE_CONNECTION_FLAGS, &priv->flags },
{ NULL },
};
@@ -871,6 +890,9 @@ get_property (GObject *object, guint prop_id,
case PROP_UNSAVED:
g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->unsaved);
break;
+ case PROP_FLAGS:
+ g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->flags);
+ break;
case PROP_VISIBLE:
g_value_set_boolean (value, NM_REMOTE_CONNECTION_GET_PRIVATE (object)->visible);
break;
@@ -929,6 +951,21 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
G_PARAM_STATIC_STRINGS));
/**
+ * NMRemoteConnection:flags:
+ *
+ * The flags of the connection as unsigned integer. The values
+ * correspond to the #NMSettingsConnectionFlags enum.
+ *
+ * Since: 1.12
+ **/
+ g_object_class_install_property
+ (object_class, PROP_FLAGS,
+ g_param_spec_uint (NM_REMOTE_CONNECTION_FLAGS, "", "",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
* NMRemoteConnection:visible:
*
* %TRUE if the remote connection is visible to the current user, %FALSE if
diff --git a/libnm/nm-remote-connection.h b/libnm/nm-remote-connection.h
index 1e7d7618b5..a729f904f6 100644
--- a/libnm/nm-remote-connection.h
+++ b/libnm/nm-remote-connection.h
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
#define NM_REMOTE_CONNECTION_DBUS_CONNECTION "dbus-connection"
#define NM_REMOTE_CONNECTION_PATH "path"
#define NM_REMOTE_CONNECTION_UNSAVED "unsaved"
+#define NM_REMOTE_CONNECTION_FLAGS "flags"
#define NM_REMOTE_CONNECTION_VISIBLE "visible"
/**
@@ -123,6 +124,9 @@ GVariant *nm_remote_connection_get_secrets_finish (NMRemoteConnection *connectio
gboolean nm_remote_connection_get_unsaved (NMRemoteConnection *connection);
+NM_AVAILABLE_IN_1_12
+NMSettingsConnectionFlags nm_remote_connection_get_flags (NMRemoteConnection *connection);
+
gboolean nm_remote_connection_get_visible (NMRemoteConnection *connection);
G_END_DECLS
diff --git a/src/devices/bluetooth/nm-bluez-device.c b/src/devices/bluetooth/nm-bluez-device.c
index bd3cf18a67..cc9e38c89b 100644
--- a/src/devices/bluetooth/nm-bluez-device.c
+++ b/src/devices/bluetooth/nm-bluez-device.c
@@ -254,7 +254,7 @@ pan_connection_check_create (NMBluezDevice *self)
g_assert (connection_compatible (self, added));
g_assert (nm_connection_compare (added, connection, NM_SETTING_COMPARE_FLAG_EXACT));
- nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added), NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED, TRUE);
+ nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added), NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED, TRUE);
priv->connections = g_slist_prepend (priv->connections, g_object_ref (added));
priv->pan_connection = added;
@@ -1186,7 +1186,7 @@ dispose (GObject *object)
/* 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)),
- NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED))
+ NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED))
to_delete = g_object_ref (priv->pan_connection);
priv->pan_connection = NULL;
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 882e9a86d1..61b73ed1ae 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -10969,7 +10969,7 @@ nm_device_set_ip_config (NMDevice *self,
if ( nm_device_sys_iface_state_is_external (self)
&& (settings_connection = nm_device_get_settings_connection (self))
&& NM_FLAGS_HAS (nm_settings_connection_get_flags (settings_connection),
- NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED)
+ 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),
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index 4f6033893b..4b8b4e853e 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -121,9 +121,8 @@ static const GDBusSignalInfo signal_info_state_changed;
static void check_master_ready (NMActiveConnection *self);
static void _device_cleanup (NMActiveConnection *self);
-static void _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
- GParamSpec *param,
- NMActiveConnection *self);
+static void _settings_connection_flags_changed (NMSettingsConnection *settings_connection,
+ NMActiveConnection *self);
static void _set_activation_type_managed (NMActiveConnection *self);
/*****************************************************************************/
@@ -200,12 +199,12 @@ _set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connec
if (priv->settings_connection.obj) {
g_signal_handlers_disconnect_by_func (priv->settings_connection.obj, _settings_connection_updated, self);
- g_signal_handlers_disconnect_by_func (priv->settings_connection.obj, _settings_connection_notify_flags, self);
+ g_signal_handlers_disconnect_by_func (priv->settings_connection.obj, _settings_connection_flags_changed, self);
}
if (connection) {
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, (GCallback) _settings_connection_updated, self);
if (nm_active_connection_get_activation_type (self) == NM_ACTIVATION_TYPE_EXTERNAL)
- g_signal_connect (connection, "notify::"NM_SETTINGS_CONNECTION_FLAGS, (GCallback) _settings_connection_notify_flags, self);
+ g_signal_connect (connection, NM_SETTINGS_CONNECTION_FLAGS_CHANGED, (GCallback) _settings_connection_flags_changed, self);
}
nm_dbus_track_obj_path_set (&priv->settings_connection, connection, TRUE);
@@ -857,9 +856,9 @@ _set_activation_type (NMActiveConnection *self,
if (priv->settings_connection.obj) {
if (activation_type == NM_ACTIVATION_TYPE_EXTERNAL)
- g_signal_connect (priv->settings_connection.obj, "notify::"NM_SETTINGS_CONNECTION_FLAGS, (GCallback) _settings_connection_notify_flags, self);
+ g_signal_connect (priv->settings_connection.obj, NM_SETTINGS_CONNECTION_FLAGS_CHANGED, (GCallback) _settings_connection_flags_changed, self);
else
- g_signal_handlers_disconnect_by_func (priv->settings_connection.obj, _settings_connection_notify_flags, self);
+ g_signal_handlers_disconnect_by_func (priv->settings_connection.obj, _settings_connection_flags_changed, self);
}
}
@@ -896,9 +895,8 @@ nm_active_connection_get_activation_reason (NMActiveConnection *self)
/*****************************************************************************/
static void
-_settings_connection_notify_flags (NMSettingsConnection *settings_connection,
- GParamSpec *param,
- NMActiveConnection *self)
+_settings_connection_flags_changed (NMSettingsConnection *settings_connection,
+ NMActiveConnection *self)
{
GError *error = NULL;
@@ -908,7 +906,7 @@ _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
nm_assert (NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->settings_connection.obj == settings_connection);
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (settings_connection),
- NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED))
+ NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED))
return;
_set_activation_type_managed (self);
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 612f41562c..5074ae7e1a 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -639,7 +639,7 @@ _delete_volatile_connection_do (NMManager *self,
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
if (!NM_FLAGS_HAS (nm_settings_connection_get_flags (connection),
- NM_SETTINGS_CONNECTION_FLAGS_VOLATILE))
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE))
return;
if (active_connection_find_first (self,
connection,
@@ -836,7 +836,7 @@ _get_activatable_connections_filter (NMSettings *settings,
gpointer user_data)
{
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (connection),
- NM_SETTINGS_CONNECTION_FLAGS_VOLATILE))
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE))
return FALSE;
return !active_connection_find_first (user_data, connection, NULL, NM_ACTIVE_CONNECTION_STATE_DEACTIVATING);
}
@@ -1870,7 +1870,7 @@ connection_flags_changed (NMSettings *settings,
DeleteVolatileConnectionData *data;
if (!NM_FLAGS_HAS (nm_settings_connection_get_flags (connection),
- NM_SETTINGS_CONNECTION_FLAGS_VOLATILE))
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE))
return;
if (active_connection_find_first (self, connection, NULL, NM_ACTIVE_CONNECTION_STATE_DEACTIVATED)) {
@@ -2319,8 +2319,8 @@ get_existing_connection (NMManager *self,
}
nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added),
- NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED |
- NM_SETTINGS_CONNECTION_FLAGS_VOLATILE,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED |
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE,
TRUE);
NM_SET_OUT (out_generated, TRUE);
return added;
diff --git a/src/nm-policy.c b/src/nm-policy.c
index 0d5f8c79cb..55b6caf601 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -2356,7 +2356,7 @@ connection_flags_changed (NMSettings *settings,
NMPolicy *self = _PRIV_TO_SELF (priv);
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (connection),
- NM_SETTINGS_CONNECTION_FLAGS_VISIBLE)) {
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE)) {
if (!nm_settings_connection_autoconnect_is_blocked (connection))
schedule_activate_all (self);
} else
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index 9e87a35ba3..6871499eb4 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -61,6 +61,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingsConnection,
enum {
REMOVED,
UPDATED_INTERNAL,
+ FLAGS_CHANGED,
LAST_SIGNAL
};
@@ -72,7 +73,7 @@ typedef struct _NMSettingsConnectionPrivate {
NMSessionMonitor *session_monitor;
gulong session_changed_id;
- NMSettingsConnectionFlags flags:5;
+ NMSettingsConnectionIntFlags flags:5;
bool removed:1;
bool ready:1;
@@ -316,7 +317,7 @@ static void
set_visible (NMSettingsConnection *self, gboolean new_visible)
{
nm_settings_connection_set_flags (self,
- NM_SETTINGS_CONNECTION_FLAGS_VISIBLE,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE,
new_visible);
}
@@ -386,7 +387,7 @@ nm_settings_connection_check_permission (NMSettingsConnection *self,
priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
if (!NM_FLAGS_HAS (nm_settings_connection_get_flags (self),
- NM_SETTINGS_CONNECTION_FLAGS_VISIBLE))
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE))
return FALSE;
s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
@@ -486,30 +487,30 @@ secrets_cleared_cb (NMSettingsConnection *self)
static void
set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode persist_mode)
{
- NMSettingsConnectionFlags flags = NM_SETTINGS_CONNECTION_FLAGS_NONE;
- const NMSettingsConnectionFlags ALL = NM_SETTINGS_CONNECTION_FLAGS_UNSAVED
- | NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED
- | NM_SETTINGS_CONNECTION_FLAGS_VOLATILE;
+ NMSettingsConnectionIntFlags flags = NM_SETTINGS_CONNECTION_INT_FLAGS_NONE;
+ const NMSettingsConnectionIntFlags ALL = NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED
+ | NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED
+ | NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE;
switch (persist_mode) {
case NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK:
- flags = NM_SETTINGS_CONNECTION_FLAGS_NONE;
+ flags = NM_SETTINGS_CONNECTION_INT_FLAGS_NONE;
break;
case NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY:
case NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY_DETACHED:
case NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY_ONLY:
- flags = NM_SETTINGS_CONNECTION_FLAGS_UNSAVED;
+ flags = NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED;
break;
case NM_SETTINGS_CONNECTION_PERSIST_MODE_VOLATILE_DETACHED:
case NM_SETTINGS_CONNECTION_PERSIST_MODE_VOLATILE_ONLY:
- flags = NM_SETTINGS_CONNECTION_FLAGS_UNSAVED |
- NM_SETTINGS_CONNECTION_FLAGS_VOLATILE;
+ flags = NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED |
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE;
break;
case NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED:
/* only set the connection as unsaved, but preserve the nm-generated
* and volatile flag. */
nm_settings_connection_set_flags (self,
- NM_SETTINGS_CONNECTION_FLAGS_UNSAVED,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED,
TRUE);
return;
case NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP:
@@ -683,7 +684,7 @@ nm_settings_connection_update (NMSettingsConnection *self,
}
nm_settings_connection_set_flags (self,
- NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_VOLATILE,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE,
FALSE);
if (replaced) {
@@ -2310,45 +2311,45 @@ nm_settings_connection_signal_remove (NMSettingsConnection *self)
gboolean
nm_settings_connection_get_unsaved (NMSettingsConnection *self)
{
- return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_FLAGS_UNSAVED);
+ return NM_FLAGS_HAS (nm_settings_connection_get_flags (self), NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED);
}
/*****************************************************************************/
-NM_UTILS_FLAGS2STR_DEFINE_STATIC (_settings_connection_flags_to_string, NMSettingsConnectionFlags,
- NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_FLAGS_NONE, "none"),
- NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_FLAGS_UNSAVED, "unsaved"),
- NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED, "nm-generated"),
- NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_FLAGS_VOLATILE, "volatile"),
- NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_FLAGS_VISIBLE, "visible"),
+NM_UTILS_FLAGS2STR_DEFINE_STATIC (_settings_connection_flags_to_string, NMSettingsConnectionIntFlags,
+ NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, "none"),
+ NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED, "unsaved"),
+ NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED, "nm-generated"),
+ NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE, "volatile"),
+ NM_UTILS_FLAGS2STR (NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE, "visible"),
);
-NMSettingsConnectionFlags
+NMSettingsConnectionIntFlags
nm_settings_connection_get_flags (NMSettingsConnection *self)
{
- g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NM_SETTINGS_CONNECTION_FLAGS_NONE);
+ g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NM_SETTINGS_CONNECTION_INT_FLAGS_NONE);
return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->flags;
}
-NMSettingsConnectionFlags
-nm_settings_connection_set_flags (NMSettingsConnection *self, NMSettingsConnectionFlags flags, gboolean set)
+NMSettingsConnectionIntFlags
+nm_settings_connection_set_flags (NMSettingsConnection *self, NMSettingsConnectionIntFlags flags, gboolean set)
{
return nm_settings_connection_set_flags_full (self,
flags,
- set ? flags : NM_SETTINGS_CONNECTION_FLAGS_NONE);
+ set ? flags : NM_SETTINGS_CONNECTION_INT_FLAGS_NONE);
}
-NMSettingsConnectionFlags
+NMSettingsConnectionIntFlags
nm_settings_connection_set_flags_full (NMSettingsConnection *self,
- NMSettingsConnectionFlags mask,
- NMSettingsConnectionFlags value)
+ NMSettingsConnectionIntFlags mask,
+ NMSettingsConnectionIntFlags value)
{
NMSettingsConnectionPrivate *priv;
- NMSettingsConnectionFlags old_flags;
+ NMSettingsConnectionIntFlags old_flags;
- g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NM_SETTINGS_CONNECTION_FLAGS_NONE);
- nm_assert (mask && !NM_FLAGS_ANY (mask, ~NM_SETTINGS_CONNECTION_FLAGS_ALL));
+ g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NM_SETTINGS_CONNECTION_INT_FLAGS_NONE);
+ nm_assert (mask && !NM_FLAGS_ANY (mask, ~NM_SETTINGS_CONNECTION_INT_FLAGS_ALL));
nm_assert (!NM_FLAGS_ANY (value, ~mask));
priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
@@ -2357,6 +2358,7 @@ nm_settings_connection_set_flags_full (NMSettingsConnection *self,
old_flags = priv->flags;
if (old_flags != value) {
+ gboolean notify_unsaved = FALSE;
char buf1[255], buf2[255];
_LOGT ("update settings-connection flags to %s (was %s)",
@@ -2364,9 +2366,17 @@ nm_settings_connection_set_flags_full (NMSettingsConnection *self,
_settings_connection_flags_to_string (priv->flags, buf2, sizeof (buf2)));
priv->flags = value;
nm_assert (priv->flags == value);
- _notify (self, PROP_FLAGS);
- if (NM_FLAGS_HAS (old_flags, NM_SETTINGS_CONNECTION_FLAGS_UNSAVED) != NM_FLAGS_HAS (value, NM_SETTINGS_CONNECTION_FLAGS_UNSAVED))
+
+ if (NM_FLAGS_HAS (old_flags, NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED) != NM_FLAGS_HAS (value, NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED)) {
+ g_object_freeze_notify (G_OBJECT (self));
_notify (self, PROP_UNSAVED);
+ notify_unsaved = TRUE;
+ }
+ _notify (self, PROP_FLAGS);
+ if (notify_unsaved)
+ g_object_thaw_notify (G_OBJECT (self));
+
+ g_signal_emit (self, signals[FLAGS_CHANGED], 0);
}
return old_flags;
}
@@ -2882,7 +2892,7 @@ gboolean
nm_settings_connection_autoconnect_is_blocked (NMSettingsConnection *self)
{
NMSettingsConnectionPrivate *priv;
- NMSettingsConnectionFlags flags;
+ NMSettingsConnectionIntFlags flags;
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), TRUE);
@@ -2894,9 +2904,9 @@ nm_settings_connection_autoconnect_is_blocked (NMSettingsConnection *self)
return TRUE;
flags = priv->flags;
- if (NM_FLAGS_HAS (flags, NM_SETTINGS_CONNECTION_FLAGS_VOLATILE))
+ if (NM_FLAGS_HAS (flags, NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE))
return TRUE;
- if (!NM_FLAGS_HAS (flags, NM_SETTINGS_CONNECTION_FLAGS_VISIBLE))
+ if (!NM_FLAGS_HAS (flags, NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE))
return TRUE;
return FALSE;
@@ -3072,7 +3082,8 @@ get_property (GObject *object, guint prop_id,
g_value_set_boolean (value, nm_settings_connection_get_ready (self));
break;
case PROP_FLAGS:
- g_value_set_uint (value, nm_settings_connection_get_flags (self));
+ g_value_set_uint (value,
+ nm_settings_connection_get_flags (self) & NM_SETTINGS_CONNECTION_INT_FLAGS_EXPORTED_MASK);
break;
case PROP_FILENAME:
g_value_set_string (value, nm_settings_connection_get_filename (self));
@@ -3190,7 +3201,8 @@ static const NMDBusInterfaceInfoExtended interface_info_settings_connection = {
&signal_info_removed,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
- NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Unsaved", "b", NM_SETTINGS_CONNECTION_UNSAVED),
+ NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Unsaved", "b", NM_SETTINGS_CONNECTION_UNSAVED),
+ NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE ("Flags", "u", NM_SETTINGS_CONNECTION_FLAGS),
),
),
.legacy_property_changed = TRUE,
@@ -3228,9 +3240,7 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *klass)
obj_properties[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,
+ 0, G_MAXUINT32, 0,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
@@ -3260,6 +3270,14 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[FLAGS_CHANGED] =
+ g_signal_new (NM_SETTINGS_CONNECTION_FLAGS_CHANGED,
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h
index 555a1d1285..589016996c 100644
--- a/src/settings/nm-settings-connection.h
+++ b/src/settings/nm-settings-connection.h
@@ -38,6 +38,7 @@
#define NM_SETTINGS_CONNECTION_GET_SECRETS "get-secrets"
#define NM_SETTINGS_CONNECTION_CANCEL_SECRETS "cancel-secrets"
#define NM_SETTINGS_CONNECTION_UPDATED_INTERNAL "updated-internal"
+#define NM_SETTINGS_CONNECTION_FLAGS_CHANGED "flags-changed"
/* Properties */
#define NM_SETTINGS_CONNECTION_UNSAVED "unsaved"
@@ -49,32 +50,45 @@
/**
- * NMSettingsConnectionFlags:
- * @NM_SETTINGS_CONNECTION_FLAGS_NONE: no flag set
- * @NM_SETTINGS_CONNECTION_FLAGS_UNSAVED: the connection is not saved to disk
- * @NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED: A connection is "nm-generated" if
+ * NMSettingsConnectionIntFlags:
+ * @NM_SETTINGS_CONNECTION_INT_FLAGS_NONE: no flag set
+ * @NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED: the connection is not saved to disk.
+ * See also #NM_SETTINGS_CONNECTION_FLAG_UNSAVED.
+ * @NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED: A connection is "nm-generated" if
* it was generated by NetworkManger. If the connection gets modified or saved
* by the user, the flag gets cleared. A nm-generated is implicitly unsaved.
- * @NM_SETTINGS_CONNECTION_FLAGS_VOLATILE: The connection will be deleted
+ * See also #NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED.
+ * @NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE: The connection will be deleted
* when it disconnects. That is for in-memory connections (unsaved), which are
* currently active but cleanup on disconnect.
- * @NM_SETTINGS_CONNECTION_FLAGS_VISIBLE: The connection is visible
- * @NM_SETTINGS_CONNECTION_FLAGS_ALL: special mask, for all known flags
+ * See also #NM_SETTINGS_CONNECTION_FLAG_VOLATILE.
+ * @NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE: The connection is visible
+ * @NM_SETTINGS_CONNECTION_INT_FLAGS_EXPORTED_MASK: the entire enum is
+ * internal, however, parts of it is public API as #NMSettingsConnectionFlags.
+ * This mask, are the public flags.
+ * @NM_SETTINGS_CONNECTION_INT_FLAGS_ALL: special mask, for all known flags
*
* #NMSettingsConnection flags.
**/
typedef enum {
- NM_SETTINGS_CONNECTION_FLAGS_NONE = 0,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_NONE = 0,
- NM_SETTINGS_CONNECTION_FLAGS_UNSAVED = (1LL << 0),
- NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED = (1LL << 1),
- NM_SETTINGS_CONNECTION_FLAGS_VOLATILE = (1LL << 2),
+ NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED = NM_SETTINGS_CONNECTION_FLAG_UNSAVED,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED = NM_SETTINGS_CONNECTION_FLAG_NM_GENERATED,
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE = NM_SETTINGS_CONNECTION_FLAG_VOLATILE,
- NM_SETTINGS_CONNECTION_FLAGS_VISIBLE = (1LL << 3),
+ NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE = (1LL << 3),
- __NM_SETTINGS_CONNECTION_FLAGS_LAST,
- NM_SETTINGS_CONNECTION_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_FLAGS_LAST - 1) << 1) - 1,
-} NMSettingsConnectionFlags;
+ __NM_SETTINGS_CONNECTION_INT_FLAGS_LAST,
+
+ NM_SETTINGS_CONNECTION_INT_FLAGS_EXPORTED_MASK = 0
+ | NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED
+ | NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED
+ | NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE
+ | 0,
+
+ NM_SETTINGS_CONNECTION_INT_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_INT_FLAGS_LAST - 1) << 1) - 1,
+} NMSettingsConnectionIntFlags;
typedef enum {
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE = 0,
@@ -196,9 +210,9 @@ void nm_settings_connection_signal_remove (NMSettingsConnection *self);
gboolean nm_settings_connection_get_unsaved (NMSettingsConnection *self);
-NMSettingsConnectionFlags nm_settings_connection_get_flags (NMSettingsConnection *self);
-NMSettingsConnectionFlags nm_settings_connection_set_flags (NMSettingsConnection *self, NMSettingsConnectionFlags flags, gboolean set);
-NMSettingsConnectionFlags nm_settings_connection_set_flags_full (NMSettingsConnection *self, NMSettingsConnectionFlags mask, NMSettingsConnectionFlags value);
+NMSettingsConnectionIntFlags nm_settings_connection_get_flags (NMSettingsConnection *self);
+NMSettingsConnectionIntFlags nm_settings_connection_set_flags (NMSettingsConnection *self, NMSettingsConnectionIntFlags flags, gboolean set);
+NMSettingsConnectionIntFlags nm_settings_connection_set_flags_full (NMSettingsConnection *self, NMSettingsConnectionIntFlags mask, NMSettingsConnectionIntFlags value);
int nm_settings_connection_cmp_timestamp (NMSettingsConnection *ac, NMSettingsConnection *ab);
int nm_settings_connection_cmp_timestamp_p_with_data (gconstpointer pa, gconstpointer pb, gpointer user_data);
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index d42994d728..e2be3d120e 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -829,7 +829,6 @@ connection_updated (NMSettingsConnection *connection, gboolean by_user, gpointer
static void
connection_flags_changed (NMSettingsConnection *connection,
- GParamSpec *pspec,
gpointer user_data)
{
g_signal_emit (NM_SETTINGS (user_data),
@@ -992,7 +991,7 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
G_CALLBACK (connection_removed), self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
G_CALLBACK (connection_updated), self);
- g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_FLAGS,
+ g_signal_connect (connection, NM_SETTINGS_CONNECTION_FLAGS_CHANGED,
G_CALLBACK (connection_flags_changed),
self);
if (!priv->startup_complete) {