class editExportEntry(Screen, ConfigListScreen): skin = """ <screen name="editExportEntry" position="center,center" size="560,350" title="edit Export Entry"> <widget name="config" position="10,10" size="540,150" scrollbarMode="showOnDemand" /> <widget name="ButtonGreentext" position="50,270" size="460,21" halign="left" zPosition="10" font="Regular;21" transparent="1" /> <widget name="ButtonGreen" pixmap="skin_default/buttons/button_green.png" position="30,273" zPosition="10" size="15,16" transparent="1" alphatest="on" /> <widget name="ButtonRedtext" position="50,300" size="460,21" halign="left" zPosition="10" font="Regular;21" transparent="1" /> <widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="30,303" zPosition="10" size="15,16" transparent="1" alphatest="on" /> <ePixmap pixmap="skin_default/bottombar.png" position="10,250" size="540,120" zPosition="1" transparent="1" alphatest="on" /> </screen>""" def __init__(self, session, exportDir, client, options): self.skin = editExportEntry.skin self.session = session Screen.__init__(self, session) nfsoptions = [\ "ro,sync", "rw,sync", "ro,async", "rw,async", "ro,no_root_squash", "rw,no_root_squash", "ro,no_subtree_check", "rw,no_subtree_check", "ro,insecure", "rw,insecure", "ro,insecure,no_subtree_check", "rw,insecure,no_subtree_check", "ro,sync,no_subtree_check", "rw,sync,no_subtree_check", "ro,async,no_subtree_check", "rw,async,no_subtree_check", "ro,no_root_squash,no_subtree_check", "rw,no_root_squash,no_subtree_check", "ro,no_root_squash,sync", "rw,no_root_squash,sync", "ro,no_root_squash,sync,no_subtree_check", "rw,no_root_squash,sync,no_subtree_check", "ro,no_root_squash,async", "rw,no_root_squash,async", "ro,no_root_squash,async,no_subtree_check", "rw,no_root_squash,async,no_subtree_check"] optionsEntrys = {} for x in nfsoptions: optionsEntrys[x] = x clientIP = [192, 168, 0, 0] self.netmask = '' tmp = client.split('/') if len(tmp) > 1: client = tmp[0] self.netmask = tmp[1] if client == '*': everyIP = True else: everyIP = False theIP = client.split('.') clientIP = [] for x in theIP: clientIP.append(int(x)) self.exportDirConfigEntry = NoSave(ConfigDirectory(exportDir)) self.everyIPConfigEntry = NoSave(ConfigEnableDisable(default=everyIP)) self.clientConfigEntry = NoSave(ConfigIP(clientIP)) self.optionsConfigEntry = NoSave( ConfigSelection(optionsEntrys, options)) ConfigListScreen.__init__(self, []) self.createSetup() self.everyIPConfigEntry.addNotifier(self.toggleEveryIP) self["actions"] = ActionMap( ["OkCancelActions", "ColorActions"], { "cancel": self.cancel, "red": self.cancel, "green": self.green, "ok": self.ok }, -2) self["ButtonGreen"] = Pixmap() self["ButtonGreentext"] = Label(_("Save and Close")) self["ButtonRed"] = Pixmap() self["ButtonRedtext"] = Label(_("Close")) def createSetup(self): self.list = [] self.list.append( getConfigListEntry(_("export directory"), self.exportDirConfigEntry)) self.list.append( getConfigListEntry(_("every ip"), self.everyIPConfigEntry)) if not self.everyIPConfigEntry.value: self.list.append( getConfigListEntry(_("client ip"), self.clientConfigEntry)) self.list.append( getConfigListEntry(_("options"), self.optionsConfigEntry)) self["config"].setList(self.list) def toggleEveryIP(self, configElement): self.createSetup() def cancel(self): self.close(False) def ok(self): if self["config"].getCurrent()[1] == self.exportDirConfigEntry: self.session.openWithCallback( self.dirSelectDlgClosed, dirSelectDlg, self.exportDirConfigEntry.value + '/') def dirSelectDlgClosed(self, path): if path != False: if path.endswith('/'): path = path[:-1] self.exportDirConfigEntry.setValue(path) def green(self): data = [] data.append(self.exportDirConfigEntry.value) if self.everyIPConfigEntry.value: ipdata = '*' else: ipdata = "%d.%d.%d.%d" % tuple(self.clientConfigEntry.value) if len(self.netmask) > 0: ipdata = ipdata + "/" + self.netmask data.append(ipdata) data.append(self.optionsConfigEntry.value) self.close(data)
class GrowleeConfiguration(Screen, ConfigListScreen): skin = """ <screen name="GrowleeConfiguration" position="center,center" size="560,400" title="Growlee Setup" > <ePixmap position="0,0" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" /> <ePixmap position="140,0" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" /> <ePixmap position="280,0" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" /> <ePixmap position="420,0" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" /> <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" /> <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" /> <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" /> <widget name="config" position="5,45" size="550,350" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session): Screen.__init__(self, session) # Buttons self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self["key_yellow"] = StaticText(_("New")) self["key_blue"] = StaticText(_("Delete")) # Summary self.setup_title = "Growlee Configuration" self.onChangedEntry = [] # Define Actions self["setupActions"] = ActionMap( ["SetupActions", "ColorActions"], {"blue": self.delete, "yellow": self.new, "cancel": self.keyCancel, "save": self.keySave}, ) self.hostElement = NoSave(ConfigSelection(choices=[(x, x.name.value) for x in config.plugins.growlee.hosts])) self.hostElement.addNotifier(self.setupList, initial_call=False) ConfigListScreen.__init__(self, [], session=session, on_change=self.changed) self.cur = self.hostElement.value # Trigger change self.setupList() self.changed() def delete(self): from Screens.MessageBox import MessageBox self.session.openWithCallback( self.deleteConfirm, MessageBox, _("Really delete this entry?\nIt cannot be recovered!") ) def deleteConfirm(self, result): if result and config.plugins.growlee.hostcount.value > 0: config.plugins.growlee.hostcount.value -= 1 config.plugins.growlee.hosts.remove(self.cur) self.hostElement.setChoices([(x, x.name.value) for x in config.plugins.growlee.hosts]) self.cur = self.hostElement.value def new(self): self.cur = addHost(_("New connection")) config.plugins.growlee.hostcount.value += 1 self.hostElement.setChoices([(x, x.name.value) for x in config.plugins.growlee.hosts]) self.hostElement.setValue(self.cur) def changed(self): for x in self.onChangedEntry: x() def setupList(self, *args): last = self.cur if self.setupList in last.protocol.notifiers: last.protocol.removeNotifier(self.setupList) cur = self.hostElement.value self.cur = cur cur.protocol.addNotifier(self.setupList, initial_call=False) l = [ getConfigListEntry(_("Host"), self.hostElement), getConfigListEntry(_("Name"), cur.name), getConfigListEntry(_("Type"), cur.protocol), getConfigListEntry(_("Minimum Priority"), cur.level), getConfigListEntry(_("Send Notifications?"), cur.enable_outgoing), ] proto = cur.protocol.value if proto == "prowl": l.append(getConfigListEntry(_("API Key"), cur.password)) else: if proto != "gntp": l.append(getConfigListEntry(_("Receive Notifications?"), cur.enable_incoming)) l.append(getConfigListEntry(_("Address"), cur.address)) if proto == "growl" or proto == "gntp": l.append(getConfigListEntry(_("Password"), cur.password)) self["config"].list = l def getCurrentEntry(self): cur = self["config"].getCurrent() return cur and cur[0] def getCurrentValue(self): cur = self["config"].getCurrent() return cur and str(cur[1].getText()) def createSummary(self): return SetupSummary def keySave(self): config.plugins.growlee.save() if self["config"].isChanged(): def doConnect(*args, **kwargs): growleeConnection.listen() d = growleeConnection.stop() if d is not None: d.addCallback(doConnect).addErrback(emergencyDisable) else: maybeConnect() self.saveAll() self.close() def close(self): if self.setupList in self.cur.protocol.notifiers: self.cur.protocol.removeNotifier(self.setupList) Screen.close(self)
class UserDialog(Screen, ConfigListScreen): skin = '\n\t\t<screen name="UserDialog" position="center,center" size="560,300" title="UserDialog">\n\t\t\t<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t\t<widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t\t<widget name="config" position="5,50" size="550,200" zPosition="1" scrollbarMode="showOnDemand" />\n\t\t\t<ePixmap pixmap="skin_default/div-h.png" position="0,270" zPosition="1" size="560,2" />\n\t\t\t<widget source="introduction" render="Label" position="10,280" size="540,21" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/>\n\t\t\t<widget name="VKeyIcon" pixmap="skin_default/buttons/key_text.png" position="10,280" zPosition="10" size="35,25" transparent="1" alphatest="on" />\n\t\t\t<widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="410,330" zPosition="1" size="1,1" transparent="1" alphatest="on" />\t\n\t\t</screen>' def __init__(self, session, plugin_path, hostinfo = None): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) self.hostinfo = hostinfo self.cache_ttl = 86400 self.cache_file = '/etc/enigma2/' + self.hostinfo + '.cache' self.createConfig() self['actions'] = NumberActionMap(['SetupActions'], {'ok': self.ok, 'back': self.close, 'cancel': self.close, 'red': self.close}, -2) self['VirtualKB'] = ActionMap(['VirtualKeyboardActions'], {'showVirtualKeyboard': self.KeyText}, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=self.session) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) self['VKeyIcon'] = Pixmap() self['HelpWindow'] = Pixmap() self['introduction'] = StaticText(_('Press OK to save settings.')) self['key_red'] = StaticText(_('Close')) def layoutFinished(self): self.setTitle(_('Enter user and password for host: ') + self.hostinfo) def convertIP(self, ip): strIP = ip.split('.') ip = [] for x in strIP: ip.append(int(x)) return ip def createConfig(self): self.usernameEntry = None self.passwordEntry = None self.username = None self.password = None if os_path.exists(self.cache_file): print 'Loading user cache from ', print self.cache_file try: self.hostdata = load_cache(self.cache_file) username = self.hostdata['username'] password = self.hostdata['password'] except: username = '******' password = '******' else: username = '******' password = '******' self.username = NoSave(ConfigText(default=username, visible_width=50, fixed_size=False)) self.password = NoSave(ConfigPassword(default=password, visible_width=50, fixed_size=False)) def createSetup(self): self.list = [] self.usernameEntry = getConfigListEntry(_('Username'), self.username) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_('Password'), self.password) self.list.append(self.passwordEntry) self['config'].list = self.list self['config'].l.setList(self.list) self['config'].onSelectionChanged.append(self.selectionChanged) def KeyText(self): if self['config'].getCurrent() == self.usernameEntry: self.session.openWithCallback(lambda x: self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title=_('Enter username:'******'config'].getCurrent() == self.passwordEntry: self.session.openWithCallback(lambda x: self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title=_('Enter password:'******'username': self.username.setValue(callback) self['config'].invalidate(self.usernameEntry) if entry == 'password': self.password.setValue(callback) self['config'].invalidate(self.passwordEntry) def newConfig(self): if self['config'].getCurrent() == self.InterfaceEntry: self.createSetup() def keyLeft(self): ConfigListScreen.keyLeft(self) def keyRight(self): ConfigListScreen.keyRight(self) def selectionChanged(self): current = self['config'].getCurrent() helpwindowpos = self['HelpWindow'].getPosition() if current[1].help_window.instance is not None: current[1].help_window.instance.move(ePoint(helpwindowpos[0], helpwindowpos[1])) def ok(self): current = self['config'].getCurrent() self.hostdata = {'username': self.username.value, 'password': self.password.value} write_cache(self.cache_file, self.hostdata) self.close(True)
class UserDialog(Screen, ConfigListScreen): skin = """ <screen name="UserDialog" position="center,center" size="560,300" title="UserDialog"> <ePixmap pixmap="buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="config" position="5,50" size="550,200" zPosition="1" scrollbarMode="showOnDemand" /> <ePixmap pixmap="div-h.png" position="0,270" zPosition="1" size="560,2" /> <widget source="introduction" render="Label" position="10,280" size="540,21" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/> <widget name="VKeyIcon" pixmap="buttons/key_text.png" position="10,280" zPosition="10" size="35,25" transparent="1" alphatest="on" /> <widget name="HelpWindow" pixmap="vkey_icon.png" position="160,250" zPosition="1" size="1,1" transparent="1" alphatest="on" /> </screen>""" def __init__(self, session, plugin_path, hostinfo=None): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) self.hostinfo = str(hostinfo) self.cache_file = '/etc/enigma2/' + self.hostinfo + '.cache' #Path to cache directory self.createConfig() self["actions"] = NumberActionMap( ["SetupActions"], { "ok": self.ok, "back": self.close, "cancel": self.close, "red": self.close, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=self.session) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Boolean(False) self["HelpWindow"] = Pixmap() self["introduction"] = StaticText(_("Press OK to save settings.")) self["key_red"] = StaticText(_("Close")) def layoutFinished(self): self.setTitle(_("Enter user and password for host: ") + self.hostinfo) def createConfig(self): username = '******' password = '******' print('Loading user cache from ', self.cache_file) try: hostdata = load_cache(self.cache_file) username = hostdata['username'] password = hostdata['password'] except: pass self.username = NoSave( ConfigText(default=username, visible_width=50, fixed_size=False)) self.password = NoSave( ConfigPassword(default=password, visible_width=50, fixed_size=False)) def createSetup(self): self.list = [] self.usernameEntry = getConfigListEntry(_("Username"), self.username) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_("Password"), self.password) self.list.append(self.passwordEntry) self["config"].list = self.list self["config"].l.setList(self.list) self["config"].onSelectionChanged.append(self.selectionChanged) def KeyText(self): if self["config"].getCurrent() == self.usernameEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title=(_("Enter username:"******"config"].getCurrent() == self.passwordEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title=(_("Enter password:"******"config"].invalidate(self.usernameEntry) if entry == 'password': self.password.setValue(callback) self["config"].invalidate(self.passwordEntry) def newConfig(self): if self["config"].getCurrent() == self.InterfaceEntry: self.createSetup() def keyLeft(self): ConfigListScreen.keyLeft(self) def keyRight(self): ConfigListScreen.keyRight(self) def selectionChanged(self): current = self["config"].getCurrent() helpwindowpos = self["HelpWindow"].getPosition() if current[1].help_window.instance is not None: current[1].help_window.instance.move( enigma.ePoint(helpwindowpos[0], helpwindowpos[1])) def ok(self): current = self["config"].getCurrent() hostdata = { 'username': self.username.value, 'password': self.password.value } write_cache(self.cache_file, hostdata) self.close(True)
class AutoMountEdit(Screen, ConfigListScreen): skin = """ <screen name="AutoMountEdit" position="center,center" size="560,450" title="MountEdit"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="config" position="5,50" size="550,250" zPosition="1" scrollbarMode="showOnDemand" /> <ePixmap pixmap="skin_default/div-h.png" position="0,420" zPosition="1" size="560,2" /> <widget source="introduction" render="Label" position="10,430" size="540,21" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/> <widget name="VKeyIcon" pixmap="skin_default/buttons/key_text.png" position="10,430" zPosition="10" size="35,25" transparent="1" alphatest="on" /> <widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="160,350" zPosition="1" size="1,1" transparent="1" alphatest="on" /> </screen>""" def __init__(self, session, plugin_path, mountinfo = None ): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) self.onChangedEntry = [ ] self.mountinfo = mountinfo if self.mountinfo is None: #Initialize blank mount enty self.mountinfo = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False, 'hdd_replacement' : False } self.applyConfigRef = None self.updateConfigRef = None self.mounts = iAutoMount.getMountsList() self.createConfig() self["actions"] = NumberActionMap(["SetupActions", "ColorActions"], { "ok": self.ok, "back": self.close, "cancel": self.close, "red": self.close, "green": self.ok, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self.list = [] ConfigListScreen.__init__(self, self.list,session = self.session) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Pixmap() self["HelpWindow"] = Pixmap() self["introduction"] = StaticText(_("Press OK to activate the settings.")) self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("Save")) self.selectionChanged() # for summary: def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self["config"].getCurrent()[0] def getCurrentValue(self): return str(self["config"].getCurrent()[1].getText()) def createSummary(self): from Screens.Setup import SetupSummary return SetupSummary def layoutFinished(self): self.setup_title = _("Mounts editor") Screen.setTitle(self, _(self.setup_title)) self["VKeyIcon"].hide() self["VirtualKB"].setEnabled(False) self["HelpWindow"].hide() # helper function to convert ips from a sring to a list of ints def convertIP(self, ip): strIP = ip.split('.') ip = [] for x in strIP: ip.append(int(x)) return ip def exit(self): self.close() def createConfig(self): self.mountusingEntry = None self.sharenameEntry = None self.mounttypeEntry = None self.activeEntry = None self.ipEntry = None self.sharedirEntry = None self.optionsEntry = None self.usernameEntry = None self.passwordEntry = None self.hdd_replacementEntry = None self.mountusing = [] self.mountusing.append(("autofs", _("AUTOFS (mount as needed)"))) self.mountusing.append(("fstab", _("FSTAB (mount at boot)"))) self.mountusing.append(("enigma2", _("Enigma2 (mount using enigma2)"))) self.mountusing.append(("old_enigma2", _("Enigma2 old format (mount using linux)"))) self.sharetypelist = [] self.sharetypelist.append(("nfs", _("NFS share"))) self.sharetypelist.append(("cifs", _("CIFS share"))) if self.mountinfo.has_key('mountusing'): mountusing = self.mountinfo['mountusing'] if mountusing is False: mountusing = "fstab" else: mountusing = "fstab" if self.mountinfo.has_key('mounttype'): mounttype = self.mountinfo['mounttype'] if mounttype is False: mounttype = "nfs" else: mounttype = "nfs" if self.mountinfo.has_key('active'): active = self.mountinfo['active'] if active == 'True': active = True if active == 'False': active = False else: active = True if self.mountinfo.has_key('ip'): if self.mountinfo['ip'] is False: ip = [192, 168, 0, 0] else: ip = self.convertIP(self.mountinfo['ip']) else: ip = [192, 168, 0, 0] if mounttype == "nfs": defaultOptions = "rw,nolock,tcp" else: defaultOptions = "rw,utf8" if self.mountinfo['sharename'] and self.mountinfo.has_key('sharename'): sharename = re_sub("\W", "", self.mountinfo['sharename']) else: sharename = "Sharename" if self.mountinfo.has_key('sharedir'): sharedir = self.mountinfo['sharedir'] else: sharedir = "/export/hdd" if self.mountinfo.has_key('options'): options = self.mountinfo['options'] else: options = defaultOptions if self.mountinfo.has_key('username'): username = self.mountinfo['username'] else: username = "" if self.mountinfo.has_key('password'): password = self.mountinfo['password'] else: password = "" if self.mountinfo.has_key('hdd_replacement'): hdd_replacement = self.mountinfo['hdd_replacement'] if hdd_replacement == 'True': hdd_replacement = True if hdd_replacement == 'False': hdd_replacement = False else: hdd_replacement = False if sharename is False: sharename = "Sharename" if sharedir is False: sharedir = "/export/hdd" if username is False: username = "" if password is False: password = "" self.old_sharename = sharename self.old_sharedir = sharedir self.mountusingConfigEntry = NoSave(ConfigSelection(self.mountusing, default = mountusing )) self.activeConfigEntry = NoSave(ConfigEnableDisable(default = active)) self.ipConfigEntry = NoSave(ConfigIP(default = ip)) self.sharenameConfigEntry = NoSave(ConfigText(default = sharename, visible_width = 50, fixed_size = False)) self.sharedirConfigEntry = NoSave(ConfigText(default = sharedir, visible_width = 50, fixed_size = False)) self.optionsConfigEntry = NoSave(ConfigText(default = defaultOptions, visible_width = 50, fixed_size = False)) if options is not False: self.optionsConfigEntry.value = options self.usernameConfigEntry = NoSave(ConfigText(default = username, visible_width = 50, fixed_size = False)) self.passwordConfigEntry = NoSave(ConfigPassword(default = password, visible_width = 50, fixed_size = False)) self.mounttypeConfigEntry = NoSave(ConfigSelection(self.sharetypelist, default = mounttype )) self.hdd_replacementConfigEntry = NoSave(ConfigYesNo(default = hdd_replacement)) def createSetup(self): self.list = [] self.mountusingEntry = getConfigListEntry(_("Mount using"), self.mountusingConfigEntry) self.list.append(self.mountusingEntry) self.activeEntry = getConfigListEntry(_("Active"), self.activeConfigEntry) self.list.append(self.activeEntry) self.sharenameEntry = getConfigListEntry(_("Local share name"), self.sharenameConfigEntry) self.list.append(self.sharenameEntry) self.mounttypeEntry = getConfigListEntry(_("Mount type"), self.mounttypeConfigEntry) self.list.append(self.mounttypeEntry) self.ipEntry = getConfigListEntry(_("Server IP"), self.ipConfigEntry) self.list.append(self.ipEntry) self.sharedirEntry = getConfigListEntry(_("Server share"), self.sharedirConfigEntry) self.list.append(self.sharedirEntry) self.hdd_replacementEntry = getConfigListEntry(_("use as HDD replacement"), self.hdd_replacementConfigEntry) self.list.append(self.hdd_replacementEntry) self.optionsEntry = getConfigListEntry(_("Mount options"), self.optionsConfigEntry) self.list.append(self.optionsEntry) if self.mounttypeConfigEntry.value == "cifs": self.usernameEntry = getConfigListEntry(_("Username"), self.usernameConfigEntry) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_("Password"), self.passwordConfigEntry) self.list.append(self.passwordEntry) self["config"].list = self.list self["config"].l.setList(self.list) self["config"].onSelectionChanged.append(self.selectionChanged) def newConfig(self): if self["config"].getCurrent() == self.mounttypeEntry: if self.mounttypeConfigEntry.value == "nfs": defaultOptions = "rw,nolock,tcp" else: defaultOptions = "rw,utf8" if self.mountinfo.has_key('options'): options = self.mountinfo['options'] else: options = defaultOptions self.optionsConfigEntry = NoSave(ConfigText(default = defaultOptions, visible_width = 50, fixed_size = False)) if options is not False: self.optionsConfigEntry.value = options self.createSetup() def KeyText(self): print "Green Pressed" if self["config"].getCurrent() == self.sharenameEntry: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'sharename'), VirtualKeyBoard, title = (_("Enter share name:")), text = self.sharenameConfigEntry.value) if self["config"].getCurrent() == self.sharedirEntry: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'sharedir'), VirtualKeyBoard, title = (_("Enter share directory:")), text = self.sharedirConfigEntry.value) if self["config"].getCurrent() == self.optionsEntry: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'options'), VirtualKeyBoard, title = (_("Enter options:")), text = self.optionsConfigEntry.value) if self["config"].getCurrent() == self.usernameEntry: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title = (_("Enter username:"******"config"].getCurrent() == self.passwordEntry: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title = (_("Enter password:"******"config"].invalidate(self.sharenameConfigEntry) if entry == 'sharedir': self.sharedirConfigEntry.setValue(callback) self["config"].invalidate(self.sharedirConfigEntry) if entry == 'options': self.optionsConfigEntry.setValue(callback) self["config"].invalidate(self.optionsConfigEntry) if entry == 'username': self.usernameConfigEntry.setValue(callback) self["config"].invalidate(self.usernameConfigEntry) if entry == 'password': self.passwordConfigEntry.setValue(callback) self["config"].invalidate(self.passwordConfigEntry) def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def selectionChanged(self): current = self["config"].getCurrent() if current == self.mountusingEntry or current == self.activeEntry or current == self.ipEntry or current == self.mounttypeEntry or current == self.hdd_replacementEntry: self["VKeyIcon"].hide() self["VirtualKB"].setEnabled(False) else: helpwindowpos = self["HelpWindow"].getPosition() if current[1].help_window.instance is not None: current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1])) self["VKeyIcon"].show() self["VirtualKB"].setEnabled(True) def ok(self): current = self["config"].getCurrent() if current == self.sharenameEntry or current == self.sharedirEntry or current == self.sharedirEntry or current == self.optionsEntry or current == self.usernameEntry or current == self.passwordEntry: if current[1].help_window.instance is not None: current[1].help_window.instance.hide() sharename = re_sub("\W", "", self.sharenameConfigEntry.value) if self.sharedirConfigEntry.value.startswith("/"): sharedir = self.sharedirConfigEntry.value[1:] else: sharedir = self.sharedirConfigEntry.value sharexists = False for data in self.mounts: if self.mounts[data]['sharename'] == self.old_sharename: sharexists = True break if self.old_sharename != self.sharenameConfigEntry.value: self.session.openWithCallback(self.updateConfig, MessageBox, _("You have changed the share name!\nUpdate existing entry and continue?\n"), default=False ) elif self.old_sharename == self.sharenameConfigEntry.value and sharexists: self.session.openWithCallback(self.updateConfig, MessageBox, _("A mount entry with this name already exists!\nUpdate existing entry and continue?\n"), default=False ) else: self.session.openWithCallback(self.applyConfig, MessageBox, _("Are you sure you want to save this network mount?\n\n") ) def updateConfig(self, ret = False): if (ret == True): sharedir = None if self.old_sharename != self.sharenameConfigEntry.value: xml_sharename = self.old_sharename else: xml_sharename = self.sharenameConfigEntry.value if self.sharedirConfigEntry.value.startswith("/"): sharedir = self.sharedirConfigEntry.value[1:] else: sharedir = self.sharedirConfigEntry.value iAutoMount.setMountsAttribute(xml_sharename, "mountusing", self.mountusingConfigEntry.value) iAutoMount.setMountsAttribute(xml_sharename, "sharename", self.sharenameConfigEntry.value) iAutoMount.setMountsAttribute(xml_sharename, "active", self.activeConfigEntry.value) iAutoMount.setMountsAttribute(xml_sharename, "ip", self.ipConfigEntry.getText()) iAutoMount.setMountsAttribute(xml_sharename, "sharedir", sharedir) iAutoMount.setMountsAttribute(xml_sharename, "mounttype", self.mounttypeConfigEntry.value) iAutoMount.setMountsAttribute(xml_sharename, "options", self.optionsConfigEntry.value) iAutoMount.setMountsAttribute(xml_sharename, "username", self.usernameConfigEntry.value) iAutoMount.setMountsAttribute(xml_sharename, "password", self.passwordConfigEntry.value) iAutoMount.setMountsAttribute(xml_sharename, "hdd_replacement", self.hdd_replacementConfigEntry.value) self.updateConfigRef = None self.updateConfigRef = self.session.openWithCallback(self.updateConfigfinishedCB, MessageBox, _("Please wait while updating your network mount..."), type = MessageBox.TYPE_INFO, enable_input = False) iAutoMount.writeMountsConfig() iAutoMount.getAutoMountPoints(self.updateConfigDataAvail, True) else: self.close() def updateConfigDataAvail(self, data): if data is True: self.updateConfigRef.close(True) def updateConfigfinishedCB(self,data): if data is True: self.session.openWithCallback(self.Updatefinished, MessageBox, _("Your network mount has been updated."), type = MessageBox.TYPE_INFO, timeout = 10) def Updatefinished(self,data): if data is not None: if data is True: self.close() def applyConfig(self, ret = False): if (ret == True): data = { 'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, \ 'username': False, 'password': False, 'mounttype' : False, 'options' : False, 'hdd_replacement' : False } data['mountusing'] = self.mountusingConfigEntry.value data['active'] = self.activeConfigEntry.value data['ip'] = self.ipConfigEntry.getText() data['sharename'] = re_sub("\W", "", self.sharenameConfigEntry.value) # "\W" matches everything that is "not numbers, letters, or underscores",where the alphabet defaults to ASCII. if self.sharedirConfigEntry.value.startswith("/"): data['sharedir'] = self.sharedirConfigEntry.value[1:] else: data['sharedir'] = self.sharedirConfigEntry.value data['options'] = self.optionsConfigEntry.value data['mounttype'] = self.mounttypeConfigEntry.value data['username'] = self.usernameConfigEntry.value data['password'] = self.passwordConfigEntry.value data['hdd_replacement'] = self.hdd_replacementConfigEntry.value self.applyConfigRef = None self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network mount..."), type = MessageBox.TYPE_INFO, enable_input = False) iAutoMount.automounts[self.sharenameConfigEntry.value] = data iAutoMount.writeMountsConfig() iAutoMount.getAutoMountPoints(self.applyConfigDataAvail, True) else: self.close() def applyConfigDataAvail(self, data): if data is True: self.applyConfigRef.close(True) def applyConfigfinishedCB(self,data): if data is True: self.session.openWithCallback(self.applyfinished, MessageBox, _("Your network mount has been activated."), type = MessageBox.TYPE_INFO, timeout = 10) def applyfinished(self,data): if data is not None: if data is True: self.close()
class AutoMountEdit(Screen, ConfigListScreen): skin = """ <screen name="AutoMountEdit" position="center,center" size="560,450" title="MountEdit"> <ePixmap pixmap="buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="config" position="5,50" size="550,250" zPosition="1" scrollbarMode="showOnDemand" /> <ePixmap pixmap="div-h.png" position="0,420" zPosition="1" size="560,2" /> <widget source="introduction" render="Label" position="10,430" size="540,21" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/> <widget source="VKeyIcon" render="Pixmap" pixmap="buttons/key_text.png" position="10,430" zPosition="10" size="35,25" transparent="1" alphatest="on"> <convert type="ConditionalShowHide" /> </widget> <widget name="HelpWindow" pixmap="vkey_icon.png" position="160,350" zPosition="1" size="1,1" transparent="1" alphatest="on" /> </screen>""" def __init__(self, session, plugin_path, mountinfo=None): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) self.mountinfo = mountinfo if self.mountinfo is None: #Initialize blank mount enty self.mountinfo = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False } self.applyConfigRef = None self.updateConfigRef = None self.mounts = iAutoMount.getMountsList() self.createConfig() self["actions"] = NumberActionMap( ["SetupActions"], { "ok": self.ok, "back": self.close, "cancel": self.close, "red": self.close, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=self.session) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Boolean(False) self["HelpWindow"] = Pixmap() self["introduction"] = StaticText( _("Press OK to activate the settings.")) self["key_red"] = StaticText(_("Cancel")) def layoutFinished(self): self.setTitle(_("Mounts editor")) self["VKeyIcon"].boolean = False self["VirtualKB"].setEnabled(False) self["HelpWindow"].hide() # helper function to convert ips from a sring to a list of ints def convertIP(self, ip): strIP = ip.split('.') ip = [] for x in strIP: ip.append(int(x)) return ip def exit(self): self.close() def createConfig(self): self.sharenameEntry = None self.mounttypeEntry = None self.activeEntry = None self.ipEntry = None self.sharedirEntry = None self.optionsEntry = None self.usernameEntry = None self.passwordEntry = None self.hdd_replacementEntry = None self.sharetypelist = [("nfs", _("NFS share")), ("cifs", _("CIFS share"))] if self.mountinfo.has_key('mounttype'): mounttype = self.mountinfo['mounttype'] if not mounttype: mounttype = "nfs" else: mounttype = "nfs" if self.mountinfo.has_key('active'): active = self.mountinfo['active'] if active == 'True': active = True if active == 'False': active = False else: active = True if self.mountinfo.has_key('ip'): if self.mountinfo['ip'] is False: ip = [192, 168, 0, 0] else: ip = self.convertIP(self.mountinfo['ip']) else: ip = [192, 168, 0, 0] if self.mountinfo.has_key('sharename'): sharename = self.mountinfo['sharename'] else: sharename = "Sharename" if self.mountinfo.has_key('sharedir'): sharedir = self.mountinfo['sharedir'] else: sharedir = "/export/hdd" if self.mountinfo.has_key('options'): options = self.mountinfo['options'] else: options = "rw,nolock,soft" if self.mountinfo.has_key('username'): username = self.mountinfo['username'] else: username = "" if self.mountinfo.has_key('password'): password = self.mountinfo['password'] else: password = "" if self.mountinfo.has_key('hdd_replacement'): hdd_replacement = self.mountinfo['hdd_replacement'] if hdd_replacement == 'True': hdd_replacement = True if hdd_replacement == 'False': hdd_replacement = False else: hdd_replacement = False if sharename is False: sharename = "Sharename" if sharedir is False: sharedir = "/export/hdd" if mounttype == "nfs": defaultOptions = "rw,nolock,soft" else: defaultOptions = "rw" if username is False: username = "" if password is False: password = "" self.activeConfigEntry = NoSave(ConfigEnableDisable(default=active)) self.ipConfigEntry = NoSave(ConfigIP(default=ip)) self.sharenameConfigEntry = NoSave( ConfigText(default=sharename, visible_width=50, fixed_size=False)) self.sharedirConfigEntry = NoSave( ConfigText(default=sharedir, visible_width=50, fixed_size=False)) self.optionsConfigEntry = NoSave( ConfigText(default=defaultOptions, visible_width=50, fixed_size=False)) if options is not False: self.optionsConfigEntry.value = options self.usernameConfigEntry = NoSave( ConfigText(default=username, visible_width=50, fixed_size=False)) self.passwordConfigEntry = NoSave( ConfigPassword(default=password, visible_width=50, fixed_size=False)) self.mounttypeConfigEntry = NoSave( ConfigSelection(self.sharetypelist, default=mounttype)) self.hdd_replacementConfigEntry = NoSave( ConfigYesNo(default=hdd_replacement)) def createSetup(self): self.list = [] self.activeEntry = getConfigListEntry(_("Active"), self.activeConfigEntry) self.list.append(self.activeEntry) self.sharenameEntry = getConfigListEntry(_("Local share name"), self.sharenameConfigEntry) self.list.append(self.sharenameEntry) self.mounttypeEntry = getConfigListEntry(_("Mount type"), self.mounttypeConfigEntry) self.list.append(self.mounttypeEntry) self.ipEntry = getConfigListEntry(_("Server IP"), self.ipConfigEntry) self.list.append(self.ipEntry) self.sharedirEntry = getConfigListEntry(_("Server share"), self.sharedirConfigEntry) self.list.append(self.sharedirEntry) self.hdd_replacementEntry = getConfigListEntry( _("use as HDD replacement"), self.hdd_replacementConfigEntry) self.list.append(self.hdd_replacementEntry) if self.optionsConfigEntry.value == self.optionsConfigEntry.default: if self.mounttypeConfigEntry.value == "cifs": self.optionsConfigEntry = NoSave( ConfigText(default="rw", visible_width=50, fixed_size=False)) else: self.optionsConfigEntry = NoSave( ConfigText(default="rw,nolock,soft", visible_width=50, fixed_size=False)) self.optionsEntry = getConfigListEntry(_("Mount options"), self.optionsConfigEntry) self.list.append(self.optionsEntry) if self.mounttypeConfigEntry.value == "cifs": self.usernameEntry = getConfigListEntry(_("Username"), self.usernameConfigEntry) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_("Password"), self.passwordConfigEntry) self.list.append(self.passwordEntry) self["config"].list = self.list self["config"].l.setList(self.list) self["config"].onSelectionChanged.append(self.selectionChanged) def newConfig(self): if self["config"].getCurrent() == self.mounttypeEntry: self.createSetup() def KeyText(self): print "Green Pressed" if self["config"].getCurrent() == self.sharenameEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'sharename'), VirtualKeyBoard, title=(_("Enter share name:")), text=self.sharenameConfigEntry.value) if self["config"].getCurrent() == self.sharedirEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'sharedir'), VirtualKeyBoard, title=(_("Enter share directory:")), text=self.sharedirConfigEntry.value) if self["config"].getCurrent() == self.optionsEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'options'), VirtualKeyBoard, title=(_("Enter options:")), text=self.optionsConfigEntry.value) if self["config"].getCurrent() == self.usernameEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title=(_("Enter username:"******"config"].getCurrent() == self.passwordEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title=(_("Enter password:"******"config"].invalidate(self.sharenameConfigEntry) if entry == 'sharedir': self.sharedirConfigEntry.setValue(callback) self["config"].invalidate(self.sharedirConfigEntry) if entry == 'options': self.optionsConfigEntry.setValue(callback) self["config"].invalidate(self.optionsConfigEntry) if entry == 'username': self.usernameConfigEntry.setValue(callback) self["config"].invalidate(self.usernameConfigEntry) if entry == 'password': self.passwordConfigEntry.setValue(callback) self["config"].invalidate(self.passwordConfigEntry) def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def selectionChanged(self): current = self["config"].getCurrent() if current == self.activeEntry or current == self.ipEntry or current == self.mounttypeEntry or current == self.hdd_replacementEntry: self["VKeyIcon"].boolean = False self["VirtualKB"].setEnabled(False) else: helpwindowpos = self["HelpWindow"].getPosition() if current[1].help_window.instance is not None: current[1].help_window.instance.move( ePoint(helpwindowpos[0], helpwindowpos[1])) self["VKeyIcon"].boolean = True self["VirtualKB"].setEnabled(True) def ok(self): current = self["config"].getCurrent() if current == self.sharenameEntry or current == self.sharedirEntry or current == self.sharedirEntry or current == self.optionsEntry or current == self.usernameEntry or current == self.passwordEntry: if current[1].help_window.instance is not None: current[1].help_window.instance.hide() sharename = self.sharenameConfigEntry.value if self.mounts.has_key(sharename) is True: self.session.openWithCallback(self.updateConfig, MessageBox, (_( "A mount entry with this name already exists!\nUpdate existing entry and continue?\n" ))) else: self.session.openWithCallback( self.applyConfig, MessageBox, (_("Are you sure you want to save this network mount?\n\n"))) def updateConfig(self, ret=False): if (ret == True): sharedir = None if self.sharedirConfigEntry.value.startswith("/"): sharedir = self.sharedirConfigEntry.value[1:] else: sharedir = self.sharedirConfigEntry.value iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "sharename", self.sharenameConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "active", self.activeConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "ip", self.ipConfigEntry.getText()) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "sharedir", sharedir) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "mounttype", self.mounttypeConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "options", self.optionsConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "username", self.usernameConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "password", self.passwordConfigEntry.value) iAutoMount.setMountsAttribute( self.sharenameConfigEntry.value, "hdd_replacement", self.hdd_replacementConfigEntry.value) self.updateConfigRef = None self.updateConfigRef = self.session.openWithCallback( self.updateConfigfinishedCB, MessageBox, _("Please wait while updating your network mount..."), type=MessageBox.TYPE_INFO, enable_input=False) iAutoMount.writeMountsConfig() iAutoMount.getAutoMountPoints(self.updateConfigDataAvail) else: self.close() def updateConfigDataAvail(self, data): if data is True: self.updateConfigRef.close(True) def updateConfigfinishedCB(self, data): if data is True: self.session.openWithCallback( self.Updatefinished, MessageBox, _("Your network mount has been updated."), type=MessageBox.TYPE_INFO, timeout=10) def Updatefinished(self, data): if data is not None: if data is True: self.close() def applyConfig(self, ret=False): if (ret == True): data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, \ 'username': False, 'password': False, 'mounttype' : False, 'options' : False, 'hdd_replacement' : False } data['active'] = self.activeConfigEntry.value data['ip'] = self.ipConfigEntry.getText() data['sharename'] = re_sub("\W", "", self.sharenameConfigEntry.value) # "\W" matches everything that is "not numbers, letters, or underscores",where the alphabet defaults to ASCII. if self.sharedirConfigEntry.value.startswith("/"): data['sharedir'] = self.sharedirConfigEntry.value[1:] else: data['sharedir'] = self.sharedirConfigEntry.value data['options'] = self.optionsConfigEntry.value data['mounttype'] = self.mounttypeConfigEntry.value data['username'] = self.usernameConfigEntry.value data['password'] = self.passwordConfigEntry.value data['hdd_replacement'] = self.hdd_replacementConfigEntry.value self.applyConfigRef = None self.applyConfigRef = self.session.openWithCallback( self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network mount..."), type=MessageBox.TYPE_INFO, enable_input=False) iAutoMount.automounts[self.sharenameConfigEntry.value] = data iAutoMount.writeMountsConfig() iAutoMount.getAutoMountPoints(self.applyConfigDataAvail) else: self.close() def applyConfigDataAvail(self, data): if data is True: self.applyConfigRef.close(True) def applyConfigfinishedCB(self, data): if data is True: self.session.openWithCallback( self.applyfinished, MessageBox, _("Your network mount has been activated."), type=MessageBox.TYPE_INFO, timeout=10) def applyfinished(self, data): if data is not None: if data is True: self.close()
class AutoMountEdit(Screen, ConfigListScreen): skin = """ <screen name="AutoMountEdit" position="center,120" size="820,520" title="MountEdit"> <ePixmap pixmap="skin_default/buttons/red.png" position="10,5" size="200,40" alphatest="on"/> <widget source="key_red" render="Label" position="10,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" shadowColor="black" shadowOffset="-2,-2"/> <eLabel position="10,50" size="800,1" backgroundColor="grey"/> <widget name="config" position="10,55" size="800,420" enableWrapAround="1" scrollbarMode="showOnDemand"/> <widget name="VKeyIcon" position="730,10" size="70,30" pixmap="skin_default/icons/text.png" alphatest="on"/> <widget name="HelpWindow" position="338,445" zPosition="1" size="1,1" transparent="1"/> <eLabel position="10,480" size="800,1" backgroundColor="grey"/> <widget source="introduction" render="Label" position="10,488" size="800,25" font="Regular;22" halign="center" transparent="1"/> </screen>""" def __init__(self, session, plugin_path, mountinfo = None ): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) ConfigListScreen.__init__(self, [],session = session) self.mountinfo = mountinfo if self.mountinfo is None: #Initialize default mount data (using nfs default options) self.mountinfo = iAutoMount.DEFAULT_OPTIONS_NFS self._applyConfigMsgBox = None self.updateConfigRef = None self.mounts = iAutoMount.getMounts() self.createConfig() self["actions"] = NumberActionMap(["SetupActions"], { "ok": self.ok, "back": self.close, "cancel": self.close, "red": self.close, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Pixmap() self["HelpWindow"] = Pixmap() self["introduction"] = StaticText(_("Press OK to activate the settings.")) self["key_red"] = StaticText(_("Cancel")) def layoutFinished(self): self.setTitle(_("Mounts editor")) self["VKeyIcon"].hide() self["VirtualKB"].setEnabled(False) self["HelpWindow"].hide() # helper function to convert ips from a sring to a list of ints def convertIP(self, ip): strIP = ip.split('.') ip = [] for x in strIP: ip.append(int(x)) return ip def exit(self): self.close() def createConfig(self): self.sharetypelist = [] self.sharetypelist.append(("nfs", _("NFS share"))) self.sharetypelist.append(("cifs", _("CIFS share"))) mounttype = self.mountinfo['mounttype'] active = self.mountinfo['active'] ip = self.convertIP(self.mountinfo['ip']) sharename = self.mountinfo['sharename'] sharedir = self.mountinfo['sharedir'] options = self.mountinfo['options'] username = self.mountinfo['username'] password = self.mountinfo['password'] hdd_replacement = self.mountinfo['hdd_replacement'] if mounttype == "nfs": defaultOptions = iAutoMount.DEFAULT_OPTIONS_NFS['options'] else: defaultOptions = iAutoMount.DEFAULT_OPTIONS_CIFS['options'] self._cfgActive = NoSave(ConfigOnOff(default = active)) self._cfgIp = NoSave(ConfigIP(default = ip)) self._cfgSharename = NoSave(ConfigText(default = sharename, visible_width = 50, fixed_size = False)) self._cfgSharedir = NoSave(ConfigText(default = sharedir, visible_width = 50, fixed_size = False)) self._cfgOptions = NoSave(ConfigText(default = defaultOptions, visible_width = 50, fixed_size = False)) if options is not False: self._cfgOptions.value = options self._cfgUsername = NoSave(ConfigText(default = username, visible_width = 50, fixed_size = False)) self._cfgPassword = NoSave(ConfigPassword(default = password, visible_width = 50, fixed_size = False)) self._cfgMounttype = NoSave(ConfigSelection(self.sharetypelist, default = mounttype )) self._cfgHddReplacement = NoSave(ConfigYesNo(default = hdd_replacement)) def createSetup(self): if self._cfgOptions.value == self._cfgOptions.default: if self._cfgMounttype.value == "nfs": self._cfgOptions = NoSave(ConfigText(default = iAutoMount.DEFAULT_OPTIONS_NFS['options'], visible_width = 50, fixed_size = False)) else: self._cfgOptions = NoSave(ConfigText(default = iAutoMount.DEFAULT_OPTIONS_CIFS['options'], visible_width = 50, fixed_size = False)) optionsEntry = getConfigListEntry(_("Mount options"), self._cfgOptions) lst = [ getConfigListEntry(_("Active"), self._cfgActive), getConfigListEntry(_("Local share name"), self._cfgSharename), getConfigListEntry(_("Mount type"), self._cfgMounttype), getConfigListEntry(_("Server IP"), self._cfgIp), getConfigListEntry(_("Server share"), self._cfgSharedir), getConfigListEntry(_("use as HDD replacement"), self._cfgHddReplacement), optionsEntry, ] if self._cfgMounttype.value == "cifs": lst.extend([ getConfigListEntry(_("Username"), self._cfgUsername), getConfigListEntry(_("Password"), self._cfgPassword) ]) self["config"].list = lst self["config"].onSelectionChanged.append(self.selectionChanged) def newConfig(self): if self["config"].getCurrent()[1] == self._cfgMounttype: self.createSetup() def KeyText(self): current = self["config"].getCurrent()[1] if current == self._cfgSharename: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'sharename'), VirtualKeyBoard, title = (_("Enter share name:")), text = self._cfgSharename.value) elif current == self._cfgSharedir: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'sharedir'), VirtualKeyBoard, title = (_("Enter share directory:")), text = self._cfgSharedir.value) elif current == self._cfgOptions: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'options'), VirtualKeyBoard, title = (_("Enter options:")), text = self._cfgOptions.value) elif current == self._cfgUsername: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title = (_("Enter username:"******"Enter password:"******"config"].invalidate(self._cfgSharename) elif entry == 'sharedir': self._cfgSharedir.setValue(callback) self["config"].invalidate(self._cfgSharedir) elif entry == 'options': self._cfgOptions.setValue(callback) self["config"].invalidate(self._cfgOptions) elif entry == 'username': self._cfgUsername.setValue(callback) self["config"].invalidate(self._cfgUsername) elif entry == 'password': self._cfgPassword.setValue(callback) self["config"].invalidate(self._cfgPassword) def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def selectionChanged(self): current = self["config"].getCurrent()[1] if current == self._cfgActive or current == self._cfgIp or current == self._cfgMounttype or current == self._cfgHddReplacement: self["VKeyIcon"].hide() else: self["VKeyIcon"].show() def ok(self): sharename = self._cfgSharename.value if self.mounts.has_key(sharename) is True: self.session.openWithCallback(self.updateConfig, MessageBox, (_("A mount entry with this name already exists!\nUpdate existing entry and continue?\n") ) ) else: self.applyConfig(True) def updateConfig(self, ret = False): if ret == True: sharedir = None if self._cfgSharedir.value.startswith("/"): sharedir = self._cfgSharedir.value[1:] else: sharedir = self._cfgSharedir.value sharename = self._cfgSharename.value iAutoMount.setMountAttributes(sharename, { "sharename" : sharename, "active" : self._cfgActive.value, "ip" : self._cfgIp.getText(), "sharedir" : sharedir, "mounttype" : self._cfgMounttype.value, "options" : self._cfgOptions.value, "username" : self._cfgUsername.value, "password" : self._cfgPassword.value, "hdd_replacement" : self._cfgHddReplacement.value }) self._applyConfigMsgBox = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait while updating your network mount..."), type = MessageBox.TYPE_INFO, enable_input = False) iAutoMount.save() iAutoMount.reload(self.applyConfigDataAvail) else: self.close() def applyConfig(self, ret = False): if ret: if self._cfgMounttype.value == 'nfs': data = iAutoMount.DEFAULT_OPTIONS_NFS else: data = iAutoMount.DEFAULT_OPTIONS_CIFS data['active'] = self._cfgActive.value data['ip'] = self._cfgIp.getText() data['sharename'] = re_sub("\W", "", self._cfgSharename.value) # "\W" matches everything that is "not numbers, letters, or underscores",where the alphabet defaults to ASCII. if self._cfgSharedir.value.startswith("/"): data['sharedir'] = self._cfgSharedir.value[1:] else: data['sharedir'] = self._cfgSharedir.value data['options'] = self._cfgOptions.value data['mounttype'] = self._cfgMounttype.value data['username'] = self._cfgUsername.value data['password'] = self._cfgPassword.value data['hdd_replacement'] = self._cfgHddReplacement.value self._applyConfigMsgBox = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait while I'm saving your network mount..."), type = MessageBox.TYPE_INFO, enable_input = False) iAutoMount.mounts[self._cfgSharename.value] = data iAutoMount.save() iAutoMount.reload(self.applyConfigDataAvail) else: self.close() def applyConfigDataAvail(self, success): if success: self._applyConfigMsgBox.close(True) def applyConfigfinishedCB(self,data): if data is True: self.session.openWithCallback(self.applyfinished, MessageBox, _("Your network mount has been saved."), type = MessageBox.TYPE_INFO, timeout = 10) def applyfinished(self,data): if data is not None: if data is True: self.close()
class UserDialog(Screen, ConfigListScreen): skin = """ <screen name="UserDialog" position="center,center" size="560,300" title="UserDialog"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="config" position="5,50" size="550,200" zPosition="1" scrollbarMode="showOnDemand" /> <ePixmap pixmap="skin_default/div-h.png" position="0,270" zPosition="1" size="560,2" /> <widget source="introduction" render="Label" position="10,280" size="540,21" zPosition="10" font="Regular;18" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/> <widget name="VKeyIcon" pixmap="skin_default/buttons/key_text.png" position="10,280" zPosition="10" size="35,25" transparent="1" alphatest="on" /> <widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="160,250" zPosition="1" size="1,1" transparent="1" alphatest="on" /> </screen>""" def __init__(self, session, plugin_path, hostinfo = None ): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) self.hostinfo = hostinfo self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid self.cache_file = '/etc/enigma2/' + self.hostinfo + '.cache' #Path to cache directory self.createConfig() self["actions"] = NumberActionMap(["SetupActions"], { "ok": self.ok, "back": self.close, "cancel": self.close, "red": self.close, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self.list = [] ConfigListScreen.__init__(self, self.list,session = self.session) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Pixmap() self["HelpWindow"] = Pixmap() self["introduction"] = StaticText(_("Press OK to save settings.")) self["key_red"] = StaticText(_("Close")) def layoutFinished(self): self.setTitle(_("Enter user and password for host: ")+ self.hostinfo) # helper function to convert ips from a sring to a list of ints def convertIP(self, ip): strIP = ip.split('.') ip = [] for x in strIP: ip.append(int(x)) return ip def createConfig(self): self.usernameEntry = None self.passwordEntry = None self.username = None self.password = None if os_path.exists(self.cache_file): print 'Loading user cache from ',self.cache_file try: self.hostdata = load_cache(self.cache_file) username = self.hostdata['username'] password = self.hostdata['password'] except: username = "******" password = "******" else: username = "******" password = "******" self.username = NoSave(ConfigText(default = username, visible_width = 50, fixed_size = False)) self.password = NoSave(ConfigPassword(default = password, visible_width = 50, fixed_size = False)) def createSetup(self): self.list = [] self.usernameEntry = getConfigListEntry(_("Username"), self.username) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_("Password"), self.password) self.list.append(self.passwordEntry) self["config"].list = self.list self["config"].l.setList(self.list) self["config"].onSelectionChanged.append(self.selectionChanged) def KeyText(self): if self["config"].getCurrent() == self.usernameEntry: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title = (_("Enter username:"******"config"].getCurrent() == self.passwordEntry: self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title = (_("Enter password:"******"config"].invalidate(self.usernameEntry) if entry == 'password': self.password.setValue(callback) self["config"].invalidate(self.passwordEntry) def newConfig(self): if self["config"].getCurrent() == self.InterfaceEntry: self.createSetup() def keyLeft(self): ConfigListScreen.keyLeft(self) def keyRight(self): ConfigListScreen.keyRight(self) def selectionChanged(self): current = self["config"].getCurrent() helpwindowpos = self["HelpWindow"].getPosition() if current[1].help_window.instance is not None: current[1].help_window.instance.move(ePoint(helpwindowpos[0],helpwindowpos[1])) def ok(self): current = self["config"].getCurrent() self.hostdata = { 'username': self.username.value, 'password': self.password.value } write_cache(self.cache_file, self.hostdata) self.close(True)
class ConfigConnection(Screen, ConfigListScreen): def __init__(self, session): path = "/usr/lib/enigma2/python/Plugins/Extensions/iSkin/Skin/Connection.xml" with open(path, "r") as f: self.skin = f.read() f.close() Screen.__init__(self, session) self.ConfigConnection = [] self["config"] = ConfigList(self.ConfigConnection) self["Key_Red"] = Label(_("Exit")) self["Key_Green"] = Label("Save") ConfigListScreen.__init__(self, self.ConfigConnection, session=self.session) self["myActionMap"] = ActionMap( ["SetupActions", "ColorActions", "DirectionActions"], { "left": self.left, "right": self.right, "ok": self.OkKeyBoard, "green": self.KeySave, "cancel": self.KeyCancel }, -1) self.Config() self.LoadConfig() self.onLayoutFinish.append(self.MyConfigList) def getCurrentConfigPath(self): return self["config"].getCurrent()[2] def OkKeyBoard(self): if self.getCurrentConfigPath() == 'Url': self.session.openWithCallback(self.KeyBoardCallbackUrl, VirtualKeyBoard, title=(_("Insert Url")), text=self.SelectUrl.value) elif self.getCurrentConfigPath() == 'Ip': self.session.openWithCallback(self.KeyBoardCallbackIp, VirtualKeyBoard, title=(_("Insert Ip")), text=self.SelectIp.value) def KeyBoardCallbackUrl(self, callback=None, entry=None): if callback is not None and len(callback): self.SelectUrl.setValue(str(callback)) def KeyBoardCallbackIp(self, callback=None, entry=None): if callback is not None and len(callback): self.SelectIp.setValue(str(callback)) def left(self): self["config"].handleKey(KEY_LEFT) self.MyConfigList() def right(self): self["config"].handleKey(KEY_RIGHT) self.MyConfigList() def MyConfigList(self): self.ConfigConnectionList = [] self.ConfigConnectionList.append( getConfigListEntry(_('Select type Connection Insert :'), self.SelectConf, 'UrlIp')) if self.SelectConf.value == '1': self.ConfigConnectionList.append( getConfigListEntry(_('Insert Url :'), self.SelectUrl, 'Url')) else: self.ConfigConnectionList.append( getConfigListEntry(_('Insert Ip :'), self.SelectIp, 'Ip')) self.ConfigConnectionList.append( getConfigListEntry(_('Transaction Port :'), self.TransPort, 'Port')) self.ConfigConnectionList.append( getConfigListEntry(_('Timer Refresh :'), self.Timer, 'Timer')) self["config"].l.setList(self.ConfigConnectionList) def Config(self): self.SelectConf = NoSave( ConfigSelection([("1", _("Url")), ("0", _("Ip"))], default="1")) self.SelectUrl = NoSave( ConfigText(default="www.google.com", fixed_size=False)) self.SelectIp = NoSave( ConfigIP(default=[192, 168, 1, 1]) or [0, 0, 0, 0]) self.TransPort = NoSave( ConfigInteger(default=80, limits=(00000, 65535))) self.Timer = NoSave(ConfigInteger(default=120, limits=(1, 999))) def LoadConfig(self): try: try: xf = open(DirConfig, "r") f = xf.readlines() xf.close() except Exception, e: return for line in f: LoadConf = line.strip() if LoadConf.find('AddressIp') != -1: Addres = str(LoadConf.split('AddressIp')[1].strip()) Ip0 = int(Addres.split('.')[0]) Ip1 = int(Addres.split('.')[1]) Ip2 = int(Addres.split('.')[2]) Ip3 = int(Addres.split('.')[3]) self.SelectIp = NoSave( ConfigIP(default=[Ip0, Ip1, Ip2, Ip3])) elif LoadConf.find('SelectUrl') != -1: self.SelectUrl.setValue( int(str(LoadConf.split('SelectUrl')[1].strip()))) elif LoadConf.find('Port') != -1: self.TransPort.setValue( int(str(LoadConf.split('Port')[1].strip()))) elif LoadConf.find('Refresh') != -1: self.Timer.setValue( int(str(LoadConf.split('Refresh')[1].strip()))) elif LoadConf.find('ConnectionType') != -1: self.SelectConf.setValue( str(LoadConf.split('ConnectionType')[1].strip())) except:
class GrowleeConfiguration(Screen, ConfigListScreen): skin = """ <screen name="GrowleeConfiguration" position="center,center" size="560,400" title="Growlee Setup" > <ePixmap position="0,0" size="140,40" pixmap="buttons/red.png" transparent="1" alphatest="on" /> <ePixmap position="140,0" size="140,40" pixmap="buttons/green.png" transparent="1" alphatest="on" /> <ePixmap position="280,0" size="140,40" pixmap="buttons/yellow.png" transparent="1" alphatest="on" /> <ePixmap position="420,0" size="140,40" pixmap="buttons/blue.png" transparent="1" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" /> <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" /> <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" /> <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" /> <widget name="config" position="5,45" size="550,350" scrollbarMode="showOnDemand" /> </screen>""" def __init__(self, session): Screen.__init__(self, session) # Buttons self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self["key_yellow"] = StaticText(_("New")) self["key_blue"] = StaticText(_("Delete")) # Summary self.setup_title = "Growlee Configuration" self.onChangedEntry = [] # Define Actions self["setupActions"] = ActionMap( ["SetupActions", "ColorActions"], { "blue": self.delete, "yellow": self.new, "cancel": self.keyCancel, "save": self.keySave, }) self.hostElement = NoSave( ConfigSelection(choices=[(x, x.name.value) for x in config.plugins.growlee.hosts])) self.hostElement.addNotifier(self.setupList, initial_call=False) ConfigListScreen.__init__(self, [], session=session, on_change=self.changed) self.cur = self.hostElement.value # Trigger change self.setupList() self.changed() def delete(self): from Screens.MessageBox import MessageBox self.session.openWithCallback( self.deleteConfirm, MessageBox, _("Really delete this entry?\nIt cannot be recovered!")) def deleteConfirm(self, result): if result and config.plugins.growlee.hostcount.value > 0: config.plugins.growlee.hostcount.value -= 1 config.plugins.growlee.hosts.remove(self.cur) self.hostElement.setChoices([ (x, x.name.value) for x in config.plugins.growlee.hosts ]) self.cur = self.hostElement.value def new(self): self.cur = addHost(_("New connection")) config.plugins.growlee.hostcount.value += 1 self.hostElement.setChoices([(x, x.name.value) for x in config.plugins.growlee.hosts]) self.hostElement.setValue(self.cur) def changed(self): for x in self.onChangedEntry: x() def setupList(self, *args): last = self.cur if self.setupList in last.protocol.notifiers: last.protocol.removeNotifier(self.setupList) cur = self.hostElement.value self.cur = cur cur.protocol.addNotifier(self.setupList, initial_call=False) l = [ getConfigListEntry(_("Host"), self.hostElement), getConfigListEntry(_("Name"), cur.name), getConfigListEntry(_("Type"), cur.protocol), getConfigListEntry(_("Minimum Priority"), cur.level), getConfigListEntry(_("Send Notifications?"), cur.enable_outgoing), ] proto = cur.protocol.value if proto == "prowl": l.append(getConfigListEntry(_("API Key"), cur.password)) else: if proto != "gntp": l.append( getConfigListEntry(_("Receive Notifications?"), cur.enable_incoming)) l.append(getConfigListEntry(_("Address"), cur.address)) if proto == "growl" or proto == "gntp": l.append(getConfigListEntry(_("Password"), cur.password)) self["config"].list = l def getCurrentEntry(self): cur = self["config"].getCurrent() return cur and cur[0] def getCurrentValue(self): cur = self["config"].getCurrent() return cur and str(cur[1].getText()) def createSummary(self): return SetupSummary def keySave(self): config.plugins.growlee.save() if self["config"].isChanged(): def doConnect(*args, **kwargs): growleeConnection.listen() d = growleeConnection.stop() if d is not None: d.addCallback(doConnect).addErrback(emergencyDisable) else: maybeConnect() self.saveAll() self.close() def close(self): if self.setupList in self.cur.protocol.notifiers: self.cur.protocol.removeNotifier(self.setupList) Screen.close(self)
class ConfigConnection(Screen, ConfigListScreen): def __init__(self, session): path = "/usr/lib/enigma2/python/Plugins/Extensions/iSkin/Skin/Connection.xml" with open(path, "r") as f: self.skin = f.read() f.close() Screen.__init__(self, session) self.ConfigConnection = [] self["config"] = ConfigList(self.ConfigConnection) self["Key_Red"] = Label(_("Exit")) self["Key_Green"] = Label("Save") ConfigListScreen.__init__(self, self.ConfigConnection, session = self.session) self["myActionMap"] = ActionMap(["SetupActions","ColorActions","DirectionActions"], { "left" : self.left, "right" : self.right, "ok" : self.OkKeyBoard, "green": self.KeySave, "cancel": self.KeyCancel }, -1) self.Config() self.LoadConfig() self.onLayoutFinish.append(self.MyConfigList) def getCurrentConfigPath(self): return self["config"].getCurrent()[2] def OkKeyBoard(self): if self.getCurrentConfigPath() == 'Url': self.session.openWithCallback(self.KeyBoardCallbackUrl, VirtualKeyBoard, title = (_("Insert Url")), text = self.SelectUrl.value) elif self.getCurrentConfigPath() == 'Ip': self.session.openWithCallback(self.KeyBoardCallbackIp, VirtualKeyBoard, title = (_("Insert Ip")), text = self.SelectIp.value) def KeyBoardCallbackUrl(self, callback = None, entry = None): if callback is not None and len(callback): self.SelectUrl.setValue(str(callback)) def KeyBoardCallbackIp(self, callback = None, entry = None): if callback is not None and len(callback): self.SelectIp.setValue(str(callback)) def left(self): self["config"].handleKey(KEY_LEFT) self.MyConfigList() def right(self): self["config"].handleKey(KEY_RIGHT) self.MyConfigList() def MyConfigList(self): self.ConfigConnectionList = [] self.ConfigConnectionList.append(getConfigListEntry(_('Select type Connection Insert :'), self.SelectConf,'UrlIp')) if self.SelectConf.value == '1': self.ConfigConnectionList.append(getConfigListEntry(_('Insert Url :'), self.SelectUrl,'Url')) else: self.ConfigConnectionList.append(getConfigListEntry(_('Insert Ip :'), self.SelectIp,'Ip')) self.ConfigConnectionList.append(getConfigListEntry(_('Transaction Port :'), self.TransPort,'Port')) self.ConfigConnectionList.append(getConfigListEntry(_('Timer Refresh :'), self.Timer,'Timer')) self["config"].l.setList(self.ConfigConnectionList) def Config(self): self.SelectConf = NoSave(ConfigSelection([("1", _("Url")), ("0", _("Ip"))], default = "1")) self.SelectUrl = NoSave(ConfigText(default = "www.google.com", fixed_size = False)) self.SelectIp = NoSave(ConfigIP(default = [192,168,1,1]) or [0,0,0,0]) self.TransPort = NoSave(ConfigInteger(default = 80, limits = (00000,65535))) self.Timer = NoSave(ConfigInteger(default = 120, limits = (1,999))) def LoadConfig(self): try: try: xf = open(DirConfig, "r") f = xf.readlines() xf.close() except Exception, e: return for line in f: LoadConf = line.strip() if LoadConf.find('AddressIp') != -1 : Addres =str(LoadConf.split('AddressIp')[1].strip()) Ip0= int(Addres.split('.')[0]) Ip1= int(Addres.split('.')[1]) Ip2= int(Addres.split('.')[2]) Ip3= int(Addres.split('.')[3]) self.SelectIp = NoSave(ConfigIP(default = [Ip0,Ip1,Ip2,Ip3])) elif LoadConf.find('SelectUrl') != -1 : self.SelectUrl.setValue(int(str(LoadConf.split('SelectUrl')[1].strip()))) elif LoadConf.find('Port') != -1 : self.TransPort.setValue(int(str(LoadConf.split('Port')[1].strip()))) elif LoadConf.find('Refresh') != -1 : self.Timer.setValue(int(str(LoadConf.split('Refresh')[1].strip()))) elif LoadConf.find('ConnectionType') != -1 : self.SelectConf.setValue(str(LoadConf.split('ConnectionType')[1].strip())) except:
class AutoMountEdit(Screen, ConfigListScreen): skin = """ <screen name="AutoMountEdit" position="center,center" size="560,450" title="MountEdit"> <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" /> <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" /> <widget name="config" position="5,50" size="550,250" zPosition="1" scrollbarMode="showOnDemand" /> <ePixmap pixmap="skin_default/div-h.png" position="0,420" zPosition="1" size="560,2" /> <widget source="introduction" render="Label" position="10,430" size="540,21" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/> <widget name="VKeyIcon" pixmap="skin_default/buttons/key_text.png" position="10,430" zPosition="10" size="35,25" transparent="1" alphatest="on" /> <widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="160,350" zPosition="1" size="1,1" transparent="1" alphatest="on" /> </screen>""" def __init__(self, session, plugin_path, mountinfo=None): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) ConfigListScreen.__init__(self, [], session=session) self.mountinfo = mountinfo if self.mountinfo is None: #Initialize default mount data (using nfs default options) self.mountinfo = iAutoMount.DEFAULT_OPTIONS_NFS self._applyConfigMsgBox = None self.updateConfigRef = None self.mounts = iAutoMount.getMounts() self.createConfig() self["actions"] = NumberActionMap( ["SetupActions"], { "ok": self.ok, "back": self.close, "cancel": self.close, "red": self.close, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Pixmap() self["HelpWindow"] = Pixmap() self["introduction"] = StaticText( _("Press OK to activate the settings.")) self["key_red"] = StaticText(_("Cancel")) def layoutFinished(self): self.setTitle(_("Mounts editor")) self["VKeyIcon"].hide() self["VirtualKB"].setEnabled(False) self["HelpWindow"].hide() # helper function to convert ips from a sring to a list of ints def convertIP(self, ip): strIP = ip.split('.') ip = [] for x in strIP: ip.append(int(x)) return ip def exit(self): self.close() def createConfig(self): self.sharetypelist = [] self.sharetypelist.append(("nfs", _("NFS share"))) self.sharetypelist.append(("cifs", _("CIFS share"))) mounttype = self.mountinfo['mounttype'] active = self.mountinfo['active'] ip = self.convertIP(self.mountinfo['ip']) sharename = self.mountinfo['sharename'] sharedir = self.mountinfo['sharedir'] options = self.mountinfo['options'] username = self.mountinfo['username'] password = self.mountinfo['password'] hdd_replacement = self.mountinfo['hdd_replacement'] if mounttype == "nfs": defaultOptions = iAutoMount.DEFAULT_OPTIONS_NFS['options'] else: defaultOptions = iAutoMount.DEFAULT_OPTIONS_CIFS['options'] self._cfgActive = NoSave(ConfigOnOff(default=active)) self._cfgIp = NoSave(ConfigIP(default=ip)) self._cfgSharename = NoSave( ConfigText(default=sharename, visible_width=50, fixed_size=False)) self._cfgSharedir = NoSave( ConfigText(default=sharedir, visible_width=50, fixed_size=False)) self._cfgOptions = NoSave( ConfigText(default=defaultOptions, visible_width=50, fixed_size=False)) if options is not False: self._cfgOptions.value = options self._cfgUsername = NoSave( ConfigText(default=username, visible_width=50, fixed_size=False)) self._cfgPassword = NoSave( ConfigPassword(default=password, visible_width=50, fixed_size=False)) self._cfgMounttype = NoSave( ConfigSelection(self.sharetypelist, default=mounttype)) self._cfgHddReplacement = NoSave(ConfigYesNo(default=hdd_replacement)) def createSetup(self): if self._cfgOptions.value == self._cfgOptions.default: if self._cfgMounttype.value == "nfs": self._cfgOptions = NoSave( ConfigText( default=iAutoMount.DEFAULT_OPTIONS_NFS['options'], visible_width=50, fixed_size=False)) else: self._cfgOptions = NoSave( ConfigText( default=iAutoMount.DEFAULT_OPTIONS_CIFS['options'], visible_width=50, fixed_size=False)) optionsEntry = getConfigListEntry(_("Mount options"), self._cfgOptions) lst = [ getConfigListEntry(_("Active"), self._cfgActive), getConfigListEntry(_("Local share name"), self._cfgSharename), getConfigListEntry(_("Mount type"), self._cfgMounttype), getConfigListEntry(_("Server IP"), self._cfgIp), getConfigListEntry(_("Server share"), self._cfgSharedir), getConfigListEntry(_("use as HDD replacement"), self._cfgHddReplacement), optionsEntry, ] if self._cfgMounttype.value == "cifs": lst.extend([ getConfigListEntry(_("Username"), self._cfgUsername), getConfigListEntry(_("Password"), self._cfgPassword) ]) self["config"].list = lst self["config"].onSelectionChanged.append(self.selectionChanged) def newConfig(self): if self["config"].getCurrent()[1] == self._cfgMounttype: self.createSetup() def KeyText(self): current = self["config"].getCurrent()[1] if current == self._cfgSharename: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'sharename'), VirtualKeyBoard, title=(_("Enter share name:")), text=self._cfgSharename.value) elif current == self._cfgSharedir: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'sharedir'), VirtualKeyBoard, title=(_("Enter share directory:")), text=self._cfgSharedir.value) elif current == self._cfgOptions: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'options'), VirtualKeyBoard, title=(_("Enter options:")), text=self._cfgOptions.value) elif current == self._cfgUsername: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title=(_("Enter username:"******"Enter password:"******"config"].invalidate(self._cfgSharename) elif entry == 'sharedir': self._cfgSharedir.setValue(callback) self["config"].invalidate(self._cfgSharedir) elif entry == 'options': self._cfgOptions.setValue(callback) self["config"].invalidate(self._cfgOptions) elif entry == 'username': self._cfgUsername.setValue(callback) self["config"].invalidate(self._cfgUsername) elif entry == 'password': self._cfgPassword.setValue(callback) self["config"].invalidate(self._cfgPassword) def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def selectionChanged(self): current = self["config"].getCurrent()[1] if current == self._cfgActive or current == self._cfgIp or current == self._cfgMounttype or current == self._cfgHddReplacement: self["VKeyIcon"].hide() else: self["VKeyIcon"].show() def ok(self): sharename = self._cfgSharename.value if self.mounts.has_key(sharename) is True: self.session.openWithCallback(self.updateConfig, MessageBox, (_( "A mount entry with this name already exists!\nUpdate existing entry and continue?\n" ))) else: self.session.openWithCallback( self.applyConfig, MessageBox, (_("Are you sure you want to save this network mount?\n\n"))) def updateConfig(self, ret=False): if ret == True: sharedir = None if self._cfgSharedir.value.startswith("/"): sharedir = self._cfgSharedir.value[1:] else: sharedir = self._cfgSharedir.value sharename = self._cfgSharename.value iAutoMount.setMountAttributes( sharename, { "sharename": sharename, "active": self._cfgActive.value, "ip": self._cfgIp.getText(), "sharedir": sharedir, "mounttype": self._cfgMounttype.value, "options": self._cfgOptions.value, "username": self._cfgUsername.value, "password": self._cfgPassword.value, "hdd_replacement": self._cfgHddReplacement.value }) self._applyConfigMsgBox = self.session.openWithCallback( self.applyConfigfinishedCB, MessageBox, _("Please wait while updating your network mount..."), type=MessageBox.TYPE_INFO, enable_input=False) iAutoMount.save() iAutoMount.reload(self.applyConfigDataAvail) else: self.close() def applyConfig(self, ret=False): if ret == True: data = iAutoMount.DEFAULT_OPTIONS_NFS data['active'] = self._cfgActive.value data['ip'] = self._cfgIp.getText() data['sharename'] = re_sub("\W", "", self._cfgSharename.value) # "\W" matches everything that is "not numbers, letters, or underscores",where the alphabet defaults to ASCII. if self._cfgSharedir.value.startswith("/"): data['sharedir'] = self._cfgSharedir.value[1:] else: data['sharedir'] = self._cfgSharedir.value data['options'] = self._cfgOptions.value data['mounttype'] = self._cfgMounttype.value data['username'] = self._cfgUsername.value data['password'] = self._cfgPassword.value data['hdd_replacement'] = self._cfgHddReplacement.value self._applyConfigMsgBox = self.session.openWithCallback( self.applyConfigfinishedCB, MessageBox, _("Please wait while I'm saving your network mount..."), type=MessageBox.TYPE_INFO, enable_input=False) iAutoMount.mounts[self._cfgSharename.value] = data iAutoMount.save() iAutoMount.reload(self.applyConfigDataAvail) else: self.close() def applyConfigDataAvail(self, success): if success: self._applyConfigMsgBox.close(True) def applyConfigfinishedCB(self, data): if data is True: self.session.openWithCallback( self.applyfinished, MessageBox, _("Your network mount has been saved."), type=MessageBox.TYPE_INFO, timeout=10) def applyfinished(self, data): if data is not None: if data is True: self.close()
class UserDialog(Screen, ConfigListScreen): skin = """ <screen name="UserDialog" position="center,120" size="820,520" title="UserDialog"> <ePixmap pixmap="skin_default/buttons/red.png" position="10,5" size="200,40" alphatest="on"/> <widget source="key_red" render="Label" position="10,5" size="200,40" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" shadowColor="black" shadowOffset="-2,-2"/> <eLabel position="10,50" size="800,1" backgroundColor="grey"/> <widget name="config" position="10,55" size="800,420" enableWrapAround="1" scrollbarMode="showOnDemand"/> <widget name="VKeyIcon" position="730,10" size="70,30" pixmap="skin_default/icons/text.png" alphatest="on"/> <widget name="HelpWindow" position="338,445" zPosition="1" size="1,1" transparent="1"/> <eLabel position="10,480" size="800,1" backgroundColor="grey"/> <widget source="introduction" render="Label" position="10,488" size="800,25" font="Regular;22" halign="center" transparent="1"/> </screen>""" def __init__(self, session, plugin_path, hostinfo=None): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) self.hostinfo = hostinfo self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid self.cache_file = eEnv.resolve( "${sysconfdir}/enigma2/" ) + self.hostinfo + '.cache' #Path to cache directory self.createConfig() self["actions"] = NumberActionMap( ["SetupActions"], { "ok": self.ok, "back": self.close, "cancel": self.close, "red": self.close, }, -2) self["VirtualKB"] = ActionMap(["VirtualKeyboardActions"], { "showVirtualKeyboard": self.KeyText, }, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=self.session) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) # Initialize Buttons self["VKeyIcon"] = Pixmap() self["HelpWindow"] = Pixmap() self["introduction"] = StaticText(_("Press OK to save settings.")) self["key_red"] = StaticText(_("Close")) def layoutFinished(self): self.setTitle(_("Enter user and password for host: ") + self.hostinfo) # helper function to convert ips from a sring to a list of ints def convertIP(self, ip): strIP = ip.split('.') ip = [] for x in strIP: ip.append(int(x)) return ip def createConfig(self): self.usernameEntry = None self.passwordEntry = None self.username = None self.password = None username = "******" password = "" if os_path.exists(self.cache_file): print 'Loading user cache from ', self.cache_file try: self.hostdata = load_cache(self.cache_file) username = self.hostdata['username'] password = self.hostdata['password'] except: pass self.username = NoSave( ConfigText(default=username, visible_width=50, fixed_size=False)) self.password = NoSave( ConfigPassword(default=password, visible_width=50, fixed_size=False)) def createSetup(self): self.list = [] self.usernameEntry = getConfigListEntry(_("Username"), self.username) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_("Password"), self.password) self.list.append(self.passwordEntry) self["config"].list = self.list self["config"].l.setList(self.list) self["config"].onSelectionChanged.append(self.selectionChanged) def KeyText(self): if self["config"].getCurrent() == self.usernameEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title=(_("Enter username:"******"config"].getCurrent() == self.passwordEntry: self.session.openWithCallback( lambda x: self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title=(_("Enter password:"******"config"].invalidate(self.usernameEntry) if entry == 'password': self.password.setValue(callback) self["config"].invalidate(self.passwordEntry) def newConfig(self): if self["config"].getCurrent() == self.InterfaceEntry: self.createSetup() def keyLeft(self): ConfigListScreen.keyLeft(self) def keyRight(self): ConfigListScreen.keyRight(self) def selectionChanged(self): current = self["config"].getCurrent() helpwindowpos = self["HelpWindow"].getPosition() if current[1].help_window.instance is not None: current[1].help_window.instance.move( ePoint(helpwindowpos[0], helpwindowpos[1])) def ok(self): current = self["config"].getCurrent() self.hostdata = { 'username': self.username.value, 'password': self.password.value } write_cache(self.cache_file, self.hostdata) self.close(True)
class AutoMountEdit(Screen, ConfigListScreen): skin = '\n\t\t<screen name="AutoMountEdit" position="center,center" size="560,450" title="MountEdit">\n\t\t\t<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t\t<widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t\t<widget name="config" position="5,50" size="550,250" zPosition="1" scrollbarMode="showOnDemand" />\n\t\t\t<ePixmap pixmap="skin_default/div-h.png" position="0,420" zPosition="1" size="560,2" />\n\t\t\t<widget source="introduction" render="Label" position="10,430" size="540,21" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/>\n\t\t\t<widget name="VKeyIcon" pixmap="skin_default/buttons/key_text.png" position="10,430" zPosition="10" size="35,25" transparent="1" alphatest="on" />\n\t\t\t<widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="160,350" zPosition="1" size="1,1" transparent="1" alphatest="on" />\n\t\t</screen>' def __init__(self, session, plugin_path, mountinfo = None): self.skin_path = plugin_path self.session = session Screen.__init__(self, self.session) self.onChangedEntry = [] self.mountinfo = mountinfo if self.mountinfo is None: self.mountinfo = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} self.applyConfigRef = None self.updateConfigRef = None self.mounts = iAutoMount.getMountsList() self.createConfig() self['actions'] = NumberActionMap(['SetupActions', 'ColorActions'], {'ok': self.ok, 'back': self.close, 'cancel': self.close, 'red': self.close, 'green': self.ok}, -2) self['VirtualKB'] = ActionMap(['VirtualKeyboardActions'], {'showVirtualKeyboard': self.KeyText}, -2) self.list = [] ConfigListScreen.__init__(self, self.list, session=self.session) self.createSetup() self.onLayoutFinish.append(self.layoutFinished) self['VKeyIcon'] = Pixmap() self['HelpWindow'] = Pixmap() self['introduction'] = StaticText(_('Press OK to activate the settings.')) self['key_red'] = StaticText(_('Cancel')) self['key_green'] = StaticText(_('Save')) self.selectionChanged() def changedEntry(self): for x in self.onChangedEntry: x() def getCurrentEntry(self): return self['config'].getCurrent()[0] def getCurrentValue(self): return str(self['config'].getCurrent()[1].getText()) def createSummary(self): from Screens.Setup import SetupSummary return SetupSummary def layoutFinished(self): self.setup_title = _('Mounts editor') Screen.setTitle(self, _(self.setup_title)) self['VKeyIcon'].hide() self['VirtualKB'].setEnabled(False) self['HelpWindow'].hide() def convertIP(self, ip): strIP = ip.split('.') ip = [] for x in strIP: ip.append(int(x)) return ip def exit(self): self.close() def createConfig(self): self.mountusingEntry = None self.sharenameEntry = None self.mounttypeEntry = None self.activeEntry = None self.ipEntry = None self.sharedirEntry = None self.optionsEntry = None self.usernameEntry = None self.passwordEntry = None self.hdd_replacementEntry = None self.mountusing = [] self.mountusing.append(('fstab', _('FSTAB (mount using linux)'))) self.mountusing.append(('enigma2', _('Enigma2 (mount using enigma2)'))) self.mountusing.append(('old_enigma2', _('Enigma2 old format (mount using linux)'))) self.sharetypelist = [] self.sharetypelist.append(('nfs', _('NFS share'))) self.sharetypelist.append(('cifs', _('CIFS share'))) if self.mountinfo.has_key('mountusing'): mountusing = self.mountinfo['mountusing'] if mountusing is False: mountusing = 'fstab' else: mountusing = 'fstab' if self.mountinfo.has_key('mounttype'): mounttype = self.mountinfo['mounttype'] if mounttype is False: mounttype = 'nfs' else: mounttype = 'nfs' if self.mountinfo.has_key('active'): active = self.mountinfo['active'] if active == 'True': active = True if active == 'False': active = False else: active = True if self.mountinfo.has_key('ip'): if self.mountinfo['ip'] is False: ip = [192, 168, 0, 0] else: ip = self.convertIP(self.mountinfo['ip']) else: ip = [192, 168, 0, 0] if mounttype == 'nfs': defaultOptions = 'rw,nolock,tcp' else: defaultOptions = 'rw,utf8' if self.mountinfo['sharename'] and self.mountinfo.has_key('sharename'): sharename = re_sub('\\W', '', self.mountinfo['sharename']) else: sharename = 'Sharename' if self.mountinfo.has_key('sharedir'): sharedir = self.mountinfo['sharedir'] else: sharedir = '/export/hdd' if self.mountinfo.has_key('options'): options = self.mountinfo['options'] else: options = defaultOptions if self.mountinfo.has_key('username'): username = self.mountinfo['username'] else: username = '' if self.mountinfo.has_key('password'): password = self.mountinfo['password'] else: password = '' if self.mountinfo.has_key('hdd_replacement'): hdd_replacement = self.mountinfo['hdd_replacement'] if hdd_replacement == 'True': hdd_replacement = True if hdd_replacement == 'False': hdd_replacement = False else: hdd_replacement = False if sharename is False: sharename = 'Sharename' if sharedir is False: sharedir = '/export/hdd' if username is False: username = '' if password is False: password = '' self.mountusingConfigEntry = NoSave(ConfigSelection(self.mountusing, default=mountusing)) self.activeConfigEntry = NoSave(ConfigEnableDisable(default=active)) self.ipConfigEntry = NoSave(ConfigIP(default=ip)) self.sharenameConfigEntry = NoSave(ConfigText(default=sharename, visible_width=50, fixed_size=False)) self.sharedirConfigEntry = NoSave(ConfigText(default=sharedir, visible_width=50, fixed_size=False)) self.optionsConfigEntry = NoSave(ConfigText(default=defaultOptions, visible_width=50, fixed_size=False)) if options is not False: self.optionsConfigEntry.value = options self.usernameConfigEntry = NoSave(ConfigText(default=username, visible_width=50, fixed_size=False)) self.passwordConfigEntry = NoSave(ConfigPassword(default=password, visible_width=50, fixed_size=False)) self.mounttypeConfigEntry = NoSave(ConfigSelection(self.sharetypelist, default=mounttype)) self.hdd_replacementConfigEntry = NoSave(ConfigYesNo(default=hdd_replacement)) def createSetup(self): self.list = [] self.mountusingEntry = getConfigListEntry(_('Mount using'), self.mountusingConfigEntry) self.list.append(self.mountusingEntry) self.activeEntry = getConfigListEntry(_('Active'), self.activeConfigEntry) self.list.append(self.activeEntry) self.sharenameEntry = getConfigListEntry(_('Local share name'), self.sharenameConfigEntry) self.list.append(self.sharenameEntry) self.mounttypeEntry = getConfigListEntry(_('Mount type'), self.mounttypeConfigEntry) self.list.append(self.mounttypeEntry) self.ipEntry = getConfigListEntry(_('Server IP'), self.ipConfigEntry) self.list.append(self.ipEntry) self.sharedirEntry = getConfigListEntry(_('Server share'), self.sharedirConfigEntry) self.list.append(self.sharedirEntry) self.hdd_replacementEntry = getConfigListEntry(_('use as HDD replacement'), self.hdd_replacementConfigEntry) self.list.append(self.hdd_replacementEntry) self.optionsEntry = getConfigListEntry(_('Mount options'), self.optionsConfigEntry) self.list.append(self.optionsEntry) if self.mounttypeConfigEntry.value == 'cifs': self.usernameEntry = getConfigListEntry(_('Username'), self.usernameConfigEntry) self.list.append(self.usernameEntry) self.passwordEntry = getConfigListEntry(_('Password'), self.passwordConfigEntry) self.list.append(self.passwordEntry) self['config'].list = self.list self['config'].l.setList(self.list) self['config'].onSelectionChanged.append(self.selectionChanged) def newConfig(self): if self['config'].getCurrent() == self.mounttypeEntry: if self.mounttypeConfigEntry.value == 'nfs': defaultOptions = 'rw,nolock,tcp' else: defaultOptions = 'rw,utf8' if self.mountinfo.has_key('options'): options = self.mountinfo['options'] else: options = defaultOptions self.optionsConfigEntry = NoSave(ConfigText(default=defaultOptions, visible_width=50, fixed_size=False)) if options is not False: self.optionsConfigEntry.value = options self.createSetup() def KeyText(self): print 'Green Pressed' if self['config'].getCurrent() == self.sharenameEntry: self.session.openWithCallback(lambda x: self.VirtualKeyBoardCallback(x, 'sharename'), VirtualKeyBoard, title=_('Enter share name:'), text=self.sharenameConfigEntry.value) if self['config'].getCurrent() == self.sharedirEntry: self.session.openWithCallback(lambda x: self.VirtualKeyBoardCallback(x, 'sharedir'), VirtualKeyBoard, title=_('Enter share directory:'), text=self.sharedirConfigEntry.value) if self['config'].getCurrent() == self.optionsEntry: self.session.openWithCallback(lambda x: self.VirtualKeyBoardCallback(x, 'options'), VirtualKeyBoard, title=_('Enter options:'), text=self.optionsConfigEntry.value) if self['config'].getCurrent() == self.usernameEntry: self.session.openWithCallback(lambda x: self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title=_('Enter username:'******'config'].getCurrent() == self.passwordEntry: self.session.openWithCallback(lambda x: self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title=_('Enter password:'******'sharename': self.sharenameConfigEntry.setValue(callback) self['config'].invalidate(self.sharenameConfigEntry) if entry == 'sharedir': self.sharedirConfigEntry.setValue(callback) self['config'].invalidate(self.sharedirConfigEntry) if entry == 'options': self.optionsConfigEntry.setValue(callback) self['config'].invalidate(self.optionsConfigEntry) if entry == 'username': self.usernameConfigEntry.setValue(callback) self['config'].invalidate(self.usernameConfigEntry) if entry == 'password': self.passwordConfigEntry.setValue(callback) self['config'].invalidate(self.passwordConfigEntry) def keyLeft(self): ConfigListScreen.keyLeft(self) self.newConfig() def keyRight(self): ConfigListScreen.keyRight(self) self.newConfig() def selectionChanged(self): current = self['config'].getCurrent() if current == self.mountusingEntry or current == self.activeEntry or current == self.ipEntry or current == self.mounttypeEntry or current == self.hdd_replacementEntry: self['VKeyIcon'].hide() self['VirtualKB'].setEnabled(False) else: helpwindowpos = self['HelpWindow'].getPosition() if current[1].help_window.instance is not None: current[1].help_window.instance.move(ePoint(helpwindowpos[0], helpwindowpos[1])) self['VKeyIcon'].show() self['VirtualKB'].setEnabled(True) def ok(self): current = self['config'].getCurrent() if current == self.sharenameEntry or current == self.sharedirEntry or current == self.sharedirEntry or current == self.optionsEntry or current == self.usernameEntry or current == self.passwordEntry: if current[1].help_window.instance is not None: current[1].help_window.instance.hide() sharename = re_sub('\\W', '', self.sharenameConfigEntry.value) if self.sharedirConfigEntry.value.startswith('/'): sharedir = self.sharedirConfigEntry.value[1:] else: sharedir = self.sharedirConfigEntry.value sharexists = False for data in self.mounts: if self.mounts[data]['sharename'] == sharename: if self.mounts[data]['sharedir'] != sharedir: sharexists = True break if sharexists: self.session.open(MessageBox, _('A mount entry with this name already exists!\nand is not this share folder, please use a different name.\n'), type=MessageBox.TYPE_INFO) elif self.mounts.has_key(sharename) is True: self.session.openWithCallback(self.updateConfig, MessageBox, _('A mount entry with this name already exists!\nUpdate existing entry and continue?\n'), default=False) else: self.session.openWithCallback(self.applyConfig, MessageBox, _('Are you sure you want to save this network mount?\n\n')) def updateConfig(self, ret = False): if ret == True: sharedir = None if self.sharedirConfigEntry.value.startswith('/'): sharedir = self.sharedirConfigEntry.value[1:] else: sharedir = self.sharedirConfigEntry.value iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'mountusing', self.mountusingConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'sharename', self.sharenameConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'active', self.activeConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'ip', self.ipConfigEntry.getText()) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'sharedir', sharedir) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'mounttype', self.mounttypeConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'options', self.optionsConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'username', self.usernameConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'password', self.passwordConfigEntry.value) iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, 'hdd_replacement', self.hdd_replacementConfigEntry.value) self.updateConfigRef = None self.updateConfigRef = self.session.openWithCallback(self.updateConfigfinishedCB, MessageBox, _('Please wait while updating your network mount...'), type=MessageBox.TYPE_INFO, enable_input=False) iAutoMount.writeMountsConfig() iAutoMount.getAutoMountPoints(self.updateConfigDataAvail) else: self.close() def updateConfigDataAvail(self, data): if data is True: self.updateConfigRef.close(True) def updateConfigfinishedCB(self, data): if data is True: self.session.openWithCallback(self.Updatefinished, MessageBox, _('Your network mount has been updated.'), type=MessageBox.TYPE_INFO, timeout=10) def Updatefinished(self, data): if data is not None: if data is True: self.close() def applyConfig(self, ret = False): if ret == True: data = {'isMounted': False, 'mountusing': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype': False, 'options': False, 'hdd_replacement': False} data['mountusing'] = self.mountusingConfigEntry.value data['active'] = self.activeConfigEntry.value data['ip'] = self.ipConfigEntry.getText() data['sharename'] = re_sub('\\W', '', self.sharenameConfigEntry.value) if self.sharedirConfigEntry.value.startswith('/'): data['sharedir'] = self.sharedirConfigEntry.value[1:] else: data['sharedir'] = self.sharedirConfigEntry.value data['options'] = self.optionsConfigEntry.value data['mounttype'] = self.mounttypeConfigEntry.value data['username'] = self.usernameConfigEntry.value data['password'] = self.passwordConfigEntry.value data['hdd_replacement'] = self.hdd_replacementConfigEntry.value self.applyConfigRef = None self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _('Please wait for activation of your network mount...'), type=MessageBox.TYPE_INFO, enable_input=False) iAutoMount.automounts[self.sharenameConfigEntry.value] = data iAutoMount.writeMountsConfig() iAutoMount.getAutoMountPoints(self.applyConfigDataAvail) else: self.close() def applyConfigDataAvail(self, data): if data is True: self.applyConfigRef.close(True) def applyConfigfinishedCB(self, data): if data is True: self.session.openWithCallback(self.applyfinished, MessageBox, _('Your network mount has been activated.'), type=MessageBox.TYPE_INFO, timeout=10) def applyfinished(self, data): if data is not None: if data is True: self.close()