added the most important part
[vuplus_dvbapp] / doc / PLUGINS
1 enigma2 plugins
2 ===============
3
4 Enigma2 plugins are always written in python. If you really have to call
5 C/C++ functions from your code, you can supply a python module with it,
6 implementing your functions.
7
8 Let's write a plugin. We call it "ourSmallTest", and it should be a test
9 plugin.
10
11 The simplest plugin looks like the following:
12
13 Plugins/ourSmallTest/plugin.py:
14
15 "from Plugins.Plugin import PluginDescriptor
16
17 def main(session):
18         print "Hello world!"
19
20 def Plugins():
21         return PluginDescriptor(
22                 name="Our Small Test", 
23                 description="plugin to test some capabilities", 
24                 where = PluginDescriptor.WHERE_PLUGINMENU,
25                 fnc=main)"
26
27 Basically, you're writing a "python module", which is called
28 Plugins.ourSmallTest.plugin. This corresponds to the
29 Plugins/ourSmallTest/plugin.py file.
30
31 This module must define a single function called "Plugins". The functions is
32 called for every Plugin, and should return (a list of)
33 PluginDescriptor-Objects. A PluginDescriptor is a simple object, holding the
34 Plugin's name, description, picture etc., and an entry point.
35
36 In the first line, we import that class. It's contained in a module called
37 Plugins.Plugin.
38
39 At the end, we define the "Plugins"-Functions. As said, it returns a
40 constructed PluginDescriptor-object (in fact it can return either one or a
41 list of descriptors, here it returns exactly one). We use keyword arguments
42 to supply the Plugin's information, like the name, the descripttion etc.
43
44 We also supply an entry point, called "fnc". It's set to the "main"
45 function, which is defined before. Our entry point is called with a number
46 of arguments, depending on where the plugin was launched from. In this case,
47 it's a "session" argument. You need the session argument if you want to do
48 graphical output. A session basically connects to "user". There is always
49 one sessions which corresponds to the main screen output, but there can also
50 be other sessions, which yet have to be implemented. (A possible example is a
51 networked remote session.) If you don't need that argument, just ignore it.
52
53 A plugin can decide where it wants to be displayed. A possible example is
54 the plugin menu out of the main menu. In the "where" argument to the
55 descriptor, you can supply one (or a list of) "WHERE_"-identifiers. We use
56 WHERE_PLUGINMENU. There will be other ones, for example for the blue button,
57 or specific other menus.
58
59 Now, if you copy this plugin in-place, it should be listed in the plugin
60 browser in the main menu. You can press "ok" on the plugin, and the "main"
61 function, which was specified as the plugin's entry point, is executed.
62
63 If you want to open a graphical screen, you might want the entry point to
64 look like:
65
66 def main(session):
67         session.open(MyScreen)
68
69 with MyScreen being a GUI screen.
70
71
72 autostarting plugins
73 ====================
74
75 you can configure your plugin to automatically start on enigma startup, and
76 end on shutdown.
77
78 you just have to use "WHERE_AUTOSTART". your entry point must (fnc) look 
79 like:
80
81 def autostartEntry(raeson):
82         if reason == 0: # startup
83                 print "startup"
84         elif reason == 1:
85                 print "shutdown"