libQuotient
A Qt library for building matrix clients
Quotient::Connection Class Reference

#include <connection.h>

Inheritance diagram for Quotient::Connection:
Collaboration diagram for Quotient::Connection:

Classes

struct  SupportedRoomVersion
 

Public Types

enum  RoomVisibility { PublishRoom , UnpublishRoom }
 
using UsersToDevicesToContent = QHash< QString, QHash< QString, QJsonObject > >
 

Public Slots

void loginWithPassword (const QString &userId, const QString &password, const QString &initialDeviceName, const QString &deviceId={})
 Log in using a username and password pair. More...
 
void loginWithToken (const QString &loginToken, const QString &initialDeviceName, const QString &deviceId={})
 Log in using a login token. More...
 
void assumeIdentity (const QString &mxId, const QString &deviceId, const QString &accessToken)
 Use an existing access token to connect to the homeserver. More...
 
JobHandle< GetVersionsJobloadVersions ()
 Request supported spec versions from the homeserver. More...
 
JobHandle< GetCapabilitiesJobloadCapabilities ()
 Request capabilities and room versions from the server. More...
 
void reloadCapabilities ()
 
QFuture< void > logout ()
 
void sync (int timeout=-1)
 
void syncLoop (int timeout=30000)
 
void stopSync ()
 
virtual MediaThumbnailJobgetThumbnail (const QString &mediaId, QSize requestedSize, RunningPolicy policy=BackgroundRequest)
 
MediaThumbnailJobgetThumbnail (const QUrl &url, QSize requestedSize, RunningPolicy policy=BackgroundRequest)
 
MediaThumbnailJobgetThumbnail (const QUrl &url, int requestedWidth, int requestedHeight, RunningPolicy policy=BackgroundRequest)
 
JobHandle< UploadContentJobuploadContent (QIODevice *contentSource, const QString &filename={}, const QString &overrideContentType={})
 
JobHandle< UploadContentJobuploadFile (const QString &fileName, const QString &overrideContentType={})
 
BaseJobgetContent (const QString &mediaId)
 
BaseJobgetContent (const QUrl &url)
 
DownloadFileJobdownloadFile (const QUrl &url, const QString &localFilename={})
 
DownloadFileJobdownloadFile (const QUrl &url, const EncryptedFileMetadata &fileMetadata, const QString &localFilename={})
 
JobHandle< CreateRoomJobcreateRoom (RoomVisibility visibility, const QString &alias, const QString &name, const QString &topic, QStringList invites, const QString &presetName={}, const QString &roomVersion={}, bool isDirect=false, const QVector< CreateRoomJob::StateEvent > &initialState={}, const QVector< CreateRoomJob::Invite3pid > &invite3pids={}, const QJsonObject &creationContent={})
 Create a room (generic method) More...
 
void requestDirectChat (const QString &userId)
 Get a direct chat with a single user. More...
 
ForgetRoomJobforgetRoom (const QString &id)
 Send /forget to the server and delete room locally. More...
 
SendToDeviceJobsendToDevices (const QString &eventType, const UsersToDevicesToContent &contents)
 
SendMessageJobsendMessage (const QString &roomId, const RoomEvent &event)
 
virtual LeaveRoomJobleaveRoom (Room *room)
 
Quotient::KeyVerificationSessionstartKeyVerificationSession (const QString &userId, const QString &deviceId)
 
Q_INVOKABLE void startSelfVerification ()
 
void encryptionUpdate (const Room *room, const QStringList &invitedIds={})
 
static ConnectionmakeMockConnection (const QString &mxId, bool enableEncryption=true)
 

Signals

void resolveError (QString error)
 Initial server resolution has failed. More...
 
void homeserverChanged (QUrl baseUrl)
 
void loginFlowsChanged ()
 
void capabilitiesLoaded ()
 
void connected ()
 
void loggedOut ()
 
void stateChanged ()
 Login data or state have changed. More...
 
void isOnlineChanged ()
 The online state has changed. More...
 
void loginError (QString message, QString details)
 
void requestFailed (Quotient::BaseJob *request)
 A network request (job) started by callApi() has failed. More...
 
void networkError (QString message, QString details, int retriesTaken, int nextRetryInMilliseconds)
 A network request (job) failed due to network problems. More...
 
void syncDone ()
 
void syncError (QString message, QString details)
 
void newUser (Quotient::User *user)
 
void newRoom (Quotient::Room *room)
 A new room object has been created. More...
 
void invitedRoom (Quotient::Room *room, Quotient::Room *prev)
 A room invitation is seen for the first time. More...
 
void joinedRoom (Quotient::Room *room, Quotient::Room *prev)
 A joined room is seen for the first time. More...
 
void leftRoom (Quotient::Room *room, Quotient::Room *prev)
 A room has just been left. More...
 
void aboutToDeleteRoom (Quotient::Room *room)
 The room object is about to be deleted. More...
 
void createdRoom (Quotient::Room *room)
 The room has just been created by createRoom or requestDirectChat. More...
 
void loadedRoomState (Quotient::Room *room)
 The first sync for the room has been completed. More...
 
void accountDataChanged (QString type)
 Account data (except direct chats) have changed. More...
 
void directChatAvailable (Quotient::Room *directChat)
 The direct chat room is ready for using. More...
 
void directChatsListChanged (Quotient::DirectChatsMap additions, Quotient::DirectChatsMap removals)
 The list of direct chats has changed. More...
 
void ignoredUsersListChanged (Quotient::IgnoredUsersList additions, Quotient::IgnoredUsersList removals)
 
void cacheStateChanged ()
 
void lazyLoadingChanged ()
 
void turnServersChanged (const QJsonObject &servers)
 
void devicesListLoaded ()
 
void encryptionChanged (bool enabled)
 Encryption has been enabled or disabled. More...
 
void directChatsEncryptionChanged (bool enabled)
 
void newKeyVerificationSession (Quotient::KeyVerificationSession *session)
 
void keyVerificationStateChanged (const Quotient::KeyVerificationSession *session, Quotient::KeyVerificationSession::State state)
 
void sessionVerified (const QString &userId, const QString &deviceId)
 
void finishedQueryingKeys ()
 
void secretReceived (const QString &requestId, const QString &secret)
 
void userVerified (const QString &userId)
 
void crossSigningSetupRequired ()
 
void ready ()
 

Public Member Functions

 Connection (QObject *parent=nullptr)
 
 Connection (const QUrl &server, QObject *parent=nullptr)
 
 ~Connection () override
 
Q_INVOKABLE QVector< Quotient::Room * > allRooms () const
 Get all rooms known within this Connection. More...
 
Q_INVOKABLE QVector< Quotient::Room * > rooms (Quotient::JoinStates joinStates) const
 Get rooms that have either of the given join state(s) More...
 
Q_INVOKABLE int roomsCount (Quotient::JoinStates joinStates) const
 Get the total number of rooms in the given join state(s) More...
 
bool hasAccountData (const QString &type) const
 Check whether the account has data of the given type. More...
 
const EventPtraccountData (const QString &type) const
 Get a generic account data event of the given type. More...
 
template<EventClass EventT>
const EventT * accountData () const
 Get an account data event of the given type. More...
 
template<EventClass EventT>
const EventT * accountData (const QString &keyName) const
 
Q_INVOKABLE QJsonObject accountDataJson (const QString &type) const
 Get account data as a JSON object. More...
 
void setAccountData (EventPtr &&event)
 Set a generic account data event of the given type. More...
 
Q_INVOKABLE void setAccountData (const QString &type, const QJsonObject &content)
 
QStringList accountDataEventTypes () const
 Lists the types of account data that exist for this connection;. More...
 
