summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-05 20:06:03 +0200
committerThomas Haller <thaller@redhat.com>2018-04-16 15:30:07 +0200
commitacc8244ca2dce5f977f2a2552f598c79169ff909 (patch)
tree91a0a882fbd815dd7b7af2fca89a33b9e86e5a58
parent8df245d773dfbf686fe1c85863b6baf82e482661 (diff)
downloadNetworkManager-acc8244ca2dce5f977f2a2552f598c79169ff909.tar.gz
all: add D-Bus property "Flags" for Settings.Connection interface
The D-Bus interface already has a boolean property "Unsaved". While that is nicer too look at (in the API), adding a new flag is very cumbersome, and also has more overhead. For example, it requires extending the D-Bus API, all the way down to libnm. Add a flags argument, that will allow to add future boolean flags easier.
-rw-r--r--introspection/org.freedesktop.NetworkManager.Settings.Connection.xml11
-rw-r--r--libnm-core/nm-dbus-interface.h12
-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/settings/nm-settings-connection.c25
-rw-r--r--src/settings/nm-settings-connection.h7
7 files changed, 96 insertions, 2 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..28ede4985c 100644
--- a/libnm-core/nm-dbus-interface.h
+++ b/libnm-core/nm-dbus-interface.h
@@ -886,6 +886,18 @@ typedef enum { /*< skip >*/
} NMRollbackResult;
/**
+ * NMSettingsConnectionFlags:
+ * @NM_SETTINGS_CONNECTION_FLAG_NONE: an alias for numeric zero, no flags set.
+ *
+ * Flags describing the current activation state.
+ *
+ * Since: 1.12
+ **/
+typedef enum { /*< flags >*/
+ NM_SETTINGS_CONNECTION_FLAG_NONE = 0,
+} 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/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index ba2854f936..6871499eb4 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -54,6 +54,7 @@ static void nm_settings_connection_connection_interface_init (NMConnectionInterf
NM_GOBJECT_PROPERTIES_DEFINE (NMSettingsConnection,
PROP_UNSAVED,
PROP_READY,
+ PROP_FLAGS,
PROP_FILENAME,
);
@@ -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,8 +2366,16 @@ 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);
- if (NM_FLAGS_HAS (old_flags, NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED) != NM_FLAGS_HAS (value, NM_SETTINGS_CONNECTION_INT_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;
@@ -3071,6 +3081,10 @@ get_property (GObject *object, guint prop_id,
case PROP_READY:
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) & NM_SETTINGS_CONNECTION_INT_FLAGS_EXPORTED_MASK);
+ break;
case PROP_FILENAME:
g_value_set_string (value, nm_settings_connection_get_filename (self));
break;
@@ -3187,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,
@@ -3223,6 +3238,12 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_FLAGS] =
+ g_param_spec_uint (NM_SETTINGS_CONNECTION_FLAGS, "", "",
+ 0, G_MAXUINT32, 0,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
+
obj_properties[PROP_FILENAME] =
g_param_spec_string (NM_SETTINGS_CONNECTION_FILENAME, "", "",
NULL,
diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h
index f5d7b04749..f7ee28528d 100644
--- a/src/settings/nm-settings-connection.h
+++ b/src/settings/nm-settings-connection.h
@@ -45,6 +45,7 @@
/* Internal properties */
#define NM_SETTINGS_CONNECTION_READY "ready"
+#define NM_SETTINGS_CONNECTION_FLAGS "flags"
#define NM_SETTINGS_CONNECTION_FILENAME "filename"
@@ -59,6 +60,9 @@
* when it disconnects. That is for in-memory connections (unsaved), which are
* currently active but cleanup on disconnect.
* @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.
@@ -73,6 +77,9 @@ typedef enum {
NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE = (1LL << 3),
__NM_SETTINGS_CONNECTION_INT_FLAGS_LAST,
+
+ NM_SETTINGS_CONNECTION_INT_FLAGS_EXPORTED_MASK = 0,
+
NM_SETTINGS_CONNECTION_INT_FLAGS_ALL = ((__NM_SETTINGS_CONNECTION_INT_FLAGS_LAST - 1) << 1) - 1,
} NMSettingsConnectionIntFlags;