Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::ConversationModule::Impl Class Reference
Inheritance diagram for jami::ConversationModule::Impl:
Inheritance graph
Collaboration diagram for jami::ConversationModule::Impl:
Collaboration graph

Public Member Functions

bool addConversationRequest (const std::string &id, const ConversationRequest &req)
 
void addConvInfo (const ConvInfo &info)
 
void bootstrap (const std::string &convId)
 
void bootstrapCb (std::string convId)
 
void cloneConversation (const std::string &deviceId, const std::string &peer, const std::shared_ptr< SyncedConversation > &conv)
 
void cloneConversation (const std::string &deviceId, const std::string &peer, const std::string &convId)
 Clone a conversation (initial) from device.
 
void cloneConversationFrom (const std::shared_ptr< SyncedConversation > conv, const std::string &deviceId, const std::string &oldConvId="")
 
void cloneConversationFrom (const std::string &conversationId, const std::string &uri, const std::string &oldConvId="")
 
void declineOtherConversationWith (const std::string &uri)
 
void editMessage (const std::string &conversationId, const std::string &newBody, const std::string &editedId)
 
void fallbackClone (const asio::error_code &ec, const std::string &conversationId)
 
void fetchNewCommits (const std::string &peer, const std::string &deviceId, const std::string &conversationId, const std::string &commitId="")
 Pull remote device.
 
void fixStructures (std::shared_ptr< JamiAccount > account, const std::vector< std::tuple< std::string, std::string, std::string > > &updateContactConv, const std::set< std::string > &toRm)
 
std::shared_ptr< SyncedConversationgetConversation (std::string_view convId)
 
std::shared_ptr< SyncedConversationgetConversation (std::string_view convId) const
 
std::vector< std::map< std::string, std::string > > getConversationMembers (const std::string &conversationId, bool includeBanned=false) const
 Get members.
 
std::vector< std::shared_ptr< Conversation > > getConversations () const
 
std::string getOneToOneConversation (const std::string &uri) const noexcept
 
std::optional< ConversationRequestgetRequest (const std::string &id) const
 
std::vector< std::shared_ptr< SyncedConversation > > getSyncedConversations () const
 
void handlePendingConversation (const std::string &conversationId, const std::string &deviceId)
 Handle events to receive new commits.
 
 Impl (std::shared_ptr< JamiAccount > &&account, std::shared_ptr< AccountManager > &&accountManager, NeedsSyncingCb &&needsSyncingCb, SengMsgCb &&sendMsgCb, NeedSocketCb &&onNeedSocket, NeedSocketCb &&onNeedSwarmSocket, OneToOneRecvCb &&oneToOneRecvCb)
 
bool isConversation (const std::string &convId) const
 
void loadMetadata ()
 
bool removeConversation (const std::string &conversationId)
 Remove a conversation.
 
bool removeConversationImpl (SyncedConversation &conv)
 
void removeRepository (const std::string &convId, bool sync, bool force=false)
 Remove a repository and all files.
 
void removeRepositoryImpl (SyncedConversation &conv, bool sync, bool force=false)
 
void rmConversationRequest (const std::string &id)
 
void saveConvInfos () const
 
void saveConvRequests () const
 
void saveMetadata ()
 
void sendMessage (const std::string &conversationId, Json::Value &&value, const std::string &replyTo="", bool announce=true, OnCommitCb &&onCommit={}, OnDoneCb &&cb={})
 
void sendMessage (const std::string &conversationId, std::string message, const std::string &replyTo="", const std::string &type="text/plain", bool announce=true, OnCommitCb &&onCommit={}, OnDoneCb &&cb={})
 
void sendMessageNotification (const std::string &conversationId, bool sync, const std::string &commitId="", const std::string &deviceId="")
 Send a message notification to all members.
 
void sendMessageNotification (Conversation &conversation, bool sync, const std::string &commitId="", const std::string &deviceId="")
 
