QXmpp  Version: 1.6.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 
16 class QXmppCallInvitePrivate;
17 class QXmppCallInviteManagerPrivate;
18 
19 class QXMPP_EXPORT QXmppCallInvite : public QObject
20 {
21  Q_OBJECT
22 public:
23  struct Rejected
24  {
25  };
26  struct Retracted
27  {
28  };
29  struct Left
30  {
31  };
32 
33  using Result = std::variant<Rejected, Retracted, Left, QXmppError>;
34 
35  explicit QXmppCallInvite(QXmppCallInviteManager *manager);
36  ~QXmppCallInvite();
37 
42 
43  Q_SIGNAL void invited();
44  Q_SIGNAL void accepted(const QString &id, const QString &callPartnerResource);
45  Q_SIGNAL void closed(const Result &result);
46 
47 private:
49  bool audio = true,
50  bool video = false,
51  std::optional<QXmppCallInviteElement::Jingle> jingle = std::nullopt,
52  std::optional<QVector<QXmppCallInviteElement::External>> external = std::nullopt);
53 
54  QString id() const;
55  void setId(const QString &id);
56  void setCallPartnerJid(const QString &callPartnerJid);
57  QString callPartnerJid() const;
58  bool isAccepted() const;
59  void setIsAccepted(bool isAccepted);
60 
61  std::unique_ptr<QXmppCallInvitePrivate> d;
62 
63  friend class QXmppCallInviteManager;
64  friend class tst_QXmppCallInviteManager;
65 };
66 
68 {
69  Q_OBJECT
70 public:
71  using ProposeResult = std::variant<std::shared_ptr<QXmppCallInvite>, QXmppError>;
72 
75 
77  QStringList discoveryFeatures() const override;
79 
81  const QString &callPartnerJid,
82  bool audio = true,
83  bool video = false,
84  std::optional<QXmppCallInviteElement::Jingle> jingle = std::nullopt,
85  std::optional<QVector<QXmppCallInviteElement::External>> external = std::nullopt);
86 
87  Q_SIGNAL void invited(const std::shared_ptr<QXmppCallInvite> &callInvite, const QString &id);
88 
89 protected:
91  bool handleMessage(const QXmppMessage &) override;
92  void setClient(QXmppClient *client) override;
94 
95 private:
96  QXmppTask<QXmpp::SendResult> sendMessage(
97  const QXmppCallInviteElement &callInviteElement,
98  const QString &callPartnerJid);
99 
100  void clear(const std::shared_ptr<QXmppCallInvite> &callInvite);
101  void clearAll();
102 
103  bool handleCallInviteElement(QXmppCallInviteElement &&callInviteElement, const QString &senderJid);
104 
105  bool handleExistingCallInvite(
106  const std::shared_ptr<QXmppCallInvite> &existingCallInvite,
107  const QXmppCallInviteElement &callInviteElement,
108  const QString &callPartnerResource);
109 
110  bool handleInviteCallInviteElement(const QXmppCallInviteElement &callInviteElement, const QString &callPartnerJid);
111 
112  std::shared_ptr<QXmppCallInvite> addCallInvite(const QString &callPartnerJid);
113  const QVector<std::shared_ptr<QXmppCallInvite>> &callInvites() const;
114 
115 private:
116  std::unique_ptr<QXmppCallInviteManagerPrivate> d;
117 
118  friend class QXmppCallInvitePrivate;
119  friend class tst_QXmppCallInviteManager;
120 };
121 Q_DECLARE_METATYPE(QXmppCallInvite::Result)
122 Q_DECLARE_METATYPE(std::shared_ptr<QXmppCallInvite>)
123 
124 #endif // QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition: QXmppJingleData.h:661
Definition: QXmppError.h:17
The QXmppCallInvite class holds information about the Call Invite element in the current context...
Definition: QXmppCallInviteManager.h:19
virtual bool handleMessage(const QXmppMessage &)=0
Definition: QXmppStream.h:20
std::variant< std::shared_ptr< QXmppCallInvite >, QXmppError > ProposeResult
Definition: QXmppCallInviteManager.h:71
virtual QStringList discoveryFeatures() const
Definition: QXmppClientExtension.cpp:22
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:37
Definition: QXmppMessageHandler.h:15
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition: QXmppClientExtension.h:32
The QXmppCallInviteManager class makes it possible to retrieve Call Invite elements as defined by XEP...
Definition: QXmppCallInviteManager.h:67
std::variant< Rejected, Retracted, Left, QXmppError > Result
Definition: QXmppCallInviteManager.h:33
virtual void setClient(QXmppClient *client)
Definition: QXmppClientExtension.cpp:88
The QXmppClient class is the main class for using QXmpp.
Definition: QXmppClient.h:83