QXmpp  Version:1.3.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QXmppMessage Class Reference

The QXmppMessage class represents an XMPP message. More...

#include <QXmppMessage.h>

Inheritance diagram for QXmppMessage:
Inheritance graph
[legend]
Collaboration diagram for QXmppMessage:
Collaboration graph
[legend]

Public Types

enum  Type {
  Error = 0, Normal, Chat, GroupChat,
  Headline
}
 This enum describes a message type.
 
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 }
 
enum  EncryptionMethod {
  NoEncryption, UnknownEncryption, OTR, LegacyOpenPGP,
  OX, OMEMO
}
 

Public Member Functions

 QXmppMessage (const QString &from=QString(), const QString &to=QString(), const QString &body=QString(), const QString &thread=QString())
 
 QXmppMessage (const QXmppMessage &other)
 Constructs a copy of other.
 
QXmppMessageoperator= (const QXmppMessage &other)
 Assigns other to this message.
 
bool isXmppStanza () const override
 
QString body () const
 Returns the message's body.
 
void setBody (const QString &)
 
QString subject () const
 Returns the message's subject.
 
void setSubject (const QString &)
 
QString thread () const
 Returns the message's thread.
 
void setThread (const QString &)
 
QString parentThread () const
 
void setParentThread (const QString &)
 
QXmppMessage::Type type () const
 Returns the message's type.
 
void setType (QXmppMessage::Type)
 
QString outOfBandUrl () const
 
void setOutOfBandUrl (const QString &)
 
QString xhtml () const
 
void setXhtml (const QString &xhtml)
 
QXmppMessage::State state () const
 
void setState (QXmppMessage::State)
 
QDateTime stamp () const
 
void setStamp (const QDateTime &stamp)
 
bool isReceiptRequested () const
 
void setReceiptRequested (bool requested)
 
QString receiptId () const
 
void setReceiptId (const QString &id)
 
bool isAttentionRequested () const
 
void setAttentionRequested (bool requested)
 
QXmppBitsOfBinaryDataList bitsOfBinaryData () const
 
QXmppBitsOfBinaryDataListbitsOfBinaryData ()
 
void setBitsOfBinaryData (const QXmppBitsOfBinaryDataList &bitsOfBinaryData)
 
bool isSlashMeCommand () const
 
QString slashMeCommandText () const
 
QString mucInvitationJid () const
 
void setMucInvitationJid (const QString &jid)
 
QString mucInvitationPassword () const
 
void setMucInvitationPassword (const QString &password)
 
QString mucInvitationReason () const
 
void setMucInvitationReason (const QString &reason)
 
bool isPrivate () const
 
void setPrivate (const bool)
 
QString replaceId () const
 
void setReplaceId (const QString &)
 
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)
 
bool hasHint (const Hint hint) const
 
void addHint (const Hint hint)
 
void removeHint (const Hint hint)
 
void removeAllHints ()
 
QString stanzaId () const
 
void setStanzaId (const QString &id)
 
QString stanzaIdBy () const
 
void setStanzaIdBy (const QString &id)
 
QString originId () const
 
void setOriginId (const QString &id)
 
QString attachId () const
 
void setAttachId (const QString &)
 
QString mixUserJid () const
 
void setMixUserJid (const QString &)
 
QString mixUserNick () const
 
void setMixUserNick (const QString &)
 
EncryptionMethod encryptionMethod () const
 
void setEncryptionMethod (EncryptionMethod)
 
QString encryptionMethodNs () const
 
void setEncryptionMethodNs (const QString &)
 
QString encryptionName () const
 
void setEncryptionName (const QString &)
 
bool isSpoiler () const
 
void setIsSpoiler (bool)
 
QString spoilerHint () const
 
void setSpoilerHint (const QString &)
 
bool isFallback () const
 
void setIsFallback (bool isFallback)
 
- Public Member Functions inherited from QXmppStanza
 QXmppStanza (const QString &from=QString(), const QString &to=QString())
 
 QXmppStanza (const QXmppStanza &other)
 Constructs a copy of other.
 
