16#include <lager/context.hpp>
17#include <boost/hana.hpp>
85 std::optional<immer::box<Crypto>>
crypto;
99 std::pair<Event, std::optional<std::string> >
104 immer::map<std::string, immer::map<std::string, Event>>
olmEncryptSplit(
Event e, immer::map<std::string, immer::flex_vector<std::string>> userIdToDeviceIdMap,
RandomData random);
127 using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
128 if constexpr (std::is_same_v<ResT, void>) {
130 .update([f=std::forward<Func>(func)](
Crypto c)
mutable {
131 std::forward<Func>(f)(c);
135 std::optional<ResT> res;
137 .update([f=std::forward<Func>(func), &res](
Crypto c)
mutable {
138 res = std::forward<Func>(f)(c);
141 return std::move(res).value();
149 template<
class ...Args>
150 constexpr auto make(Args &&...args)
const {
151 if constexpr (Job::needsAuth()) {
155 std::forward<Args>(args)...);
159 std::forward<Args>(args)...);
168 constexpr auto job()
const {
263 std::optional<std::string>
txnId{std::nullopt};
286 std::optional<std::string>
txnId{std::nullopt};
318 std::optional<std::string>
name;
433 std::optional<ThumbnailResizingMethod>
method;
461 std::optional<std::string>
txnId{std::nullopt};
474 std::optional<std::string>
txnId{std::nullopt};
632 template<
class Archive>
635 bool dummySyncing{
false};
664 if constexpr (
typename Archive::is_loading()) {
665 std::optional<Crypto> crypto;
667 if (crypto.has_value()) {
668 m.
crypto = immer::box<Crypto>(std::move(crypto).value());
Definition basejob.hpp:68
Definition context.hpp:205
Definition file-desc.hpp:225
Definition jsonwrap.hpp:23
Definition location.hpp:10
CreateRoomPreset
Definition client-model.hpp:46
@ TrustedPrivateChat
Definition client-model.hpp:49
@ PublicChat
Definition client-model.hpp:48
@ PrivateChat
Definition client-model.hpp:47
RoomVisibility
Definition client-model.hpp:40
@ Public
Definition client-model.hpp:42
@ Private
Definition client-model.hpp:41
Effect< ClientAction, lager::deps<> > ClientEffect
Definition clientfwd.hpp:156
DeviceTrustLevel
Definition device-list-tracker.hpp:27
@ Unseen
Definition device-list-tracker.hpp:29
std::string RandomData
Definition crypto-util.hpp:35
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
const std::string DEFTXNID
Definition client-model.hpp:37
std::int_fast64_t Timestamp
Definition event.hpp:18
ThumbnailResizingMethod
Definition client-model.hpp:53
@ Crop
Definition client-model.hpp:54
@ Scale
Definition client-model.hpp:55
constexpr detail::DefaultValT DEFVAL
Definition types.hpp:125
std::pair< ClientModel, ClientEffect > ClientResult
Definition clientfwd.hpp:158
std::variant< std::monostate, ReceivingPresenceEvent, ReceivingAccountDataEvent, ReceivingRoomTimelineEvent, ReceivingRoomStateEvent, RoomMembershipChanged, ReceivingRoomAccountDataEvent, ReceivingToDeviceMessage, LoginSuccessful, LoginFailed, SaveEventsRequested, UnrecognizedResponse > KazvTrigger
Definition kazv-triggers.hpp:99
immer::flex_vector< Event > EventList
Definition types.hpp:107
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition client-model.hpp:633
Definition clientutil.hpp:140
Definition client-model.hpp:377
std::optional< std::string > reason
Definition client-model.hpp:380
std::string roomId
Definition client-model.hpp:378
std::string userId
Definition client-model.hpp:379
Definition client-model.hpp:505
std::string roomId
Definition client-model.hpp:507
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string > > devicesToSend)
Definition client-model.cpp:308
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:510
RandomData random
Definition client-model.hpp:511
std::string sessionId
Definition client-model.hpp:508
std::string sessionKey
Definition client-model.hpp:509
Definition client-model.hpp:148
constexpr auto make(Args &&...args) const
Definition client-model.hpp:150
std::string serverUrl
Definition client-model.hpp:163
std::string token
Definition client-model.hpp:164
Definition client-model.hpp:59
auto popAllTriggers()
Definition client-model.hpp:190
RoomListModel roomList
Definition client-model.hpp:76
auto withCrypto(Func &&func) -> std::decay_t< std::invoke_result_t< Func &&, Crypto & > >
Do func with crypto, returning its return value.
Definition client-model.hpp:125
std::string userId
Definition client-model.hpp:61
void maybeAddSaveEventsTrigger(const ClientModel &old)
Definition client-model.cpp:435
int syncTimeoutMs
Definition client-model.hpp:71
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition client-model.cpp:430
immer::flex_vector< std::string > devicesToSendKeys(std::string userId) const
Definition client-model.cpp:242
int firstRetryMs
Definition client-model.hpp:68
DeviceListTracker deviceLists
Definition client-model.hpp:88
bool identityKeysUploaded
Definition client-model.hpp:86
immer::flex_vector< KazvTrigger > nextTriggers
Definition client-model.hpp:82
int maxRetryMs
Definition client-model.hpp:70
ClientAction Action
Definition client-model.hpp:198
std::optional< immer::box< Crypto > > crypto
Definition client-model.hpp:85
auto popAllJobs()
Definition client-model.hpp:176
immer::map< std::string, Event > presence
Definition client-model.hpp:77
std::size_t numOneTimeKeysNeeded() const
Definition client-model.cpp:266
immer::map< std::string, immer::map< std::string, Event > > olmEncryptSplit(Event e, immer::map< std::string, immer::flex_vector< std::string > > userIdToDeviceIdMap, RandomData random)
precondition: the one-time keys for those devices must already be claimed
Definition client-model.cpp:186
std::string serverUrl
Definition client-model.hpp:60
auto roomIdsByTagId() const -> immer::map< std::string, immer::map< std::string, double > >
Definition client-model.cpp:410
immer::map< std::string, Event > accountData
Definition client-model.hpp:78
static Result update(ClientModel m, Action a)
Definition client-model.cpp:41
void addTrigger(KazvTrigger t)
Definition client-model.hpp:182
void addTriggers(immer::flex_vector< KazvTrigger > c)
Definition client-model.hpp:186
bool shouldSync
Definition client-model.hpp:67
std::string incrementalSyncFilterId
Definition client-model.hpp:73
ClientResult Result
Definition client-model.hpp:200
void addJob(BaseJob j)
Definition client-model.hpp:172
immer::flex_vector< BaseJob > nextJobs
Definition client-model.hpp:81
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition client-model.cpp:371
int retryTimeFactor
Definition client-model.hpp:69
DeviceTrustLevel trustLevelNeededToSendKeys
Definition client-model.hpp:89
void maybeRotateSessions(ClientModel oldClient)
rotate sessions for a room if there is a user in the room with devicesToSendKeys changes
Definition client-model.cpp:316
std::string initialSyncFilterId
Definition client-model.hpp:72
bool syncing
Definition client-model.hpp:66
std::string token
Definition client-model.hpp:62
std::string nextTxnId
Definition client-model.hpp:80
constexpr auto job() const
Definition client-model.hpp:168
immer::array< std::string > versions
Definition client-model.hpp:91
bool loggedIn
Definition client-model.hpp:64
EventList toDevice
Definition client-model.hpp:84
std::pair< Event, std::optional< std::string > > megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random)
Definition client-model.cpp:134
auto roomIdsUnderTag(std::string tagId) const -> immer::map< std::string, double >
Definition client-model.cpp:394
std::optional< std::string > syncToken
Definition client-model.hpp:74
std::string deviceId
Definition client-model.hpp:63
Definition client-model.hpp:313
std::optional< std::string > name
Definition client-model.hpp:318
JsonWrap creationContent
Definition client-model.hpp:323
immer::array< std::string > invite
Definition client-model.hpp:320
std::optional< Preset > preset
Definition client-model.hpp:325
std::optional< std::string > roomVersion
Definition client-model.hpp:322
std::optional< std::string > roomAliasName
Definition client-model.hpp:317
std::optional< bool > isDirect
Definition client-model.hpp:326
JsonWrap powerLevelContentOverride
Definition client-model.hpp:327
Visibility visibility
Definition client-model.hpp:316
immer::array< Event > initialState
Definition client-model.hpp:324
std::optional< std::string > topic
Definition client-model.hpp:319
Definition device-list-tracker.hpp:58
Definition client-model.hpp:423
std::string mxcUri
Definition client-model.hpp:424
std::optional< FileDesc > downloadTo
Definition client-model.hpp:425
Definition client-model.hpp:429
std::string mxcUri
Definition client-model.hpp:430
std::optional< FileDesc > downloadTo
Definition client-model.hpp:435
std::optional< ThumbnailResizingMethod > method
Definition client-model.hpp:433
std::optional< bool > allowRemote
Definition client-model.hpp:434
int width
Definition client-model.hpp:431
int height
Definition client-model.hpp:432
The action to encrypt an megolm event for a room.
Definition client-model.hpp:533
static std::size_t maxRandomSize()
Definition client-model.cpp:285
static std::size_t minRandomSize()
Definition client-model.cpp:290
Event e
The event to encrypt.
Definition client-model.hpp:540
RandomData random
Random data for the operation.
Definition client-model.hpp:546
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition client-model.hpp:542
std::string roomId
The id of the room to encrypt for.
Definition client-model.hpp:538
Definition client-model.hpp:365
std::string roomId
Definition client-model.hpp:366
The action to generate one-time keys.
Definition client-model.hpp:489
static std::size_t randomSize(std::size_t numToGen)
Definition client-model.cpp:303
RandomData random
The random data used to generate keys.
Definition client-model.hpp:496
std::size_t numToGen
The number of keys to generate.
Definition client-model.hpp:494
Definition client-model.hpp:331
std::string roomId
Definition client-model.hpp:332
Definition client-model.hpp:336
std::string stateKey
Definition client-model.hpp:339
std::string type
Definition client-model.hpp:338
std::string roomId
Definition client-model.hpp:337
Definition client-model.hpp:596
std::string userId
Definition client-model.hpp:597
Definition client-model.hpp:240
std::string serverUrl
Definition client-model.hpp:241
Definition client-model.hpp:235
std::string userId
Definition client-model.hpp:236
Definition client-model.hpp:232
Import keys from key backup file.
Definition client-model.hpp:588
std::string fileContent
The content of the key backup file.
Definition client-model.hpp:590
std::string password
The password.
Definition client-model.hpp:592
Definition client-model.hpp:343
std::string userId
Definition client-model.hpp:345
std::string roomId
Definition client-model.hpp:344
Definition client-model.hpp:354
immer::array< std::string > serverName
Definition client-model.hpp:356
std::string roomIdOrAlias
Definition client-model.hpp:355
Definition client-model.hpp:349
std::string roomId
Definition client-model.hpp:350
Definition client-model.hpp:370
std::string roomId
Definition client-model.hpp:371
std::string userId
Definition client-model.hpp:372
std::optional< std::string > reason
Definition client-model.hpp:373
Definition client-model.hpp:360
std::string roomId
Definition client-model.hpp:361
Load events from the storage into the model.
Definition client-model.hpp:612
immer::map< std::string, EventList > relatedEvents
Map from room id to a list of related events that should not be put into the timeline.
Definition client-model.hpp:621
immer::map< std::string, EventList > timelineEvents
Map from room id to a list of loaded events that should be put into the timeline.
Definition client-model.hpp:615
Status
Definition local-echo.hpp:21
Definition client-model.hpp:206
std::string password
Definition client-model.hpp:209
std::string serverUrl
Definition client-model.hpp:207
std::string username
Definition client-model.hpp:208
std::optional< std::string > deviceName
Definition client-model.hpp:210
Definition client-model.hpp:231
Login using the m.token.login flow.
Definition client-model.hpp:225
std::string loginToken
Definition client-model.hpp:227
std::string serverUrl
Definition client-model.hpp:226
std::optional< std::string > deviceName
Definition client-model.hpp:228
Definition client-model.hpp:252
std::string fromEventId
Must be where the Gap is.
Definition client-model.hpp:255
std::optional< int > limit
Definition client-model.hpp:256
std::string roomId
Definition client-model.hpp:253
Definition client-model.hpp:449
Definition client-model.hpp:403
std::string eventId
Definition client-model.hpp:405
std::string roomId
Definition client-model.hpp:404
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition client-model.hpp:565
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition client-model.hpp:566
Event e
The key event to encrypt.
Definition client-model.hpp:574
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition client-model.hpp:572
std::string roomId
The room to share the key event in.
Definition client-model.hpp:570
RandomData random
The random data for the encryption.
Definition client-model.hpp:577
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition client-model.cpp:295
Definition client-model.hpp:444
Response response
Definition client-model.hpp:445
Remove events from the model, keeping only the latest maxToKeep events.
Definition client-model.hpp:627
immer::map< std::string, std::size_t > roomIdToMaxToKeepMap
A map from roomId to maxToKeep.
Definition client-model.hpp:629
Definition client-model.hpp:500
bool isInitialSync
Definition client-model.hpp:501
Definition client-model.hpp:306
std::string eventId
Definition client-model.hpp:308
std::optional< std::string > reason
Definition client-model.hpp:309
std::string roomId
Definition client-model.hpp:307
Definition basejob.hpp:49
Definition client-model.hpp:439
BaseJob job
Definition client-model.hpp:440
Definition room-model.hpp:409
Saves an local echo.
Definition client-model.hpp:280
std::string roomId
The room id.
Definition client-model.hpp:282
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition client-model.hpp:286
Event event
The event to send.
Definition client-model.hpp:284
Definition client-model.hpp:260
std::optional< std::string > txnId
Definition client-model.hpp:263
std::string roomId
Definition client-model.hpp:261
Event event
Definition client-model.hpp:262
Send multiple to device messages.
Definition client-model.hpp:470
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition client-model.hpp:474
immer::map< std::string, immer::map< std::string, Event > > userToDeviceToEventMap
A map from user id to device id to the event.
Definition client-model.hpp:472
Definition client-model.hpp:267
Event event
Definition client-model.hpp:269
std::string roomId
Definition client-model.hpp:268
Definition client-model.hpp:458
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:460
std::optional< std::string > txnId
Definition client-model.hpp:461
Event event
Definition client-model.hpp:459
Definition client-model.hpp:453
Event accountDataEvent
Definition client-model.hpp:454
Definition client-model.hpp:390
std::string roomId
Definition client-model.hpp:391
Event accountDataEvent
Definition client-model.hpp:392
Definition client-model.hpp:601
std::optional< std::string > avatarUrl
Definition client-model.hpp:602
Definition client-model.hpp:550
std::string userId
Definition client-model.hpp:551
DeviceTrustLevel trustLevel
Definition client-model.hpp:553
std::string deviceId
Definition client-model.hpp:552
Definition client-model.hpp:606
std::optional< std::string > displayName
Definition client-model.hpp:607
Definition client-model.hpp:409
std::string eventId
Definition client-model.hpp:411
std::string roomId
Definition client-model.hpp:410
Definition client-model.hpp:247
bool shouldSync
Definition client-model.hpp:248
Definition client-model.hpp:557
DeviceTrustLevel trustLevel
Definition client-model.hpp:558
Definition client-model.hpp:396
bool typing
Definition client-model.hpp:398
std::optional< int > timeoutMs
Definition client-model.hpp:399
std::string roomId
Definition client-model.hpp:397
Definition client-model.hpp:244
Definition client-model.hpp:214
std::string username
Definition client-model.hpp:216
std::string serverUrl
Definition client-model.hpp:215
std::string deviceId
Definition client-model.hpp:218
std::string token
Definition client-model.hpp:217
Definition client-model.hpp:384
std::string roomId
Definition client-model.hpp:385
std::string userId
Definition client-model.hpp:386
Updates the status of an local echo.
Definition client-model.hpp:296
std::string roomId
The room id.
Definition client-model.hpp:298
LocalEchoDesc::Status status
The updated status of this local echo.
Definition client-model.hpp:302
std::string txnId
The chosen txnId for this event.
Definition client-model.hpp:300
Definition client-model.hpp:415
std::string uploadId
Definition client-model.hpp:419
std::optional< std::string > contentType
Definition client-model.hpp:418
std::optional< std::string > filename
Definition client-model.hpp:417
FileDesc content
Definition client-model.hpp:416
Definition client-model.hpp:478