sync from fd.org
timeout support in connection
This commit is contained in:
parent
d55e70a385
commit
25a2ef65af
3 changed files with 27 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue