1 # -*- coding: UTF-8 -*-
2 # for localized messages
6 from Screens.Screen import Screen
7 from Components.ConfigList import ConfigListScreen
8 from Screens.ChannelSelection import SimpleChannelSelection
9 from Screens.MessageBox import MessageBox
10 from Screens.ChoiceBox import ChoiceBox
13 from Screens.Setup import SetupSummary
16 from Components.ActionMap import ActionMap
17 from Components.Button import Button
20 from Components.config import getConfigListEntry, ConfigEnableDisable, \
21 ConfigYesNo, ConfigText, ConfigClock, ConfigNumber, ConfigSelection, \
25 from RecordTimer import AFTEREVENT
27 # Needed to convert our timestamp back and forth
28 from time import localtime, mktime
30 # Show ServiceName instead of ServiceReference
31 from ServiceReference import ServiceReference
33 # addAutotimerFromService
34 from enigma import eServiceCenter, iServiceInformation
36 # Default Record Directory
37 from Tools import Directories
42 ("2", _("Wednesday")),
47 ("weekend", _("Weekend")),
48 ("weekday", _("Weekday"))
51 class SimpleBouquetSelection(SimpleChannelSelection):
52 def __init__(self, session, title):
53 SimpleChannelSelection.__init__(self, session, title)
54 self.skinName = "SimpleChannelSelection"
56 def channelSelected(self): # just return selected service
57 ref = self.getCurrentSelection()
58 if (ref.flags & 7) == 7:
61 # We return the currently active path here
62 # Asking the user if this is what he wants might be better though
63 self.close(self.servicePath[-1])
65 class AutoTimerEditorBase():
66 """ Base Class for all Editors """
67 def __init__(self, timer, editingDefaults = False):
70 self.editingDefaults = editingDefaults
72 # See if we are filtering some strings
74 timer.getExcludedTitle(),
75 timer.getExcludedShort(),
76 timer.getExcludedDescription(),
77 timer.getExcludedDays()
80 timer.getIncludedTitle(),
81 timer.getIncludedShort(),
82 timer.getIncludedDescription(),
83 timer.getIncludedDays()
85 if len(self.excludes[0]) or len(self.excludes[1]) \
86 or len(self.excludes[2]) or len(self.excludes[3]) \
87 or len(self.includes[0]) or len(self.includes[1]) \
88 or len(self.includes[2]) or len(self.includes[3]):
91 self.filterSet = False
93 # See if services are restricted
94 self.services = timer.getServices()
95 self.bouquets = timer.getBouquets()
96 if len(self.services) or len(self.bouquets):
97 self.serviceRestriction = True
99 self.serviceRestriction = False
101 self.createSetup(timer)
103 def createSetup(self, timer):
105 self.name = ConfigText(default = timer.name, fixed_size = False)
108 self.match = ConfigText(default = timer.match, fixed_size = False)
109 self.match.setUseableChars('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789-_?!.:;,&%()\'"+/$@') # XXX: what exactly is useable? :-)
112 self.justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[int(timer.justplay)])
115 now = [x for x in localtime()]
116 if timer.hasTimespan():
118 now[3] = timer.timespan[0][0]
119 now[4] = timer.timespan[0][1]
121 now[3] = timer.timespan[1][0]
122 now[4] = timer.timespan[1][1]
132 self.timespan = ConfigEnableDisable(default = default)
133 self.timespanbegin = ConfigClock(default = begin)
134 self.timespanend = ConfigClock(default = end)
136 # Services have their own Screen
139 if timer.hasOffset():
141 begin = timer.getOffsetBegin()
142 end = timer.getOffsetEnd()
147 self.offset = ConfigEnableDisable(default = default)
148 self.offsetbegin = ConfigNumber(default = begin)
149 self.offsetend = ConfigNumber(default = end)
152 if timer.hasAfterEvent():
153 afterevent = { None: "default", AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby"}[timer.afterevent[0][0]]
155 afterevent = "default"
156 self.afterevent = ConfigSelection(choices = [("default", _("standard")), ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent)
158 # AfterEvent (Timespan)
159 if timer.hasAfterEvent() and timer.afterevent[0][1][0] is not None:
161 now[3] = timer.afterevent[0][1][0][0]
162 now[4] = timer.afterevent[0][1][0][1]
164 now[3] = timer.afterevent[0][1][1][0]
165 now[4] = timer.afterevent[0][1][1][1]
175 self.afterevent_timespan = ConfigEnableDisable(default = default)
176 self.afterevent_timespanbegin = ConfigClock(default = begin)
177 self.afterevent_timespanend = ConfigClock(default = end)
180 self.enabled = ConfigYesNo(default = timer.enabled)
183 if timer.hasDuration():
185 duration = timer.getDuration()
189 self.duration = ConfigEnableDisable(default = default)
190 self.durationlength = ConfigNumber(default = duration)
193 if timer.hasCounter():
194 default = timer.matchCount
197 self.counter = ConfigNumber(default = default)
198 self.counterLeft = ConfigNumber(default = timer.matchLeft)
199 selection = [("", _("Never")), ("%m", _("Monthly")), ("%U", _("Weekly (Sunday)")), ("%W", _("Weekly (Monday)"))]
200 if timer.getCounterFormatString() not in ["", "%m", "%U", "%W"]:
201 selection.append((timer.getCounterFormatString(), _("Custom (%s)") % (timer.getCounterFormatString())))
202 self.counterFormatString = ConfigSelection(selection, default = timer.getCounterFormatString())
204 # Avoid Duplicate Description
205 self.avoidDuplicateDescription = ConfigSelection([
207 ("1", _("On same service")),
208 ("2", _("On any service")),
210 default = str(timer.getAvoidDuplicateDescription())
214 if timer.hasDestination():
219 self.useDestination = ConfigYesNo(default = default)
221 default = timer.destination or Directories.resolveFilename(Directories.SCOPE_HDD)
222 choices = config.movielist.videodirs.value
224 if default not in choices:
225 choices.append(default)
226 self.destination = ConfigSelection(default = default, choices = choices)
228 def pathSelected(self, res):
230 if res not in self.destination.choices:
231 self.destination.choices.append(res)
232 self.destination.description[res] = res
233 self.destination.value = res
235 def chooseDestination(self):
236 from Screens.LocationBox import MovieLocationBox
238 self.session.openWithCallback(
241 _("Choose target folder"),
242 self.destination.value,
243 minFree = 100 # Same requirement as in Screens.TimerEntry
246 class AutoTimerEditor(Screen, ConfigListScreen, AutoTimerEditorBase):
249 skin = """<screen name="AutoTimerEdit" title="Edit AutoTimer" position="75,155" size="565,280">
250 <widget name="config" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
251 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
252 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
253 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
254 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
255 <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" />
256 <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" />
257 <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" />
258 <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" />
261 def __init__(self, session, timer, editingDefaults = False):
262 Screen.__init__(self, session)
264 AutoTimerEditorBase.__init__(self, timer, editingDefaults)
267 self.setup_title = "AutoTimer Editor"
268 self.onChangedEntry = []
270 # We might need to change shown items, so add some notifiers
271 self.timespan.addNotifier(self.reloadList, initial_call = False)
272 self.offset.addNotifier(self.reloadList, initial_call = False)
273 self.duration.addNotifier(self.reloadList, initial_call = False)
274 self.afterevent.addNotifier(self.reloadList, initial_call = False)
275 self.afterevent_timespan.addNotifier(self.reloadList, initial_call = False)
276 self.counter.addNotifier(self.reloadList, initial_call = False)
277 self.useDestination.addNotifier(self.reloadList, initial_call = False)
281 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
284 self["key_red"] = Button(_("Cancel"))
285 self["key_green"] = Button(_("OK"))
286 self["key_yellow"] = Button()
287 self["key_blue"] = Button()
290 self.renameServiceButton()
291 self.renameFilterButton()
294 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
296 "cancel": self.cancel,
297 "save": self.maybeSave,
299 "yellow": self.editFilter,
300 "blue": self.editServices
307 def renameFilterButton(self):
309 self["key_yellow"].setText(_("Edit Filters"))
311 self["key_yellow"].setText(_("Add Filters"))
313 def renameServiceButton(self):
314 if self.serviceRestriction:
315 self["key_blue"].setText(_("Edit Services"))
317 self["key_blue"].setText(_("Add Services"))
320 for x in self.onChangedEntry:
326 def getCurrentEntry(self):
327 return self["config"].getCurrent()[0]
329 def getCurrentValue(self):
330 return str(self["config"].getCurrent()[1].getText())
332 def createSummary(self):
336 # First three entries are only showed when not editing defaults
338 if not self.editingDefaults:
340 getConfigListEntry(_("Enabled"), self.enabled),
341 getConfigListEntry(_("Description"), self.name),
342 getConfigListEntry(_("Match Title"), self.match),
346 getConfigListEntry(_("Timer Type"), self.justplay),
347 getConfigListEntry(_("Only match during Timespan"), self.timespan)
350 # Only allow editing timespan when it's enabled
351 if self.timespan.value:
353 getConfigListEntry(_("Begin of Timespan"), self.timespanbegin),
354 getConfigListEntry(_("End of Timespan"), self.timespanend)
357 self.list.append(getConfigListEntry(_("Custom offset"), self.offset))
359 # Only allow editing offsets when it's enabled
360 if self.offset.value:
362 getConfigListEntry(_("Offset before recording (in m)"), self.offsetbegin),
363 getConfigListEntry(_("Offset after recording (in m)"), self.offsetend)
366 self.list.append(getConfigListEntry(_("Set maximum Duration"), self.duration))
368 # Only allow editing maxduration when it's enabled
369 if self.duration.value:
370 self.list.append(getConfigListEntry(_("Maximum Duration (in m)"), self.durationlength))
372 self.list.append(getConfigListEntry(_("After event"), self.afterevent))
374 # Only allow setting afterevent timespan when afterevent is active
375 if self.afterevent.value != "default":
376 self.list.append(getConfigListEntry(_("Execute after Event during Timespan"), self.afterevent_timespan))
378 # Only allow editing timespan when it's enabled
379 if self.afterevent_timespan.value:
381 getConfigListEntry(_("Begin of after Event Timespan"), self.afterevent_timespanbegin),
382 getConfigListEntry(_("End of after Event Timespan"), self.afterevent_timespanend)
385 self.list.append(getConfigListEntry(_("Record a maximum of x times"), self.counter))
387 # Only allow setting matchLeft when counting hits
388 if self.counter.value:
389 if not self.editingDefaults:
390 self.list.append(getConfigListEntry(_("Ammount of recordings left"), self.counterLeft))
391 self.list.append(getConfigListEntry(_("Reset Count"), self.counterFormatString))
393 self.list.append(getConfigListEntry(_("Require Description to be unique"), self.avoidDuplicateDescription))
395 # We always add this option though its expert only in enigma2
396 self.list.append(getConfigListEntry(_("Use a custom location"), self.useDestination))
397 if self.useDestination.value:
398 self.list.append(getConfigListEntry(_("Custom Location"), self.destination))
400 def reloadList(self, value):
402 self["config"].setList(self.list)
404 def editFilter(self):
405 self.session.openWithCallback(
406 self.editFilterCallback,
407 AutoTimerFilterEditor,
413 def editFilterCallback(self, ret):
415 self.filterSet = ret[0]
416 self.excludes = ret[1]
417 self.includes = ret[2]
418 self.renameFilterButton()
420 def editServices(self):
421 self.session.openWithCallback(
422 self.editServicesCallback,
423 AutoTimerServiceEditor,
424 self.serviceRestriction,
429 def editServicesCallback(self, ret):
431 self.serviceRestriction = ret[0]
432 self.services = ret[1][0]
433 self.bouquets = ret[1][1]
434 self.renameServiceButton()
437 cur = self["config"].getCurrent()
439 if cur == self.destination:
440 self.chooseDestination()
442 ConfigListScreen.keyOK(self)
445 if self["config"].isChanged():
446 self.session.openWithCallback(
449 _("Really close without saving settings?")
454 def cancelConfirm(self, ret):
459 # Check if any match is set
460 if not self.match.value.strip():
463 _("The match attribute is mandatory."),
464 type = MessageBox.TYPE_ERROR,
467 # Check if we have a trailing whitespace
468 elif self.match.value[-1:] == " ":
469 self.session.openWithCallback(
472 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (self.match.value)
478 def saveCallback(self, ret):
481 self.match.value = self.match.value.rstrip()
483 # Don't to anything if MessageBox was canceled!
487 self.timer.match = self.match.value
490 self.timer.name = self.name.value.strip() or self.timer.match
493 self.timer.enabled = self.enabled.value
496 self.timer.justplay = self.justplay.value == "zap"
499 if self.timespan.value:
500 start = self.timespanbegin.value
501 end = self.timespanend.value
502 self.timer.timespan = (start, end)
504 self.timer.timespan = None
507 if self.serviceRestriction:
508 self.timer.services = self.services
509 self.timer.bouquets = self.bouquets
511 self.timer.services = None
512 self.timer.bouquets = None
515 if self.offset.value:
516 self.timer.offset = (self.offsetbegin.value*60, self.offsetend.value*60)
518 self.timer.offset = None
521 if self.afterevent.value == "default":
522 self.timer.afterevent = []
524 afterevent = {"nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY}[self.afterevent.value]
525 # AfterEvent Timespan
526 if self.afterevent_timespan.value:
527 start = self.afterevent_timespanbegin.value
528 end = self.afterevent_timespanend.value
529 self.timer.afterevent = [(afterevent, (start, end))]
531 self.timer.afterevent = [(afterevent, None)]
534 if self.duration.value:
535 self.timer.maxduration = self.durationlength.value*60
537 self.timer.maxduration = None
541 self.timer.exclude = self.excludes
542 self.timer.include = self.includes
544 self.timer.exclude = None
545 self.timer.include = None
548 if self.counter.value:
549 self.timer.matchCount = self.counter.value
550 if self.counterLeft.value <= self.counter.value:
551 self.timer.matchLeft = self.counterLeft.value
553 self.timer.matchLeft = self.counter.value
554 if self.counterFormatString.value:
555 self.timer.matchFormatString = self.counterFormatString.value
557 self.timer.matchFormatString = ''
559 self.timer.matchCount = 0
560 self.timer.matchLeft = 0
561 self.timer.matchFormatString = ''
563 self.timer.avoidDuplicateDescription = int(self.avoidDuplicateDescription.value)
565 if self.useDestination.value:
566 self.timer.destination = self.destination.value
568 self.timer.destination = None
571 self.close(self.timer)
573 class AutoTimerFilterEditor(Screen, ConfigListScreen):
574 """Edit AutoTimer Filter"""
576 skin = """<screen name="AutoFilterEditor" title="Edit AutoTimer Filters" position="75,150" size="565,245">
577 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
578 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
579 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
580 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
581 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
582 <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" />
583 <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" />
584 <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" />
585 <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" />
588 def __init__(self, session, filterset, excludes, includes):
589 Screen.__init__(self, session)
592 self.setup_title = "AutoTimer Filters"
593 self.onChangedEntry = []
595 self.typeSelection = ConfigSelection(choices = [("title", _("in Title")), ("short", _("in Shortdescription")), ("desc", _("in Description")), ("day", _("on Weekday"))])
596 self.typeSelection.addNotifier(self.refresh, initial_call = False)
598 self.enabled = ConfigEnableDisable(default = filterset)
600 self.excludes = excludes
601 self.includes = includes
605 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
608 self["key_red"] = Button(_("Cancel"))
609 self["key_green"] = Button(_("Save"))
610 self["key_yellow"] = Button(_("delete"))
611 self["key_blue"] = Button(_("New"))
614 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
616 "cancel": self.cancel,
618 "yellow": self.remove,
627 for x in self.onChangedEntry:
633 def getCurrentEntry(self):
634 return self["config"].getCurrent()[0]
636 def getCurrentValue(self):
637 return str(self["config"].getCurrent()[1].getText())
639 def createSummary(self):
642 def saveCurrent(self):
643 del self.excludes[self.idx][:]
644 del self.includes[self.idx][:]
646 # Warning, accessing a ConfigListEntry directly might be considered evil!
649 for item in self["config"].getList()[:]:
651 # Skip empty entries (and those which are no filters)
652 if item[1].value == "" or idx < 2:
654 elif idx < self.lenExcludes:
655 self.excludes[self.idx].append(item[1].value.encode("UTF-8"))
657 self.includes[self.idx].append(item[1].value.encode("UTF-8"))
659 def refresh(self, *args, **kwargs):
663 self["config"].setList(self.list)
665 def reloadList(self):
667 getConfigListEntry(_("Enable Filtering"), self.enabled),
668 getConfigListEntry(_("Filter"), self.typeSelection)
671 if self.typeSelection.value == "day":
674 # Weekdays are presented as ConfigSelection
676 getConfigListEntry(_("Exclude"), ConfigSelection(choices = weekdays, default = x))
677 for x in self.excludes[3]
679 self.lenExcludes = len(self.list)
681 getConfigListEntry(_("Include"), ConfigSelection(choices = weekdays, default = x))
682 for x in self.includes[3]
685 elif self.typeSelection.value == "title":
687 elif self.typeSelection.value == "short":
689 else: # self.typeSelection.value == "desc":
693 getConfigListEntry(_("Exclude"), ConfigText(default = x, fixed_size = False))
694 for x in self.excludes[self.idx]
696 self.lenExcludes = len(self.list)
698 getConfigListEntry(_("Include"), ConfigText(default = x, fixed_size = False))
699 for x in self.includes[self.idx]
703 idx = self["config"].getCurrentIndex()
705 if idx < self.lenExcludes:
706 self.lenExcludes -= 1
708 list = self["config"].getList()
709 list.remove(self["config"].getCurrent())
710 self["config"].setList(list)
713 self.session.openWithCallback(
716 _("Select type of Filter"),
723 def typeSelected(self, ret):
725 list = self["config"].getList()
728 pos = self.lenExcludes
729 self.lenExcludes += 1
735 if self.typeSelection.value == "day":
736 entry = getConfigListEntry(text, ConfigSelection(choices = weekdays))
738 entry = getConfigListEntry(text, ConfigText(fixed_size = False))
740 list.insert(pos, entry)
741 self["config"].setList(list)
744 if self["config"].isChanged():
745 self.session.openWithCallback(
748 _("Really close without saving settings?")
753 def cancelConfirm(self, ret):
766 class AutoTimerServiceEditor(Screen, ConfigListScreen):
767 """Edit allowed Services of a AutoTimer"""
769 skin = """<screen name="AutoTimerServiceEditor" title="Edit AutoTimer Services" position="75,150" size="565,245">
770 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
771 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
772 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
773 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
774 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
775 <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" />
776 <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" />
777 <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" />
778 <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" />
781 def __init__(self, session, servicerestriction, servicelist, bouquetlist):
782 Screen.__init__(self, session)
785 self.setup_title = "AutoTimer Services"
786 self.onChangedEntry = []
793 self.enabled = ConfigEnableDisable(default = servicerestriction)
794 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
795 self.typeSelection.addNotifier(self.refresh, initial_call = False)
799 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
802 self["key_red"] = Button(_("Cancel"))
803 self["key_green"] = Button(_("OK"))
804 self["key_yellow"] = Button(_("delete"))
805 self["key_blue"] = Button(_("New"))
808 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
810 "cancel": self.cancel,
812 "yellow": self.remove,
821 def saveCurrent(self):
822 del self.services[self.idx][:]
824 # Warning, accessing a ConfigListEntry directly might be considered evil!
826 myl = self["config"].getList()[:]
830 self.services[self.idx].append(item[1].value)
832 def refresh(self, *args, **kwargs):
836 self["config"].setList(self.list)
838 def reloadList(self):
840 getConfigListEntry(_("Enable Service Restriction"), self.enabled),
841 getConfigListEntry(_("Editing"), self.typeSelection)
844 if self.typeSelection.value == "channels":
846 else: # self.typeSelection.value == "bouquets":
850 getConfigListEntry(_("Record on"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
851 for x in self.services[self.idx]
855 for x in self.onChangedEntry:
861 def getCurrentEntry(self):
862 return self["config"].getCurrent()[0]
864 def getCurrentValue(self):
865 return str(self["config"].getCurrent()[1].getText())
867 def createSummary(self):
871 if self["config"].getCurrentIndex() != 0:
872 list = self["config"].getList()
873 list.remove(self["config"].getCurrent())
874 self["config"].setList(list)
877 if self.typeSelection.value == "channels":
878 self.session.openWithCallback(
879 self.finishedServiceSelection,
880 SimpleChannelSelection,
881 _("Select channel to record on")
883 else: # self.typeSelection.value == "bouquets":
884 self.session.openWithCallback(
885 self.finishedServiceSelection,
886 SimpleBouquetSelection,
887 _("Select bouquet to record on")
890 def finishedServiceSelection(self, *args):
892 list = self["config"].getList()
893 sname = args[0].toString()
895 if self.typeSelection.value == "channels":
896 # strip all after last : when adding a channel
897 pos = sname.rfind(':')
899 sname = sname[:pos+1]
901 list.append(getConfigListEntry(_("Record on"), ConfigSelection(choices = [(sname, ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])))
902 self["config"].setList(list)
905 if self["config"].isChanged():
906 self.session.openWithCallback(
909 _("Really close without saving settings?")
914 def cancelConfirm(self, ret):
926 def addAutotimerFromEvent(session, evt = None, service = None):
927 from AutoTimerComponent import AutoTimerComponent
928 from AutoTimerImporter import AutoTimerImporter
929 from plugin import autotimer
931 # Create instance if needed
932 if autotimer is None:
933 from AutoTimer import AutoTimer
934 autotimer = AutoTimer()
937 match = evt and evt.getEventName() or ""
938 name = match or "New AutoTimer"
940 if service is not None:
941 service = str(service)
942 # strip all after last :
943 pos = service.rfind(':')
945 service = service[:pos+1]
947 sref = ServiceReference(service)
949 # timespan defaults to +- 1h
950 begin = evt.getBeginTime()-3600
951 end = begin + evt.getDuration()+7200
955 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-)
957 session.openWithCallback(
961 autotimer.getUniqueId(), # Id
966 match, # Proposed Match
967 begin, # Proposed Begin
969 None, # Proposed Disabled
970 sref, # Proposed ServiceReference
971 None, # Proposed afterEvent
972 None, # Proposed justplay
973 None # Proposed dirname, can we get anything useful here?
976 def addAutotimerFromService(session, service = None):
977 from AutoTimerComponent import AutoTimerComponent
978 from AutoTimerImporter import AutoTimerImporter
979 from plugin import autotimer
981 # Create instance if needed
982 if autotimer is None:
983 from AutoTimer import AutoTimer
984 autotimer = AutoTimer()
987 serviceHandler = eServiceCenter.getInstance()
988 info = serviceHandler.info(service)
990 match = info and info.getName(service) or ""
991 name = match or "New AutoTimer"
992 sref = info and info.getInfoString(service, iServiceInformation.sServiceref)
994 # strip all after last :
995 pos = sref.rfind(':')
999 sref = ServiceReference(sref)
1001 begin = info.getInfo(service, iServiceInformation.sTimeCreate)
1002 end = begin + info.getLength(service)
1006 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-)
1008 session.openWithCallback(
1012 autotimer.getUniqueId(), # Id
1017 match, # Proposed Match
1018 begin, # Proposed Begin
1020 None, # Proposed Disabled
1021 sref, # Proposed ServiceReference
1022 None, # Proposed afterEvent
1023 None, # Proposed justplay
1024 None # Proposed dirname, can we get anything useful here?
1027 def importerCallback(ret):
1031 session.openWithCallback(
1037 # Remove instance if not running in background
1038 if not config.plugins.autotimer.autopoll.value:
1039 from plugin import autotimer
1042 def editorCallback(ret):
1044 from plugin import autotimer
1046 # Create instance if needed (should have been created by addAutotimerFrom* above though)
1047 if autotimer is None:
1048 from AutoTimer import AutoTimer
1049 autotimer = AutoTimer()
1054 # Remove instance if not running in background
1055 if not config.plugins.autotimer.autopoll.value:
1056 # Save xml (as long as we added something)
1057 ret and autotimer and autotimer.writeXml()