summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-09-25 19:06:02 +0200
committerThomas Haller <thaller@redhat.com>2017-10-05 11:50:31 +0200
commit817a45bfe6d867ef2eb9b63a148db34e51c61817 (patch)
tree6138f4921d82e55c0632e2ce023b665b1812ab26 /src
parentd7bbc05b734937d4271d8c265244892f603c1ac4 (diff)
downloadNetworkManager-817a45bfe6d867ef2eb9b63a148db34e51c61817.tar.gz
libnm: add NMActivationStateFlags
No flags yet implemented. https://bugzilla.redhat.com/show_bug.cgi?id=1454883
Diffstat (limited to 'src')
-rw-r--r--src/nm-active-connection.c43
-rw-r--r--src/nm-active-connection.h14
2 files changed, 57 insertions, 0 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index 00414f0d17..61917156dd 100644
--- a/src/nm-active-connection.c
+++ b/src/nm-active-connection.c
@@ -44,6 +44,8 @@ typedef struct _NMActiveConnectionPrivate {
char *pending_activation_id;
+ NMActivationStateFlags state_flags;
+
NMActiveConnectionState state;
bool is_default:1;
bool is_default6:1;
@@ -73,6 +75,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMActiveConnection,
PROP_SPECIFIC_OBJECT,
PROP_DEVICES,
PROP_STATE,
+ PROP_STATE_FLAGS,
PROP_DEFAULT,
PROP_IP4_CONFIG,
PROP_DHCP4_CONFIG,
@@ -143,6 +146,10 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_state_to_string, NMActiveConnectionState,
);
#define state_to_string(state) NM_UTILS_LOOKUP_STR (_state_to_string, state)
+NM_UTILS_FLAGS2STR_DEFINE_STATIC (_state_flags_to_string, NMActivationStateFlags,
+ NM_UTILS_FLAGS2STR (NM_ACTIVATION_STATE_FLAG_NONE, "none"),
+);
+
/*****************************************************************************/
static void
@@ -279,6 +286,33 @@ nm_active_connection_set_state (NMActiveConnection *self,
}
}
+NMActivationStateFlags
+nm_active_connection_get_state_flags (NMActiveConnection *self)
+{
+ return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->state_flags;
+}
+
+void
+nm_active_connection_set_state_flags_full (NMActiveConnection *self,
+ NMActivationStateFlags state_flags,
+ NMActivationStateFlags mask)
+{
+ NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
+ NMActivationStateFlags f;
+
+ f = (priv->state_flags & ~mask) | (state_flags & mask);
+ if (f != priv->state_flags) {
+ char buf1[G_N_ELEMENTS (_nm_utils_to_string_buffer)];
+ char buf2[G_N_ELEMENTS (_nm_utils_to_string_buffer)];
+
+ _LOGD ("set state-flags %s (was %s)",
+ _state_flags_to_string (f, buf1, sizeof (buf1)),
+ _state_flags_to_string (priv->state_flags, buf2, sizeof (buf2)));
+ priv->state_flags = f;
+ _notify (self, PROP_STATE_FLAGS);
+ }
+}
+
const char *
nm_active_connection_get_settings_connection_id (NMActiveConnection *self)
{
@@ -1105,6 +1139,9 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, NM_ACTIVE_CONNECTION_STATE_ACTIVATING);
}
break;
+ case PROP_STATE_FLAGS:
+ g_value_set_uint (value, priv->state_flags);
+ break;
case PROP_DEFAULT:
g_value_set_boolean (value, priv->is_default);
break;
@@ -1359,6 +1396,12 @@ nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_STATE_FLAGS] =
+ g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE_FLAGS, "", "",
+ 0, G_MAXUINT32, NM_ACTIVATION_STATE_FLAG_NONE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS);
+
obj_properties[PROP_DEFAULT] =
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT, "", "",
FALSE,
diff --git a/src/nm-active-connection.h b/src/nm-active-connection.h
index 8d3478c79d..5562b42f07 100644
--- a/src/nm-active-connection.h
+++ b/src/nm-active-connection.h
@@ -39,6 +39,7 @@
#define NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT "specific-object"
#define NM_ACTIVE_CONNECTION_DEVICES "devices"
#define NM_ACTIVE_CONNECTION_STATE "state"
+#define NM_ACTIVE_CONNECTION_STATE_FLAGS "state-flags"
#define NM_ACTIVE_CONNECTION_DEFAULT "default"
#define NM_ACTIVE_CONNECTION_IP4_CONFIG "ip4-config"
#define NM_ACTIVE_CONNECTION_DHCP4_CONFIG "dhcp4-config"
@@ -145,6 +146,19 @@ void nm_active_connection_set_state (NMActiveConnection *self,
NMActiveConnectionState state,
NMActiveConnectionStateReason reason);
+NMActivationStateFlags nm_active_connection_get_state_flags (NMActiveConnection *self);
+
+void nm_active_connection_set_state_flags_full (NMActiveConnection *self,
+ NMActivationStateFlags state_flags,
+ NMActivationStateFlags mask);
+
+static inline void
+nm_active_connection_set_state_flags (NMActiveConnection *self,
+ NMActivationStateFlags state_flags)
+{
+ nm_active_connection_set_state_flags_full (self, state_flags, state_flags);
+}
+
NMDevice * nm_active_connection_get_device (NMActiveConnection *self);
gboolean nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device);