mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 12:30:10 +01:00
libnm: add NMClient:instance-flags property
Add a flags property to control behavior of NMClient. Possible future use cases: - currently it would always automatically fetch permissions. Often that is not used and the user could opt out of it. - currently, using sync init creates an internal GMainContext. This has an overhead and may be undesirable. We could implement another "sync" initialization that would merely iterate the callers mainloop until the initialization completes. A flag would allow to opt in. - currently, NMClient always fetches all connection settings automatically. Via a flag the user could opt out of that. Instead NMClient could provide an API so the user can request settings as they are needed.
This commit is contained in:
parent
51bc2c0224
commit
f7aeda0390
4 changed files with 85 additions and 0 deletions
|
|
@ -1652,3 +1652,9 @@ global:
|
|||
nm_setting_gsm_get_auto_config;
|
||||
nm_setting_ip_config_get_dhcp_hostname_flags;
|
||||
} libnm_1_20_0;
|
||||
|
||||
libnm_1_24_0 {
|
||||
global:
|
||||
nm_client_get_instance_flags;
|
||||
nm_client_instance_flags_get_type;
|
||||
} libnm_1_22_0;
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMClient,
|
|||
PROP_DBUS_CONNECTION,
|
||||
PROP_DBUS_NAME_OWNER,
|
||||
PROP_VERSION,
|
||||
PROP_INSTANCE_FLAGS,
|
||||
PROP_STATE,
|
||||
PROP_STARTUP,
|
||||
PROP_NM_RUNNING,
|
||||
|
|
@ -290,6 +291,10 @@ typedef struct {
|
|||
guint dbsid_nm_vpn_connection_state_changed;
|
||||
guint dbsid_nm_check_permissions;
|
||||
|
||||
NMClientInstanceFlags instance_flags:3;
|
||||
|
||||
bool instance_flags_constructed:1;
|
||||
|
||||
bool udev_inited:1;
|
||||
bool notify_event_lst_changed:1;
|
||||
bool check_dbobj_visible_all:1;
|
||||
|
|
@ -3750,6 +3755,22 @@ _request_wait_finish (NMClient *client,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* nm_client_get_instance_flags:
|
||||
* @self: the #NMClient instance.
|
||||
*
|
||||
* Returns: the #NMClientInstanceFlags flags.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
NMClientInstanceFlags
|
||||
nm_client_get_instance_flags (NMClient *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CLIENT (self), NM_CLIENT_INSTANCE_FLAGS_NONE);
|
||||
|
||||
return NM_CLIENT_GET_PRIVATE (self)->instance_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_client_get_dbus_connection:
|
||||
* @client: a #NMClient
|
||||
|
|
@ -6929,6 +6950,9 @@ get_property (GObject *object, guint prop_id,
|
|||
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_INSTANCE_FLAGS:
|
||||
g_value_set_uint (value, priv->instance_flags);
|
||||
break;
|
||||
case PROP_DBUS_CONNECTION:
|
||||
g_value_set_object (value, priv->dbus_connection);
|
||||
break;
|
||||
|
|
@ -7041,8 +7065,27 @@ set_property (GObject *object, guint prop_id,
|
|||
NMClient *self = NM_CLIENT (object);
|
||||
NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self);
|
||||
gboolean b;
|
||||
guint v_uint;
|
||||
|
||||
switch (prop_id) {
|
||||
|
||||
case PROP_INSTANCE_FLAGS:
|
||||
/* construct */
|
||||
|
||||
v_uint = g_value_get_uint (value);
|
||||
g_return_if_fail (!NM_FLAGS_ANY (v_uint, ~((guint) NM_CLIENT_INSTANCE_FLAGS_ALL)));
|
||||
v_uint &= ((guint) NM_CLIENT_INSTANCE_FLAGS_ALL);
|
||||
|
||||
if (!priv->instance_flags_constructed) {
|
||||
priv->instance_flags_constructed = TRUE;
|
||||
priv->instance_flags = v_uint;
|
||||
nm_assert ((guint) priv->instance_flags == v_uint);
|
||||
} else {
|
||||
/* Later, we may want to implement setting some flags not only at construct time.
|
||||
* For now, that is not implemented and resetting flags afterwards has no effect. */
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_DBUS_CONNECTION:
|
||||
/* construct-only */
|
||||
priv->dbus_connection = g_value_dup_object (value);
|
||||
|
|
@ -7475,6 +7518,25 @@ nm_client_class_init (NMClientClass *client_class)
|
|||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMClient:instance-flags:
|
||||
*
|
||||
* #NMClientInstanceFlags for the instance. These affect behavior of #NMClient.
|
||||
* This is a construct property and you may only set the flags during
|
||||
* construction.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
obj_properties[PROP_INSTANCE_FLAGS] =
|
||||
g_param_spec_uint (NM_CLIENT_INSTANCE_FLAGS, "", "",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMClient:dbus-name-owner:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,6 +15,16 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* NMClientInstanceFlags:
|
||||
* @NM_CLIENT_INSTANCE_FLAGS_NONE: special value to indicate no flags.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_CLIENT_INSTANCE_FLAGS_NONE = 0,
|
||||
} NMClientInstanceFlags;
|
||||
|
||||
#define NM_TYPE_CLIENT (nm_client_get_type ())
|
||||
#define NM_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CLIENT, NMClient))
|
||||
#define NM_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CLIENT, NMClientClass))
|
||||
|
|
@ -28,6 +38,7 @@ G_BEGIN_DECLS
|
|||
#define NM_CLIENT_NM_RUNNING "nm-running"
|
||||
#define NM_CLIENT_DBUS_CONNECTION "dbus-connection"
|
||||
#define NM_CLIENT_DBUS_NAME_OWNER "dbus-name-owner"
|
||||
#define NM_CLIENT_INSTANCE_FLAGS "instance-flags"
|
||||
|
||||
_NM_DEPRECATED_SYNC_WRITABLE_PROPERTY
|
||||
#define NM_CLIENT_NETWORKING_ENABLED "networking-enabled"
|
||||
|
|
@ -133,6 +144,10 @@ void nm_client_new_async (GCancellable *cancellable,
|
|||
NMClient *nm_client_new_finish (GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
|
||||
NM_AVAILABLE_IN_1_24
|
||||
NMClientInstanceFlags nm_client_get_instance_flags (NMClient *self);
|
||||
|
||||
NM_AVAILABLE_IN_1_22
|
||||
GDBusConnection *nm_client_get_dbus_connection (NMClient *client);
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,8 @@ typedef enum {
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_CLIENT_INSTANCE_FLAGS_ALL ((NMClientInstanceFlags) 0x0)
|
||||
|
||||
typedef struct {
|
||||
GType (*get_o_type_fcn) (void);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue