QXmpp: QXmppCallInviteManager.h Source File

QXmpp Version: 1.14.4

Loading...
Searching...
No Matches
QXmppCallInviteManager.h
1// SPDX-FileCopyrightText: 2023 Tibor Csötönyi <work@taibsu.de>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPCALLINVITEMANAGER_H
6#define QXMPPCALLINVITEMANAGER_H
7
8#include "QXmppClientExtension.h"
9#include "QXmppError.h"
10#include "QXmppJingleIq.h"
11#include "QXmppMessageHandler.h"
12#include "QXmppSendResult.h"
13#include "QXmppTask.h"
14
15class QXmppCallInviteManager;
16class QXmppCallInvitePrivate;
17class QXmppCallInviteManagerPrivate;
18
19 class QXMPP_EXPORT QXmppCallInvite : public QObject
20{
21 Q_OBJECT
22public:
23 struct Rejected { };
24 struct Retracted { };
25 struct Left { };
26
27 using Result = std::variant<Rejected, Retracted, Left, QXmppError>;
28
29 explicit QXmppCallInvite(QXmppCallInviteManager *manager);
30 ~QXmppCallInvite();
31
32 QXmppTask<QXmpp::SendResult> accept();
33 QXmppTask<QXmpp::SendResult> reject();
34 QXmppTask<QXmpp::SendResult> retract();
35 QXmppTask<QXmpp::SendResult> leave();
36
37 Q_SIGNAL void invited();
38 Q_SIGNAL void accepted(const QString &id, const QString &callPartnerResource);
39 Q_SIGNAL void closed(const QXmppCallInvite::Result &result);
40
41private:
42 QXmppTask<QXmpp::SendResult> invite(
43 bool audio = true,
44 bool video = false,
45 std::optional<QXmppCallInviteElement::Jingle> jingle = std::nullopt,
46 std::optional<QVector<QXmppCallInviteElement::External>> external = std::nullopt);
47
48 QString id() const;
49 void setId(const QString &id);
50 void setCallPartnerJid(const QString &callPartnerJid);
51 QString callPartnerJid() const;
52 bool isAccepted() const;
53 void setIsAccepted(bool isAccepted);
54
55 std::unique_ptr<QXmppCallInvitePrivate> d;
56
57 friend class QXmppCallInviteManager;
58 friend class tst_QXmppCallInviteManager;
59};
60
61 class QXMPP_EXPORT QXmppCallInviteManager : public QXmppClientExtension, public QXmppMessageHandler
62{
63 Q_OBJECT
64public:
65 using ProposeResult = std::variant<std::shared_ptr<QXmppCallInvite>, QXmppError>;
66
67 QXmppCallInviteManager();
68 ~QXmppCallInviteManager();
69
71 QStringList discoveryFeatures() const override;
73
74 QXmppTask<ProposeResult> invite(
75 const QString &callPartnerJid,
76 bool audio = true,
77 bool video = false,
78 std::optional<QXmppCallInviteElement::Jingle> jingle = std::nullopt,
79 std::optional<QVector<QXmppCallInviteElement::External>> external = std::nullopt);
80
81 Q_SIGNAL void invited(const std::shared_ptr<QXmppCallInvite> &callInvite, const QString &id);
82
83protected:
85 bool handleMessage(const QXmppMessage &) override;
87
88private:
89 QXmppTask<QXmpp::SendResult> sendMessage(
90 const QXmppCallInviteElement &callInviteElement,
91 const QString &callPartnerJid);
92
93 void clear(const std::shared_ptr<QXmppCallInvite> &callInvite);
94 void clearAll();
95
96 bool handleCallInviteElement(QXmppCallInviteElement &&callInviteElement, const QString &senderJid);
97
98 bool handleExistingCallInvite(
99 const std::shared_ptr<QXmppCallInvite> &existingCallInvite,
100 const QXmppCallInviteElement &callInviteElement,
101 const QString &callPartnerResource);
102
103 bool handleInviteCallInviteElement(const QXmppCallInviteElement &callInviteElement, const QString &callPartnerJid);
104
105 std::shared_ptr<QXmppCallInvite> addCallInvite(const QString &callPartnerJid);
106 const QVector<std::shared_ptr<QXmppCallInvite>> &callInvites() const;
107
108private:
109 std::unique_ptr<QXmppCallInviteManagerPrivate> d;
110
111 friend class QXmppCallInvitePrivate;
112 friend class tst_QXmppCallInviteManager;
113};
114Q_DECLARE_METATYPE(QXmppCallInvite::Result)
115Q_DECLARE_METATYPE(std::shared_ptr<QXmppCallInvite>)
116
117#endif // QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
QXmppCallInviteElement
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition QXmppJingleData.h:689
QXmppCallInvite::closed
Q_SIGNAL void closed(const QXmppCallInvite::Result &result)
QXmppCallInvite::accepted
Q_SIGNAL void accepted(const QString &id, const QString &callPartnerResource)
QXmppCallInvite::QXmppCallInvite
QXmppCallInvite(QXmppCallInviteManager *manager)
Constructs a Call Invite object.
Definition QXmppCallInviteManager.cpp:58
QXmppCallInvite::leave
QXmppTask< QXmpp::SendResult > leave()
Definition QXmppCallInviteManager.cpp:101
QXmppCallInvite::retract
QXmppTask< QXmpp::SendResult > retract()
Definition QXmppCallInviteManager.cpp:90
QXmppCallInvite::accept
QXmppTask< QXmpp::SendResult > accept()
Definition QXmppCallInviteManager.cpp:66
QXmppCallInvite::reject
QXmppTask< QXmpp::SendResult > reject()
Definition QXmppCallInviteManager.cpp:79
QXmppCallInvite::invited
Q_SIGNAL void invited()
QXmppCallInvite::Result
std::variant< Rejected, Retracted, Left, QXmppError > Result
Definition QXmppCallInviteManager.h:27
QXmppCallInviteManager
The QXmppCallInviteManager class makes it possible to retrieve Call Invite elements as defined by XEP...
Definition QXmppCallInviteManager.h:62
QXmppCallInviteManager::invited
Q_SIGNAL void invited(const std::shared_ptr< QXmppCallInvite > &callInvite, const QString &id)
QXmppCallInviteManager::ProposeResult
std::variant< std::shared_ptr< QXmppCallInvite >, QXmppError > ProposeResult
Definition QXmppCallInviteManager.h:65
QXmppCallInviteManager::invite
QXmppTask< ProposeResult > invite(const QString &callPartnerJid, bool audio=true, bool video=false, std::optional< QXmppCallInviteElement::Jingle > jingle=std::nullopt, std::optional< QVector< QXmppCallInviteElement::External > > external=std::nullopt)
Definition QXmppCallInviteManager.cpp:241
QXmppClientExtension::discoveryFeatures
virtual QStringList discoveryFeatures() const
Definition QXmppClientExtension.cpp:22
QXmppClientExtension::QXmppClientExtension
QXmppClientExtension()
Definition QXmppClientExtension.cpp:12
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