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.Label import Label
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="90,140" size="560,350" title="AutoMountManager">
24 <widget source="config" render="Listbox" position="10,10" size="540,220" scrollbarMode="showOnDemand" >
25 <convert type="TemplatedMultiContent">
27 MultiContentEntryText(pos = (0, 3), size = (480, 25), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 2 is the Menu Titel
28 MultiContentEntryText(pos = (10, 29), size = (480, 17), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 3 is the Description
29 MultiContentEntryPixmapAlphaTest(pos = (500, 1), size = (48, 48), png = 3), # index 4 is the pixmap
31 "fonts": [gFont("Regular", 20),gFont("Regular", 14)],
36 <widget name="introduction" position="90,260" size="300,20" zPosition="10" font="Regular;21" halign="center" transparent="1" />
37 <widget name="ButtonRedtext" position="410,305" size="140,21" zPosition="10" font="Regular;21" transparent="1" />
38 <widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="390,305" zPosition="10" size="15,16" transparent="1" alphatest="on" />
39 <ePixmap pixmap="skin_default/bottombar.png" position="10,250" size="540,120" zPosition="1" transparent="1" alphatest="on" />
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["ButtonRed"] = Pixmap()
55 self["ButtonRedtext"] = Label(_("Close"))
56 self["introduction"] = Label(_("Press OK to select."))
59 self["config"] = List(self.list)
61 self.onClose.append(self.cleanup)
62 self.onShown.append(self.setWindowTitle)
64 def setWindowTitle(self):
65 self.setTitle(_("MountManager"))
68 iNetwork.stopRestartConsole()
69 iNetwork.stopGetInterfacesConsole()
73 okpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/ok.png"))
74 self.list.append((_("Add new network mount point"),"add", _("Add a new NFS or CIFS mount point to your Dreambox."), okpng ))
75 self.list.append((_("Mountpoints management"),"view", _("View, edit or delete mountpoints on your Dreambox."), okpng ))
76 self.list.append((_("User management"),"user", _("View, edit or delete usernames and passwords for your network."), okpng))
77 self.list.append((_("Change hostname"),"hostname", _("Change the hostname of your Dreambox."), okpng))
78 self["config"].setList(self.list)
83 def keyOK(self, returnValue = None):
84 if returnValue == None:
85 returnValue = self["config"].getCurrent()[1]
86 if returnValue is "add":
88 elif returnValue is "view":
90 elif returnValue is "user":
92 elif returnValue is "hostname":
96 self.session.open(AutoMountEdit, self.skin_path)
99 self.session.open(AutoMountView, self.skin_path)
102 self.session.open(UserManager, self.skin_path)
105 if os_path.exists("/etc/hostname"):
106 fp = open('/etc/hostname', 'r')
107 self.hostname = fp.read()
109 self.session.openWithCallback(self.hostnameCallback, VirtualKeyBoard, title = (_("Enter new hostname for your Dreambox")), text = self.hostname)
111 def hostnameCallback(self, callback = None):
112 if callback is not None and len(callback):
113 fp = open('/etc/hostname', 'w+')
118 def restartLan(self):
119 iNetwork.restartNetwork(self.restartLanDataAvail)
120 self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)
122 def restartLanDataAvail(self, data):
124 iNetwork.getInterfaces(self.getInterfacesDataAvail)
126 def getInterfacesDataAvail(self, data):
128 if self.restartLanRef.execing:
129 self.restartLanRef.close(True)
131 def restartfinishedCB(self,data):
133 self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)