Implement QDBusAbstractInterface::setInteractiveAuthorizationAllowed

Task-number: QTBUG-100458
Change-Id: I48d6f17943a554c1173d16a2320eb460c3d5c387
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Gleb Popov 2023-10-16 19:52:11 +03:00
parent 889c3e2e5b
commit 295e56201d
3 changed files with 31 additions and 0 deletions

View File

@ -79,6 +79,7 @@ QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(const QString &serv
lastError(checkIfValid(serv, p, iface, isDynamic, (connectionPrivate() &&
connectionPrivate()->mode == QDBusConnectionPrivate::PeerMode))),
timeout(-1),
interactiveAuthorizationAllowed(false),
isValid(!lastError.isValid())
{
if (!isValid)
@ -396,6 +397,30 @@ int QDBusAbstractInterface::timeout() const
return d_func()->timeout;
}
/*!
When passed \a enable = \c true it causes all consecutive DBus calls made via
this interface to have the InteractiveAuthorizationAllowed flag set. Passing
false disables this behavior.
\since 6.7
\sa QDBusMessage::setInteractiveAuthorizationAllowed()
*/
void QDBusAbstractInterface::setInteractiveAuthorizationAllowed(bool enable)
{
d_func()->interactiveAuthorizationAllowed = enable;
}
/*!
Returns the current value of the InteractiveAuthorizationAllowed flag.
\since 6.7
\sa QDBusMessage::setInteractiveAuthorizationAllowed()
*/
bool QDBusAbstractInterface::isInteractiveAuthorizationAllowed() const
{
return d_func()->interactiveAuthorizationAllowed;
}
/*!
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
@ -488,6 +513,8 @@ QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList(const QString
QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), interface(), method);
QDBusMessagePrivate::setParametersValidated(msg, true);
msg.setArguments(args);
if (d->interactiveAuthorizationAllowed)
msg.setInteractiveAuthorizationAllowed(true);
return d->connection.asyncCall(msg, d->timeout);
}

View File

@ -63,6 +63,9 @@ public:
void setTimeout(int timeout);
int timeout() const;
void setInteractiveAuthorizationAllowed(bool enable);
bool isInteractiveAuthorizationAllowed() const;
QDBusMessage call(const QString &method)
{
return doCall(QDBus::AutoDetect, method, nullptr, 0);

View File

@ -42,6 +42,7 @@ public:
QString interface;
mutable QDBusError lastError;
int timeout;
bool interactiveAuthorizationAllowed;
// this is set during creation and never changed
// it can't be const because QDBusInterfacePrivate has one more check