void setConversationMembers (const std::string &convId, const std::set< std::string > &members)
 
std::shared_ptr< SyncedConversationstartConversation (const ConvInfo &info)
 
std::shared_ptr< SyncedConversationstartConversation (const std::string &convId)
 
bool updateConvForContact (const std::string &uri, const std::string &oldConv, const std::string &newConv)
 
std::weak_ptr< Implweak ()
 
template<typename S , typename T >
auto withConv (const S &convId, T &&cb) const
 
template<typename S , typename T >
auto withConversation (const S &convId, T &&cb)
 

Public Attributes

std::weak_ptr< JamiAccountaccount_
 
const std::string accountId_ {}
 
std::shared_ptr< AccountManageraccountManager_
 
std::map< std::string, std::shared_ptr< SyncedConversation >, std::less<> > conversations_
 
std::mutex conversationsMtx_ {}
 
std::map< std::string, ConversationRequestconversationsRequests_
 
std::mutex conversationsRequestsMtx_
 
std::map< std::string, ConvInfoconvInfos_
 
std::mutex convInfosMtx_
 
std::string deviceId_ {}
 
NeedsSyncingCb needsSyncingCb_
 
std::map< std::string, std::string > notSyncedNotification_
 
std::mutex notSyncedNotificationMtx_
 
OneToOneRecvCb oneToOneRecvCb_
 
NeedSocketCb onNeedSocket_
 
NeedSocketCb onNeedSwarmSocket_
 
std::map< std::string, uint64_trefreshMessage
 
std::map< std::string, std::vector< std::map< std::string, std::string > > > replay_
 
std::mutex replayMtx_
 
SengMsgCb sendMsgCb_
 
std::atomic_int syncCnt {0}
 
std::map< std::string, std::map< std::string, std::string > > syncingMetadatas_
 
std::string username_ {}
 

Detailed Description

Definition at line 120 of file conversation_module.cpp.

Constructor & Destructor Documentation

◆ Impl()

jami::ConversationModule::Impl::Impl ( std::shared_ptr< JamiAccount > &&  account,
std::shared_ptr< AccountManager > &&  accountManager,
NeedsSyncingCb &&  needsSyncingCb,
SengMsgCb &&  sendMsgCb,
NeedSocketCb &&  onNeedSocket,
NeedSocketCb &&  onNeedSwarmSocket,
OneToOneRecvCb &&  oneToOneRecvCb 
)

Definition at line 456 of file conversation_module.cpp.

References accountId_, conversationsRequests_, jami::ConversationModule::convRequests(), deviceId_, jami::emitSignal(), loadMetadata(), and username_.

Here is the call graph for this function:

Member Function Documentation

◆ addConversationRequest()

bool jami::ConversationModule::Impl::addConversationRequest ( const std::string &  id,
const ConversationRequest req 
)
inline

◆ addConvInfo()

void jami::ConversationModule::Impl::addConvInfo ( const ConvInfo info)
inline

Definition at line 239 of file conversation_module.cpp.

References convInfos_, convInfosMtx_, jami::emitSignal(), and saveConvInfos().

Here is the call graph for this function:

◆ bootstrap()

void jami::ConversationModule::Impl::bootstrap ( const std::string &  convId)

◆ bootstrapCb()

void jami::ConversationModule::Impl::bootstrapCb ( std::string  convId)

Definition at line 1257 of file conversation_module.cpp.

References jami::emitSignal(), and JAMI_DEBUG.

Referenced by bootstrap(), handlePendingConversation(), and jami::ConversationModule::startConversation().

Here is the call graph for this function:

◆ cloneConversation() [1/2]

void jami::ConversationModule::Impl::cloneConversation ( const std::string &  deviceId,
const std::string &  peer,
const std::shared_ptr< SyncedConversation > &  conv 
)

Definition at line 494 of file conversation_module.cpp.