QHash< QString, QVector< Room * > > tagsToRooms () const
 Get all Invited and Joined rooms grouped by tag. More...
 
QStringList tagNames () const
 Get all room tags known on this connection. More...
 
QVector< Room * > roomsWithTag (const QString &tagName) const
 Get the list of rooms with the specified tag. More...
 
void addToDirectChats (const Room *room, const QString &userId)
 Mark the room as a direct chat with the user. More...
 
void removeFromDirectChats (const QString &roomId, const QString &userId={})
 Unmark the room from direct chats. More...
 
bool isDirectChat (const QString &roomId) const
 Check whether the room id corresponds to a direct chat. More...
 
DirectChatsMap directChats () const
 Get the whole map from users to direct chat rooms. More...
 
QList< QString > directChatMemberIds (const Room *room) const
 Retrieve the list of member IDs the room is a direct chat with. More...
 
Q_INVOKABLE bool isIgnored (const QString &userId) const
 Check whether a particular user id is in the ignore list. More...
 
Q_INVOKABLE bool isIgnored (const Quotient::User *user) const
 Check whether a particular user is in the ignore list. More...
 
Q_INVOKABLE Quotient::IgnoredUsersList ignoredUsers () const
 Get the whole list of ignored users. More...
 
Q_INVOKABLE void addToIgnoredUsers (const QString &userId)
 Add the user to the ignore list The change signal is emitted synchronously, without waiting to complete synchronisation with the server. More...
 
Q_INVOKABLE void removeFromIgnoredUsers (const QString &userId)
 Remove the user from the ignore list. More...
 
Q_INVOKABLE QStringList userIds () const
 Get the entire list of users known to the current user on this homeserver. More...
 
QUrl homeserver () const
 Get the base URL of the homeserver to connect to. More...
 
QString domain () const
 Get the domain name used for ids/aliases on the server. More...
 
bool isUsable () const
 Check if the homeserver is known to be reachable and working. More...
 
QVector< GetLoginFlowsJob::LoginFlowloginFlows () const
 Get the list of supported login flows. More...
 
bool supportsPasswordAuth () const
 Check whether the current homeserver supports password auth. More...
 
bool supportsSso () const
 Check whether the current homeserver supports SSO. More...
 
Q_INVOKABLE Quotient::Roomroom (const QString &roomId, Quotient::JoinStates states=JoinState::Invite|JoinState::Join) const
 Find a room by its id and a mask of applicable states. More...
 
Q_INVOKABLE Quotient::RoomroomByAlias (const QString &roomAlias, Quotient::JoinStates states=JoinState::Invite|JoinState::Join) const
 Find a room by its alias and a mask of applicable states. More...
 
void updateRoomAliases (const QString &roomId, const QStringList &previousRoomAliases, const QStringList &roomAliases)
 Update the internal map of room aliases to IDs. More...
 
Q_INVOKABLE Quotient::Roominvitation (const QString &roomId) const
 
Q_INVOKABLE Quotient::Useruser (const QString &uId)
 
const Useruser () const
 
Useruser ()
 
QString userId () const
 
AvataruserAvatar (const QUrl &avatarUrl)
 Get an avatar object for the given user ID and media ID. More...
 
AvataruserAvatar (const QString &avatarMediaId)
 Get an avatar object for the given user ID and media ID. More...
 
QString deviceId () const
 
QByteArray accessToken () const
 
bool isLoggedIn () const
 
bool isOnline () const
 Whether the connection is successfully syncing with the server. More...
 
QOlmAccountolmAccount () const
 
Databasedatabase () const
 
std::unordered_map< QByteArray, QOlmInboundGroupSessionloadRoomMegolmSessions (const Room *room) const
 
void saveMegolmSession (const Room *room, const QOlmInboundGroupSession &session, const QByteArray &senderKey, const QByteArray &senderEdKey) const
 
QString edKeyForUserDevice (const QString &userId, const QString &deviceId) const
 
QString curveKeyForUserDevice (const QString &userId, const QString &device) const
 
bool hasOlmSession (const QString &user, const QString &deviceId) const
 
void sendToDevice (const QString &targetUserId, const QString &targetDeviceId, const Event &event, bool encrypted)
 
bool isVerifiedSession (const QByteArray &megolmSessionId) const
 Returns true if this megolm session comes from a verified device. More...
 
bool isVerifiedDevice (const QString &userId, const QString &deviceId) const
 Returns whether the device is verified. More...
 
bool isKnownE2eeCapableDevice (const QString &userId, const QString &deviceId) const
 Returns whether the device is known and supports end-to-end encryption. More...
 
void sendSessionKeyToDevices (const QString &roomId, const QOlmOutboundGroupSession &outboundSession, const QMultiHash< QString, QString > &devices)
 
QJsonObject decryptNotification (const QJsonObject &notification)
 
QStringList devicesForUser (const QString &userId) const
 
Q_INVOKABLE bool isQueryingKeys () const
 
QFuture< QByteArray > requestKeyFromDevices (event_type_t name)
 
QString masterKeyForUser (const QString &userId) const
 
Q_INVOKABLE bool isUserVerified (const QString &userId) const
 
Q_INVOKABLE bool allSessionsSelfVerified (const QString &userId) const
 
bool hasConflictingDeviceIdsAndCrossSigningKeys (const QString &userId)
 
void reloadDevices ()
 
Q_INVOKABLE Quotient::SyncJobsyncJob () const
 
Q_INVOKABLE QString nextBatchToken () const
 
Q_INVOKABLE int millisToReconnect () const
 
Q_INVOKABLE void getTurnServers ()
 
Q_INVOKABLE bool capabilitiesReady () const
 Find out if homeserver capabilites have been loaded. More...
 
Q_INVOKABLE bool loadingCapabilities () const
 
QStringList supportedMatrixSpecVersions () const
 Get the list of Matrix CS API spec versions supported by the homeserver. More...
 
QString defaultRoomVersion () const
 Get the room version recommended by the server. More...
 
QStringList stableRoomVersions () const
 Get the room version considered stable by the server. More...
 
QVector< SupportedRoomVersionavailableRoomVersions () const
 Get all room versions supported by the server Only works after server capabilities have been loaded. More...
 
bool canChangePassword () const
 
bool encryptionEnabled () const
 Check whether encryption is enabled on this connection. More...
 
void enableEncryption (bool enable)
 Enable or disable encryption on this connection. More...
 
bool directChatEncryptionEnabled () const
 Check whether encryption is enabled for new direct chats on this connection. More...
 
void enableDirectChatEncryption (bool enable)
 Enable or disable whether new direct chats are encrypted on this connection. More...
 
Q_INVOKABLE void loadState ()
 Load room state from a previously saved file. More...
 
Q_INVOKABLE void saveState () const
 Save the current state for all rooms to a file. More...
 
void saveRoomState (Room *r) const
 This method saves the current state of a single room. More...
 
Q_INVOKABLE QString stateCachePath () const
 Get the default directory path to save the room state to. More...
 
QDir stateCacheDir () const
 Get the default directory to save the room state to. More...
 
bool cacheState () const
 Whether or not the rooms state should be cached locally. More...
 
void setCacheState (bool newValue)
 
bool lazyLoading () const
 
void setLazyLoading (bool newValue)
 
Q_INVOKABLE BaseJobrun (BaseJob *job, RunningPolicy runningPolicy=ForegroundRequest)
 Start a pre-created job object on this connection. More...
 
