libQuotient
A Qt library for building matrix clients
|
#include <roommessageevent.h>
Public Types | |
enum class | MsgType { Text , Emote , Notice , Image , File , Location , Video , Audio , Unknown } |
Public Member Functions | |
RoomMessageEvent (const QString &plainBody, const QString &jsonMsgType, std::unique_ptr< EventContent::Base > content=nullptr, const std::optional< EventRelation > &relatesTo=std::nullopt) | |
RoomMessageEvent (const QString &plainBody, MsgType msgType=MsgType::Text, std::unique_ptr< EventContent::Base > content=nullptr, const std::optional< EventRelation > &relatesTo=std::nullopt) | |
RoomMessageEvent (const QJsonObject &obj) | |
MsgType | msgtype () const |
QString | rawMsgtype () const |
QString | plainBody () const |
std::unique_ptr< EventContent::Base > | content () const |
Load event content from the event JSON. More... | |
void | setContent (std::unique_ptr< EventContent::Base > content) |
Update the message JSON with the given content. More... | |
template<std::derived_from< EventContent::Base > ContentT> | |
bool | has () const |
Determine whether the message has content/attachment of a specified type. More... | |
template<std::derived_from< EventContent::Base > ContentT> | |
std::unique_ptr< ContentT > | get () const |
Get the message content and try to cast it to the specified type. More... | |
QMimeType | mimeType () const |
bool | hasThumbnail () const |
Determine whether the message has a thumbnail. More... | |
EventContent::Thumbnail | getThumbnail () const |
Retrieve a thumbnail from the message event. More... | |
std::optional< EventRelation > | relatesTo () const |
The EventRelation for this event. More... | |
QString | upstreamEventId () const |
The upstream event ID for the relation. More... | |
QString | replacedEvent () const |
Obtain id of an event replaced by the current one. More... | |
bool | isReplaced () const |
Determine whether the event has been replaced. More... | |
QString | replacedBy () const |
bool | isReply (bool includeFallbacks=false) const |
Determine whether the event is a reply to another message. More... | |
QString | replyEventId (bool includeFallbacks=false) const |
The ID for the event being replied to. More... | |
bool | isThreaded () const |
Determine whether the event is part of a thread. More... | |
QString | threadRootEventId () const |
The event ID for the thread root event. More... | |
QString | fileNameToDownload () const |
void | updateFileSourceInfo (const FileSourceInfo &fsi) |
Public Member Functions inherited from Quotient::RoomEvent | |
~RoomEvent () override | |
QString | displayId () const |
A convenience function to get a display string for an event ID. More... | |
QString | id () const |
The event_id JSON value for the event. More... | |
QDateTime | originTimestamp () const |
QString | roomId () const |
QString | senderId () const |
bool | isRedacted () const |
const event_ptr_tt< RedactionEvent > & | redactedBecause () const |
QString | redactionReason () const |
QString | transactionId () const |
The transaction_id JSON value for the event. More... | |
bool | isStateEvent () const |
QString | stateKey () const |
void | setRoomId (const QString &roomId) |
Fill the pending event object with the room id. More... | |
void | setSender (const QString &senderId) |
Fill the pending event object with the sender id. More... | |
void | setTransactionId (const QString &txnId) |
Fill the pending event object with the transaction id. More... | |
void | addId (const QString &newId) |
Add an event id to locally created events after they are sent. More... | |
void | setOriginalEvent (event_ptr_tt< EncryptedEvent > &&originalEvent) |
const EncryptedEvent * | originalEvent () const |
const QJsonObject | encryptedJson () const |
Public Member Functions inherited from Quotient::Event | |
virtual const AbstractEventMetaType & | metaType () const |
Event (Event &&) noexcept=default | |
Event & | operator= (Event &&)=delete |
virtual | ~Event () |
QString | matrixType () const |
Exact Matrix type stored in JSON. More... | |
template<EventClass EventT> | |
bool | is () const |
template<typename... VisitorTs> | |
auto | switchOnType (VisitorTs &&... visitors) const |
Apply one of the visitors based on the actual event type. More... | |
const QJsonObject & | fullJson () const |
const QJsonObject | contentJson () const |
template<typename T , typename KeyT > | |
const T | contentPart (KeyT &&key) const |
Get a part of the content object, assuming a given type. More... | |
const QJsonObject | unsignedJson () const |
template<typename T , typename KeyT > | |
const T | unsignedPart (KeyT &&key) const |
Get a part of the unsigned object, assuming a given type. More... | |
bool | isStateEvent () const |
Static Public Member Functions | |
static QString | rawMsgTypeForUrl (const QUrl &url) |
static QString | rawMsgTypeForFile (const QFileInfo &fi) |
Static Public Member Functions inherited from Quotient::Event | |
static QJsonObject | basicJson (const QString &matrixType, const QJsonObject &content) |
Make a minimal correct Matrix event JSON. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from Quotient::Event | |
static EventMetaType< Event > | BaseMetaType { "Event" } |
Protected Member Functions inherited from Quotient::RoomEvent | |
RoomEvent (const QJsonObject &json) | |
void | dumpTo (QDebug dbg) const override |
Protected Member Functions inherited from Quotient::Event | |
Event (const QJsonObject &json) | |
QJsonObject & | editJson () |
The event class corresponding to m.room.message events
Definition at line 19 of file roommessageevent.h.
|
strong |
Enumerator | |
---|---|
Text | |
Emote | |
Notice | |
Image | |
File | |
Location | |
Video | |
Audio | |
Unknown |
Definition at line 24 of file roommessageevent.h.
Quotient::RoomMessageEvent::RoomMessageEvent | ( | const QString & | plainBody, |
const QString & | jsonMsgType, | ||
std::unique_ptr< EventContent::Base > | content = nullptr , |
||
const std::optional< EventRelation > & | relatesTo = std::nullopt |
||
) |
|
explicit |
|
explicit |
std::unique_ptr<EventContent::Base> Quotient::RoomMessageEvent::content | ( | ) | const |
Load event content from the event JSON.
std::unique_ptr<>
because the deserialised content object is no more stored inside the event. The calling code must either store the entire returned value in a variable or copy/move away the needed field from the returned value; a reference or a pointer to a field will become dangling at the statement end.QString Quotient::RoomMessageEvent::fileNameToDownload | ( | ) | const |
|
inline |
Get the message content and try to cast it to the specified type.
Definition at line 77 of file roommessageevent.h.
EventContent::Thumbnail Quotient::RoomMessageEvent::getThumbnail | ( | ) | const |
Retrieve a thumbnail from the message event.
|
inline |
Determine whether the message has content/attachment of a specified type.
ContentT
(e.g. m.file
or m.audio
for FileContent); false otherwise Definition at line 70 of file roommessageevent.h.
bool Quotient::RoomMessageEvent::hasThumbnail | ( | ) | const |
Determine whether the message has a thumbnail.
bool Quotient::RoomMessageEvent::isReplaced | ( | ) | const |
Determine whether the event has been replaced.
"rel_type": "m.replace"
; false otherwise bool Quotient::RoomMessageEvent::isReply | ( | bool | includeFallbacks = false | ) | const |
Determine whether the event is a reply to another message.
includeFallbacks | include thread fallback replies for non-threaded clients. |
"m.in_reply_to"
event ID and is not a thread fallback (except where includeFallbacks
is true); false otherwise."rel_type"
of "m.thread"
if "is_falling_back"
is false. bool Quotient::RoomMessageEvent::isThreaded | ( | ) | const |
Determine whether the event is part of a thread.
"rel_type": "m.thread"
or "m.relations": { "m.thread": {}}
; false otherwise. QMimeType Quotient::RoomMessageEvent::mimeType | ( | ) | const |
MsgType Quotient::RoomMessageEvent::msgtype | ( | ) | const |
QString Quotient::RoomMessageEvent::plainBody | ( | ) | const |
QString Quotient::RoomMessageEvent::rawMsgtype | ( | ) | const |
|
static |
|
static |
std::optional<EventRelation> Quotient::RoomMessageEvent::relatesTo | ( | ) | const |
The EventRelation for this event.
QString Quotient::RoomMessageEvent::replacedBy | ( | ) | const |
QString Quotient::RoomMessageEvent::replacedEvent | ( | ) | const |
Obtain id of an event replaced by the current one.
QString Quotient::RoomMessageEvent::replyEventId | ( | bool | includeFallbacks = false | ) | const |
The ID for the event being replied to.
includeFallbacks | include thread fallback replies for non-threaded clients. |
"rel_type"
is "m.thread"
and "is_falling_back"
is false (except where includeFallbacks
is true). void Quotient::RoomMessageEvent::setContent | ( | std::unique_ptr< EventContent::Base > | content | ) |
Update the message JSON with the given content.
QString Quotient::RoomMessageEvent::threadRootEventId | ( | ) | const |
The event ID for the thread root event.
void Quotient::RoomMessageEvent::updateFileSourceInfo | ( | const FileSourceInfo & | fsi | ) |
QString Quotient::RoomMessageEvent::upstreamEventId | ( | ) | const |
The upstream event ID for the relation.