libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
connection.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Kitsune Ral <Kitsune-Ral@users.sf.net>
2// SPDX-FileCopyrightText: 2017 Roman Plášil <me@rplasil.name>
3// SPDX-FileCopyrightText: 2019 Alexey Andreyev <aa13q@ya.ru>
4// SPDX-License-Identifier: LGPL-2.1-or-later
5
6#pragma once
7
10#include "ssosession.h"
11#include "util.h"
12
13#include "csapi/create_room.h"
14#include "csapi/login.h"
15#include "csapi/content-repo.h"
16
17#include "e2ee/qolmoutboundsession.h"
18
19#include "events/accountdataevents.h"
20#include "jobs/jobhandle.h"
21#include "jobs/syncjob.h"
22
23#include <QtCore/QDir>
24#include <QtCore/QObject>
25#include <QtCore/QSize>
26#include <QtCore/QUrl>
27#include <QtQmlIntegration/qqmlintegration.h>
28
29#include <functional>
30
31Q_DECLARE_METATYPE(Quotient::GetLoginFlowsJob::LoginFlow)
32
33class TestCrossSigning;
34
35namespace Quotient {
36
37class Avatar;
38class Room;
39class User;
40class ConnectionData;
41class RoomEvent;
42
43class GetVersionsJob;
44class GetCapabilitiesJob;
45class RoomMessagesJob;
46class PostReceiptJob;
47class ForgetRoomJob;
48class MediaThumbnailJob;
49class JoinRoomJob;
50class DownloadFileJob;
51class SendToDeviceJob;
52class SendMessageJob;
53class LeaveRoomJob;
54class Database;
55struct EncryptedFileMetadata;
56
57class QOlmAccount;
58class QOlmInboundGroupSession;
59
61
64
65//! Predefined login flow types
66namespace LoginFlowTypes {
67 inline constexpr auto Password = "m.login.password"_L1, SSO = "m.login.sso"_L1,
68 Token = "m.login.token"_L1;
69}
70
71class Connection;
72
73using room_factory_t =
74 std::function<Room*(Connection*, const QString&, JoinState)>;
75using user_factory_t = std::function<User*(Connection*, const QString&)>;
76
77//! \brief The default factory to create room objects
78//!
79//! Just a wrapper around operator new.
80//! \sa Connection::setRoomFactory, Connection::setRoomType
81template <typename T = Room>
82auto defaultRoomFactory(Connection* c, const QString& id, JoinState js)
83{
84 return new T(c, id, js);
85}
86
87//! \brief The default factory to create user objects
88//!
89//! Just a wrapper around operator new.
90//! \sa Connection::setUserFactory, Connection::setUserType
91template <typename T = User>
92auto defaultUserFactory(Connection* c, const QString& id)
93{
94 return new T(id, c);
95}
96
97// Room ids, rather than room pointers, are used in the direct chat
98// map types because the library keeps Invite rooms separate from
99// rooms in Join and Leave state; and direct chats in account data
100// are stored with no regard to their state.
103
108
127
128public:
130
134 }; // FIXME: Should go inside CreateRoomJob
135
136 explicit Connection(QObject* parent = nullptr);
137 explicit Connection(const QUrl& server, QObject* parent = nullptr);
139
140 //! \brief Get all rooms known within this Connection
141 //!
142 //! This includes Invite, Join and Leave rooms, in no particular order.
143 //! \note Leave rooms will only show up in the list if they have been left
144 //! in the same running session. The library doesn't cache left rooms
145 //! between runs and it doesn't retrieve the full list of left rooms
146 //! from the server.
147 //! \sa rooms, room, roomsWithTag
149
150 //! \brief Get rooms that have either of the given join state(s)
151 //!
152 //! This method returns, in no particular order, rooms which join state
153 //! matches the mask passed in \p joinStates.
154 //! \note Similar to allRooms(), this won't retrieve the full list of
155 //! Leave rooms from the server.
156 //! \sa allRooms, room, roomsWithTag
159
160 //! Get the total number of rooms in the given join state(s)
162
163 //! \brief Check whether the account has data of the given type
164 //!
165 //! Direct chats map is not supported by this method _yet_.
166 bool hasAccountData(const QString& type) const;
167
168 //! \brief Get a generic account data event of the given type
169 //!
170 //! \return an account data event of the given type stored on the server,
171 //! or nullptr if there's none of that type.
172 //! \note Direct chats map cannot be retrieved using this method _yet_;
173 //! use directChats() instead.
174 const EventPtr& accountData(const QString& type) const;
175
176 //! \brief Get an account data event of the given type
177 //!
178 //! \return the account data content for the given event type stored
179 //! on the server, or a default-constructed object if there's none
180 //! of that type.
181 //! \note Direct chats map cannot be retrieved using this method _yet_;
182 //! use directChats() instead.
183 template <EventClass EventT>
184 const EventT* accountData() const
185 {
186 // 0.9: use the default argument and fold into the next overload
188 }
189
190 template <EventClass EventT>
191 const EventT* accountData(const QString& keyName) const
192 {
194 }
195
196 //! \brief Get account data as a JSON object
197 //!
198 //! This returns the content part of the account data event
199 //! of the given type. Direct chats map cannot be retrieved using
200 //! this method _yet_; use directChats() instead.
202
203 //! Set a generic account data event of the given type
205
207 const QJsonObject& content);
208
209 //! Lists the types of account data that exist for this connection;
211
212 //! \brief Get all Invited and Joined rooms grouped by tag
213 //! \return a hashmap from tag name to a vector of room pointers,
214 //! sorted by their order in the tag - details are at
215 //! https://spec.matrix.org/v1.5/client-server-api/#room-tagging
217
218 //! Get all room tags known on this connection
220
221 //! Get the list of rooms with the specified tag
223
224 //! \brief Mark the room as a direct chat with the user
225 //!
226 //! This function marks \p room as a direct chat with \p userId.
227 //! Emits the signal synchronously, without waiting to complete
228 //! synchronisation with the server.
229 //! \sa directChatsListChanged
231
232 //! \brief Unmark the room from direct chats
233 //!
234 //! This function removes the room id from direct chats either for
235 //! a specific \p user or for all users if \p userId is empty.
236 //! The room id is used to allow removal of, e.g., ids of forgotten
237 //! rooms; a Room object need not exist. Emits the signal
238 //! immediately, without waiting to complete synchronisation with
239 //! the server.
240 //! \sa directChatsListChanged
242
243 //! Check whether the room id corresponds to a direct chat
244 bool isDirectChat(const QString& roomId) const;
245
246 //! Get the whole map from users to direct chat rooms
248
249 //! \brief Retrieve the list of member IDs the room is a direct chat with
250 //!
251 //! \return The list of member IDs for which this room is marked as
252 //! a direct chat; an empty list if the room is not a direct chat
254
255 //! Check whether a particular user id is in the ignore list
257
258 //! Get the whole list of ignored users
260
261 //! \brief Add the user to the ignore list
262 //! The change signal is emitted synchronously, without waiting
263 //! to complete synchronisation with the server.
264 //!
265 //! \sa ignoredUsersListChanged
267
268 //! \brief Remove the user from the ignore list
269 //!
270 //! Similar to adding, the change signal is emitted synchronously.
271 //! \sa ignoredUsersListChanged
273
274 //! \brief Get the entire list of users known to the current user on this homeserver
275 //! \note Be mindful that this can easily count thousands or tens of thousands, and use
276 //! sparingly; when in a room context, always use Room::members() instead
278
279 //! Get the base URL of the homeserver to connect to
281 //! Get the domain name used for ids/aliases on the server
283 //! Get the list of supported login flows
285 //! Get the login flow of a given type
287 //! Check whether the current homeserver supports password auth
289 //! Check whether the current homeserver supports SSO
290 bool supportsSso() const;
291 //! Find a room by its id and a mask of applicable states
293 const QString& roomId,
295 //! Find a room by its alias and a mask of applicable states
297 const QString& roomAlias,
299 //! \brief Update the internal map of room aliases to IDs
300 //!
301 //! This is used to maintain the internal index of room aliases.
302 //! It does NOT change aliases on the server,
303 //! \sa Room::setLocalAliases
306 const QStringList& roomAliases);
309 const User* user() const;
312
313 //! \brief Get an avatar object for the given user ID and media ID
315
316 //! \brief Get an avatar object for the given user ID and media ID
318
321 bool isLoggedIn() const;
322
323 //! \brief Whether the connection is successfully syncing with the server.
324 //!
325 //! \return true, if the last sync was successful, false otherwise.
326 bool isOnline() const;
329
331 const Room* room) const;
334
336 const QString& deviceId) const;
338 const QString& device) const;
339 bool hasOlmSession(const QString& user, const QString& deviceId) const;
340
341 // This assumes that an olm session already exists. If it doesn't, no message is sent.
343 const Event& event, bool encrypted);
344
345 //! Returns true if this megolm session comes from a verified device
347
348 //! Returns whether the device is verified
349 bool isVerifiedDevice(const QString& userId, const QString& deviceId) const;
350
351 //! \brief Returns whether the device is known and supports end-to-end encryption.
352 //!
353 //! This might give unexpected results for users we're not tracking,
354 //! i.e., users that we don't share an encrypted room with
356
357
361
365
367
372
374
378
380
384
385 static constexpr QStringView StableTag = u"stable";
386 bool isStable() const { return status == StableTag; }
387
389 {
391 return dbg.nospace() << v.id << '/' << v.status;
392 }
393 };
394
395 //! Find out if homeserver capabilites have been loaded
397
398 //! Get the list of Matrix CS API spec versions supported by the homeserver
400
401 //! \brief Get the room version recommended by the server
402 //!
403 //! Only works after server capabilities have been loaded.
404 //! \sa loadingCapabilities
406 //! \brief Get the room version considered stable by the server
407 //!
408 //! Only works after server capabilities have been loaded.
409 //! \sa loadingCapabilities
411 //! \brief Get all room versions supported by the server
412 //! Only works after server capabilities have been loaded.
413 //! \sa loadingCapabilities
415
416 //! Indicate if the user can change its password from the client.
417 //! This is often not the case when SSO is enabled.
418 //! \sa loadingCapabilities
419 bool canChangePassword() const;
420
421 //! \brief Check whether encryption is enabled on this connection
422 //! \sa enableEncryption
423 bool encryptionEnabled() const;
424
425 //! \brief Enable or disable encryption on this connection
426 //!
427 //! \note This has no effect if the library is compiled without E2EE support
428 //!
429 //! \sa encryptionEnabled
431
432 //! \brief Check whether encryption is enabled for new direct chats on this connection
433 //!
434 //! \note This has no effect if the library is compiled without E2EE support
435 //!
436 //! \sa enableDirectChatEncryption
438
439 //! \brief Enable or disable whether new direct chats are encrypted on this connection
440 //!
441 //! \note This has no effect if the library is compiled without E2EE support
442 //!
443 //! \sa directChatEncryptionEnabled
445
446 //! \brief Load room state from a previously saved file
447 //!
448 //! Call this before first sync.
449 //! \sa saveState
451
452 //! \brief Save the current state for all rooms to a file
453 //!
454 //! This method saves the current state of rooms (but not messages
455 //! in them) to a local cache file, so that it could be loaded by
456 //! loadState() on a next run of the client.
457 //! \sa loadState
458 Q_INVOKABLE void saveState() const;
459
460 //! This method saves the current state of a single room.
461 void saveRoomState(Room* r) const;
462
463 //! \brief Get the default directory path to save the room state to
464 //! \sa stateCacheDir
466
467 //! \brief Get the default directory to save the room state to
468 //!
469 //! This function returns the default directory to store the cached
470 //! room state, defined as follows:
471 //! \code
472 //! QStandardPaths::writeableLocation(QStandardPaths::CacheLocation) +
473 //! _safeUserId + "_state.json" \endcode where `_safeUserId` is userId() with
474 //! `:` (colon) replaced by
475 //! `_` (underscore), as colons are reserved characters on Windows.
476 //! \sa loadState, saveState, stateCachePath
478
479 //! \brief Whether or not the rooms state should be cached locally
480 //! \sa loadState, saveState
481 bool cacheState() const;
483
484 bool lazyLoading() const;
486
487 //! \brief Start a pre-made job object on this connection
488 //!
489 //! Use this overload in case when you don't want to, or cannot, use JobHandle. Internally,
490 //! this is also the function all other template wrappers ultimately call to do the real work.
493
494 //! \brief Start a pre-created job on this connection
495 //!
496 //! Use this overload if you have a job object pre-made with JobHandle<>::createFrom() when
497 //! you need to actually start (or rather, queue) the network request. It is strongly
498 //! recommended to use the job handle returned by run() instead of the original, as run() may
499 //! (in the future) attach continuations to the future interface of the handle.
500 //! \sa JobHandle::createFrom
501 template <std::derived_from<BaseJob> JobT>
504 {
506 return std::move(job);
507 }
508
509 //! \brief Start a job of a given type with specified arguments and policy
510 //!
511 //! This is a universal method to create and start a job of a type passed
512 //! as a template parameter. The policy allows to fine-tune the way
513 //! the job is executed - as of this writing it means a choice
514 //! between "foreground" and "background".
515 //!
516 //! \param runningPolicy controls how the job is executed
517 //! \param jobArgs arguments to the job constructor
518 //!
519 //! \sa BaseJob::isBackground. QNetworkRequest::BackgroundRequestAttribute
520 template <typename JobT, typename... JobArgTs>
522 {
524 }
525
526 //! \brief Start a job of a specified type with specified arguments
527 //!
528 //! This is an overload that runs the job with "foreground" policy.
529 template <typename JobT, typename... JobArgTs>
531 {
533 }
534
535 //! \brief Get a request URL for a job with specified type and arguments
536 //!
537 //! This calls JobT::makeRequestUrl() prepending the connection's homeserver
538 //! to the list of arguments.
539 template <typename JobT, typename... JobArgTs>
541 {
543 }
544
545 //! \brief Start a local HTTP server and generate a single sign-on URL
546 //!
547 //! This call does the preparatory steps to carry out single sign-on
548 //! sequence
549 //! \sa https://matrix.org/docs/guides/sso-for-client-developers
550 //! \return A proxy object holding two URLs: one for SSO on the chosen
551 //! homeserver and another for the local callback address. Normally
552 //! you won't need the callback URL unless you proxy the response
553 //! with a custom UI. You do not need to delete the SsoSession
554 //! object; the Connection that issued it will dispose of it once
555 //! the login sequence completes (with any outcome).
557 const QString& deviceId = {});
558
559 //! \brief Generate a new transaction id
560 //!
561 //! Transaction id's are unique within a single Connection object
563
564 //! Convert an mxc: URL into a CS API URL
566
568 const QString& maybeSuccessorId) const;
569
570 //! Set the E2EE default state for any Connection created further
572
573 //! Set the direct chat E2EE default state for any Connection created further
575
576 //! Set a room factory function
578
579 //! Set a user factory function
581
582 //! Get a room factory function
584
585 //! Get a user factory function
587
588 //! Set the room factory to default with the overriden room type
589 template <typename T>
590 static void setRoomType()
591 {
593 }
594
595 //! Set the user factory to default with the overriden user type
596 template <typename T>
597 static void setUserType()
598 {
600 }
601
602 //! \brief Determine and set the homeserver from MXID
603 //!
604 //! This attempts to resolve the homeserver by requesting
605 //! .well-known/matrix/client record from the server taken from the MXID
606 //! serverpart. If there is no record found, the serverpart itself is
607 //! attempted as the homeserver base URL; if the record is there but
608 //! is malformed (e.g., the homeserver base URL cannot be found in it)
609 //! resolveError() is emitted and further processing stops. Otherwise,
610 //! setHomeserver is called, preparing the Connection object for the login
611 //! attempt.
612 //! \param mxid user Matrix ID, such as @someone:example.org
613 //! \sa setHomeserver, homeserverChanged, loginFlowsChanged, resolveError
615
616 //! \brief Set the homeserver base URL and retrieve its login flows
617 //!
618 //! \sa LoginFlowsJob, loginFlows, loginFlowsChanged, homeserverChanged
620
621 //! \brief Get a future to a direct chat with the user
623
624 //! Create a direct chat with a single user, optional name and topic
625 //!
626 //! A room will always be created, unlike in requestDirectChat.
627 //! It is advised to use requestDirectChat as a default way of getting
628 //! one-on-one with a person, and only use createDirectChat when
629 //! a new creation is explicitly desired.
631 const QString& topic = {},
632 const QString& name = {});
633
635 const QStringList& serverNames = {});
636
638 const QStringList& serverNames = {});
639
641
642public Q_SLOTS:
643 //! \brief Log in using a username and password pair
644 //!
645 //! Before logging in, this method checks if the homeserver is valid and
646 //! supports the password login flow. If the homeserver is invalid but
647 //! a full user MXID is provided, this method calls resolveServer() using
648 //! this MXID.
649 //! \sa resolveServer, resolveError, loginError
652 const QString& deviceId = {});
653
654 //! \brief Log in using a login token
655 //!
656 //! One usual case for this method is the final stage of logging in via SSO.
657 //! Unlike loginWithPassword() and assumeIdentity(), this method cannot
658 //! resolve the server from the user name because the full user MXID is
659 //! encoded in the login token. Callers should ensure the homeserver
660 //! sanity in advance.
663 const QString& deviceId = {});
664
665 //! \brief Use an existing access token to connect to the homeserver
666 //!
667 //! Similar to loginWithPassword(), this method checks that the homeserver
668 //! URL is valid and tries to resolve it from the MXID in case it is not.
669 //! \since 0.7.2
671
672 //! \brief Request supported spec versions from the homeserver
673 //!
674 //! This call does not obtain room versions - use loadCapabilities() for that.
676
677 //! Request capabilities and room versions from the server
679
681
682 void sync(int timeout = -1);
684
685 void stopSync();
686
692 int requestedHeight,
694
695 // QIODevice* should already be open
697 const QString& overrideContentType = {});
699 const QString& overrideContentType = {});
700
701 // If localFilename is empty, a temporary file will be created
703
706 const QString& localFilename = {});
707
708 //! \brief Create a room (generic method)
709 //!
710 //! This method allows to customize room entirely to your liking,
711 //! providing all the attributes the original CS API provides.
714 const QString& presetName = {}, const QString& roomVersion = {},
715 bool isDirect = false,
718 const QJsonObject& creationContent = {});
719
720 //! \brief Create a room with additional creators
721 //!
722 //! This is a temporary (until post-0.10) overload that accepts \p additionalCreators.
723 //! After 0.10 both overloads will merge into one again.
725 const QString &name, const QString &topic,
727 const QString &roomVersion, bool isDirect,
730 const QVector<Invite3pid> &invite3pids = {},
732
733 //! \brief Get a direct chat with a single user
734 //!
735 //! This method may return synchronously or asynchoronously depending
736 //! on whether a direct chat room with the respective person exists
737 //! already.
738 //! \sa directChatAvailable
740
741 //! \brief Send /forget to the server and delete room locally
742 //!
743 //! This method is in Connection, not in Room, since it's a
744 //! room lifecycle operation, and Connection is an acting room manager.
745 //! It ensures that the local user is not a member of a room (running /leave,
746 //! if necessary) then issues a /forget request and if that one doesn't fail
747 //! deletion of the local Room object is ensured.
748 //! \param id the room id to forget
749 //! \return the ongoing /forget request to the server; note that the
750 //! success() signal of this request is connected to deleteLater()
751 //! of a respective room so by the moment this finishes, there
752 //! might be no Room object anymore.
754
757
758 [[deprecated("This method is experimental and may be removed any time")]] //
760
761 //! \deprecated Do not use this directly, use Room::leaveRoom() instead
763
765 const QString& deviceId);
766
769
771 bool enableEncryption = true);
772
774 //! \brief Initial server resolution has failed
775 //!
776 //! This signal is emitted when resolveServer() did not manage to resolve
777 //! the homeserver using its .well-known/client record or otherwise.
778 //! \sa resolveServer
780
784
785 void connected();
786 void loggedOut();
787
788 //! \brief Login data or state have changed
789 //!
790 //! This is a common change signal for userId, deviceId and
791 //! accessToken - these properties normally only change at
792 //! a successful login and logout and are constant at other times.
794
795 //! The online state has changed.
797
799
800 //! \brief A network request (job) started by callApi() has failed
801 //! \param request the pointer to the failed job
802 //! \sa callApi
804
805 //! \brief A network request (job) failed due to network problems
806 //!
807 //! This is _only_ emitted when the job will retry on its own;
808 //! once it gives up, requestFailed() will be emitted.
809 //!
810 //! \param message message about the network problem
811 //! \param details raw error details, if any available
812 //! \param retriesTaken how many retries have already been taken
813 //! \param nextRetryInMilliseconds when the job will retry again
814 //! (-1 if no next retry is scheduled)
817
818 void syncDone();
820
822
823 //! \group Signals emitted on room transitions
824 //!
825 //! Note: Rooms in Invite state are always stored separately from
826 //! rooms in Join/Leave state, because of special treatment of
827 //! invite_state in Matrix CS API (see The Spec on /sync for details).
828 //! Therefore, objects below are: r - room in Join/Leave state;
829 //! i - room in Invite state
830 //!
831 //! 1. none -> Invite: newRoom(r), invitedRoom(r,nullptr)
832 //! 2. none -> Join: newRoom(r), joinedRoom(r,nullptr)
833 //! 3. none -> Leave: newRoom(r), leftRoom(r,nullptr)
834 //! 4. Invite -> Join:
835 //! newRoom(r), joinedRoom(r,i), aboutToDeleteRoom(i)
836 //! 4a. Leave and Invite -> Join:
837 //! joinedRoom(r,i), aboutToDeleteRoom(i)
838 //! 5. Invite -> Leave:
839 //! newRoom(r), leftRoom(r,i), aboutToDeleteRoom(i)
840 //! 5a. Leave and Invite -> Leave:
841 //! leftRoom(r,i), aboutToDeleteRoom(i)
842 //! 6. Join -> Leave: leftRoom(r)
843 //! 7. Leave -> Invite: newRoom(i), invitedRoom(i,r)
844 //! 8. Leave -> Join: joinedRoom(r)
845 //! The following transitions are only possible via forgetRoom()
846 //! so far; if a room gets forgotten externally, sync won't tell
847 //! about it:
848 //! 9. any -> none: as any -> Leave, then aboutToDeleteRoom(r)
849
850 //! A new room object has been created
852
853 //! \brief A room invitation is seen for the first time
854 //!
855 //! If the same room is in Left state, it's passed in prev. Beware
856 //! that initial sync will trigger this signal for all rooms in
857 //! Invite state.
859
860 //! \brief A joined room is seen for the first time
861 //!
862 //! It's not the same as receiving a room in "join" section of sync
863 //! response (rooms will be there even after joining); it's also
864 //! not (exactly) the same as actual joining action of a user (all
865 //! rooms coming in initial sync will trigger this signal too). If
866 //! this room was in Invite state before, the respective object is
867 //! passed in prev (and it will be deleted shortly afterwards).
869
870 //! \brief A room has just been left
871 //!
872 //! If this room has been in Invite state (as in case of rejecting
873 //! an invitation), the respective object will be passed in prev
874 //! (and will be deleted shortly afterwards). Note that, similar
875 //! to invitedRoom and joinedRoom, this signal is triggered for all
876 //! Left rooms upon initial sync (not only those that were left
877 //! right before the sync).
879
880 //! The room object is about to be deleted
882
883 //! \brief The room has just been created by createRoom or requestDirectChat
884 //!
885 //! This signal is not emitted in usual room state transitions,
886 //! only as an outcome of room creation operations invoked by
887 //! the client.
888 //! \note requestDirectChat doesn't necessarily create a new chat;
889 //! directChatAvailable() is more appropriate if you need to obtain
890 //! a direct chat room after requestDirectChat().
892
893 //! \brief The first sync for the room has been completed
894 //!
895 //! This signal is emitted after the room has been synced the first
896 //! time. This is the right signal to connect to if you need to
897 //! access the room state (name, aliases, members); state transition
898 //! signals (newRoom, joinedRoom etc.) come earlier, when the room
899 //! has just been created.
901
902 //! Account data (except direct chats) have changed
904
905 //! \brief The direct chat room is ready for using
906 //!
907 //! This signal is emitted upon any successful outcome from
908 //! requestDirectChat.
910
911 //! \brief The list of direct chats has changed
912 //!
913 //! This signal is emitted every time when the mapping of users
914 //! to direct chat rooms is changed (because of either local updates
915 //! or a different list arrived from the server).
918
921
926
927 //! Encryption has been enabled or disabled
930
938
940
941 //! The account does not yet have cross-signing keys. The client should ask the user
942 //! whether to create them now and then set them up, if desired.
944
945 //! The connection is ready to be used. Most notably, the fundamental e2ee data is loaded.
946 //! This does not mean that the server was reached, a sync was performed, or the state cache was loaded.
947 void ready();
948
949 friend class ::TestCrossSigning;
950protected:
951 //! Access the underlying ConnectionData class
953
954 //! Get the homeserver data necessary to construct network requests
956
957 //! \brief Get a Room object for the given id in the given state
958 //!
959 //! Use this method when you need a Room object in the local list
960 //! of rooms, with the given state. Note that this does not interact
961 //! with the server; in particular, does not automatically create
962 //! rooms on the server. This call performs necessary join state
963 //! transitions; e.g., if it finds a room in Invite but
964 //! `joinState == JoinState::Join` then the Invite room object
965 //! will be deleted and a new room object with Join state created.
966 //! In contrast, switching between Join and Leave happens within
967 //! the same object.
968 //! \param id room id (not alias!)
969 //! \param joinState desired (target) join state of the room; if
970 //! omitted, any state will be found and return unchanged, or a
971 //! new Join room created.
972 //! \return a pointer to a Room object with the specified id and the
973 //! specified state; nullptr if roomId is empty or if roomFactory()
974 //! failed to create a Room object.
976
977 //! Process sync data from a successful sync request
978 void onSyncSuccess(SyncData&& data, bool fromCache = false);
979
980protected Q_SLOTS:
982
983private:
984 class Private;
986
989};
990} // namespace Quotient
991Q_DECLARE_METATYPE(Quotient::DirectChatsMap)
992Q_DECLARE_METATYPE(Quotient::IgnoredUsersList)
Predefined login flow types.
Definition connection.h:66
constexpr auto Token
Definition connection.h:68
constexpr auto Password
Definition connection.h:67
auto defaultRoomFactory(Connection *c, const QString &id, JoinState js)
The default factory to create room objects.
Definition connection.h:82
auto defaultUserFactory(Connection *c, const QString &id)
The default factory to create user objects.
Definition connection.h:92
#define QUOTIENT_API