2 from Screens.Screen import Screen
3 from Components.ConfigList import ConfigListScreen
4 from Screens.ChannelSelection import SimpleChannelSelection
5 from Screens.MessageBox import MessageBox
6 from Screens.ChoiceBox import ChoiceBox
9 from Screens.Setup import SetupSummary
12 from Components.ActionMap import ActionMap
13 from Components.Button import Button
16 from Components.config import getConfigListEntry, ConfigEnableDisable, \
17 ConfigYesNo, ConfigText, ConfigClock, ConfigNumber, ConfigSelection
20 from RecordTimer import AFTEREVENT
22 # Needed to convert our timestamp back and forth
23 from time import localtime, mktime
25 # Show ServiceName instead of ServiceReference
26 from ServiceReference import ServiceReference
31 ("2", _("Wednesday")),
36 ("weekend", _("Weekend")),
37 ("weekday", _("Weekday"))
40 class SimpleBouquetSelection(SimpleChannelSelection):
41 def __init__(self, session, title):
42 SimpleChannelSelection.__init__(self, session, title)
43 self.skinName = "SimpleChannelSelection"
45 def channelSelected(self): # just return selected service
46 ref = self.getCurrentSelection()
47 if (ref.flags & 7) == 7:
50 # We return the currently active path here
51 # Asking the user if this is what he wants might be better though
52 self.close(self.servicePath[-1])
54 class AutoTimerEditor(Screen, ConfigListScreen):
57 skin = """<screen name="AutoTimerEdit" title="Edit AutoTimer" position="75,155" size="565,280">
58 <widget name="config" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
59 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
60 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
61 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
62 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
63 <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" />
64 <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" />
65 <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" />
66 <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" />
69 def __init__(self, session, timer):
70 Screen.__init__(self, session)
76 self.setup_title = "AutoTimer Editor"
77 self.onChangedEntry = []
79 # See if we are filtering some strings
81 timer.getExcludedTitle(),
82 timer.getExcludedShort(),
83 timer.getExcludedDescription(),
84 timer.getExcludedDays()
87 timer.getIncludedTitle(),
88 timer.getIncludedShort(),
89 timer.getIncludedDescription(),
90 timer.getIncludedDays()
92 if len(self.excludes[0]) or len(self.excludes[1]) \
93 or len(self.excludes[2]) or len(self.excludes[3]) \
94 or len(self.includes[0]) or len(self.includes[1]) \
95 or len(self.includes[2]) or len(self.includes[3]):
98 self.filterSet = False
100 # See if services are restricted
101 self.services = timer.getServices()
102 self.bouquets = timer.getBouquets()
103 if len(self.services) or len(self.bouquets):
104 self.serviceRestriction = True
106 self.serviceRestriction = False
108 self.createSetup(timer)
110 # We might need to change shown items, so add some notifiers
111 self.timespan.addNotifier(self.reloadList, initial_call = False)
112 self.offset.addNotifier(self.reloadList, initial_call = False)
113 self.duration.addNotifier(self.reloadList, initial_call = False)
114 self.afterevent.addNotifier(self.reloadList, initial_call = False)
115 self.afterevent_timespan.addNotifier(self.reloadList, initial_call = False)
116 self.counter.addNotifier(self.reloadList, initial_call = False)
120 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
123 self["key_red"] = Button(_("Cancel"))
124 self["key_green"] = Button(_("OK"))
125 self["key_yellow"] = Button()
126 self["key_blue"] = Button()
129 self.renameServiceButton()
130 self.renameFilterButton()
133 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
135 "cancel": self.cancel,
136 "save": self.maybeSave,
138 "yellow": self.editFilter,
139 "blue": self.editServices
146 def renameFilterButton(self):
148 self["key_yellow"].setText(_("Edit Filters"))
150 self["key_yellow"].setText(_("Add Filters"))
152 def renameServiceButton(self):
153 if self.serviceRestriction:
154 self["key_blue"].setText(_("Edit Services"))
156 self["key_blue"].setText(_("Add Services"))
159 for x in self.onChangedEntry:
165 def getCurrentEntry(self):
166 return self["config"].getCurrent()[0]
168 def getCurrentValue(self):
169 return str(self["config"].getCurrent()[1].getText())
171 def createSummary(self):
174 def createSetup(self, timer):
176 self.name = ConfigText(default = timer.name, fixed_size = False)
179 self.match = ConfigText(default = timer.match, fixed_size = False)
180 self.match.setUseableChars('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789') # XXX: what exactly is useable? :-)
183 self.justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[int(timer.justplay)])
186 now = [x for x in localtime()]
187 if timer.hasTimespan():
189 now[3] = timer.timespan[0][0]
190 now[4] = timer.timespan[0][1]
192 now[3] = timer.timespan[1][0]
193 now[4] = timer.timespan[1][1]
203 self.timespan = ConfigEnableDisable(default = default)
204 self.timespanbegin = ConfigClock(default = begin)
205 self.timespanend = ConfigClock(default = end)
207 # Services have their own Screen
210 if timer.hasOffset():
212 begin = timer.getOffsetBegin()
213 end = timer.getOffsetEnd()
218 self.offset = ConfigEnableDisable(default = default)
219 self.offsetbegin = ConfigNumber(default = begin)
220 self.offsetend = ConfigNumber(default = end)
223 if timer.hasAfterEvent():
224 afterevent = { None: "default", AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby"}[timer.afterevent[0][0]]
226 afterevent = "default"
227 self.afterevent = ConfigSelection(choices = [("default", _("standard")), ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent)
229 # AfterEvent (Timespan)
230 if timer.hasAfterEvent() and timer.afterevent[0][1][0] is not None:
232 now[3] = timer.afterevent[0][1][0][0]
233 now[4] = timer.afterevent[0][1][0][1]
235 now[3] = timer.afterevent[0][1][1][0]
236 now[4] = timer.afterevent[0][1][1][1]
246 self.afterevent_timespan = ConfigEnableDisable(default = default)
247 self.afterevent_timespanbegin = ConfigClock(default = begin)
248 self.afterevent_timespanend = ConfigClock(default = end)
251 self.enabled = ConfigYesNo(default = timer.enabled)
254 if timer.hasDuration():
256 duration = timer.getDuration()
260 self.duration = ConfigEnableDisable(default = default)
261 self.durationlength = ConfigNumber(default = duration)
264 if timer.hasCounter():
265 default = timer.matchCount
268 self.counter = ConfigNumber(default = default)
269 self.counterLeft = ConfigNumber(default = timer.matchLeft)
270 selection = [("", _("Never")), ("%m", _("Monthly")), ("%U", _("Weekly (Sunday)")), ("%W", _("Weekly (Monday)"))]
271 if timer.getCounterFormatString() not in ["", "%m", "%U", "%W"]:
272 selection.append((timer.getCounterFormatString(), _("Custom (%s)") % (timer.getCounterFormatString())))
273 self.counterFormatString = ConfigSelection(selection, default = timer.getCounterFormatString())
275 # Avoid Duplicate Description
276 self.avoidDuplicateDescription = ConfigEnableDisable(default = timer.getAvoidDuplicateDescription())
279 self.destination = ConfigSelection(choices = [timer.destination or "/hdd/movie/"])
282 # First four entries are always shown
284 getConfigListEntry(_("Enabled"), self.enabled),
285 getConfigListEntry(_("Description"), self.name),
286 getConfigListEntry(_("Match Title"), self.match),
287 getConfigListEntry(_("Timer Type"), self.justplay),
288 getConfigListEntry(_("Only match during Timespan"), self.timespan)
291 # Only allow editing timespan when it's enabled
292 if self.timespan.value:
294 getConfigListEntry(_("Begin of Timespan"), self.timespanbegin),
295 getConfigListEntry(_("End of Timespan"), self.timespanend)
298 self.list.append(getConfigListEntry(_("Custom offset"), self.offset))
300 # Only allow editing offsets when it's enabled
301 if self.offset.value:
303 getConfigListEntry(_("Offset before recording (in m)"), self.offsetbegin),
304 getConfigListEntry(_("Offset after recording (in m)"), self.offsetend)
307 self.list.append(getConfigListEntry(_("Set maximum Duration"), self.duration))
309 # Only allow editing maxduration when it's enabled
310 if self.duration.value:
312 getConfigListEntry(_("Maximum Duration (in m)"), self.durationlength)
315 self.list.append(getConfigListEntry(_("After event"), self.afterevent))
317 # Only allow setting afterevent timespan when afterevent is active
318 if self.afterevent.value != "default":
319 self.list.append(getConfigListEntry(_("Execute after Event during Timespan"), self.afterevent_timespan))
321 # Only allow editing timespan when it's enabled
322 if self.afterevent_timespan.value:
324 getConfigListEntry(_("Begin of after Event Timespan"), self.afterevent_timespanbegin),
325 getConfigListEntry(_("End of after Event Timespan"), self.afterevent_timespanend)
328 self.list.append(getConfigListEntry(_("Record a maximum of x times"), self.counter))
330 # Only allow setting matchLeft when counting hits
331 if self.counter.value:
332 self.list.append(getConfigListEntry(_("Ammount of recordings left"), self.counterLeft))
333 self.list.append(getConfigListEntry(_("Reset Count"), self.counterFormatString))
335 self.list.append(getConfigListEntry(_("Require Description to be unique"), self.avoidDuplicateDescription))
337 # We always add this option though its actually expert only
338 self.list.append(getConfigListEntry(_("Custom Location"), self.destination))
340 def reloadList(self, value):
342 self["config"].setList(self.list)
344 def editFilter(self):
345 self.session.openWithCallback(
346 self.editFilterCallback,
347 AutoTimerFilterEditor,
353 def editFilterCallback(self, ret):
355 self.filterSet = ret[0]
356 self.excludes = ret[1]
357 self.includes = ret[2]
358 self.renameFilterButton()
360 def editServices(self):
361 self.session.openWithCallback(
362 self.editServicesCallback,
363 AutoTimerServiceEditor,
364 self.serviceRestriction,
369 def editServicesCallback(self, ret):
371 self.serviceRestriction = ret[0]
372 self.services = ret[1][0]
373 self.bouquets = ret[1][1]
374 self.renameServiceButton()
377 cur = self["config"].getCurrent()
379 if cur == self.destination:
380 from Screens.LocationBox import LocationBox
382 self.session.openWithCallback(
385 text = _("Choose target folder"),
387 currDir = self.destination.value
390 ConfigListScreen.keyOK(self)
392 def pathSelected(self, res):
394 self.destination.choices.append(res)
395 self.destination.description[res] = res
396 self.destination.value = res
399 if self["config"].isChanged():
400 self.session.openWithCallback(
403 _("Really close without saving settings?")
408 def cancelConfirm(self, ret):
413 # Check if we have a trailing whitespace
414 if self.match.value[-1:] == " ":
415 self.session.openWithCallback(
418 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (self.match.value)
424 def saveCallback(self, ret):
427 self.match.value = self.match.value.rstrip()
429 # Don't to anything if MessageBox was canceled!
433 self.timer.match = self.match.value
436 self.timer.name = self.name.value or self.timer.match
439 self.timer.enabled = self.enabled.value
442 self.timer.justplay = self.justplay.value == "zap"
445 if self.timespan.value:
446 start = self.timespanbegin.value
447 end = self.timespanend.value
448 self.timer.timespan = (start, end)
450 self.timer.timespan = None
453 if self.serviceRestriction:
454 self.timer.services = self.services
455 self.timer.bouquets = self.bouquets
457 self.timer.services = None
458 self.timer.bouquets = None
461 if self.offset.value:
462 self.timer.offset = (self.offsetbegin.value*60, self.offsetend.value*60)
464 self.timer.offset = None
467 if self.afterevent.value == "default":
468 self.timer.afterevent = []
470 afterevent = {"nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY}[self.afterevent.value]
471 # AfterEvent Timespan
472 if self.afterevent_timespan.value:
473 start = self.afterevent_timespanbegin.value
474 end = self.afterevent_timespanend.value
475 self.timer.afterevent = [(afterevent, (start, end))]
477 self.timer.afterevent = [(afterevent, None)]
480 if self.duration.value:
481 self.timer.maxduration = self.durationlength.value*60
483 self.timer.maxduration = None
487 self.timer.exclude = self.excludes
488 self.timer.include = self.includes
490 self.timer.exclude = None
491 self.timer.include = None
494 if self.counter.value:
495 self.timer.matchCount = self.counter.value
496 if self.counterLeft.value <= self.counter.value:
497 self.timer.matchLeft = self.counterLeft.value
499 self.timer.matchLeft = self.counter.value
500 if self.counterFormatString.value:
501 self.timer.matchFormatString = self.counterFormatString.value
503 self.timer.matchFormatString = ''
505 self.timer.matchCount = 0
506 self.timer.matchLeft = 0
507 self.timer.matchFormatString = ''
509 self.timer.avoidDuplicateDescription = self.avoidDuplicateDescription.value
511 if self.destination.value == "/hdd/movie/":
512 self.timer.destination = None
514 self.timer.destination = self.destination.value
517 self.close(self.timer)
519 class AutoTimerFilterEditor(Screen, ConfigListScreen):
520 """Edit AutoTimer Filter"""
522 skin = """<screen name="AutoFilterEditor" title="Edit AutoTimer Filters" position="75,150" size="565,245">
523 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
524 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
525 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
526 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
527 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
528 <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" />
529 <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" />
530 <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" />
531 <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" />
534 def __init__(self, session, filterset, excludes, includes):
535 Screen.__init__(self, session)
538 self.setup_title = "AutoTimer Filters"
539 self.onChangedEntry = []
541 self.typeSelection = ConfigSelection(choices = [("title", _("in Title")), ("short", _("in Shortdescription")), ("desc", _("in Description")), ("day", _("on Weekday"))])
542 self.typeSelection.addNotifier(self.refresh, initial_call = False)
544 self.enabled = ConfigEnableDisable(default = filterset)
546 self.excludes = excludes
547 self.includes = includes
551 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
554 self["key_red"] = Button(_("Cancel"))
555 self["key_green"] = Button(_("Save"))
556 self["key_yellow"] = Button(_("delete"))
557 self["key_blue"] = Button(_("New"))
560 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
562 "cancel": self.cancel,
564 "yellow": self.remove,
573 for x in self.onChangedEntry:
579 def getCurrentEntry(self):
580 return self["config"].getCurrent()[0]
582 def getCurrentValue(self):
583 return str(self["config"].getCurrent()[1].getText())
585 def createSummary(self):
588 def saveCurrent(self):
589 del self.excludes[self.idx][:]
590 del self.includes[self.idx][:]
592 # Warning, accessing a ConfigListEntry directly might be considered evil!
595 for item in self["config"].getList():
597 # Skip empty entries (and those which are no filters)
598 if item[1].value == "" or idx < 2:
600 elif idx < self.lenExcludes:
601 self.excludes[self.idx].append(item[1].value.encode("UTF-8"))
603 self.includes[self.idx].append(item[1].value.encode("UTF-8"))
605 def refresh(self, value):
609 self["config"].setList(self.list)
611 def reloadList(self):
613 getConfigListEntry(_("Enable Filtering"), self.enabled),
614 getConfigListEntry(_("Filter"), self.typeSelection)
617 if self.typeSelection.value == "day":
620 # Weekdays are presented as ConfigSelection
622 getConfigListEntry(_("Exclude"), ConfigSelection(choices = weekdays, default = x))
623 for x in self.excludes[3]
625 self.lenExcludes = len(self.list)
627 getConfigListEntry(_("Include"), ConfigSelection(choices = weekdays, default = x))
628 for x in self.includes[3]
631 elif self.typeSelection.value == "title":
633 elif self.typeSelection.value == "short":
635 else: # self.typeSelection.value == "desc":
639 getConfigListEntry(_("Exclude"), ConfigText(default = x, fixed_size = False))
640 for x in self.excludes[self.idx]
642 self.lenExcludes = len(self.list)
644 getConfigListEntry(_("Include"), ConfigText(default = x, fixed_size = False))
645 for x in self.includes[self.idx]
649 idx = self["config"].getCurrentIndex()
651 if idx < self.lenExcludes:
652 self.lenExcludes -= 1
654 list = self["config"].getList()
655 list.remove(self["config"].getCurrent())
656 self["config"].setList(list)
659 self.session.openWithCallback(
662 _("Select type of Filter"),
669 def typeSelected(self, ret):
671 list = self["config"].getList()
674 pos = self.lenExcludes
675 self.lenExcludes += 1
681 if self.typeSelection.value == "day":
682 entry = getConfigListEntry(text, ConfigSelection(choices = weekdays))
684 entry = getConfigListEntry(text, ConfigText(fixed_size = False))
686 list.insert(pos, entry)
687 self["config"].setList(list)
690 if self["config"].isChanged():
691 self.session.openWithCallback(
694 _("Really close without saving settings?")
699 def cancelConfirm(self, ret):
712 class AutoTimerServiceEditor(Screen, ConfigListScreen):
713 """Edit allowed Services of a AutoTimer"""
715 skin = """<screen name="AutoTimerServiceEditor" title="Edit AutoTimer Services" position="75,150" size="565,245">
716 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
717 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
718 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
719 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
720 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
721 <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" />
722 <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" />
723 <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" />
724 <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" />
727 def __init__(self, session, servicerestriction, servicelist, bouquetlist):
728 Screen.__init__(self, session)
731 self.setup_title = "AutoTimer Services"
732 self.onChangedEntry = []
739 self.enabled = ConfigEnableDisable(default = servicerestriction)
740 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
741 self.typeSelection.addNotifier(self.refresh, initial_call = False)
745 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
748 self["key_red"] = Button(_("Cancel"))
749 self["key_green"] = Button(_("OK"))
750 self["key_yellow"] = Button(_("delete"))
751 self["key_blue"] = Button(_("New"))
754 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
756 "cancel": self.cancel,
758 "yellow": self.remove,
767 def saveCurrent(self):
768 del self.services[self.idx][:]
770 # Warning, accessing a ConfigListEntry directly might be considered evil!
772 myl = self["config"].getList()
776 self.services[self.idx].append(item[1].value)
778 def refresh(self, value):
782 self["config"].setList(self.list)
784 def reloadList(self):
786 getConfigListEntry(_("Enable Service Restriction"), self.enabled),
787 getConfigListEntry(_("Editing"), self.typeSelection)
790 if self.typeSelection.value == "channels":
792 else: # self.typeSelection.value == "bouquets":
796 getConfigListEntry(_("Record on"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
797 for x in self.services[self.idx]
801 for x in self.onChangedEntry:
807 def getCurrentEntry(self):
808 return self["config"].getCurrent()[0]
810 def getCurrentValue(self):
811 return str(self["config"].getCurrent()[1].getText())
813 def createSummary(self):
817 if self["config"].getCurrentIndex() != 0:
818 list = self["config"].getList()
819 list.remove(self["config"].getCurrent())
820 self["config"].setList(list)
823 if self.typeSelection.value == "channels":
824 self.session.openWithCallback(
825 self.finishedServiceSelection,
826 SimpleChannelSelection,
827 _("Select channel to record on")
829 else: # self.typeSelection.value == "bouquets":
830 self.session.openWithCallback(
831 self.finishedServiceSelection,
832 SimpleBouquetSelection,
833 _("Select bouquet to record on")
836 def finishedServiceSelection(self, *args):
838 list = self["config"].getList()
839 sname = args[0].toString()
841 if self.typeSelection.value == "channels":
842 # strip all after last : when adding a channel
843 pos = sname.rfind(':')
845 sname = sname[:pos+1]
847 list.append(getConfigListEntry(_("Record on"), ConfigSelection(choices = [(sname, ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])))
848 self["config"].setList(list)
851 if self["config"].isChanged():
852 self.session.openWithCallback(
855 _("Really close without saving settings?")
860 def cancelConfirm(self, ret):
872 def addAutotimerFromEvent(session, evt = None, service = None):
873 from AutoTimerComponent import AutoTimerComponent
875 name = evt and evt.getEventName() or "New AutoTimer"
876 match = evt and evt.getEventName() or ""
878 if service is not None:
879 service = str(service)
880 # strip all after last :
881 pos = service.rfind(':')
883 service = service[:pos+1]
885 servicelist.append(service)
887 begin = evt.getBeginTime()
888 end = begin + evt.getDuration()
889 timetuple = (begin-3600, end+3600) # timespan defaults to +- 1h
893 session.openWithCallback(
897 self.autotimer.getUniqueId(), # Id
901 timespan = timetuple,
902 services = servicelist
906 def addCallback(ret):
908 from plugin import autotimer
910 # Create instance if needed
911 if autotimer is None:
912 from AutoTimer import AutoTimer
913 autotimer = AutoTimer()
917 # Remove instance if not running in background
918 if not config.plugins.autotimer.autopoll.value: