New configs: Every weekday is now configureable (download: yes/no)
[enigma2-plugins.git] / rsdownloader / src / RSConfig.py
1 ##\r
2 ## RS Downloader\r
3 ## by AliAbdul\r
4 ##\r
5 from Components.ActionMap import ActionMap\r
6 from Components.config import config, ConfigText, ConfigYesNo, ConfigClock, ConfigSubsection, getConfigListEntry\r
7 from Components.ConfigList import ConfigListScreen\r
8 from Components.Label import Label
9 from RSTranslation import _, TitleScreen\r
10 from time import time\r
11 \r
12 ##############################################################################\r
13 \r
14 config.plugins.RSDownloader = ConfigSubsection()
15 config.plugins.RSDownloader.onoff = ConfigYesNo(default=True)\r
16 config.plugins.RSDownloader.username = ConfigText(default="", fixed_size=False)\r
17 config.plugins.RSDownloader.password = ConfigText(default="", fixed_size=False)\r
18 config.plugins.RSDownloader.lists_directory = ConfigText(default="/media/cf/rs/lists/", fixed_size=False)\r
19 config.plugins.RSDownloader.downloads_directory = ConfigText(default="/media/cf/rs/downloads", fixed_size=False)
20 config.plugins.RSDownloader.ignore_time = ConfigYesNo(default=False)\r
21 config.plugins.RSDownloader.start_time = ConfigClock(default=time())\r
22 config.plugins.RSDownloader.end_time = ConfigClock(default=time())
23 config.plugins.RSDownloader.download_monday = ConfigYesNo(default=True)
24 config.plugins.RSDownloader.download_tuesday = ConfigYesNo(default=True)
25 config.plugins.RSDownloader.download_wednesday = ConfigYesNo(default=True)
26 config.plugins.RSDownloader.download_thursday = ConfigYesNo(default=True)
27 config.plugins.RSDownloader.download_friday = ConfigYesNo(default=True)
28 config.plugins.RSDownloader.download_saturday = ConfigYesNo(default=True)
29 config.plugins.RSDownloader.download_sunday = ConfigYesNo(default=True)\r
30 config.plugins.RSDownloader.write_log = ConfigYesNo(default=True)
31 config.plugins.RSDownloader.reconnect_fritz = ConfigYesNo(default=False)\r
32 \r
33 ##############################################################################\r
34 \r
35 class RSConfig(ConfigListScreen, TitleScreen):\r
36         skin = """\r
37                 <screen position="80,170" size="560,270" title="RS Downloader">\r
38                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />\r
39                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />\r
40                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />\r
41                         <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />\r
42                         <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />\r
43                         <widget name="config" position="0,45" size="560,220" scrollbarMode="showOnDemand" />\r
44                 </screen>"""\r
45 \r
46         def __init__(self, session):\r
47                 TitleScreen.__init__(self, session)\r
48                 \r
49                 self["key_green"] = Label(_("Save"))\r
50                 \r
51                 list = []\r
52                 list.append(getConfigListEntry(_("Download in the background:"), config.plugins.RSDownloader.onoff))\r
53                 list.append(getConfigListEntry(_("Username:"), config.plugins.RSDownloader.username))\r
54                 list.append(getConfigListEntry(_("Password:"), config.plugins.RSDownloader.password))\r
55                 list.append(getConfigListEntry(_("Lists directory:"), config.plugins.RSDownloader.lists_directory))\r
56                 list.append(getConfigListEntry(_("Downloads directory:"), config.plugins.RSDownloader.downloads_directory))\r
57                 list.append(getConfigListEntry(_("Ignore download times:"), config.plugins.RSDownloader.ignore_time))\r
58                 list.append(getConfigListEntry(_("Allow downloading on monday:"), config.plugins.RSDownloader.download_monday))\r
59                 list.append(getConfigListEntry(_("Allow downloading on tuesday:"), config.plugins.RSDownloader.download_tuesday))\r
60                 list.append(getConfigListEntry(_("Allow downloading on wednesday:"), config.plugins.RSDownloader.download_wednesday))\r
61                 list.append(getConfigListEntry(_("Allow downloading on thursday:"), config.plugins.RSDownloader.download_thursday))\r
62                 list.append(getConfigListEntry(_("Allow downloading on friday:"), config.plugins.RSDownloader.download_friday))\r
63                 list.append(getConfigListEntry(_("Allow downloading on saturday:"), config.plugins.RSDownloader.download_saturday))\r
64                 list.append(getConfigListEntry(_("Allow downloading on sunday:"), config.plugins.RSDownloader.download_sunday))
65                 list.append(getConfigListEntry(_("Don't download before:"), config.plugins.RSDownloader.start_time))\r
66                 list.append(getConfigListEntry(_("Don't download after:"), config.plugins.RSDownloader.end_time))\r
67                 list.append(getConfigListEntry(_("Write log:"), config.plugins.RSDownloader.write_log))
68                 list.append(getConfigListEntry(_("Reconnect fritz.Box before downloading:"), config.plugins.RSDownloader.reconnect_fritz))\r
69                 ConfigListScreen.__init__(self, list)\r
70                 \r
71                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "cancel": self.exit}, -1)\r
72 \r
73         def save(self):\r
74                 for x in self["config"].list:\r
75                         x[1].save()\r
76                 self.close()\r
77 \r
78         def exit(self):\r
79                 for x in self["config"].list:\r
80                         x[1].cancel()\r
81                 self.close()\r