10#include <lager/reader.hpp>
11#include <immer/box.hpp>
12#include <immer/map.hpp>
13#include <immer/flex_vector.hpp>
14#include <immer/flex_vector_transient.hpp>
92#ifdef KAZV_USE_THREAD_SAFETY_HELPER
93 , EventLoopThreadIdKeeper &
111 Client(lager::reader<SdkModel> sdk,
124 Client(lager::reader<SdkModel> sdk,
167 return clientCursor()
174 return rooms().xform(
175 zug::map([](
auto m) {
177 immer::flex_vector<std::string>{},
178 zug::map([](
auto val) {
return val.first; }),
183 auto roomIdsUnderTag(std::string tagId)
const -> lager::reader<immer::map<std::string, double>>;
191 auto roomIdsByTagId() const -> lager::reader<immer::map<
std::
string, immer::map<
std::
string,
double>>>;
255 std::
string password,
std::
string deviceName) const;
273 std::
string token,
std::
string deviceId) const;
291 std::
string homeserver,
292 std::
string loginToken,
293 std::optional<
std::
string> deviceName
301 auto
shouldSync() const -> lager::reader<
bool>;
346 std::optional<
std::
string> name = {},
347 std::optional<std::string> alias = {},
348 immer::array<std::string> invite = {},
349 std::optional<bool> isDirect = {},
350 bool allowFederate =
true,
351 std::optional<std::string> topic = {},
352 JsonWrap powerLevelContentOverride = json::object(),
353 std::optional<CreateRoomPreset> preset = std::nullopt,
354 immer::array<Event> initialState = immer::array<Event>()
375 PromiseT joinRoom(std::string roomId, immer::array<std::string> serverName)
const;
390 std::string uploadId,
391 std::optional<std::string> filename = std::nullopt,
392 std::optional<std::string> contentType = std::nullopt)
const;
417 using namespace CursorOp;
419 return (+clientCursor())
420 .template job<GetContentJob>()
421 .make(serverName, mediaId).url();
451 std::optional<FileDesc> downloadTo = std::nullopt)
const;
473 std::optional<ThumbnailResizingMethod> method = std::nullopt,
474 std::optional<FileDesc> downloadTo = std::nullopt)
const;
539 auto devicesOfUser(std::string userId)
const -> lager::reader<immer::flex_vector<DeviceKeyInfo>>;
612 template<class Archive>
614 ar << sdkCursor().get();
751 void syncForever(
std::optional<
int> retryTime =
std::nullopt) const;
753 const lager::reader<
SdkModel> &sdkCursor() const;
760 KAZV_DECLARE_THREAD_ID();
Definition basejob.hpp:68
Represent a Matrix client.
Definition client.hpp:87
PromiseT setAccountData(Event accountDataEvent) const
Set the account data that is not associated with any room.
Definition client.cpp:687
PromiseT setDisplayName(std::optional< std::string > displayName) const
Change the display name of the current user.
Definition client.cpp:631
auto directRoomMap() const -> lager::reader< immer::map< std::string, std::string > >
Get the map from direct messaging room ids to user ids.
Definition client.cpp:665
Room roomByCursor(lager::reader< std::string > id) const
Get the room with id.
Definition client.cpp:124
auto roomIdsByTagId() const -> lager::reader< immer::map< std::string, immer::map< std::string, double > > >
Get the room ids under all tags.
Definition client.cpp:677
PromiseT setTrustLevelNeededToSendKeys(DeviceTrustLevel trustLevel) const
Set the trust level needed to send keys to a device.
Definition client.cpp:660
PromiseT getVersions(std::string homeserver) const
Get all supported versions.
Definition client.cpp:697
PromiseT joinRoomById(std::string roomId) const
Join a room by its id.
Definition client.cpp:252
PromiseT joinRoom(std::string roomId, immer::array< std::string > serverName) const
Join a room by its id or alias.
Definition client.cpp:257
PromiseT cancelVerification(std::string userId, std::string deviceId) const
Cancel a verification process.
Definition client.cpp:455
std::string mxcUriToHttp(std::string mxcUri) const
Convert a MXC URI to an HTTP(s) URI.
Definition client.hpp:416
auto trustLevelNeededToSendKeys() const -> lager::reader< DeviceTrustLevel >
Get the trust level needed to send keys to a device.
Definition client.cpp:655
NotificationHandler notificationHandler() const
Get a notification handler that works on this Client.
Definition client.cpp:692
Client toEventLoop() const
Create a Client that is not constructed from a cursor.
Definition client.cpp:109
auto syncing() const
Definition client.hpp:506
PromiseT setAvatarUrl(std::optional< std::string > avatarUrl) const
Change the avatar url of the current user.
Definition client.cpp:626
PromiseT mLoginTokenLogin(std::string homeserver, std::string loginToken, std::optional< std::string > deviceName) const
Login using a login token.
Definition client.cpp:152
SingleTypePromise< DefaultRetType > PromiseT
Definition client.hpp:100
PromiseT logout() const
Stop syncing and then logout current session.
Definition client.cpp:193
PromiseT processVerificationEventsFromSync(EventList toDeviceEvents) const
Process verification events from a sync result.
Definition client.cpp:359
std::string mxcUriToHttpV1(std::string mxcUri) const
Convert a MXC URI to an HTTP(s) URI that needs Authorization.
Definition client.cpp:289
auto roomIds() const
Definition client.hpp:173
PromiseT readyForVerification(std::string userId, std::string deviceId) const
Signal that the user is ready for an incoming verification request.
Definition client.cpp:419
PromiseT purgeRoomEvents(immer::map< std::string, std::size_t > roomIdToMaxToKeepMap) const
Purge events in room, keeping the latest numToKeep events.
Definition client.cpp:737
Context< ActionT > ContextT
Definition client.hpp:97
PromiseT downloadContent(std::string mxcUri, std::optional< FileDesc > downloadTo=std::nullopt) const
Download content from the content repository.
Definition client.cpp:297
PromiseT stopSyncing() const
Stop the indefinite syncing.
Definition client.cpp:592
PromiseT denyVerificationSasMatch(std::string userId, std::string deviceId) const
Deny an sas match for a verification process.
Definition client.cpp:475
BaseJob getRoomIdByAliasJob(std::string roomAlias) const
Get a GetRoomIdByAliasJob.
Definition client.cpp:732
auto accountData() const -> lager::reader< immer::map< std::string, Event > >
Get the account data that is not associated with any room.
Definition client.cpp:682
PromiseT requestOutgoingToDeviceVerification(std::string userId, std::string deviceId) const
Request an outgoing verification using to-device message.
Definition client.cpp:384
void serializeTo(Archive &ar) const
Serialize the model to a Boost.Serialization archive.
Definition client.hpp:613
PromiseT ensureInitVerificationTracker() const
Ensure the VerificationTracker is initialized.
Definition client.cpp:485
auto shouldSync() const -> lager::reader< bool >
Get the shouldSync field of current ClientModel.
Definition client.cpp:189
PromiseT loadEventsFromStorage(immer::map< std::string, EventList > timelineEvents, immer::map< std::string, EventList > relatedEvents) const
Load events from storage into the model.
Definition client.cpp:742
PromiseT setDeviceTrustLevel(std::string userId, std::string deviceId, DeviceTrustLevel trustLevel) const
Set the trust level of a device.
Definition client.cpp:650
Room room(std::string id) const
Get the room with id .
Definition client.cpp:115
ClientAction ActionT
Definition client.hpp:89
PromiseT autoDiscover(std::string userId) const
Automatically discover the homeserver for userId.
Definition client.cpp:201
PromiseT addDirectRoom(std::string userId, std::string roomId) const
Mark a room as a direct chat by send the m.direct account data.
Definition client.cpp:707
lager::deps< JobInterface &, EventInterface &, SdkModelCursorKey, RandomInterface &, VerificationTracker & > DepsT
Definition client.hpp:96
auto devicesOfUser(std::string userId) const -> lager::reader< immer::flex_vector< DeviceKeyInfo > >
Get the info of all devices of user userId that supports encryption.
Definition client.cpp:636
PromiseT tokenLogin(std::string homeserver, std::string username, std::string token, std::string deviceId) const
Login using token and deviceId.
Definition client.cpp:172
auto supportVersions() const -> lager::reader< immer::array< std::string > >
Get all supported versions.
Definition client.cpp:702
PromiseT importFromKeyBackupFile(std::string fileContent, std::string password) const
Import keys from a key backup file.
Definition client.cpp:750
PromiseT uploadContent(immer::box< Bytes > content, std::string uploadId, std::optional< std::string > filename=std::nullopt, std::optional< std::string > contentType=std::nullopt) const
Upload content to the content repository.
Definition client.cpp:263
PromiseT downloadThumbnail(std::string mxcUri, int width, int height, std::optional< ThumbnailResizingMethod > method=std::nullopt, std::optional< FileDesc > downloadTo=std::nullopt) const
Download a thumbnail from the content repository.
Definition client.cpp:303
PromiseT getProfile(std::string userId) const
Fetch the profile of a user.
Definition client.cpp:621
PromiseT confirmVerificationSasMatch(std::string userId, std::string deviceId) const
Confirm an sas match for a verification process.
Definition client.cpp:465
PromiseT createRoom(RoomVisibility v, std::optional< std::string > name={}, std::optional< std::string > alias={}, immer::array< std::string > invite={}, std::optional< bool > isDirect={}, bool allowFederate=true, std::optional< std::string > topic={}, JsonWrap powerLevelContentOverride=json::object(), std::optional< CreateRoomPreset > preset=std::nullopt, immer::array< Event > initialState=immer::array< Event >()) const
Create a room.
Definition client.cpp:220
auto roomIdsUnderTag(std::string tagId) const -> lager::reader< immer::map< std::string, double > >
Definition client.cpp:670
PromiseT passwordLogin(std::string homeserver, std::string username, std::string password, std::string deviceName) const
Login using the password.
Definition client.cpp:133
PromiseT startSyncing() const
Start syncing if the Client is not syncing.
Definition client.cpp:314
auto rooms() const
Definition client.hpp:166
Definition context.hpp:130
Definition eventinterface.hpp:15
A class to handle a notification.
Definition notification-handler.hpp:22
Definition random-generator.hpp:16
Represent a Matrix room.
Definition room.hpp:38
Definition promise-interface.hpp:122
#define KAZV_WRAP_ATTR(_type, _d, _attr)
Definition clientutil.hpp:152
Definition location.hpp:10
RoomVisibility
Definition client-model.hpp:40
DeviceTrustLevel
Definition device-list-tracker.hpp:27
lager::dep::key< SdkModelCursorTag, lager::dep::fn< std::shared_ptr< lager::reader< SdkModel > > > > SdkModelCursorKey
Definition sdk-model-cursor-tag.hpp:23
detail::IntoImmerT intoImmer
Definition cursorutil.hpp:88
std::pair< std::string, std::string > mxcUriToMediaDesc(std::string mxcUri)
Definition content.cpp:17
std::variant< RoomListAction, LoginAction, TokenLoginAction, MLoginTokenLoginAction, LogoutAction, HardLogoutAction, GetWellknownAction, GetVersionsAction, SyncAction, SetShouldSyncAction, PostInitialFiltersAction, SetAccountDataAction, PaginateTimelineAction, SendMessageAction, SendStateEventAction, SaveLocalEchoAction, UpdateLocalEchoStatusAction, RedactEventAction, CreateRoomAction, GetRoomStatesAction, GetStateEventAction, InviteToRoomAction, JoinRoomByIdAction, JoinRoomAction, LeaveRoomAction, ForgetRoomAction, KickAction, BanAction, UnbanAction, SetAccountDataPerRoomAction, ProcessResponseAction, SetTypingAction, PostReceiptAction, SetReadMarkerAction, UploadContentAction, DownloadContentAction, DownloadThumbnailAction, SendToDeviceMessageAction, SendMultipleToDeviceMessagesAction, UploadIdentityKeysAction, GenerateAndUploadOneTimeKeysAction, QueryKeysAction, EnsureKeysFromDevicesAction, ClaimKeysAction, EncryptMegOlmEventAction, SetDeviceTrustLevelAction, SetDevicesTrustLevelsAction, SetTrustLevelNeededToSendKeysAction, PrepareForSharingRoomKeyAction, ImportFromKeyBackupFileAction, NotifyVerificationTrackerModelAction, GetUserProfileAction, SetAvatarUrlAction, SetDisplayNameAction, ResubmitJobAction, LoadEventsFromStorageAction, PurgeRoomTimelineAction > ClientAction
Definition clientfwd.hpp:160
immer::flex_vector< Event > EventList
Definition types.hpp:107
Definition clientutil.hpp:140
Definition client-model.hpp:59
RoomListModel roomList
Definition client-model.hpp:76
bool syncing
Definition client-model.hpp:66
Definition client.hpp:102
Definition jobinterface.hpp:21
immer::map< std::string, RoomModel > rooms
Definition room-model.hpp:420
Definition sdk-model.hpp:26
A stateful tracker for all verification processes.
Definition verification-tracker.hpp:98
#define KAZV_DECLARE_EVENT_LOOP_THREAD_ID_KEEPER(_initializer)
Definition thread-safety-helper.hpp:75