From 48a1be9f2acc19ea9f25cefa7d06cb1e04cd9d51 Mon Sep 17 00:00:00 2001 From: pdurante Date: Sun, 29 Apr 2007 01:17:32 +0000 Subject: [PATCH] * Included config.h in all headers * Don't define DBUS_API_SUBJECT_TO_CHANGE unless for old D-Bus versions * Use recursive mutex functions if libdbus supports it * Specify the path when adding match rules, otherwise messages wouldn't be forwarded to the right object under some circumstances * Added integration with the glib main loop (configure with --enable-glib) * Added a gtkmm dbus-browser clone to demonstrate glib integration * Fixed a typo in dbusxx-xml2cpp proxy output * Added python usage instructions for the Echo example git-svn-id: http://dev.openwengo.org/svn/openwengo/wengophone-ng/branches/wengophone-dbus-api/libs/dbus@10948 30a43799-04e7-0310-8b2b-ea0d24f86d0e --- configure.ac | 35 +++++++- examples/Makefile.am | 2 +- examples/echo/README | 12 +++ examples/glib/Makefile.am | 22 +++++ examples/glib/dbus-browser.cpp | 135 +++++++++++++++++++++++++++++++ examples/glib/dbus-browser.h | 62 ++++++++++++++ include/dbus-c++/config.h.in | 6 ++ include/dbus-c++/connection.h | 4 + include/dbus-c++/dbus.h | 4 + include/dbus-c++/debug.h | 4 + include/dbus-c++/dispatcher.h | 16 +++- include/dbus-c++/error.h | 4 + include/dbus-c++/eventloop.h | 4 + include/dbus-c++/interface.h | 4 + include/dbus-c++/introspection.h | 4 + include/dbus-c++/message.h | 4 + include/dbus-c++/object.h | 4 + include/dbus-c++/pendingcall.h | 4 + include/dbus-c++/property.h | 4 + include/dbus-c++/refptr_impl.h | 4 + include/dbus-c++/server.h | 4 + include/dbus-c++/types.h | 4 + include/dbus-c++/util.h | 4 + include/dbus-c++/xml.h | 4 + src/Makefile.am | 16 ++-- src/connection_p.h | 4 + src/dispatcher.cpp | 26 ++++++ src/dispatcher_p.h | 4 + src/internalerror.h | 4 + src/message_p.h | 4 + src/object.cpp | 17 ++-- src/pendingcall_p.h | 4 + src/server_p.h | 4 + tools/Makefile.am | 3 +- tools/introspect.h | 4 + tools/xml2cpp.cpp | 2 +- tools/xml2cpp.h | 4 + 37 files changed, 427 insertions(+), 23 deletions(-) create mode 100644 examples/glib/Makefile.am create mode 100644 examples/glib/dbus-browser.cpp create mode 100644 examples/glib/dbus-browser.h diff --git a/configure.ac b/configure.ac index ccbf569..ec9f9be 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,12 @@ AC_ARG_ENABLE(debug, enable_debug=$enableval,enable_debug=auto ) +AC_ARG_ENABLE(glib, + AS_HELP_STRING([--enable-glib], + [enable glib integration]), + enable_glib=$enableval,enable_debug=auto +) + AC_ARG_ENABLE(doxygen-docs, AS_HELP_STRING([--enable-doxygen-docs], [build DOXYGEN documentation (requires Doxygen)]), @@ -48,6 +54,32 @@ PKG_CHECK_MODULES([dbus], dbus-1 >= $DBUS_REQUIRED_VERSION,, AC_SUBST(dbus_CFLAGS) AC_SUBST(dbus_LIBS) +DBUS_API_STABLE_VERSION=1.0.0 +PKG_CHECK_EXISTS(dbus-1 < $DBUS_API_STABLE_VERSION, + AC_DEFINE(DBUS_API_SUBJECT_TO_CHANGE, , [unstable DBus]) +) + +DBUS_RECURSIVE_MUTEX_VERSION=0.95 +PKG_CHECK_EXISTS(dbus-1 >= $DBUS_RECURSIVE_MUTEX_VERSION, + AC_DEFINE(DBUS_HAS_RECURSIVE_MUTEX, , [DBus supports recursive mutexes (needs DBus >= 0.95)]) +) + +if test x$enable_glib = xyes ; then +PKG_CHECK_MODULES([glib], glib-2.0) +AC_SUBST(glib_CFLAGS) +AC_SUBST(glib_LIBS) +AM_CONDITIONAL(ENABLE_GLIB, test 1 = 1) +PKG_CHECK_MODULES([gtkmm], gtkmm-2.4, + AM_CONDITIONAL(HAVE_GTKMM, test 1 = 1), + AM_CONDITIONAL(HAVE_GTKMM, test 0 = 1) +) +AC_SUBST(gtkmm_CFLAGS) +AC_SUBST(gtkmm_LIBS) +else +AM_CONDITIONAL(ENABLE_GLIB, test 0 = 1) +AM_CONDITIONAL(HAVE_GTKMM, test 0 = 1) +fi + AC_CHECK_LIB([expat], XML_ParserCreate_MM, [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ], have_expat=false) @@ -66,7 +98,7 @@ AC_SUBST(xml_LIBS) if test x$enable_debug = xyes ; then CXXFLAGS="-Wall -ggdb -O0 -DDEBUG" else - CXXFLAGS="-Wall -O3 -DDEBUG" + CXXFLAGS="-Wall -O3" fi @@ -122,5 +154,6 @@ AC_OUTPUT( examples/properties/Makefile examples/echo/Makefile examples/hal/Makefile + examples/glib/Makefile dbus-c++-1.pc ) diff --git a/examples/Makefile.am b/examples/Makefile.am index 98b2e27..b346604 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = properties echo hal +SUBDIRS = properties echo hal glib MAINTAINERCLEANFILES = \ Makefile.in diff --git a/examples/echo/README b/examples/echo/README index 0422415..74e1d6d 100644 --- a/examples/echo/README +++ b/examples/echo/README @@ -9,3 +9,15 @@ dbus-send --dest=org.freedesktop.DBus.Examples.Echo --type=method_call --print-r dbus-send --dest=org.freedesktop.DBus.Examples.Echo --type=method_call --print-reply /org/freedesktop/DBus/Examples/Echo org.freedesktop.DBus.EchoDemo.Sum array:int32:10,100,250 dbus-send --dest=org.freedesktop.DBus.Examples.Echo --type=method_call --print-reply /org/freedesktop/DBus/Examples/Echo org.freedesktop.DBus.EchoDemo.Info + +or, using python instead + +$ python +import dbus +bus = dbus.SessionBus() +object = bus.get_object('org.freedesktop.DBus.Examples.Echo','/org/freedesktop/DBus/Examples/Echo') +echo = dbus.Interface(object, dbus_interface='org.freedesktop.DBus.EchoDemo') +echo.Random() +echo.Hello("world") +echo.Sum([123, 234, 95, 520]) +echo.Info() diff --git a/examples/glib/Makefile.am b/examples/glib/Makefile.am new file mode 100644 index 0000000..a327c00 --- /dev/null +++ b/examples/glib/Makefile.am @@ -0,0 +1,22 @@ +EXTRA_DIST = + +AM_CPPFLAGS = -I$(top_srcdir)/include $(gtkmm_CFLAGS) + +if HAVE_GTKMM +noinst_PROGRAMS = dbus-browser +endif + +dbus_browser_SOURCES = dbus-glue.h dbus-browser.h dbus-browser.cpp +dbus_browser_LDADD = $(top_builddir)/src/libdbus-c++-1.la $(gtkmm_LIBS) + +dbus-glue.h: $(top_srcdir)/data/org.freedesktop.DBus.xml + $(top_builddir)/tools/dbusxx-xml2cpp $^ --proxy=$@ + +BUILT_SOURCES = dbus-glue.h +CLEANFILES = $(BUILT_SOURCES) + +dist-hook: + cd $(distdir); rm -f $(BUILT_SOURCES) + +MAINTAINERCLEANFILES = \ + Makefile.in diff --git a/examples/glib/dbus-browser.cpp b/examples/glib/dbus-browser.cpp new file mode 100644 index 0000000..04f9bad --- /dev/null +++ b/examples/glib/dbus-browser.cpp @@ -0,0 +1,135 @@ +#include "dbus-browser.h" + +#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) +{ + set_title("D-Bus Browser"); + set_border_width(5); + set_default_size(400, 500); + + typedef std::vector< ::DBus::String > Names; + + Names names = ListNames(); + + for(Names::iterator it = names.begin(); it != names.end(); ++it) + { + _cb_busnames.append_text(*it); + } + + _cb_busnames.signal_changed().connect( sigc::mem_fun(*this, &DBusBrowser::on_select_busname) ); + + _tm_inspect = Gtk::TreeStore::create(_records); + _tv_inspect.set_model(_tm_inspect); + _tv_inspect.append_column("Node", _records.name); + + _sc_tree.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + _sc_tree.add(_tv_inspect); + + _vbox.pack_start(_cb_busnames, Gtk::PACK_SHRINK); + _vbox.pack_start(_sc_tree); + + add(_vbox); + + show_all_children(); +} + +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; +} + +void DBusBrowser::on_select_busname() +{ + Glib::ustring busname = _cb_busnames.get_active_text(); + if(busname.empty()) return; + + _tm_inspect->clear(); + _inspect_append(NULL, "", busname); +} + +void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string& buspath, const std::string& busname ) +{ + DBusInspector inspector(conn(), buspath.empty() ? "/" : buspath.c_str(), busname.c_str()); + + ::DBus::Xml::Document doc(inspector.Introspect()); + ::DBus::Xml::Node& root = *(doc.root); + + ::DBus::Xml::Nodes ifaces = root["interface"]; + + for(::DBus::Xml::Nodes::iterator ii = ifaces.begin(); ii != ifaces.end(); ++ii) + { + ::DBus::Xml::Node& iface = **ii; + + Gtk::TreeModel::Row i_row = row + ? *(_tm_inspect->append(row->children())) + : *(_tm_inspect->append()); + i_row[_records.name] = "interface: " + iface.get("name"); + + ::DBus::Xml::Nodes methods = iface["method"]; + + for(::DBus::Xml::Nodes::iterator im = methods.begin(); im != methods.end(); ++im) + { + Gtk::TreeModel::Row m_row = *(_tm_inspect->append(i_row.children())); + m_row[_records.name] = "method: " + (*im)->get("name"); + } + + ::DBus::Xml::Nodes signals = iface["signal"]; + + for(::DBus::Xml::Nodes::iterator is = signals.begin(); is != signals.end(); ++is) + { + Gtk::TreeModel::Row s_row = *(_tm_inspect->append(i_row.children())); + s_row[_records.name] = "signal: " + (*is)->get("name"); + } + } + + ::DBus::Xml::Nodes nodes = root["node"]; + + for(::DBus::Xml::Nodes::iterator in = nodes.begin(); in != nodes.end(); ++in) + { + std::string name = (*in)->get("name"); + + Gtk::TreeModel::Row n_row = row + ? *(_tm_inspect->append(row->children())) + : *(_tm_inspect->append()); + n_row[_records.name] = name; + + _inspect_append(&n_row, buspath + "/" + name, busname); + } +} + +DBus::Glib::BusDispatcher dispatcher; + +int main(int argc, char* argv[]) +{ + Gtk::Main kit(argc, argv); + + DBus::default_dispatcher = &dispatcher; + + dispatcher.attach(NULL); + + DBus::Connection conn = DBus::Connection::SessionBus(); + + DBusBrowser browser(conn); + + Gtk::Main::run(browser); + + return 0; +} diff --git a/examples/glib/dbus-browser.h b/examples/glib/dbus-browser.h new file mode 100644 index 0000000..10c9b3d --- /dev/null +++ b/examples/glib/dbus-browser.h @@ -0,0 +1,62 @@ +#ifndef __DEMO_DBUS_BROWSER_H +#define __DEMO_DBUS_BROWSER_H + +#include +#include +#include + +#include "dbus-glue.h" + +class DBusInspector +: public DBus::IntrospectableProxy, + public DBus::ObjectProxy +{ +public: + + DBusInspector( DBus::Connection& conn, const char* path, const char* service ) + : DBus::ObjectProxy(conn, path, service) + {} +}; + +class DBusBrowser +: public org::freedesktop::DBus, + public DBus::IntrospectableProxy, + public DBus::ObjectProxy, + public Gtk::Window +{ +public: + + DBusBrowser( ::DBus::Connection& ); + +private: + + void NameOwnerChanged( const ::DBus::String&, const ::DBus::String&, const ::DBus::String& ); + + void NameLost( const ::DBus::String& ); + + void NameAcquired( const ::DBus::String& ); + + void on_select_busname(); + + void _inspect_append( Gtk::TreeModel::Row*, const std::string&, const std::string& ); + +private: + + class InspectRecord : public Gtk::TreeModel::ColumnRecord + { + public: + + InspectRecord() { add(name); } + + Gtk::TreeModelColumn name; + }; + + Gtk::VBox _vbox; + Gtk::ScrolledWindow _sc_tree; + Gtk::ComboBoxText _cb_busnames; + Gtk::TreeView _tv_inspect; + Glib::RefPtr _tm_inspect; + InspectRecord _records; +}; + +#endif//__DEMO_DBUS_BROWSER_H diff --git a/include/dbus-c++/config.h.in b/include/dbus-c++/config.h.in index d9bffb5..8130122 100644 --- a/include/dbus-c++/config.h.in +++ b/include/dbus-c++/config.h.in @@ -1,5 +1,11 @@ /* include/dbus-c++/config.h.in. Generated from configure.ac by autoheader. */ +/* unstable DBus */ +#undef DBUS_API_SUBJECT_TO_CHANGE + +/* DBus supports recursive mutexes (needs DBus >= 0.95) */ +#undef DBUS_HAS_RECURSIVE_MUTEX + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H diff --git a/include/dbus-c++/connection.h b/include/dbus-c++/connection.h index 869e6b9..614c41e 100644 --- a/include/dbus-c++/connection.h +++ b/include/dbus-c++/connection.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_CONNECTION_H #define __DBUSXX_CONNECTION_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "types.h" diff --git a/include/dbus-c++/dbus.h b/include/dbus-c++/dbus.h index 9ec837b..5c03b16 100644 --- a/include/dbus-c++/dbus.h +++ b/include/dbus-c++/dbus.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_DBUS_H #define __DBUSXX_DBUS_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "types.h" #include "interface.h" #include "object.h" diff --git a/include/dbus-c++/debug.h b/include/dbus-c++/debug.h index 8829ce3..fcc3e73 100644 --- a/include/dbus-c++/debug.h +++ b/include/dbus-c++/debug.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_DEBUG_H #define __DBUSXX_DEBUG_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + namespace DBus { typedef void (*LogFunction)(const char* format, ...); diff --git a/include/dbus-c++/dispatcher.h b/include/dbus-c++/dispatcher.h index 4f19db5..c59ec6c 100644 --- a/include/dbus-c++/dispatcher.h +++ b/include/dbus-c++/dispatcher.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_DISPATCHER_H #define __DBUSXX_DISPATCHER_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "connection.h" namespace DBus { @@ -126,9 +130,9 @@ public: virtual ~Mutex() {} - virtual bool lock() = 0; + virtual void lock() = 0; - virtual bool unlock() = 0; + virtual void unlock() = 0; struct Internal; @@ -158,10 +162,18 @@ protected: Internal* _int; }; +#ifndef DBUS_HAS_RECURSIVE_MUTEX +typedef Mutex* (*MutexNewFn)(); +typedef bool (*MutexFreeFn)( Mutex* mx ); +typedef bool (*MutexLockFn)( Mutex* mx ); +typedef void (*MutexUnlockFn)( Mutex* mx ); +#else typedef Mutex* (*MutexNewFn)(); typedef void (*MutexFreeFn)( Mutex* mx ); typedef void (*MutexLockFn)( Mutex* mx ); typedef void (*MutexUnlockFn)( Mutex* mx ); +#endif//DBUS_HAS_RECURSIVE_MUTEX + typedef CondVar* (*CondVarNewFn)(); typedef void (*CondVarFreeFn)( CondVar* cv ); typedef void (*CondVarWaitFn)( CondVar* cv, Mutex* mx ); diff --git a/include/dbus-c++/error.h b/include/dbus-c++/error.h index 2505bb4..023e36a 100644 --- a/include/dbus-c++/error.h +++ b/include/dbus-c++/error.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_ERROR_H #define __DBUSXX_ERROR_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "util.h" #include diff --git a/include/dbus-c++/eventloop.h b/include/dbus-c++/eventloop.h index 7903a10..016dd86 100644 --- a/include/dbus-c++/eventloop.h +++ b/include/dbus-c++/eventloop.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_EVENTLOOP_H #define __DBUSXX_EVENTLOOP_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "dispatcher.h" diff --git a/include/dbus-c++/interface.h b/include/dbus-c++/interface.h index ad02279..90c398d 100644 --- a/include/dbus-c++/interface.h +++ b/include/dbus-c++/interface.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_INTERFACE_H #define __DBUSXX_INTERFACE_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include "util.h" diff --git a/include/dbus-c++/introspection.h b/include/dbus-c++/introspection.h index 8e343c5..a6d7ebf 100644 --- a/include/dbus-c++/introspection.h +++ b/include/dbus-c++/introspection.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_INTROSPECTION_H #define __DBUSXX_INTROSPECTION_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "interface.h" namespace DBus { diff --git a/include/dbus-c++/message.h b/include/dbus-c++/message.h index 389c5c3..a710c9c 100644 --- a/include/dbus-c++/message.h +++ b/include/dbus-c++/message.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_MESSAGE_H #define __DBUSXX_MESSAGE_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/include/dbus-c++/object.h b/include/dbus-c++/object.h index d0a2f61..65bbcf0 100644 --- a/include/dbus-c++/object.h +++ b/include/dbus-c++/object.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_OBJECT_H #define __DBUSXX_OBJECT_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/include/dbus-c++/pendingcall.h b/include/dbus-c++/pendingcall.h index 0b71b51..1b7ccbc 100644 --- a/include/dbus-c++/pendingcall.h +++ b/include/dbus-c++/pendingcall.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_PENDING_CALL_H #define __DBUSXX_PENDING_CALL_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "util.h" namespace DBus { diff --git a/include/dbus-c++/property.h b/include/dbus-c++/property.h index 6b17018..f0b4670 100644 --- a/include/dbus-c++/property.h +++ b/include/dbus-c++/property.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_PROPERTY_H #define __DBUSXX_PROPERTY_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "types.h" #include "interface.h" diff --git a/include/dbus-c++/refptr_impl.h b/include/dbus-c++/refptr_impl.h index 5e29a26..1f78a24 100644 --- a/include/dbus-c++/refptr_impl.h +++ b/include/dbus-c++/refptr_impl.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_REFPTR_IMPL_H #define __DBUSXX_REFPTR_IMPL_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "util.h" namespace DBus { diff --git a/include/dbus-c++/server.h b/include/dbus-c++/server.h index a75c174..8e858e0 100644 --- a/include/dbus-c++/server.h +++ b/include/dbus-c++/server.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_SERVER_H #define __DBUSXX_SERVER_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "error.h" diff --git a/include/dbus-c++/types.h b/include/dbus-c++/types.h index a180c9f..1e68a37 100644 --- a/include/dbus-c++/types.h +++ b/include/dbus-c++/types.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_TYPES_H #define __DBUSXX_TYPES_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/include/dbus-c++/util.h b/include/dbus-c++/util.h index 58c7f84..a8ac23c 100644 --- a/include/dbus-c++/util.h +++ b/include/dbus-c++/util.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_UTIL_H #define __DBUSXX_UTIL_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "debug.h" namespace DBus { diff --git a/include/dbus-c++/xml.h b/include/dbus-c++/xml.h index d9d23de..79574c0 100644 --- a/include/dbus-c++/xml.h +++ b/include/dbus-c++/xml.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_XML_H #define __DBUSXX_XML_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/Makefile.am b/src/Makefile.am index 3962aca..aa850b2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,8 +1,13 @@ AM_CPPFLAGS = \ $(dbus_CFLAGS) \ $(xml_CFLAGS) \ - -I$(top_srcdir)/include \ - -DDBUS_API_SUBJECT_TO_CHANGE + $(glib_CFLAGS) \ + -I$(top_srcdir)/include + +if ENABLE_GLIB +GLIB_H = $(HEADER_DIR)/glib-integration.h +GLIB_CPP = glib-integration.cpp +endif HEADER_DIR = $(top_srcdir)/include/dbus-c++ HEADER_FILES = \ @@ -24,14 +29,15 @@ HEADER_FILES = \ $(HEADER_DIR)/util.h \ $(HEADER_DIR)/refptr_impl.h \ $(HEADER_DIR)/xml.h \ - $(HEADER_DIR)/introspection.h + $(HEADER_DIR)/introspection.h \ + $(GLIB_H) lib_includedir=$(includedir)/dbus-c++-1/dbus-c++/ lib_include_HEADERS = $(HEADER_FILES) lib_LTLIBRARIES = libdbus-c++-1.la -libdbus_c___1_la_SOURCES = $(HEADER_FILES) interface.cpp object.cpp introspection.cpp debug.cpp eventloop.cpp xml.cpp types.cpp connection.cpp connection_p.h property.cpp dispatcher.cpp dispatcher_p.h pendingcall.cpp pendingcall_p.h error.cpp internalerror.h message.cpp message_p.h server.cpp server_p.h -libdbus_c___1_la_LIBADD = $(dbus_LIBS) $(xml_LIBS) +libdbus_c___1_la_SOURCES = $(HEADER_FILES) interface.cpp object.cpp introspection.cpp debug.cpp eventloop.cpp xml.cpp types.cpp connection.cpp connection_p.h property.cpp dispatcher.cpp dispatcher_p.h pendingcall.cpp pendingcall_p.h error.cpp internalerror.h message.cpp message_p.h server.cpp server_p.h $(GLIB_CPP) +libdbus_c___1_la_LIBADD = $(dbus_LIBS) $(xml_LIBS) $(glib_LIBS) MAINTAINERCLEANFILES = \ Makefile.in diff --git a/src/connection_p.h b/src/connection_p.h index a8d8490..9a1d489 100644 --- a/src/connection_p.h +++ b/src/connection_p.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_CONNECTION_P_H #define __DBUSXX_CONNECTION_P_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp index 3e5abd2..c8100df 100644 --- a/src/dispatcher.cpp +++ b/src/dispatcher.cpp @@ -181,6 +181,7 @@ void DBus::_init_threading( CondVarWakeAllFn c6 ) { +#ifndef DBUS_HAS_RECURSIVE_MUTEX DBusThreadFunctions functions = { DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK | DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK | @@ -203,5 +204,30 @@ void DBus::_init_threading( (DBusCondVarWakeOneFunction) c5, (DBusCondVarWakeAllFunction) c6 }; +#else + DBusThreadFunctions functions = { + DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK | + DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK | + DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK | + DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK | + DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK | + DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK | + DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK | + DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK | + DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK| + DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK, + 0, 0, 0, 0, + (DBusCondVarNewFunction) c1, + (DBusCondVarFreeFunction) c2, + (DBusCondVarWaitFunction) c3, + (DBusCondVarWaitTimeoutFunction) c4, + (DBusCondVarWakeOneFunction) c5, + (DBusCondVarWakeAllFunction) c6, + (DBusRecursiveMutexNewFunction) m1, + (DBusRecursiveMutexFreeFunction) m2, + (DBusRecursiveMutexLockFunction) m3, + (DBusRecursiveMutexUnlockFunction) m4 + }; +#endif//DBUS_HAS_RECURSIVE_MUTEX dbus_threads_init(&functions); } diff --git a/src/dispatcher_p.h b/src/dispatcher_p.h index 2f7b074..97e2e36 100644 --- a/src/dispatcher_p.h +++ b/src/dispatcher_p.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_DISPATCHER_P_H #define __DBUSXX_DISPATCHER_P_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/internalerror.h b/src/internalerror.h index 8a8b15c..9285f55 100644 --- a/src/internalerror.h +++ b/src/internalerror.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_INTERNALERROR_H #define __DBUSXX_INTERNALERROR_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/message_p.h b/src/message_p.h index fb5b107..406ee6a 100644 --- a/src/message_p.h +++ b/src/message_p.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_MESSAGE_P_H #define __DBUSXX_MESSAGE_P_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/object.cpp b/src/object.cpp index 94c3b43..0ad759e 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -143,7 +143,7 @@ void ObjectAdaptor::register_obj() InterfaceAdaptorTable::const_iterator ii = _interfaces.begin(); while( ii != _interfaces.end() ) { - std::string im = "type='method_call',interface='"+ii->first+"'"; + std::string im = "type='method_call',interface='"+ii->first+"',path='"+path()+"'"; conn().add_match(im.c_str()); ++ii; } @@ -163,7 +163,7 @@ void ObjectAdaptor::unregister_obj() InterfaceAdaptorTable::const_iterator ii = _interfaces.begin(); while( ii != _interfaces.end() ) { - std::string im = "type='method_call',interface='"+ii->first+"'"; + std::string im = "type='method_call',interface='"+ii->first+"',path='"+path()+"'"; conn().remove_match(im.c_str()); ++ii; } @@ -290,13 +290,10 @@ void ObjectProxy::register_obj() InterfaceProxyTable::const_iterator ii = _interfaces.begin(); while( ii != _interfaces.end() ) { - std::string im = "type='signal',interface='"+ii->first+"'"; + std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'"; conn().add_match(im.c_str()); ++ii; } - -// conn().add_match("type='signal'"); -// conn().add_match("type='method_call'"); } void ObjectProxy::unregister_obj() @@ -306,13 +303,10 @@ void ObjectProxy::unregister_obj() InterfaceProxyTable::const_iterator ii = _interfaces.begin(); while( ii != _interfaces.end() ) { - std::string im = "type='signal',interface='"+ii->first+"'"; + std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'"; conn().remove_match(im.c_str()); ++ii; } -// conn().remove_match("type='method_call'"); -// conn().remove_match("type='signal'"); - conn().remove_filter(_filtered); } @@ -334,7 +328,8 @@ bool ObjectProxy::handle_message( const Message& msg ) const char* interface = smsg.interface(); const char* member = smsg.member(); - debug_log("filtered signal %s(in %s) from remote object %s", member, interface, msg.sender()); + debug_log("filtered signal %s(in %s) from remote object %s", + member, interface, msg.sender()); InterfaceProxy* ii = find_interface(interface); if( ii ) diff --git a/src/pendingcall_p.h b/src/pendingcall_p.h index bf24a87..2f65f11 100644 --- a/src/pendingcall_p.h +++ b/src/pendingcall_p.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_PENDING_CALL_P_H #define __DBUSXX_PENDING_CALL_P_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/src/server_p.h b/src/server_p.h index 3c7b063..c6c050b 100644 --- a/src/server_p.h +++ b/src/server_p.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_SERVER_P_H #define __DBUSXX_SERVER_P_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/tools/Makefile.am b/tools/Makefile.am index 73a0df9..c512098 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -4,8 +4,7 @@ CXX = $(CXX_FOR_BUILD) AM_CPPFLAGS = \ $(dbus_CFLAGS) \ - -I$(top_srcdir)/include \ - -DDBUS_API_SUBJECT_TO_CHANGE + -I$(top_srcdir)/include if CROSS_COMPILING libdbus_cxx_la = $(BUILD_LIBDBUS_CXX_DIR)/src/libdbus-c++-1.la diff --git a/tools/introspect.h b/tools/introspect.h index 7e218a2..3633611 100644 --- a/tools/introspect.h +++ b/tools/introspect.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_TOOLS_INTROSPECT_H #define __DBUSXX_TOOLS_INTROSPECT_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/tools/xml2cpp.cpp b/tools/xml2cpp.cpp index df8bebc..3b38c6c 100644 --- a/tools/xml2cpp.cpp +++ b/tools/xml2cpp.cpp @@ -353,7 +353,7 @@ void generate_proxy( Xml::Document& doc, const char* filename ) if(arg_name.length()) file << tab << tab << "wi << " << arg_name << ";" << endl; else - file << tab << tab << "wi << argout" << j << ";" << endl; + file << tab << tab << "wi << argin" << j << ";" << endl; } file << tab << tab << "call.member(\"" << method.get("name") << "\");" << endl diff --git a/tools/xml2cpp.h b/tools/xml2cpp.h index 7bb1981..e385edb 100644 --- a/tools/xml2cpp.h +++ b/tools/xml2cpp.h @@ -25,6 +25,10 @@ #ifndef __DBUSXX_TOOLS_XML2CPP_H #define __DBUSXX_TOOLS_XML2CPP_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include