diff options
author | Robert Griebl <robert.griebl@qt.io> | 2022-08-18 22:17:05 +0200 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2022-09-16 13:15:00 +0200 |
commit | 22929f522153d66187e4cb930b71a11c0b4166c6 (patch) | |
tree | f3407c13f7cf50c5fcb3330ad8cce68f9474d973 /src/intent-client-lib/intentclientrequest.cpp | |
parent | 1163402cf942842297dc4a24911f063da84fc97b (diff) |
Intents: add broadcasts
This commit adds a new intent type: a broadcast.
Broadcasts will be delivered to all applications (*), but they do not have
the possibility to return a reply back to the sender.
Implementation wise, they are just treated as normal requests that are
multiplexed for every application.
(*) This can be limited with the new handleOnlyWhenRunning flag.
Change-Id: If9f954cf5e52707624b95c80c8e984dfd6c4315a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Diffstat (limited to 'src/intent-client-lib/intentclientrequest.cpp')
-rw-r--r-- | src/intent-client-lib/intentclientrequest.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/intent-client-lib/intentclientrequest.cpp b/src/intent-client-lib/intentclientrequest.cpp index 09836df2..e077fe35 100644 --- a/src/intent-client-lib/intentclientrequest.cpp +++ b/src/intent-client-lib/intentclientrequest.cpp @@ -126,6 +126,15 @@ QT_BEGIN_NAMESPACE_AM \sa succeeded */ +/*! \qmlproperty bool IntentRequest::broadcast + \readonly + \since 6.5 + + Only Set to \c true, if the received request is a broadcast. + + \note Valid only on received requests. +*/ + /*! \qmlsignal IntentRequest::replyReceived() This signal gets emitted when a reply to an intent request is available. The signal handler @@ -145,7 +154,7 @@ IntentClientRequest::Direction IntentClientRequest::direction() const IntentClientRequest::~IntentClientRequest() { // the incoming request was gc'ed on the JavaScript side, but no reply was sent yet - if ((direction() == Direction::ToApplication) && !m_finished) + if ((direction() == Direction::ToApplication) && !m_finished && !m_broadcast) sendErrorReply(qSL("Request not handled")); } @@ -174,6 +183,11 @@ QVariantMap IntentClientRequest::parameters() const return m_parameters; } +bool IntentClientRequest::isBroadcast() const +{ + return m_broadcast; +} + bool IntentClientRequest::succeeded() const { return m_succeeded; @@ -210,6 +224,11 @@ void IntentClientRequest::sendReply(const QVariantMap &result) qmlWarning(this) << "Calling IntentRequest::sendReply on requests originating from this application is a no-op."; return; } + if (m_broadcast) { + qmlWarning(this) << "Calling IntentRequest::sendReply on broadcast requests is a no-op."; + return; + } + IntentClient *ic = IntentClient::instance(); if (QThread::currentThread() != ic->thread()) { @@ -241,6 +260,10 @@ void IntentClientRequest::sendErrorReply(const QString &errorMessage) qmlWarning(this) << "Calling IntentRequest::sendErrorReply on requests originating from this application is a no-op."; return; } + if (m_broadcast) { + qmlWarning(this) << "Calling IntentRequest::sendErrorReply on broadcast requests is a no-op."; + return; + } IntentClient *ic = IntentClient::instance(); if (QThread::currentThread() != ic->thread()) { @@ -286,7 +309,8 @@ void IntentClientRequest::connectNotify(const QMetaMethod &signal) IntentClientRequest::IntentClientRequest(Direction direction, const QString &requestingApplicationId, const QUuid &id, const QString &intentId, - const QString &applicationId, const QVariantMap ¶meters) + const QString &applicationId, const QVariantMap ¶meters, + bool broadcast) : QObject() , m_direction(direction) , m_id(id) @@ -294,6 +318,7 @@ IntentClientRequest::IntentClientRequest(Direction direction, const QString &req , m_requestingApplicationId(requestingApplicationId) , m_applicationId(applicationId) , m_parameters(parameters) + , m_broadcast(broadcast) { } void IntentClientRequest::setRequestId(const QUuid &requestId) |