1 # -*- coding: utf-8 -*-
2 # for localized messages
4 from Screens.Screen import Screen
5 from Screens.MessageBox import MessageBox
6 from Screens.VirtualKeyBoard import VirtualKeyBoard
7 from Components.Sources.StaticText import StaticText
8 from Components.Pixmap import Pixmap
9 from Components.ActionMap import ActionMap
10 from Components.Network import iNetwork
11 from Components.Sources.List import List
12 from Tools.LoadPixmap import LoadPixmap
13 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
14 from os import path as os_path
16 from MountView import AutoMountView
17 from MountEdit import AutoMountEdit
18 from AutoMount import iAutoMount, AutoMount
19 from UserManager import UserManager
21 class AutoMountManager(Screen):
23 <screen name="AutoMountManager" position="center,center" size="560,400" title="AutoMountManager">
24 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
25 <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" />
26 <widget source="config" render="Listbox" position="5,50" size="540,300" scrollbarMode="showOnDemand" >
27 <convert type="TemplatedMultiContent">
29 MultiContentEntryText(pos = (0, 3), size = (480, 25), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 2 is the Menu Titel
30 MultiContentEntryText(pos = (10, 29), size = (480, 17), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 3 is the Description
31 MultiContentEntryPixmapAlphaTest(pos = (500, 1), size = (48, 48), png = 3), # index 4 is the pixmap
33 "fonts": [gFont("Regular", 20),gFont("Regular", 14)],
38 <ePixmap pixmap="skin_default/div-h.png" position="0,360" zPosition="1" size="560,2" />
39 <widget source="introduction" render="Label" position="10,370" size="540,21" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/>
41 def __init__(self, session, iface ,plugin_path):
42 self.skin_path = plugin_path
43 self.session = session
45 self.restartLanRef = None
46 Screen.__init__(self, session)
47 self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"],
54 self["key_red"] = StaticText(_("Close"))
55 self["introduction"] = StaticText(_("Press OK to select."))
58 self["config"] = List(self.list)
60 self.onClose.append(self.cleanup)
61 self.onShown.append(self.setWindowTitle)
63 def setWindowTitle(self):
64 self.setTitle(_("MountManager"))
67 iNetwork.stopRestartConsole()
68 iNetwork.stopGetInterfacesConsole()
72 okpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/ok.png"))
73 self.list.append((_("Add new network mount point"),"add", _("Add a new NFS or CIFS mount point to your Dreambox."), okpng ))
74 self.list.append((_("Mountpoints management"),"view", _("View, edit or delete mountpoints on your Dreambox."), okpng ))
75 self.list.append((_("User management"),"user", _("View, edit or delete usernames and passwords for your network."), okpng))
76 self.list.append((_("Change hostname"),"hostname", _("Change the hostname of your Dreambox."), okpng))
77 self["config"].setList(self.list)
82 def keyOK(self, returnValue = None):
83 if returnValue == None:
84 returnValue = self["config"].getCurrent()[1]
85 if returnValue is "add":
87 elif returnValue is "view":
89 elif returnValue is "user":
91 elif returnValue is "hostname":
95 self.session.open(AutoMountEdit, self.skin_path)
98 self.session.open(AutoMountView, self.skin_path)
101 self.session.open(UserManager, self.skin_path)
104 if os_path.exists("/etc/hostname"):
105 fp = open('/etc/hostname', 'r')
106 self.hostname = fp.read()
108 self.session.openWithCallback(self.hostnameCallback, VirtualKeyBoard, title = (_("Enter new hostname for your Dreambox")), text = self.hostname)
110 def hostnameCallback(self, callback = None):
111 if callback is not None and len(callback):
112 fp = open('/etc/hostname', 'w+')
117 def restartLan(self):
118 iNetwork.restartNetwork(self.restartLanDataAvail)
119 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
121 def restartLanDataAvail(self, data):
123 iNetwork.getInterfaces(self.getInterfacesDataAvail)
125 def getInterfacesDataAvail(self, data):
127 if self.restartLanRef.execing:
128 self.restartLanRef.close(True)
130 def restartfinishedCB(self,data):
132 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)