Add working Networkinteface Source/Converter
[enigma2-plugins.git] / webinterface / src / WebComponents / Sources / Network.py
1 from Components.Sources.Source import Source
2 from Components.Network import iNetwork
3 #from Components.Element import cached
4
5
6 class Network(Source):
7     LAN = 0
8     WLAN = 1
9     
10     def __init__(self, device = LAN):
11         Source.__init__(self)
12         if device is self.LAN:
13             self.iface = "eth0"
14         elif device is self.WLAN:
15             self.iface = "ath0"
16             
17             
18             #Get Network Info
19     def ConvertIP(self, list):
20         if(len(list) == 4):
21             retstr = "%s.%s.%s.%s" %(list[0], list[1], list[2], list[3])
22         else:
23             retstr = "0.0.0.0"
24         return retstr
25 #    @cached        
26     def getInterface(self):
27         self.mac =  iNetwork.getAdapterAttribute(self.iface, "mac")
28         self.dhcp = iNetwork.getAdapterAttribute(self.iface, "dhcp")
29         self.ip = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "ip"))
30         self.netmask = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "netmask"))
31         self.gateway = self.ConvertIP(iNetwork.getAdapterAttribute(self.iface, "gateway"))
32         
33         return self
34         
35     interface = property(getInterface)
36     
37     def destroy(self):
38         Source.destroy(self)