Branch data Line data Source code
1 : : // Copyright (C) 2021 The Qt Company Ltd.
2 : : // Copyright (C) 2019 Luxoft Sweden AB
3 : : // Copyright (C) 2018 Pelagicore AG
4 : : // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
5 : :
6 : : #ifndef INTENTSERVERREQUEST_H
7 : : #define INTENTSERVERREQUEST_H
8 : :
9 : : #include <QtCore/QObject>
10 : : #include <QtCore/QString>
11 : : #include <QtCore/QVariantMap>
12 : : #include <QtCore/QUuid>
13 : : #include <QtCore/QVector>
14 : : #include <QtCore/QPointer>
15 : : #include <QtAppManCommon/global.h>
16 : : #include <QtAppManIntentServer/intent.h>
17 : :
18 : : QT_BEGIN_NAMESPACE_AM
19 : :
20 : : class IntentServer;
21 : :
22 : : class IntentServerRequest : public QObject
23 : : {
24 : : Q_OBJECT
25 : :
26 : : public:
27 : : IntentServerRequest(const QString &requestingApplicationId, const QString &intentId,
28 : : const QVector<Intent *> &potentialIntents, const QVariantMap ¶meters,
29 : : bool broadcast);
30 : :
31 : : enum class State {
32 : : ReceivedRequest,
33 : : WaitingForDisambiguation,
34 : : Disambiguated,
35 : : WaitingForApplicationStart,
36 : : StartedApplication,
37 : : WaitingForReplyFromApplication,
38 : : ReceivedReplyFromApplication,
39 : : };
40 : :
41 [ # # # # ]: 0 : Q_ENUM(State)
42 : :
43 : : State state() const;
44 : : QUuid requestId() const;
45 : : QString intentId() const;
46 : : QString requestingApplicationId() const;
47 : : Intent *selectedIntent() const;
48 : : QList<Intent *> potentialIntents() const;
49 : : QVariantMap parameters() const;
50 : : bool succeeded() const;
51 : : QVariantMap result() const;
52 : : bool isBroadcast() const;
53 : :
54 : : void setState(State newState);
55 : : void setSelectedIntent(Intent *intent);
56 : :
57 : : void setRequestFailed(const QString &errorMessage);
58 : : void setRequestSucceeded(const QVariantMap &result);
59 : :
60 : : private:
61 : : QUuid m_id;
62 : : State m_state;
63 : : bool m_succeeded = false;
64 : : bool m_broadcast = false;
65 : : QString m_intentId;
66 : : QString m_requestingApplicationId;
67 : : // These are copies of the real intents, as QML cannot cope with QPointer<Intent> and the
68 : : // real Intent pointers could die during handling, due to app removal.
69 : : Intent *m_selectedIntent = nullptr;
70 : : QVector<Intent *> m_potentialIntents;
71 : : QVariantMap m_parameters;
72 : : QVariantMap m_result;
73 : : };
74 : :
75 : : QT_END_NAMESPACE_AM
76 : :
77 : : #endif // INTENTSERVERREQUEST_H
|