1 # for localized messages
5 from Screens.MessageBox import MessageBox
8 from Components.config import config, ConfigSubsection, ConfigEnableDisable, \
9 ConfigNumber, ConfigSelection, ConfigYesNo
12 from Components.PluginComponent import plugins
13 from Plugins.Plugin import PluginDescriptor
15 # Initialize Configuration
16 config.plugins.autotimer = ConfigSubsection()
17 config.plugins.autotimer.autopoll = ConfigEnableDisable(default = False)
18 config.plugins.autotimer.interval = ConfigNumber(default = 3)
19 config.plugins.autotimer.refresh = ConfigSelection(choices = [
21 ("auto", _("Only AutoTimers created during this session")),
22 ("all", _("All non-repeating timers"))
25 config.plugins.autotimer.try_guessing = ConfigEnableDisable(default = True)
26 config.plugins.autotimer.editor = ConfigSelection(choices = [
27 ("plain", _("Classic")),
28 ("wizard", _("Wizard"))
31 config.plugins.autotimer.disabled_on_conflict = ConfigEnableDisable(default = False)
32 config.plugins.autotimer.show_in_extensionsmenu = ConfigYesNo(default = False)
33 config.plugins.autotimer.fastscan = ConfigYesNo(default = False)
34 config.plugins.autotimer.notifconflict = ConfigYesNo(default = True)
35 config.plugins.autotimer.maxdaysinfuture = ConfigNumber(default = 0)
36 config.plugins.autotimer.show_help = ConfigYesNo(default = True)
44 return _("AutoTimer Help")
49 _("Welcome to the AutoTimer-Plugin"),
50 _("This help screen is supposed to give you a quick look at everything the AutoTimer has to offer.\nYou can abort it at any time by pressing the RED or EXIT button on your remote control or bring it up at a later point by selecting it from the control menu using the MENU button from the regular entry point of the plugin (more on that later).\n\n\nBut you really should consider to take the few minutes it takes to read these help pages.")
53 _("The \"Overview\""),
54 _("The AutoTimer overview is the standard entry point to this plugin.\n\nIf AutoTimers are configured you can choose them from a list to change them (OK button on your remove) or remove them (YELLOW button on your remote).\nNew Timers can be added by pressing the BLUE button and the control menu can be opened using the MENU button.\n\nWhen leaving the plugin using the GREEN button it will search the EPG for matching events ONCE. To configure a regular search interval of the plugin to search for events open the control menu and enter the plugin setup.")
57 _("What is this \"control menu\" you keep talking about?"),
58 _("The control menu hides less frequently used options of the plugin, including the configuration and default settings for new AutoTimers.\n\nWhile you can just open the menu and take a look for yourself, let's go through the available options:\n - Help:\n What you are looking at right now\n - Preview:\n Simulate EPG search, helps finding errors in your setup.\n - Import existing Timer:\n Create a new AutoTimer based on an existing regular timer.\n - Import from EPG:\n Create an AutoTimer based on an EPG event.\n - Setup:\n Generic configuration of the plugin.\n - Edit new timer defaults:\n Configure default values for new AutoTimers.\n - Create a new timer using the wizard/classic editor:\n Use the non-default editor to create a new AutoTimer.")
62 _("This screen should be pretty straight-forward. If the option name does not give its meaning away there should be an explanation for each of them when you select them. If there is no visible explanation this is most likely a skin issue and please try if the default skin fixes the issue.\n\nA lot of effort has been put in making the parameters as easy to understand as possible, so give reading them a try ;-).")
65 _("Wizard or Classic Editor?"),
66 _("This is mostly a matter of taste.\nThe Wizard provides you with a reduced set of options and presents them in smaller sets at a time. It is mostly aimed at users not very experienced with this plugin or the \"expert\" level features of enigma2.\n\nYou can check out the \"classic\" editor by opening an existing timer from the overview and if you prefer this view over the wizard you can change the default editor in the setup dialog.")
70 _("You now know almost everything there is to know about the AutoTimer-Plugin.\n\nAs a final hint I can't stress how important it is to take a look at the help texts that are shown in the setup dialogs as they cover the most frequently asked questions. Surprisingly even after the hints were added ;-).")
75 from Plugins.SystemPlugins.MPHelp import registerHelp, HelpPage
76 except ImportError, ie:
77 print "[AutoTimer] Unable to find MPHelp, help not available!"
79 registerHelp(getHelpName, getHelpText, "AutoTimerHelp")
83 def autostart(reason, **kwargs):
88 if config.plugins.autotimer.autopoll.value and reason == 0:
89 # Initialize AutoTimer
90 from AutoTimer import AutoTimer
91 autotimer = AutoTimer()
94 from AutoPoller import AutoPoller
95 autopoller = AutoPoller()
100 if autopoller is not None:
104 if autotimer is not None:
105 # We re-read the config so we won't save wrong information
109 # XXX: we should at least dump the error
119 def main(session, **kwargs):
123 if autotimer is None:
124 from AutoTimer import AutoTimer
125 autotimer = AutoTimer()
129 except SyntaxError, se:
132 _("Your config file is not well-formed:\n%s") % (str(se)),
133 type = MessageBox.TYPE_ERROR,
138 # Do not run in background while editing, this might screw things up
139 if autopoller is not None:
142 from AutoTimerOverview import AutoTimerOverview
143 session.openWithCallback(
149 def editCallback(session):
153 # XXX: canceling of GUI (Overview) won't affect config values which might have been changed - is this intended?
155 # Don't parse EPG if editing was canceled
156 if session is not None:
158 ret = autotimer.parseEPG()
161 _("Found a total of %d matching Events.\n%d Timer were added and %d modified, %d conflicts encountered.") % (ret[0], ret[1], ret[2], len(ret[4])),
162 type = MessageBox.TYPE_INFO,
169 # Start autopoller again if wanted
170 if config.plugins.autotimer.autopoll.value:
171 if autopoller is None:
172 from AutoPoller import AutoPoller
173 autopoller = AutoPoller()
174 autopoller.start(initial = False)
175 # Remove instance if not running in background
181 def movielist(session, service, **kwargs):
182 from AutoTimerEditor import addAutotimerFromService
183 addAutotimerFromService(session, service)
186 def eventinfo(session, servicelist, **kwargs):
187 from AutoTimerEditor import AutoTimerEPGSelection
188 ref = session.nav.getCurrentlyPlayingServiceReference()
189 session.open(AutoTimerEPGSelection, ref)
191 # XXX: we need this helper function to identify the descriptor
193 def extensionsmenu(session, **kwargs):
194 main(session, **kwargs)
196 def housekeepingExtensionsmenu(el):
198 plugins.addPlugin(extDescriptor)
200 plugins.removePlugin(extDescriptor)
202 config.plugins.autotimer.show_in_extensionsmenu.addNotifier(housekeepingExtensionsmenu, initial_call = False, immediate_feedback = True)
203 extDescriptor = PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = extensionsmenu, needsRestart = False)
205 def Plugins(**kwargs):
207 PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart, needsRestart = False),
208 PluginDescriptor(name="AutoTimer", description = _("Edit Timers and scan for new Events"), where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc = main, needsRestart = False),
209 PluginDescriptor(name="AutoTimer", description= _("add AutoTimer..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc = movielist, needsRestart = False),
210 PluginDescriptor(name=_("add AutoTimer..."), where = PluginDescriptor.WHERE_EVENTINFO, fnc = eventinfo, needsRestart = False),
212 if config.plugins.autotimer.show_in_extensionsmenu.value:
213 l.append(extDescriptor)