diff 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
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Tue Mar 03 19:00:21 2015 +0100
+++ b/src/browser/libervia_main.py	Tue Mar 03 22:31:54 2015 +0100
@@ -138,18 +138,10 @@
 
     def importPlugins(self):
         self.plugins = {}
-        inhibited_menus = []
-        # FIXME: plugins import should be dynamic and generic like in sat
         try:
             self.plugins['otr'] = plugin_sec_otr.OTR(self)
         except TypeError:  # plugin_sec_otr has not been imported
-            inhibited_menus.append('OTR')
-
-        class DummyPlugin(object):
-            def inhibitMenus(self):
-                return inhibited_menus
-
-        self.plugins['dummy_plugin'] = DummyPlugin()
+            pass
 
     # def addSelectedListener(self, callback):
     #     self._selected_listeners.add(callback)
@@ -262,24 +254,10 @@
 
         @param menus (list[tuple]): menu data
         """
-        def process(menus, inhibited=None):
-            for raw_menu in menus:
-                id_, type_, path, path_i18n = raw_menu
-                if inhibited and path[0] in inhibited:
-                    continue
-                menus_data = self.menus.setdefault(type_, [])
-                menus_data.append((id_, path, path_i18n))
-
+        self.callListeners('gotMenus', menus)  # FIXME: to be done another way or moved to quick_app
         self.menus = {}
-        inhibited = set() # FIXME
-        extras = []
-        for plugin in self.plugins.values():
-            if hasattr(plugin, "inhibitMenus"):
-                inhibited.update(plugin.inhibitMenus())
-            if hasattr(plugin, "extraMenus"):
-                extras.extend(plugin.extraMenus())
-        process(menus, inhibited)
-        process(extras)
+        for id_, type_, path, path_i18n in menus:
+            self.menus.setdefault(type_, []).append((id_, path, path_i18n))
         self.panel.menu.createMenus()
 
     def _isRegisteredCB(self, result):
@@ -342,7 +320,7 @@
         # for cat, name in C.CACHED_PARAMS:
         #     self.bridge.call('asyncGetParamA', param_cb(cat, name, count), name, cat)
 
-    def profilePlugged(self, dummy):
+    def profilePlugged(self, dummy):  # FIXME: to be called as a "profilePlugged" listener?
         QuickApp.profilePlugged(self, dummy)
         # we fill the panels already here
         for wid in self.widgets.getWidgets(blog.MicroblogPanel):
@@ -354,11 +332,6 @@
         #we ask for our own microblogs:
         self.bridge.getMassiveLastMblogs('JID', (unicode(self.whoami.bare),), 10, profile=C.PROF_KEY_NONE, callback=self._ownBlogsFills)
 
-        # initialize plugins which waited for the connection to be done
-        for plugin in self.plugins.values():
-            if hasattr(plugin, 'profileConnected'):
-                plugin.profileConnected()
-
     def addContactList(self, dummy):
         contact_list = ContactList(self)
         self.panel.addContactList(contact_list)