from Screens.HelpMenu import HelpableScreen
from Components.Network import iNetwork
from Components.Sources.StaticText import StaticText
+from Components.Sources.Boolean import Boolean
from Components.Label import Label,MultiColorLabel
from Components.Pixmap import Pixmap,MultiPixmap
from Components.MenuList import MenuList
from Components.PluginComponent import plugins
from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
-from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_SKIN
from Tools.LoadPixmap import LoadPixmap
from Plugins.Plugin import PluginDescriptor
from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
num_configured_if = len(iNetwork.getConfiguredAdapters())
if num_configured_if >= 2:
if default is True:
- png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue.png"))
+ png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue.png"))
if default is False:
- png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/buttons/button_blue_off.png"))
+ png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/button_blue_off.png"))
res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(25, 25), png = png))
if active is True:
- png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_on.png"))
+ png2 = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_on.png"))
if active is False:
- png2 = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock_error.png"))
+ png2 = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_error.png"))
res.append(MultiContentEntryPixmapAlphaTest(pos=(40, 1), size=(25, 25), png = png2))
return res
self["key_red"] = StaticText(_("Close"))
self["key_green"] = StaticText(_("Select"))
self["key_yellow"] = StaticText("")
+ self["key_blue"] = StaticText("")
self["introduction"] = StaticText(self.edittext)
self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
{
"red": (self.close, _("exit network interface list")),
"green": (self.okbuttonClick, _("select interface")),
+ "blue": (self.openNetworkWizard, _("Use the Networkwizard to configure selected network adapter")),
})
self["DefaultInterfaceAction"] = HelpableActionMap(self, "ColorActions",
else:
active_int = False
self.list.append(InterfaceEntryComponent(index = x[1],name = _(x[0]),default=default_int,active=active_int ))
-
+
+ if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
+ self["key_blue"].setText(_("NetworkWizard"))
self["list"].l.setList(self.list)
def setDefaultInterface(self):
self.updateList()
self.session.open(MessageBox, _("Finished configuring your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
+ def openNetworkWizard(self):
+ if os_path.exists(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkWizard/networkwizard.xml")):
+ try:
+ from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
+ except ImportError:
+ self.session.open(MessageBox, _("The NetworkWizard extension is not installed!\nPlease install it."), type = MessageBox.TYPE_INFO,timeout = 10 )
+ else:
+ selection = self["list"].getCurrent()
+ if selection is not None:
+ self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard, selection[0])
class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
def remove(self):
print "currentIndex:", self["config"].getCurrentIndex()
-
index = self["config"].getCurrentIndex()
if index < len(self.nameservers):
iNetwork.removeNameserver(self.nameservers[index])
self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
{
- "cancel": (self.cancel, _("exit network adapter setup menu")),
- "ok": (self.ok, _("select menu entry")),
+ "cancel": (self.keyCancel, _("exit network adapter configuration")),
+ "ok": (self.keySave, _("activate network adapter configuration")),
})
self["ColorActions"] = HelpableActionMap(self, "ColorActions",
{
- "red": (self.cancel, _("exit network adapter configuration")),
+ "red": (self.keyCancel, _("exit network adapter configuration")),
"blue": (self.KeyBlue, _("open nameserver configuration")),
})
- self["VirtualKB"] = HelpableActionMap(self, "VirtualKeyboardActions",
- {
- "showVirtualKeyboard": (self.KeyText, [_("open virtual keyboard input help"),_("* Only available when entering hidden SSID or network key")] ),
- })
-
self["actions"] = NumberActionMap(["SetupActions"],
{
- "ok": self.ok,
+ "ok": self.keySave,
}, -2)
self.list = []
self["key_red"] = StaticText(_("Cancel"))
self["key_blue"] = StaticText(_("Edit DNS"))
- self["VKeyIcon"] = Pixmap()
+ self["VKeyIcon"] = Boolean(False)
self["HelpWindow"] = Pixmap()
-
+ self["HelpWindow"].hide()
+
def layoutFinished(self):
self["DNS1"].setText(self.primaryDNS.getText())
self["DNS2"].setText(self.secondaryDNS.getText())
self["Gateway"].setText("")
self["Gatewaytext"].setText("")
self["Adapter"].setText(iNetwork.getFriendlyAdapterName(self.iface))
- self["VKeyIcon"].hide()
- self["VirtualKB"].setEnabled(False)
- self["HelpWindow"].hide()
def createConfig(self):
self.InterfaceEntry = None
try:
self.aps = self.w.getNetworkList()
if self.aps is not None:
- print "[NetworkSetup.py] got Accespoints!"
for ap in self.aps:
a = self.aps[ap]
if a['active']:
self.default = self.wsconfig['ssid']
if "hidden..." not in self.nwlist:
- self.nwlist.append(("hidden...",_("hidden network")))
+ self.nwlist.append(("hidden...",_("enter hidden network SSID")))
if self.default not in self.nwlist:
self.nwlist.append((self.default,self.default))
config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default ))
self["config"].list = self.list
self["config"].l.setList(self.list)
- if not self.selectionChanged in self["config"].onSelectionChanged:
- self["config"].onSelectionChanged.append(self.selectionChanged)
def KeyBlue(self):
self.session.openWithCallback(self.NameserverSetupClosed, NameserverSetup)
- def KeyText(self):
- if self.iface == "wlan0" or self.iface == "ath0" :
- if self["config"].getCurrent() == self.hiddenSSID:
- if config.plugins.wlan.essid.value == 'hidden...':
- self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN network name/SSID:")), text = config.plugins.wlan.essid.value)
- if self["config"].getCurrent() == self.encryptionKey:
- self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value)
-
- def VirtualKeyBoardSSIDCallback(self, callback = None):
- if callback is not None and len(callback):
- config.plugins.wlan.hiddenessid.setValue(callback)
- self["config"].invalidate(self.hiddenSSID)
-
- def VirtualKeyBoardKeyCallback(self, callback = None):
- if callback is not None and len(callback):
- config.plugins.wlan.encryption.psk.setValue(callback)
- self["config"].invalidate(self.encryptionKey)
-
def newConfig(self):
if self["config"].getCurrent() == self.InterfaceEntry:
self.createSetup()
def keyRight(self):
ConfigListScreen.keyRight(self)
self.newConfig()
+
+ def keySave(self):
+ self.hideInputHelp()
+ if self["config"].isChanged():
+ self.session.openWithCallback(self.keySaveConfirm, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
+ else:
+ if self.finished_cb:
+ self.finished_cb()
+ else:
+ self.close('cancel')
- def selectionChanged(self):
- current = self["config"].getCurrent()
- if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
- 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)
- elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
- 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 keySaveConfirm(self, ret = False):
+ if (ret == True):
+ num_configured_if = len(iNetwork.getConfiguredAdapters())
+ if num_configured_if >= 1:
+ if num_configured_if == 1 and self.iface in iNetwork.getConfiguredAdapters():
+ self.applyConfig(True)
+ else:
+ self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("A second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
+ else:
+ self.applyConfig(True)
else:
- self["VKeyIcon"].hide()
- self["VirtualKB"].setEnabled(False)
+ self.keyCancel()
- def ok(self):
- current = self["config"].getCurrent()
- if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
- if current[1].help_window.instance is not None:
- current[1].help_window.instance.hide()
- elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
- if current[1].help_window.instance is not None:
- current[1].help_window.instance.hide()
- self.session.openWithCallback(self.applyConfig, MessageBox, (_("Are you sure you want to activate this network configuration?\n\n") + self.oktext ) )
+ def secondIfaceFoundCB(self,data):
+ if data is False:
+ self.applyConfig(True)
+ else:
+ configuredInterfaces = iNetwork.getConfiguredAdapters()
+ for interface in configuredInterfaces:
+ if interface == self.iface:
+ continue
+ iNetwork.setAdapterAttribute(interface, "up", False)
+ iNetwork.deactivateInterface(interface)
+ self.applyConfig(True)
def applyConfig(self, ret = False):
if (ret == True):
iNetwork.restartNetwork(self.applyConfigDataAvail)
self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False)
else:
- self.cancel()
+ self.keyCancel()
def applyConfigDataAvail(self, data):
if data is True:
def applyConfigfinishedCB(self,data):
if data is True:
- num_configured_if = len(iNetwork.getConfiguredAdapters())
- if num_configured_if >= 2:
- self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("Your network configuration has been activated.\nA second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True)
+ if self.finished_cb:
+ self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
else:
- if self.finished_cb:
- self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
- else:
- self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
-
- def secondIfaceFoundCB(self,data):
- if data is False:
- self.close('ok')
- else:
- configuredInterfaces = iNetwork.getConfiguredAdapters()
- for interface in configuredInterfaces:
- if interface == self.iface:
- continue
- iNetwork.setAdapterAttribute(interface, "up", False)
- iNetwork.deactivateInterface(interface)
- self.applyConfig(True)
+ self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
def ConfigfinishedCB(self,data):
if data is not None:
if data is True:
self.close('ok')
- def cancel(self):
+ def keyCancelConfirm(self, result):
+ if not result:
+ return
if self.oldInterfaceState is False:
- iNetwork.deactivateInterface(self.iface,self.cancelCB)
+ iNetwork.deactivateInterface(self.iface,self.keyCancelCB)
+ else:
+ self.close('cancel')
+
+ def keyCancel(self):
+ self.hideInputHelp()
+ if self["config"].isChanged():
+ self.session.openWithCallback(self.keyCancelConfirm, MessageBox, _("Really close without saving settings?"))
else:
self.close('cancel')
- def cancelCB(self,data):
+ def keyCancelCB(self,data):
if data is not None:
if data is True:
self.close('cancel')
def runAsync(self, finished_cb):
self.finished_cb = finished_cb
- self.ok()
+ self.keySave()
def NameserverSetupClosed(self, *ret):
iNetwork.loadNameserverConfig()
def cleanup(self):
iNetwork.stopLinkStateConsole()
+
+ def hideInputHelp(self):
+ current = self["config"].getCurrent()
+ if current == self.hiddenSSID and config.plugins.wlan.essid.value == 'hidden...':
+ if current[1].help_window.instance is not None:
+ current[1].help_window.instance.hide()
+ elif current == self.encryptionKey and config.plugins.wlan.encryption.enabled.value:
+ if current[1].help_window.instance is not None:
+ current[1].help_window.instance.hide()
class AdapterSetupConfiguration(Screen, HelpableScreen):
self.session = session
self.iface = iface
self.restartLanRef = None
+ self.LinkState = None
self.mainmenu = self.genMainMenu()
self["menulist"] = MenuList(self.mainmenu)
self["key_red"] = StaticText(_("Close"))
self.onClose.append(self.cleanup)
def ok(self):
+ self.cleanup()
if self["menulist"].getCurrent()[1] == 'edit':
if self.iface == 'wlan0' or self.iface == 'ath0':
try:
self.session.openWithCallback(self.restartLan, MessageBox, (_("Are you sure you want to restart your network interfaces?\n\n") + self.oktext ) )
if self["menulist"].getCurrent()[1] == 'openwizard':
from Plugins.SystemPlugins.NetworkWizard.NetworkWizard import NetworkWizard
- self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard)
+ self.session.openWithCallback(self.AdapterSetupClosed, NetworkWizard, self.iface)
if self["menulist"].getCurrent()[1][0] == 'extendedSetup':
self.extended = self["menulist"].getCurrent()[1][2]
self.extended(self.session, self.iface)
self.loadDescription()
def loadDescription(self):
- print self["menulist"].getCurrent()[1]
if self["menulist"].getCurrent()[1] == 'edit':
self["description"].setText(_("Edit the network configuration of your Dreambox.\n" ) + self.oktext )
if self["menulist"].getCurrent()[1] == 'test':
self["description"].setText(_(self["menulist"].getCurrent()[1][1]) + self.oktext )
def updateStatusbar(self, data = None):
+ self.mainmenu = self.genMainMenu()
+ self["menulist"].l.setList(self.mainmenu)
self["IFtext"].setText(_("Network:"))
self["IF"].setText(iNetwork.getFriendlyAdapterName(self.iface))
self["Statustext"].setText(_("Link:"))
if self.iface == 'wlan0' or self.iface == 'ath0':
try:
- from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
+ from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
except:
- self["statuspic"].setPixmapNum(1)
- self["statuspic"].show()
+ self["statuspic"].setPixmapNum(1)
+ self["statuspic"].show()
else:
iStatus.getDataForInterface(self.iface,self.getInfoCB)
else:
callFnc = p.__call__["ifaceSupported"](self.iface)
if callFnc is not None:
self.extended = callFnc
- print p.__call__
if p.__call__.has_key("WlanPluginEntry"): # internally used only for WLAN Plugin
menu.append((_("Scan Wireless Networks"), "scanwlan"))
if iNetwork.getAdapterAttribute(self.iface, "up"):
# Display Wlan not available Message
self.showErrorMessage()
else:
- self.mainmenu = self.genMainMenu()
- self["menulist"].l.setList(self.mainmenu)
self.updateStatusbar()
else:
- self.mainmenu = self.genMainMenu()
- self["menulist"].l.setList(self.mainmenu)
self.updateStatusbar()
def WlanStatusClosed(self, *ret):
if ret is not None and len(ret):
from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
iStatus.stopWlanConsole()
- self.mainmenu = self.genMainMenu()
- self["menulist"].l.setList(self.mainmenu)
self.updateStatusbar()
def WlanScanClosed(self,*ret):
else:
from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
iStatus.stopWlanConsole()
- self.mainmenu = self.genMainMenu()
- self["menulist"].l.setList(self.mainmenu)
self.updateStatusbar()
def restartLan(self, ret = False):
self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False)
def dataAvail(self,data):
- self.output = data.strip()
- result = self.output.split('\n')
- pattern = re_compile("Link detected: yes")
- for item in result:
- if re_search(pattern, item):
- self["statuspic"].setPixmapNum(0)
- else:
- self["statuspic"].setPixmapNum(1)
- self["statuspic"].show()
+ self.LinkState = None
+ for line in data.splitlines():
+ line = line.strip()
+ if 'Link detected:' in line:
+ if "yes" in line:
+ self.LinkState = True
+ else:
+ self.LinkState = False
+ if self.LinkState == True:
+ iNetwork.checkNetworkState(self.checkNetworkCB)
+ else:
+ self["statuspic"].setPixmapNum(1)
+ self["statuspic"].show()
def showErrorMessage(self):
self.session.open(MessageBox, self.errortext, type = MessageBox.TYPE_INFO,timeout = 10 )
def cleanup(self):
iNetwork.stopLinkStateConsole()
iNetwork.stopDeactivateInterfaceConsole()
+ iNetwork.stopPingConsole()
try:
- from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus,Status
+ from Plugins.SystemPlugins.WirelessLan.Wlan import iStatus
except ImportError:
pass
else:
iStatus.stopWlanConsole()
def getInfoCB(self,data,status):
+ self.LinkState = None
if data is not None:
if data is True:
if status is not None:
if status[self.iface]["acesspoint"] == "No Connection" or status[self.iface]["acesspoint"] == "Not-Associated" or status[self.iface]["acesspoint"] == False:
+ self.LinkState = False
self["statuspic"].setPixmapNum(1)
+ self["statuspic"].show()
else:
- self["statuspic"].setPixmapNum(0)
- self["statuspic"].show()
+ self.LinkState = True
+ iNetwork.checkNetworkState(self.checkNetworkCB)
+
+ def checkNetworkCB(self,data):
+ if iNetwork.getAdapterAttribute(self.iface, "up") is True:
+ if self.LinkState is True:
+ if data <= 2:
+ self["statuspic"].setPixmapNum(0)
+ else:
+ self["statuspic"].setPixmapNum(1)
+ self["statuspic"].show()
+ else:
+ self["statuspic"].setPixmapNum(1)
+ self["statuspic"].show()
+ else:
+ self["statuspic"].setPixmapNum(1)
+ self["statuspic"].show()
+
class NetworkAdapterTest(Screen):
def __init__(self, session,iface):
pass
else:
iStatus.stopWlanConsole()
-
+