From c3f146913be36f4268900937de0b76aac1f748dd Mon Sep 17 00:00:00 2001 From: pd Date: Sun, 31 Aug 2008 17:44:52 +0200 Subject: [PATCH 1/7] Commented out unused variables (Marko Anastasov) --- include/dbus-c++/property.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/dbus-c++/property.h b/include/dbus-c++/property.h index 7bb3b38..c9755e1 100644 --- a/include/dbus-c++/property.h +++ b/include/dbus-c++/property.h @@ -80,10 +80,10 @@ public: protected: - virtual void on_get_property(InterfaceAdaptor &interface, const std::string &property, Variant &value) + virtual void on_get_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, Variant &/*value*/) {} - virtual void on_set_property(InterfaceAdaptor &interface, const std::string &property, const Variant &value) + virtual void on_set_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, const Variant &/*value*/) {} IntrospectedInterface *const introspect() const; From 050170173abc9739a8578ad7845ffb1b47cf8aa0 Mon Sep 17 00:00:00 2001 From: pd Date: Sun, 31 Aug 2008 19:25:24 +0200 Subject: [PATCH 2/7] Removed useless sleep() in example --- examples/echo/echo-server.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/echo/echo-server.cpp b/examples/echo/echo-server.cpp index 77e9616..d69333b 100644 --- a/examples/echo/echo-server.cpp +++ b/examples/echo/echo-server.cpp @@ -20,7 +20,6 @@ int32_t EchoServer::Random() std::string EchoServer::Hello(const std::string &name) { - sleep (10); return "Hello " + name + "!"; } From d2b0909093fe623b0c8ccfbba85aa0978160e0a8 Mon Sep 17 00:00:00 2001 From: pd Date: Fri, 5 Sep 2008 00:33:28 +0200 Subject: [PATCH 3/7] Typo in glib example --- examples/glib/Makefile.am | 2 +- examples/glib/dbus-browser.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/glib/Makefile.am b/examples/glib/Makefile.am index 849c468..42a33d8 100644 --- a/examples/glib/Makefile.am +++ b/examples/glib/Makefile.am @@ -1,6 +1,6 @@ EXTRA_DIST = -AM_CPPFLAGS = -I$(top_srcdir)/include $(gtkmm_CFLAGS) -I$(top_srcdir)/tools +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include $(gtkmm_CFLAGS) -I$(top_srcdir)/tools if HAVE_GTKMM noinst_PROGRAMS = dbus-browser diff --git a/examples/glib/dbus-browser.h b/examples/glib/dbus-browser.h index 4e95980..9bbefbf 100644 --- a/examples/glib/dbus-browser.h +++ b/examples/glib/dbus-browser.h @@ -19,7 +19,7 @@ public: }; class DBusBrowser -: public org::freedesktop::DBus, +: public org::freedesktop::DBus_proxy, public DBus::IntrospectableProxy, public DBus::ObjectProxy, public Gtk::Window From fcf526f7f21fc9c6f67b63cafca0e17484c77e75 Mon Sep 17 00:00:00 2001 From: pd Date: Fri, 5 Sep 2008 16:20:10 +0200 Subject: [PATCH 4/7] Added Properties XML description --- data/org.freedesktop.DBus.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/data/org.freedesktop.DBus.xml b/data/org.freedesktop.DBus.xml index 27afd0a..cbb38ab 100644 --- a/data/org.freedesktop.DBus.xml +++ b/data/org.freedesktop.DBus.xml @@ -6,6 +6,22 @@ + + + + + + + + + + + + + + + + From 96eb77ce7eea3b3d6155562fc1c7a7b1c206f287 Mon Sep 17 00:00:00 2001 From: pd Date: Fri, 5 Sep 2008 16:29:14 +0200 Subject: [PATCH 5/7] Redone properties example --- configure.ac | 1 - examples/Makefile.am | 2 +- examples/properties/Makefile.am | 20 +++-- examples/properties/README | 18 ----- examples/properties/props-introspect.xml | 10 --- examples/properties/props-server.cpp | 46 ------------ examples/properties/props-server.h | 21 ------ examples/properties/propsgs-client.cpp | 72 ++++++++++++++++++ .../propsgs-client.h | 4 +- .../propsgs-introspect.xml | 3 + .../propsgs-server.cpp | 10 +++ .../propsgs-server.h | 0 examples/properties_get_set/Makefile.am | 26 ------- .../properties_get_set/propsgs-client.cpp | 75 ------------------- 14 files changed, 102 insertions(+), 206 deletions(-) delete mode 100644 examples/properties/README delete mode 100644 examples/properties/props-introspect.xml delete mode 100644 examples/properties/props-server.cpp delete mode 100644 examples/properties/props-server.h create mode 100644 examples/properties/propsgs-client.cpp rename examples/{properties_get_set => properties}/propsgs-client.h (85%) rename examples/{properties_get_set => properties}/propsgs-introspect.xml (83%) rename examples/{properties_get_set => properties}/propsgs-server.cpp (82%) rename examples/{properties_get_set => properties}/propsgs-server.h (100%) delete mode 100644 examples/properties_get_set/Makefile.am delete mode 100644 examples/properties_get_set/propsgs-client.cpp diff --git a/configure.ac b/configure.ac index 0e5ed6b..b30b6cf 100644 --- a/configure.ac +++ b/configure.ac @@ -187,7 +187,6 @@ AC_OUTPUT( doc/Doxyfile examples/Makefile examples/properties/Makefile - examples/properties_get_set/Makefile examples/echo/Makefile examples/hal/Makefile examples/glib/Makefile diff --git a/examples/Makefile.am b/examples/Makefile.am index d3cbb7c..b346604 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = properties properties_get_set echo hal glib +SUBDIRS = properties echo hal glib MAINTAINERCLEANFILES = \ Makefile.in diff --git a/examples/properties/Makefile.am b/examples/properties/Makefile.am index 6cb3ad4..6e5419d 100644 --- a/examples/properties/Makefile.am +++ b/examples/properties/Makefile.am @@ -1,16 +1,22 @@ -EXTRA_DIST = README props-introspect.xml +EXTRA_DIST = propsget-introspect.xml AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -noinst_PROGRAMS = props-server +noinst_PROGRAMS = propsgs-server propsgs-client -props_server_SOURCES = props-glue.h props-server.h props-server.cpp -props_server_LDADD = $(top_builddir)/src/libdbus-c++-1.la +propsgs_server_SOURCES = propsgs-glue.h propsgs-server.h propsgs-server.cpp +propsgs_server_LDADD = $(top_builddir)/src/libdbus-c++-1.la -props-glue.h: props-introspect.xml - $(top_builddir)/tools/dbusxx-xml2cpp $^ --adaptor=$@ +propsgs_client_SOURCES = propsgs-glue.h propsgs-client.h propsgs-client.cpp +propsgs_client_LDADD = $(top_builddir)/src/libdbus-c++-1.la -lpthread -BUILT_SOURCES = props-glue.h +propsgs-glue-adaptor.h: propsgs-introspect.xml + $(top_builddir)/tools/dbusxx-xml2cpp $^ --adaptor=$@ -- + +propsgs-glue-proxy.h: propsgs-introspect.xml + $(top_builddir)/tools/dbusxx-xml2cpp $^ --proxy=$@ -- + +BUILT_SOURCES = propsgs-glue-adaptor.h propsgs-glue-proxy.h CLEANFILES = $(BUILT_SOURCES) dist-hook: diff --git a/examples/properties/README b/examples/properties/README deleted file mode 100644 index 2e7f3d7..0000000 --- a/examples/properties/README +++ /dev/null @@ -1,18 +0,0 @@ -This very simple example shows how to export properties (from objects implementing the org.freedesktop.DBus.Properties interface) - -To test, run `DBUSXX_VERBOSE=1 ./props-server` and try the following commands: - -dbus-send --dest=org.freedesktop.DBus.Examples.Properties --type=method_call --print-reply /org/freedesktop/DBus/Examples/Properties org.freedesktop.DBus.Properties.Get string:"org.freedesktop.DBus.PropsDemo" string:"Version" - -dbus-send --dest=org.freedesktop.DBus.Examples.Properties --type=method_call --print-reply /org/freedesktop/DBus/Examples/Properties org.freedesktop.DBus.Properties.Set string:"org.freedesktop.DBus.PropsDemo" string:"Version" int32:2 - -dbus-send --dest=org.freedesktop.DBus.Examples.Properties --type=method_call --print-reply /org/freedesktop/DBus/Examples/Properties org.freedesktop.DBus.Properties.Set string:"org.freedesktop.DBus.PropsDemo" string:"Message" variant:string:"Hello D-Bus" - -dbus-send --dest=org.freedesktop.DBus.Examples.Properties --type=method_call --print-reply /org/freedesktop/DBus/Examples/Properties org.freedesktop.DBus.Properties.Set string:"org.freedesktop.DBus.PropsDemo" string:"Message" variant:int32:200 - -dbus-send --dest=org.freedesktop.DBus.Examples.Properties --type=method_call --print-reply /org/freedesktop/DBus/Examples/Properties org.freedesktop.DBus.Properties.Get string:"org.freedesktop.DBus.PropsDemo" string:"Message" - -dbus-send --dest=org.freedesktop.DBus.Examples.Properties --type=method_call --print-reply /org/freedesktop/DBus/Examples/Properties org.freedesktop.DBus.Properties.Get string:"org.freedesktop.DBus.PropsDemo" string:"Something" - -dbus-send --dest=org.freedesktop.DBus.Examples.Properties --type=method_call --print-reply /org/freedesktop/DBus/Examples/Properties org.freedesktop.DBus.Properties.Get string:"org.freedesktop.DBus.PropsDemo" int32:100 - diff --git a/examples/properties/props-introspect.xml b/examples/properties/props-introspect.xml deleted file mode 100644 index 1ce7e72..0000000 --- a/examples/properties/props-introspect.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/examples/properties/props-server.cpp b/examples/properties/props-server.cpp deleted file mode 100644 index f782489..0000000 --- a/examples/properties/props-server.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "props-server.h" -#include - -static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties"; -static const char *PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties"; - -PropsServer::PropsServer(DBus::Connection &connection) -: DBus::ObjectAdaptor(connection, PROPS_SERVER_PATH) -{ - Version = 1; - Message = "default message"; -} - -void PropsServer::on_set_property - (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value) -{ - if (property == "Message") - { - std::string msg = value; - this->MessageChanged(msg); - } -} - -DBus::BusDispatcher dispatcher; - -void niam(int sig) -{ - dispatcher.leave(); -} - -int main() -{ - signal(SIGTERM, niam); - signal(SIGINT, niam); - - DBus::default_dispatcher = &dispatcher; - - DBus::Connection conn = DBus::Connection::SessionBus(); - conn.request_name(PROPS_SERVER_NAME); - - PropsServer server(conn); - - dispatcher.enter(); - - return 0; -} diff --git a/examples/properties/props-server.h b/examples/properties/props-server.h deleted file mode 100644 index 574ec40..0000000 --- a/examples/properties/props-server.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __DEMO_PROPS_SERVER_H -#define __DEMO_PROPS_SERVER_H - -#include -#include "props-glue.h" - -class PropsServer -: public org::freedesktop::DBus::PropsDemo_adaptor, - public DBus::IntrospectableAdaptor, - public DBus::PropertiesAdaptor, - public DBus::ObjectAdaptor -{ -public: - - PropsServer(DBus::Connection &connection); - - void on_set_property - (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); -}; - -#endif//__DEMO_PROPS_SERVER_H diff --git a/examples/properties/propsgs-client.cpp b/examples/properties/propsgs-client.cpp new file mode 100644 index 0000000..d4b51f4 --- /dev/null +++ b/examples/properties/propsgs-client.cpp @@ -0,0 +1,72 @@ +#include "propsgs-client.h" +#include +#include +#include + +using namespace org::freedesktop::DBus; + +static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties"; +static const char *PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties"; + +PropsClient::PropsClient(DBus::Connection &connection, const char *path, const char *name) +: DBus::ObjectProxy(connection, path, name) +{ +} + +void PropsClient::MessageChanged(const std::string& message) +{ + std::cout << "MessageChanged signal, new value: " << message << "\n"; +}; + +void PropsClient::DataChanged(const double& data) +{ + std::cout << "DataChanged signal, new value:" << data << "\n"; +}; + +void *test_property_proxy(void * input) +{ + PropsClient *client = static_cast(input); + + std::cout << "read property 'Version', value:" << client->Version() << "\n"; + + std::cout << "read property 'Message', value:" << client->Message() << "\n"; + + client->Message("message set by property access"); + std::cout << "wrote property 'Message'\n"; + + std::cout << "read property 'Message', value:" << client->Message() << "\n"; + + client->Data(1.1); + std::cout << "wrote property 'Data'\n"; + + return NULL; +} + +DBus::BusDispatcher dispatcher; + +void niam(int sig) +{ + dispatcher.leave(); + pthread_exit(NULL); +} + +int main() +{ + signal(SIGTERM, niam); + signal(SIGINT, niam); + + DBus::default_dispatcher = &dispatcher; + + DBus::_init_threading(); + + DBus::Connection conn = DBus::Connection::SessionBus(); + + PropsClient client (conn, PROPS_SERVER_PATH, PROPS_SERVER_NAME); + + pthread_t thread; + pthread_create(&thread, NULL, test_property_proxy, &client); + + dispatcher.enter(); + + return 0; +} diff --git a/examples/properties_get_set/propsgs-client.h b/examples/properties/propsgs-client.h similarity index 85% rename from examples/properties_get_set/propsgs-client.h rename to examples/properties/propsgs-client.h index 85595d5..99b70c5 100644 --- a/examples/properties_get_set/propsgs-client.h +++ b/examples/properties/propsgs-client.h @@ -7,7 +7,7 @@ class PropsClient : public org::freedesktop::DBus::PropsGSDemo_proxy, public DBus::IntrospectableProxy, -// public DBus::PropertiesProxy, + public DBus::PropertiesProxy, public DBus::ObjectProxy { public: @@ -15,6 +15,8 @@ public: PropsClient(DBus::Connection &connection, const char *path, const char *name); void MessageChanged(const std::string& message); + + void DataChanged(const double& data); }; #endif//__DEMO_PROPS_SERVER_H diff --git a/examples/properties_get_set/propsgs-introspect.xml b/examples/properties/propsgs-introspect.xml similarity index 83% rename from examples/properties_get_set/propsgs-introspect.xml rename to examples/properties/propsgs-introspect.xml index 5c0e74f..1045930 100644 --- a/examples/properties_get_set/propsgs-introspect.xml +++ b/examples/properties/propsgs-introspect.xml @@ -7,5 +7,8 @@ + + + diff --git a/examples/properties_get_set/propsgs-server.cpp b/examples/properties/propsgs-server.cpp similarity index 82% rename from examples/properties_get_set/propsgs-server.cpp rename to examples/properties/propsgs-server.cpp index 8339d20..c3ff23f 100644 --- a/examples/properties_get_set/propsgs-server.cpp +++ b/examples/properties/propsgs-server.cpp @@ -1,4 +1,5 @@ #include "propsgs-server.h" +#include #include static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties"; @@ -16,9 +17,18 @@ void PropsServer::on_set_property { if (property == "Message") { + std::cout << "'Message' has been changed\n"; + std::string msg = value; this->MessageChanged(msg); } + if (property == "Data") + { + std::cout << "'Data' has been changed\n"; + + double data = value; + this->DataChanged(data); + } } DBus::BusDispatcher dispatcher; diff --git a/examples/properties_get_set/propsgs-server.h b/examples/properties/propsgs-server.h similarity index 100% rename from examples/properties_get_set/propsgs-server.h rename to examples/properties/propsgs-server.h diff --git a/examples/properties_get_set/Makefile.am b/examples/properties_get_set/Makefile.am deleted file mode 100644 index 6e5419d..0000000 --- a/examples/properties_get_set/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -EXTRA_DIST = propsget-introspect.xml - -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include - -noinst_PROGRAMS = propsgs-server propsgs-client - -propsgs_server_SOURCES = propsgs-glue.h propsgs-server.h propsgs-server.cpp -propsgs_server_LDADD = $(top_builddir)/src/libdbus-c++-1.la - -propsgs_client_SOURCES = propsgs-glue.h propsgs-client.h propsgs-client.cpp -propsgs_client_LDADD = $(top_builddir)/src/libdbus-c++-1.la -lpthread - -propsgs-glue-adaptor.h: propsgs-introspect.xml - $(top_builddir)/tools/dbusxx-xml2cpp $^ --adaptor=$@ -- - -propsgs-glue-proxy.h: propsgs-introspect.xml - $(top_builddir)/tools/dbusxx-xml2cpp $^ --proxy=$@ -- - -BUILT_SOURCES = propsgs-glue-adaptor.h propsgs-glue-proxy.h -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - -MAINTAINERCLEANFILES = \ - Makefile.in diff --git a/examples/properties_get_set/propsgs-client.cpp b/examples/properties_get_set/propsgs-client.cpp deleted file mode 100644 index b47ad39..0000000 --- a/examples/properties_get_set/propsgs-client.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "propsgs-client.h" -#include -#include - -using namespace org::freedesktop::DBus; - -#define P(x) std::cout << #x << " = " << x << std::endl; - -static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties"; -static const char *PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties"; - -PropsClient::PropsClient(DBus::Connection &connection, const char *path, const char *name) -: DBus::ObjectProxy(connection, path, name) -{ -} - -void PropsClient::MessageChanged(const std::string& message){ - std::cout << "message received: " << message << std::endl; -}; - -DBus::BusDispatcher dispatcher; - -PropsClient * client; - -void niam(int sig) -{ - dispatcher.leave(); - pthread_exit(NULL); - delete client; -} - -#include - -void * test_property_proxy(void * input){ - P("1"); - sleep(2); - P(client->Version()); - - P("2"); - sleep(1); - P(client->Message()); - - P("3"); - sleep(1); - client->Message( "message set by property access" ); - - P("4"); - sleep(1); - P(client->Message()); - - P("5"); - sleep(1); - client->Data( 1.1 ); -} - -int main() -{ - signal(SIGTERM, niam); - signal(SIGINT, niam); - - DBus::default_dispatcher = &dispatcher; - - DBus::Connection conn = DBus::Connection::SessionBus(); - - client = new PropsClient(conn, PROPS_SERVER_PATH, PROPS_SERVER_NAME ); - - pthread_t thread; - pthread_create(&thread, NULL, test_property_proxy, 0); - - P("dispatcher.enter();"); - - dispatcher.enter(); - - return 0; -} From 17474fbb874876bfa4e7aec9e0705d0065848464 Mon Sep 17 00:00:00 2001 From: pd Date: Fri, 5 Sep 2008 16:30:11 +0200 Subject: [PATCH 6/7] Edited debug output in eventloop --- src/eventloop-integration.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/eventloop-integration.cpp b/src/eventloop-integration.cpp index ca72ca8..b107567 100644 --- a/src/eventloop-integration.cpp +++ b/src/eventloop-integration.cpp @@ -97,7 +97,8 @@ Timeout *BusDispatcher::add_timeout(Timeout::Internal *ti) bt->expired = new Callback(this, &BusDispatcher::timeout_expired); bt->data(bt); - debug_log("added timeout %p (%s)", bt, ((Timeout *)bt)->enabled() ? "on":"off"); + debug_log("added timeout %p (%s) interval=%d", + bt, ((Timeout *)bt)->enabled() ? "on":"off", ((Timeout *)bt)->interval()); return bt; } @@ -117,8 +118,7 @@ Watch *BusDispatcher::add_watch(Watch::Internal *wi) bw->data(bw); debug_log("added watch %p (%s) fd=%d flags=%d", - bw, ((Watch *)bw)->enabled() ? "on":"off", ((Watch *)bw)->descriptor(), ((Watch *)bw)->flags() - ); + bw, ((Watch *)bw)->enabled() ? "on":"off", ((Watch *)bw)->descriptor(), ((Watch *)bw)->flags()); return bw; } From 5b13d582bc1114d474278e092d2709c9570415c4 Mon Sep 17 00:00:00 2001 From: pd Date: Mon, 8 Sep 2008 19:07:59 +0200 Subject: [PATCH 7/7] Changed Makefile.am to reflect last file shuffling (Ignacy Gawedzki) --- examples/properties/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/properties/Makefile.am b/examples/properties/Makefile.am index 6e5419d..a99749a 100644 --- a/examples/properties/Makefile.am +++ b/examples/properties/Makefile.am @@ -1,13 +1,13 @@ -EXTRA_DIST = propsget-introspect.xml +EXTRA_DIST = propsgs-introspect.xml AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include noinst_PROGRAMS = propsgs-server propsgs-client -propsgs_server_SOURCES = propsgs-glue.h propsgs-server.h propsgs-server.cpp +propsgs_server_SOURCES = propsgs-glue-adaptor.h propsgs-server.h propsgs-server.cpp propsgs_server_LDADD = $(top_builddir)/src/libdbus-c++-1.la -propsgs_client_SOURCES = propsgs-glue.h propsgs-client.h propsgs-client.cpp +propsgs_client_SOURCES = propsgs-glue-proxy.h propsgs-client.h propsgs-client.cpp propsgs_client_LDADD = $(top_builddir)/src/libdbus-c++-1.la -lpthread propsgs-glue-adaptor.h: propsgs-introspect.xml