1 from Screens.Screen import Screen
2 from Screens.MessageBox import MessageBox
4 from Components.ActionMap import ActionMap, NumberActionMap
5 from Components.Pixmap import Pixmap
6 from Components.Label import Label
7 from Components.GUIComponent import *
8 from Components.MenuList import MenuList
9 from Components.MultiContent import MultiContentEntryText
12 from Components.config import config, getConfigListEntry
13 from Components.ConfigList import ConfigList, ConfigListScreen
14 from Components.Network import Network
16 from Plugins.Plugin import PluginDescriptor
18 from Wlan import Wlan, WlanList, wpaSupplicant
20 plugin_path = "/usr/lib/enigma2/python/Plugins/SystemPlugins/WirelessLan"
22 class WlanSelection(Screen):
24 <screen position="70,138" size="610,300" title="Choose a Wireless Network" >
25 <widget name="list" position="10,10" size="580,200" scrollbarMode="showOnDemand" />
27 <widget name="cancel" position="10,255" size="140,40" pixmap="~/key-red.png" zPosition="1" transparent="1" alphatest="on" />
28 <widget name="select" position="160,255" size="140,40" pixmap="~/key-green.png" zPosition="1" transparent="1" alphatest="on" />
29 <widget name="rescan" position="310,255" size="140,40" pixmap="~/key-yellow.png" zPosition="1" transparent="1" alphatest="on" />
30 <widget name="skip" position="460,255" size="140,40" pixmap="~/key-blue.png" zPosition="1" transparent="1" alphatest="on" />
32 <widget name="canceltext" position="10,255" size="140,40" valign="center" halign="center" zPosition="2" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
33 <widget name="selecttext" position="160,255" size="140,40" valign="center" halign="center" zPosition="2" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
34 <widget name="rescantext" position="310,255" size="140,40" valign="center" halign="center" zPosition="2" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
35 <widget name="skiptext" position="460,255" size="140,40" valign="center" halign="center" zPosition="2" font="Regular;20" transparent="1" foregroundColor="#FFFFFF" />
38 def __init__(self, session, args = None):
40 self.skin = WlanSelection.skin
41 self.session = session
42 Screen.__init__(self, session)
46 self["list"] = WlanList(self.session)
47 self.skin_path = plugin_path
49 self["cancel"] = Pixmap()
50 self["select"] = Pixmap()
51 self["rescan"] = Pixmap()
52 self["skip"] = Pixmap()
55 self["canceltext"] = Label(_("Cancel"))
56 self["selecttext"] = Label(_("Select"))
57 self["rescantext"] = Label(_("Rescan"))
58 self["skiptext"] = Label(_("Skip"))
60 self["actions"] = NumberActionMap(["WizardActions", "InputActions", "EPGSelectActions"],
68 self["shortcuts"] = ActionMap(["ShortcutActions"],
72 "yellow": self.rescan,
77 cur = self["list"].getCurrent()
79 ret = (self.session, cur)
81 ret = (self.session, None)
88 self.close( (self.session, None) )
91 self.close( (None ,) )
93 class WlanConfiguration(ConfigListScreen, Screen):
95 <screen position="76,138" size="600,300" title="Wireless Network Configuration" >
96 <widget name="interface" position="10,10" size="580,30" font="Regular;24" valign="center" />
97 <widget name="config" position="10,60" size="580,150" scrollbarMode="showOnDemand" />
98 <widget name="introduction" position="100,260" size="400,30" font="Regular;23" valign="center" halign="center" />
102 def __init__(self, session, essid = None, encrypted = False, iface = "wlan0"):
104 Screen.__init__(self, session)
105 self.skin = WlanConfiguration.skin
109 self.ws = wpaSupplicant()
111 self["introduction"] = Label(_("Press OK to activate the settings."))
112 self["interface"] = Label(_("Interface: ")+self.iface)
118 config.plugins.wlan.essid.value = essid
119 config.plugins.wlan.encryption.enabled.value = True
121 self["actions"] = ActionMap(["SetupActions"],
124 "cancel": self.cancel,
127 ConfigListScreen.__init__(self, self.list)
130 def createSetup(self):
134 self.list.append(getConfigListEntry(_("Network SSID"), config.plugins.wlan.essid))
135 self.list.append(getConfigListEntry(_("Encryption"), config.plugins.wlan.encryption.enabled))
137 if config.plugins.wlan.encryption.enabled.value:
138 self.list.append(getConfigListEntry(_("Encryption Type"), config.plugins.wlan.encryption.type))
139 self.list.append(getConfigListEntry(_("Encryption Key"), config.plugins.wlan.encryption.psk))
141 self["config"].list = self.list
142 self["config"].l.setList(self.list)
145 ConfigListScreen.keyLeft(self)
149 ConfigListScreen.keyRight(self)
153 self.ws.writeConfig()
154 self.ws.restart(self.iface)
160 def EntryChosen(parms):
163 if parms[1] is not None:
168 session.open(WlanConfiguration, essid, encrypted, iface)
170 session.open(WlanConfiguration)
172 def WlanSelectionMain(session, iface):
173 session.openWithCallback(EntryChosen, WlanSelection)
175 def WlanConfigurationMain(session, **kwargs):
176 session.open(WlanConfiguration)
178 def callFunction(iface):
181 if iface in w.getWirelessInterfaces():
182 return WlanSelectionMain
186 def configStrings(iface):
187 return "#Custom Configstring for "+iface
189 def Plugins(**kwargs):
190 return PluginDescriptor(name=_("Wireless LAN"), description=_("Connect to a Wireless Network"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": callFunction, "configStrings": configStrings, "menuEntryName": lambda x: _("Wlan Configuartion Utility")})