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, \
21 from RecordTimer import AFTEREVENT
23 # Needed to convert our timestamp back and forth
24 from time import localtime, mktime
26 # Show ServiceName instead of ServiceReference
27 from ServiceReference import ServiceReference
29 # addAutotimerFromService
30 from enigma import eServiceCenter, iServiceInformation
32 # Default Record Directory
33 from Tools import Directories
38 ("2", _("Wednesday")),
43 ("weekend", _("Weekend")),
44 ("weekday", _("Weekday"))
47 class SimpleBouquetSelection(SimpleChannelSelection):
48 def __init__(self, session, title):
49 SimpleChannelSelection.__init__(self, session, title)
50 self.skinName = "SimpleChannelSelection"
52 def channelSelected(self): # just return selected service
53 ref = self.getCurrentSelection()
54 if (ref.flags & 7) == 7:
57 # We return the currently active path here
58 # Asking the user if this is what he wants might be better though
59 self.close(self.servicePath[-1])
61 class AutoTimerEditor(Screen, ConfigListScreen):
64 skin = """<screen name="AutoTimerEdit" title="Edit AutoTimer" position="75,155" size="565,280">
65 <widget name="config" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
66 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
67 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
68 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
69 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
70 <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" />
71 <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" />
72 <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" />
73 <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" />
76 def __init__(self, session, timer, editingDefaults = False):
77 Screen.__init__(self, session)
81 self.editingDefaults = editingDefaults
84 self.setup_title = "AutoTimer Editor"
85 self.onChangedEntry = []
87 # See if we are filtering some strings
89 timer.getExcludedTitle(),
90 timer.getExcludedShort(),
91 timer.getExcludedDescription(),
92 timer.getExcludedDays()
95 timer.getIncludedTitle(),
96 timer.getIncludedShort(),
97 timer.getIncludedDescription(),
98 timer.getIncludedDays()
100 if len(self.excludes[0]) or len(self.excludes[1]) \
101 or len(self.excludes[2]) or len(self.excludes[3]) \
102 or len(self.includes[0]) or len(self.includes[1]) \
103 or len(self.includes[2]) or len(self.includes[3]):
104 self.filterSet = True
106 self.filterSet = False
108 # See if services are restricted
109 self.services = timer.getServices()
110 self.bouquets = timer.getBouquets()
111 if len(self.services) or len(self.bouquets):
112 self.serviceRestriction = True
114 self.serviceRestriction = False
116 self.createSetup(timer)
118 # We might need to change shown items, so add some notifiers
119 self.timespan.addNotifier(self.reloadList, initial_call = False)
120 self.offset.addNotifier(self.reloadList, initial_call = False)
121 self.duration.addNotifier(self.reloadList, initial_call = False)
122 self.afterevent.addNotifier(self.reloadList, initial_call = False)
123 self.afterevent_timespan.addNotifier(self.reloadList, initial_call = False)
124 self.counter.addNotifier(self.reloadList, initial_call = False)
125 self.useDestination.addNotifier(self.reloadList, initial_call = False)
129 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
132 self["key_red"] = Button(_("Cancel"))
133 self["key_green"] = Button(_("OK"))
134 self["key_yellow"] = Button()
135 self["key_blue"] = Button()
138 self.renameServiceButton()
139 self.renameFilterButton()
142 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
144 "cancel": self.cancel,
145 "save": self.maybeSave,
147 "yellow": self.editFilter,
148 "blue": self.editServices
155 def renameFilterButton(self):
157 self["key_yellow"].setText(_("Edit Filters"))
159 self["key_yellow"].setText(_("Add Filters"))
161 def renameServiceButton(self):
162 if self.serviceRestriction:
163 self["key_blue"].setText(_("Edit Services"))
165 self["key_blue"].setText(_("Add Services"))
168 for x in self.onChangedEntry:
174 def getCurrentEntry(self):
175 return self["config"].getCurrent()[0]
177 def getCurrentValue(self):
178 return str(self["config"].getCurrent()[1].getText())
180 def createSummary(self):
183 def createSetup(self, timer):
185 self.name = ConfigText(default = timer.name, fixed_size = False)
188 self.match = ConfigText(default = timer.match, fixed_size = False)
189 self.match.setUseableChars('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789') # XXX: what exactly is useable? :-)
192 self.justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[int(timer.justplay)])
195 now = [x for x in localtime()]
196 if timer.hasTimespan():
198 now[3] = timer.timespan[0][0]
199 now[4] = timer.timespan[0][1]
201 now[3] = timer.timespan[1][0]
202 now[4] = timer.timespan[1][1]
212 self.timespan = ConfigEnableDisable(default = default)
213 self.timespanbegin = ConfigClock(default = begin)
214 self.timespanend = ConfigClock(default = end)
216 # Services have their own Screen
219 if timer.hasOffset():
221 begin = timer.getOffsetBegin()
222 end = timer.getOffsetEnd()
227 self.offset = ConfigEnableDisable(default = default)
228 self.offsetbegin = ConfigNumber(default = begin)
229 self.offsetend = ConfigNumber(default = end)
232 if timer.hasAfterEvent():
233 afterevent = { None: "default", AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby"}[timer.afterevent[0][0]]
235 afterevent = "default"
236 self.afterevent = ConfigSelection(choices = [("default", _("standard")), ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent)
238 # AfterEvent (Timespan)
239 if timer.hasAfterEvent() and timer.afterevent[0][1][0] is not None:
241 now[3] = timer.afterevent[0][1][0][0]
242 now[4] = timer.afterevent[0][1][0][1]
244 now[3] = timer.afterevent[0][1][1][0]
245 now[4] = timer.afterevent[0][1][1][1]
255 self.afterevent_timespan = ConfigEnableDisable(default = default)
256 self.afterevent_timespanbegin = ConfigClock(default = begin)
257 self.afterevent_timespanend = ConfigClock(default = end)
260 self.enabled = ConfigYesNo(default = timer.enabled)
263 if timer.hasDuration():
265 duration = timer.getDuration()
269 self.duration = ConfigEnableDisable(default = default)
270 self.durationlength = ConfigNumber(default = duration)
273 if timer.hasCounter():
274 default = timer.matchCount
277 self.counter = ConfigNumber(default = default)
278 self.counterLeft = ConfigNumber(default = timer.matchLeft)
279 selection = [("", _("Never")), ("%m", _("Monthly")), ("%U", _("Weekly (Sunday)")), ("%W", _("Weekly (Monday)"))]
280 if timer.getCounterFormatString() not in ["", "%m", "%U", "%W"]:
281 selection.append((timer.getCounterFormatString(), _("Custom (%s)") % (timer.getCounterFormatString())))
282 self.counterFormatString = ConfigSelection(selection, default = timer.getCounterFormatString())
284 # Avoid Duplicate Description
285 self.avoidDuplicateDescription = ConfigEnableDisable(default = timer.getAvoidDuplicateDescription())
288 if timer.hasDestination():
293 self.useDestination = ConfigYesNo(default = default)
295 default = timer.destination or Directories.resolveFilename(Directories.SCOPE_HDD)
296 choices = config.movielist.videodirs.value
297 if default not in choices:
298 choices.append(default)
299 self.destination = ConfigSelection(default = default, choices = choices)
302 # First three entries are only showed when not editing defaults
304 if not self.editingDefaults:
306 getConfigListEntry(_("Enabled"), self.enabled),
307 getConfigListEntry(_("Description"), self.name),
308 getConfigListEntry(_("Match Title"), self.match),
312 getConfigListEntry(_("Timer Type"), self.justplay),
313 getConfigListEntry(_("Only match during Timespan"), self.timespan)
316 # Only allow editing timespan when it's enabled
317 if self.timespan.value:
319 getConfigListEntry(_("Begin of Timespan"), self.timespanbegin),
320 getConfigListEntry(_("End of Timespan"), self.timespanend)
323 self.list.append(getConfigListEntry(_("Custom offset"), self.offset))
325 # Only allow editing offsets when it's enabled
326 if self.offset.value:
328 getConfigListEntry(_("Offset before recording (in m)"), self.offsetbegin),
329 getConfigListEntry(_("Offset after recording (in m)"), self.offsetend)
332 self.list.append(getConfigListEntry(_("Set maximum Duration"), self.duration))
334 # Only allow editing maxduration when it's enabled
335 if self.duration.value:
336 self.list.append(getConfigListEntry(_("Maximum Duration (in m)"), self.durationlength))
338 self.list.append(getConfigListEntry(_("After event"), self.afterevent))
340 # Only allow setting afterevent timespan when afterevent is active
341 if self.afterevent.value != "default":
342 self.list.append(getConfigListEntry(_("Execute after Event during Timespan"), self.afterevent_timespan))
344 # Only allow editing timespan when it's enabled
345 if self.afterevent_timespan.value:
347 getConfigListEntry(_("Begin of after Event Timespan"), self.afterevent_timespanbegin),
348 getConfigListEntry(_("End of after Event Timespan"), self.afterevent_timespanend)
351 self.list.append(getConfigListEntry(_("Record a maximum of x times"), self.counter))
353 # Only allow setting matchLeft when counting hits
354 if self.counter.value:
355 if not self.editingDefaults:
356 self.list.append(getConfigListEntry(_("Ammount of recordings left"), self.counterLeft))
357 self.list.append(getConfigListEntry(_("Reset Count"), self.counterFormatString))
359 self.list.append(getConfigListEntry(_("Require Description to be unique"), self.avoidDuplicateDescription))
361 # We always add this option though its expert only in enigma2
362 self.list.append(getConfigListEntry(_("Use a custom location"), self.useDestination))
363 if self.useDestination.value:
364 self.list.append(getConfigListEntry(_("Custom Location"), self.destination))
366 def reloadList(self, value):
368 self["config"].setList(self.list)
370 def editFilter(self):
371 self.session.openWithCallback(
372 self.editFilterCallback,
373 AutoTimerFilterEditor,
379 def editFilterCallback(self, ret):
381 self.filterSet = ret[0]
382 self.excludes = ret[1]
383 self.includes = ret[2]
384 self.renameFilterButton()
386 def editServices(self):
387 self.session.openWithCallback(
388 self.editServicesCallback,
389 AutoTimerServiceEditor,
390 self.serviceRestriction,
395 def editServicesCallback(self, ret):
397 self.serviceRestriction = ret[0]
398 self.services = ret[1][0]
399 self.bouquets = ret[1][1]
400 self.renameServiceButton()
403 cur = self["config"].getCurrent()
405 if cur == self.destination:
406 from Screens.LocationBox import MovieLocationBox
408 self.session.openWithCallback(
411 _("Choose target folder"),
412 self.destination.value,
413 minFree = 100 # Same requirement as in Screens.TimerEntry
416 ConfigListScreen.keyOK(self)
418 def pathSelected(self, res):
420 self.destination.choices.append(res)
421 self.destination.description[res] = res
422 self.destination.value = res
425 if self["config"].isChanged():
426 self.session.openWithCallback(
429 _("Really close without saving settings?")
434 def cancelConfirm(self, ret):
439 # Check if we have a trailing whitespace
440 if self.match.value[-1:] == " ":
441 self.session.openWithCallback(
444 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (self.match.value)
450 def saveCallback(self, ret):
453 self.match.value = self.match.value.rstrip()
455 # Don't to anything if MessageBox was canceled!
459 self.timer.match = self.match.value
462 self.timer.name = self.name.value or self.timer.match
465 self.timer.enabled = self.enabled.value
468 self.timer.justplay = self.justplay.value == "zap"
471 if self.timespan.value:
472 start = self.timespanbegin.value
473 end = self.timespanend.value
474 self.timer.timespan = (start, end)
476 self.timer.timespan = None
479 if self.serviceRestriction:
480 self.timer.services = self.services
481 self.timer.bouquets = self.bouquets
483 self.timer.services = None
484 self.timer.bouquets = None
487 if self.offset.value:
488 self.timer.offset = (self.offsetbegin.value*60, self.offsetend.value*60)
490 self.timer.offset = None
493 if self.afterevent.value == "default":
494 self.timer.afterevent = []
496 afterevent = {"nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY}[self.afterevent.value]
497 # AfterEvent Timespan
498 if self.afterevent_timespan.value:
499 start = self.afterevent_timespanbegin.value
500 end = self.afterevent_timespanend.value
501 self.timer.afterevent = [(afterevent, (start, end))]
503 self.timer.afterevent = [(afterevent, None)]
506 if self.duration.value:
507 self.timer.maxduration = self.durationlength.value*60
509 self.timer.maxduration = None
513 self.timer.exclude = self.excludes
514 self.timer.include = self.includes
516 self.timer.exclude = None
517 self.timer.include = None
520 if self.counter.value:
521 self.timer.matchCount = self.counter.value
522 if self.counterLeft.value <= self.counter.value:
523 self.timer.matchLeft = self.counterLeft.value
525 self.timer.matchLeft = self.counter.value
526 if self.counterFormatString.value:
527 self.timer.matchFormatString = self.counterFormatString.value
529 self.timer.matchFormatString = ''
531 self.timer.matchCount = 0
532 self.timer.matchLeft = 0
533 self.timer.matchFormatString = ''
535 self.timer.avoidDuplicateDescription = self.avoidDuplicateDescription.value
537 if self.useDestination.value:
538 self.timer.destination = self.destination.value
540 self.timer.destination = None
543 self.close(self.timer)
545 class AutoTimerFilterEditor(Screen, ConfigListScreen):
546 """Edit AutoTimer Filter"""
548 skin = """<screen name="AutoFilterEditor" title="Edit AutoTimer Filters" position="75,150" size="565,245">
549 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
550 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
551 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
552 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
553 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
554 <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" />
555 <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" />
556 <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" />
557 <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" />
560 def __init__(self, session, filterset, excludes, includes):
561 Screen.__init__(self, session)
564 self.setup_title = "AutoTimer Filters"
565 self.onChangedEntry = []
567 self.typeSelection = ConfigSelection(choices = [("title", _("in Title")), ("short", _("in Shortdescription")), ("desc", _("in Description")), ("day", _("on Weekday"))])
568 self.typeSelection.addNotifier(self.refresh, initial_call = False)
570 self.enabled = ConfigEnableDisable(default = filterset)
572 self.excludes = excludes
573 self.includes = includes
577 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
580 self["key_red"] = Button(_("Cancel"))
581 self["key_green"] = Button(_("Save"))
582 self["key_yellow"] = Button(_("delete"))
583 self["key_blue"] = Button(_("New"))
586 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
588 "cancel": self.cancel,
590 "yellow": self.remove,
599 for x in self.onChangedEntry:
605 def getCurrentEntry(self):
606 return self["config"].getCurrent()[0]
608 def getCurrentValue(self):
609 return str(self["config"].getCurrent()[1].getText())
611 def createSummary(self):
614 def saveCurrent(self):
615 del self.excludes[self.idx][:]
616 del self.includes[self.idx][:]
618 # Warning, accessing a ConfigListEntry directly might be considered evil!
621 for item in self["config"].getList():
623 # Skip empty entries (and those which are no filters)
624 if item[1].value == "" or idx < 2:
626 elif idx < self.lenExcludes:
627 self.excludes[self.idx].append(item[1].value.encode("UTF-8"))
629 self.includes[self.idx].append(item[1].value.encode("UTF-8"))
631 def refresh(self, value):
635 self["config"].setList(self.list)
637 def reloadList(self):
639 getConfigListEntry(_("Enable Filtering"), self.enabled),
640 getConfigListEntry(_("Filter"), self.typeSelection)
643 if self.typeSelection.value == "day":
646 # Weekdays are presented as ConfigSelection
648 getConfigListEntry(_("Exclude"), ConfigSelection(choices = weekdays, default = x))
649 for x in self.excludes[3]
651 self.lenExcludes = len(self.list)
653 getConfigListEntry(_("Include"), ConfigSelection(choices = weekdays, default = x))
654 for x in self.includes[3]
657 elif self.typeSelection.value == "title":
659 elif self.typeSelection.value == "short":
661 else: # self.typeSelection.value == "desc":
665 getConfigListEntry(_("Exclude"), ConfigText(default = x, fixed_size = False))
666 for x in self.excludes[self.idx]
668 self.lenExcludes = len(self.list)
670 getConfigListEntry(_("Include"), ConfigText(default = x, fixed_size = False))
671 for x in self.includes[self.idx]
675 idx = self["config"].getCurrentIndex()
677 if idx < self.lenExcludes:
678 self.lenExcludes -= 1
680 list = self["config"].getList()
681 list.remove(self["config"].getCurrent())
682 self["config"].setList(list)
685 self.session.openWithCallback(
688 _("Select type of Filter"),
695 def typeSelected(self, ret):
697 list = self["config"].getList()
700 pos = self.lenExcludes
701 self.lenExcludes += 1
707 if self.typeSelection.value == "day":
708 entry = getConfigListEntry(text, ConfigSelection(choices = weekdays))
710 entry = getConfigListEntry(text, ConfigText(fixed_size = False))
712 list.insert(pos, entry)
713 self["config"].setList(list)
716 if self["config"].isChanged():
717 self.session.openWithCallback(
720 _("Really close without saving settings?")
725 def cancelConfirm(self, ret):
738 class AutoTimerServiceEditor(Screen, ConfigListScreen):
739 """Edit allowed Services of a AutoTimer"""
741 skin = """<screen name="AutoTimerServiceEditor" title="Edit AutoTimer Services" position="75,150" size="565,245">
742 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
743 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
744 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
745 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
746 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
747 <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" />
748 <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" />
749 <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" />
750 <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" />
753 def __init__(self, session, servicerestriction, servicelist, bouquetlist):
754 Screen.__init__(self, session)
757 self.setup_title = "AutoTimer Services"
758 self.onChangedEntry = []
765 self.enabled = ConfigEnableDisable(default = servicerestriction)
766 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
767 self.typeSelection.addNotifier(self.refresh, initial_call = False)
771 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
774 self["key_red"] = Button(_("Cancel"))
775 self["key_green"] = Button(_("OK"))
776 self["key_yellow"] = Button(_("delete"))
777 self["key_blue"] = Button(_("New"))
780 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
782 "cancel": self.cancel,
784 "yellow": self.remove,
793 def saveCurrent(self):
794 del self.services[self.idx][:]
796 # Warning, accessing a ConfigListEntry directly might be considered evil!
798 myl = self["config"].getList()
802 self.services[self.idx].append(item[1].value)
804 def refresh(self, value):
808 self["config"].setList(self.list)
810 def reloadList(self):
812 getConfigListEntry(_("Enable Service Restriction"), self.enabled),
813 getConfigListEntry(_("Editing"), self.typeSelection)
816 if self.typeSelection.value == "channels":
818 else: # self.typeSelection.value == "bouquets":
822 getConfigListEntry(_("Record on"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
823 for x in self.services[self.idx]
827 for x in self.onChangedEntry:
833 def getCurrentEntry(self):
834 return self["config"].getCurrent()[0]
836 def getCurrentValue(self):
837 return str(self["config"].getCurrent()[1].getText())
839 def createSummary(self):
843 if self["config"].getCurrentIndex() != 0:
844 list = self["config"].getList()
845 list.remove(self["config"].getCurrent())
846 self["config"].setList(list)
849 if self.typeSelection.value == "channels":
850 self.session.openWithCallback(
851 self.finishedServiceSelection,
852 SimpleChannelSelection,
853 _("Select channel to record on")
855 else: # self.typeSelection.value == "bouquets":
856 self.session.openWithCallback(
857 self.finishedServiceSelection,
858 SimpleBouquetSelection,
859 _("Select bouquet to record on")
862 def finishedServiceSelection(self, *args):
864 list = self["config"].getList()
865 sname = args[0].toString()
867 if self.typeSelection.value == "channels":
868 # strip all after last : when adding a channel
869 pos = sname.rfind(':')
871 sname = sname[:pos+1]
873 list.append(getConfigListEntry(_("Record on"), ConfigSelection(choices = [(sname, ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])))
874 self["config"].setList(list)
877 if self["config"].isChanged():
878 self.session.openWithCallback(
881 _("Really close without saving settings?")
886 def cancelConfirm(self, ret):
898 def addAutotimerFromEvent(session, evt = None, service = None):
899 from AutoTimerComponent import AutoTimerComponent
900 from AutoTimerImporter import AutoTimerImporter
901 from plugin import autotimer
903 # Create instance if needed
904 if autotimer is None:
905 from AutoTimer import AutoTimer
906 autotimer = AutoTimer()
908 match = evt and evt.getEventName() or ""
909 name = match or "New AutoTimer"
911 if service is not None:
912 service = str(service)
913 # strip all after last :
914 pos = service.rfind(':')
916 service = service[:pos+1]
918 sref = ServiceReference(service)
920 # timespan defaults to +- 1h
921 begin = evt.getBeginTime()-3600
922 end = begin + evt.getDuration()+7200
926 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-)
928 session.openWithCallback(
932 autotimer.getUniqueId(), # Id
937 match, # Proposed Match
938 begin, # Proposed Begin
940 None, # Proposed Disabled
941 sref, # Proposed ServiceReference
942 None, # Proposed afterEvent
943 None, # Proposed justplay
944 None # Proposed dirname, can we get anything useful here?
947 def addAutotimerFromService(session, service = None):
948 from AutoTimerComponent import AutoTimerComponent
949 from AutoTimerImporter import AutoTimerImporter
950 from plugin import autotimer
952 # Create instance if needed
953 if autotimer is None:
954 from AutoTimer import AutoTimer
955 autotimer = AutoTimer()
957 serviceHandler = eServiceCenter.getInstance()
958 info = serviceHandler.info(service)
960 match = info and info.getName(service) or ""
961 name = match or "New AutoTimer"
962 sref = info and info.getInfoString(service, iServiceInformation.sServiceref)
964 # strip all after last :
965 pos = sref.rfind(':')
969 sref = ServiceReference(sref)
971 begin = info.getInfo(service, iServiceInformation.sTimeCreate)
972 end = begin + info.getLength(service)
976 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-)
978 session.openWithCallback(
982 autotimer.getUniqueId(), # Id
987 match, # Proposed Match
988 begin, # Proposed Begin
990 None, # Proposed Disabled
991 sref, # Proposed ServiceReference
992 None, # Proposed afterEvent
993 None, # Proposed justplay
994 None # Proposed dirname, can we get anything useful here?
997 def importerCallback(ret):
1001 session.openWithCallback(
1007 # Remove instance if not running in background
1008 if not config.plugins.autotimer.autopoll.value:
1009 from plugin import autotimer
1013 def editorCallback(ret):
1015 from plugin import autotimer
1017 # Create instance if needed (should have been created by addAutotimerFrom* above though)
1018 if autotimer is None:
1019 from AutoTimer import AutoTimer
1020 autotimer = AutoTimer()
1024 # Remove instance if not running in background
1025 if not config.plugins.autotimer.autopoll.value:
1026 # Save xml (as long as we added something)
1027 ret and autotimer and autotimer.writeXml()