VPS 1.3: handle AFTEREVENT.AUTO correctly if receiver was woken up by plugin
[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.3"
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_allow_wakeup = getConfigListEntry(_("Wakeup from Deep-Standby is allowed"), config.plugins.vps.allow_wakeup)
37                 self.vps_allow_seeking_multiple_pdc = getConfigListEntry(_("Seeking connected events"), config.plugins.vps.allow_seeking_multiple_pdc)
38                 self.vps_default = getConfigListEntry(_("VPS enabled by default"), config.plugins.vps.vps_default)
39                 self.vps_instanttimer = getConfigListEntry(_("Enable VPS on instant records"), config.plugins.vps.instanttimer)
40                 
41                 self.list = []
42                 self.list.append(self.vps_enabled)
43                 self.list.append(self.vps_initial_time)
44                 self.list.append(self.vps_allow_wakeup)
45                 self.list.append(self.vps_allow_seeking_multiple_pdc)
46                 self.list.append(self.vps_default)
47                 self.list.append(self.vps_instanttimer)
48
49                 ConfigListScreen.__init__(self, self.list, session = session)
50                 self["config"].onSelectionChanged.append(self.updateHelp)
51
52                 # Initialize Buttons
53                 self["key_red"] = StaticText(_("Cancel"))
54                 self["key_green"] = StaticText(_("OK"))
55                 self["key_blue"] = StaticText(_("Information"))
56
57                 self["help"] = StaticText()
58
59                 # Define Actions
60                 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
61                         {
62                                 "cancel": self.keyCancel,
63                                 "save": self.keySave,
64                                 "blue": self.show_info,
65                         }
66                 )
67                 
68                 self.onLayoutFinish.append(self.setCustomTitle)
69                 
70         def setCustomTitle(self):
71                 self.setTitle(self.setup_title)
72         
73         def updateHelp(self):
74                 cur = self["config"].getCurrent()
75                 if cur == self.vps_enabled:
76                         self["help"].text = _("This plugin can determine whether a programme begins earlier or lasts longer. The channel has to provide reliable data.")
77                 elif cur == self.vps_initial_time:
78                         self["help"].text = _("If possible, x minutes before a timer starts VPS-Plugin will control whether the programme begins earlier. (0 disables feature)")
79                 elif cur == self.vps_default:
80                         self["help"].text = _("Enable VPS by default (new timers)")
81                 elif cur == self.vps_allow_wakeup:
82                         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.")
83                 elif cur == self.vps_allow_seeking_multiple_pdc:
84                         self["help"].text = _("If a programme is interrupted and divided into separate events, the plugin will search for the connected events.")
85                 elif cur == self.vps_instanttimer:
86                         self["help"].text = _("When yes, VPS will be enabled on instant records (stop after current event), if the channel supports VPS.")
87
88         def show_info(self):
89                 VPS_show_info(self.session)
90         
91         def cancelConfirm(self, result):
92                 if not result:
93                         return
94
95                 for x in self["config"].list:
96                         x[1].cancel()
97
98                 self.close(self.session)
99
100         def keyCancel(self):
101                 if self["config"].isChanged():
102                         from Screens.MessageBox import MessageBox
103
104                         self.session.openWithCallback(
105                                 self.cancelConfirm,
106                                 MessageBox,
107                                 _("Really close without saving settings?")
108                         )
109                 else:
110                         self.close(self.session)
111
112         def keySave(self):
113                 for x in self["config"].list:
114                         x[1].save()
115
116                 self.close(self.session)
117
118
119
120 class VPS_Screen_Info(Screen):
121         skin = """<screen name="vpsInfo" position="center,center" size="550,400" title="VPS-Plugin Information">
122                 <widget name="text" position="10,10" size="540,390" font="Regular;22" />
123         </screen>"""
124         
125         def __init__(self, session):
126                 Screen.__init__(self, session)
127                 
128                 #Summary
129                 self.info_title = _("VPS-Plugin Information")
130                 
131                 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."))
132                 
133                 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions"], 
134                         {
135                                 "cancel": self.close,
136                                 "ok": self.close,
137                                 "up": self["text"].pageUp,
138                                 "down": self["text"].pageDown,
139                         }, -1)
140                 
141                 self.onLayoutFinish.append(self.setCustomTitle)
142                 
143         def setCustomTitle(self):
144                 self.setTitle(self.info_title)
145                 
146         
147 def VPS_show_info(session):
148         session.open(VPS_Screen_Info)
149