virtual ~QXmppStanza ()
 Destroys a QXmppStanza.
 
QXmppStanzaoperator= (const QXmppStanza &other)
 Assigns other to this stanza.
 
QString to () const
 
void setTo (const QString &)
 
QString from () const
 Returns the stanza's sender JID.
 
void setFrom (const QString &)
 
QString id () const
 Returns the stanza's identifier.
 
void setId (const QString &)
 
QString lang () const
 Returns the stanza's language.
 
void setLang (const QString &)
 
QXmppStanza::Error error () const
 Returns the stanza's error.
 
void setError (const QXmppStanza::Error &error)
 
QXmppElementList extensions () const
 
void setExtensions (const QXmppElementList &elements)
 
QList< QXmppExtendedAddressextendedAddresses () const
 
void setExtendedAddresses (const QList< QXmppExtendedAddress > &extendedAddresses)
 

Static Public Member Functions

static bool isSlashMeCommand (const QString &body)
 
static QString slashMeCommandText (const QString &body)
 

Detailed Description

The QXmppMessage class represents an XMPP message.

Member Enumeration Documentation

◆ EncryptionMethod

This enum describes different end-to-end encryption methods. These can be used to mark a message explicitly as encrypted with a specific algothim. See XEP-0380: Explicit Message Encryption for details.

Since
QXmpp 1.1
Enumerator
NoEncryption 

No encryption.

UnknownEncryption 

Unknown encryption.

OTR 

XEP-0364: Current Off-the-Record Messaging Usage

LegacyOpenPGP 

XEP-0027: Current Jabber OpenPGP Usage

OX 

XEP-0373: OpenPGP for XMPP

OMEMO 

XEP-0384: OMEMO Encryption

◆ Hint

XEP-0334: Message Processing Hints

Since
QXmpp 1.1
Enumerator
NoPermanentStore 

Do not allow permanent storage.

NoStore 

Do not store at all.

NoCopy 

Do not copy the message.

Store 

Do store the message.

◆ Marker

This enum describes a chat marker as defined by XEP-0333: Chat Markers.

Since
QXmpp 0.8.1

◆ State

This enum describes a chat state as defined by XEP-0085: Chat State Notifications.

Since
QXmpp 0.2
Enumerator
None 

The message does not contain any chat state information.

Active 

User is actively participating in the chat session.

Inactive 

User has not been actively participating in the chat session.

Gone 

User has effectively ended their participation in the chat session.

Composing 

User is composing a message.

Paused 

User had been composing but now has stopped.

Constructor & Destructor Documentation

◆ QXmppMessage()

QXmppMessage::QXmppMessage ( const QString &  from = QString(),
const QString &  to = QString(),
const QString &  body = QString(),
const QString &  thread = QString() 
)

Constructs a QXmppMessage.

Parameters
from
to
body
thread

Member Function Documentation

◆ addHint()

void QXmppMessage::addHint ( const Hint  hint)

Adds a hint to the message, as defined in XEP-0334: Message Processing Hints

Since
QXmpp 1.1

◆ attachId()

QString QXmppMessage::attachId ( ) const

Returns the message id this message is linked/attached to. See XEP-0367: Message Attaching for details.

Since
QXmpp 1.1

◆ bitsOfBinaryData() [1/2]

QXmppBitsOfBinaryDataList & QXmppMessage::bitsOfBinaryData ( )

Returns a list of data attached using XEP-0231: Bits of Binary.

This could be used to resolve cid: URIs found in the X-HTML body.

Since
QXmpp 1.2

◆ bitsOfBinaryData() [2/2]

QXmppBitsOfBinaryDataList QXmppMessage::bitsOfBinaryData ( ) const

Returns a list of data packages attached using XEP-0231: Bits of Binary.

This could be used to resolve cid: URIs found in the X-HTML body.

Since
QXmpp 1.2

◆ encryptionMethod()

QXmppMessage::EncryptionMethod QXmppMessage::encryptionMethod ( ) const

Returns the encryption method this message is advertised to be encrypted with.