References jami::ConversationModule::addConvInfo(), jami::emitSignal(), JAMI_DEBUG, JAMI_LOG, JAMI_WARNING, and jami::MIME_TYPE_GIT.

Here is the call graph for this function:

◆ cloneConversation() [2/2]

void jami::ConversationModule::Impl::cloneConversation ( const std::string &  deviceId,
const std::string &  peer,
const std::string &  convId 
)

Clone a conversation (initial) from device.

Parameters
deviceId
convId

Definition at line 482 of file conversation_module.cpp.

References jami::emitSignal(), JAMI_DEBUG, and jami::ConversationModule::startConversation().

Here is the call graph for this function:

◆ cloneConversationFrom() [1/2]

void jami::ConversationModule::Impl::cloneConversationFrom ( const std::shared_ptr< SyncedConversation conv,
const std::string &  deviceId,
const std::string &  oldConvId = "" 
)

Definition at line 1329 of file conversation_module.cpp.

References jami::emitSignal(), fallbackClone(), JAMI_WARNING, jami::MAX_FALLBACK, and jami::MIME_TYPE_GIT.

Here is the call graph for this function:

◆ cloneConversationFrom() [2/2]

void jami::ConversationModule::Impl::cloneConversationFrom ( const std::string &  conversationId,
const std::string &  uri,
const std::string &  oldConvId = "" 
)

◆ declineOtherConversationWith()

void jami::ConversationModule::Impl::declineOtherConversationWith ( const std::string &  uri)

Definition at line 938 of file conversation_module.cpp.

References jami::emitSignal(), and JAMI_WARNING.

Referenced by addConversationRequest().

Here is the call graph for this function:

◆ editMessage()

void jami::ConversationModule::Impl::editMessage ( const std::string &  conversationId,
const std::string &  newBody,
const std::string &  editedId 
)

◆ fallbackClone()

void jami::ConversationModule::Impl::fallbackClone ( const asio::error_code &  ec,
const std::string &  conversationId 
)

◆ fetchNewCommits()

void jami::ConversationModule::Impl::fetchNewCommits ( const std::string &  peer,
const std::string &  deviceId,
const std::string &  conversationId,
const std::string &  commitId = "" 
)

Pull remote device.

Parameters
peerContact URI
deviceIdContact's device
conversationId
commitId(optional)

Definition at line 550 of file conversation_module.cpp.

References jami::emitSignal(), jami::ConversationModule::getConversation(), JAMI_DEBUG, JAMI_ERROR, JAMI_LOG, JAMI_WARNING, and jami::MIME_TYPE_INVITE.

Here is the call graph for this function:

◆ fixStructures()

void jami::ConversationModule::Impl::fixStructures ( std::shared_ptr< JamiAccount account,
const std::vector< std::tuple< std::string, std::string, std::string > > &  updateContactConv,
const std::set< std::string > &  toRm 
)

◆ getConversation() [1/2]

std::shared_ptr< SyncedConversation > jami::ConversationModule::Impl::getConversation ( std::string_view  convId)
inline

Definition at line 258 of file conversation_module.cpp.

References conversations_, conversationsMtx_, and jami::emitSignal().

Here is the call graph for this function:

◆ getConversation() [2/2]

std::shared_ptr< SyncedConversation > jami::ConversationModule::Impl::getConversation ( std::string_view  convId) const
inline

Definition at line 252 of file conversation_module.cpp.

References conversations_, conversationsMtx_, and jami::emitSignal().

Referenced by withConv(), and withConversation().

Here is the call graph for this function:

◆ getConversationMembers()

std::vector< std::map< std::string, std::string > > jami::ConversationModule::Impl::getConversationMembers ( const std::string &  conversationId,
bool  includeBanned = false 
) const

Get members.

Parameters
conversationId
includeBanned
Returns
a map of members with their role and details

Definition at line 956 of file conversation_module.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getConversations()

std::vector< std::shared_ptr< Conversation > > jami::ConversationModule::Impl::getConversations ( ) const
inline

