[VPS] margin after record, fix starting from standby
[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 VERSION = "1.4"
12
13 class VPS_Setup(Screen, ConfigListScreen):
14
15         skin = """<screen name="vpsConfiguration" title="VPS-Plugin" position="center,center" size="600,370">
16                 <ePixmap position="5,5" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
17                 <ePixmap position="155,5" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
18                 <ePixmap position="305,5" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
19                 <ePixmap position="455,5" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
20                 <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" />
21                 <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" />
22                 <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" />
23                 <widget name="config" position="5,50" size="590,185" scrollbarMode="showOnDemand" />
24                 <ePixmap pixmap="skin_default/div-h.png" position="0,236" zPosition="1" size="600,2" />
25                 <widget source="help" render="Label" position="5,245" size="590,125" font="Regular;21" />
26         </screen>"""
27         
28         def __init__(self, session):
29                 Screen.__init__(self, session)
30
31                 #Summary
32                 self.setup_title = _("VPS Setup Version %s") %VERSION
33
34                 self.vps_enabled = getConfigListEntry(_("Enable VPS-Plugin"), config.plugins.vps.enabled)
35                 self.vps_initial_time = getConfigListEntry(_("Starting time"), config.plugins.vps.initial_time)
36                 self.vps_margin_after = getConfigListEntry(_("Margin after record (in seconds)"), config.plugins.vps.margin_after)
37                 self.vps_allow_wakeup = getConfigListEntry(_("Wakeup from Deep-Standby is allowed"), config.plugins.vps.allow_wakeup)
38                 self.vps_allow_seeking_multiple_pdc = getConfigListEntry(_("Seeking connected events"), config.plugins.vps.allow_seeking_multiple_pdc)
39                 self.vps_default = getConfigListEntry(_("VPS enabled by default"), config.plugins.vps.vps_default)
40                 self.vps_instanttimer = getConfigListEntry(_("Enable VPS on instant records"), config.plugins.vps.instanttimer)
41                 
42                 self.list = []
43                 self.list.append(self.vps_enabled)
44                 self.list.append(self.vps_initial_time)
45                 self.list.append(self.vps_margin_after)
46                 self.list.append(self.vps_allow_wakeup)
47                 self.list.append(self.vps_allow_seeking_multiple_pdc)
48                 self.list.append(self.vps_default)
49                 self.list.append(self.vps_instanttimer)
50
51                 ConfigListScreen.__init__(self, self.list, session = session)
52                 self["config"].onSelectionChanged.append(self.updateHelp)
53
54                 # Initialize Buttons
55                 self["key_red"] = StaticText(_("Cancel"))
56                 self["key_green"] = StaticText(_("OK"))
57                 self["key_blue"] = StaticText(_("Information"))
58
59                 self["help"] = StaticText()
60
61                 # Define Actions
62                 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
63                         {
64                                 "cancel": self.keyCancel,
65                                 "save": self.keySave,
66                                 "blue": self.show_info,
67                         }
68                 )
69                 
70                 self.onLayoutFinish.append(self.setCustomTitle)
71                 
72         def setCustomTitle(self):
73                 self.setTitle(self.setup_title)
74         
75         def updateHelp(self):
76                 cur = self["config"].getCurrent()
77                 if cur == self.vps_enabled:
78                         self["help"].text = _("This plugin can determine whether a programme begins earlier or lasts longer. The channel has to provide reliable data.")
79                 elif cur == self.vps_initial_time:
80                         self["help"].text = _("If possible, x minutes before a timer starts VPS-Plugin will control whether the programme begins earlier. (0 disables feature)")
81                 elif cur == self.vps_margin_after:
82                         self["help"].text = _("The recording will last n seconds longer after the channel sent the stop signal.")
83                 elif cur == self.vps_default:
84                         self["help"].text = _("Enable VPS by default (new timers)")
85                 elif cur == self.vps_allow_wakeup:
86                         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.")
87                 elif cur == self.vps_allow_seeking_multiple_pdc:
88                         self["help"].text = _("If a programme is interrupted and divided into separate events, the plugin will search for the connected events.")
89                 elif cur == self.vps_instanttimer:
90                         self["help"].text = _("When yes, VPS will be enabled on instant records (stop after current event), if the channel supports VPS.")
91
92         def show_info(self):
93                 VPS_show_info(self.session)
94         
95         def cancelConfirm(self, result):
96                 if not result:
97                         return
98
99                 for x in self["config"].list:
100                         x[1].cancel()
101
102                 self.close(self.session)
103
104         def keyCancel(self):
105                 if self["config"].isChanged():
106                         from Screens.MessageBox import MessageBox
107
108                         self.session.openWithCallback(
109                                 self.cancelConfirm,
110                                 MessageBox,
111                                 _("Really close without saving settings?")
112                         )
113                 else:
114                         self.close(self.session)
115
116         def keySave(self):
117                 for x in self["config"].list:
118                         x[1].save()
119
120                 self.close(self.session)
121
122
123
124 class VPS_Screen_Info(Screen):
125         skin = """<screen name="vpsInfo" position="center,center" size="550,400" title="VPS-Plugin Information">
126                 <widget name="text" position="10,10" size="540,390" font="Regular;22" />
127         </screen>"""
128         
129         def __init__(self, session):
130                 Screen.__init__(self, session)
131                 
132                 #Summary
133                 self.info_title = _("VPS-Plugin Information")
134                 
135                 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."))
136                 
137                 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions"], 
138                         {
139                                 "cancel": self.close,
140                                 "ok": self.close,
141                                 "up": self["text"].pageUp,
142                                 "down": self["text"].pageDown,
143                         }, -1)
144                 
145                 self.onLayoutFinish.append(self.setCustomTitle)
146                 
147         def setCustomTitle(self):
148                 self.setTitle(self.info_title)
149                 
150         
151 def VPS_show_info(session):
152         session.open(VPS_Screen_Info)
153