Separated the client classes.
[cnetworkmanager.git] / manager06.py
blob0c951a473d70687e0c8cc7328ed678acc814ee7e
1 import manager
3 class cNM_06(manager.cNM):
4 def Api(self):
5 return "06"
7 def SetWifiEnabled(self, v):
8 # TODO: async call, catch the state signal and exit
9 # weird: synchronous call works, but times out
10 # asynchronous call does not work
11 self.nmi.setWirelessEnabled(v,
12 reply_handler=self.quitter_handler,
13 error_handler=self.quitter_handler)
14 global LOOP
15 LOOP = True
17 def SetOnline(self, v):
18 if v:
19 self.nmi.wake(True,
20 reply_handler=self.quitter_handler,
21 error_handler=self.quitter_handler)
22 else:
23 self.nmi.sleep(True,
24 reply_handler=self.quitter_handler,
25 error_handler=self.quitter_handler)
26 global LOOP
27 LOOP = True
29 def Dump0(self):
30 print "State:", self.NM_STATE[self.nmi.state()]
31 we = self.nmi.getWirelessEnabled()
32 if isinstance(we, tuple):
33 print "Wifi enabled:", bool(we[0])
34 print "Wifi HW enabled:", bool(we[1])
35 else:
36 print "Wifi enabled:", bool(we)
38 try:
39 dup = self.nmi.getDialup()
40 print "Dialup:", dup
41 except dbus.exceptions.DBusException, e:
42 #if e.get_dbus_name() == "org.freedesktop.NetworkManager.NoDialup":
43 # pass
44 #else:
45 print e
47 def Devices(self):
48 opaths = self.nmi.getDevices()
49 return map(cDevice_06, opaths)
51 def ActiveConnections(self):
52 return [] # at most one active connection, FIXME find it
54 def ActivateConnection(self, conn, device, ap):
55 # passing *_handler makes the call asynchronous
56 self.nmi.setActiveDevice(device.opath, ssid_str(conn.Ssid()),
57 reply_handler=self.silent_handler,
58 error_handler=self.err_handler,