Definition at line 289 of file conversation_module.cpp.

References _, conversations_, conversationsMtx_, and jami::emitSignal().

Here is the call graph for this function:

◆ getOneToOneConversation()

std::string jami::ConversationModule::Impl::getOneToOneConversation ( const std::string &  uri) const
noexcept

Definition at line 901 of file conversation_module.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getRequest()

std::optional< ConversationRequest > jami::ConversationModule::Impl::getRequest ( const std::string &  id) const

Definition at line 891 of file conversation_module.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getSyncedConversations()

std::vector< std::shared_ptr< SyncedConversation > > jami::ConversationModule::Impl::getSyncedConversations ( ) const
inline

Definition at line 280 of file conversation_module.cpp.

References _, conversations_, conversationsMtx_, and jami::emitSignal().

Here is the call graph for this function:

◆ handlePendingConversation()

void jami::ConversationModule::Impl::handlePendingConversation ( const std::string &  conversationId,
const std::string &  deviceId 
)

◆ isConversation()

bool jami::ConversationModule::Impl::isConversation ( const std::string &  convId) const
inline
Returns
if a convId is a valid conversation (repository cloned & usable)

Definition at line 232 of file conversation_module.cpp.

References conversations_, conversationsMtx_, and jami::emitSignal().

Referenced by addConversationRequest().

Here is the call graph for this function:

◆ loadMetadata()

void jami::ConversationModule::Impl::loadMetadata ( )
inline

Definition at line 437 of file conversation_module.cpp.

References accountId_, jami::emitSignal(), jami::fileutils::get_data_dir(), JAMI_WARNING, jami::fileutils::loadFile(), and syncingMetadatas_.

Referenced by Impl().

Here is the call graph for this function:

◆ removeConversation()

bool jami::ConversationModule::Impl::removeConversation ( const std::string &  conversationId)

Remove a conversation.

Parameters
conversationId

Definition at line 1009 of file conversation_module.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ removeConversationImpl()

bool jami::ConversationModule::Impl::removeConversationImpl ( SyncedConversation conv)

◆ removeRepository()

void jami::ConversationModule::Impl::removeRepository ( const std::string &  convId,
bool  sync,
bool  force = false 
)

Remove a repository and all files.

Parameters
convId
syncIf we send an update to other account's devices
forceTrue if ignore the removing flag

Definition at line 964 of file conversation_module.cpp.

References jami::emitSignal(), and jami::ConversationModule::getConversation().

Here is the call graph for this function:

◆ removeRepositoryImpl()

void jami::ConversationModule::Impl::removeRepositoryImpl ( SyncedConversation conv,
bool  sync,
bool  force = false 
)

◆ rmConversationRequest()

void jami::ConversationModule::Impl::rmConversationRequest ( const std::string &  id)
inline

Definition at line 356 of file conversation_module.cpp.

References conversationsRequests_, jami::emitSignal(), saveConvRequests(), saveMetadata(), and syncingMetadatas_.

Here is the call graph for this function:

◆ saveConvInfos()

void jami::ConversationModule::Impl::saveConvInfos ( ) const
inline
Note
convInfosMtx_ should be locked

Definition at line 327 of file conversation_module.cpp.

References accountId_, convInfos_, and jami::ConversationModule::saveConvInfos().

Referenced by addConvInfo().

Here is the call graph for this function:

◆ saveConvRequests()

void jami::ConversationModule::Impl::saveConvRequests ( ) const
inline
Note
conversationsRequestsMtx_ should be locked

Definition at line 331 of file conversation_module.cpp.

References accountId_, conversationsRequests_, and jami::ConversationModule::saveConvRequests().

Referenced by addConversationRequest(), and rmConversationRequest().

Here is the call graph for this function:

◆ saveMetadata()

void jami::ConversationModule::Impl::saveMetadata ( )
inline

Definition at line 430 of file conversation_module.cpp.

