Loading...
Searching...
No Matches
QXmppCallInviteManager.h
// SPDX-FileCopyrightText: 2023 Tibor Csötönyi <work@taibsu.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPCALLINVITEMANAGER_H
#define QXMPPCALLINVITEMANAGER_H
#include "QXmppClientExtension.h"
#include "QXmppError.h"
#include "QXmppJingleIq.h"
#include "QXmppMessageHandler.h"
#include "QXmppSendResult.h"
#include "QXmppTask.h"
class QXmppCallInviteManager;
class QXmppCallInvitePrivate;
class QXmppCallInviteManagerPrivate;
class QXMPP_EXPORT QXmppCallInvite : public QObject
{
Q_OBJECT
public:
struct Rejected { };
struct Retracted { };
struct Left { };
using Result = std::variant<Rejected, Retracted, Left, QXmppError>;
explicit QXmppCallInvite(QXmppCallInviteManager *manager);
~QXmppCallInvite();
QXmppTask<QXmpp::SendResult> accept();
QXmppTask<QXmpp::SendResult> reject();
QXmppTask<QXmpp::SendResult> retract();
QXmppTask<QXmpp::SendResult> leave();
Q_SIGNAL void invited();
Q_SIGNAL void accepted(const QString &id, const QString &callPartnerResource);
Q_SIGNAL void closed(const QXmppCallInvite::Result &result);
private:
QXmppTask<QXmpp::SendResult> invite(
bool audio = true,
bool video = false,
std::optional<QXmppCallInviteElement::Jingle> jingle = std::nullopt,
std::optional<QVector<QXmppCallInviteElement::External>> external = std::nullopt);
QString id() const;
void setId(const QString &id);
void setCallPartnerJid(const QString &callPartnerJid);
QString callPartnerJid() const;
bool isAccepted() const;
void setIsAccepted(bool isAccepted);
std::unique_ptr<QXmppCallInvitePrivate> d;
friend class QXmppCallInviteManager;
friend class tst_QXmppCallInviteManager;
};
class QXMPP_EXPORT QXmppCallInviteManager : public QXmppClientExtension, public QXmppMessageHandler
{
Q_OBJECT
public:
using ProposeResult = std::variant<std::shared_ptr<QXmppCallInvite>, QXmppError>;
QXmppCallInviteManager();
~QXmppCallInviteManager();
QStringList discoveryFeatures() const override;
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);
Q_SIGNAL void invited(const std::shared_ptr<QXmppCallInvite> &callInvite, const QString &id);
protected:
bool handleMessage(const QXmppMessage &) override;
private:
QXmppTask<QXmpp::SendResult> sendMessage(
const QXmppCallInviteElement &callInviteElement,
const QString &callPartnerJid);
void clear(const std::shared_ptr<QXmppCallInvite> &callInvite);
void clearAll();
bool handleCallInviteElement(QXmppCallInviteElement &&callInviteElement, const QString &senderJid);
bool handleExistingCallInvite(
const std::shared_ptr<QXmppCallInvite> &existingCallInvite,
const QXmppCallInviteElement &callInviteElement,
const QString &callPartnerResource);
bool handleInviteCallInviteElement(const QXmppCallInviteElement &callInviteElement, const QString &callPartnerJid);
std::shared_ptr<QXmppCallInvite> addCallInvite(const QString &callPartnerJid);
const QVector<std::shared_ptr<QXmppCallInvite>> &callInvites() const;
private:
std::unique_ptr<QXmppCallInviteManagerPrivate> d;
friend class QXmppCallInvitePrivate;
friend class tst_QXmppCallInviteManager;
};
Q_DECLARE_METATYPE(QXmppCallInvite::Result)
Q_DECLARE_METATYPE(std::shared_ptr<QXmppCallInvite>)
#endif // QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
QXmppCallInviteElement
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition QXmppJingleData.h:649
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
QXmppCallInvite
The QXmppCallInvite class holds information about the Call Invite element in the current context.
Definition QXmppCallInviteManager.h:20
QXmppCallInvite::Result
std::variant< Rejected, Retracted, Left, QXmppError > Result
Definition QXmppCallInviteManager.h:27
QXmppCallInvite::invited
Q_SIGNAL void invited()
QXmppCallInvite::accepted
Q_SIGNAL void accepted(const QString &id, const QString &callPartnerResource)
QXmppCallInvite::closed
Q_SIGNAL void closed(const QXmppCallInvite::Result &result)
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:32
QXmppMessageHandler
Definition QXmppMessageHandler.h:16
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:64
QXmppTask
Definition QXmppTask.h:62
QXmppError
Definition QXmppError.h:17