Separated the client classes.
[cnetworkmanager.git] / device07.py
blobb134f18a3e823e72348babd785c9c0e231086257
1 from device import cDevice, cDeviceEth
2 from manager import NMI
3 from ap07 import cAP_07
4 from util import *
5 import dbus
7 class cDevice_07(cDevice):
8 def DeviceType0(self):
9 if self.dt is None:
10 self.dt = self.get_property("DeviceType")
11 if self.dt == 1:
12 self.__class__ = cDeviceEth_07
13 elif self.dt == 2:
14 self.__class__ = cDeviceWifi_07
15 elif self.dt == 3:
16 self.__class__ = cDeviceGSM_07
17 return self.dt
19 NM_DEVICE_STATE = [
20 "UNKNOWN", "UNMANAGED", "UNAVAILABLE", "DISCONNECTED", "PREPARE",
21 "CONFIG", "NEED_AUTH", "IP_CONFIG", "ACTIVATED", "FAILED",]
23 def Dump(self):
24 cDevice.Dump(self)
26 # "Ip4Config", only for NM_DEVICE_STATE_ACTIVATED
27 for P in ["Udi", "Interface", "Driver",]:
28 print " %s: %s" % (P, self.get_property(P))
29 addr = self.get_property("Ip4Address")
30 print " Ip4Address:", self.ip_str(addr)
31 caps = self.get_property("Capabilities")
32 print " Capabilities:", bitmask_str(self.NM_DEVICE_CAP, caps)
33 state = self.NM_DEVICE_STATE[self.get_property("State")]
34 print " Dev State:", state
35 if state == "ACTIVATED":
36 self.DumpIp4Config(self.get_property("Ip4Config"))
38 dt = self.DeviceType()
39 print " Dev Type:", dt
40 self.DumpMore()
42 class cDeviceEth_07(cDevice_07, cDeviceEth):
43 def DumpMore(self):
44 for P in ["HwAddress", "Speed", "Carrier"]:
45 print " %s: %s" % (P, self.get_property(P))
47 class cDeviceGSM_07(cDevice_07):
48 def DumpMore(self):
49 for P in []:
50 print " %s: %s" % (P, self.get_property(P))
52 class cDeviceWifi_07(cDevice_07):
53 NM_802_11_DEVICE_CAP = {1:"CIPHER_WEP40", 2:"CIPHER_WEP104",
54 4:"CIPHER_TKIP", 8:"CIPHER_CCMP",
55 16:"WPA", 32:"RSN",}
57 def APs(self):
58 self.wdevi = dbus.Interface(self.obj, NMI + ".Device.Wireless")
59 aps = self.wdevi.GetAccessPoints()
60 return map(cAP_07, aps)
62 def DumpMore(self):
63 print " Dev Mode:", self.IW_MODE[self.get_property("Mode")]
64 wcaps = self.get_property("WirelessCapabilities")
65 print " Wifi Capabilities:", bitmask_str(self.NM_802_11_DEVICE_CAP, wcaps)
66 for P in ["HwAddress", "Bitrate", "ActiveAccessPoint"]:
67 print " %s: %s" % (P, self.get_property(P))
68 #FIXME pass options otherwise
69 # if self.options.ap:
70 print " Access Points"
71 for ap in self.APs():
72 ap.Dump()