References accountId_, jami::emitSignal(), jami::fileutils::get_data_dir(), and syncingMetadatas_.

Referenced by rmConversationRequest().

Here is the call graph for this function:

◆ sendMessage() [1/2]

void jami::ConversationModule::Impl::sendMessage ( const std::string &  conversationId,
Json::Value &&  value,
const std::string &  replyTo = "",
bool  announce = true,
OnCommitCb &&  onCommit = {},
OnDoneCb &&  cb = {} 
)

Definition at line 1184 of file conversation_module.cpp.

References jami::emitSignal(), jami::ConversationModule::getConversation(), and JAMI_ERR.

Here is the call graph for this function:

◆ sendMessage() [2/2]

void jami::ConversationModule::Impl::sendMessage ( const std::string &  conversationId,
std::string  message,
const std::string &  replyTo = "",
const std::string &  type = "text/plain",
bool  announce = true,
OnCommitCb &&  onCommit = {},
OnDoneCb &&  cb = {} 
)

Definition at line 1164 of file conversation_module.cpp.

References jami::emitSignal(), and jami::ConversationModule::sendMessage().

Here is the call graph for this function:

◆ sendMessageNotification() [1/2]

void jami::ConversationModule::Impl::sendMessageNotification ( const std::string &  conversationId,
bool  sync,
const std::string &  commitId = "",
const std::string &  deviceId = "" 
)

Send a message notification to all members.

Parameters
conversation
commit
syncIf we send an update to other account's devices
deviceIdIf we need to filter a specific device

Definition at line 1067 of file conversation_module.cpp.

References jami::emitSignal(), and jami::ConversationModule::getConversation().

Here is the call graph for this function:

◆ sendMessageNotification() [2/2]

void jami::ConversationModule::Impl::sendMessageNotification ( Conversation conversation,
bool  sync,
const std::string &  commitId = "",
const std::string &  deviceId = "" 
)

◆ setConversationMembers()

void jami::ConversationModule::Impl::setConversationMembers ( const std::string &  convId,
const std::set< std::string > &  members 
)

Definition at line 3274 of file conversation_module.cpp.

◆ startConversation() [1/2]

std::shared_ptr< SyncedConversation > jami::ConversationModule::Impl::startConversation ( const ConvInfo info)
inline

Definition at line 272 of file conversation_module.cpp.

References conversations_, conversationsMtx_, and jami::emitSignal().

Here is the call graph for this function:

◆ startConversation() [2/2]

std::shared_ptr< SyncedConversation > jami::ConversationModule::Impl::startConversation ( const std::string &  convId)
inline

Definition at line 264 of file conversation_module.cpp.

References conversations_, conversationsMtx_, and jami::emitSignal().

Here is the call graph for this function:

◆ updateConvForContact()

bool jami::ConversationModule::Impl::updateConvForContact ( const std::string &  uri,
const std::string &  oldConv,
const std::string &  newConv 
)

Definition at line 917 of file conversation_module.cpp.

References jami::emitSignal(), jami::ConversationModule::getOneToOneConversation(), and JAMI_DEBUG.

Here is the call graph for this function:

◆ weak()

std::weak_ptr< Impl > jami::ConversationModule::Impl::weak ( )
inline

Definition at line 402 of file conversation_module.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ withConv()

template<typename S , typename T >
auto jami::ConversationModule::Impl::withConv ( const S convId,
T &&  cb 
) const
inline

Definition at line 132 of file conversation_module.cpp.

References jami::emitSignal(), getConversation(), and JAMI_WARNING.

Here is the call graph for this function:

◆ withConversation()

template<typename S , typename T >
auto jami::ConversationModule::Impl::withConversation ( const S convId,
T &&  cb 
)
inline

Definition at line 143 of file conversation_module.cpp.

References jami::emitSignal(), getConversation(), and JAMI_WARNING.

Here is the call graph for this function:

