Cleaned up namespace: networkmanager.applet.
[cnetworkmanager.git] / monitor.py
blob4439163843e91065ccfa9469da0a4968f15db399
1 from monitor_base import MonitorBase
2 from manager import cNM
3 from device07 import cDevice_07
5 class Monitor(MonitorBase):
6 def __init__(self, bus):
7 MonitorBase.__init__(self, bus)
9 self.watch(
10 self.propc_h,
11 dbus_interface="org.freedesktop.NetworkManager.Device.Wireless",
12 signal_name="PropertiesChanged")
13 self.watch(
14 self.propc_h,
15 dbus_interface="org.freedesktop.NetworkManager.AccessPoint",
16 signal_name="PropertiesChanged")
18 self.ignore("org.freedesktop.Hal.Device", "PropertyModified")
19 self.ignore("fi.epitest.hostap.WPASupplicant.Interface", "ScanResultsAvailable")
20 self.ignore("com.redhat.PrinterSpooler", "QueueChanged")
21 self.ignore("org.freedesktop.NetworkManager", "StateChange") # deprecated
22 self.watch(self.nm_sc_h, "org.freedesktop.NetworkManager", "StateChanged")
23 self.watch(self.wpas_isc_h, "fi.epitest.hostap.WPASupplicant.Interface", "StateChange")
24 self.watch(self.nmd_sc_h, "org.freedesktop.NetworkManager.Device", "StateChanged")
25 self.watch(self.bus_noc_h, "org.freedesktop.DBus", "NameOwnerChanged")
27 def bus_noc_h(self, *args, **kwargs):
28 (name, old, new) = args
29 if new == "":
30 new = "gone"
31 else:
32 new = "at " + new
33 print "\tBUS NOC\t%s %s" % (name, new)
35 def wpas_isc_h(self, *args, **kwargs):
36 opath = kwargs["path"]
37 (new, old) = args
38 print "\tWPAS %s\t(%s, was %s)" % (new, opath, old.lower())
40 def nmd_sc_h(self, *args, **kwargs):
41 opath = kwargs["path"]
42 (new, old, reason) = args
43 news = cDevice_07.NM_DEVICE_STATE[new]
44 olds = cDevice_07.NM_DEVICE_STATE[old]
45 reasons = ""
46 if reason != 0:
47 reasons = "reason %d" % reason
48 print "\tDevice State %s\t(%s, was %s%s)" % (news, opath, olds.lower(), reasons)
50 def nm_sc_h(self, *args, **kwargs):
51 s = args[0]
52 ss = cNM.NM_STATE[s]
53 print "\tNM State:", ss
55 def propc_h(self, *args, **kwargs):
56 opath = kwargs["path"]
57 props = args[0]
58 for k, v in props.iteritems():
59 if k == "Strength":
60 v = "%u" % v
61 line = "\tPROP\t%s\t%s\t(%s)" % (k, v, opath)
62 print line