Note
QXmppMessage::NoEncryption does not necesserily mean that the message is not encrypted; it may also be that the author of the message does not support XEP-0380: Explicit Message Encryption.
If this returns QXmppMessage::UnknownEncryption, you can still get the namespace of the encryption with encryptionMethodNs() and possibly also a name with encryptionName().
Since
QXmpp 1.1

◆ encryptionMethodNs()

QString QXmppMessage::encryptionMethodNs ( ) const

Returns the namespace of the advertised encryption method via. XEP-0380: Explicit Message Encryption.

Since
QXmpp 1.1

◆ encryptionName()

QString QXmppMessage::encryptionName ( ) const

Returns the associated name of the encryption method this message advertises to be encrypted with. See XEP-0380: Explicit Message Encryption for details.

Since
QXmpp 1.1

◆ hasHint()

bool QXmppMessage::hasHint ( const Hint  hint) const

Returns true if the message contains the hint passed, as defined in XEP-0334: Message Processing Hints

Since
QXmpp 1.1

◆ isAttentionRequested()

bool QXmppMessage::isAttentionRequested ( ) const

Returns true if the user's attention is requested, as defined by XEP-0224: Attention.

Since
QXmpp 0.4

◆ isFallback()

bool QXmppMessage::isFallback ( ) const

Sets whether this message is only a fallback according to XEP-0428: Fallback Indication.

This is useful for clients not supporting end-to-end encryption to indicate that the message body does not contain the intended text of the author.

Since
QXmpp 1.3

◆ isMarkable()

bool QXmppMessage::isMarkable ( ) const

Returns true if a message is markable, as defined by XEP-0333: Chat Markers.

Since
QXmpp 0.8.1

◆ isPrivate()

bool QXmppMessage::isPrivate ( ) const

Returns if the message is marked with a <private/> tag, in which case it will not be forwarded to other resources according to XEP-0280: Message Carbons.

Since
QXmpp 1.0

◆ isReceiptRequested()

bool QXmppMessage::isReceiptRequested ( ) const

Returns true if a delivery receipt is requested, as defined by XEP-0184: Message Delivery Receipts.

Since
QXmpp 0.4

◆ isSlashMeCommand() [1/2]

bool QXmppMessage::isSlashMeCommand ( ) const

Returns whether the body of the message is a '/me command' as defined in XEP-0245: The /me Command.

Note
If you want to check a custom string for the /me command, you can use the static version of this method. This can be helpful when checking user input before a message was sent.
Since
QXmpp 1.3

◆ isSlashMeCommand() [2/2]

bool QXmppMessage::isSlashMeCommand ( const QString &  body)
static

Returns whether the given text is a '/me command' as defined in XEP-0245: The /me Command.

Since
QXmpp 1.3

◆ isSpoiler()

bool QXmppMessage::isSpoiler ( ) const

Returns true, if this is a spoiler message according to XEP-0382: Spoiler messages. The spoiler hint however can still be empty.

A spoiler message's content should not be visible to the user by default.

Since
QXmpp 1.1

◆ isXmppStanza()

bool QXmppMessage::isXmppStanza ( ) const
overridevirtual

Indicates if the QXmppStanza is a stanza in the XMPP sense (i. e. a message, iq or presence)

Since
QXmpp 1.0

Reimplemented from QXmppStanza.

◆ markedId()

QString QXmppMessage::markedId ( ) const

Returns the message's marker id, as defined by XEP-0333: Chat Markers.

Since
QXmpp 0.8.1

◆ markedThread()

QString QXmppMessage::markedThread ( ) const

Returns the message's marker thread, as defined by XEP-0333: Chat Markers.

Since
QXmpp 0.8.1

◆ marker()

QXmppMessage::Marker QXmppMessage::marker ( ) const

Returns the message's marker, as defined by XEP-0333: Chat Markers.

Since
QXmpp 0.8.1

◆ mixUserJid()

QString QXmppMessage::mixUserJid ( ) const

Returns the actual JID of a MIX channel participant.

Since
QXmpp 1.1

◆ mixUserNick()

QString QXmppMessage::mixUserNick ( ) const

