diff options
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusabstractinterface.cpp | 31 | ||||
-rw-r--r-- | src/dbus/qdbusabstractinterface.h | 3 | ||||
-rw-r--r-- | src/dbus/qdbusabstractinterface_p.h | 1 |
3 files changed, 31 insertions, 4 deletions
diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 187ad67..9f68313 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -88,6 +88,7 @@ QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(const QString &serv : connection(con), service(serv), path(p), interface(iface), lastError(checkIfValid(serv, p, iface, isDynamic, (connectionPrivate() && connectionPrivate()->mode == QDBusConnectionPrivate::PeerMode))), + timeout(-1), isValid(!lastError.isValid()) { if (!isValid) @@ -144,7 +145,7 @@ void QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, QVariant & QLatin1String("Get")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << interface << QString::fromUtf8(mp.name()); - QDBusMessage reply = connection.call(msg, QDBus::Block); + QDBusMessage reply = connection.call(msg, QDBus::Block, timeout); if (reply.type() != QDBusMessage::ReplyMessage) { lastError = reply; @@ -210,7 +211,7 @@ bool QDBusAbstractInterfacePrivate::setProperty(const QMetaProperty &mp, const Q QLatin1String("Set")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << interface << QString::fromUtf8(mp.name()) << QVariant::fromValue(QDBusVariant(value)); - QDBusMessage reply = connection.call(msg, QDBus::Block); + QDBusMessage reply = connection.call(msg, QDBus::Block, timeout); if (reply.type() != QDBusMessage::ReplyMessage) { lastError = reply; @@ -384,6 +385,28 @@ QDBusError QDBusAbstractInterface::lastError() const } /*! + Sets the timeout in seconds for all future DBus calls to \a timeout. + -1 means the default DBus timeout (usually 25 seconds). + + \since 4.8 +*/ +void QDBusAbstractInterface::setTimeout(int timeout) +{ + d_func()->timeout = timeout; +} + +/*! + Returns the current value of the timeout in seconds. + -1 means the default DBus timeout (usually 25 seconds). + + \since 4.8 +*/ +int QDBusAbstractInterface::timeout() const +{ + return d_func()->timeout; +} + +/*! Places a call to the remote method specified by \a method on this interface, using \a args as arguments. This function returns the message that was received as a reply, which can be a normal QDBusMessage::ReplyMessage (indicating success) or QDBusMessage::ErrorMessage (if the call @@ -442,7 +465,7 @@ QDBusMessage QDBusAbstractInterface::callWithArgumentList(QDBus::CallMode mode, QDBusMessagePrivate::setParametersValidated(msg, true); msg.setArguments(args); - QDBusMessage reply = d->connection.call(msg, mode); + QDBusMessage reply = d->connection.call(msg, mode, d->timeout); if (thread() == QThread::currentThread()) d->lastError = reply; // will clear if reply isn't an error @@ -475,7 +498,7 @@ QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList(const QString QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), interface(), method); QDBusMessagePrivate::setParametersValidated(msg, true); msg.setArguments(args); - return d->connection.asyncCall(msg); + return d->connection.asyncCall(msg, d->timeout); } /*! diff --git a/src/dbus/qdbusabstractinterface.h b/src/dbus/qdbusabstractinterface.h index 72b922e..34ff410 100644 --- a/src/dbus/qdbusabstractinterface.h +++ b/src/dbus/qdbusabstractinterface.h @@ -95,6 +95,9 @@ public: QDBusError lastError() const; + void setTimeout(int timeout); + int timeout() const; + QDBusMessage call(const QString &method, const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant(), diff --git a/src/dbus/qdbusabstractinterface_p.h b/src/dbus/qdbusabstractinterface_p.h index a000daf..4f96165 100644 --- a/src/dbus/qdbusabstractinterface_p.h +++ b/src/dbus/qdbusabstractinterface_p.h @@ -77,6 +77,7 @@ public: QString path; QString interface; mutable QDBusError lastError; + int timeout; // this is set during creation and never changed // it can't be const because QDBusInterfacePrivate has one more check |