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.
This commit is contained in:
Thomas Haller 2018-04-05 20:15:50 +02:00
parent 417c7ebe4a
commit 8df245d773
4 changed files with 20 additions and 26 deletions

View file

@ -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;

View file

@ -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

View file

@ -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"

View file

@ -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) {