libQuotient
A Qt library for building matrix clients
Quotient::EventContent::FileInfo Struct Reference

Mix-in class representing info subobject in content JSON. More...

#include <eventcontent.h>

Inheritance diagram for Quotient::EventContent::FileInfo:

Public Member Functions

 FileInfo ()=default
 
 FileInfo (const QFileInfo &fi)
 Construct from a QFileInfo object. More...
 
 FileInfo (FileSourceInfo sourceInfo, qint64 payloadSize=-1, const QMimeType &mimeType={}, QString originalFilename={})
 
 FileInfo (FileSourceInfo sourceInfo, const QJsonObject &infoJson, QString originalFilename={})
 Construct from a JSON info payload. More...
 
bool isValid () const
 
QUrl url () const
 
QString mediaId () const
 Extract media id from the URL. More...
 

Public Attributes

FileSourceInfo source
 
QJsonObject originalInfoJson
 
QMimeType mimeType
 
qint64 payloadSize = 0
 
QString originalName
 

Detailed Description

Mix-in class representing info subobject in content JSON.

This is one of base classes for content types that deal with files or URLs. It stores file metadata attributes, such as size, MIME type etc. found in the content/info subobject of event JSON payloads. Actual content classes derive from this class and Base that provides a polymorphic interface to access data in the mix-in. FileInfo (as well as ImageInfo, that adds image size to the metadata) is NOT polymorphic and is used in a non-polymorphic way to store thumbnail metadata (in a separate instance), next to the metadata on the file itself.

If you need to make a new content (not info) class based on files/URLs take UrlBasedContent as the example, i.e.:

  1. Double-inherit from this class (or ImageInfo) and Base.
  2. Provide a constructor from QJsonObject that will pass the info subobject (not the whole content JSON) down to FileInfo/ImageInfo.
  3. Override fillJson() to customise the JSON export logic. Make sure to call toInfoJson() from it to produce the payload for the info subobject in the JSON payload.
See also
ImageInfo, FileContent, ImageContent, AudioContent, VideoContent, UrlBasedContent

Definition at line 87 of file eventcontent.h.

Constructor & Destructor Documentation

◆ FileInfo() [1/4]

Quotient::EventContent::FileInfo::FileInfo ( )
default

◆ FileInfo() [2/4]

Quotient::EventContent::FileInfo::FileInfo ( const QFileInfo &  fi)
explicit

Construct from a QFileInfo object.

Parameters
fia QFileInfo object referring to an existing file

◆ FileInfo() [3/4]

Quotient::EventContent::FileInfo::FileInfo ( FileSourceInfo  sourceInfo,
qint64  payloadSize = -1,
const QMimeType &  mimeType = {},
QString  originalFilename = {} 
)
explicit

◆ FileInfo() [4/4]

Quotient::EventContent::FileInfo::FileInfo ( FileSourceInfo  sourceInfo,
const QJsonObject &  infoJson,
QString  originalFilename = {} 
)

Construct from a JSON info payload.

Make sure to pass the info subobject of content JSON, not the whole JSON content.

Member Function Documentation

◆ isValid()

bool Quotient::EventContent::FileInfo::isValid ( ) const

◆ mediaId()

QString Quotient::EventContent::FileInfo::mediaId ( ) const
inline

Extract media id from the URL.

This can be used, e.g., to construct a QML-facing image:// URI as follows:

"image://provider/" + info.mediaId()

Definition at line 111 of file eventcontent.h.

◆ url()

QUrl Quotient::EventContent::FileInfo::url ( ) const

Member Data Documentation

◆ mimeType

QMimeType Quotient::EventContent::FileInfo::mimeType

Definition at line 115 of file eventcontent.h.

◆ originalInfoJson

QJsonObject Quotient::EventContent::FileInfo::originalInfoJson

Definition at line 114 of file eventcontent.h.

◆ originalName

QString Quotient::EventContent::FileInfo::originalName

Definition at line 117 of file eventcontent.h.

◆ payloadSize

qint64 Quotient::EventContent::FileInfo::payloadSize = 0

Definition at line 116 of file eventcontent.h.

◆ source

FileSourceInfo Quotient::EventContent::FileInfo::source

Definition at line 113 of file eventcontent.h.


The documentation for this struct was generated from the following file: