summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Volz <andreas@frodo.mittelerde>2010-06-03 20:44:32 +0200
committerAndreas Volz <andreas@frodo.mittelerde>2010-06-03 20:44:32 +0200
commitd083d0716776b60a9396053b204497b4577b9ec4 (patch)
treee44402184c8f882609d14ef44391ffbf13a9dc67
parent7889c46e57603bcc0fcdcf263dc5afa1cbbcaa5b (diff)
downloaddbus-c++-d083d0716776b60a9396053b204497b4577b9ec4.tar.gz
SourceForge Patches ID: 2701443 - Add methods to adjust timeout. Submitted: Oron Peled ( oron ) - 2009-03-21 23:27:55 CET
-rw-r--r--include/dbus-c++/object.h10
-rw-r--r--src/eventloop-integration.cpp7
-rw-r--r--src/object.cpp12
3 files changed, 25 insertions, 4 deletions
diff --git a/include/dbus-c++/object.h b/include/dbus-c++/object.h
index 962bf77..494aa82 100644
--- a/include/dbus-c++/object.h
+++ b/include/dbus-c++/object.h
@@ -52,6 +52,10 @@ public:
inline Connection &conn();
+ void set_timeout(int new_timeout = -1);
+
+ inline int get_timeout() const;
+
private:
DXXAPILOCAL virtual bool handle_message(const Message &) = 0;
@@ -63,6 +67,7 @@ private:
Connection _conn;
DBus::Path _path;
std::string _service;
+ int _default_timeout;
};
/*
@@ -83,6 +88,11 @@ const std::string &Object::service() const
return _service;
}
+int Object::get_timeout() const
+{
+ return _default_timeout;
+}
+
/*
*/
diff --git a/src/eventloop-integration.cpp b/src/eventloop-integration.cpp
index d801574..8b9c49b 100644
--- a/src/eventloop-integration.cpp
+++ b/src/eventloop-integration.cpp
@@ -109,8 +109,11 @@ Timeout *BusDispatcher::add_timeout(Timeout::Internal *ti)
bt->expired = new Callback<BusDispatcher, void, DefaultTimeout &>(this, &BusDispatcher::timeout_expired);
bt->data(bt);
- debug_log("added timeout %p (%s) interval=%d",
- bt, ((Timeout *)bt)->enabled() ? "on":"off", ((Timeout *)bt)->interval());
+ debug_log("added timeout %p (%s) (%d millies)",
+ bt,
+ ((Timeout*)bt)->enabled() ? "on":"off",
+ ((Timeout*)bt)->interval()
+ );
return bt;
}
diff --git a/src/object.cpp b/src/object.cpp
index f7d0916..88c3bb0 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -40,7 +40,7 @@
using namespace DBus;
Object::Object(Connection &conn, const Path &path, const char *service)
-: _conn(conn), _path(path), _service(service ? service : "")
+: _conn(conn), _path(path), _service(service ? service : ""), _default_timeout(-1)
{
}
@@ -48,6 +48,14 @@ Object::~Object()
{
}
+void Object::set_timeout(int new_timeout)
+{
+ debug_log("%s: %d millies", __PRETTY_FUNCTION__, new_timeout);
+ if(new_timeout < 0 && new_timeout != -1)
+ throw ErrorInvalidArgs("Bad timeout, cannot set it");
+ _default_timeout = new_timeout;
+}
+
struct ObjectAdaptor::Private
{
static void unregister_function_stub(DBusConnection *, void *);
@@ -329,7 +337,7 @@ Message ObjectProxy::_invoke_method(CallMessage &call)
if (call.destination() == NULL)
call.destination(service().c_str());
- return conn().send_blocking(call);
+ return conn().send_blocking(call, get_timeout());
}
bool ObjectProxy::_invoke_method_noreply(CallMessage &call)