1 # -*- coding: utf-8 -*-
3 # AutomaticVolumeAdjustment E2
7 # Coded by Dr.Best (c) 2010
8 # Support: www.dreambox-tools.info
10 # This plugin is licensed under the Creative Commons
11 # Attribution-NonCommercial-ShareAlike 3.0 Unported
12 # License. To view a copy of this license, visit
13 # http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
14 # Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
16 # Alternatively, this plugin may be distributed and executed on hardware which
17 # is licensed by Dream Multimedia GmbH.
19 # This plugin is NOT free software. It is open source, you are allowed to
20 # modify it (if you keep the license), but it may not be commercially
21 # distributed other than under the conditions noted above.
23 from Components.config import ConfigSubsection, ConfigText, \
24 config, ConfigInteger, Config, ConfigSubList, ConfigDirectory, NoSave, ConfigYesNo
25 from os import path as os_path, open as os_open, close as os_close, O_RDWR as os_O_RDWR, O_CREAT as os_O_CREAT
27 class AutomaticVolumeAdjustmentConfig():
29 self.CONFIG_FILE = '/usr/lib/enigma2/python/Plugins/SystemPlugins/AutomaticVolumeAdjustment/config'
33 # load config file and initialize
34 def loadConfigFile(self):
35 print "[AutomaticVolumeAdjustmentConfig] Loading config file..."
36 self.config = Config()
37 if not os_path.exists(self.CONFIG_FILE):
38 fd = os_open( self.CONFIG_FILE, os_O_RDWR|os_O_CREAT)
40 self.config.loadFromFile(self.CONFIG_FILE)
41 self.config.entriescount = ConfigInteger(0)
42 self.config.Entries = ConfigSubList()
43 self.config.enable = ConfigYesNo(default = False)
44 self.config.adustvalue = ConfigInteger(default=25, limits=(0,50))
45 self.config.mpeg_max_volume = ConfigInteger(default=100, limits=(10,100))
46 self.config.show_volumebar = ConfigYesNo(default = False)
50 count = self.config.entriescount.value
54 self.initEntryConfig()
56 print "[AutomaticVolumeAdjustmentConfig] Loaded %s entries from config file..." % count
58 def initEntryConfig(self):
59 self.config.Entries.append(ConfigSubsection())
60 i = len(self.config.Entries) - 1
61 self.config.Entries[i].servicereference = ConfigText(default = "")
62 self.config.Entries[i].name = NoSave(ConfigDirectory(default = _("Press OK to select a service")))
63 self.config.Entries[i].adjustvalue = ConfigInteger(default=25, limits=(5,50))
64 return self.config.Entries[i]
66 def remove(self, configItem):
67 self.config.entriescount.value = self.config.entriescount.value - 1
68 self.config.entriescount.save()
69 self.config.Entries.remove(configItem)
70 self.config.Entries.save()
74 print "[AutomaticVolumeAdjustmentConfig] saving config file..."
75 self.config.saveToFile(self.CONFIG_FILE)