mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 14:50:30 +01:00
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.
This commit is contained in:
parent
8df245d773
commit
acc8244ca2
7 changed files with 96 additions and 2 deletions
|
|
@ -159,6 +159,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.
|
||||
|
|
|
|||
|
|
@ -885,6 +885,18 @@ typedef enum { /*< skip >*/
|
|||
NM_ROLLBACK_RESULT_ERR_FAILED = 3,
|
||||
} 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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -651,6 +653,22 @@ nm_remote_connection_get_unsaved (NMRemoteConnection *connection)
|
|||
return NM_REMOTE_CONNECTION_GET_PRIVATE (connection)->unsaved;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
|
@ -928,6 +950,21 @@ nm_remote_connection_class_init (NMRemoteConnectionClass *remote_class)
|
|||
G_PARAM_READABLE |
|
||||
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:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue