libQuotient
A Qt library for building matrix clients
|
#include <connection.h>
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< GetVersionsJob > | loadVersions () |
Request supported spec versions from the homeserver. More... | |
JobHandle< GetCapabilitiesJob > | loadCapabilities () |
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 MediaThumbnailJob * | getThumbnail (const QString &mediaId, QSize requestedSize, RunningPolicy policy=BackgroundRequest) |
MediaThumbnailJob * | getThumbnail (const QUrl &url, QSize requestedSize, RunningPolicy policy=BackgroundRequest) |
MediaThumbnailJob * | getThumbnail (const QUrl &url, int requestedWidth, int requestedHeight, RunningPolicy policy=BackgroundRequest) |
JobHandle< UploadContentJob > | uploadContent (QIODevice *contentSource, const QString &filename={}, const QString &overrideContentType={}) |
JobHandle< UploadContentJob > | uploadFile (const QString &fileName, const QString &overrideContentType={}) |
BaseJob * | getContent (const QString &mediaId) |
BaseJob * | getContent (const QUrl &url) |
DownloadFileJob * | downloadFile (const QUrl &url, const QString &localFilename={}) |
DownloadFileJob * | downloadFile (const QUrl &url, const EncryptedFileMetadata &fileMetadata, const QString &localFilename={}) |
JobHandle< CreateRoomJob > | 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={}) |
Create a room (generic method) More... | |
void | requestDirectChat (const QString &userId) |
Get a direct chat with a single user. More... | |
ForgetRoomJob * | forgetRoom (const QString &id) |
Send /forget to the server and delete room locally. More... | |
SendToDeviceJob * | sendToDevices (const QString &eventType, const UsersToDevicesToContent &contents) |
SendMessageJob * | sendMessage (const QString &roomId, const RoomEvent &event) |
virtual LeaveRoomJob * | leaveRoom (Room *room) |
Quotient::KeyVerificationSession * | startKeyVerificationSession (const QString &userId, const QString &deviceId) |
Q_INVOKABLE void | startSelfVerification () |
void | encryptionUpdate (const Room *room, const QStringList &invitedIds={}) |
static Connection * | makeMockConnection (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 EventPtr & | accountData (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::LoginFlow > | loginFlows () 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::Room * | room (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::Room * | roomByAlias (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::Room * | invitation (const QString &roomId) const |
Q_INVOKABLE Quotient::User * | user (const QString &uId) |
const User * | user () const |
User * | user () |
QString | userId () const |
Avatar & | userAvatar (const QUrl &avatarUrl) |
Get an avatar object for the given user ID and media ID. More... | |
Avatar & | userAvatar (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... | |
QOlmAccount * | olmAccount () const |
Database * | database () const |
std::unordered_map< QByteArray, QOlmInboundGroupSession > | loadRoomMegolmSessions (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 ¬ification) |
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::SyncJob * | syncJob () 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< SupportedRoomVersion > | availableRoomVersions () 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 BaseJob * | run (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 SsoSession * | prepareForSso (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< CreateRoomJob > | createDirectChat (const QString &userId, const QString &topic={}, const QString &name={}) |
Q_INVOKABLE JobHandle< JoinRoomJob > | joinRoom (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 ConnectionData * | connectionData () const |
Access the underlying ConnectionData class. More... | |
HomeserverData | homeserverData () const |
Get the homeserver data necessary to construct network requests. More... | |
Room * | provideRoom (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 | |
User * | localUser |
QString | localUserId |
QString | domain |
QString | deviceId |
QByteArray | accessToken |
bool | isLoggedIn |
bool | isOnline |
QString | defaultRoomVersion |
QUrl | homeserver |
QVector< GetLoginFlowsJob::LoginFlow > | loginFlows |
bool | isUsable |
bool | supportsSso |
bool | supportsPasswordAuth |
bool | cacheState |
bool | lazyLoading |
bool | canChangePassword |
bool | encryptionEnabled |
bool | directChatEncryptionEnabled |
QStringList | accountDataEventTypes |
Friends | |
class | ::TestCrossSigning |
Definition at line 114 of file connection.h.
using Quotient::Connection::UsersToDevicesToContent = QHash<QString, QHash<QString, QJsonObject> > |
Definition at line 138 of file connection.h.
Enumerator | |
---|---|
PublishRoom | |
UnpublishRoom |
Definition at line 140 of file connection.h.
|
explicit |
|
explicit |
|
override |
|
signal |
The room object is about to be deleted.
QByteArray Quotient::Connection::accessToken | ( | ) | const |
|
inline |
Get an account data event of the given type.
Definition at line 193 of file connection.h.
|
inline |
Definition at line 200 of file connection.h.
const EventPtr& Quotient::Connection::accountData | ( | const QString & | type | ) | const |
Get a generic account data event of the given type.
|
signal |
Account data (except direct chats) have changed.
QStringList Quotient::Connection::accountDataEventTypes | ( | ) | const |
Lists the types of account data that exist for this connection;.
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.
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.
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.
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.
Q_INVOKABLE bool Quotient::Connection::allSessionsSelfVerified | ( | const QString & | userId | ) | const |
|
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.
QVector<SupportedRoomVersion> Quotient::Connection::availableRoomVersions | ( | ) | const |
Get all room versions supported by the server Only works after server capabilities have been loaded.
bool Quotient::Connection::cacheState | ( | ) | const |
|
signal |
|
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.
|
inline |
Definition at line 533 of file connection.h.
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.
|
signal |
Q_INVOKABLE bool Quotient::Connection::capabilitiesReady | ( | ) | const |
Find out if homeserver capabilites have been loaded.
|
signal |
|
protected |
Access the underlying ConnectionData class.
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.
|
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.
|
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.
|
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.
QString Quotient::Connection::curveKeyForUserDevice | ( | const QString & | userId, |
const QString & | device | ||
) | const |
Database* Quotient::Connection::database | ( | ) | const |
QJsonObject Quotient::Connection::decryptNotification | ( | const QJsonObject & | notification | ) |
QString Quotient::Connection::defaultRoomVersion | ( | ) | const |
Get the room version recommended by the server.
Only works after server capabilities have been loaded.
QString Quotient::Connection::deviceId | ( | ) | const |
QStringList Quotient::Connection::devicesForUser | ( | const QString & | userId | ) | const |
|
signal |
|
signal |
The direct chat room is ready for using.
This signal is emitted upon any successful outcome from requestDirectChat.
bool Quotient::Connection::directChatEncryptionEnabled | ( | ) | const |
Check whether encryption is enabled for new direct chats on this connection.
QList<QString> Quotient::Connection::directChatMemberIds | ( | const Room * | room | ) | const |
Retrieve the list of member IDs the room is a direct chat with.
DirectChatsMap Quotient::Connection::directChats | ( | ) | const |
Get the whole map from users to direct chat rooms.
|
signal |
|
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).
QString Quotient::Connection::domain | ( | ) | const |
Get the domain name used for ids/aliases on the server.
|
slot |
|
slot |
QString Quotient::Connection::edKeyForUserDevice | ( | const QString & | userId, |
const QString & | deviceId | ||
) | const |
void Quotient::Connection::enableDirectChatEncryption | ( | bool | enable | ) |
Enable or disable whether new direct chats are encrypted on this connection.
void Quotient::Connection::enableEncryption | ( | bool | enable | ) |
Enable or disable encryption on this connection.
|
signal |
Encryption has been enabled or disabled.
bool Quotient::Connection::encryptionEnabled | ( | ) | const |
Check whether encryption is enabled on this connection.
|
slot |
|
signal |
|
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.
id | the room id to forget |
Q_INVOKABLE QString Quotient::Connection::generateTxnId | ( | ) | const |
Generate a new transaction id.
Transaction id's are unique within a single Connection object
|
slot |
|
slot |
Q_INVOKABLE QFuture<Room*> Quotient::Connection::getDirectChat | ( | const QString & | otherUserId | ) |
Get a future to a direct chat with the user.
|
virtualslot |
|
slot |
|
slot |
Q_INVOKABLE void Quotient::Connection::getTurnServers | ( | ) |
|
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.
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.
bool Quotient::Connection::hasConflictingDeviceIdsAndCrossSigningKeys | ( | const QString & | userId | ) |
bool Quotient::Connection::hasOlmSession | ( | const QString & | user, |
const QString & | deviceId | ||
) | const |
QUrl Quotient::Connection::homeserver | ( | ) | const |
Get the base URL of the homeserver to connect to.
|
signal |
|
protected |
Get the homeserver data necessary to construct network requests.
Q_INVOKABLE Quotient::IgnoredUsersList Quotient::Connection::ignoredUsers | ( | ) | const |
Get the whole list of ignored users.
|
signal |
Q_INVOKABLE Quotient::Room* Quotient::Connection::invitation | ( | const QString & | roomId | ) | const |
|
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.
bool Quotient::Connection::isDirectChat | ( | const QString & | roomId | ) | const |
Check whether the room id corresponds to a direct chat.
Q_INVOKABLE bool Quotient::Connection::isIgnored | ( | const QString & | userId | ) | const |
Check whether a particular user id is in the ignore list.
Q_INVOKABLE bool Quotient::Connection::isIgnored | ( | const Quotient::User * | user | ) | const |
Check whether a particular user is in the ignore list.
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
bool Quotient::Connection::isLoggedIn | ( | ) | const |
bool Quotient::Connection::isOnline | ( | ) | const |
Whether the connection is successfully syncing with the server.
|
signal |
The online state has changed.
Q_INVOKABLE bool Quotient::Connection::isQueryingKeys | ( | ) | const |
bool Quotient::Connection::isUsable | ( | ) | const |
Check if the homeserver is known to be reachable and working.
Q_INVOKABLE bool Quotient::Connection::isUserVerified | ( | const QString & | userId | ) | const |
bool Quotient::Connection::isVerifiedDevice | ( | const QString & | userId, |
const QString & | deviceId | ||
) | const |
Returns whether the device is verified.
bool Quotient::Connection::isVerifiedSession | ( | const QByteArray & | megolmSessionId | ) | const |
Returns true if this megolm session comes from a verified device.
Q_INVOKABLE QFuture<Room*> Quotient::Connection::joinAndGetRoom | ( | const QString & | roomAlias, |
const QStringList & | serverNames = {} |
||
) |
|
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).
Q_INVOKABLE JobHandle<JoinRoomJob> Quotient::Connection::joinRoom | ( | const QString & | roomAlias, |
const QStringList & | serverNames = {} |
||
) |
|
signal |
bool Quotient::Connection::lazyLoading | ( | ) | const |
|
signal |
|
virtualslot |
|
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).
|
slot |
Request capabilities and room versions from the server.
|
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.
Q_INVOKABLE bool Quotient::Connection::loadingCapabilities | ( | ) | const |
std::unordered_map<QByteArray, QOlmInboundGroupSession> Quotient::Connection::loadRoomMegolmSessions | ( | const Room * | room | ) | const |
Q_INVOKABLE void Quotient::Connection::loadState | ( | ) |
|
slot |
Request supported spec versions from the homeserver.
This call does not obtain room versions - use loadCapabilities() for that.
|
signal |
|
signal |
QVector<GetLoginFlowsJob::LoginFlow> Quotient::Connection::loginFlows | ( | ) | const |
Get the list of supported login flows.
|
signal |
|
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.
|
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.
|
slot |
Q_INVOKABLE QUrl Quotient::Connection::makeMediaUrl | ( | QUrl | mxcUrl | ) | const |
Convert an mxc: URL into a CS API URL.
|
staticslot |
QString Quotient::Connection::masterKeyForUser | ( | const QString & | userId | ) | const |
Q_INVOKABLE int Quotient::Connection::millisToReconnect | ( | ) | const |
|
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.
message | message about the network problem |
details | raw error details, if any available |
retriesTaken | how many retries have already been taken |
nextRetryInMilliseconds | when the job will retry again (-1 if no next retry is scheduled) |
|
signal |
|
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
|
signal |
Q_INVOKABLE QString Quotient::Connection::nextBatchToken | ( | ) | const |
QOlmAccount* Quotient::Connection::olmAccount | ( | ) | const |
|
protected |
Process sync data from a successful sync request.
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
|
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.
id | room id (not alias!) |
joinState | desired (target) join state of the room; if omitted, any state will be found and return unchanged, or a new Join room created. |
|
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.
|
slot |
void Quotient::Connection::reloadDevices | ( | ) |
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.
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.
|
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.
|
signal |
QFuture<QByteArray> Quotient::Connection::requestKeyFromDevices | ( | event_type_t | name | ) |
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.
|
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.
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.
mxid | user Matrix ID, such as @someone:example.org |
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.
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.
|
static |
Get a room factory function.
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
.
Q_INVOKABLE int Quotient::Connection::roomsCount | ( | Quotient::JoinStates | joinStates | ) | const |
Get the total number of rooms in the given join state(s)
Q_INVOKABLE bool Quotient::Connection::roomSucceeds | ( | const QString & | maybePredecessorId, |
const QString & | maybeSuccessorId | ||
) | const |
QVector<Room*> Quotient::Connection::roomsWithTag | ( | const QString & | tagName | ) | const |
Get the list of rooms with the specified tag.
Q_INVOKABLE BaseJob* Quotient::Connection::run | ( | BaseJob * | job, |
RunningPolicy | runningPolicy = ForegroundRequest |
||
) |
Start a pre-created job object on this connection.
void Quotient::Connection::saveMegolmSession | ( | const Room * | room, |
const QOlmInboundGroupSession & | session, | ||
const QByteArray & | senderKey, | ||
const QByteArray & | senderEdKey | ||
) | const |
void Quotient::Connection::saveRoomState | ( | Room * | r | ) | const |
This method saves the current state of a single room.
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.
|
signal |
|
slot |
void Quotient::Connection::sendSessionKeyToDevices | ( | const QString & | roomId, |
const QOlmOutboundGroupSession & | outboundSession, | ||
const QMultiHash< QString, QString > & | devices | ||
) |
void Quotient::Connection::sendToDevice | ( | const QString & | targetUserId, |
const QString & | targetDeviceId, | ||
const Event & | event, | ||
bool | encrypted | ||
) |
|
slot |
|
signal |
Q_INVOKABLE void Quotient::Connection::setAccountData | ( | const QString & | type, |
const QJsonObject & | content | ||
) |
void Quotient::Connection::setAccountData | ( | EventPtr && | event | ) |
Set a generic account data event of the given type.
void Quotient::Connection::setCacheState | ( | bool | newValue | ) |
|
static |
Set the direct chat E2EE default state for any Connection created further.
|
static |
Set the E2EE default state for any Connection created further.
Q_INVOKABLE QFuture<QList<LoginFlow> > Quotient::Connection::setHomeserver | ( | const QUrl & | baseUrl | ) |
Set the homeserver base URL and retrieve its login flows.
void Quotient::Connection::setLazyLoading | ( | bool | newValue | ) |
|
static |
Set a room factory function.
|
inlinestatic |
Set the room factory to default with the overriden room type.
Definition at line 602 of file connection.h.
|
static |
Set a user factory function.
|
inlinestatic |
Set the user factory to default with the overriden user type.
Definition at line 609 of file connection.h.
QStringList Quotient::Connection::stableRoomVersions | ( | ) | const |
Get the room version considered stable by the server.
Only works after server capabilities have been loaded.
|
slot |
|
slot |
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:
where _safeUserId
is userId() with :
(colon) replaced by _
(underscore), as colons are reserved characters on Windows.
Q_INVOKABLE QString Quotient::Connection::stateCachePath | ( | ) | const |
Get the default directory path to save the room state to.
|
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.
|
slot |
QStringList Quotient::Connection::supportedMatrixSpecVersions | ( | ) | const |
Get the list of Matrix CS API spec versions supported by the homeserver.
bool Quotient::Connection::supportsPasswordAuth | ( | ) | const |
Check whether the current homeserver supports password auth.
bool Quotient::Connection::supportsSso | ( | ) | const |
Check whether the current homeserver supports SSO.
|
slot |
|
signal |
|
signal |
Q_INVOKABLE Quotient::SyncJob* Quotient::Connection::syncJob | ( | ) | const |
|
slot |
|
protectedslot |
QStringList Quotient::Connection::tagNames | ( | ) | const |
Get all room tags known on this connection.
QHash<QString, QVector<Room*> > Quotient::Connection::tagsToRooms | ( | ) | const |
Get all Invited and Joined rooms grouped by tag.
|
signal |
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,
|
slot |
|
slot |
User* Quotient::Connection::user | ( | ) |
const User* Quotient::Connection::user | ( | ) | const |
Q_INVOKABLE Quotient::User* Quotient::Connection::user | ( | const QString & | uId | ) |
Avatar& Quotient::Connection::userAvatar | ( | const QString & | avatarMediaId | ) |
Get an avatar object for the given user ID and media ID.
Avatar& Quotient::Connection::userAvatar | ( | const QUrl & | avatarUrl | ) |
Get an avatar object for the given user ID and media ID.
|
static |
Get a user factory function.
QString Quotient::Connection::userId | ( | ) | const |
Q_INVOKABLE QStringList Quotient::Connection::userIds | ( | ) | const |
Get the entire list of users known to the current user on this homeserver.
|
signal |
|
friend |
Definition at line 951 of file connection.h.
RunningPolicy Quotient::Connection::runningPolicy |
Definition at line 514 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
readwrite |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
readwrite |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
readwrite |
Definition at line 66 of file connection.h.
|
readwrite |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
readwrite |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.
|
read |
Definition at line 66 of file connection.h.