diff --git a/README b/README index e49e8db..355c3d5 100644 --- a/README +++ b/README @@ -2,7 +2,13 @@ Debugging --------- To compile debugging code configure the project with the --enable-debug option. Then at runtime you may set the environment variable "DBUSXX_VERBOSE=1" to activate debugging and to '0' to deactivate debugging. + Hints ----- Your applications based on dbus-c++ have to support PTHREAD and to export the variable HAVE_PTHREAD_H. + +BUGS: +----- +- dbus seems to stop working sometimes (only seen with ecore integrattion) +- ecore dbus integration is really "raw" (but working) at the moment diff --git a/configure.ac b/configure.ac index 77759e1..fb34ee9 100644 --- a/configure.ac +++ b/configure.ac @@ -203,7 +203,8 @@ AC_OUTPUT( examples/Makefile examples/properties/Makefile examples/echo/Makefile - examples/hal/Makefile + examples/ecore/Makefile + examples/hal/Makefile examples/glib/Makefile dbus-c++-1.pc dbus-c++-1-uninstalled.pc diff --git a/examples/Makefile.am b/examples/Makefile.am index b346604..3e81869 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = properties echo hal glib +SUBDIRS = properties echo hal glib ecore MAINTAINERCLEANFILES = \ Makefile.in diff --git a/examples/ecore/Makefile.am b/examples/ecore/Makefile.am new file mode 100644 index 0000000..93ab959 --- /dev/null +++ b/examples/ecore/Makefile.am @@ -0,0 +1,23 @@ +EXTRA_DIST = + +AM_CPPFLAGS = -I$(top_srcdir)/include $(ecore_CFLAGS) $(xml_CFLAGS) -I$(top_srcdir)/tools + +if ENABLE_ECORE +noinst_PROGRAMS = dbus_ecore +endif + +dbus_ecore_SOURCES = dbus_ecore-glue.h dbus_ecore.h dbus_ecore.cpp $(top_srcdir)/tools/xml.cpp +dbus_ecore_LDADD = $(top_builddir)/src/libdbus-c++-1.la $(ecore_LIBS) $(xml_LIBS) + +dbus_ecore-glue.h: $(top_srcdir)/data/org.freedesktop.DBus.xml + $(top_builddir)/tools/dbusxx-xml2cpp $^ --proxy=$@ + +BUILT_SOURCES = dbus_ecore-glue.h +CLEANFILES = $(BUILT_SOURCES) + +dist-hook: + cd $(distdir); rm -f $(BUILT_SOURCES) + +MAINTAINERCLEANFILES = \ + Makefile.in + diff --git a/examples/ecore/dbus_ecore.cpp b/examples/ecore/dbus_ecore.cpp new file mode 100644 index 0000000..e24b178 --- /dev/null +++ b/examples/ecore/dbus_ecore.cpp @@ -0,0 +1,68 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "dbus_ecore.h" + +#include +#include + +using namespace std; + +static const char* DBUS_SERVER_NAME = "org.freedesktop.DBus"; +static const char* DBUS_SERVER_PATH = "/org/freedesktop/DBus"; + +DBusBrowser::DBusBrowser( ::DBus::Connection& conn ) +: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME) +{ + typedef std::vector< ::DBus::String > Names; + + Names names = ListNames(); + + for(Names::iterator it = names.begin(); it != names.end(); ++it) + { + cout << *it << endl; + } +} + +void DBusBrowser::NameOwnerChanged( + const ::DBus::String& name, const ::DBus::String& old_owner, const ::DBus::String& new_owner ) +{ + cout << name << ": " << old_owner << " -> " << new_owner << endl; +} + +void DBusBrowser::NameLost( const ::DBus::String& name ) +{ + cout << name << " lost" << endl; +} + +void DBusBrowser::NameAcquired( const ::DBus::String& name ) +{ + cout << name << " acquired" << endl; +} + +DBus::Ecore::BusDispatcher dispatcher; + +void niam( int sig ) +{ + ecore_main_loop_quit(); +} + +int main(int argc, char* argv[]) +{ + signal(SIGTERM, niam); + signal(SIGINT, niam); + + ecore_init(); + + DBus::default_dispatcher = &dispatcher; + + DBus::Connection conn = DBus::Connection::SessionBus(); + + DBusBrowser browser(conn); + + ecore_main_loop_begin(); + ecore_shutdown(); + + return 0; +} diff --git a/examples/ecore/dbus_ecore.h b/examples/ecore/dbus_ecore.h new file mode 100644 index 0000000..e5190e9 --- /dev/null +++ b/examples/ecore/dbus_ecore.h @@ -0,0 +1,31 @@ +#ifndef __DEMO_DBUS_BROWSER_H +#define __DEMO_DBUS_BROWSER_H + +#include +#include +#include + +#include "dbus_ecore-glue.h" + +class DBusBrowser +: public org::freedesktop::DBus, + public DBus::IntrospectableProxy, + public DBus::ObjectProxy +{ +public: + + DBusBrowser( ::DBus::Connection& conn ); + +private: + + void NameOwnerChanged( const ::DBus::String&, const ::DBus::String&, const ::DBus::String& ); + + void NameLost( const ::DBus::String& ); + + void NameAcquired( const ::DBus::String& ); + +private: + +}; + +#endif//__DEMO_DBUS_BROWSER_H