de3ec4f06ecac0cb8a6b26c28f10354df9780270
[enigma2.git] / lib / python / Plugins / Plugin.py
1 from enigma import loadPNG
2 from Components.config import ConfigSubsection, config
3
4 config.plugins = ConfigSubsection()
5
6 class PluginDescriptor:
7         """An object to describe a plugin."""
8         
9         # where to list the plugin. Note that there are different call arguments,
10         # so you might not be able to combine them.
11         
12         # supported arguments are:
13         #   session
14         #   servicereference
15         #   reason
16         
17         # you have to ignore unknown kwargs!
18         
19         # argument: session
20         WHERE_EXTENSIONSMENU = 0
21         WHERE_MAINMENU = 1
22         WHERE_PLUGINMENU  = 2
23         # argument: session, serviceref (currently selected)
24         WHERE_MOVIELIST = 3
25         # ...
26         WHERE_SETUP    = 4
27         
28         # reason (0: start, 1: end)
29         WHERE_AUTOSTART = 5
30         
31         # start as wizard. In that case, fnc must be a screen class!
32         WHERE_WIZARD = 6
33         
34         # like autostart, but for a session. currently, only session starts are 
35         # delivered, and only on pre-loaded plugins
36         WHERE_SESSIONSTART = 7
37         
38         # start as teletext plugin. arguments: session, serviceref
39         WHERE_TELETEXT = 8
40         
41         def __init__(self, name = "Plugin", where = [ ], description = "", icon = None, fnc = None):
42                 self.name = name
43                 if type(where) is list:
44                         self.where = where
45                 else:
46                         self.where = [ where ]
47                 self.description = description
48
49                 if type(icon) is str or icon is None:
50                         self.iconstr = icon
51                         self.icon = None
52                 else:
53                         self.icon = icon
54
55                 self.__call__ = fnc
56
57         def updateIcon(self, path):
58                 if type(self.iconstr) is str:
59                         self.icon = loadPNG(path + "/" + self.iconstr)
60                 else:
61                         self.icon = None
62
63         def __eq__(self, other):
64                 return self.__call__ == other.__call__