From 25a2ef65af65cab9241da2684cdec0f078dc8c4d Mon Sep 17 00:00:00 2001 From: Andreas Volz Date: Mon, 16 Nov 2009 23:00:10 +0100 Subject: [PATCH] sync from fd.org timeout support in connection --- examples/Makefile.am | 3 +-- include/dbus-c++/connection.h | 5 +++++ src/connection.cpp | 24 +++++++++++++++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 29bfab7..a940bc8 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,5 +1,4 @@ -SUBDIRS = properties echo hal glib -DIST_SUBDIRS = properties echo hal glib ecore +SUBDIRS = properties echo hal glib ecore MAINTAINERCLEANFILES = \ Makefile.in diff --git a/include/dbus-c++/connection.h b/include/dbus-c++/connection.h index 410ce55..3f8aaf6 100644 --- a/include/dbus-c++/connection.h +++ b/include/dbus-c++/connection.h @@ -446,6 +446,10 @@ public: bool start_service( const char* name, unsigned long flags ); const std::vector& names(); + + void set_timeout(int timeout); + + int get_timeout(); private: @@ -454,6 +458,7 @@ private: private: RefPtrI _pvt; + int _timeout; friend class ObjectAdaptor; // needed in order to register object paths for a connection }; diff --git a/src/connection.cpp b/src/connection.cpp index 41afe9a..e1eec7e 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -202,6 +202,7 @@ Connection Connection::ActivationBus() } Connection::Connection(const char *address, bool priv) +: _timeout(-1) { InternalError e; DBusConnection *conn = priv @@ -218,13 +219,13 @@ Connection::Connection(const char *address, bool priv) } Connection::Connection(Connection::Private *p) -: _pvt(p) +: _pvt(p), _timeout(-1) { setup(default_dispatcher); } Connection::Connection(const Connection &c) -: _pvt(c._pvt) +: _pvt(c._pvt),_timeout(c._timeout) { dbus_connection_ref(_pvt->conn); } @@ -360,7 +361,14 @@ Message Connection::send_blocking(Message &msg, int timeout) DBusMessage *reply; InternalError e; - reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e); + if (this->_timeout != -1) + { + reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, this->_timeout, e); + } + else + { + reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e); + } if (e) throw Error(e); @@ -444,3 +452,13 @@ bool Connection::start_service(const char *name, unsigned long flags) return b; } +void Connection::set_timeout(int timeout) +{ + _timeout=timeout; +} + +int Connection::get_timeout() +{ + return _timeout; +} +