diff options
author | Kai Uwe Broulik <kde@privat.broulik.de> | 2018-04-04 15:48:53 +0200 |
---|---|---|
committer | Kai Uwe Broulik <kde@privat.broulik.de> | 2018-07-10 19:46:40 +0000 |
commit | d743df975db3403ec83d67bd376d8a6bfea3dfb0 (patch) | |
tree | 647560847f9ae5d4bd6ddffc5d64d40a030a2f3d /src/dbus/qdbusmessage.cpp | |
parent | 5c5af7155ae989664919de1f10ac17121fa12a36 (diff) |
Support interactive authorization flag in DBusMessage
This flag was introduced to serve as a replacement for a dedicated "interactive" boolean
argument in method calls guarded by Polkit.
Change-Id: Ida91c9872e70f8ca6672563d0ca6642f38c498ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus/qdbusmessage.cpp')
-rw-r--r-- | src/dbus/qdbusmessage.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index ef827e82b0..3e8f2eaf3f 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -70,7 +70,8 @@ static inline const char *data(const QByteArray &arr) QDBusMessagePrivate::QDBusMessagePrivate() : msg(0), reply(0), localReply(0), ref(1), type(QDBusMessage::InvalidMessage), delayedReply(false), localMessage(false), - parametersValidated(false), autoStartService(true) + parametersValidated(false), autoStartService(true), + interactiveAuthorizationAllowed(false) { } @@ -138,6 +139,8 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB msg = q_dbus_message_new_method_call(data(d_ptr->service.toUtf8()), d_ptr->path.toUtf8(), data(d_ptr->interface.toUtf8()), d_ptr->name.toUtf8()); q_dbus_message_set_auto_start( msg, d_ptr->autoStartService ); + q_dbus_message_set_allow_interactive_authorization(msg, d_ptr->interactiveAuthorizationAllowed); + break; case QDBusMessage::ReplyMessage: msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); @@ -242,6 +245,7 @@ QDBusMessage QDBusMessagePrivate::fromDBusMessage(DBusMessage *dmsg, QDBusConnec QString::fromUtf8(q_dbus_message_get_member(dmsg)); message.d_ptr->service = QString::fromUtf8(q_dbus_message_get_sender(dmsg)); message.d_ptr->signature = QString::fromUtf8(q_dbus_message_get_signature(dmsg)); + message.d_ptr->interactiveAuthorizationAllowed = q_dbus_message_get_allow_interactive_authorization(dmsg); message.d_ptr->msg = q_dbus_message_ref(dmsg); QDBusDemarshaller demarshaller(capabilities); @@ -725,6 +729,44 @@ bool QDBusMessage::autoStartService() const } /*! + Sets the interactive authorization flag to \a enable. + This flag only makes sense for method call messages, where it + tells the D-Bus server that the caller of the method is prepared + to wait for interactive authorization to take place (for instance + via Polkit) before the actual method is processed. + + By default this flag is false and the other end is expected to + make any authorization decisions non-interactively and promptly. + + The \c org.freedesktop.DBus.Error.InteractiveAuthorizationRequired + error indicates that authorization failed, but could have succeeded + if this flag had been set. + + \sa isInteractiveAuthorizationAllowed() + + \since 5.12 +*/ +void QDBusMessage::setInteractiveAuthorizationAllowed(bool enable) +{ + d_ptr->interactiveAuthorizationAllowed = enable; +} + +/*! + Returns the interactive authorization allowed flag, as set by + setInteractiveAuthorizationAllowed(). By default this flag + is false and the other end is expected to make any authorization + decisions non-interactively and promptly. + + \sa setInteractiveAuthorizationAllowed() + + \since 5.12 +*/ +bool QDBusMessage::isInteractiveAuthorizationAllowed() const +{ + return d_ptr->interactiveAuthorizationAllowed; +} + +/*! Sets the arguments that are going to be sent over D-Bus to \a arguments. Those will be the arguments to a method call or the parameters in the signal. |