Returns the MIX participant's nickname.

Since
QXmpp 1.1

◆ mucInvitationJid()

QString QXmppMessage::mucInvitationJid ( ) const

Returns the JID for a multi-user chat direct invitation as defined by XEP-0249: Direct MUC Invitations.

Since
QXmpp 0.7.4

◆ mucInvitationPassword()

QString QXmppMessage::mucInvitationPassword ( ) const

Returns the password for a multi-user chat direct invitation as defined by XEP-0249: Direct MUC Invitations.

Since
QXmpp 0.7.4

◆ mucInvitationReason()

QString QXmppMessage::mucInvitationReason ( ) const

Returns the reason for a multi-user chat direct invitation as defined by XEP-0249: Direct MUC Invitations.

Since
QXmpp 0.7.4

◆ originId()

QString QXmppMessage::originId ( ) const

Returns the origin ID of the message according to XEP-0359: Unique and Stable Stanza IDs.

Since
QXmpp 1.3

◆ outOfBandUrl()

QString QXmppMessage::outOfBandUrl ( ) const

Returns a possibly attached URL from XEP-0066: Out of Band Data

Since
QXmpp 1.0

◆ parentThread()

QString QXmppMessage::parentThread ( ) const

Returns the optional parent thread of this message.

The possibility to create child threads was added in RFC6121.

Since
QXmpp 1.3

◆ receiptId()

QString QXmppMessage::receiptId ( ) const

If this message is a delivery receipt, returns the ID of the original message.

Since
QXmpp 0.4

◆ removeAllHints()

void QXmppMessage::removeAllHints ( )

Removes all hints from the message, as defined in XEP-0334: Message Processing Hints

Since
QXmpp 1.1

◆ removeHint()

void QXmppMessage::removeHint ( const Hint  hint)

Removes a hint from the message, as defined in XEP-0334: Message Processing Hints

Since
QXmpp 1.1

◆ replaceId()

QString QXmppMessage::replaceId ( ) const

Returns the message id to replace with this message as used in XEP-0308: Last Message Correction. If the returned string is empty, this message is not replacing another.

Since
QXmpp 1.0

◆ setAttachId()

void QXmppMessage::setAttachId ( const QString &  attachId)

Sets the id of the attached message as in XEP-0367: Message Attaching. This can be used for a "reply to" or "reaction" function.

The used message id depends on the message context, see the Business rules section of the XEP for details about when to use which id.

Since
QXmpp 1.1

◆ setAttentionRequested()

void QXmppMessage::setAttentionRequested ( bool  requested)

Sets whether the user's attention is requested, as defined by XEP-0224: Attention.

Parameters
requestedWhether to request attention (true) or not (false)
Since
QXmpp 0.4

◆ setBitsOfBinaryData()

void QXmppMessage::setBitsOfBinaryData ( const QXmppBitsOfBinaryDataList bitsOfBinaryData)

Sets a list of XEP-0231: Bits of Binary attachments to be included.

Since
QXmpp 1.2

◆ setBody()

void QXmppMessage::setBody ( const QString &  body)

Sets the message's body.

Parameters
body

◆ setEncryptionMethod()

void QXmppMessage::setEncryptionMethod ( QXmppMessage::EncryptionMethod  method)

Advertises that this message is encrypted with the given encryption method. See XEP-0380: Explicit Message Encryption for details.

Since
QXmpp 1.1

◆ setEncryptionMethodNs()

void QXmppMessage::setEncryptionMethodNs ( const QString &  encryptionMethod)

Sets the namespace of the encryption method this message advertises to be encrypted with. See XEP-0380: Explicit Message Encryption for details.

Since
QXmpp 1.1

◆ setEncryptionName()

void QXmppMessage::setEncryptionName ( const QString &  encryptionName)

Sets the name of the encryption method for XEP-0380: Explicit Message Encryption.

Note
This should only be used, if the encryption method is custom and is not one of the methods listed in the XEP.
Since
QXmpp 1.1

◆ setIsFallback()

void QXmppMessage::setIsFallback ( bool  isFallback)

