summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Volz <andreas@frodo.mittelerde>2009-11-16 23:00:10 +0100
committerAndreas Volz <andreas@frodo.mittelerde>2009-11-16 23:00:10 +0100
commit25a2ef65af65cab9241da2684cdec0f078dc8c4d (patch)
treeee8af61b02b85f10e1299b345bbdbdb4849f7180
parentd55e70a385695369984f1d24cd6574904f66165b (diff)
downloaddbus-c++-25a2ef65af65cab9241da2684cdec0f078dc8c4d.tar.gz
sync from fd.org
timeout support in connection
-rw-r--r--examples/Makefile.am3
-rw-r--r--include/dbus-c++/connection.h5
-rw-r--r--src/connection.cpp24
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<std::string>& names();
+
+ void set_timeout(int timeout);
+
+ int get_timeout();
private:
@@ -454,6 +458,7 @@ private:
private:
RefPtrI<Private> _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;
+}
+