VPS-Plugin: initial checkin
[enigma2-plugins.git] / vps / src_py / plugin.py
1 from Plugins.Plugin import PluginDescriptor
2 from os import stat
3 from Vps import vps_timers
4 from Vps_setup import VPS_Setup
5 from Modifications import register_vps
6
7 # Config
8 from Components.config import config, ConfigYesNo, ConfigSubsection, ConfigInteger
9
10 config.plugins.vps = ConfigSubsection()
11 config.plugins.vps.enabled = ConfigYesNo(default = True)
12 config.plugins.vps.initial_time = ConfigInteger(default=10, limits=(0, 120))
13 config.plugins.vps.allow_overwrite = ConfigYesNo(default = False)
14 config.plugins.vps.allow_wakeup = ConfigYesNo(default = False)
15 config.plugins.vps.default_vps = ConfigYesNo(default = False)
16 config.plugins.vps.default_overwrite = ConfigYesNo(default = False)
17 config.plugins.vps.infotext = ConfigInteger(default = 0)
18
19
20 def autostart(reason, **kwargs):
21         if reason == 0:
22                 if kwargs.has_key("session"):
23                         session = kwargs["session"]
24                         vps_timers.session = session
25                         vps_timers.checkTimer()
26                 
27                 register_vps()
28         
29         elif reason == 1:
30                 vps_timers.shutdown()
31                 
32
33 def setup(session, **kwargs):
34         session.openWithCallback(doneConfig, VPS_Setup)
35
36 def doneConfig(session, **kwargs):
37         vps_timers.checkTimer()
38
39 def startSetup(menuid):
40         if menuid != "system":
41                 return []
42         return [("VPS-Plugin", setup, "vps", 50)]
43
44 def getNextWakeup():
45         return vps_timers.NextWakeup()
46         
47         
48
49 def Plugins(**kwargs):
50         return [
51                 PluginDescriptor(
52                         name = "VPS",
53                         where = [
54                                 PluginDescriptor.WHERE_AUTOSTART,
55                                 PluginDescriptor.WHERE_SESSIONSTART
56                         ],
57                         fnc = autostart,
58                         wakeupfnc = getNextWakeup
59                 ),
60                 PluginDescriptor(
61                         name = "VPS-Plugin",
62                         where = PluginDescriptor.WHERE_MENU,
63                         fnc = startSetup
64                 ),
65         ]