dbusmm/examples/ping example_ping_listen.cc, 1.1.1.1, 1.2 example_ping_send.cc, 1.1.1.1, 1.2

Murray Cumming murrayc at freedesktop.org
Mon Jun 20 01:10:44 PDT 2005


Update of /cvs/dbus/dbusmm/examples/ping
In directory gabe:/tmp/cvs-serv5178/examples/ping

Modified Files:
	example_ping_listen.cc example_ping_send.cc 
Log Message:
2005-06-20  Murray Cumming <murrayc at murrayc.com>

        * dbus/src/connection.ccg:
        * dbus/src/proxy.ccg:
        * dbus/src/proxy.hg:
        * tools/m4/convert.m4:
        * tools/m4/convert_dbus.m4: Added Proxy, though
        it is currently impossible to wrap the constructors, and
        the signature-less callbacks need some thought.


Index: example_ping_listen.cc
===================================================================
RCS file: /cvs/dbus/dbusmm/examples/ping/example_ping_listen.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- example_ping_listen.cc	20 Jun 2005 07:11:37 -0000	1.1.1.1
+++ example_ping_listen.cc	20 Jun 2005 08:10:42 -0000	1.2
@@ -1,36 +1,45 @@
 #include <dbusmm.h>
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus.h>
+
 #include <iostream>
 #include <sstream>
 
 
+Glib::RefPtr<DBus::Connection> con;
+
 static DBusHandlerResult signal_filter 
       (DBusConnection *connection, DBusMessage *message, void *user_data);
 
 int
 main (int argc, char **argv)
 {
-  GMainLoop *loop;
-  
+  /* Create a new event loop to run in */
+  Glib::RefPtr<Glib::MainLoop> loop = Glib::MainLoop::create();
+
   try
   {
     /* Get a connection to the session bus */
-    dbus::connection con = dbus::bus::get_connection(); 
-
-    loop = g_main_loop_new (NULL, FALSE);
+    con = DBus::Connection::get();
 
-    dbus_connection_setup_with_g_main (bus.cobj(), NULL);
+    /* Set up this connection to work in a GLib event loop */
+    con->setup_with_main();
 
     /* listening to messages from all objects as no path is specified */
-    dbus_bus_add_match (con.cobj(), "type='signal',interface='com.burtonini.dbus.Signal'", 0);
-    dbus_connection_add_filter (con.cobj(), signal_filter, loop, NULL);
+    //dbus_bus_add_match (con.cobj(), "type='signal',interface='com.burtonini.dbus.Signal'", 0);
+    //dbus_connection_add_filter (con.cobj(), signal_filter, loop, NULL);
 
-    g_main_loop_run (loop);
+    /* Start the event loop */
+    loop->run();
   }
-  catch(const dbus::exception& ex)
+  catch(const DBus::Error& ex)
   {
     std::cout << "dbus exception caught: " << std::endl << ex.what() << std::endl;
   }
 
+
+
   return 0;
 }
 

Index: example_ping_send.cc
===================================================================
RCS file: /cvs/dbus/dbusmm/examples/ping/example_ping_send.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- example_ping_send.cc	20 Jun 2005 07:11:37 -0000	1.1.1.1
+++ example_ping_send.cc	20 Jun 2005 08:10:42 -0000	1.2
@@ -50,7 +50,7 @@
     /* Start the event loop */
     loop->run();
   }
-  catch(const DBus::exception& ex)
+  catch(const DBus::Error& ex)
   {
     std::cout << "dbus exception caught: " << std::endl << ex.what() << std::endl;
   }



More information about the dbus-commit mailing list