QXmpp Version: 1.10.0
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
16class QXmppCallInvitePrivate;
17class QXmppCallInviteManagerPrivate;
18
19class 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);
31
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:
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
62{
63 Q_OBJECT
64public:
65 using ProposeResult = std::variant<std::shared_ptr<QXmppCallInvite>, QXmppError>;
66
69
71 QStringList discoveryFeatures() const override;
73
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:
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
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition: QXmppJingleData.h:649
The QXmppCallInviteManager class makes it possible to retrieve Call Invite elements as defined by XEP...
Definition: QXmppCallInviteManager.h:62
Q_SIGNAL void invited(const std::shared_ptr< QXmppCallInvite > &callInvite, const QString &id)
std::variant< std::shared_ptr< QXmppCallInvite >, QXmppError > ProposeResult
Definition: QXmppCallInviteManager.h:65
The QXmppCallInvite class holds information about the Call Invite element in the current context.
Definition: QXmppCallInviteManager.h:20
std::variant< Rejected, Retracted, Left, QXmppError > Result
Definition: QXmppCallInviteManager.h:27
Q_SIGNAL void invited()
Q_SIGNAL void accepted(const QString &id, const QString &callPartnerResource)
Q_SIGNAL void closed(const QXmppCallInvite::Result &result)
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:32
Definition: QXmppMessageHandler.h:16
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:64
Definition: QXmppTask.h:62
Definition: QXmppError.h:17