From 12290252c7948886caac1014a04b57daf87b215c Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 7 Jul 2016 11:35:19 +0200 Subject: libnm/client: emit signals when active connection disappears It allows us to reliably track failures to activate a connection. --- libnm/nm-client.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'libnm/nm-client.c') diff --git a/libnm/nm-client.c b/libnm/nm-client.c index a7ecdb5572..4b375581c1 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -89,6 +89,8 @@ enum { PERMISSION_CHANGED, CONNECTION_ADDED, CONNECTION_REMOVED, + ACTIVE_CONNECTION_ADDED, + ACTIVE_CONNECTION_REMOVED, LAST_SIGNAL }; @@ -1751,6 +1753,22 @@ settings_connection_removed (NMRemoteSettings *manager, g_signal_emit (client, signals[CONNECTION_REMOVED], 0, connection); } +static void +manager_active_connection_added (NMManager *manager, + NMActiveConnection *active_connection, + gpointer client) +{ + g_signal_emit (client, signals[ACTIVE_CONNECTION_ADDED], 0, active_connection); +} + +static void +manager_active_connection_removed (NMManager *manager, + NMActiveConnection *active_connection, + gpointer client) +{ + g_signal_emit (client, signals[ACTIVE_CONNECTION_REMOVED], 0, active_connection); +} + static void constructed (GObject *object) { @@ -1772,6 +1790,10 @@ constructed (GObject *object) G_CALLBACK (manager_any_device_removed), client); g_signal_connect (priv->manager, "permission-changed", G_CALLBACK (manager_permission_changed), client); + g_signal_connect (priv->manager, "active-connection-added", + G_CALLBACK (manager_active_connection_added), client); + g_signal_connect (priv->manager, "active-connection-removed", + G_CALLBACK (manager_active_connection_removed), client); priv->settings = g_object_new (NM_TYPE_REMOTE_SETTINGS, NM_OBJECT_PATH, NM_DBUS_PATH_SETTINGS, @@ -2353,6 +2375,36 @@ nm_client_class_init (NMClientClass *client_class) NULL, NULL, NULL, G_TYPE_NONE, 1, NM_TYPE_REMOTE_CONNECTION); + + /** + * NMClient::active-connection-added: + * @client: the settings object that received the signal + * @active_connection: the new active connection + * + * Notifies that a #NMActiveConnection has been added. + **/ + signals[ACTIVE_CONNECTION_ADDED] = + g_signal_new (NM_CLIENT_ACTIVE_CONNECTION_ADDED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, + NM_TYPE_ACTIVE_CONNECTION); + + /** + * NMClient::active-connection-removed: + * @client: the settings object that received the signal + * @active_connection: the removed active connection + * + * Notifies that a #NMActiveConnection has been removed. + **/ + signals[ACTIVE_CONNECTION_REMOVED] = + g_signal_new (NM_CLIENT_ACTIVE_CONNECTION_REMOVED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, + NM_TYPE_ACTIVE_CONNECTION); } static void -- cgit v1.2.1