1 # for localized messages
5 from Screens.Screen import Screen
6 from Components.ConfigList import ConfigListScreen
7 from Screens.ChannelSelection import SimpleChannelSelection
8 from Screens.MessageBox import MessageBox
9 from Screens.ChoiceBox import ChoiceBox
12 from Screens.Setup import SetupSummary
15 from Components.ActionMap import ActionMap
16 from Components.Button import Button
19 from Components.config import getConfigListEntry, ConfigEnableDisable, \
20 ConfigYesNo, ConfigText, ConfigClock, ConfigNumber, ConfigSelection, \
24 from RecordTimer import AFTEREVENT
26 # Needed to convert our timestamp back and forth
27 from time import localtime, mktime
29 # Show ServiceName instead of ServiceReference
30 from ServiceReference import ServiceReference
32 # addAutotimerFromService
33 from enigma import eServiceCenter, iServiceInformation
35 # Default Record Directory
36 from Tools import Directories
41 ("2", _("Wednesday")),
46 ("weekend", _("Weekend")),
47 ("weekday", _("Weekday"))
50 class SimpleBouquetSelection(SimpleChannelSelection):
51 def __init__(self, session, title):
52 SimpleChannelSelection.__init__(self, session, title)
53 self.skinName = "SimpleChannelSelection"
55 def channelSelected(self): # just return selected service
56 ref = self.getCurrentSelection()
57 if (ref.flags & 7) == 7:
60 # We return the currently active path here
61 # Asking the user if this is what he wants might be better though
62 self.close(self.servicePath[-1])
64 class AutoTimerEditorBase():
65 """ Base Class for all Editors """
66 def __init__(self, timer, editingDefaults = False):
69 self.editingDefaults = editingDefaults
71 # See if we are filtering some strings
73 timer.getExcludedTitle(),
74 timer.getExcludedShort(),
75 timer.getExcludedDescription(),
76 timer.getExcludedDays()
79 timer.getIncludedTitle(),
80 timer.getIncludedShort(),
81 timer.getIncludedDescription(),
82 timer.getIncludedDays()
84 if len(self.excludes[0]) or len(self.excludes[1]) \
85 or len(self.excludes[2]) or len(self.excludes[3]) \
86 or len(self.includes[0]) or len(self.includes[1]) \
87 or len(self.includes[2]) or len(self.includes[3]):
90 self.filterSet = False
92 # See if services are restricted
93 self.services = timer.getServices()
94 self.bouquets = timer.getBouquets()
95 if len(self.services) or len(self.bouquets):
96 self.serviceRestriction = True
98 self.serviceRestriction = False
100 self.createSetup(timer)
102 def createSetup(self, timer):
104 self.name = ConfigText(default = timer.name, fixed_size = False)
107 self.match = ConfigText(default = timer.match, fixed_size = False)
108 self.match.setUseableChars('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789') # XXX: what exactly is useable? :-)
111 self.justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[int(timer.justplay)])
114 now = [x for x in localtime()]
115 if timer.hasTimespan():
117 now[3] = timer.timespan[0][0]
118 now[4] = timer.timespan[0][1]
120 now[3] = timer.timespan[1][0]
121 now[4] = timer.timespan[1][1]
131 self.timespan = ConfigEnableDisable(default = default)
132 self.timespanbegin = ConfigClock(default = begin)
133 self.timespanend = ConfigClock(default = end)
135 # Services have their own Screen
138 if timer.hasOffset():
140 begin = timer.getOffsetBegin()
141 end = timer.getOffsetEnd()
146 self.offset = ConfigEnableDisable(default = default)
147 self.offsetbegin = ConfigNumber(default = begin)
148 self.offsetend = ConfigNumber(default = end)
151 if timer.hasAfterEvent():
152 afterevent = { None: "default", AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby"}[timer.afterevent[0][0]]
154 afterevent = "default"
155 self.afterevent = ConfigSelection(choices = [("default", _("standard")), ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent)
157 # AfterEvent (Timespan)
158 if timer.hasAfterEvent() and timer.afterevent[0][1][0] is not None:
160 now[3] = timer.afterevent[0][1][0][0]
161 now[4] = timer.afterevent[0][1][0][1]
163 now[3] = timer.afterevent[0][1][1][0]
164 now[4] = timer.afterevent[0][1][1][1]
174 self.afterevent_timespan = ConfigEnableDisable(default = default)
175 self.afterevent_timespanbegin = ConfigClock(default = begin)
176 self.afterevent_timespanend = ConfigClock(default = end)
179 self.enabled = ConfigYesNo(default = timer.enabled)
182 if timer.hasDuration():
184 duration = timer.getDuration()
188 self.duration = ConfigEnableDisable(default = default)
189 self.durationlength = ConfigNumber(default = duration)
192 if timer.hasCounter():
193 default = timer.matchCount
196 self.counter = ConfigNumber(default = default)
197 self.counterLeft = ConfigNumber(default = timer.matchLeft)
198 selection = [("", _("Never")), ("%m", _("Monthly")), ("%U", _("Weekly (Sunday)")), ("%W", _("Weekly (Monday)"))]
199 if timer.getCounterFormatString() not in ["", "%m", "%U", "%W"]:
200 selection.append((timer.getCounterFormatString(), _("Custom (%s)") % (timer.getCounterFormatString())))
201 self.counterFormatString = ConfigSelection(selection, default = timer.getCounterFormatString())
203 # Avoid Duplicate Description
204 self.avoidDuplicateDescription = ConfigEnableDisable(default = timer.getAvoidDuplicateDescription())
207 if timer.hasDestination():
212 self.useDestination = ConfigYesNo(default = default)
214 default = timer.destination or Directories.resolveFilename(Directories.SCOPE_HDD)
217 choices = config.movielist.videodirs.value
219 print "config.movielist.videodirs.value not set"
221 if default not in choices:
222 choices.append(default)
223 self.destination = ConfigSelection(default = default, choices = choices)
225 def pathSelected(self, res):
227 if res not in self.destination.choices:
228 self.destination.choices.append(res)
229 self.destination.description[res] = res
230 self.destination.value = res
232 def chooseDestination(self):
233 from Screens.LocationBox import MovieLocationBox
235 self.session.openWithCallback(
238 _("Choose target folder"),
239 self.destination.value,
240 minFree = 100 # Same requirement as in Screens.TimerEntry
243 class AutoTimerEditor(Screen, ConfigListScreen, AutoTimerEditorBase):
246 skin = """<screen name="AutoTimerEdit" title="Edit AutoTimer" position="75,155" size="565,280">
247 <widget name="config" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
248 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
249 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
250 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
251 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
252 <widget name="key_red" position="0,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
253 <widget name="key_green" position="140,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
254 <widget name="key_yellow" position="280,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
255 <widget name="key_blue" position="420,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
258 def __init__(self, session, timer, editingDefaults = False):
259 Screen.__init__(self, session)
261 AutoTimerEditorBase.__init__(self, timer, editingDefaults)
264 self.setup_title = "AutoTimer Editor"
265 self.onChangedEntry = []
267 # We might need to change shown items, so add some notifiers
268 self.timespan.addNotifier(self.reloadList, initial_call = False)
269 self.offset.addNotifier(self.reloadList, initial_call = False)
270 self.duration.addNotifier(self.reloadList, initial_call = False)
271 self.afterevent.addNotifier(self.reloadList, initial_call = False)
272 self.afterevent_timespan.addNotifier(self.reloadList, initial_call = False)
273 self.counter.addNotifier(self.reloadList, initial_call = False)
274 self.useDestination.addNotifier(self.reloadList, initial_call = False)
278 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
281 self["key_red"] = Button(_("Cancel"))
282 self["key_green"] = Button(_("OK"))
283 self["key_yellow"] = Button()
284 self["key_blue"] = Button()
287 self.renameServiceButton()
288 self.renameFilterButton()
291 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
293 "cancel": self.cancel,
294 "save": self.maybeSave,
296 "yellow": self.editFilter,
297 "blue": self.editServices
304 def renameFilterButton(self):
306 self["key_yellow"].setText(_("Edit Filters"))
308 self["key_yellow"].setText(_("Add Filters"))
310 def renameServiceButton(self):
311 if self.serviceRestriction:
312 self["key_blue"].setText(_("Edit Services"))
314 self["key_blue"].setText(_("Add Services"))
317 for x in self.onChangedEntry:
323 def getCurrentEntry(self):
324 return self["config"].getCurrent()[0]
326 def getCurrentValue(self):
327 return str(self["config"].getCurrent()[1].getText())
329 def createSummary(self):
333 # First three entries are only showed when not editing defaults
335 if not self.editingDefaults:
337 getConfigListEntry(_("Enabled"), self.enabled),
338 getConfigListEntry(_("Description"), self.name),
339 getConfigListEntry(_("Match Title"), self.match),
343 getConfigListEntry(_("Timer Type"), self.justplay),
344 getConfigListEntry(_("Only match during Timespan"), self.timespan)
347 # Only allow editing timespan when it's enabled
348 if self.timespan.value:
350 getConfigListEntry(_("Begin of Timespan"), self.timespanbegin),
351 getConfigListEntry(_("End of Timespan"), self.timespanend)
354 self.list.append(getConfigListEntry(_("Custom offset"), self.offset))
356 # Only allow editing offsets when it's enabled
357 if self.offset.value:
359 getConfigListEntry(_("Offset before recording (in m)"), self.offsetbegin),
360 getConfigListEntry(_("Offset after recording (in m)"), self.offsetend)
363 self.list.append(getConfigListEntry(_("Set maximum Duration"), self.duration))
365 # Only allow editing maxduration when it's enabled
366 if self.duration.value:
367 self.list.append(getConfigListEntry(_("Maximum Duration (in m)"), self.durationlength))
369 self.list.append(getConfigListEntry(_("After event"), self.afterevent))
371 # Only allow setting afterevent timespan when afterevent is active
372 if self.afterevent.value != "default":
373 self.list.append(getConfigListEntry(_("Execute after Event during Timespan"), self.afterevent_timespan))
375 # Only allow editing timespan when it's enabled
376 if self.afterevent_timespan.value:
378 getConfigListEntry(_("Begin of after Event Timespan"), self.afterevent_timespanbegin),
379 getConfigListEntry(_("End of after Event Timespan"), self.afterevent_timespanend)
382 self.list.append(getConfigListEntry(_("Record a maximum of x times"), self.counter))
384 # Only allow setting matchLeft when counting hits
385 if self.counter.value:
386 if not self.editingDefaults:
387 self.list.append(getConfigListEntry(_("Ammount of recordings left"), self.counterLeft))
388 self.list.append(getConfigListEntry(_("Reset Count"), self.counterFormatString))
390 self.list.append(getConfigListEntry(_("Require Description to be unique"), self.avoidDuplicateDescription))
392 # We always add this option though its expert only in enigma2
393 self.list.append(getConfigListEntry(_("Use a custom location"), self.useDestination))
394 if self.useDestination.value:
395 self.list.append(getConfigListEntry(_("Custom Location"), self.destination))
397 def reloadList(self, value):
399 self["config"].setList(self.list)
401 def editFilter(self):
402 self.session.openWithCallback(
403 self.editFilterCallback,
404 AutoTimerFilterEditor,
410 def editFilterCallback(self, ret):
412 self.filterSet = ret[0]
413 self.excludes = ret[1]
414 self.includes = ret[2]
415 self.renameFilterButton()
417 def editServices(self):
418 self.session.openWithCallback(
419 self.editServicesCallback,
420 AutoTimerServiceEditor,
421 self.serviceRestriction,
426 def editServicesCallback(self, ret):
428 self.serviceRestriction = ret[0]
429 self.services = ret[1][0]
430 self.bouquets = ret[1][1]
431 self.renameServiceButton()
434 cur = self["config"].getCurrent()
436 if cur == self.destination:
437 self.chooseDestination()
439 ConfigListScreen.keyOK(self)
442 if self["config"].isChanged():
443 self.session.openWithCallback(
446 _("Really close without saving settings?")
451 def cancelConfirm(self, ret):
456 # Check if any match is set
457 if not self.match.value.strip():
460 _("The match attribute is mandatory."),
461 type = MessageBox.TYPE_ERROR,
464 # Check if we have a trailing whitespace
465 elif self.match.value[-1:] == " ":
466 self.session.openWithCallback(
469 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (self.match.value)
475 def saveCallback(self, ret):
478 self.match.value = self.match.value.rstrip()
480 # Don't to anything if MessageBox was canceled!
484 self.timer.match = self.match.value
487 self.timer.name = self.name.value.strip() or self.timer.match
490 self.timer.enabled = self.enabled.value
493 self.timer.justplay = self.justplay.value == "zap"
496 if self.timespan.value:
497 start = self.timespanbegin.value
498 end = self.timespanend.value
499 self.timer.timespan = (start, end)
501 self.timer.timespan = None
504 if self.serviceRestriction:
505 self.timer.services = self.services
506 self.timer.bouquets = self.bouquets
508 self.timer.services = None
509 self.timer.bouquets = None
512 if self.offset.value:
513 self.timer.offset = (self.offsetbegin.value*60, self.offsetend.value*60)
515 self.timer.offset = None
518 if self.afterevent.value == "default":
519 self.timer.afterevent = []
521 afterevent = {"nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY}[self.afterevent.value]
522 # AfterEvent Timespan
523 if self.afterevent_timespan.value:
524 start = self.afterevent_timespanbegin.value
525 end = self.afterevent_timespanend.value
526 self.timer.afterevent = [(afterevent, (start, end))]
528 self.timer.afterevent = [(afterevent, None)]
531 if self.duration.value:
532 self.timer.maxduration = self.durationlength.value*60
534 self.timer.maxduration = None
538 self.timer.exclude = self.excludes
539 self.timer.include = self.includes
541 self.timer.exclude = None
542 self.timer.include = None
545 if self.counter.value:
546 self.timer.matchCount = self.counter.value
547 if self.counterLeft.value <= self.counter.value:
548 self.timer.matchLeft = self.counterLeft.value
550 self.timer.matchLeft = self.counter.value
551 if self.counterFormatString.value:
552 self.timer.matchFormatString = self.counterFormatString.value
554 self.timer.matchFormatString = ''
556 self.timer.matchCount = 0
557 self.timer.matchLeft = 0
558 self.timer.matchFormatString = ''
560 self.timer.avoidDuplicateDescription = self.avoidDuplicateDescription.value
562 if self.useDestination.value:
563 self.timer.destination = self.destination.value
565 self.timer.destination = None
568 self.close(self.timer)
570 class AutoTimerFilterEditor(Screen, ConfigListScreen):
571 """Edit AutoTimer Filter"""
573 skin = """<screen name="AutoFilterEditor" title="Edit AutoTimer Filters" position="75,150" size="565,245">
574 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
575 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
576 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
577 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
578 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
579 <widget name="key_red" position="5,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
580 <widget name="key_green" position="145,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
581 <widget name="key_yellow" position="285,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
582 <widget name="key_blue" position="425,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
585 def __init__(self, session, filterset, excludes, includes):
586 Screen.__init__(self, session)
589 self.setup_title = "AutoTimer Filters"
590 self.onChangedEntry = []
592 self.typeSelection = ConfigSelection(choices = [("title", _("in Title")), ("short", _("in Shortdescription")), ("desc", _("in Description")), ("day", _("on Weekday"))])
593 self.typeSelection.addNotifier(self.refresh, initial_call = False)
595 self.enabled = ConfigEnableDisable(default = filterset)
597 self.excludes = excludes
598 self.includes = includes
602 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
605 self["key_red"] = Button(_("Cancel"))
606 self["key_green"] = Button(_("Save"))
607 self["key_yellow"] = Button(_("delete"))
608 self["key_blue"] = Button(_("New"))
611 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
613 "cancel": self.cancel,
615 "yellow": self.remove,
624 for x in self.onChangedEntry:
630 def getCurrentEntry(self):
631 return self["config"].getCurrent()[0]
633 def getCurrentValue(self):
634 return str(self["config"].getCurrent()[1].getText())
636 def createSummary(self):
639 def saveCurrent(self):
640 del self.excludes[self.idx][:]
641 del self.includes[self.idx][:]
643 # Warning, accessing a ConfigListEntry directly might be considered evil!
646 for item in self["config"].getList():
648 # Skip empty entries (and those which are no filters)
649 if item[1].value == "" or idx < 2:
651 elif idx < self.lenExcludes:
652 self.excludes[self.idx].append(item[1].value.encode("UTF-8"))
654 self.includes[self.idx].append(item[1].value.encode("UTF-8"))
656 def refresh(self, value):
660 self["config"].setList(self.list)
662 def reloadList(self):
664 getConfigListEntry(_("Enable Filtering"), self.enabled),
665 getConfigListEntry(_("Filter"), self.typeSelection)
668 if self.typeSelection.value == "day":
671 # Weekdays are presented as ConfigSelection
673 getConfigListEntry(_("Exclude"), ConfigSelection(choices = weekdays, default = x))
674 for x in self.excludes[3]
676 self.lenExcludes = len(self.list)
678 getConfigListEntry(_("Include"), ConfigSelection(choices = weekdays, default = x))
679 for x in self.includes[3]
682 elif self.typeSelection.value == "title":
684 elif self.typeSelection.value == "short":
686 else: # self.typeSelection.value == "desc":
690 getConfigListEntry(_("Exclude"), ConfigText(default = x, fixed_size = False))
691 for x in self.excludes[self.idx]
693 self.lenExcludes = len(self.list)
695 getConfigListEntry(_("Include"), ConfigText(default = x, fixed_size = False))
696 for x in self.includes[self.idx]
700 idx = self["config"].getCurrentIndex()
702 if idx < self.lenExcludes:
703 self.lenExcludes -= 1
705 list = self["config"].getList()
706 list.remove(self["config"].getCurrent())
707 self["config"].setList(list)
710 self.session.openWithCallback(
713 _("Select type of Filter"),
720 def typeSelected(self, ret):
722 list = self["config"].getList()
725 pos = self.lenExcludes
726 self.lenExcludes += 1
732 if self.typeSelection.value == "day":
733 entry = getConfigListEntry(text, ConfigSelection(choices = weekdays))
735 entry = getConfigListEntry(text, ConfigText(fixed_size = False))
737 list.insert(pos, entry)
738 self["config"].setList(list)
741 if self["config"].isChanged():
742 self.session.openWithCallback(
745 _("Really close without saving settings?")
750 def cancelConfirm(self, ret):
763 class AutoTimerServiceEditor(Screen, ConfigListScreen):
764 """Edit allowed Services of a AutoTimer"""
766 skin = """<screen name="AutoTimerServiceEditor" title="Edit AutoTimer Services" position="75,150" size="565,245">
767 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
768 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
769 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
770 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
771 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
772 <widget name="key_red" position="5,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
773 <widget name="key_green" position="145,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
774 <widget name="key_yellow" position="285,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
775 <widget name="key_blue" position="425,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
778 def __init__(self, session, servicerestriction, servicelist, bouquetlist):
779 Screen.__init__(self, session)
782 self.setup_title = "AutoTimer Services"
783 self.onChangedEntry = []
790 self.enabled = ConfigEnableDisable(default = servicerestriction)
791 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
792 self.typeSelection.addNotifier(self.refresh, initial_call = False)
796 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
799 self["key_red"] = Button(_("Cancel"))
800 self["key_green"] = Button(_("OK"))
801 self["key_yellow"] = Button(_("delete"))
802 self["key_blue"] = Button(_("New"))
805 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
807 "cancel": self.cancel,
809 "yellow": self.remove,
818 def saveCurrent(self):
819 del self.services[self.idx][:]
821 # Warning, accessing a ConfigListEntry directly might be considered evil!
823 myl = self["config"].getList()
827 self.services[self.idx].append(item[1].value)
829 def refresh(self, value):
833 self["config"].setList(self.list)
835 def reloadList(self):
837 getConfigListEntry(_("Enable Service Restriction"), self.enabled),
838 getConfigListEntry(_("Editing"), self.typeSelection)
841 if self.typeSelection.value == "channels":
843 else: # self.typeSelection.value == "bouquets":
847 getConfigListEntry(_("Record on"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
848 for x in self.services[self.idx]
852 for x in self.onChangedEntry:
858 def getCurrentEntry(self):
859 return self["config"].getCurrent()[0]
861 def getCurrentValue(self):
862 return str(self["config"].getCurrent()[1].getText())
864 def createSummary(self):
868 if self["config"].getCurrentIndex() != 0:
869 list = self["config"].getList()
870 list.remove(self["config"].getCurrent())
871 self["config"].setList(list)
874 if self.typeSelection.value == "channels":
875 self.session.openWithCallback(
876 self.finishedServiceSelection,
877 SimpleChannelSelection,
878 _("Select channel to record on")
880 else: # self.typeSelection.value == "bouquets":
881 self.session.openWithCallback(
882 self.finishedServiceSelection,
883 SimpleBouquetSelection,
884 _("Select bouquet to record on")
887 def finishedServiceSelection(self, *args):
889 list = self["config"].getList()
890 sname = args[0].toString()
892 if self.typeSelection.value == "channels":
893 # strip all after last : when adding a channel
894 pos = sname.rfind(':')
896 sname = sname[:pos+1]
898 list.append(getConfigListEntry(_("Record on"), ConfigSelection(choices = [(sname, ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])))
899 self["config"].setList(list)
902 if self["config"].isChanged():
903 self.session.openWithCallback(
906 _("Really close without saving settings?")
911 def cancelConfirm(self, ret):
923 def addAutotimerFromEvent(session, evt = None, service = None):
924 from AutoTimerComponent import AutoTimerComponent
925 from AutoTimerImporter import AutoTimerImporter
926 from plugin import autotimer
928 # Create instance if needed
929 if autotimer is None:
930 from AutoTimer import AutoTimer
931 autotimer = AutoTimer()
933 match = evt and evt.getEventName() or ""
934 name = match or "New AutoTimer"
936 if service is not None:
937 service = str(service)
938 # strip all after last :
939 pos = service.rfind(':')
941 service = service[:pos+1]
943 sref = ServiceReference(service)
945 # timespan defaults to +- 1h
946 begin = evt.getBeginTime()-3600
947 end = begin + evt.getDuration()+7200
951 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-)
953 session.openWithCallback(
957 autotimer.getUniqueId(), # Id
962 match, # Proposed Match
963 begin, # Proposed Begin
965 None, # Proposed Disabled
966 sref, # Proposed ServiceReference
967 None, # Proposed afterEvent
968 None, # Proposed justplay
969 None # Proposed dirname, can we get anything useful here?
972 def addAutotimerFromService(session, service = None):
973 from AutoTimerComponent import AutoTimerComponent
974 from AutoTimerImporter import AutoTimerImporter
975 from plugin import autotimer
977 # Create instance if needed
978 if autotimer is None:
979 from AutoTimer import AutoTimer
980 autotimer = AutoTimer()
982 serviceHandler = eServiceCenter.getInstance()
983 info = serviceHandler.info(service)
985 match = info and info.getName(service) or ""
986 name = match or "New AutoTimer"
987 sref = info and info.getInfoString(service, iServiceInformation.sServiceref)
989 # strip all after last :
990 pos = sref.rfind(':')
994 sref = ServiceReference(sref)
996 begin = info.getInfo(service, iServiceInformation.sTimeCreate)
997 end = begin + info.getLength(service)
1001 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-)
1003 session.openWithCallback(
1007 autotimer.getUniqueId(), # Id
1012 match, # Proposed Match
1013 begin, # Proposed Begin
1015 None, # Proposed Disabled
1016 sref, # Proposed ServiceReference
1017 None, # Proposed afterEvent
1018 None, # Proposed justplay
1019 None # Proposed dirname, can we get anything useful here?
1022 def importerCallback(ret):
1026 session.openWithCallback(
1032 # Remove instance if not running in background
1033 if not config.plugins.autotimer.autopoll.value:
1034 from plugin import autotimer
1038 def editorCallback(ret):
1040 from plugin import autotimer
1042 # Create instance if needed (should have been created by addAutotimerFrom* above though)
1043 if autotimer is None:
1044 from AutoTimer import AutoTimer
1045 autotimer = AutoTimer()
1049 # Remove instance if not running in background
1050 if not config.plugins.autotimer.autopoll.value:
1051 # Save xml (as long as we added something)
1052 ret and autotimer and autotimer.writeXml()