summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-05 20:15:50 +0200
committerThomas Haller <thaller@redhat.com>2018-04-16 15:30:07 +0200
commit8df245d773dfbf686fe1c85863b6baf82e482661 (patch)
treede848300a33e14c85c8f8b54d7bb445d329be423
parent417c7ebe4a25aea55238988e7fa5baded1e59c51 (diff)
downloadNetworkManager-8df245d773dfbf686fe1c85863b6baf82e482661.tar.gz
settings: make NM_SETTINGS_CONNECTION_FLAGS property NM_SETTINGS_CONNECTION_FLAGS_CHANGED signal
For one, these flags are "internal" flags. Soon, we will gain a new NMSettingsConnectionFlags type that is exported on D-Bus and partly overlaps with these internal flags. However, then we will need the "flags" properties to expose the public bits. This property only exists because other parts are interested in notification signals. Note that we encourage NMDbusObject types to freeze/thaw property-changed notifications. As freezing the notifications also delays the signals, this is not desired for the purpose where internal users subscribe to the signal.
-rw-r--r--src/nm-active-connection.c18
-rw-r--r--src/settings/nm-settings-connection.c23
-rw-r--r--src/settings/nm-settings-connection.h2
-rw-r--r--src/settings/nm-settings.c3
4 files changed, 20 insertions, 26 deletions
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
index 8c5a8573ba..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;
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index 5a9159983a..ba2854f936 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -54,13 +54,13 @@ static void nm_settings_connection_connection_interface_init (NMConnectionInterf
NM_GOBJECT_PROPERTIES_DEFINE (NMSettingsConnection,
PROP_UNSAVED,
PROP_READY,
- PROP_FLAGS,
PROP_FILENAME,
);
enum {
REMOVED,
UPDATED_INTERNAL,
+ FLAGS_CHANGED,
LAST_SIGNAL
};
@@ -2364,9 +2364,9 @@ 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_INT_FLAGS_UNSAVED) != NM_FLAGS_HAS (value, NM_SETTINGS_CONNECTION_INT_FLAGS_UNSAVED))
_notify (self, PROP_UNSAVED);
+ g_signal_emit (self, signals[FLAGS_CHANGED], 0);
}
return old_flags;
}
@@ -3071,9 +3071,6 @@ 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));
- break;
case PROP_FILENAME:
g_value_set_string (value, nm_settings_connection_get_filename (self));
break;
@@ -3226,14 +3223,6 @@ 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, "", "",
- NM_SETTINGS_CONNECTION_INT_FLAGS_NONE,
- NM_SETTINGS_CONNECTION_INT_FLAGS_ALL,
- NM_SETTINGS_CONNECTION_INT_FLAGS_NONE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS);
-
obj_properties[PROP_FILENAME] =
g_param_spec_string (NM_SETTINGS_CONNECTION_FILENAME, "", "",
NULL,
@@ -3260,6 +3249,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 1c1bf7b439..f5d7b04749 100644
--- a/src/settings/nm-settings-connection.h
+++ b/src/settings/nm-settings-connection.h
@@ -38,13 +38,13 @@
#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"
/* Internal properties */
#define NM_SETTINGS_CONNECTION_READY "ready"
-#define NM_SETTINGS_CONNECTION_FLAGS "flags"
#define NM_SETTINGS_CONNECTION_FILENAME "filename"
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) {