From 92ea35469da682175117e5de035b9a6ad0e58ed8 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 22 Aug 2012 18:33:17 -0500 Subject: [PATCH] core: add manager active connection added/removed signals Will replace the VPN manager's activated/deactivated signals; listeners can attach to the active connection's 'state' property and listen for the changes to ACTIVATED and DEACTIVATED. Works for all connections, not just VPN ones. --- src/nm-manager.c | 21 +++++++++++++++++++++ src/nm-manager.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/src/nm-manager.c b/src/nm-manager.c index 6bd31700b1..fec1508840 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -256,6 +256,8 @@ enum { PROPERTIES_CHANGED, CHECK_PERMISSIONS, USER_PERMISSIONS_CHANGED, + ACTIVE_CONNECTION_ADDED, + ACTIVE_CONNECTION_REMOVED, LAST_SIGNAL }; @@ -319,6 +321,7 @@ _active_connection_cleanup (gpointer user_data) iter = iter->next; if (nm_active_connection_get_state (ac) == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { priv->active_connections = g_slist_remove (priv->active_connections, ac); + g_signal_emit (self, signals[ACTIVE_CONNECTION_REMOVED], 0, ac); g_signal_handlers_disconnect_by_func (ac, active_connection_state_changed, self); g_object_unref (ac); changed = TRUE; @@ -362,6 +365,8 @@ active_connection_add (NMManager *self, NMActiveConnection *active) g_signal_connect (active, "notify::" NM_ACTIVE_CONNECTION_STATE, G_CALLBACK (active_connection_state_changed), self); + + g_signal_emit (self, signals[ACTIVE_CONNECTION_ADDED], 0, active); g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS); } @@ -4608,6 +4613,22 @@ nm_manager_class_init (NMManagerClass *manager_class) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[ACTIVE_CONNECTION_ADDED] = + g_signal_new (NM_MANAGER_ACTIVE_CONNECTION_ADDED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + + signals[ACTIVE_CONNECTION_REMOVED] = + g_signal_new (NM_MANAGER_ACTIVE_CONNECTION_REMOVED, + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (manager_class), &dbus_glib_nm_manager_object_info); diff --git a/src/nm-manager.h b/src/nm-manager.h index 7d0b9a55cd..66d0678318 100644 --- a/src/nm-manager.h +++ b/src/nm-manager.h @@ -63,6 +63,11 @@ typedef enum { #define NM_MANAGER_HOSTNAME "hostname" #define NM_MANAGER_SLEEPING "sleeping" +/* Internal signals */ +#define NM_MANAGER_ACTIVE_CONNECTION_ADDED "active-connection-added" +#define NM_MANAGER_ACTIVE_CONNECTION_REMOVED "active-connection-removed" + + typedef struct { GObject parent; } NMManager;