template<std::derived_from< BaseJob > JobT>
 requires (!std::same_as< JobT, BaseJob >) JobHandle< JobT > run(JobT *job
 Start a pre-created job on this connection and get a job handle to it. More...
 
RunningPolicy typename JobArgTs JobHandle< JobT > callApi (RunningPolicy runningPolicy, JobArgTs &&... jobArgs)
 
template<typename JobT , typename... JobArgTs>
JobHandle< JobT > callApi (JobArgTs &&... jobArgs)
 Start a job of a specified type with specified arguments. More...
 
template<typename JobT , typename... JobArgTs>
QUrl getUrlForApi (JobArgTs &&... jobArgs) const
 Get a request URL for a job with specified type and arguments. More...
 
Q_INVOKABLE SsoSessionprepareForSso (const QString &initialDeviceName, const QString &deviceId={})
 Start a local HTTP server and generate a single sign-on URL. More...
 
Q_INVOKABLE QString generateTxnId () const
 Generate a new transaction id. More...
 
Q_INVOKABLE QUrl makeMediaUrl (QUrl mxcUrl) const
 Convert an mxc: URL into a CS API URL. More...
 
Q_INVOKABLE bool roomSucceeds (const QString &maybePredecessorId, const QString &maybeSuccessorId) const
 
Q_INVOKABLE void resolveServer (const QString &mxid)
 Determine and set the homeserver from MXID. More...
 
Q_INVOKABLE QFuture< QList< LoginFlow > > setHomeserver (const QUrl &baseUrl)
 Set the homeserver base URL and retrieve its login flows. More...
 
Q_INVOKABLE QFuture< Room * > getDirectChat (const QString &otherUserId)
 Get a future to a direct chat with the user. More...
 
Q_INVOKABLE JobHandle< CreateRoomJobcreateDirectChat (const QString &userId, const QString &topic={}, const QString &name={})
 
Q_INVOKABLE JobHandle< JoinRoomJobjoinRoom (const QString &roomAlias, const QStringList &serverNames={})
 
Q_INVOKABLE QFuture< Room * > joinAndGetRoom (const QString &roomAlias, const QStringList &serverNames={})
 

Static Public Member Functions

static void setEncryptionDefault (bool useByDefault)
 Set the E2EE default state for any Connection created further. More...
 
static void setDirectChatEncryptionDefault (bool useByDefault)
 Set the direct chat E2EE default state for any Connection created further. More...
 
static void setRoomFactory (room_factory_t f)
 Set a room factory function. More...
 
static void setUserFactory (user_factory_t f)
 Set a user factory function. More...
 
static room_factory_t roomFactory ()
 Get a room factory function. More...
 
static user_factory_t userFactory ()
 Get a user factory function. More...
 
template<typename T >
static void setRoomType ()
 Set the room factory to default with the overriden room type. More...
 
template<typename T >
static void setUserType ()
 Set the user factory to default with the overriden user type. More...
 

Public Attributes

RunningPolicy runningPolicy
 

Protected Slots

void syncLoopIteration ()
 

Protected Member Functions

const ConnectionDataconnectionData () const
 Access the underlying ConnectionData class. More...
 
HomeserverData homeserverData () const
 Get the homeserver data necessary to construct network requests. More...
 
RoomprovideRoom (const QString &id, std::optional< JoinState > joinState={})
 Get a Room object for the given id in the given state. More...
 
void onSyncSuccess (SyncData &&data, bool fromCache=false)
 Process sync data from a successful sync request. More...
 

Properties

UserlocalUser
 
QString localUserId
 
QString domain
 
QString deviceId
 
QByteArray accessToken
 
bool isLoggedIn
 
bool isOnline
 
QString defaultRoomVersion
 
QUrl homeserver
 
QVector< GetLoginFlowsJob::LoginFlowloginFlows
 
bool isUsable
 
bool supportsSso
 
bool supportsPasswordAuth
 
bool cacheState
 
bool lazyLoading
 
bool canChangePassword
 
bool encryptionEnabled
 
bool directChatEncryptionEnabled
 
QStringList accountDataEventTypes
 

Friends

class ::TestCrossSigning
 

Detailed Description

Definition at line 114 of file connection.h.

Member Typedef Documentation

◆ UsersToDevicesToContent

using Quotient::Connection::UsersToDevicesToContent = QHash<QString, QHash<QString, QJsonObject> >

Definition at line 138 of file connection.h.

Member Enumeration Documentation

◆ RoomVisibility

Enumerator
PublishRoom 
UnpublishRoom 

Definition at line 140 of file connection.h.

Constructor & Destructor Documentation

◆ Connection() [1/2]

Quotient::Connection::Connection ( QObject *  parent = nullptr)
explicit

◆ Connection() [2/2]

Quotient::Connection::Connection ( const QUrl &  server,
QObject *  parent = nullptr 
)
explicit

◆ ~Connection()

Quotient::Connection::~Connection ( )
override

Member Function Documentation

◆ aboutToDeleteRoom

void Quotient::Connection::aboutToDeleteRoom ( Quotient::Room room)
signal

The room object is about to be deleted.

◆ accessToken()

QByteArray Quotient::Connection::accessToken ( ) const

◆ accountData() [1/3]

template<EventClass EventT>
const EventT* Quotient::Connection::accountData ( ) const
inline

Get an account data event of the given type.

Returns
the account data content for the given event type stored on the server, or a default-constructed object if there's none of that type.
Note
Direct chats map cannot be retrieved using this method yet; use directChats() instead.

Definition at line 193 of file connection.h.

◆ accountData() [2/3]

template<EventClass EventT>
const EventT* Quotient::Connection::accountData ( const QString &  keyName) const
inline

Definition at line 200 of file connection.h.

◆ accountData() [3/3]

const EventPtr& Quotient::Connection::accountData ( const QString &  type) const

Get a generic account data event of the given type.

Returns
an account data event of the given type stored on the server, or nullptr if there's none of that type.
Note
Direct chats map cannot be retrieved using this method yet; use directChats() instead.

◆ accountDataChanged

void Quotient::Connection::accountDataChanged ( QString  type)
signal

Account data (except direct chats) have changed.

◆ accountDataEventTypes()

QStringList Quotient::Connection::accountDataEventTypes ( ) const

Lists the types of account data that exist for this connection;.

◆ accountDataJson()

Q_INVOKABLE QJsonObject Quotient::Connection::accountDataJson ( const QString &  type) const

Get account data as a JSON object.

This returns the content part of the account data event of the given type. Direct chats map cannot be retrieved using this method yet; use directChats() instead.

◆ addToDirectChats()

void Quotient::Connection::addToDirectChats ( const Room room,
const QString &  userId 
)

Mark the room as a direct chat with the user.

This function marks room as a direct chat with userId. Emits the signal synchronously, without waiting to complete synchronisation with the server.

See also
directChatsListChanged

◆ addToIgnoredUsers()

Q_INVOKABLE void Quotient::Connection::addToIgnoredUsers ( const QString &  userId)

Add the user to the ignore list The change signal is emitted synchronously, without waiting to complete synchronisation with the server.

See also
ignoredUsersListChanged

◆ allRooms()

Q_INVOKABLE QVector<Quotient::Room*> Quotient::Connection::allRooms ( ) const

Get all rooms known within this Connection.

This includes Invite, Join and Leave rooms, in no particular order.

Note
Leave rooms will only show up in the list if they have been left in the same running session. The library doesn't cache left rooms between runs and it doesn't retrieve the full list of left rooms from the server.
See also
rooms, room, roomsWithTag

◆ allSessionsSelfVerified()

Q_INVOKABLE bool Quotient::Connection::allSessionsSelfVerified ( const QString &  userId) const

◆ assumeIdentity

void Quotient::Connection::assumeIdentity ( const QString &  mxId,
const QString &  deviceId,
const QString &  accessToken 
)
slot

Use an existing access token to connect to the homeserver.

Similar to loginWithPassword(), this method checks that the homeserver URL is valid and tries to resolve it from the MXID in case it is not.

Since
0.7.2

◆ availableRoomVersions()

QVector<SupportedRoomVersion> Quotient::Connection::availableRoomVersions ( ) const

Get all room versions supported by the server Only works after server capabilities have been loaded.

See also
loadingCapabilities

◆ cacheState()

bool Quotient::Connection::cacheState ( ) const

Whether or not the rooms state should be cached locally.

See also
loadState, saveState

◆ cacheStateChanged

void Quotient::Connection::cacheStateChanged ( )
signal

◆ callApi() [1/2]

template<typename JobT , typename... JobArgTs>
JobHandle<JobT> Quotient::Connection::callApi ( JobArgTs &&...  jobArgs)
inline

Start a job of a specified type with specified arguments.

This is an overload that runs the job with "foreground" policy.

Definition at line 542 of file connection.h.

◆ callApi() [2/2]

RunningPolicy typename JobArgTs JobHandle<JobT> Quotient::Connection::callApi ( RunningPolicy  runningPolicy,
JobArgTs &&...  jobArgs 
)
inline

Definition at line 533 of file connection.h.

◆ canChangePassword()

bool Quotient::Connection::canChangePassword ( ) const

Indicate if the user can change its password from the client. This is often not the case when SSO is enabled.

See also
loadingCapabilities

◆ capabilitiesLoaded

void Quotient::Connection::capabilitiesLoaded ( )
signal

◆ capabilitiesReady()

Q_INVOKABLE bool Quotient::Connection::capabilitiesReady ( ) const

Find out if homeserver capabilites have been loaded.

◆ connected

void Quotient::Connection::connected ( )
signal

◆ connectionData()

const ConnectionData* Quotient::Connection::connectionData ( ) const
protected

Access the underlying ConnectionData class.

◆ createDirectChat()

Q_INVOKABLE JobHandle<CreateRoomJob> Quotient::Connection::createDirectChat ( const QString &  userId,
const QString &  topic = {},
const QString &  name = {} 
)

Create a direct chat with a single user, optional name and topic

A room will always be created, unlike in requestDirectChat. It is advised to use requestDirectChat as a default way of getting one-on-one with a person, and only use createDirectChat when a new creation is explicitly desired.

◆ createdRoom

void Quotient::Connection::createdRoom ( Quotient::Room room)
signal

The room has just been created by createRoom or requestDirectChat.

This signal is not emitted in usual room state transitions, only as an outcome of room creation operations invoked by the client.

Note
requestDirectChat doesn't necessarily create a new chat; directChatAvailable() is more appropriate if you need to obtain a direct chat room after requestDirectChat().

◆ createRoom

JobHandle<CreateRoomJob> Quotient::Connection::createRoom ( RoomVisibility  visibility,
const QString &  alias,
const QString &  name,
const QString &  topic,
QStringList  invites,
const QString &  presetName = {},
const QString &  roomVersion = {},
bool  isDirect = false,
const QVector< CreateRoomJob::StateEvent > &  initialState = {},
const QVector< CreateRoomJob::Invite3pid > &  invite3pids = {},
const QJsonObject &  creationContent = {} 
)
slot

Create a room (generic method)

This method allows to customize room entirely to your liking, providing all the attributes the original CS API provides.

◆ crossSigningSetupRequired

void Quotient::Connection::crossSigningSetupRequired ( )
signal

The account does not yet have cross-signing keys. The client should ask the user whether to create them now and then set them up, if desired.

◆ curveKeyForUserDevice()

QString Quotient::Connection::curveKeyForUserDevice ( const QString &  userId,
const QString &  device 
) const

◆ database()

Database* Quotient::Connection::database ( ) const

◆ decryptNotification()

QJsonObject Quotient::Connection::decryptNotification ( const QJsonObject &  notification)

◆ defaultRoomVersion()

QString Quotient::Connection::defaultRoomVersion ( ) const

Get the room version recommended by the server.

Only works after server capabilities have been loaded.

See also
loadingCapabilities

◆ deviceId()

QString Quotient::Connection::deviceId ( ) const

◆ devicesForUser()

QStringList Quotient::Connection::devicesForUser ( const QString &  userId) const

◆ devicesListLoaded

void Quotient::Connection::devicesListLoaded ( )
signal

◆ directChatAvailable

void Quotient::Connection::directChatAvailable ( Quotient::Room directChat)
signal

The direct chat room is ready for using.

This signal is emitted upon any successful outcome from requestDirectChat.

◆ directChatEncryptionEnabled()

bool Quotient::Connection::directChatEncryptionEnabled ( ) const

Check whether encryption is enabled for new direct chats on this connection.

Note
This has no effect if the library is compiled without E2EE support
See also
enableDirectChatEncryption

◆ directChatMemberIds()

QList<QString> Quotient::Connection::directChatMemberIds ( const Room room) const

Retrieve the list of member IDs the room is a direct chat with.

Returns
The list of member IDs for which this room is marked as a direct chat; an empty list if the room is not a direct chat

◆ directChats()

DirectChatsMap Quotient::Connection::directChats ( ) const

Get the whole map from users to direct chat rooms.

◆ directChatsEncryptionChanged

void Quotient::Connection::directChatsEncryptionChanged ( bool  enabled)
signal

◆ directChatsListChanged

void Quotient::Connection::directChatsListChanged ( Quotient::DirectChatsMap  additions,
Quotient::DirectChatsMap  removals 
)
signal

The list of direct chats has changed.

This signal is emitted every time when the mapping of users to direct chat rooms is changed (because of either local updates or a different list arrived from the server).

◆ domain()

QString Quotient::Connection::domain ( ) const

Get the domain name used for ids/aliases on the server.

◆ downloadFile [1/2]

DownloadFileJob* Quotient::Connection::downloadFile ( const QUrl &  url,
const EncryptedFileMetadata fileMetadata,
const QString &  localFilename = {} 
)
slot

◆ downloadFile [2/2]

DownloadFileJob* Quotient::Connection::downloadFile ( const QUrl &  url,
const QString &  localFilename = {} 
)
slot

◆ edKeyForUserDevice()

QString Quotient::Connection::edKeyForUserDevice ( const QString &  userId,
const QString &  deviceId 
) const

◆ enableDirectChatEncryption()

void Quotient::Connection::enableDirectChatEncryption ( bool  enable)

Enable or disable whether new direct chats are encrypted on this connection.

Note
This has no effect if the library is compiled without E2EE support
See also
directChatEncryptionEnabled

◆ enableEncryption()

void Quotient::Connection::enableEncryption ( bool  enable)

Enable or disable encryption on this connection.

Note
This has no effect if the library is compiled without E2EE support
See also
encryptionEnabled

◆ encryptionChanged

void Quotient::Connection::encryptionChanged ( bool  enabled)
signal

Encryption has been enabled or disabled.

◆ encryptionEnabled()

bool Quotient::Connection::encryptionEnabled ( ) const

Check whether encryption is enabled on this connection.

See also
enableEncryption

◆ encryptionUpdate

void Quotient::Connection::encryptionUpdate ( const Room room,
const QStringList invitedIds = {} 
)
slot

◆ finishedQueryingKeys

void Quotient::Connection::finishedQueryingKeys ( )
signal

◆ forgetRoom

ForgetRoomJob* Quotient::Connection::forgetRoom ( const QString &  id)
slot

Send /forget to the server and delete room locally.

This method is in Connection, not in Room, since it's a room lifecycle operation, and Connection is an acting room manager. It ensures that the local user is not a member of a room (running /leave, if necessary) then issues a /forget request and if that one doesn't fail deletion of the local Room object is ensured.

Parameters
idthe room id to forget
Returns
the ongoing /forget request to the server; note that the success() signal of this request is connected to deleteLater() of a respective room so by the moment this finishes, there might be no Room object anymore.

◆ generateTxnId()

Q_INVOKABLE QString Quotient::Connection::generateTxnId ( ) const

Generate a new transaction id.

Transaction id's are unique within a single Connection object

◆ getContent [1/2]

BaseJob* Quotient::Connection::getContent ( const QString &  mediaId)
slot

◆ getContent [2/2]

BaseJob* Quotient::Connection::getContent ( const QUrl &  url)
slot

◆ getDirectChat()

Q_INVOKABLE QFuture<Room*> Quotient::Connection::getDirectChat ( const QString &  otherUserId)

Get a future to a direct chat with the user.

◆ getThumbnail [1/3]

virtual MediaThumbnailJob* Quotient::Connection::getThumbnail ( const QString &  mediaId,
QSize  requestedSize,
RunningPolicy  policy = BackgroundRequest 
)
virtualslot

◆ getThumbnail [2/3]

MediaThumbnailJob* Quotient::Connection::getThumbnail ( const QUrl &  url,
int  requestedWidth,
int  requestedHeight,
RunningPolicy  policy = BackgroundRequest 
)
slot

◆ getThumbnail [3/3]

MediaThumbnailJob* Quotient::Connection::getThumbnail ( const QUrl &  url,
QSize  requestedSize,
RunningPolicy  policy = BackgroundRequest 
)
slot

◆ getTurnServers()

Q_INVOKABLE void Quotient::Connection::getTurnServers ( )

◆ getUrlForApi()

template<typename JobT , typename... JobArgTs>
QUrl Quotient::Connection::getUrlForApi ( JobArgTs &&...  jobArgs) const
inline

Get a request URL for a job with specified type and arguments.

This calls JobT::makeRequestUrl() prepending the connection's homeserver to the list of arguments.

Definition at line 552 of file connection.h.

◆ hasAccountData()

bool Quotient::Connection::hasAccountData ( const QString &  type) const

Check whether the account has data of the given type.

Direct chats map is not supported by this method yet.

◆ hasConflictingDeviceIdsAndCrossSigningKeys()

bool Quotient::Connection::hasConflictingDeviceIdsAndCrossSigningKeys ( const QString &  userId)

◆ hasOlmSession()

bool Quotient::Connection::hasOlmSession ( const QString &  user,
const QString &  deviceId 
) const

◆ homeserver()

QUrl Quotient::Connection::homeserver ( ) const

Get the base URL of the homeserver to connect to.

◆ homeserverChanged

void Quotient::Connection::homeserverChanged ( QUrl  baseUrl)
signal

◆ homeserverData()

HomeserverData Quotient::Connection::homeserverData ( ) const
protected

Get the homeserver data necessary to construct network requests.

◆ ignoredUsers()

Q_INVOKABLE Quotient::IgnoredUsersList Quotient::Connection::ignoredUsers ( ) const

Get the whole list of ignored users.

◆ ignoredUsersListChanged

void Quotient::Connection::ignoredUsersListChanged ( Quotient::IgnoredUsersList  additions,
Quotient::IgnoredUsersList  removals 
)
signal

◆ invitation()

Q_INVOKABLE Quotient::Room* Quotient::Connection::invitation ( const QString &  roomId) const

◆ invitedRoom

void Quotient::Connection::invitedRoom ( Quotient::Room room,
Quotient::Room prev 
)
signal

A room invitation is seen for the first time.

If the same room is in Left state, it's passed in prev. Beware that initial sync will trigger this signal for all rooms in Invite state.

◆ isDirectChat()

bool Quotient::Connection::isDirectChat ( const QString &  roomId) const

Check whether the room id corresponds to a direct chat.

◆ isIgnored() [1/2]

Q_INVOKABLE bool Quotient::Connection::isIgnored ( const QString &  userId) const

Check whether a particular user id is in the ignore list.

◆ isIgnored() [2/2]

Q_INVOKABLE bool Quotient::Connection::isIgnored ( const Quotient::User user) const

Check whether a particular user is in the ignore list.

◆ isKnownE2eeCapableDevice()

bool Quotient::Connection::isKnownE2eeCapableDevice ( const QString &  userId,
const QString &  deviceId 
) const

Returns whether the device is known and supports end-to-end encryption.

This might give unexpected results for users we're not tracking, i.e., users that we don't share an encrypted room with

◆ isLoggedIn()

bool Quotient::Connection::isLoggedIn ( ) const

◆ isOnline()

bool Quotient::Connection::isOnline ( ) const

Whether the connection is successfully syncing with the server.

Returns
true, if the last sync was successful, false otherwise.

◆ isOnlineChanged

void Quotient::Connection::isOnlineChanged ( )
signal

The online state has changed.

◆ isQueryingKeys()

Q_INVOKABLE bool Quotient::Connection::isQueryingKeys ( ) const

◆ isUsable()

bool Quotient::Connection::isUsable ( ) const

Check if the homeserver is known to be reachable and working.

◆ isUserVerified()

Q_INVOKABLE bool Quotient::Connection::isUserVerified ( const QString &  userId) const

◆ isVerifiedDevice()

bool Quotient::Connection::isVerifiedDevice ( const QString &  userId,
const QString &  deviceId 
) const

Returns whether the device is verified.

◆ isVerifiedSession()

bool Quotient::Connection::isVerifiedSession ( const QByteArray &  megolmSessionId) const

Returns true if this megolm session comes from a verified device.

◆ joinAndGetRoom()

Q_INVOKABLE QFuture<Room*> Quotient::Connection::joinAndGetRoom ( const QString &  roomAlias,
const QStringList serverNames = {} 
)

◆ joinedRoom

void Quotient::Connection::joinedRoom ( Quotient::Room room,
Quotient::Room prev 
)
signal

A joined room is seen for the first time.

It's not the same as receiving a room in "join" section of sync response (rooms will be there even after joining); it's also not (exactly) the same as actual joining action of a user (all rooms coming in initial sync will trigger this signal too). If this room was in Invite state before, the respective object is passed in prev (and it will be deleted shortly afterwards).

◆ joinRoom()

Q_INVOKABLE JobHandle<JoinRoomJob> Quotient::Connection::joinRoom ( const QString &  roomAlias,
const QStringList serverNames = {} 
)

◆ keyVerificationStateChanged

void Quotient::Connection::keyVerificationStateChanged ( const Quotient::KeyVerificationSession session,
Quotient::KeyVerificationSession::State  state 
)
signal

◆ lazyLoading()

bool Quotient::Connection::lazyLoading ( ) const

◆ lazyLoadingChanged

void Quotient::Connection::lazyLoadingChanged ( )
signal

◆ leaveRoom

virtual LeaveRoomJob* Quotient::Connection::leaveRoom ( Room room)
virtualslot
Deprecated:
Do not use this directly, use Room::leaveRoom() instead

◆ leftRoom

void Quotient::Connection::leftRoom ( Quotient::Room room,
Quotient::Room prev 
)
signal

A room has just been left.

If this room has been in Invite state (as in case of rejecting an invitation), the respective object will be passed in prev (and will be deleted shortly afterwards). Note that, similar to invitedRoom and joinedRoom, this signal is triggered for all Left rooms upon initial sync (not only those that were left right before the sync).

◆ loadCapabilities

JobHandle<GetCapabilitiesJob> Quotient::Connection::loadCapabilities ( )
slot

Request capabilities and room versions from the server.

◆ loadedRoomState

void Quotient::Connection::loadedRoomState ( Quotient::Room room)
signal

The first sync for the room has been completed.

This signal is emitted after the room has been synced the first time. This is the right signal to connect to if you need to access the room state (name, aliases, members); state transition signals (newRoom, joinedRoom etc.) come earlier, when the room has just been created.

◆ loadingCapabilities()

Q_INVOKABLE bool Quotient::Connection::loadingCapabilities ( ) const

◆ loadRoomMegolmSessions()

std::unordered_map<QByteArray, QOlmInboundGroupSession> Quotient::Connection::loadRoomMegolmSessions ( const Room room) const

◆ loadState()

Q_INVOKABLE void Quotient::Connection::loadState ( )

Load room state from a previously saved file.

Call this before first sync.

See also
saveState

◆ loadVersions

JobHandle<GetVersionsJob> Quotient::Connection::loadVersions ( )
slot

Request supported spec versions from the homeserver.

This call does not obtain room versions - use loadCapabilities() for that.

◆ loggedOut

void Quotient::Connection::loggedOut ( )
signal

◆ loginError

void Quotient::Connection::loginError ( QString  message,
QString  details 
)
signal

◆ loginFlows()

QVector<GetLoginFlowsJob::LoginFlow> Quotient::Connection::loginFlows ( ) const

Get the list of supported login flows.

◆ loginFlowsChanged

void Quotient::Connection::loginFlowsChanged ( )
signal

◆ loginWithPassword

void Quotient::Connection::loginWithPassword ( const QString &  userId,
const QString &  password,
const QString &  initialDeviceName,
const QString &  deviceId = {} 
)
slot

Log in using a username and password pair.

Before logging in, this method checks if the homeserver is valid and supports the password login flow. If the homeserver is invalid but a full user MXID is provided, this method calls resolveServer() using this MXID.

See also
resolveServer, resolveError, loginError

◆ loginWithToken

void Quotient::Connection::loginWithToken ( const QString &  loginToken,
const QString &  initialDeviceName,
const QString &  deviceId = {} 
)
slot

Log in using a login token.

One usual case for this method is the final stage of logging in via SSO. Unlike loginWithPassword() and assumeIdentity(), this method cannot resolve the server from the user name because the full user MXID is encoded in the login token. Callers should ensure the homeserver sanity in advance.

◆ logout

QFuture<void> Quotient::Connection::logout ( )
slot

◆ makeMediaUrl()

Q_INVOKABLE QUrl Quotient::Connection::makeMediaUrl ( QUrl  mxcUrl) const

Convert an mxc: URL into a CS API URL.

◆ makeMockConnection

static Connection* Quotient::Connection::makeMockConnection ( const QString &  mxId,
bool  enableEncryption = true 
)
staticslot

◆ masterKeyForUser()

QString Quotient::Connection::masterKeyForUser ( const QString &  userId) const

◆ millisToReconnect()

Q_INVOKABLE int Quotient::Connection::millisToReconnect ( ) const

◆ networkError

void Quotient::Connection::networkError ( QString  message,
QString  details,
int  retriesTaken,
int  nextRetryInMilliseconds 
)
signal

A network request (job) failed due to network problems.

This is only emitted when the job will retry on its own; once it gives up, requestFailed() will be emitted.

Parameters
messagemessage about the network problem
detailsraw error details, if any available
retriesTakenhow many retries have already been taken
nextRetryInMillisecondswhen the job will retry again (-1 if no next retry is scheduled)

◆ newKeyVerificationSession

void Quotient::Connection::newKeyVerificationSession ( Quotient::KeyVerificationSession session)
signal

◆ newRoom

void Quotient::Connection::newRoom ( Quotient::Room room)
signal

A new room object has been created.

\group Signals emitted on room transitions

Note: Rooms in Invite state are always stored separately from rooms in Join/Leave state, because of special treatment of invite_state in Matrix CS API (see The Spec on /sync for details). Therefore, objects below are: r - room in Join/Leave state; i - room in Invite state

  1. none -> Invite: newRoom(r), invitedRoom(r,nullptr)
  2. none -> Join: newRoom(r), joinedRoom(r,nullptr)
  3. none -> Leave: newRoom(r), leftRoom(r,nullptr)
  4. Invite -> Join: newRoom(r), joinedRoom(r,i), aboutToDeleteRoom(i) 4a. Leave and Invite -> Join: joinedRoom(r,i), aboutToDeleteRoom(i)
  5. Invite -> Leave: newRoom(r), leftRoom(r,i), aboutToDeleteRoom(i) 5a. Leave and Invite -> Leave: leftRoom(r,i), aboutToDeleteRoom(i)
  6. Join -> Leave: leftRoom(r)
  7. Leave -> Invite: newRoom(i), invitedRoom(i,r)
  8. Leave -> Join: joinedRoom(r) The following transitions are only possible via forgetRoom() so far; if a room gets forgotten externally, sync won't tell about it:
  9. any -> none: as any -> Leave, then aboutToDeleteRoom(r)

◆ newUser

void Quotient::Connection::newUser ( Quotient::User user)
signal

◆ nextBatchToken()

Q_INVOKABLE QString Quotient::Connection::nextBatchToken ( ) const

◆ olmAccount()

QOlmAccount* Quotient::Connection::olmAccount ( ) const

◆ onSyncSuccess()

void Quotient::Connection::onSyncSuccess ( SyncData &&  data,
bool  fromCache = false 
)
protected

Process sync data from a successful sync request.

◆ prepareForSso()

Q_INVOKABLE SsoSession* Quotient::Connection::prepareForSso ( const QString &  initialDeviceName,
const QString &  deviceId = {} 
)

Start a local HTTP server and generate a single sign-on URL.

This call does the preparatory steps to carry out single sign-on sequence

See also
https://matrix.org/docs/guides/sso-for-client-developers
Returns
A proxy object holding two URLs: one for SSO on the chosen homeserver and another for the local callback address. Normally you won't need the callback URL unless you proxy the response with a custom UI. You do not need to delete the SsoSession object; the Connection that issued it will dispose of it once the login sequence completes (with any outcome).

◆ provideRoom()

Room* Quotient::Connection::provideRoom ( const QString &  id,
std::optional< JoinState joinState = {} 
)
protected

Get a Room object for the given id in the given state.

Use this method when you need a Room object in the local list of rooms, with the given state. Note that this does not interact with the server; in particular, does not automatically create rooms on the server. This call performs necessary join state transitions; e.g., if it finds a room in Invite but joinState == JoinState::Join then the Invite room object will be deleted and a new room object with Join state created. In contrast, switching between Join and Leave happens within the same object.

Parameters
idroom id (not alias!)
joinStatedesired (target) join state of the room; if omitted, any state will be found and return unchanged, or a new Join room created.
Returns
a pointer to a Room object with the specified id and the specified state; nullptr if roomId is empty or if roomFactory() failed to create a Room object.

◆ ready

void Quotient::Connection::ready ( )
signal

The connection is ready to be used. Most notably, the fundamental e2ee data is loaded. This does not mean that the server was reached, a sync was performed, or the state cache was loaded.

◆ reloadCapabilities

void Quotient::Connection::reloadCapabilities ( )
slot

◆ reloadDevices()

void Quotient::Connection::reloadDevices ( )

◆ removeFromDirectChats()

void Quotient::Connection::removeFromDirectChats ( const QString &  roomId,
const QString &  userId = {} 
)

Unmark the room from direct chats.

This function removes the room id from direct chats either for a specific user or for all users if userId is empty. The room id is used to allow removal of, e.g., ids of forgotten rooms; a Room object need not exist. Emits the signal immediately, without waiting to complete synchronisation with the server.

See also
directChatsListChanged

◆ removeFromIgnoredUsers()

Q_INVOKABLE void Quotient::Connection::removeFromIgnoredUsers ( const QString &  userId)

Remove the user from the ignore list.

Similar to adding, the change signal is emitted synchronously.

See also
ignoredUsersListChanged

◆ requestDirectChat

void Quotient::Connection::requestDirectChat ( const QString &  userId)
slot

Get a direct chat with a single user.

This method may return synchronously or asynchoronously depending on whether a direct chat room with the respective person exists already.

See also
directChatAvailable

◆ requestFailed

void Quotient::Connection::requestFailed ( Quotient::BaseJob request)
signal

A network request (job) started by callApi() has failed.

Parameters
requestthe pointer to the failed job
See also
callApi

◆ requestKeyFromDevices()

QFuture<QByteArray> Quotient::Connection::requestKeyFromDevices ( event_type_t  name)

◆ requires()

template<std::derived_from< BaseJob > JobT>
Quotient::Connection::requires ( !std::same_as< JobT, BaseJob )

Start a pre-created job on this connection and get a job handle to it.

This is a template overload for run(BaseJob*, RunningPolicy) - if you call run() on any derived job (99% of the cases when you're going to call it), this overload will be chosen as a more type-safe and feature-rich version. It's not Q_INVOKABLE though.

◆ resolveError

void Quotient::Connection::resolveError ( QString  error)
signal

Initial server resolution has failed.

This signal is emitted when resolveServer() did not manage to resolve the homeserver using its .well-known/client record or otherwise.

See also
resolveServer

◆ resolveServer()

Q_INVOKABLE void Quotient::Connection::resolveServer ( const QString &  mxid)

Determine and set the homeserver from MXID.

This attempts to resolve the homeserver by requesting .well-known/matrix/client record from the server taken from the MXID serverpart. If there is no record found, the serverpart itself is attempted as the homeserver base URL; if the record is there but is malformed (e.g., the homeserver base URL cannot be found in it) resolveError() is emitted and further processing stops. Otherwise, setHomeserver is called, preparing the Connection object for the login attempt.

Parameters
mxiduser Matrix ID, such as @someone:example.org
See also
setHomeserver, homeserverChanged, loginFlowsChanged, resolveError

◆ room()

Q_INVOKABLE Quotient::Room* Quotient::Connection::room ( const QString &  roomId,
Quotient::JoinStates  states = JoinState::Invite|JoinState::Join 
) const

Find a room by its id and a mask of applicable states.

◆ roomByAlias()

Q_INVOKABLE Quotient::Room* Quotient::Connection::roomByAlias ( const QString &  roomAlias,
Quotient::JoinStates  states = JoinState::Invite|JoinState::Join 
) const

Find a room by its alias and a mask of applicable states.

◆ roomFactory()

static room_factory_t Quotient::Connection::roomFactory ( )
static

Get a room factory function.

◆ rooms()

Q_INVOKABLE QVector<Quotient::Room*> Quotient::Connection::rooms ( Quotient::JoinStates  joinStates) const

Get rooms that have either of the given join state(s)

This method returns, in no particular order, rooms which join state matches the mask passed in joinStates.

Note
Similar to allRooms(), this won't retrieve the full list of Leave rooms from the server.
See also
allRooms, room, roomsWithTag

◆ roomsCount()

Q_INVOKABLE int Quotient::Connection::roomsCount ( Quotient::JoinStates  joinStates) const

Get the total number of rooms in the given join state(s)

◆ roomSucceeds()

Q_INVOKABLE bool Quotient::Connection::roomSucceeds ( const QString &  maybePredecessorId,
const QString &  maybeSuccessorId 
) const

◆ roomsWithTag()

QVector<Room*> Quotient::Connection::roomsWithTag ( const QString &  tagName) const

Get the list of rooms with the specified tag.

◆ run()

Q_INVOKABLE BaseJob* Quotient::Connection::run ( BaseJob job,
RunningPolicy  runningPolicy = ForegroundRequest 
)

Start a pre-created job object on this connection.

◆ saveMegolmSession()

void Quotient::Connection::saveMegolmSession ( const Room room,
const QOlmInboundGroupSession session,
const QByteArray &  senderKey,
const QByteArray &  senderEdKey 
) const

◆ saveRoomState()

void Quotient::Connection::saveRoomState ( Room r) const

This method saves the current state of a single room.

◆ saveState()

Q_INVOKABLE void Quotient::Connection::saveState ( ) const

Save the current state for all rooms to a file.

This method saves the current state of rooms (but not messages in them) to a local cache file, so that it could be loaded by loadState() on a next run of the client.

See also
loadState

◆ secretReceived

void Quotient::Connection::secretReceived ( const QString &  requestId,
const QString &  secret 
)
signal

◆ sendMessage

SendMessageJob* Quotient::Connection::sendMessage ( const QString &  roomId,
const RoomEvent event 
)
slot

◆ sendSessionKeyToDevices()

void Quotient::Connection::sendSessionKeyToDevices ( const QString &  roomId,
const QOlmOutboundGroupSession outboundSession,
const QMultiHash< QString, QString > &  devices 
)

◆ sendToDevice()

void Quotient::Connection::sendToDevice ( const QString &  targetUserId,
const QString &  targetDeviceId,
const Event event,
bool  encrypted 
)

◆ sendToDevices

SendToDeviceJob* Quotient::Connection::sendToDevices ( const QString &  eventType,
const UsersToDevicesToContent contents 
)
slot

◆ sessionVerified

void Quotient::Connection::sessionVerified ( const QString &  userId,
const QString &  deviceId 
)
signal

◆ setAccountData() [1/2]

Q_INVOKABLE void Quotient::Connection::setAccountData ( const QString &  type,
const QJsonObject &  content 
)

◆ setAccountData() [2/2]

void Quotient::Connection::setAccountData ( EventPtr &&  event)

Set a generic account data event of the given type.

◆ setCacheState()

void Quotient::Connection::setCacheState ( bool  newValue)

◆ setDirectChatEncryptionDefault()

static void Quotient::Connection::setDirectChatEncryptionDefault ( bool  useByDefault)
static

Set the direct chat E2EE default state for any Connection created further.

◆ setEncryptionDefault()

static void Quotient::Connection::setEncryptionDefault ( bool  useByDefault)
static

Set the E2EE default state for any Connection created further.

◆ setHomeserver()

Q_INVOKABLE QFuture<QList<LoginFlow> > Quotient::Connection::setHomeserver ( const QUrl &  baseUrl)

Set the homeserver base URL and retrieve its login flows.

See also
LoginFlowsJob, loginFlows, loginFlowsChanged, homeserverChanged

◆ setLazyLoading()

void Quotient::Connection::setLazyLoading ( bool  newValue)

◆ setRoomFactory()

static void Quotient::Connection::setRoomFactory ( room_factory_t  f)
static

Set a room factory function.

◆ setRoomType()

template<typename T >
static void Quotient::Connection::setRoomType ( )
inlinestatic

Set the room factory to default with the overriden room type.

Definition at line 602 of file connection.h.

◆ setUserFactory()

static void Quotient::Connection::setUserFactory ( user_factory_t  f)
static

Set a user factory function.

◆ setUserType()

template<typename T >
static void Quotient::Connection::setUserType ( )
inlinestatic

Set the user factory to default with the overriden user type.

Definition at line 609 of file connection.h.

◆ stableRoomVersions()

QStringList Quotient::Connection::stableRoomVersions ( ) const

Get the room version considered stable by the server.

Only works after server capabilities have been loaded.

See also
loadingCapabilities

◆ startKeyVerificationSession

Quotient::KeyVerificationSession* Quotient::Connection::startKeyVerificationSession ( const QString &  userId,
const QString &  deviceId 
)
slot

◆ startSelfVerification

Q_INVOKABLE void Quotient::Connection::startSelfVerification ( )
slot

◆ stateCacheDir()

QDir Quotient::Connection::stateCacheDir ( ) const

Get the default directory to save the room state to.

This function returns the default directory to store the cached room state, defined as follows:

QStandardPaths::writeableLocation(QStandardPaths::CacheLocation) +
_safeUserId + "_state.json"

where _safeUserId is userId() with : (colon) replaced by _ (underscore), as colons are reserved characters on Windows.

See also
loadState, saveState, stateCachePath

◆ stateCachePath()

Q_INVOKABLE QString Quotient::Connection::stateCachePath ( ) const

Get the default directory path to save the room state to.

See also
stateCacheDir

◆ stateChanged

void Quotient::Connection::stateChanged ( )
signal

Login data or state have changed.

This is a common change signal for userId, deviceId and accessToken - these properties normally only change at a successful login and logout and are constant at other times.

◆ stopSync

void Quotient::Connection::stopSync ( )
slot

◆ supportedMatrixSpecVersions()

QStringList Quotient::Connection::supportedMatrixSpecVersions ( ) const

Get the list of Matrix CS API spec versions supported by the homeserver.

◆ supportsPasswordAuth()

bool Quotient::Connection::supportsPasswordAuth ( ) const

Check whether the current homeserver supports password auth.

◆ supportsSso()

bool Quotient::Connection::supportsSso ( ) const

Check whether the current homeserver supports SSO.

◆ sync

void Quotient::Connection::sync ( int  timeout = -1)
slot

◆ syncDone

void Quotient::Connection::syncDone ( )
signal

◆ syncError

void Quotient::Connection::syncError ( QString  message,
QString  details 
)
signal

◆ syncJob()

Q_INVOKABLE Quotient::SyncJob* Quotient::Connection::syncJob ( ) const

◆ syncLoop

void Quotient::Connection::syncLoop ( int  timeout = 30000)
slot

◆ syncLoopIteration

void Quotient::Connection::syncLoopIteration ( )
protectedslot

◆ tagNames()

QStringList Quotient::Connection::tagNames ( ) const

Get all room tags known on this connection.

◆ tagsToRooms()

QHash<QString, QVector<Room*> > Quotient::Connection::tagsToRooms ( ) const

Get all Invited and Joined rooms grouped by tag.

Returns
a hashmap from tag name to a vector of room pointers, sorted by their order in the tag - details are at https://spec.matrix.org/v1.5/client-server-api/#room-tagging

◆ turnServersChanged

void Quotient::Connection::turnServersChanged ( const QJsonObject &  servers)
signal

◆ updateRoomAliases()

void Quotient::Connection::updateRoomAliases ( const QString &  roomId,
const QStringList previousRoomAliases,
const QStringList roomAliases 
)

Update the internal map of room aliases to IDs.

This is used to maintain the internal index of room aliases. It does NOT change aliases on the server,

See also
Room::setLocalAliases

◆ uploadContent

JobHandle<UploadContentJob> Quotient::Connection::uploadContent ( QIODevice *  contentSource,
const QString &  filename = {},
const QString &  overrideContentType = {} 
)
slot

◆ uploadFile

JobHandle<UploadContentJob> Quotient::Connection::uploadFile ( const QString &  fileName,
const QString &  overrideContentType = {} 
)
slot

◆ user() [1/3]

User* Quotient::Connection::user ( )

◆ user() [2/3]

const User* Quotient::Connection::user ( ) const

◆ user() [3/3]

Q_INVOKABLE Quotient::User* Quotient::Connection::user ( const QString &  uId)

◆ userAvatar() [1/2]

Avatar& Quotient::Connection::userAvatar ( const QString &  avatarMediaId)

Get an avatar object for the given user ID and media ID.

◆ userAvatar() [2/2]

Avatar& Quotient::Connection::userAvatar ( const QUrl &  avatarUrl)

Get an avatar object for the given user ID and media ID.

◆ userFactory()

static user_factory_t Quotient::Connection::userFactory ( )
static

Get a user factory function.

◆ userId()

QString Quotient::Connection::userId ( ) const

◆ userIds()

Q_INVOKABLE QStringList Quotient::Connection::userIds ( ) const

Get the entire list of users known to the current user on this homeserver.

Note
Be mindful that this can easily count thousands or tens of thousands, and use sparingly; when in a room context, always use Room::members() instead

◆ userVerified

void Quotient::Connection::userVerified ( const QString &  userId)
signal

Friends And Related Function Documentation

◆ ::TestCrossSigning

friend class ::TestCrossSigning
friend

Definition at line 951 of file connection.h.

Member Data Documentation

◆ runningPolicy

RunningPolicy Quotient::Connection::runningPolicy
Initial value:
{
JobHandle jh { job };
run(static_cast<BaseJob*>(job), runningPolicy);
return jh;
}
template <typename JobT
RunningPolicy runningPolicy
Definition: connection.h:514
Q_INVOKABLE BaseJob * run(BaseJob *job, RunningPolicy runningPolicy=ForegroundRequest)
Start a pre-created job object on this connection.
JobHandle(JobT *) -> JobHandle< JobT >

Definition at line 514 of file connection.h.

Property Documentation

◆ accessToken

QByteArray Quotient::Connection::accessToken
read

Definition at line 66 of file connection.h.

◆ accountDataEventTypes

QStringList Quotient::Connection::accountDataEventTypes
read

Definition at line 66 of file connection.h.

◆ cacheState

bool Quotient::Connection::cacheState
readwrite

Definition at line 66 of file connection.h.

◆ canChangePassword

bool Quotient::Connection::canChangePassword
read

Definition at line 66 of file connection.h.

◆ defaultRoomVersion

QString Quotient::Connection::defaultRoomVersion
read

Definition at line 66 of file connection.h.

◆ deviceId

QString Quotient::Connection::deviceId
read

Definition at line 66 of file connection.h.

◆ directChatEncryptionEnabled

bool Quotient::Connection::directChatEncryptionEnabled
readwrite

Definition at line 66 of file connection.h.

◆ domain

QString Quotient::Connection::domain
read

Definition at line 66 of file connection.h.

◆ encryptionEnabled

bool Quotient::Connection::encryptionEnabled
readwrite

Definition at line 66 of file connection.h.

◆ homeserver

QUrl Quotient::Connection::homeserver
readwrite

Definition at line 66 of file connection.h.

◆ isLoggedIn

bool Quotient::Connection::isLoggedIn
read

Definition at line 66 of file connection.h.

◆ isOnline

bool Quotient::Connection::isOnline
read

Definition at line 66 of file connection.h.

◆ isUsable

bool Quotient::Connection::isUsable
read

Definition at line 66 of file connection.h.

◆ lazyLoading

bool Quotient::Connection::lazyLoading
readwrite

Definition at line 66 of file connection.h.

◆ localUser

User* Quotient::Connection::localUser
read

Definition at line 66 of file connection.h.

◆ localUserId

QString Quotient::Connection::localUserId
read

Definition at line 66 of file connection.h.

◆ loginFlows

QVector<GetLoginFlowsJob::LoginFlow> Quotient::Connection::loginFlows
read

Definition at line 66 of file connection.h.

◆ supportsPasswordAuth

bool Quotient::Connection::supportsPasswordAuth
read

Definition at line 66 of file connection.h.

◆ supportsSso

bool Quotient::Connection::supportsSso
read

Definition at line 66 of file connection.h.


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