summaryrefslogtreecommitdiff
path: root/test/monitor-near
diff options
context:
space:
mode:
authorUlf <ulf.hofemeier@intel.com>2012-10-15 08:48:33 -0700
committerUlf <ulf.hofemeier@intel.com>2012-10-15 08:48:33 -0700
commitea5e13a057fdebdcc293c9da0b6544187ed0596f (patch)
treeb56b2772983e28566121a5109300be28eeba6add /test/monitor-near
downloadneard-ea5e13a057fdebdcc293c9da0b6544187ed0596f.tar.gz
neard-ea5e13a057fdebdcc293c9da0b6544187ed0596f.tar.bz2
neard-ea5e13a057fdebdcc293c9da0b6544187ed0596f.zip
Diffstat (limited to 'test/monitor-near')
-rwxr-xr-xtest/monitor-near62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/monitor-near b/test/monitor-near
new file mode 100755
index 0000000..fef307e
--- /dev/null
+++ b/test/monitor-near
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.mainloop.glib
+
+from dbus.lowlevel import MethodCallMessage, HANDLER_RESULT_NOT_YET_HANDLED
+
+def extract_list(list):
+ val = "["
+ for i in list:
+ val += " " + str(i)
+ val += " ]"
+ return val
+
+def extract_bool(b):
+ if b == dbus.Boolean(1):
+ val = "true"
+ else:
+ val = "false"
+ return val
+
+
+def property_changed_adapter(name, value, path):
+ adapter = path[path.rfind("/") + 1:]
+ if name in ["Polling"]:
+ val = extract_bool(value)
+ elif name in ["Tags", "Devices"]:
+ val = extract_list(value)
+ else:
+ val = str(value)
+
+ print "[Adapter] [%s] %s = %s" % (adapter, name, val)
+
+def property_changed_manager(name, value, path):
+ manager = path[path.rfind("/") + 1:]
+ if name in ["Adapters"]:
+ val = extract_list(value)
+
+ print "[Manager] %s = %s" % (name, val)
+
+
+if __name__ == '__main__':
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ bus = dbus.SystemBus()
+
+ bus.add_signal_receiver(property_changed_manager,
+ bus_name="org.neard",
+ dbus_interface="org.neard.Manager",
+ signal_name = "PropertyChanged",
+ path_keyword="path")
+
+ bus.add_signal_receiver(property_changed_adapter,
+ bus_name="org.neard",
+ dbus_interface="org.neard.Adapter",
+ signal_name = "PropertyChanged",
+ path_keyword="path")
+
+ mainloop = gobject.MainLoop()
+ mainloop.run()