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();
const QString &remoteJid() const;
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 &remoteResource);
Q_SIGNAL void closed(const Result &result);
private:
QXmppJingleMessageInitiation(QXmppJingleMessageInitiationManager *manager, const QString &id, const QString &remoteJid);
QString id() const;
void setId(const QString &id);
void setRemoteJid(const QString &remoteJid);
bool isProceeded() const;
void setIsProceeded(bool isProceeded);
bool isFinished() const;
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 &remoteJid,
const QXmppJingleRtpDescription &description);
QXmppTask<ProposeResult> propose(
const QString &remoteJid,
const QList<QXmppJingleRtpDescription> &descriptions);
Q_SIGNAL void proposed(
const std::shared_ptr<QXmppJingleMessageInitiation> &jmi,
const QString &id,
const std::optional<QXmppJingleRtpDescription> &description);
Q_SIGNAL void proposeReceived(
const std::shared_ptr<QXmppJingleMessageInitiation> &jmi,
const QString &id,
const QList<QXmppJingleRtpDescription> &descriptions);
protected:
bool handleMessage(const QXmppMessage &) override;
private:
QXmppTask<ProposeResult> propose(
const QString &id,
const QString &remoteJid,
const QList<QXmppJingleRtpDescription> &descriptions);
QXmppTask<QXmpp::SendResult> sendMessage(
const QXmppJingleMessageInitiationElement &jmiElement,
const QString &remoteJid);
void clear(const std::shared_ptr<QXmppJingleMessageInitiation> &jmi);
void clearAll();
bool handleJmiElement(QXmppJingleMessageInitiationElement &&jmiElement, const QString &remoteJid);
bool handleExistingJmi(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QXmppJingleMessageInitiationElement &jmiElement, const QString &remoteResource);
bool handleProposeJmiElement(const QXmppJingleMessageInitiationElement &jmiElement, const QString &remoteJid);
bool handleTieBreak(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QXmppJingleMessageInitiationElement &jmiElement, const QString &remoteResource);
bool handleExistingSession(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QString &jmiElementId);
bool handleNonExistingSession(const std::shared_ptr<QXmppJingleMessageInitiation> &existingJmi, const QString &jmiElementId, const QString &remoteResource);
std::shared_ptr<QXmppJingleMessageInitiation> addJmi(const QString &id, const QString &remoteJid);
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::discoveryFeatures
virtual QStringList discoveryFeatures() const
Definition QXmppClientExtension.cpp:22
QXmppClientExtension::QXmppClientExtension
QXmppClientExtension()
Definition QXmppClientExtension.cpp:12
QXmppJingleMessageInitiationElement
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition QXmppJingleData.h:642
QXmppJingleMessageInitiationManager
The QXmppJingleMessageInitiationManager class makes it possible to retrieve Jingle Message Initiation...
Definition QXmppJingleMessageInitiationManager.h:73
QXmppJingleMessageInitiationManager::ProposeResult
std::variant< std::shared_ptr< QXmppJingleMessageInitiation >, QXmppError > ProposeResult
Definition QXmppJingleMessageInitiationManager.h:76
QXmppJingleMessageInitiationManager::propose
QXmppTask< ProposeResult > propose(const QString &remoteJid, const QXmppJingleRtpDescription &description)
Definition QXmppJingleMessageInitiationManager.cpp:293
QXmppJingleMessageInitiationManager::proposeReceived
Q_SIGNAL void proposeReceived(const std::shared_ptr< QXmppJingleMessageInitiation > &jmi, const QString &id, const QList< QXmppJingleRtpDescription > &descriptions)
QXmppJingleMessageInitiationManager::proposed
Q_SIGNAL void proposed(const std::shared_ptr< QXmppJingleMessageInitiation > &jmi, const QString &id, const std::optional< QXmppJingleRtpDescription > &description)
QXmppJingleMessageInitiation::proceeded
Q_SIGNAL void proceeded(const QString &id, const QString &remoteResource)
QXmppJingleMessageInitiation::closed
Q_SIGNAL void closed(const Result &result)
QXmppJingleMessageInitiation::finish
QXmppTask< QXmpp::SendResult > finish(std::optional< QXmppJingleReason > reason, const QString &migratedTo={})
Definition QXmppJingleMessageInitiationManager.cpp:146
QXmppJingleMessageInitiation::remoteJid
const QString & remoteJid() const
Definition QXmppJingleMessageInitiationManager.cpp:200
QXmppJingleMessageInitiation::ring
QXmppTask< QXmpp::SendResult > ring()
Definition QXmppJingleMessageInitiationManager.cpp:72
QXmppJingleMessageInitiation::retract
QXmppTask< QXmpp::SendResult > retract(std::optional< QXmppJingleReason > reason, bool containsTieBreak=false)
Definition QXmppJingleMessageInitiationManager.cpp:122
QXmppJingleMessageInitiation::reject
QXmppTask< QXmpp::SendResult > reject(std::optional< QXmppJingleReason > reason, bool containsTieBreak=false)
Definition QXmppJingleMessageInitiationManager.cpp:98
QXmppJingleMessageInitiation::Result
std::variant< Rejected, Retracted, Finished, QXmppError > Result
Variant of Rejected, Retracted, Finished or Error result types.
Definition QXmppJingleMessageInitiationManager.h:40
QXmppJingleMessageInitiation::ringing
Q_SIGNAL void ringing()
QXmppJingleMessageInitiation::proceed
QXmppTask< QXmpp::SendResult > proceed()
Definition QXmppJingleMessageInitiationManager.cpp:83
QXmppJingleRtpDescription
Represents a description for XEP-0167: Jingle RTP Sessions, including media type, streaming source,...
Definition QXmppJingleData.h:253
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