Loading...
Searching...
No Matches
QXmppJingleMessageInitiationManager.h
// SPDX-FileCopyrightText: 2023 Tibor Csötönyi <work@taibsu.de>
// SPDX-FileCopyrightText: 2023 Melvin Keskin <melvo@olomono.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
#define QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
#include "QXmppClientExtension.h"
#include "QXmppError.h"
#include "QXmppJingleIq.h"
#include "QXmppMessageHandler.h"
#include "QXmppSendResult.h"
#include "QXmppTask.h"
class QXmppJingleMessageInitiationManager;
class QXmppJingleMessageInitiationPrivate;
class QXmppJingleMessageInitiationManagerPrivate;
class QXMPP_EXPORT QXmppJingleMessageInitiation : public QObject
{
Q_OBJECT
public:
struct Rejected {
std::optional<QXmppJingleReason> reason;
bool containsTieBreak;
};
struct Retracted {
std::optional<QXmppJingleReason> reason;
bool containsTieBreak;
};
struct Finished {
std::optional<QXmppJingleReason> reason;
QString migratedTo;
};
using Result = std::variant<Rejected, Retracted, Finished, QXmppError>;
QXmppJingleMessageInitiation(QXmppJingleMessageInitiationManager *manager);
~QXmppJingleMessageInitiation();
QXmppTask<QXmpp::SendResult> ring();
QXmppTask<QXmpp::SendResult> proceed();
QXmppTask<QXmpp::SendResult> reject(std::optional<QXmppJingleReason> reason, bool containsTieBreak = false);
QXmppTask<QXmpp::SendResult> retract(std::optional<QXmppJingleReason> reason, bool containsTieBreak = false);
QXmppTask<QXmpp::SendResult> finish(std::optional<QXmppJingleReason> reason, const QString &migratedTo = {});
Q_SIGNAL void ringing();
Q_SIGNAL void proceeded(const QString &id, const QString &callPartnerResource);
Q_SIGNAL void closed(const Result &result);
private:
QString id() const;
void setId(const QString &id);
void setCallPartnerJid(const QString &callPartnerJid);
QString callPartnerJid() const;
bool isProceeded() const;
void setIsProceeded(bool isProceeded);
std::unique_ptr<QXmppJingleMessageInitiationPrivate> d;
friend class QXmppJingleMessageInitiationManager;
friend class tst_QXmppJingleMessageInitiationManager;
};
class QXMPP_EXPORT QXmppJingleMessageInitiationManager : public QXmppClientExtension, public QXmppMessageHandler
{
Q_OBJECT
public:
using ProposeResult = std::variant<std::shared_ptr<QXmppJingleMessageInitiation>, QXmppError>;
QXmppJingleMessageInitiationManager();
~QXmppJingleMessageInitiationManager();
QStringList discoveryFeatures() const override;
QXmppTask<ProposeResult> propose(
const QString &callPartnerJid,
const QXmppJingleDescription &description);
Q_SIGNAL void proposed(
const std::shared_ptr<QXmppJingleMessageInitiation> &jmi,
const QString &id,
const std::optional<QXmppJingleDescription> &description);
protected:
bool handleMessage(const QXmppMessage &) override;
private:
QXmppTask<QXmpp::SendResult> sendMessage(
const QXmppJingleMessageInitiationElement &jmiElement,
const QString &callPartnerJid);
void clear(const std::shared_ptr<QXmppJingleMessageInitiation> &jmi);
void clearAll();
bool handleJmiElement(QXmppJingleMessageInitiationElement &&jmiElement, const QString &senderJid);
bool handleExistingJmi(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QXmppJingleMessageInitiationElement &jmiElement, const QString &callPartnerResource);
bool handleProposeJmiElement(const QXmppJingleMessageInitiationElement &jmiElement, const QString &callPartnerJid);
bool handleTieBreak(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QXmppJingleMessageInitiationElement &jmiElement, const QString &callPartnerResource);
bool handleExistingSession(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QString &jmiElementId);
bool handleNonExistingSession(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QString &jmiElementId, const QString &callPartnerResource);
std::shared_ptr<QXmppJingleMessageInitiation> addJmi(const QString &callPartnerJid);
const QVector<std::shared_ptr<QXmppJingleMessageInitiation>> &jmis() const;
private:
std::unique_ptr<QXmppJingleMessageInitiationManagerPrivate> d;
friend class QXmppJingleMessageInitiationPrivate;
friend class tst_QXmppJingleMessageInitiationManager;
};
Q_DECLARE_METATYPE(QXmppJingleMessageInitiation::Result)
#endif // QXMPPJINGLEMESSAGEINITIATIONMANAGER_H
QXmppClientExtension
The QXmppClientExtension class is the base class for QXmppClient extensions.
Definition QXmppClientExtension.h:32
QXmppJingleDescription
The QXmppJingleDescription class represents descriptions for Jingle elements including media type,...
Definition QXmppJingleData.h:246
QXmppJingleMessageInitiationElement
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition QXmppJingleData.h:602
QXmppJingleMessageInitiationManager
The QXmppJingleMessageInitiationManager class makes it possible to retrieve Jingle Message Initiation...
Definition QXmppJingleMessageInitiationManager.h:70
QXmppJingleMessageInitiationManager::proposed
Q_SIGNAL void proposed(const std::shared_ptr< QXmppJingleMessageInitiation > &jmi, const QString &id, const std::optional< QXmppJingleDescription > &description)
QXmppJingleMessageInitiationManager::ProposeResult
std::variant< std::shared_ptr< QXmppJingleMessageInitiation >, QXmppError > ProposeResult
Definition QXmppJingleMessageInitiationManager.h:73
QXmppJingleMessageInitiation
The QXmppJingleMessageInitiation class holds information about the JMI element in the current context...
Definition QXmppJingleMessageInitiationManager.h:21
QXmppJingleMessageInitiation::closed
Q_SIGNAL void closed(const Result &result)
QXmppJingleMessageInitiation::proceeded
Q_SIGNAL void proceeded(const QString &id, const QString &callPartnerResource)
QXmppJingleMessageInitiation::ringing
Q_SIGNAL void ringing()
QXmppJingleMessageInitiation::Result
std::variant< Rejected, Retracted, Finished, QXmppError > Result
Variant of Rejected, Retracted, Finished or Error result types.
Definition QXmppJingleMessageInitiationManager.h:40
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