Member Data Documentation

◆ account_

std::weak_ptr<JamiAccount> jami::ConversationModule::Impl::account_

Definition at line 371 of file conversation_module.cpp.

◆ accountId_

const std::string jami::ConversationModule::Impl::accountId_ {}

◆ accountManager_

std::shared_ptr<AccountManager> jami::ConversationModule::Impl::accountManager_

Definition at line 372 of file conversation_module.cpp.

◆ conversations_

std::map<std::string, std::shared_ptr<SyncedConversation>, std::less<> > jami::ConversationModule::Impl::conversations_

◆ conversationsMtx_

std::mutex jami::ConversationModule::Impl::conversationsMtx_ {}
mutable

◆ conversationsRequests_

std::map<std::string, ConversationRequest> jami::ConversationModule::Impl::conversationsRequests_

◆ conversationsRequestsMtx_

std::mutex jami::ConversationModule::Impl::conversationsRequestsMtx_
mutable

Definition at line 384 of file conversation_module.cpp.

◆ convInfos_

std::map<std::string, ConvInfo> jami::ConversationModule::Impl::convInfos_

Definition at line 393 of file conversation_module.cpp.

Referenced by addConvInfo(), and saveConvInfos().

◆ convInfosMtx_

std::mutex jami::ConversationModule::Impl::convInfosMtx_
mutable

Definition at line 392 of file conversation_module.cpp.

Referenced by addConvInfo().

◆ deviceId_

std::string jami::ConversationModule::Impl::deviceId_ {}

Definition at line 380 of file conversation_module.cpp.

Referenced by Impl().

◆ needsSyncingCb_

NeedsSyncingCb jami::ConversationModule::Impl::needsSyncingCb_

Definition at line 374 of file conversation_module.cpp.

◆ notSyncedNotification_

std::map<std::string, std::string> jami::ConversationModule::Impl::notSyncedNotification_

Definition at line 400 of file conversation_module.cpp.

◆ notSyncedNotificationMtx_

std::mutex jami::ConversationModule::Impl::notSyncedNotificationMtx_

Definition at line 399 of file conversation_module.cpp.

◆ oneToOneRecvCb_

OneToOneRecvCb jami::ConversationModule::Impl::oneToOneRecvCb_

Definition at line 378 of file conversation_module.cpp.

◆ onNeedSocket_

NeedSocketCb jami::ConversationModule::Impl::onNeedSocket_

Definition at line 376 of file conversation_module.cpp.

◆ onNeedSwarmSocket_

NeedSocketCb jami::ConversationModule::Impl::onNeedSwarmSocket_

Definition at line 377 of file conversation_module.cpp.

◆ refreshMessage

std::map<std::string, uint64_t> jami::ConversationModule::Impl::refreshMessage

Definition at line 407 of file conversation_module.cpp.

◆ replay_

std::map<std::string, std::vector<std::map<std::string, std::string> > > jami::ConversationModule::Impl::replay_

Definition at line 406 of file conversation_module.cpp.

◆ replayMtx_

std::mutex jami::ConversationModule::Impl::replayMtx_

Definition at line 405 of file conversation_module.cpp.

◆ sendMsgCb_

SengMsgCb jami::ConversationModule::Impl::sendMsgCb_

Definition at line 375 of file conversation_module.cpp.

◆ syncCnt

std::atomic_int jami::ConversationModule::Impl::syncCnt {0}

Definition at line 408 of file conversation_module.cpp.

◆ syncingMetadatas_

std::map<std::string, std::map<std::string, std::string> > jami::ConversationModule::Impl::syncingMetadatas_

Definition at line 429 of file conversation_module.cpp.

Referenced by loadMetadata(), rmConversationRequest(), and saveMetadata().

◆ username_

std::string jami::ConversationModule::Impl::username_ {}

Definition at line 381 of file conversation_module.cpp.

Referenced by Impl().


The documentation for this class was generated from the following file: