QXmpp Version: 1.10.0
QXmppJingleMessageInitiationManager.h
1// SPDX-FileCopyrightText: 2023 Tibor Csötönyi <work@taibsu.de>
2// SPDX-FileCopyrightText: 2023 Melvin Keskin <melvo@olomono.de>
3//
4// SPDX-License-Identifier: LGPL-2.1-or-later
5
6#ifndef QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
7#define QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
8
9#include "QXmppClientExtension.h"
10#include "QXmppError.h"
11#include "QXmppJingleIq.h"
12#include "QXmppMessageHandler.h"
13#include "QXmppSendResult.h"
14#include "QXmppTask.h"
15
17class QXmppJingleMessageInitiationPrivate;
18class QXmppJingleMessageInitiationManagerPrivate;
19
20class QXMPP_EXPORT QXmppJingleMessageInitiation : public QObject
21{
22 Q_OBJECT
23public:
24 struct Rejected {
25 std::optional<QXmppJingleReason> reason;
26 bool containsTieBreak;
27 };
28
29 struct Retracted {
30 std::optional<QXmppJingleReason> reason;
31 bool containsTieBreak;
32 };
33
34 struct Finished {
35 std::optional<QXmppJingleReason> reason;
36 QString migratedTo;
37 };
38
40 using Result = std::variant<Rejected, Retracted, Finished, QXmppError>;
41
44
47 QXmppTask<QXmpp::SendResult> reject(std::optional<QXmppJingleReason> reason, bool containsTieBreak = false);
48 QXmppTask<QXmpp::SendResult> retract(std::optional<QXmppJingleReason> reason, bool containsTieBreak = false);
49 QXmppTask<QXmpp::SendResult> finish(std::optional<QXmppJingleReason> reason, const QString &migratedTo = {});
50
51 Q_SIGNAL void ringing();
52 Q_SIGNAL void proceeded(const QString &id, const QString &callPartnerResource);
53 Q_SIGNAL void closed(const Result &result);
54
55private:
56 QString id() const;
57 void setId(const QString &id);
58 void setCallPartnerJid(const QString &callPartnerJid);
59 QString callPartnerJid() const;
60 bool isProceeded() const;
61 void setIsProceeded(bool isProceeded);
62
63 std::unique_ptr<QXmppJingleMessageInitiationPrivate> d;
64
66 friend class tst_QXmppJingleMessageInitiationManager;
67};
68
70{
71 Q_OBJECT
72public:
73 using ProposeResult = std::variant<std::shared_ptr<QXmppJingleMessageInitiation>, QXmppError>;
74
77
79 QStringList discoveryFeatures() const override;
81
83 const QString &callPartnerJid,
84 const QXmppJingleDescription &description);
85
86 Q_SIGNAL void proposed(
87 const std::shared_ptr<QXmppJingleMessageInitiation> &jmi,
88 const QString &id,
89 const std::optional<QXmppJingleDescription> &description);
90
91protected:
93 bool handleMessage(const QXmppMessage &) override;
95
96private:
99 const QString &callPartnerJid);
100
101 void clear(const std::shared_ptr<QXmppJingleMessageInitiation> &jmi);
102 void clearAll();
103
104 bool handleJmiElement(QXmppJingleMessageInitiationElement &&jmiElement, const QString &senderJid);
105 bool handleExistingJmi(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QXmppJingleMessageInitiationElement &jmiElement, const QString &callPartnerResource);
106 bool handleProposeJmiElement(const QXmppJingleMessageInitiationElement &jmiElement, const QString &callPartnerJid);
107 bool handleTieBreak(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QXmppJingleMessageInitiationElement &jmiElement, const QString &callPartnerResource);
108 bool handleExistingSession(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QString &jmiElementId);
109 bool handleNonExistingSession(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QString &jmiElementId, const QString &callPartnerResource);
110 std::shared_ptr<QXmppJingleMessageInitiation> addJmi(const QString &callPartnerJid);
111 const QVector<std::shared_ptr<QXmppJingleMessageInitiation>> &jmis() const;
112
113private:
114 std::unique_ptr<QXmppJingleMessageInitiationManagerPrivate> d;
115
116 friend class QXmppJingleMessageInitiationPrivate;
117 friend class tst_QXmppJingleMessageInitiationManager;
118};
119
120Q_DECLARE_METATYPE(QXmppJingleMessageInitiation::Result)
121
122#endif // QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:32
The QXmppJingleDescription class represents descriptions for Jingle elements including media type,...
Definition: QXmppJingleData.h:246
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition: QXmppJingleData.h:602
The QXmppJingleMessageInitiationManager class makes it possible to retrieve Jingle Message Initiation...
Definition: QXmppJingleMessageInitiationManager.h:70
Q_SIGNAL void proposed(const std::shared_ptr< QXmppJingleMessageInitiation > &jmi, const QString &id, const std::optional< QXmppJingleDescription > &description)
std::variant< std::shared_ptr< QXmppJingleMessageInitiation >, QXmppError > ProposeResult
Definition: QXmppJingleMessageInitiationManager.h:73
The QXmppJingleMessageInitiation class holds information about the JMI element in the current context...
Definition: QXmppJingleMessageInitiationManager.h:21
Q_SIGNAL void closed(const Result &result)
Q_SIGNAL void proceeded(const QString &id, const QString &callPartnerResource)
std::variant< Rejected, Retracted, Finished, QXmppError > Result
Variant of Rejected, Retracted, Finished or Error result types.
Definition: QXmppJingleMessageInitiationManager.h:40
Definition: QXmppMessageHandler.h:16
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:64
Definition: QXmppTask.h:62
Definition: QXmppError.h:17