mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 07:20:14 +01:00
settings: combine "updated" and "updated-by-user" signal in NMSettingsConnection
Instead of connecting to two similar signals, combine them into one
and pass "by_user" argument.
We still need to keep the original NM_SETTINGS_CONNECTION_UPDATED signal,
because it is exposed on D-Bus.
(cherry picked from commit 65c55e2a78)
This commit is contained in:
parent
fba19c43ee
commit
52644bfebd
3 changed files with 34 additions and 32 deletions
|
|
@ -81,7 +81,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingsConnection,
|
|||
enum {
|
||||
UPDATED,
|
||||
REMOVED,
|
||||
UPDATED_BY_USER,
|
||||
UPDATED_INTERNAL,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
|
@ -130,6 +130,15 @@ typedef struct {
|
|||
|
||||
/*******************************************************************/
|
||||
|
||||
static void
|
||||
_emit_updated (NMSettingsConnection *self, gboolean by_user)
|
||||
{
|
||||
g_signal_emit (self, signals[UPDATED], 0);
|
||||
g_signal_emit (self, signals[UPDATED_INTERNAL], 0, by_user);
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
gboolean
|
||||
nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection *self,
|
||||
NMConnection *applied_connection,
|
||||
|
|
@ -483,7 +492,7 @@ static void
|
|||
connection_changed_cb (NMSettingsConnection *self, gpointer unused)
|
||||
{
|
||||
set_unsaved (self, TRUE);
|
||||
g_signal_emit (self, signals[UPDATED], 0);
|
||||
_emit_updated (self, FALSE);
|
||||
}
|
||||
|
||||
/* Update the settings of this connection to match that of 'new_connection',
|
||||
|
|
@ -566,12 +575,10 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
|
|||
if (update_unsaved)
|
||||
set_unsaved (self, TRUE);
|
||||
|
||||
g_signal_emit (self, signals[UPDATED], 0);
|
||||
|
||||
g_signal_emit (self, signals[UPDATED_BY_USER], 0);
|
||||
|
||||
g_signal_handlers_unblock_by_func (self, G_CALLBACK (connection_changed_cb), NULL);
|
||||
|
||||
_emit_updated (self, TRUE);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
@ -2739,7 +2746,6 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
|
|||
|
||||
/* Signals */
|
||||
|
||||
/* Emitted when the connection is changed for any reason */
|
||||
signals[UPDATED] =
|
||||
g_signal_new (NM_SETTINGS_CONNECTION_UPDATED,
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
|
|
@ -2749,14 +2755,14 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
|
|||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/* Emitted when connection is changed from D-Bus */
|
||||
signals[UPDATED_BY_USER] =
|
||||
g_signal_new (NM_SETTINGS_CONNECTION_UPDATED_BY_USER,
|
||||
/* internal signal, with an argument (gboolean by_user). */
|
||||
signals[UPDATED_INTERNAL] =
|
||||
g_signal_new (NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
g_cclosure_marshal_VOID__BOOLEAN,
|
||||
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
||||
|
||||
signals[REMOVED] =
|
||||
g_signal_new (NM_SETTINGS_CONNECTION_REMOVED,
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ G_BEGIN_DECLS
|
|||
#define NM_SETTINGS_CONNECTION_GET_SECRETS "get-secrets"
|
||||
#define NM_SETTINGS_CONNECTION_CANCEL_SECRETS "cancel-secrets"
|
||||
|
||||
/* Emitted when connection is changed by a user action */
|
||||
#define NM_SETTINGS_CONNECTION_UPDATED_BY_USER "updated-by-user"
|
||||
/* Internal signals */
|
||||
#define NM_SETTINGS_CONNECTION_UPDATED_INTERNAL "updated-internal"
|
||||
|
||||
/* Properties */
|
||||
#define NM_SETTINGS_CONNECTION_VISIBLE "visible"
|
||||
|
|
|
|||
|
|
@ -879,9 +879,15 @@ next:
|
|||
}
|
||||
|
||||
static void
|
||||
connection_updated (NMSettingsConnection *connection, gpointer user_data)
|
||||
connection_updated (NMSettingsConnection *connection, gboolean by_user, gpointer user_data)
|
||||
{
|
||||
/* Re-emit for listeners like NMPolicy */
|
||||
if (by_user) {
|
||||
g_signal_emit (NM_SETTINGS (user_data),
|
||||
signals[CONNECTION_UPDATED_BY_USER],
|
||||
0,
|
||||
connection);
|
||||
}
|
||||
|
||||
g_signal_emit (NM_SETTINGS (user_data),
|
||||
signals[CONNECTION_UPDATED],
|
||||
0,
|
||||
|
|
@ -889,16 +895,6 @@ connection_updated (NMSettingsConnection *connection, gpointer user_data)
|
|||
g_signal_emit_by_name (NM_SETTINGS (user_data), NM_CP_SIGNAL_CONNECTION_UPDATED, connection);
|
||||
}
|
||||
|
||||
static void
|
||||
connection_updated_by_user (NMSettingsConnection *connection, gpointer user_data)
|
||||
{
|
||||
/* Re-emit for listeners like NMPolicy */
|
||||
g_signal_emit (NM_SETTINGS (user_data),
|
||||
signals[CONNECTION_UPDATED_BY_USER],
|
||||
0,
|
||||
connection);
|
||||
}
|
||||
|
||||
static void
|
||||
connection_visibility_changed (NMSettingsConnection *connection,
|
||||
GParamSpec *pspec,
|
||||
|
|
@ -929,7 +925,6 @@ connection_removed (NMSettingsConnection *connection, gpointer user_data)
|
|||
|
||||
g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_removed), self);
|
||||
g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_updated), self);
|
||||
g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_updated_by_user), self);
|
||||
g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_visibility_changed), self);
|
||||
g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (connection_ready_changed), self);
|
||||
g_object_unref (self);
|
||||
|
|
@ -1061,10 +1056,8 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
|
|||
g_object_ref (self);
|
||||
g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED,
|
||||
G_CALLBACK (connection_removed), self);
|
||||
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED,
|
||||
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
|
||||
G_CALLBACK (connection_updated), self);
|
||||
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_BY_USER,
|
||||
G_CALLBACK (connection_updated_by_user), self);
|
||||
g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_VISIBLE,
|
||||
G_CALLBACK (connection_visibility_changed),
|
||||
self);
|
||||
|
|
@ -1928,10 +1921,13 @@ default_wired_connection_removed_cb (NMSettingsConnection *connection, NMSetting
|
|||
}
|
||||
|
||||
static void
|
||||
default_wired_connection_updated_by_user_cb (NMSettingsConnection *connection, NMSettings *self)
|
||||
default_wired_connection_updated_by_user_cb (NMSettingsConnection *connection, gboolean by_user, NMSettings *self)
|
||||
{
|
||||
NMDevice *device;
|
||||
|
||||
if (!by_user)
|
||||
return;
|
||||
|
||||
/* The connection has been changed by the user, it should no longer be
|
||||
* considered a default wired connection, and should no longer affect
|
||||
* the no-auto-default configuration option.
|
||||
|
|
@ -2006,7 +2002,7 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self)
|
|||
g_object_set_data (G_OBJECT (added), DEFAULT_WIRED_DEVICE_TAG, device);
|
||||
g_object_set_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG, added);
|
||||
|
||||
g_signal_connect (added, NM_SETTINGS_CONNECTION_UPDATED_BY_USER,
|
||||
g_signal_connect (added, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
|
||||
G_CALLBACK (default_wired_connection_updated_by_user_cb), self);
|
||||
g_signal_connect (added, NM_SETTINGS_CONNECTION_REMOVED,
|
||||
G_CALLBACK (default_wired_connection_removed_cb), self);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue