diff src/core/sat_main.py @ 438:62145e50eae5

core: plugins can now have profileConnected/profileDisconnected method to initialise/free profile dependant resources
author Goffi <goffi@goffi.org>
date Sat, 03 Dec 2011 15:45:48 +0100
parents d7e5df876a04
children cf005701624b
line wrap: on
line diff
--- a/src/core/sat_main.py	Wed Nov 30 00:24:41 2011 +0100
+++ b/src/core/sat_main.py	Sat Dec 03 15:45:48 2011 +0100
@@ -247,6 +247,9 @@
             for plugin in self.plugins.iteritems():
                 if plugin[1].is_handler:
                     plugin[1].getHandler(profile).setHandlerParent(current)
+                connected_cb = getattr(plugin[1], "profileConnected", None)
+                if connected_cb:
+                    connected_cb(profile)
 
             current.startService()
 
@@ -262,6 +265,10 @@
         profile = self.memory.getProfileName(profile_key)
         info(_("Disconnecting..."))
         self.profiles[profile].stopService()
+        for plugin in self.plugins.iteritems():
+            disconnected_cb = getattr(plugin[1], "profileDisconnected", None)
+            if disconnected_cb:
+                disconnected_cb(profile)
 
     def purgeClient(self, profile):
         """Remove reference to a profile client and purge cache