add a tuxbox plugins plugin to prepare loading of tuxbox plugins when the c++ part...
[enigma2.git] / lib / python / Components / PluginComponent.py
index 10e1b59d6f6a6a5bc8e0c2b3dcee7122b2cc7228..960043d68d98c624d6aacc626670032e94ee182a 100644 (file)
@@ -27,22 +27,29 @@ class PluginComponent:
                                                print "trying to import " + pluginmodule
                                                exec "import " + pluginmodule
                                                plugin = eval(pluginmodule)
-                                               picturepath = plugin.getPicturePath()
-                                               pluginname = plugin.getPluginName()
+                                               plugins = plugin.getPlugins()
+                                               try: picturepaths = plugin.getPicturePaths()
+                                               except:
+                                                       picturepaths = []
+                                                       for p in plugins:
+                                                               picturepaths.append("")
                                                try:
                                                        for menuEntry in plugin.getMenuRegistrationList():
                                                                self.menuEntries.append([menuEntry, pluginmodule])
                                                except:
                                                        pass
-               
-                                               list.append((picturepath, pluginname , x))
+       
+                                               for y in range(len(plugins)):
+                                                       if len(plugins[y]) < 4:
+                                                               list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][1], plugins[y][2], None))
+                                                       else:
+                                                               list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][1], plugins[y][2], plugins[y][3]))
                                                if runAutostartPlugins:
                                                        try: plugin.autostart()
                                                        except: pass
                                                if runAutoendPlugins:
                                                        try: plugin.autoend()
                                                        except: pass
-                                                       
                        except:
                                print "Directory", path, "contains a faulty plugin"
                self.menuUpdate()
@@ -58,8 +65,11 @@ class PluginComponent:
        
        def runPlugin(self, plugin, session):
                try:
-                       exec "import " + self.prefix + plugin[2] + ".plugin"
-                       eval(self.prefix + plugin[2] + ".plugin").main(session)
+                       exec("import " + self.prefix + plugin[2] + ".plugin")
+                       if plugin[3] == "screen":
+                               session.open(eval(self.prefix + plugin[2] + ".plugin." + plugin[4]), plugin[5])
+                       elif plugin[3] == "function":
+                               eval(self.prefix + plugin[2] + ".plugin." + plugin[4])(session, plugin[5])
                except:
                        print "exec of plugin failed!"