Merge remote-tracking branch 'origin/master'
[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="565,370">
14                 <ePixmap position="0,5" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
15                 <ePixmap position="140,5" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
16                 <ePixmap position="280,5" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
17                 <ePixmap position="420,5" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
18                 <widget source="key_red" render="Label" position="0,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
19                 <widget source="key_green" render="Label" position="140,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
20                 <widget source="key_blue" render="Label" position="420,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
21                 <widget name="config" position="5,50" size="555,200" scrollbarMode="showOnDemand" />
22                 <ePixmap pixmap="skin_default/div-h.png" position="0,251" zPosition="1" size="565,2" />
23                 <widget source="help" render="Label" position="5,255" size="555,113" 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_overwrite = getConfigListEntry(_("Recordings can be controlled by channel"), config.plugins.vps.allow_overwrite)
34                 self.vps_allow_wakeup = getConfigListEntry(_("Wakeup from Deep-Standby is allowed"), config.plugins.vps.allow_wakeup)
35                 self.vps_default = getConfigListEntry(_("VPS enabled by default"), config.plugins.vps.default_vps)
36                 self.vps_default_overwrite = getConfigListEntry(_("Recordings are controlled by channel by default"), config.plugins.vps.default_overwrite)
37                 
38                 self.list = []
39                 self.list.append(self.vps_enabled)
40                 self.list.append(self.vps_initial_time)
41                 self.list.append(self.vps_allow_overwrite)
42                 self.list.append(self.vps_allow_wakeup)
43                 self.list.append(self.vps_default)
44                 self.list.append(self.vps_default_overwrite)
45
46                 ConfigListScreen.__init__(self, self.list, session = session)
47                 self["config"].onSelectionChanged.append(self.updateHelp)
48
49                 # Initialize Buttons
50                 self["key_red"] = StaticText(_("Cancel"))
51                 self["key_green"] = StaticText(_("OK"))
52                 self["key_blue"] = StaticText(_("Information"))
53
54                 self["help"] = StaticText()
55
56                 # Define Actions
57                 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
58                         {
59                                 "cancel": self.keyCancel,
60                                 "save": self.keySave,
61                                 "blue": self.show_info,
62                         }
63                 )
64         
65         def updateHelp(self):
66                 cur = self["config"].getCurrent()
67                 if cur == self.vps_enabled:
68                         self["help"].text = _("This plugin can determine whether a programme begins earlier or lasts longer. The channel has to provide reliable data.")
69                 elif cur == self.vps_initial_time:
70                         self["help"].text = _("If possible, x minutes before a timer starts VPS-Plugin will control whether the programme begins earlier. (0 disables feature)")
71                 elif cur == self.vps_allow_overwrite:
72                         self["help"].text = _("If enabled, you can decide whether a timer should be controlled by channel (Running-Status). Programmed start and end time will be ignored.")
73                 elif cur == self.vps_default:
74                         self["help"].text = _("Enable VPS by default (new timers)")
75                 elif cur == self.vps_default_overwrite:
76                         self["help"].text = _("Enable \"Recording controlled by channel\" by default (new timers)")
77                 elif cur == self.vps_allow_wakeup:
78                         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.")
79
80         def show_info(self):
81                 VPS_show_info(self.session)
82         
83         def cancelConfirm(self, result):
84                 if not result:
85                         return
86
87                 for x in self["config"].list:
88                         x[1].cancel()
89
90                 self.close(self.session)
91
92         def keyCancel(self):
93                 if self["config"].isChanged():
94                         from Screens.MessageBox import MessageBox
95
96                         self.session.openWithCallback(
97                                 self.cancelConfirm,
98                                 MessageBox,
99                                 _("Really close without saving settings?")
100                         )
101                 else:
102                         self.close(self.session)
103
104         def keySave(self):
105                 for x in self["config"].list:
106                         x[1].save()
107
108                 self.close(self.session)
109
110
111
112 class VPS_Screen_Info(Screen):
113         skin = """<screen name="vpsInfo" position="center,center" size="550,400" title="VPS-Plugin Information">
114                 <widget name="text" position="10,10" size="540,390" font="Regular;22" />
115         </screen>"""
116         
117         def __init__(self, session):
118                 Screen.__init__(self, session)
119                 
120                 self["text"] = ScrollLabel(_("The 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 is definitely starting at the latest at the startTime. The recording may start earlier or lasts longer.\n\nIf you also enable \"Recording controlled by channel\", the recording will only start, when the channel flags the programme as running.\n\n\nSupported channels\n\nGermany:\n ARD, ZDF, Sky and DMAX\n\nAustria:\n ORF and Servus TV\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."))
121                 
122                 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions"], 
123                         {
124                                 "cancel": self.close,
125                                 "ok": self.close,
126                                 "up": self["text"].pageUp,
127                                 "down": self["text"].pageDown,
128                         }, -1)
129                 
130         
131 def VPS_show_info(session):
132         session.open(VPS_Screen_Info)
133