Separated the client classes.
[cnetworkmanager.git] / manager.py
blobdf4808ede65ea0d49eaf2578923e9785a83cddb3
1 import dbus
3 import object
5 NMI = 'org.freedesktop.NetworkManager'
7 class cNM(object.cObject):
8 # TODO: pull them from introspection.xml
9 NM_STATE = ["UNKNOWN", "ASLEEP", "CONNECTING", "CONNECTED", "DISCONNECTED",]
11 def __init__(self, opath, options):
12 object.cObject.__init__(self, opath)
13 self.nmi = dbus.Interface(self.obj, NMI)
14 self.options = options
16 def get_property(self, property_name):
17 return object.cObject.get_property(self, NMI, property_name)
19 def set_property(self, property_name, value):
20 return object.cObject.set_property(self, NMI, property_name, value)
22 def Api(self):
23 return "common"
25 def Dump0(self):
26 "Dumps its own info (not owned objects)."
27 pass
29 def Dump(self):
30 self.Dump0()
31 if self.options.dev:
32 for device in self.Devices():
33 device.Dump()
35 if self.options.actcon:
36 print "Active Connections"
37 aconns = self.ActiveConnections()
38 for aconn in aconns:
39 aconn.Dump()
41 def ListNets(self):
42 print "Wifi Networks:"
43 for dev in self.Devices():
44 dev.ListNets()
46 def err_handler(self, *args):
47 print "ERR:", args
49 def silent_handler(self, *args):
50 pass
51 #print "BOO!:", args
53 def quitter_handler(self, *args):
54 # exit the loop that runs only because of us
55 print "padla"
56 sys.exit(0)
58 def WatchState(self):
59 self.bus.add_signal_receiver(self.state_changed_handler,
60 dbus_interface="org.freedesktop.NetworkManager",
61 signal_name="StateChanged")
63 def state_changed_handler(self, *args):
64 s = args[0]
65 ss = self.NM_STATE[s]
66 print time.strftime("(%X)"),
67 print "State:", ss