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 ExtendedConfigText(ConfigText):
52 def __init__(self, default = "", fixed_size = True, visible_width = False):
53 ConfigText.__init__(self, default = default, fixed_size = fixed_size, visible_width = visible_width)
55 # Workaround some characters currently not "typeable" using NumericalTextInput
56 mapping = self.mapping
58 if "&" not in mapping[0]:
60 if ";" not in mapping[0]:
62 if "%" not in mapping[0]:
65 class SimpleBouquetSelection(SimpleChannelSelection):
66 def __init__(self, session, title):
67 SimpleChannelSelection.__init__(self, session, title)
68 self.skinName = "SimpleChannelSelection"
70 def channelSelected(self): # just return selected service
71 ref = self.getCurrentSelection()
72 if (ref.flags & 7) == 7:
75 # We return the currently active path here
76 # Asking the user if this is what he wants might be better though
77 self.close(self.servicePath[-1])
79 class AutoTimerEditorBase():
80 """ Base Class for all Editors """
81 def __init__(self, timer, editingDefaults = False):
84 self.editingDefaults = editingDefaults
86 # See if we are filtering some strings
88 timer.getExcludedTitle(),
89 timer.getExcludedShort(),
90 timer.getExcludedDescription(),
91 timer.getExcludedDays()
94 timer.getIncludedTitle(),
95 timer.getIncludedShort(),
96 timer.getIncludedDescription(),
97 timer.getIncludedDays()
99 if len(self.excludes[0]) or len(self.excludes[1]) \
100 or len(self.excludes[2]) or len(self.excludes[3]) \
101 or len(self.includes[0]) or len(self.includes[1]) \
102 or len(self.includes[2]) or len(self.includes[3]):
103 self.filterSet = True
105 self.filterSet = False
107 # See if services are restricted
108 self.services = timer.getServices()
109 self.bouquets = timer.getBouquets()
110 if len(self.services) or len(self.bouquets):
111 self.serviceRestriction = True
113 self.serviceRestriction = False
115 self.createSetup(timer)
117 def createSetup(self, timer):
119 self.name = ExtendedConfigText(default = timer.name, fixed_size = False)
122 self.match = ExtendedConfigText(default = timer.match, fixed_size = False)
123 self.match.setUseableChars('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789-_?!.:;,&%()\'"+/$@') # XXX: what exactly is useable? :-)
126 self.justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = {0: "record", 1: "zap"}[int(timer.justplay)])
129 now = [x for x in localtime()]
130 if timer.hasTimespan():
132 now[3] = timer.timespan[0][0]
133 now[4] = timer.timespan[0][1]
135 now[3] = timer.timespan[1][0]
136 now[4] = timer.timespan[1][1]
146 self.timespan = ConfigEnableDisable(default = default)
147 self.timespanbegin = ConfigClock(default = begin)
148 self.timespanend = ConfigClock(default = end)
150 # Services have their own Screen
153 if timer.hasOffset():
155 begin = timer.getOffsetBegin()
156 end = timer.getOffsetEnd()
161 self.offset = ConfigEnableDisable(default = default)
162 self.offsetbegin = ConfigNumber(default = begin)
163 self.offsetend = ConfigNumber(default = end)
166 if timer.hasAfterEvent():
167 afterevent = { None: "default", AFTEREVENT.NONE: "nothing", AFTEREVENT.DEEPSTANDBY: "deepstandby", AFTEREVENT.STANDBY: "standby"}[timer.afterevent[0][0]]
169 afterevent = "default"
170 self.afterevent = ConfigSelection(choices = [("default", _("standard")), ("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", _("go to deep standby"))], default = afterevent)
172 # AfterEvent (Timespan)
173 if timer.hasAfterEvent() and timer.afterevent[0][1][0] is not None:
175 now[3] = timer.afterevent[0][1][0][0]
176 now[4] = timer.afterevent[0][1][0][1]
178 now[3] = timer.afterevent[0][1][1][0]
179 now[4] = timer.afterevent[0][1][1][1]
189 self.afterevent_timespan = ConfigEnableDisable(default = default)
190 self.afterevent_timespanbegin = ConfigClock(default = begin)
191 self.afterevent_timespanend = ConfigClock(default = end)
194 self.enabled = ConfigYesNo(default = timer.enabled)
197 if timer.hasDuration():
199 duration = timer.getDuration()
203 self.duration = ConfigEnableDisable(default = default)
204 self.durationlength = ConfigNumber(default = duration)
207 if timer.hasCounter():
208 default = timer.matchCount
211 self.counter = ConfigNumber(default = default)
212 self.counterLeft = ConfigNumber(default = timer.matchLeft)
213 selection = [("", _("Never")), ("%m", _("Monthly")), ("%U", _("Weekly (Sunday)")), ("%W", _("Weekly (Monday)"))]
214 if timer.getCounterFormatString() not in ["", "%m", "%U", "%W"]:
215 selection.append((timer.getCounterFormatString(), _("Custom (%s)") % (timer.getCounterFormatString())))
216 self.counterFormatString = ConfigSelection(selection, default = timer.getCounterFormatString())
218 # Avoid Duplicate Description
219 self.avoidDuplicateDescription = ConfigSelection([
221 ("1", _("On same service")),
222 ("2", _("On any service")),
224 default = str(timer.getAvoidDuplicateDescription())
228 if timer.hasDestination():
233 self.useDestination = ConfigYesNo(default = default)
235 default = timer.destination or Directories.resolveFilename(Directories.SCOPE_HDD)
236 choices = config.movielist.videodirs.value
238 if default not in choices:
239 choices.append(default)
240 self.destination = ConfigSelection(default = default, choices = choices)
242 def pathSelected(self, res):
244 if res not in self.destination.choices:
245 self.destination.choices.append(res)
246 self.destination.description[res] = res
247 self.destination.value = res
249 def chooseDestination(self):
250 from Screens.LocationBox import MovieLocationBox
252 self.session.openWithCallback(
255 _("Choose target folder"),
256 self.destination.value,
257 minFree = 100 # Same requirement as in Screens.TimerEntry
260 class AutoTimerEditor(Screen, ConfigListScreen, AutoTimerEditorBase):
263 skin = """<screen name="AutoTimerEdit" title="Edit AutoTimer" position="75,155" size="565,280">
264 <widget name="config" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
265 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
266 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
267 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
268 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
269 <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" />
270 <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" />
271 <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" />
272 <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" />
275 def __init__(self, session, timer, editingDefaults = False):
276 Screen.__init__(self, session)
278 AutoTimerEditorBase.__init__(self, timer, editingDefaults)
281 self.setup_title = "AutoTimer Editor"
282 self.onChangedEntry = []
284 # We might need to change shown items, so add some notifiers
285 self.timespan.addNotifier(self.reloadList, initial_call = False)
286 self.offset.addNotifier(self.reloadList, initial_call = False)
287 self.duration.addNotifier(self.reloadList, initial_call = False)
288 self.afterevent.addNotifier(self.reloadList, initial_call = False)
289 self.afterevent_timespan.addNotifier(self.reloadList, initial_call = False)
290 self.counter.addNotifier(self.reloadList, initial_call = False)
291 self.useDestination.addNotifier(self.reloadList, initial_call = False)
295 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
298 self["key_red"] = Button(_("Cancel"))
299 self["key_green"] = Button(_("OK"))
300 self["key_yellow"] = Button()
301 self["key_blue"] = Button()
304 self.renameServiceButton()
305 self.renameFilterButton()
308 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
310 "cancel": self.cancel,
311 "save": self.maybeSave,
313 "yellow": self.editFilter,
314 "blue": self.editServices
321 def renameFilterButton(self):
323 self["key_yellow"].setText(_("Edit Filters"))
325 self["key_yellow"].setText(_("Add Filters"))
327 def renameServiceButton(self):
328 if self.serviceRestriction:
329 self["key_blue"].setText(_("Edit Services"))
331 self["key_blue"].setText(_("Add Services"))
334 for x in self.onChangedEntry:
340 def getCurrentEntry(self):
341 return self["config"].getCurrent()[0]
343 def getCurrentValue(self):
344 return str(self["config"].getCurrent()[1].getText())
346 def createSummary(self):
350 # First three entries are only showed when not editing defaults
352 if not self.editingDefaults:
354 getConfigListEntry(_("Enabled"), self.enabled),
355 getConfigListEntry(_("Description"), self.name),
356 getConfigListEntry(_("Match Title"), self.match),
360 getConfigListEntry(_("Timer Type"), self.justplay),
361 getConfigListEntry(_("Only match during Timespan"), self.timespan)
364 # Only allow editing timespan when it's enabled
365 if self.timespan.value:
367 getConfigListEntry(_("Begin of Timespan"), self.timespanbegin),
368 getConfigListEntry(_("End of Timespan"), self.timespanend)
371 self.list.append(getConfigListEntry(_("Custom offset"), self.offset))
373 # Only allow editing offsets when it's enabled
374 if self.offset.value:
376 getConfigListEntry(_("Offset before recording (in m)"), self.offsetbegin),
377 getConfigListEntry(_("Offset after recording (in m)"), self.offsetend)
380 self.list.append(getConfigListEntry(_("Set maximum Duration"), self.duration))
382 # Only allow editing maxduration when it's enabled
383 if self.duration.value:
384 self.list.append(getConfigListEntry(_("Maximum Duration (in m)"), self.durationlength))
386 self.list.append(getConfigListEntry(_("After event"), self.afterevent))
388 # Only allow setting afterevent timespan when afterevent is active
389 if self.afterevent.value != "default":
390 self.list.append(getConfigListEntry(_("Execute after Event during Timespan"), self.afterevent_timespan))
392 # Only allow editing timespan when it's enabled
393 if self.afterevent_timespan.value:
395 getConfigListEntry(_("Begin of after Event Timespan"), self.afterevent_timespanbegin),
396 getConfigListEntry(_("End of after Event Timespan"), self.afterevent_timespanend)
399 self.list.append(getConfigListEntry(_("Record a maximum of x times"), self.counter))
401 # Only allow setting matchLeft when counting hits
402 if self.counter.value:
403 if not self.editingDefaults:
404 self.list.append(getConfigListEntry(_("Ammount of recordings left"), self.counterLeft))
405 self.list.append(getConfigListEntry(_("Reset Count"), self.counterFormatString))
407 self.list.append(getConfigListEntry(_("Require Description to be unique"), self.avoidDuplicateDescription))
409 # We always add this option though its expert only in enigma2
410 self.list.append(getConfigListEntry(_("Use a custom location"), self.useDestination))
411 if self.useDestination.value:
412 self.list.append(getConfigListEntry(_("Custom Location"), self.destination))
414 def reloadList(self, value):
416 self["config"].setList(self.list)
418 def editFilter(self):
419 self.session.openWithCallback(
420 self.editFilterCallback,
421 AutoTimerFilterEditor,
427 def editFilterCallback(self, ret):
429 self.filterSet = ret[0]
430 self.excludes = ret[1]
431 self.includes = ret[2]
432 self.renameFilterButton()
434 def editServices(self):
435 self.session.openWithCallback(
436 self.editServicesCallback,
437 AutoTimerServiceEditor,
438 self.serviceRestriction,
443 def editServicesCallback(self, ret):
445 self.serviceRestriction = ret[0]
446 self.services = ret[1][0]
447 self.bouquets = ret[1][1]
448 self.renameServiceButton()
451 cur = self["config"].getCurrent()
453 if cur == self.destination:
454 self.chooseDestination()
456 ConfigListScreen.keyOK(self)
459 if self["config"].isChanged():
460 self.session.openWithCallback(
463 _("Really close without saving settings?")
468 def cancelConfirm(self, ret):
473 # Check if any match is set
474 if not self.match.value.strip():
477 _("The match attribute is mandatory."),
478 type = MessageBox.TYPE_ERROR,
481 # Check if we have a trailing whitespace
482 elif self.match.value[-1:] == " ":
483 self.session.openWithCallback(
486 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (self.match.value)
492 def saveCallback(self, ret):
495 self.match.value = self.match.value.rstrip()
497 # Don't to anything if MessageBox was canceled!
501 self.timer.match = self.match.value
504 self.timer.name = self.name.value.strip() or self.timer.match
507 self.timer.enabled = self.enabled.value
510 self.timer.justplay = self.justplay.value == "zap"
513 if self.timespan.value:
514 start = self.timespanbegin.value
515 end = self.timespanend.value
516 self.timer.timespan = (start, end)
518 self.timer.timespan = None
521 if self.serviceRestriction:
522 self.timer.services = self.services
523 self.timer.bouquets = self.bouquets
525 self.timer.services = None
526 self.timer.bouquets = None
529 if self.offset.value:
530 self.timer.offset = (self.offsetbegin.value*60, self.offsetend.value*60)
532 self.timer.offset = None
535 if self.afterevent.value == "default":
536 self.timer.afterevent = []
538 afterevent = {"nothing": AFTEREVENT.NONE, "deepstandby": AFTEREVENT.DEEPSTANDBY, "standby": AFTEREVENT.STANDBY}[self.afterevent.value]
539 # AfterEvent Timespan
540 if self.afterevent_timespan.value:
541 start = self.afterevent_timespanbegin.value
542 end = self.afterevent_timespanend.value
543 self.timer.afterevent = [(afterevent, (start, end))]
545 self.timer.afterevent = [(afterevent, None)]
548 if self.duration.value:
549 self.timer.maxduration = self.durationlength.value*60
551 self.timer.maxduration = None
555 self.timer.exclude = self.excludes
556 self.timer.include = self.includes
558 self.timer.exclude = None
559 self.timer.include = None
562 if self.counter.value:
563 self.timer.matchCount = self.counter.value
564 if self.counterLeft.value <= self.counter.value:
565 self.timer.matchLeft = self.counterLeft.value
567 self.timer.matchLeft = self.counter.value
568 if self.counterFormatString.value:
569 self.timer.matchFormatString = self.counterFormatString.value
571 self.timer.matchFormatString = ''
573 self.timer.matchCount = 0
574 self.timer.matchLeft = 0
575 self.timer.matchFormatString = ''
577 self.timer.avoidDuplicateDescription = int(self.avoidDuplicateDescription.value)
579 if self.useDestination.value:
580 self.timer.destination = self.destination.value
582 self.timer.destination = None
585 self.close(self.timer)
587 class AutoTimerFilterEditor(Screen, ConfigListScreen):
588 """Edit AutoTimer Filter"""
590 skin = """<screen name="AutoFilterEditor" title="Edit AutoTimer Filters" position="75,150" size="565,245">
591 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
592 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
593 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
594 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
595 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
596 <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" />
597 <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" />
598 <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" />
599 <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" />
602 def __init__(self, session, filterset, excludes, includes):
603 Screen.__init__(self, session)
606 self.setup_title = "AutoTimer Filters"
607 self.onChangedEntry = []
609 self.typeSelection = ConfigSelection(choices = [("title", _("in Title")), ("short", _("in Shortdescription")), ("desc", _("in Description")), ("day", _("on Weekday"))])
610 self.typeSelection.addNotifier(self.refresh, initial_call = False)
612 self.enabled = ConfigEnableDisable(default = filterset)
614 self.excludes = excludes
615 self.includes = includes
619 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
622 self["key_red"] = Button(_("Cancel"))
623 self["key_green"] = Button(_("Save"))
624 self["key_yellow"] = Button(_("delete"))
625 self["key_blue"] = Button(_("New"))
628 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
630 "cancel": self.cancel,
632 "yellow": self.remove,
641 for x in self.onChangedEntry:
647 def getCurrentEntry(self):
648 return self["config"].getCurrent()[0]
650 def getCurrentValue(self):
651 return str(self["config"].getCurrent()[1].getText())
653 def createSummary(self):
656 def saveCurrent(self):
657 del self.excludes[self.idx][:]
658 del self.includes[self.idx][:]
660 # Warning, accessing a ConfigListEntry directly might be considered evil!
663 for item in self["config"].getList()[:]:
665 # Skip empty entries (and those which are no filters)
666 if item[1].value == "" or idx < 2:
668 elif idx < self.lenExcludes:
669 self.excludes[self.idx].append(item[1].value.encode("UTF-8"))
671 self.includes[self.idx].append(item[1].value.encode("UTF-8"))
673 def refresh(self, *args, **kwargs):
677 self["config"].setList(self.list)
679 def reloadList(self):
681 getConfigListEntry(_("Enable Filtering"), self.enabled),
682 getConfigListEntry(_("Filter"), self.typeSelection)
685 if self.typeSelection.value == "day":
688 # Weekdays are presented as ConfigSelection
690 getConfigListEntry(_("Exclude"), ConfigSelection(choices = weekdays, default = x))
691 for x in self.excludes[3]
693 self.lenExcludes = len(self.list)
695 getConfigListEntry(_("Include"), ConfigSelection(choices = weekdays, default = x))
696 for x in self.includes[3]
699 elif self.typeSelection.value == "title":
701 elif self.typeSelection.value == "short":
703 else: # self.typeSelection.value == "desc":
707 getConfigListEntry(_("Exclude"), ExtendedConfigText(default = x, fixed_size = False))
708 for x in self.excludes[self.idx]
710 self.lenExcludes = len(self.list)
712 getConfigListEntry(_("Include"), ExtendedConfigText(default = x, fixed_size = False))
713 for x in self.includes[self.idx]
717 idx = self["config"].getCurrentIndex()
719 if idx < self.lenExcludes:
720 self.lenExcludes -= 1
722 list = self["config"].getList()
723 list.remove(self["config"].getCurrent())
724 self["config"].setList(list)
727 self.session.openWithCallback(
730 _("Select type of Filter"),
737 def typeSelected(self, ret):
739 list = self["config"].getList()
742 pos = self.lenExcludes
743 self.lenExcludes += 1
749 if self.typeSelection.value == "day":
750 entry = getConfigListEntry(text, ConfigSelection(choices = weekdays))
752 entry = getConfigListEntry(text, ExtendedConfigText(fixed_size = False))
754 list.insert(pos, entry)
755 self["config"].setList(list)
758 if self["config"].isChanged():
759 self.session.openWithCallback(
762 _("Really close without saving settings?")
767 def cancelConfirm(self, ret):
780 class AutoTimerServiceEditor(Screen, ConfigListScreen):
781 """Edit allowed Services of a AutoTimer"""
783 skin = """<screen name="AutoTimerServiceEditor" title="Edit AutoTimer Services" position="75,150" size="565,245">
784 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
785 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
786 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
787 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
788 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
789 <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" />
790 <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" />
791 <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" />
792 <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" />
795 def __init__(self, session, servicerestriction, servicelist, bouquetlist):
796 Screen.__init__(self, session)
799 self.setup_title = "AutoTimer Services"
800 self.onChangedEntry = []
807 self.enabled = ConfigEnableDisable(default = servicerestriction)
808 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
809 self.typeSelection.addNotifier(self.refresh, initial_call = False)
813 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
816 self["key_red"] = Button(_("Cancel"))
817 self["key_green"] = Button(_("OK"))
818 self["key_yellow"] = Button(_("delete"))
819 self["key_blue"] = Button(_("New"))
822 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
824 "cancel": self.cancel,
826 "yellow": self.remove,
835 def saveCurrent(self):
836 del self.services[self.idx][:]
838 # Warning, accessing a ConfigListEntry directly might be considered evil!
840 myl = self["config"].getList()[:]
844 self.services[self.idx].append(item[1].value)
846 def refresh(self, *args, **kwargs):
850 self["config"].setList(self.list)
852 def reloadList(self):
854 getConfigListEntry(_("Enable Service Restriction"), self.enabled),
855 getConfigListEntry(_("Editing"), self.typeSelection)
858 if self.typeSelection.value == "channels":
860 else: # self.typeSelection.value == "bouquets":
864 getConfigListEntry(_("Record on"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
865 for x in self.services[self.idx]
869 for x in self.onChangedEntry:
875 def getCurrentEntry(self):
876 return self["config"].getCurrent()[0]
878 def getCurrentValue(self):
879 return str(self["config"].getCurrent()[1].getText())
881 def createSummary(self):
885 if self["config"].getCurrentIndex() != 0:
886 list = self["config"].getList()
887 list.remove(self["config"].getCurrent())
888 self["config"].setList(list)
891 if self.typeSelection.value == "channels":
892 self.session.openWithCallback(
893 self.finishedServiceSelection,
894 SimpleChannelSelection,
895 _("Select channel to record on")
897 else: # self.typeSelection.value == "bouquets":
898 self.session.openWithCallback(
899 self.finishedServiceSelection,
900 SimpleBouquetSelection,
901 _("Select bouquet to record on")
904 def finishedServiceSelection(self, *args):
906 list = self["config"].getList()
907 sname = args[0].toString()
909 if self.typeSelection.value == "channels":
910 # strip all after last : when adding a channel
911 pos = sname.rfind(':')
913 sname = sname[:pos+1]
915 list.append(getConfigListEntry(_("Record on"), ConfigSelection(choices = [(sname, ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])))
916 self["config"].setList(list)
919 if self["config"].isChanged():
920 self.session.openWithCallback(
923 _("Really close without saving settings?")
928 def cancelConfirm(self, ret):
940 def addAutotimerFromEvent(session, evt = None, service = None):
941 from AutoTimerComponent import AutoTimerComponent
942 from AutoTimerImporter import AutoTimerImporter
943 from plugin import autotimer
945 # Create instance if needed
946 if autotimer is None:
947 from AutoTimer import AutoTimer
948 autotimer = AutoTimer()
951 match = evt and evt.getEventName() or ""
952 name = match or "New AutoTimer"
954 if service is not None:
955 service = str(service)
956 # strip all after last :
957 pos = service.rfind(':')
959 service = service[:pos+1]
961 sref = ServiceReference(service)
963 # timespan defaults to +- 1h
964 begin = evt.getBeginTime()-3600
965 end = begin + evt.getDuration()+7200
969 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-)
971 session.openWithCallback(
975 autotimer.getUniqueId(), # Id
980 match, # Proposed Match
981 begin, # Proposed Begin
983 None, # Proposed Disabled
984 sref, # Proposed ServiceReference
985 None, # Proposed afterEvent
986 None, # Proposed justplay
987 None # Proposed dirname, can we get anything useful here?
990 def addAutotimerFromService(session, service = None):
991 from AutoTimerComponent import AutoTimerComponent
992 from AutoTimerImporter import AutoTimerImporter
993 from plugin import autotimer
995 # Create instance if needed
996 if autotimer is None:
997 from AutoTimer import AutoTimer
998 autotimer = AutoTimer()
1001 serviceHandler = eServiceCenter.getInstance()
1002 info = serviceHandler.info(service)
1004 match = info and info.getName(service) or ""
1005 name = match or "New AutoTimer"
1006 sref = info and info.getInfoString(service, iServiceInformation.sServiceref)
1008 # strip all after last :
1009 pos = sref.rfind(':')
1013 sref = ServiceReference(sref)
1015 begin = info.getInfo(service, iServiceInformation.sTimeCreate)
1016 end = begin + info.getLength(service)
1020 # XXX: we might want to make sure that we actually collected any data because the importer does not do so :-)
1022 session.openWithCallback(
1026 autotimer.getUniqueId(), # Id
1031 match, # Proposed Match
1032 begin, # Proposed Begin
1034 None, # Proposed Disabled
1035 sref, # Proposed ServiceReference
1036 None, # Proposed afterEvent
1037 None, # Proposed justplay
1038 None # Proposed dirname, can we get anything useful here?
1041 def importerCallback(ret):
1045 session.openWithCallback(
1051 # Remove instance if not running in background
1052 if not config.plugins.autotimer.autopoll.value:
1053 from plugin import autotimer
1056 def editorCallback(ret):
1058 from plugin import autotimer
1060 # Create instance if needed (should have been created by addAutotimerFrom* above though)
1061 if autotimer is None:
1062 from AutoTimer import AutoTimer
1063 autotimer = AutoTimer()
1068 # Remove instance if not running in background
1069 if not config.plugins.autotimer.autopoll.value:
1070 # Save xml (as long as we added something)
1071 ret and autotimer and autotimer.writeXml()