comparison 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
comparison
equal deleted inserted replaced
437:02c633a0ddcf 438:62145e50eae5
245 debug (_("setting plugins parents")) 245 debug (_("setting plugins parents"))
246 246
247 for plugin in self.plugins.iteritems(): 247 for plugin in self.plugins.iteritems():
248 if plugin[1].is_handler: 248 if plugin[1].is_handler:
249 plugin[1].getHandler(profile).setHandlerParent(current) 249 plugin[1].getHandler(profile).setHandlerParent(current)
250 connected_cb = getattr(plugin[1], "profileConnected", None)
251 if connected_cb:
252 connected_cb(profile)
250 253
251 current.startService() 254 current.startService()
252 255
253 return current.getConnectionDeferred() 256 return current.getConnectionDeferred()
254 257
260 info(_("not connected !")) 263 info(_("not connected !"))
261 return 264 return
262 profile = self.memory.getProfileName(profile_key) 265 profile = self.memory.getProfileName(profile_key)
263 info(_("Disconnecting...")) 266 info(_("Disconnecting..."))
264 self.profiles[profile].stopService() 267 self.profiles[profile].stopService()
268 for plugin in self.plugins.iteritems():
269 disconnected_cb = getattr(plugin[1], "profileDisconnected", None)
270 if disconnected_cb:
271 disconnected_cb(profile)
265 272
266 def purgeClient(self, profile): 273 def purgeClient(self, profile):
267 """Remove reference to a profile client and purge cache 274 """Remove reference to a profile client and purge cache
268 the garbage collector can then free the memory""" 275 the garbage collector can then free the memory"""
269 try: 276 try: