libkazv
Kazv::ClientModel Struct Reference

#include <client-model.hpp>

Collaboration diagram for Kazv::ClientModel:

Classes

struct  MakeJobT
 

Public Types

using Action = ClientAction
 
using Effect = ClientEffect
 
using Result = ClientResult
 

Public Member Functions

immer::flex_vector< std::string > devicesToSendKeys (std::string userId) const
 
void maybeRotateSessions (ClientModel oldClient)
 rotate sessions for a room if there is a user in the room with devicesToSendKeys changes More...
 
std::pair< Event, std::optional< std::string > > megOlmEncrypt (Event e, std::string roomId, Timestamp timeMs, RandomData random)
 
Event olmEncrypt (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 More...
 
std::size_t numOneTimeKeysNeeded () const
 
auto directRoomMap () const -> immer::map< std::string, std::string >
 
auto roomIdsUnderTag (std::string tagId) const -> immer::map< std::string, double >
 
auto roomIdsByTagId () const -> immer::map< std::string, immer::map< std::string, double >>
 
const CryptoconstCrypto () const
 Get the const reference of crypto of this client. More...
 
template<class Func >
auto withCrypto (Func &&func) -> std::decay_t< std::invoke_result_t< Func &&, Crypto & >>
 Do func with crypto, returning its return value. More...
 
template<class Job >
constexpr auto job () const
 
void addJob (BaseJob j)
 
auto popAllJobs ()
 
void addTrigger (KazvEvent t)
 
void addTriggers (immer::flex_vector< KazvEvent > c)
 
auto popAllTriggers ()
 

Static Public Member Functions

static Result update (ClientModel m, Action a)
 

Public Attributes

std::string serverUrl
 
std::string userId
 
std::string token
 
std::string deviceId
 
bool loggedIn {false}
 
bool syncing {false}
 
bool shouldSync {true}
 
int firstRetryMs {1000}
 
int retryTimeFactor {2}
 
int maxRetryMs {30 * 1000}
 
int syncTimeoutMs {20000}
 
std::string initialSyncFilterId
 
std::string incrementalSyncFilterId
 
std::optional< std::string > syncToken
 
RoomListModel roomList
 
immer::map< std::string, Eventpresence
 
immer::map< std::string, EventaccountData
 
std::string nextTxnId {DEFTXNID}
 
immer::flex_vector< BaseJobnextJobs
 
immer::flex_vector< KazvEventnextTriggers
 
EventList toDevice
 
std::optional< immer::box< Crypto > > crypto
 
bool identityKeysUploaded {false}
 
DeviceListTracker deviceLists
 
DeviceTrustLevel trustLevelNeededToSendKeys {DeviceTrustLevel::Unseen}
 

Member Typedef Documentation

◆ Action

◆ Effect

◆ Result

Member Function Documentation

◆ addJob()

void Kazv::ClientModel::addJob ( BaseJob  j)
inline

◆ addTrigger()

void Kazv::ClientModel::addTrigger ( KazvEvent  t)
inline

◆ addTriggers()

void Kazv::ClientModel::addTriggers ( immer::flex_vector< KazvEvent c)
inline

◆ constCrypto()

const Crypto & Kazv::ClientModel::constCrypto ( ) const

Get the const reference of crypto of this client.

crypto.has_value() must be true.

◆ devicesToSendKeys()

immer::flex_vector< std::string > Kazv::ClientModel::devicesToSendKeys ( std::string  userId) const

◆ directRoomMap()

auto Kazv::ClientModel::directRoomMap ( ) const -> immer::map<std::string, std::string>
Returns
the mapping from room id to user id of direct rooms

◆ job()

template<class Job >
constexpr auto Kazv::ClientModel::job ( ) const
inlineconstexpr

◆ maybeRotateSessions()

void Kazv::ClientModel::maybeRotateSessions ( ClientModel  oldClient)

rotate sessions for a room if there is a user in the room with devicesToSendKeys changes

◆ megOlmEncrypt()

std::pair< Event, std::optional< std::string > > Kazv::ClientModel::megOlmEncrypt ( Event  e,
std::string  roomId,
Timestamp  timeMs,
RandomData  random 
)

◆ numOneTimeKeysNeeded()

std::size_t Kazv::ClientModel::numOneTimeKeysNeeded ( ) const
Returns
number of one-time keys we need to generate

◆ olmEncrypt()

Event Kazv::ClientModel::olmEncrypt ( 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

◆ popAllJobs()

auto Kazv::ClientModel::popAllJobs ( )
inline

◆ popAllTriggers()

auto Kazv::ClientModel::popAllTriggers ( )
inline

◆ roomIdsByTagId()

auto Kazv::ClientModel::roomIdsByTagId ( ) const -> immer::map<std::string, immer::map<std::string, double>>

◆ roomIdsUnderTag()

auto Kazv::ClientModel::roomIdsUnderTag ( std::string  tagId) const -> immer::map<std::string, double>

◆ update()

auto Kazv::ClientModel::update ( ClientModel  m,
Action  a 
)
static

◆ withCrypto()

template<class Func >
auto Kazv::ClientModel::withCrypto ( Func &&  func) -> std::decay_t<std::invoke_result_t<Func &&, Crypto &>>
inline

Do func with crypto, returning its return value.

crypto.has_value() must be true.

Member Data Documentation

◆ accountData

immer::map<std::string , Event> Kazv::ClientModel::accountData

◆ crypto

std::optional<immer::box<Crypto> > Kazv::ClientModel::crypto

◆ deviceId

std::string Kazv::ClientModel::deviceId

◆ deviceLists

DeviceListTracker Kazv::ClientModel::deviceLists

◆ firstRetryMs

int Kazv::ClientModel::firstRetryMs {1000}

◆ identityKeysUploaded

bool Kazv::ClientModel::identityKeysUploaded {false}

◆ incrementalSyncFilterId

std::string Kazv::ClientModel::incrementalSyncFilterId

◆ initialSyncFilterId

std::string Kazv::ClientModel::initialSyncFilterId

◆ loggedIn

bool Kazv::ClientModel::loggedIn {false}

◆ maxRetryMs

int Kazv::ClientModel::maxRetryMs {30 * 1000}

◆ nextJobs

immer::flex_vector<BaseJob> Kazv::ClientModel::nextJobs

◆ nextTriggers

immer::flex_vector<KazvEvent> Kazv::ClientModel::nextTriggers

◆ nextTxnId

std::string Kazv::ClientModel::nextTxnId {DEFTXNID}

◆ presence

immer::map<std::string , Event> Kazv::ClientModel::presence

◆ retryTimeFactor

int Kazv::ClientModel::retryTimeFactor {2}

◆ roomList

RoomListModel Kazv::ClientModel::roomList

◆ serverUrl

std::string Kazv::ClientModel::serverUrl

◆ shouldSync

bool Kazv::ClientModel::shouldSync {true}

◆ syncing

bool Kazv::ClientModel::syncing {false}

◆ syncTimeoutMs

int Kazv::ClientModel::syncTimeoutMs {20000}

◆ syncToken

std::optional<std::string> Kazv::ClientModel::syncToken

◆ toDevice

EventList Kazv::ClientModel::toDevice

◆ token

std::string Kazv::ClientModel::token

◆ trustLevelNeededToSendKeys

DeviceTrustLevel Kazv::ClientModel::trustLevelNeededToSendKeys {DeviceTrustLevel::Unseen}

◆ userId

std::string Kazv::ClientModel::userId

The documentation for this struct was generated from the following files: