Loading...
Searching...
No Matches
QXmppMessage.h
// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <manjeetdahiya@gmail.com>
// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
// SPDX-FileCopyrightText: 2018 Linus Jahn <lnj@kaidan.im>
// SPDX-FileCopyrightText: 2020 Melvin Keskin <melvo@olomono.de>
// SPDX-FileCopyrightText: 2023 Tibor Csötönyi <work@taibsu.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPMESSAGE_H
#define QXMPPMESSAGE_H
#include "QXmppFallback.h"
#include "QXmppFileShare.h"
#include "QXmppStanza.h"
#include <optional>
// Required for source compatibility
#include <QDateTime>
class QXmppMessagePrivate;
class QXmppBitsOfBinaryDataList;
class QXmppFallback;
class QXmppJingleMessageInitiationElement;
class QXmppMessageReaction;
class QXmppMixInvitation;
#ifdef BUILD_OMEMO
class QXmppOmemoElement;
#endif
class QXmppTrustMessageElement;
class QXmppOutOfBandUrl;
class QXmppCallInviteElement;
namespace QXmpp {
struct Reply {
QString to;
QString id;
};
} // namespace QXmpp
struct QXmppStanzaId {
QString id;
QString by;
};
class QXMPP_EXPORT QXmppMessage : public QXmppStanza
{
public:
#if QXMPP_DEPRECATED_SINCE(1, 5)
using EncryptionMethod = QXmpp::EncryptionMethod;
static const EncryptionMethod NoEncryption = EncryptionMethod::NoEncryption;
static const EncryptionMethod UnknownEncryption = EncryptionMethod::UnknownEncryption;
static const EncryptionMethod OTR = EncryptionMethod::Otr;
static const EncryptionMethod LegacyOpenPGP = EncryptionMethod::LegacyOpenPgp;
static const EncryptionMethod OX = EncryptionMethod::Ox;
static const EncryptionMethod OMEMO = EncryptionMethod::Omemo0;
#endif
enum Type {
Error = 0,
Normal,
Chat,
GroupChat,
Headline
};
enum State {
None = 0,
Active,
Inactive,
Gone,
Composing,
Paused
};
enum Marker {
NoMarker = 0,
Received,
Displayed,
Acknowledged
};
enum Hint {
NoPermanentStore = 1 << 0,
NoStore = 1 << 1,
NoCopy = 1 << 2,
Store = 1 << 3
};
QXmppMessage(const QString &from = QString(), const QString &to = QString(),
const QString &body = QString(), const QString &thread = QString());
QXmppMessage(const QXmppMessage &other);
QXmppMessage(QXmppMessage &&);
~QXmppMessage() override;
QXmppMessage &operator=(const QXmppMessage &other);
QXmppMessage &operator=(QXmppMessage &&);
bool isXmppStanza() const override;
QString body() const;
void setBody(const QString &);
QString e2eeFallbackBody() const;
void setE2eeFallbackBody(const QString &fallbackBody);
QString subject() const;
void setSubject(const QString &);
QString thread() const;
void setThread(const QString &);
QString parentThread() const;
void setParentThread(const QString &);
QXmppMessage::Type type() const;
void setType(QXmppMessage::Type);
// XEP-0066: Out of Band Data
QString outOfBandUrl() const;
void setOutOfBandUrl(const QString &);
QVector<QXmppOutOfBandUrl> outOfBandUrls() const;
void setOutOfBandUrls(const QVector<QXmppOutOfBandUrl> &urls);
// XEP-0071: XHTML-IM
QString xhtml() const;
void setXhtml(const QString &xhtml);
// XEP-0085: Chat State Notifications
QXmppMessage::State state() const;
void setState(QXmppMessage::State);
// XEP-0091: Legacy Delayed Delivery | XEP-0203: Delayed Delivery
QDateTime stamp() const;
void setStamp(const QDateTime &stamp);
// XEP-0184: Message Delivery Receipts
bool isReceiptRequested() const;
void setReceiptRequested(bool requested);
QString receiptId() const;
void setReceiptId(const QString &id);
// XEP-0224: Attention
bool isAttentionRequested() const;
void setAttentionRequested(bool requested);
// XEP-0231: Bits of Binary
QXmppBitsOfBinaryDataList bitsOfBinaryData() const;
QXmppBitsOfBinaryDataList &bitsOfBinaryData();
void setBitsOfBinaryData(const QXmppBitsOfBinaryDataList &bitsOfBinaryData);
// XEP-0245: The /me Command
static bool isSlashMeCommand(const QString &body);
bool isSlashMeCommand() const;
static QString slashMeCommandText(const QString &body);
QString slashMeCommandText() const;
// XEP-0249: Direct MUC Invitations
QString mucInvitationJid() const;
void setMucInvitationJid(const QString &jid);
QString mucInvitationPassword() const;
void setMucInvitationPassword(const QString &password);
QString mucInvitationReason() const;
void setMucInvitationReason(const QString &reason);
// XEP-0280: Message Carbons
bool isPrivate() const;
void setPrivate(const bool);
bool isCarbonForwarded() const;
void setCarbonForwarded(bool);
// XEP-0308: Last Message Correction
QString replaceId() const;
void setReplaceId(const QString &);
// XEP-0333: Chat State Markers
bool isMarkable() const;
void setMarkable(const bool);
QString markedId() const;
void setMarkerId(const QString &);
QString markedThread() const;
void setMarkedThread(const QString &);
Marker marker() const;
void setMarker(const Marker);
// XEP-0334: Message Processing Hints
bool hasHint(const Hint hint) const;
void addHint(const Hint hint);
void removeHint(const Hint hint);
void removeAllHints();
// XEP-0353: Jingle Message Initiation
std::optional<QXmppJingleMessageInitiationElement> jingleMessageInitiationElement() const;
void setJingleMessageInitiationElement(const std::optional<QXmppJingleMessageInitiationElement> &jingleMessageInitiationElement);
// XEP-0359: Unique and Stable Stanza IDs
#if QXMPP_DEPRECATED_SINCE(1, 8)
[[deprecated("Use stanzaIds() instead.")]]
QString stanzaId() const;
[[deprecated("Use setStanzaIds() instead.")]]
void setStanzaId(const QString &id);
[[deprecated("Use stanzaIds() instead.")]]
QString stanzaIdBy() const;
[[deprecated("Use setStanzaIds() instead.")]]
void setStanzaIdBy(const QString &id);
#endif
QVector<QXmppStanzaId> stanzaIds() const;
void setStanzaIds(const QVector<QXmppStanzaId> &);
QString originId() const;
void setOriginId(const QString &id);
// XEP-0367: Message Attaching
QString attachId() const;
void setAttachId(const QString &);
// XEP-0369: Mediated Information eXchange (MIX)
QString mixParticipantId() const;
QString mixUserJid() const;
void setMixUserJid(const QString &);
QString mixUserNick() const;
void setMixUserNick(const QString &);
// XEP-0380: Explicit Message Encryption
QXmpp::EncryptionMethod encryptionMethod() const;
void setEncryptionMethod(QXmpp::EncryptionMethod);
QString encryptionMethodNs() const;
void setEncryptionMethodNs(const QString &);
QString encryptionName() const;
void setEncryptionName(const QString &);
// XEP-0382: Spoiler messages
bool isSpoiler() const;
void setIsSpoiler(bool);
QString spoilerHint() const;
void setSpoilerHint(const QString &);
// XEP-0407: Mediated Information eXchange (MIX): Miscellaneous Capabilities
std::optional<QXmppMixInvitation> mixInvitation() const;
void setMixInvitation(const std::optional<QXmppMixInvitation> &mixInvitation);
// XEP-0428: Fallback Indication
#if QXMPP_DEPRECATED_SINCE(1, 7)
[[deprecated("Use fallbackMarkers()")]] bool isFallback() const;
[[deprecated("Use setFallbackMarkers()")]] void setIsFallback(bool isFallback);
#endif
const QVector<QXmppFallback> &fallbackMarkers() const;
void setFallbackMarkers(const QVector<QXmppFallback> &);
QString readFallbackRemovedText(QXmppFallback::Element element, const QVector<QString> &supportedNamespaces) const;
QString readFallbackText(QXmppFallback::Element element, QStringView forNamespace) const;
// XEP-0434: Trust Messages (TM)
std::optional<QXmppTrustMessageElement> trustMessageElement() const;
void setTrustMessageElement(const std::optional<QXmppTrustMessageElement> &trustMessageElement);
// XEP-0444: Message Reactions
std::optional<QXmppMessageReaction> reaction() const;
void setReaction(const std::optional<QXmppMessageReaction> &reaction);
// XEP-0447: Stateless file sharing
const QVector<QXmppFileShare> &sharedFiles() const;
void setSharedFiles(const QVector<QXmppFileShare> &sharedFiles);
QVector<QXmppFileSourcesAttachment> fileSourcesAttachments() const;
void setFileSourcesAttachments(const QVector<QXmppFileSourcesAttachment> &);
// XEP-0461: Message Replies
std::optional<QXmpp::Reply> reply() const;
void setReply(const std::optional<QXmpp::Reply> &);
QString readReplyQuoteFromBody() const;
// XEP-0482: Call Invites
std::optional<QXmppCallInviteElement> callInviteElement() const;
void setCallInviteElement(std::optional<QXmppCallInviteElement> callInviteElement);
#ifdef BUILD_OMEMO
// XEP-0384: OMEMO Encryption
std::optional<QXmppOmemoElement> omemoElement() const;
void setOmemoElement(const std::optional<QXmppOmemoElement> &omemoElement);
#endif
void parse(const QDomElement &element) override final;
virtual void parse(const QDomElement &element, QXmpp::SceMode);
void toXml(QXmlStreamWriter *writer) const override final;
virtual void toXml(QXmlStreamWriter *writer, QXmpp::SceMode) const;
void parseExtensions(const QDomElement &element, QXmpp::SceMode sceMode);
virtual bool parseExtension(const QDomElement &element, QXmpp::SceMode);
virtual void serializeExtensions(QXmlStreamWriter *writer, QXmpp::SceMode, const QString &baseNamespace = {}) const;
private:
QSharedDataPointer<QXmppMessagePrivate> d;
};
Q_DECLARE_METATYPE(QXmppMessage)
#endif // QXMPPMESSAGE_H
QXmppBitsOfBinaryDataList
Definition QXmppBitsOfBinaryDataList.h:16
QXmppCallInviteElement
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition QXmppJingleData.h:649
QXmppFallback
Definition QXmppFallback.h:20
QXmppFallback::Element
Element
Definition QXmppFallback.h:22
QXmppJingleMessageInitiationElement
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition QXmppJingleData.h:602
QXmppMessageReaction
The QXmppMessageReaction class represents a reaction to a message in the form of emojis as specified ...
Definition QXmppMessageReaction.h:17
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:64
QXmppMessage::operator=
QXmppMessage & operator=(QXmppMessage &&)
Move-assignment operator.
QXmppMessage::operator=
QXmppMessage & operator=(const QXmppMessage &other)
Assignment operator.
QXmppMessage::Type
Type
This enum describes a message type.
Definition QXmppMessage.h:80
QXmppMessage::QXmppMessage
QXmppMessage(QXmppMessage &&)
Move-constructor.
QXmppMessage::Marker
Marker
Definition QXmppMessage.h:108
QXmppMessage::Hint
Hint
Definition QXmppMessage.h:120
QXmppMessage::State
State
Definition QXmppMessage.h:94
QXmppMessage::Active
@ Active
User is actively participating in the chat session.
Definition QXmppMessage.h:96
QXmppMessage::Inactive
@ Inactive
User has not been actively participating in the chat session.
Definition QXmppMessage.h:97
QXmppMessage::Composing
@ Composing
User is composing a message.
Definition QXmppMessage.h:99
QXmppMessage::Gone
@ Gone
User has effectively ended their participation in the chat session.
Definition QXmppMessage.h:98
QXmppMessage::QXmppMessage
QXmppMessage(const QXmppMessage &other)
Constructs a copy of other.
QXmppNonza::parse
virtual void parse(const QDomElement &)=0
QXmppNonza::isXmppStanza
virtual bool isXmppStanza() const
Definition QXmppNonza.h:19
QXmppNonza::toXml
virtual void toXml(QXmlStreamWriter *writer) const =0
QXmppOutOfBandUrl
Definition QXmppOutOfBandUrl.h:19
QXmppStanza::Error
The Error class represents a stanza error.
Definition QXmppStanza.h:94
QXmppStanza
The QXmppStanza class is the base class for all XMPP stanzas.
Definition QXmppStanza.h:88
QXmppTrustMessageElement
The QXmppTrustMessageElement class represents a trust message element as defined by XEP-0434: Trust M...
Definition QXmppTrustMessageElement.h:18
QXmppMixInvitation::QXmppMixInvitation
QXmppMixInvitation()
The QXmppMixInvitation class is used to invite a user to a XEP-0369: Mediated Information eXchange (M...
Definition QXmppMixInvitation.cpp:39
QXmpp
Definition Algorithms.h:12
QXmpp::SceMode
SceMode
Definition QXmppGlobal.h:136
QXmpp::EncryptionMethod
EncryptionMethod
Definition QXmppGlobal.h:89
QXmppStanzaId
Stanza ID element as defined in XEP-0359: Unique and Stable Stanza IDs.
Definition QXmppMessage.h:51
QXmppStanzaId::by
QString by
JID of the generating entity.
Definition QXmppMessage.h:55
QXmppStanzaId::id
QString id
Identifier of the stanza element.
Definition QXmppMessage.h:53
QXmpp::Reply
Definition QXmppMessage.h:41
QXmpp::Reply::to
QString to
Definition QXmppMessage.h:44
QXmpp::Reply::id
QString id
ID of the referenced message.
Definition QXmppMessage.h:46