Sets whether this message is only a fallback according to XEP-0428: Fallback Indication.

This is useful for clients not supporting end-to-end encryption to indicate that the message body does not contain the intended text of the author.

Since
QXmpp 1.3

◆ setIsSpoiler()

void QXmppMessage::setIsSpoiler ( bool  isSpoiler)

Sets whether this is a spoiler message as specified in XEP-0382: Spoiler messages.

The content of spoiler messages will not be displayed by default to the user. However, clients not supporting spoiler messages will still display the content as usual.

Since
QXmpp 1.1

◆ setMarkable()

void QXmppMessage::setMarkable ( const bool  markable)

Sets if the message is markable, as defined by XEP-0333: Chat Markers.

Since
QXmpp 0.8.1

◆ setMarkedThread()

void QXmppMessage::setMarkedThread ( const QString &  markedThread)

Sets the message's marked thread, as defined by XEP-0333: Chat Markers.

Since
QXmpp 0.8.1

◆ setMarker()

void QXmppMessage::setMarker ( const Marker  marker)

Sets the message's marker, as defined by XEP-0333: Chat Markers

Since
QXmpp 0.8.1

◆ setMarkerId()

void QXmppMessage::setMarkerId ( const QString &  markerId)

Sets the message's marker id, as defined by XEP-0333: Chat Markers.

Since
QXmpp 0.8.1

◆ setMixUserJid()

void QXmppMessage::setMixUserJid ( const QString &  mixUserJid)

Sets the actual JID of a MIX channel participant.

Since
QXmpp 1.1

◆ setMixUserNick()

void QXmppMessage::setMixUserNick ( const QString &  mixUserNick)

Sets the MIX participant's nickname.

Since
QXmpp 1.1

◆ setMucInvitationJid()

void QXmppMessage::setMucInvitationJid ( const QString &  jid)

Sets the JID for a multi-user chat direct invitation as defined by XEP-0249: Direct MUC Invitations.

Since
QXmpp 0.7.4

◆ setMucInvitationPassword()

void QXmppMessage::setMucInvitationPassword ( const QString &  password)

Sets the password for a multi-user chat direct invitation as defined by XEP-0249: Direct MUC Invitations.

Since
QXmpp 0.7.4

◆ setMucInvitationReason()

void QXmppMessage::setMucInvitationReason ( const QString &  reason)

Sets the reason for a multi-user chat direct invitation as defined by XEP-0249: Direct MUC Invitations.

Since
QXmpp 0.7.4

◆ setOriginId()

void QXmppMessage::setOriginId ( const QString &  id)

Sets the origin ID of the message according to XEP-0359: Unique and Stable Stanza IDs.

Since
QXmpp 1.3

◆ setOutOfBandUrl()

void QXmppMessage::setOutOfBandUrl ( const QString &  url)

Sets the attached URL for XEP-0066: Out of Band Data

Since
QXmpp 1.0

◆ setParentThread()

void QXmppMessage::setParentThread ( const QString &  parent)

Sets the optional parent thread of this message.

The possibility to create child threads was added in RFC6121.

Since
QXmpp 1.3

◆ setPrivate()

void QXmppMessage::setPrivate ( const bool  priv)

If true is passed, the message is marked with a <private/> tag, in which case it will not be forwarded to other resources according to XEP-0280: Message Carbons.

Since
QXmpp 1.0

◆ setReceiptId()

void QXmppMessage::setReceiptId ( const QString &  id)

Make this message a delivery receipt for the message with the given id.

Since
QXmpp 0.4

◆ setReceiptRequested()

void QXmppMessage::setReceiptRequested ( bool  requested)

Sets whether a delivery receipt is requested, as defined by XEP-0184: Message Delivery Receipts.

Since
QXmpp 0.4

◆ setReplaceId()

void QXmppMessage::setReplaceId ( const QString &  replaceId)

Sets the message id to replace with this message as in XEP-0308: Last Message Correction.

Since
QXmpp 1.0

◆ setSpoilerHint()

