QXmpp: QXmppJingleMessageInitiationManager.h Source File

QXmpp Version: 1.14.4

Loading...
Searching...
No Matches
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
16class QXmppJingleMessageInitiationManager;
17class QXmppJingleMessageInitiationPrivate;
18class QXmppJingleMessageInitiationManagerPrivate;
19
20 class 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
42 ~QXmppJingleMessageInitiation();
43
44 const QString &remoteJid() const;
45
46 QXmppTask<QXmpp::SendResult> ring();
47 QXmppTask<QXmpp::SendResult> proceed();
48 QXmppTask<QXmpp::SendResult> reject(std::optional<QXmppJingleReason> reason, bool containsTieBreak = false);
49 QXmppTask<QXmpp::SendResult> retract(std::optional<QXmppJingleReason> reason, bool containsTieBreak = false);
50 QXmppTask<QXmpp::SendResult> finish(std::optional<QXmppJingleReason> reason, const QString &migratedTo = {});
51
52 Q_SIGNAL void ringing();
53 Q_SIGNAL void proceeded(const QString &id, const QString &remoteResource);
54 Q_SIGNAL void closed(const Result &result);
55
56private:
57 QXmppJingleMessageInitiation(QXmppJingleMessageInitiationManager *manager, const QString &id, const QString &remoteJid);
58
59 QString id() const;
60 void setId(const QString &id);
61 void setRemoteJid(const QString &remoteJid);
62 bool isProceeded() const;
63 void setIsProceeded(bool isProceeded);
64 bool isFinished() const;
65
66 std::unique_ptr<QXmppJingleMessageInitiationPrivate> d;
67
68 friend class QXmppJingleMessageInitiationManager;
69 friend class tst_QXmppJingleMessageInitiationManager;
70};
71
72 class QXMPP_EXPORT QXmppJingleMessageInitiationManager : public QXmppClientExtension, public QXmppMessageHandler
73{
74 Q_OBJECT
75public:
76 using ProposeResult = std::variant<std::shared_ptr<QXmppJingleMessageInitiation>, QXmppError>;
77
78 QXmppJingleMessageInitiationManager();
79 ~QXmppJingleMessageInitiationManager();
80
82 QStringList discoveryFeatures() const override;
84
85 QXmppTask<ProposeResult> propose(
86 const QString &remoteJid,
87 const QXmppJingleRtpDescription &description);
88 QXmppTask<ProposeResult> propose(
89 const QString &remoteJid,
90 const QList<QXmppJingleRtpDescription> &descriptions);
91
92 Q_SIGNAL void proposed(
93 const std::shared_ptr<QXmppJingleMessageInitiation> &jmi,
94 const QString &id,
95 const std::optional<QXmppJingleRtpDescription> &description);
96 Q_SIGNAL void proposeReceived(
97 const std::shared_ptr<QXmppJingleMessageInitiation> &jmi,
98 const QString &id,
99 const QList<QXmppJingleRtpDescription> &descriptions);
100
101protected:
103 bool handleMessage(const QXmppMessage &) override;
105
106private:
107 QXmppTask<ProposeResult> propose(
108 const QString &id,
109 const QString &remoteJid,
110 const QList<QXmppJingleRtpDescription> &descriptions);
111 QXmppTask<QXmpp::SendResult> sendMessage(
112 const QXmppJingleMessageInitiationElement &jmiElement,
113 const QString &remoteJid);
114
115 void clear(const std::shared_ptr<QXmppJingleMessageInitiation> &jmi);
116 void clearAll();
117
118 bool handleJmiElement(QXmppJingleMessageInitiationElement &&jmiElement, const QString &remoteJid);
119 bool handleExistingJmi(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QXmppJingleMessageInitiationElement &jmiElement, const QString &remoteResource);
120 bool handleProposeJmiElement(const QXmppJingleMessageInitiationElement &jmiElement, const QString &remoteJid);
121 bool handleTieBreak(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QXmppJingleMessageInitiationElement &jmiElement, const QString &remoteResource);
122 bool handleExistingSession(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QString &jmiElementId);
123 bool handleNonExistingSession(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QString &jmiElementId, const QString &remoteResource);
124 std::shared_ptr<QXmppJingleMessageInitiation> addJmi(const QString &id, const QString &remoteJid);
125 const QVector<std::shared_ptr<QXmppJingleMessageInitiation>> &jmis() const;
126
127private:
128 std::unique_ptr<QXmppJingleMessageInitiationManagerPrivate> d;
129
130 friend class QXmppJingleMessageInitiationPrivate;
131 friend class tst_QXmppJingleMessageInitiationManager;
132};
133
134Q_DECLARE_METATYPE(QXmppJingleMessageInitiation::Result)
135
136#endif // QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
QXmppClientExtension::discoveryFeatures
virtual QStringList discoveryFeatures() const
Definition QXmppClientExtension.cpp:22
QXmppClientExtension::QXmppClientExtension
QXmppClientExtension()
Definition QXmppClientExtension.cpp:12
QXmppJingleMessageInitiationElement
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition QXmppJingleData.h:642
QXmppJingleMessageInitiation::proceeded
Q_SIGNAL void proceeded(const QString &id, const QString &remoteResource)
QXmppJingleMessageInitiation::closed
Q_SIGNAL void closed(const Result &result)
QXmppJingleMessageInitiation::finish
QXmppTask< QXmpp::SendResult > finish(std::optional< QXmppJingleReason > reason, const QString &migratedTo={})
Definition QXmppJingleMessageInitiationManager.cpp:176
QXmppJingleMessageInitiation::remoteJid
const QString & remoteJid() const
Definition QXmppJingleMessageInitiationManager.cpp:242
QXmppJingleMessageInitiation::ring
QXmppTask< QXmpp::SendResult > ring()
Definition QXmppJingleMessageInitiationManager.cpp:72
QXmppJingleMessageInitiation::retract
QXmppTask< QXmpp::SendResult > retract(std::optional< QXmppJingleReason > reason, bool containsTieBreak=false)
Definition QXmppJingleMessageInitiationManager.cpp:137
QXmppJingleMessageInitiation::reject
QXmppTask< QXmpp::SendResult > reject(std::optional< QXmppJingleReason > reason, bool containsTieBreak=false)
Definition QXmppJingleMessageInitiationManager.cpp:98
QXmppJingleMessageInitiation::Result
std::variant< Rejected, Retracted, Finished, QXmppError > Result
Variant of Rejected, Retracted, Finished or Error result types.
Definition QXmppJingleMessageInitiationManager.h:40
QXmppJingleMessageInitiation::ringing
Q_SIGNAL void ringing()
QXmppJingleMessageInitiation::proceed
QXmppTask< QXmpp::SendResult > proceed()
Definition QXmppJingleMessageInitiationManager.cpp:83
QXmppJingleMessageInitiationManager
The QXmppJingleMessageInitiationManager class makes it possible to retrieve Jingle Message Initiation...
Definition QXmppJingleMessageInitiationManager.h:73
QXmppJingleMessageInitiationManager::ProposeResult
std::variant< std::shared_ptr< QXmppJingleMessageInitiation >, QXmppError > ProposeResult
Definition QXmppJingleMessageInitiationManager.h:76
QXmppJingleMessageInitiationManager::propose
QXmppTask< ProposeResult > propose(const QString &remoteJid, const QXmppJingleRtpDescription &description)
Definition QXmppJingleMessageInitiationManager.cpp:335
QXmppJingleMessageInitiationManager::proposeReceived
Q_SIGNAL void proposeReceived(const std::shared_ptr< QXmppJingleMessageInitiation > &jmi, const QString &id, const QList< QXmppJingleRtpDescription > &descriptions)
QXmppJingleMessageInitiationManager::proposed
Q_SIGNAL void proposed(const std::shared_ptr< QXmppJingleMessageInitiation > &jmi, const QString &id, const std::optional< QXmppJingleRtpDescription > &description)
QXmppJingleRtpDescription
Represents a description for XEP-0167: Jingle RTP Sessions, including media type, streaming source,...
Definition QXmppJingleData.h:253
QXmppMessageHandler
Definition QXmppMessageHandler.h:16
QXmppMessageHandler::handleMessage
virtual bool handleMessage(const QXmppMessage &)=0
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:64
QXmppTask
Definition QXmppTask.h:46
QXmppError
Definition QXmppError.h:17