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