16#include <lager/context.hpp>
17#include <boost/hana.hpp>
85 std::optional<immer::box<Crypto>>
crypto;
103 std::pair<Event, std::optional<std::string> >
108 immer::map<std::string, immer::map<std::string, Event>>
olmEncryptSplit(
Event e, immer::map<std::string, immer::flex_vector<std::string>> userIdToDeviceIdMap,
RandomData random,
bool attachSenderDeviceKeys =
false);
141 using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
142 if constexpr (std::is_same_v<ResT, void>) {
144 .update([f=std::forward<Func>(func)](
Crypto c)
mutable {
145 std::forward<Func>(f)(c);
149 std::optional<ResT> res;
151 .update([f=std::forward<Func>(func), &res](
Crypto c)
mutable {
152 res = std::forward<Func>(f)(c);
155 return std::move(res).value();
163 template<
class ...Args>
164 constexpr auto make(Args &&...args)
const {
165 if constexpr (Job::needsAuth()) {
169 std::forward<Args>(args)...);
173 std::forward<Args>(args)...);
182 constexpr auto job()
const {
277 std::optional<std::string>
txnId{std::nullopt};
300 std::optional<std::string>
txnId{std::nullopt};
332 std::optional<std::string>
name;
447 std::optional<ThumbnailResizingMethod>
method;
475 std::optional<std::string>
txnId{std::nullopt};
488 std::optional<std::string>
txnId{std::nullopt};
674 immer::map<std::string, immer::flex_vector<std::string>>
devices;
714 template<
class Archive>
717 bool dummySyncing{
false};
746 if constexpr (
typename Archive::is_loading()) {
747 std::optional<Crypto> crypto;
749 if (crypto.has_value()) {
750 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:164
std::variant< std::monostate, ReceivingPresenceEvent, ReceivingAccountDataEvent, ReceivingRoomTimelineEvent, ReceivingRoomStateEvent, RoomMembershipChanged, ReceivingRoomAccountDataEvent, ReceivingToDeviceMessage, LoginSuccessful, LoginFailed, SaveEventsRequested, VerificationTrackerModelChanged, UnrecognizedResponse > KazvTrigger
Definition kazv-triggers.hpp:103
DeviceTrustLevel
Definition device-list-tracker.hpp:27
@ Unseen
Definition device-list-tracker.hpp:29
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, RequestShareRoomSessionKeyAction, GetUserProfileAction, SetAvatarUrlAction, SetDisplayNameAction, ResubmitJobAction, LoadEventsFromStorageAction, PurgeRoomTimelineAction > ClientAction
Definition clientfwd.hpp:162
std::string RandomData
Definition crypto-util.hpp:35
nlohmann::json json
Definition jsonwrap.hpp:20
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:166
immer::flex_vector< Event > EventList
Definition types.hpp:107
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition client-model.hpp:715
Definition clientutil.hpp:140
Device identity keys.
Definition device_keys.hpp:13
Definition client-model.hpp:391
std::optional< std::string > reason
Definition client-model.hpp:394
std::string roomId
Definition client-model.hpp:392
std::string userId
Definition client-model.hpp:393
Definition client-model.hpp:559
std::string roomId
Definition client-model.hpp:561
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string > > devicesToSend)
Definition client-model.cpp:371
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:564
RandomData random
Definition client-model.hpp:565
std::string sessionId
Definition client-model.hpp:562
std::string sessionKey
Definition client-model.hpp:563
Definition client-model.hpp:162
constexpr auto make(Args &&...args) const
Definition client-model.hpp:164
std::string serverUrl
Definition client-model.hpp:177
std::string token
Definition client-model.hpp:178
Definition client-model.hpp:59
auto popAllTriggers()
Definition client-model.hpp:204
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:139
std::string userId
Definition client-model.hpp:61
void maybeAddSaveEventsTrigger(const ClientModel &old)
Definition client-model.cpp:498
int syncTimeoutMs
Definition client-model.hpp:71
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition client-model.cpp:493
immer::flex_vector< std::string > devicesToSendKeys(std::string userId) const
Definition client-model.cpp:286
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:212
std::optional< immer::box< Crypto > > crypto
Definition client-model.hpp:85
auto popAllJobs()
Definition client-model.hpp:190
immer::map< std::string, Event > presence
Definition client-model.hpp:77
std::size_t numOneTimeKeysNeeded() const
Definition client-model.cpp:329
json convertSignature(std::string signature) const
Convert a signature from Crypto into a json object.
Definition client-model.cpp:277
std::string serverUrl
Definition client-model.hpp:60
auto roomIdsByTagId() const -> immer::map< std::string, immer::map< std::string, double > >
Definition client-model.cpp:473
immer::map< std::string, Event > accountData
Definition client-model.hpp:78
DeviceKeys makeSelfDeviceKeys()
Make a struct of DeviceKeys for identity keys of the current device.
Definition client-model.cpp:251
static Result update(ClientModel m, Action a)
Definition client-model.cpp:41
void addTrigger(KazvTrigger t)
Definition client-model.hpp:196
void addTriggers(immer::flex_vector< KazvTrigger > c)
Definition client-model.hpp:200
immer::map< std::string, immer::map< std::string, Event > > olmEncryptSplit(Event e, immer::map< std::string, immer::flex_vector< std::string > > userIdToDeviceIdMap, RandomData random, bool attachSenderDeviceKeys=false)
precondition: the one-time keys for those devices must already be claimed
Definition client-model.cpp:186
bool shouldSync
Definition client-model.hpp:67
std::string incrementalSyncFilterId
Definition client-model.hpp:73
ClientResult Result
Definition client-model.hpp:214
void addJob(BaseJob j)
Definition client-model.hpp:186
immer::flex_vector< BaseJob > nextJobs
Definition client-model.hpp:81
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition client-model.cpp:434
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:379
std::string initialSyncFilterId
Definition client-model.hpp:72
bool syncing
Definition client-model.hpp:66
immer::map< std::string, immer::flex_vector< std::string > > devicesToRequestKeys() const
Definition client-model.cpp:311
std::string token
Definition client-model.hpp:62
std::string nextTxnId
Definition client-model.hpp:80
constexpr auto job() const
Definition client-model.hpp:182
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:457
std::optional< std::string > syncToken
Definition client-model.hpp:74
std::string deviceId
Definition client-model.hpp:63
Definition client-model.hpp:327
std::optional< std::string > name
Definition client-model.hpp:332
JsonWrap creationContent
Definition client-model.hpp:337
immer::array< std::string > invite
Definition client-model.hpp:334
std::optional< Preset > preset
Definition client-model.hpp:339
std::optional< std::string > roomVersion
Definition client-model.hpp:336
std::optional< std::string > roomAliasName
Definition client-model.hpp:331
std::optional< bool > isDirect
Definition client-model.hpp:340
JsonWrap powerLevelContentOverride
Definition client-model.hpp:341
Visibility visibility
Definition client-model.hpp:330
immer::array< Event > initialState
Definition client-model.hpp:338
std::optional< std::string > topic
Definition client-model.hpp:333
Definition device-list-tracker.hpp:68
Definition client-model.hpp:437
std::string mxcUri
Definition client-model.hpp:438
std::optional< FileDesc > downloadTo
Definition client-model.hpp:439
Definition client-model.hpp:443
std::string mxcUri
Definition client-model.hpp:444
std::optional< FileDesc > downloadTo
Definition client-model.hpp:449
std::optional< ThumbnailResizingMethod > method
Definition client-model.hpp:447
std::optional< bool > allowRemote
Definition client-model.hpp:448
int width
Definition client-model.hpp:445
int height
Definition client-model.hpp:446
The action to encrypt an megolm event for a room.
Definition client-model.hpp:587
static std::size_t maxRandomSize()
Definition client-model.cpp:348
static std::size_t minRandomSize()
Definition client-model.cpp:353
Event e
The event to encrypt.
Definition client-model.hpp:594
RandomData random
Random data for the operation.
Definition client-model.hpp:600
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition client-model.hpp:596
std::string roomId
The id of the room to encrypt for.
Definition client-model.hpp:592
Ensure keys from devices of a user.
Definition client-model.hpp:543
immer::map< std::string, immer::flex_vector< std::string > > userIdToDeviceIdsMap
The map detailing the devices of which the keys to be fetched.
Definition client-model.hpp:555
Definition client-model.hpp:379
std::string roomId
Definition client-model.hpp:380
The action to generate one-time keys.
Definition client-model.hpp:503
static std::size_t randomSize(std::size_t numToGen)
Definition client-model.cpp:366
RandomData random
The random data used to generate keys.
Definition client-model.hpp:510
std::size_t numToGen
The number of keys to generate.
Definition client-model.hpp:508
Definition client-model.hpp:345
std::string roomId
Definition client-model.hpp:346
Definition client-model.hpp:350
std::string stateKey
Definition client-model.hpp:353
std::string type
Definition client-model.hpp:352
std::string roomId
Definition client-model.hpp:351
Definition client-model.hpp:678
std::string userId
Definition client-model.hpp:679
Definition client-model.hpp:254
std::string serverUrl
Definition client-model.hpp:255
Definition client-model.hpp:249
std::string userId
Definition client-model.hpp:250
Definition client-model.hpp:246
Import keys from key backup file.
Definition client-model.hpp:658
std::string fileContent
The content of the key backup file.
Definition client-model.hpp:660
std::string password
The password.
Definition client-model.hpp:662
Definition client-model.hpp:357
std::string userId
Definition client-model.hpp:359
std::string roomId
Definition client-model.hpp:358
Definition client-model.hpp:368
immer::array< std::string > serverName
Definition client-model.hpp:370
std::string roomIdOrAlias
Definition client-model.hpp:369
Definition client-model.hpp:363
std::string roomId
Definition client-model.hpp:364
Definition client-model.hpp:384
std::string roomId
Definition client-model.hpp:385
std::string userId
Definition client-model.hpp:386
std::optional< std::string > reason
Definition client-model.hpp:387
Definition client-model.hpp:374
std::string roomId
Definition client-model.hpp:375
Load events from the storage into the model.
Definition client-model.hpp:694
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:703
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:697
Status
Definition local-echo.hpp:21
Definition client-model.hpp:220
std::string password
Definition client-model.hpp:223
std::string serverUrl
Definition client-model.hpp:221
std::string username
Definition client-model.hpp:222
std::optional< std::string > deviceName
Definition client-model.hpp:224
Definition client-model.hpp:245
Login using the m.token.login flow.
Definition client-model.hpp:239
std::string loginToken
Definition client-model.hpp:241
std::string serverUrl
Definition client-model.hpp:240
std::optional< std::string > deviceName
Definition client-model.hpp:242
Notify that the verification tracker model has been changed.
Definition client-model.hpp:668
Definition client-model.hpp:266
std::string fromEventId
Must be where the Gap is.
Definition client-model.hpp:269
std::optional< int > limit
Definition client-model.hpp:270
std::string roomId
Definition client-model.hpp:267
Definition client-model.hpp:463
Definition client-model.hpp:417
std::string eventId
Definition client-model.hpp:419
std::string roomId
Definition client-model.hpp:418
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition client-model.hpp:635
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition client-model.hpp:636
Event e
The key event to encrypt.
Definition client-model.hpp:644
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition client-model.hpp:642
std::string roomId
The room to share the key event in.
Definition client-model.hpp:640
RandomData random
The random data for the encryption.
Definition client-model.hpp:647
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition client-model.cpp:358
Definition client-model.hpp:458
Response response
Definition client-model.hpp:459
Remove events from the model, keeping only the latest maxToKeep events.
Definition client-model.hpp:709
immer::map< std::string, std::size_t > roomIdToMaxToKeepMap
A map from roomId to maxToKeep.
Definition client-model.hpp:711
Definition client-model.hpp:514
bool isInitialSync
Definition client-model.hpp:515
Definition client-model.hpp:320
std::string eventId
Definition client-model.hpp:322
std::optional< std::string > reason
Definition client-model.hpp:323
std::string roomId
Definition client-model.hpp:321
Definition client-model.hpp:671
immer::map< std::string, immer::flex_vector< std::string > > devices
Definition client-model.hpp:674
Event event
Definition client-model.hpp:673
std::string roomId
Definition client-model.hpp:672
Definition basejob.hpp:49
Definition client-model.hpp:453
BaseJob job
Definition client-model.hpp:454
Definition room-model.hpp:450
Saves an local echo.
Definition client-model.hpp:294
std::string roomId
The room id.
Definition client-model.hpp:296
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition client-model.hpp:300
Event event
The event to send.
Definition client-model.hpp:298
Definition client-model.hpp:274
std::optional< std::string > txnId
Definition client-model.hpp:277
std::string roomId
Definition client-model.hpp:275
Event event
Definition client-model.hpp:276
Send multiple to device messages.
Definition client-model.hpp:484
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition client-model.hpp:488
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:486
Definition client-model.hpp:281
Event event
Definition client-model.hpp:283
std::string roomId
Definition client-model.hpp:282
Definition client-model.hpp:472
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:474
std::optional< std::string > txnId
Definition client-model.hpp:475
Event event
Definition client-model.hpp:473
Definition client-model.hpp:467
Event accountDataEvent
Definition client-model.hpp:468
Definition client-model.hpp:404
std::string roomId
Definition client-model.hpp:405
Event accountDataEvent
Definition client-model.hpp:406
Definition client-model.hpp:683
std::optional< std::string > avatarUrl
Definition client-model.hpp:684
Definition client-model.hpp:604
std::string userId
Definition client-model.hpp:605
DeviceTrustLevel trustLevel
Definition client-model.hpp:607
std::string deviceId
Definition client-model.hpp:606
Set the trust levels of devices.
Definition client-model.hpp:619
immer::map< std::string, immer::map< std::string, DeviceTrustLevel > > trustLevelMap
A map from userId to deviceId to the trust level to set.
Definition client-model.hpp:623
Definition client-model.hpp:688
std::optional< std::string > displayName
Definition client-model.hpp:689
Definition client-model.hpp:423
std::string eventId
Definition client-model.hpp:425
std::string roomId
Definition client-model.hpp:424
Definition client-model.hpp:261
bool shouldSync
Definition client-model.hpp:262
Definition client-model.hpp:627
DeviceTrustLevel trustLevel
Definition client-model.hpp:628
Definition client-model.hpp:410
bool typing
Definition client-model.hpp:412
std::optional< int > timeoutMs
Definition client-model.hpp:413
std::string roomId
Definition client-model.hpp:411
Definition client-model.hpp:258
Definition client-model.hpp:228
std::string username
Definition client-model.hpp:230
std::string serverUrl
Definition client-model.hpp:229
std::string deviceId
Definition client-model.hpp:232
std::string token
Definition client-model.hpp:231
Definition client-model.hpp:398
std::string roomId
Definition client-model.hpp:399
std::string userId
Definition client-model.hpp:400
Updates the status of an local echo.
Definition client-model.hpp:310
std::string roomId
The room id.
Definition client-model.hpp:312
LocalEchoDesc::Status status
The updated status of this local echo.
Definition client-model.hpp:316
std::string txnId
The chosen txnId for this event.
Definition client-model.hpp:314
Definition client-model.hpp:429
std::string uploadId
Definition client-model.hpp:433
std::optional< std::string > contentType
Definition client-model.hpp:432
std::optional< std::string > filename
Definition client-model.hpp:431
FileDesc content
Definition client-model.hpp:430
Definition client-model.hpp:492