void QXmppMessage::setSpoilerHint ( const QString &  spoilerHint)

Sets a spoiler hint for XEP-0382: Spoiler messages. If the spoiler hint is not empty, isSpoiler will be set to true.

A spoiler hint is optional for spoiler messages.

Keep in mind that the spoiler hint is not displayed at all by clients not supporting spoiler messages.

Since
QXmpp 1.1

◆ setStamp()

void QXmppMessage::setStamp ( const QDateTime &  stamp)

Sets the message's timestamp without modifying the type of the stamp (XEP-0093: Legacy Delayed Delivery or XEP-0203: Delayed Delivery).

By default messages are constructed with the new delayed delivery XEP, but parsed messages keep their type.

Since
QXmpp 0.2

◆ setStanzaId()

void QXmppMessage::setStanzaId ( const QString &  id)

Sets the stanza ID of the message according to XEP-0359: Unique and Stable Stanza IDs.

Since
QXmpp 1.3

◆ setStanzaIdBy()

void QXmppMessage::setStanzaIdBy ( const QString &  by)

Sets the creator of the stanza ID according to XEP-0359: Unique and Stable Stanza IDs.

Since
QXmpp 1.3

◆ setState()

void QXmppMessage::setState ( QXmppMessage::State  state)

Sets the the chat state notification according to XEP-0085: Chat State Notifications.

Since
QXmpp 0.2

◆ setSubject()

void QXmppMessage::setSubject ( const QString &  subject)

Sets the message's subject.

Parameters
subject

◆ setThread()

void QXmppMessage::setThread ( const QString &  thread)

Sets the message's thread.

Parameters
thread

◆ setType()

void QXmppMessage::setType ( QXmppMessage::Type  type)

Sets the message's type.

Parameters
type

◆ setXhtml()

void QXmppMessage::setXhtml ( const QString &  xhtml)

Sets the message's XHTML body as defined by XEP-0071: XHTML-IM.

Since
QXmpp 0.6.2

◆ slashMeCommandText() [1/2]

QString QXmppMessage::slashMeCommandText ( ) const

Returns the part of the body after the /me command.

This cuts off '/me ' (with the space) from the body, in case the body starts with that. In case the body does not contain a /me command as defined in XEP-0245: The /me Command, a null string is returned.

This is useful when displaying the /me command correctly to the user.

Since
QXmpp 1.3

◆ slashMeCommandText() [2/2]

QString QXmppMessage::slashMeCommandText ( const QString &  body)
static

Returns the part of the body after the /me command.

This cuts off '/me ' (with the space) from the body, in case the body starts with that. In case the body does not contain a /me command as defined in XEP-0245: The /me Command, a null string is returned.

This is useful when displaying the /me command correctly to the user.

Since
QXmpp 1.3

◆ spoilerHint()

QString QXmppMessage::spoilerHint ( ) const

Returns the spoiler hint as specified in XEP-0382: Spoiler messages.

The hint may be empty, even if isSpoiler is true.

Since
QXmpp 1.1

◆ stamp()

QDateTime QXmppMessage::stamp ( ) const

Returns the optional timestamp of the message specified using XEP-0093: Legacy Delayed Delivery or using XEP-0203: Delayed Delivery (preferred).

Since
QXmpp 0.2

◆ stanzaId()

QString QXmppMessage::stanzaId ( ) const

Returns the stanza ID of the message according to XEP-0359: Unique and Stable Stanza IDs.

Since
QXmpp 1.3

◆ stanzaIdBy()

QString QXmppMessage::stanzaIdBy ( ) const

Returns the creator of the stanza ID according to XEP-0359: Unique and Stable Stanza IDs.

Since
QXmpp 1.3

◆ state()

QXmppMessage::State QXmppMessage::state ( ) const

Returns the the chat state notification according to XEP-0085: Chat State Notifications.

Since
QXmpp 0.2

◆ xhtml()

QString QXmppMessage::xhtml ( ) const

Returns the message's XHTML body as defined by XEP-0071: XHTML-IM.

Since
QXmpp 0.6.2

The documentation for this class was generated from the following files: