VPS 1.0
[enigma2-plugins.git] / vps / src_py / Vps_setup.py
1 # -*- coding: utf-8 -*-
2
3 from . import _
4 from Screens.Screen import Screen
5 from Components.ScrollLabel import ScrollLabel
6 from Components.ConfigList import ConfigListScreen
7 from Components.ActionMap import ActionMap
8 from Components.Sources.StaticText import StaticText
9 from Components.config import config, getConfigListEntry
10
11 class VPS_Setup(Screen, ConfigListScreen):
12
13         skin = """<screen name="vpsConfiguration" title="VPS-Plugin" position="center,center" size="600,370">
14                 <ePixmap position="5,5" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
15                 <ePixmap position="155,5" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
16                 <ePixmap position="305,5" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
17                 <ePixmap position="455,5" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
18                 <widget source="key_red" render="Label" position="5,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;20" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
19                 <widget source="key_green" render="Label" position="155,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;20" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
20                 <widget source="key_blue" render="Label" position="455,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;20" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
21                 <widget name="config" position="5,50" size="590,185" scrollbarMode="showOnDemand" />
22                 <ePixmap pixmap="skin_default/div-h.png" position="0,236" zPosition="1" size="600,2" />
23                 <widget source="help" render="Label" position="5,245" size="590,125" font="Regular;21" />
24         </screen>"""
25         
26         def __init__(self, session):
27                 Screen.__init__(self, session)
28                 
29                 self.setup_title = "VPS-Plugin Einstellungen"
30                 
31                 self.vps_enabled = getConfigListEntry(_("Enable VPS-Plugin"), config.plugins.vps.enabled)
32                 self.vps_initial_time = getConfigListEntry(_("Starting time"), config.plugins.vps.initial_time)
33                 self.vps_allow_wakeup = getConfigListEntry(_("Wakeup from Deep-Standby is allowed"), config.plugins.vps.allow_wakeup)
34                 self.vps_allow_seeking_multiple_pdc = getConfigListEntry(_("Seeking connected events"), config.plugins.vps.allow_seeking_multiple_pdc)
35                 self.vps_default = getConfigListEntry(_("VPS enabled by default"), config.plugins.vps.vps_default)
36                 
37                 self.list = []
38                 self.list.append(self.vps_enabled)
39                 self.list.append(self.vps_initial_time)
40                 self.list.append(self.vps_allow_wakeup)
41                 self.list.append(self.vps_allow_seeking_multiple_pdc)
42                 self.list.append(self.vps_default)
43
44                 ConfigListScreen.__init__(self, self.list, session = session)
45                 self["config"].onSelectionChanged.append(self.updateHelp)
46
47                 # Initialize Buttons
48                 self["key_red"] = StaticText(_("Cancel"))
49                 self["key_green"] = StaticText(_("OK"))
50                 self["key_blue"] = StaticText(_("Information"))
51
52                 self["help"] = StaticText()
53
54                 # Define Actions
55                 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
56                         {
57                                 "cancel": self.keyCancel,
58                                 "save": self.keySave,
59                                 "blue": self.show_info,
60                         }
61                 )
62         
63         def updateHelp(self):
64                 cur = self["config"].getCurrent()
65                 if cur == self.vps_enabled:
66                         self["help"].text = _("This plugin can determine whether a programme begins earlier or lasts longer. The channel has to provide reliable data.")
67                 elif cur == self.vps_initial_time:
68                         self["help"].text = _("If possible, x minutes before a timer starts VPS-Plugin will control whether the programme begins earlier. (0 disables feature)")
69                 elif cur == self.vps_default:
70                         self["help"].text = _("Enable VPS by default (new timers)")
71                 elif cur == self.vps_allow_wakeup:
72                         self["help"].text = _("If enabled and necessary, the plugin will wake up the Dreambox from Deep-Standby for the defined starting time to control whether the programme begins earlier.")
73                 elif cur == self.vps_allow_seeking_multiple_pdc:
74                         self["help"].text = _("If a programme is interrupted and divided into separate events, the plugin will search for the connected events.")
75
76         def show_info(self):
77                 VPS_show_info(self.session)
78         
79         def cancelConfirm(self, result):
80                 if not result:
81                         return
82
83                 for x in self["config"].list:
84                         x[1].cancel()
85
86                 self.close(self.session)
87
88         def keyCancel(self):
89                 if self["config"].isChanged():
90                         from Screens.MessageBox import MessageBox
91
92                         self.session.openWithCallback(
93                                 self.cancelConfirm,
94                                 MessageBox,
95                                 _("Really close without saving settings?")
96                         )
97                 else:
98                         self.close(self.session)
99
100         def keySave(self):
101                 for x in self["config"].list:
102                         x[1].save()
103
104                 self.close(self.session)
105
106
107
108 class VPS_Screen_Info(Screen):
109         skin = """<screen name="vpsInfo" position="center,center" size="550,400" title="VPS-Plugin Information">
110                 <widget name="text" position="10,10" size="540,390" font="Regular;22" />
111         </screen>"""
112         
113         def __init__(self, session):
114                 Screen.__init__(self, session)
115                 
116                 self["text"] = ScrollLabel(_("VPS-Plugin can react on delays arising in the startTime or endTime of a programme. VPS is only supported by certain channels!\n\nIf you enable VPS, the recording will only start, when the channel flags the programme as running.\n\nIf you select \"yes (safe mode)\", the recording is definitely starting at the latest at the startTime you defined. The recording may start earlier or last longer.\n\n\nSupported channels\n\nGermany:\n ARD and ZDF\n\nAustria:\n ORF\n\nSwitzerland:\n SF\n\nCzech Republic:\n CT\n\nIf a timer is programmed manually (not via EPG), it is necessary to set a VPS-Time to enable VPS. VPS-Time (also known as PDC) is the first published start time, e.g. given in magazines. If you set a VPS-Time, you have to leave timer name empty."))
117                 
118                 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions"], 
119                         {
120                                 "cancel": self.close,
121                                 "ok": self.close,
122                                 "up": self["text"].pageUp,
123                                 "down": self["text"].pageDown,
124                         }, -1)
125                 
126         
127 def VPS_show_info(session):
128         session.open(VPS_Screen_Info)
129