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,
bool attachSenderDeviceKeys =
false);
137 using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
138 if constexpr (std::is_same_v<ResT, void>) {
140 .update([f=std::forward<Func>(func)](
Crypto c)
mutable {
141 std::forward<Func>(f)(c);
145 std::optional<ResT> res;
147 .update([f=std::forward<Func>(func), &res](
Crypto c)
mutable {
148 res = std::forward<Func>(f)(c);
151 return std::move(res).value();
159 template<
class ...Args>
160 constexpr auto make(Args &&...args)
const {
161 if constexpr (Job::needsAuth()) {
165 std::forward<Args>(args)...);
169 std::forward<Args>(args)...);
178 constexpr auto job()
const {
273 std::optional<std::string>
txnId{std::nullopt};
296 std::optional<std::string>
txnId{std::nullopt};
328 std::optional<std::string>
name;
443 std::optional<ThumbnailResizingMethod>
method;
471 std::optional<std::string>
txnId{std::nullopt};
484 std::optional<std::string>
txnId{std::nullopt};
703 template<
class Archive>
706 bool dummySyncing{
false};
735 if constexpr (
typename Archive::is_loading()) {
736 std::optional<Crypto> crypto;
738 if (crypto.has_value()) {
739 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:162
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::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:164
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
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition client-model.hpp:704
Definition clientutil.hpp:140
Device identity keys.
Definition device_keys.hpp:13
Definition client-model.hpp:387
std::optional< std::string > reason
Definition client-model.hpp:390
std::string roomId
Definition client-model.hpp:388
std::string userId
Definition client-model.hpp:389
Definition client-model.hpp:555
std::string roomId
Definition client-model.hpp:557
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string > > devicesToSend)
Definition client-model.cpp:352
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:560
RandomData random
Definition client-model.hpp:561
std::string sessionId
Definition client-model.hpp:558
std::string sessionKey
Definition client-model.hpp:559
Definition client-model.hpp:158
constexpr auto make(Args &&...args) const
Definition client-model.hpp:160
std::string serverUrl
Definition client-model.hpp:173
std::string token
Definition client-model.hpp:174
Definition client-model.hpp:59
auto popAllTriggers()
Definition client-model.hpp:200
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:135
std::string userId
Definition client-model.hpp:61
void maybeAddSaveEventsTrigger(const ClientModel &old)
Definition client-model.cpp:479
int syncTimeoutMs
Definition client-model.hpp:71
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition client-model.cpp:474
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:208
std::optional< immer::box< Crypto > > crypto
Definition client-model.hpp:85
auto popAllJobs()
Definition client-model.hpp:186
immer::map< std::string, Event > presence
Definition client-model.hpp:77
std::size_t numOneTimeKeysNeeded() const
Definition client-model.cpp:310
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:454
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:192
void addTriggers(immer::flex_vector< KazvTrigger > c)
Definition client-model.hpp:196
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:210
void addJob(BaseJob j)
Definition client-model.hpp:182
immer::flex_vector< BaseJob > nextJobs
Definition client-model.hpp:81
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition client-model.cpp:415
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:360
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:178
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:438
std::optional< std::string > syncToken
Definition client-model.hpp:74
std::string deviceId
Definition client-model.hpp:63
Definition client-model.hpp:323
std::optional< std::string > name
Definition client-model.hpp:328
JsonWrap creationContent
Definition client-model.hpp:333
immer::array< std::string > invite
Definition client-model.hpp:330
std::optional< Preset > preset
Definition client-model.hpp:335
std::optional< std::string > roomVersion
Definition client-model.hpp:332
std::optional< std::string > roomAliasName
Definition client-model.hpp:327
std::optional< bool > isDirect
Definition client-model.hpp:336
JsonWrap powerLevelContentOverride
Definition client-model.hpp:337
Visibility visibility
Definition client-model.hpp:326
immer::array< Event > initialState
Definition client-model.hpp:334
std::optional< std::string > topic
Definition client-model.hpp:329
Definition device-list-tracker.hpp:58
Definition client-model.hpp:433
std::string mxcUri
Definition client-model.hpp:434
std::optional< FileDesc > downloadTo
Definition client-model.hpp:435
Definition client-model.hpp:439
std::string mxcUri
Definition client-model.hpp:440
std::optional< FileDesc > downloadTo
Definition client-model.hpp:445
std::optional< ThumbnailResizingMethod > method
Definition client-model.hpp:443
std::optional< bool > allowRemote
Definition client-model.hpp:444
int width
Definition client-model.hpp:441
int height
Definition client-model.hpp:442
The action to encrypt an megolm event for a room.
Definition client-model.hpp:583
static std::size_t maxRandomSize()
Definition client-model.cpp:329
static std::size_t minRandomSize()
Definition client-model.cpp:334
Event e
The event to encrypt.
Definition client-model.hpp:590
RandomData random
Random data for the operation.
Definition client-model.hpp:596
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition client-model.hpp:592
std::string roomId
The id of the room to encrypt for.
Definition client-model.hpp:588
Ensure keys from devices of a user.
Definition client-model.hpp:539
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:551
Definition client-model.hpp:375
std::string roomId
Definition client-model.hpp:376
The action to generate one-time keys.
Definition client-model.hpp:499
static std::size_t randomSize(std::size_t numToGen)
Definition client-model.cpp:347
RandomData random
The random data used to generate keys.
Definition client-model.hpp:506
std::size_t numToGen
The number of keys to generate.
Definition client-model.hpp:504
Definition client-model.hpp:341
std::string roomId
Definition client-model.hpp:342
Definition client-model.hpp:346
std::string stateKey
Definition client-model.hpp:349
std::string type
Definition client-model.hpp:348
std::string roomId
Definition client-model.hpp:347
Definition client-model.hpp:667
std::string userId
Definition client-model.hpp:668
Definition client-model.hpp:250
std::string serverUrl
Definition client-model.hpp:251
Definition client-model.hpp:245
std::string userId
Definition client-model.hpp:246
Definition client-model.hpp:242
Import keys from key backup file.
Definition client-model.hpp:654
std::string fileContent
The content of the key backup file.
Definition client-model.hpp:656
std::string password
The password.
Definition client-model.hpp:658
Definition client-model.hpp:353
std::string userId
Definition client-model.hpp:355
std::string roomId
Definition client-model.hpp:354
Definition client-model.hpp:364
immer::array< std::string > serverName
Definition client-model.hpp:366
std::string roomIdOrAlias
Definition client-model.hpp:365
Definition client-model.hpp:359
std::string roomId
Definition client-model.hpp:360
Definition client-model.hpp:380
std::string roomId
Definition client-model.hpp:381
std::string userId
Definition client-model.hpp:382
std::optional< std::string > reason
Definition client-model.hpp:383
Definition client-model.hpp:370
std::string roomId
Definition client-model.hpp:371
Load events from the storage into the model.
Definition client-model.hpp:683
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:692
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:686
Status
Definition local-echo.hpp:21
Definition client-model.hpp:216
std::string password
Definition client-model.hpp:219
std::string serverUrl
Definition client-model.hpp:217
std::string username
Definition client-model.hpp:218
std::optional< std::string > deviceName
Definition client-model.hpp:220
Definition client-model.hpp:241
Login using the m.token.login flow.
Definition client-model.hpp:235
std::string loginToken
Definition client-model.hpp:237
std::string serverUrl
Definition client-model.hpp:236
std::optional< std::string > deviceName
Definition client-model.hpp:238
Notify that the verification tracker model has been changed.
Definition client-model.hpp:664
Definition client-model.hpp:262
std::string fromEventId
Must be where the Gap is.
Definition client-model.hpp:265
std::optional< int > limit
Definition client-model.hpp:266
std::string roomId
Definition client-model.hpp:263
Definition client-model.hpp:459
Definition client-model.hpp:413
std::string eventId
Definition client-model.hpp:415
std::string roomId
Definition client-model.hpp:414
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition client-model.hpp:631
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition client-model.hpp:632
Event e
The key event to encrypt.
Definition client-model.hpp:640
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition client-model.hpp:638
std::string roomId
The room to share the key event in.
Definition client-model.hpp:636
RandomData random
The random data for the encryption.
Definition client-model.hpp:643
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition client-model.cpp:339
Definition client-model.hpp:454
Response response
Definition client-model.hpp:455
Remove events from the model, keeping only the latest maxToKeep events.
Definition client-model.hpp:698
immer::map< std::string, std::size_t > roomIdToMaxToKeepMap
A map from roomId to maxToKeep.
Definition client-model.hpp:700
Definition client-model.hpp:510
bool isInitialSync
Definition client-model.hpp:511
Definition client-model.hpp:316
std::string eventId
Definition client-model.hpp:318
std::optional< std::string > reason
Definition client-model.hpp:319
std::string roomId
Definition client-model.hpp:317
Definition basejob.hpp:49
Definition client-model.hpp:449
BaseJob job
Definition client-model.hpp:450
Definition room-model.hpp:450
Saves an local echo.
Definition client-model.hpp:290
std::string roomId
The room id.
Definition client-model.hpp:292
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition client-model.hpp:296
Event event
The event to send.
Definition client-model.hpp:294
Definition client-model.hpp:270
std::optional< std::string > txnId
Definition client-model.hpp:273
std::string roomId
Definition client-model.hpp:271
Event event
Definition client-model.hpp:272
Send multiple to device messages.
Definition client-model.hpp:480
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition client-model.hpp:484
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:482
Definition client-model.hpp:277
Event event
Definition client-model.hpp:279
std::string roomId
Definition client-model.hpp:278
Definition client-model.hpp:468
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:470
std::optional< std::string > txnId
Definition client-model.hpp:471
Event event
Definition client-model.hpp:469
Definition client-model.hpp:463
Event accountDataEvent
Definition client-model.hpp:464
Definition client-model.hpp:400
std::string roomId
Definition client-model.hpp:401
Event accountDataEvent
Definition client-model.hpp:402
Definition client-model.hpp:672
std::optional< std::string > avatarUrl
Definition client-model.hpp:673
Definition client-model.hpp:600
std::string userId
Definition client-model.hpp:601
DeviceTrustLevel trustLevel
Definition client-model.hpp:603
std::string deviceId
Definition client-model.hpp:602
Set the trust levels of devices.
Definition client-model.hpp:615
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:619
Definition client-model.hpp:677
std::optional< std::string > displayName
Definition client-model.hpp:678
Definition client-model.hpp:419
std::string eventId
Definition client-model.hpp:421
std::string roomId
Definition client-model.hpp:420
Definition client-model.hpp:257
bool shouldSync
Definition client-model.hpp:258
Definition client-model.hpp:623
DeviceTrustLevel trustLevel
Definition client-model.hpp:624
Definition client-model.hpp:406
bool typing
Definition client-model.hpp:408
std::optional< int > timeoutMs
Definition client-model.hpp:409
std::string roomId
Definition client-model.hpp:407
Definition client-model.hpp:254
Definition client-model.hpp:224
std::string username
Definition client-model.hpp:226
std::string serverUrl
Definition client-model.hpp:225
std::string deviceId
Definition client-model.hpp:228
std::string token
Definition client-model.hpp:227
Definition client-model.hpp:394
std::string roomId
Definition client-model.hpp:395
std::string userId
Definition client-model.hpp:396
Updates the status of an local echo.
Definition client-model.hpp:306
std::string roomId
The room id.
Definition client-model.hpp:308
LocalEchoDesc::Status status
The updated status of this local echo.
Definition client-model.hpp:312
std::string txnId
The chosen txnId for this event.
Definition client-model.hpp:310
Definition client-model.hpp:425
std::string uploadId
Definition client-model.hpp:429
std::optional< std::string > contentType
Definition client-model.hpp:428
std::optional< std::string > filename
Definition client-model.hpp:427
FileDesc content
Definition client-model.hpp:426
Definition client-model.hpp:488