]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
[dbus_conn] extend test with filters to make it work like dbus-monitor
authorPrashanth Mundkur <prashanth.mundkur@citrix.com>
Thu, 16 Jul 2009 22:47:59 +0000 (15:47 -0700)
committerPrashanth Mundkur <prashanth.mundkur@citrix.com>
Thu, 16 Jul 2009 22:47:59 +0000 (15:47 -0700)
common/test/dbus_mon.ml

index 983d3c4473acde84eaa101ef0e6636c7066d8c93..cb27a39689c148a8f27a93c10c14ab04e22cce24 100644 (file)
@@ -19,10 +19,11 @@ let msg_received_callback conn m =
         | None -> ());
        List.iter (fun arg ->
                        Printf.printf " Arg: %s\n" (DBus.string_of_ty arg)
-                 ) (DBus.Message.get m)
+                 ) (DBus.Message.get m);
+       Printf.printf "%!"
 
 let error_callback conn err =
-       Printf.printf "Received error.\n"
+       Printf.printf "Received error.\n%!"
 
 let callbacks =
 {
@@ -46,6 +47,14 @@ let make_get_machine_id () =
        let msg = DBus.Message.new_method_call destination path interface meth
        in msg
 
+let make_filter msg_type =
+       let path = "/org/freedesktop/DBus" in
+       let interface = "org.freedesktop.DBus" in
+       let meth = "AddMatch" in
+       let msg = DBus.Message.new_method_call destination path interface meth in
+         DBus.Message.append msg [(DBus.String (Printf.sprintf "type='%s'" msg_type))];
+         msg
+
 let loop el conn =
        while Eventloop.has_connections el || Eventloop.has_timers el
        do
@@ -65,6 +74,11 @@ let main () =
        Dbus_conn.enable_recv conn;
        ignore (Dbus_conn.send conn (make_ping ()));
        ignore (Dbus_conn.send conn (make_get_machine_id ()));
+       ignore (Dbus_conn.send conn (make_filter "method_call"));
+       ignore (Dbus_conn.send conn (make_filter "method_return"));
+       ignore (Dbus_conn.send conn (make_filter "error"));
+       ignore (Dbus_conn.send conn (make_filter "signal"));
+
        loop el conn
 
 let _ =