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