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>
65#ifdef KAZV_USE_THREAD_SAFETY_HELPER
66 , EventLoopThreadIdKeeper &
84 Client(lager::reader<SdkModel> sdk,
97 Client(lager::reader<SdkModel> sdk,
140 return clientCursor()
147 return rooms().xform(
148 zug::map([](
auto m) {
150 immer::flex_vector<std::string>{},
151 zug::map([](
auto val) {
return val.first; }),
156 auto roomIdsUnderTag(std::string tagId)
const -> lager::reader<immer::map<std::string, double>>;
164 auto roomIdsByTagId() const -> lager::reader<immer::map<
std::
string, immer::map<
std::
string,
double>>>;
228 std::
string password,
std::
string deviceName) const;
246 std::
string token,
std::
string deviceId) const;
264 std::
string homeserver,
265 std::
string loginToken,
266 std::optional<
std::
string> deviceName
274 auto
shouldSync() const -> lager::reader<
bool>;
319 std::optional<
std::
string> name = {},
320 std::optional<std::string> alias = {},
321 immer::array<std::string> invite = {},
322 std::optional<bool> isDirect = {},
323 bool allowFederate =
true,
324 std::optional<std::string> topic = {},
325 JsonWrap powerLevelContentOverride = json::object(),
326 std::optional<CreateRoomPreset> preset = std::nullopt,
327 immer::array<Event> initialState = immer::array<Event>()
348 PromiseT joinRoom(std::string roomId, immer::array<std::string> serverName)
const;
363 std::string uploadId,
364 std::optional<std::string> filename = std::nullopt,
365 std::optional<std::string> contentType = std::nullopt)
const;
390 using namespace CursorOp;
392 return (+clientCursor())
393 .template job<GetContentJob>()
394 .make(serverName, mediaId).url();
424 std::optional<FileDesc> downloadTo = std::nullopt)
const;
446 std::optional<ThumbnailResizingMethod> method = std::nullopt,
447 std::optional<FileDesc> downloadTo = std::nullopt)
const;
512 auto devicesOfUser(std::string userId)
const -> lager::reader<immer::flex_vector<DeviceKeyInfo>>;
585 template<class Archive>
587 ar << sdkCursor().get();
661 void syncForever(
std::optional<
int> retryTime =
std::nullopt) const;
663 const lager::reader<
SdkModel> &sdkCursor() const;
670 KAZV_DECLARE_THREAD_ID();
Definition basejob.hpp:68
Represent a Matrix client.
Definition client.hpp:60
PromiseT setAccountData(Event accountDataEvent) const
Set the account data that is not associated with any room.
Definition client.cpp:474
PromiseT setDisplayName(std::optional< std::string > displayName) const
Change the display name of the current user.
Definition client.cpp:418
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:452
Room roomByCursor(lager::reader< std::string > id) const
Get the room with id.
Definition client.cpp:77
auto roomIdsByTagId() const -> lager::reader< immer::map< std::string, immer::map< std::string, double > > >
Get the room ids under all tags.
Definition client.cpp:464
PromiseT setTrustLevelNeededToSendKeys(DeviceTrustLevel trustLevel) const
Set the trust level needed to send keys to a device.
Definition client.cpp:447
lager::deps< JobInterface &, EventInterface &, SdkModelCursorKey, RandomInterface & > DepsT
Definition client.hpp:69
PromiseT getVersions(std::string homeserver) const
Get all supported versions.
Definition client.cpp:484
PromiseT joinRoomById(std::string roomId) const
Join a room by its id.
Definition client.cpp:205
PromiseT joinRoom(std::string roomId, immer::array< std::string > serverName) const
Join a room by its id or alias.
Definition client.cpp:210
std::string mxcUriToHttp(std::string mxcUri) const
Convert a MXC URI to an HTTP(s) URI.
Definition client.hpp:389
auto trustLevelNeededToSendKeys() const -> lager::reader< DeviceTrustLevel >
Get the trust level needed to send keys to a device.
Definition client.cpp:442
NotificationHandler notificationHandler() const
Get a notification handler that works on this Client.
Definition client.cpp:479
Client toEventLoop() const
Create a Client that is not constructed from a cursor.
Definition client.cpp:62
auto syncing() const
Definition client.hpp:479
PromiseT setAvatarUrl(std::optional< std::string > avatarUrl) const
Change the avatar url of the current user.
Definition client.cpp:413
PromiseT mLoginTokenLogin(std::string homeserver, std::string loginToken, std::optional< std::string > deviceName) const
Login using a login token.
Definition client.cpp:105
SingleTypePromise< DefaultRetType > PromiseT
Definition client.hpp:73
PromiseT logout() const
Stop syncing and then logout current session.
Definition client.cpp:146
std::string mxcUriToHttpV1(std::string mxcUri) const
Convert a MXC URI to an HTTP(s) URI that needs Authorization.
Definition client.cpp:242
auto roomIds() const
Definition client.hpp:146
PromiseT purgeRoomEvents(immer::map< std::string, std::size_t > roomIdToMaxToKeepMap) const
Purge events in room, keeping the latest numToKeep events.
Definition client.cpp:524
Context< ActionT > ContextT
Definition client.hpp:70
PromiseT downloadContent(std::string mxcUri, std::optional< FileDesc > downloadTo=std::nullopt) const
Download content from the content repository.
Definition client.cpp:250
PromiseT stopSyncing() const
Stop the indefinite syncing.
Definition client.cpp:379
BaseJob getRoomIdByAliasJob(std::string roomAlias) const
Get a GetRoomIdByAliasJob.
Definition client.cpp:519
auto accountData() const -> lager::reader< immer::map< std::string, Event > >
Get the account data that is not associated with any room.
Definition client.cpp:469
void serializeTo(Archive &ar) const
Serialize the model to a Boost.Serialization archive.
Definition client.hpp:586
auto shouldSync() const -> lager::reader< bool >
Get the shouldSync field of current ClientModel.
Definition client.cpp:142
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:529
PromiseT setDeviceTrustLevel(std::string userId, std::string deviceId, DeviceTrustLevel trustLevel) const
Set the trust level of a device.
Definition client.cpp:437
Room room(std::string id) const
Get the room with id .
Definition client.cpp:68
ClientAction ActionT
Definition client.hpp:62
PromiseT autoDiscover(std::string userId) const
Automatically discover the homeserver for userId.
Definition client.cpp:154
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:494
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:423
PromiseT tokenLogin(std::string homeserver, std::string username, std::string token, std::string deviceId) const
Login using token and deviceId.
Definition client.cpp:125
auto supportVersions() const -> lager::reader< immer::array< std::string > >
Get all supported versions.
Definition client.cpp:489
PromiseT importFromKeyBackupFile(std::string fileContent, std::string password) const
Import keys from a key backup file.
Definition client.cpp:537
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:216
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:256
PromiseT getProfile(std::string userId) const
Fetch the profile of a user.
Definition client.cpp:408
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:173
auto roomIdsUnderTag(std::string tagId) const -> lager::reader< immer::map< std::string, double > >
Definition client.cpp:457
PromiseT passwordLogin(std::string homeserver, std::string username, std::string password, std::string deviceName) const
Login using the password.
Definition client.cpp:86
PromiseT startSyncing() const
Start syncing if the Client is not syncing.
Definition client.cpp:267
auto rooms() const
Definition client.hpp:139
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
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, ClaimKeysAction, EncryptMegOlmEventAction, SetDeviceTrustLevelAction, SetTrustLevelNeededToSendKeysAction, PrepareForSharingRoomKeyAction, ImportFromKeyBackupFileAction, GetUserProfileAction, SetAvatarUrlAction, SetDisplayNameAction, ResubmitJobAction, LoadEventsFromStorageAction, PurgeRoomTimelineAction > ClientAction
Definition clientfwd.hpp:154
detail::IntoImmerT intoImmer
Definition cursorutil.hpp:88
std::pair< std::string, std::string > mxcUriToMediaDesc(std::string mxcUri)
Definition content.cpp:17
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 jobinterface.hpp:21
immer::map< std::string, RoomModel > rooms
Definition room-model.hpp:410
Definition sdk-model.hpp:26
#define KAZV_DECLARE_EVENT_LOOP_THREAD_ID_KEEPER(_initializer)
Definition thread-safety-helper.hpp:75