Mercurial > libervia-web
comparison src/browser/libervia_main.py @ 665:6a8a1103ad10 frontends_multi_profiles
browser_side: OTR uses 'profilePlugged', 'disconnect' and 'gotMenus' listeners
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 03 Mar 2015 22:31:54 +0100 |
parents | 423182fea41c |
children | 166f3b624816 |
comparison
equal
deleted
inserted
replaced
664:8449a5db0602 | 665:6a8a1103ad10 |
---|---|
136 | 136 |
137 self.bridge_signals.register(functionName, callback, with_profile=with_profile) | 137 self.bridge_signals.register(functionName, callback, with_profile=with_profile) |
138 | 138 |
139 def importPlugins(self): | 139 def importPlugins(self): |
140 self.plugins = {} | 140 self.plugins = {} |
141 inhibited_menus = [] | |
142 # FIXME: plugins import should be dynamic and generic like in sat | |
143 try: | 141 try: |
144 self.plugins['otr'] = plugin_sec_otr.OTR(self) | 142 self.plugins['otr'] = plugin_sec_otr.OTR(self) |
145 except TypeError: # plugin_sec_otr has not been imported | 143 except TypeError: # plugin_sec_otr has not been imported |
146 inhibited_menus.append('OTR') | 144 pass |
147 | |
148 class DummyPlugin(object): | |
149 def inhibitMenus(self): | |
150 return inhibited_menus | |
151 | |
152 self.plugins['dummy_plugin'] = DummyPlugin() | |
153 | 145 |
154 # def addSelectedListener(self, callback): | 146 # def addSelectedListener(self, callback): |
155 # self._selected_listeners.add(callback) | 147 # self._selected_listeners.add(callback) |
156 | 148 |
157 def getSelected(self): | 149 def getSelected(self): |
260 def gotMenus(self, menus): | 252 def gotMenus(self, menus): |
261 """Put the menus data in cache and build the main menu bar | 253 """Put the menus data in cache and build the main menu bar |
262 | 254 |
263 @param menus (list[tuple]): menu data | 255 @param menus (list[tuple]): menu data |
264 """ | 256 """ |
265 def process(menus, inhibited=None): | 257 self.callListeners('gotMenus', menus) # FIXME: to be done another way or moved to quick_app |
266 for raw_menu in menus: | |
267 id_, type_, path, path_i18n = raw_menu | |
268 if inhibited and path[0] in inhibited: | |
269 continue | |
270 menus_data = self.menus.setdefault(type_, []) | |
271 menus_data.append((id_, path, path_i18n)) | |
272 | |
273 self.menus = {} | 258 self.menus = {} |
274 inhibited = set() # FIXME | 259 for id_, type_, path, path_i18n in menus: |
275 extras = [] | 260 self.menus.setdefault(type_, []).append((id_, path, path_i18n)) |
276 for plugin in self.plugins.values(): | |
277 if hasattr(plugin, "inhibitMenus"): | |
278 inhibited.update(plugin.inhibitMenus()) | |
279 if hasattr(plugin, "extraMenus"): | |
280 extras.extend(plugin.extraMenus()) | |
281 process(menus, inhibited) | |
282 process(extras) | |
283 self.panel.menu.createMenus() | 261 self.panel.menu.createMenus() |
284 | 262 |
285 def _isRegisteredCB(self, result): | 263 def _isRegisteredCB(self, result): |
286 registered, warning = result | 264 registered, warning = result |
287 if not registered: | 265 if not registered: |
340 | 318 |
341 # count = [0] # used to do something similar to DeferredList | 319 # count = [0] # used to do something similar to DeferredList |
342 # for cat, name in C.CACHED_PARAMS: | 320 # for cat, name in C.CACHED_PARAMS: |
343 # self.bridge.call('asyncGetParamA', param_cb(cat, name, count), name, cat) | 321 # self.bridge.call('asyncGetParamA', param_cb(cat, name, count), name, cat) |
344 | 322 |
345 def profilePlugged(self, dummy): | 323 def profilePlugged(self, dummy): # FIXME: to be called as a "profilePlugged" listener? |
346 QuickApp.profilePlugged(self, dummy) | 324 QuickApp.profilePlugged(self, dummy) |
347 # we fill the panels already here | 325 # we fill the panels already here |
348 for wid in self.widgets.getWidgets(blog.MicroblogPanel): | 326 for wid in self.widgets.getWidgets(blog.MicroblogPanel): |
349 if wid.accept_all(): | 327 if wid.accept_all(): |
350 self.bridge.getMassiveLastMblogs('ALL', (), 10, profile=C.PROF_KEY_NONE, callback=wid.massiveInsert) | 328 self.bridge.getMassiveLastMblogs('ALL', (), 10, profile=C.PROF_KEY_NONE, callback=wid.massiveInsert) |
351 else: | 329 else: |
352 self.bridge.getMassiveLastMblogs('GROUP', wid.accepted_groups, 10, profile=C.PROF_KEY_NONE, callback=wid.massiveInsert) | 330 self.bridge.getMassiveLastMblogs('GROUP', wid.accepted_groups, 10, profile=C.PROF_KEY_NONE, callback=wid.massiveInsert) |
353 | 331 |
354 #we ask for our own microblogs: | 332 #we ask for our own microblogs: |
355 self.bridge.getMassiveLastMblogs('JID', (unicode(self.whoami.bare),), 10, profile=C.PROF_KEY_NONE, callback=self._ownBlogsFills) | 333 self.bridge.getMassiveLastMblogs('JID', (unicode(self.whoami.bare),), 10, profile=C.PROF_KEY_NONE, callback=self._ownBlogsFills) |
356 | |
357 # initialize plugins which waited for the connection to be done | |
358 for plugin in self.plugins.values(): | |
359 if hasattr(plugin, 'profileConnected'): | |
360 plugin.profileConnected() | |
361 | 334 |
362 def addContactList(self, dummy): | 335 def addContactList(self, dummy): |
363 contact_list = ContactList(self) | 336 contact_list = ContactList(self) |
364 self.panel.addContactList(contact_list) | 337 self.panel.addContactList(contact_list) |
365 | 338 |