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

Public Member Functions

void addGitSocket (const DeviceId &deviceId, const std::shared_ptr< dhtnet::ChannelSocket > &socket)
 
std::vector< std::shared_ptr< libjami::SwarmMessage > > addToHistory (History &history, const std::vector< std::map< std::string, std::string > > &commits, bool messageReceived=false, bool commitFromSelf=false)
 
void announce (const std::string &commitId, bool commitFromSelf=false)
 
void announce (const std::vector< std::map< std::string, std::string > > &commits, bool commitFromSelf=false)
 
void announce (const std::vector< std::string > &commits, bool commitFromSelf=false)
 
std::string_view bannedType (const std::string &uri) const
 
std::vector< std::string > commitsEndedCalls ()
 If, for whatever reason, the daemon is stopped while hosting a conference, we need to announce the end of this call when restarting.
 
void disconnectFromPeer (const std::string &peerUri)
 Remove all git sockets and all DRT nodes associated with the given peer.
 
std::vector< std::map< std::string, std::string > > getMembers (bool includeInvited, bool includeLeft) const
 
std::vector< std::map< std::string, std::string > > getMembers (bool includeInvited, bool includeLeft, bool includeBanned) const
 
std::shared_ptr< dhtnet::ChannelSocket > gitSocket (const DeviceId &deviceId) const
 
void handleEdition (History &history, const std::shared_ptr< libjami::SwarmMessage > &sharedCommit, bool messageReceived) const
 
bool handleMessage (History &history, const std::shared_ptr< libjami::SwarmMessage > &sharedCommit, bool messageReceived) const
 
void handleReaction (History &history, const std::shared_ptr< libjami::SwarmMessage > &sharedCommit) const
 
 Impl (const std::shared_ptr< JamiAccount > &account, const std::string &conversationId)
 
 Impl (const std::shared_ptr< JamiAccount > &account, const std::string &remoteDevice, const std::string &conversationId)
 
 Impl (const std::shared_ptr< JamiAccount > &account, ConversationMode mode, const std::string &otherMember="")
 
void init (const std::shared_ptr< JamiAccount > &account)
 
void initActiveCalls (const std::vector< std::map< std::string, std::string > > &commits) const
 Initialize activeCalls_ from the list of commits in the repository.
 
bool isAdmin () const
 
void loadActiveCalls () const
 
void loadHostedCalls () const
 
std::vector< std::map< std::string, std::string > > loadMessages (const LogOptions &options)
 
std::vector< libjami::SwarmMessageloadMessages2 (const LogOptions &options, History *optHistory=nullptr)
 
void loadStatus ()
 
std::vector< std::map< std::string, std::string > > mergeHistory (const std::string &uri)
 
void pull (const std::string &deviceId)
 
void rectifyStatus (const std::shared_ptr< libjami::SwarmMessage > &message, History &history) const
 
void removeGitSocket (const DeviceId &deviceId)
 
std::filesystem::path repoPath () const
 
void saveActiveCalls () const
 
void saveHostedCalls () const
 
void saveStatus ()
 
std::string toString () const
 
void updateActiveCalls (const std::map< std::string, std::string > &commit, bool eraseOnly=false, bool emitSig=true) const
 Update activeCalls_ via announced commits (in load or via new commits)
 
void updateStatus (const std::string &uri, libjami::Account::MessageStates status, const std::string &commitId, const std::string &ts, bool emit=false)
 
void voteUnban (const std::string &contactUri, const std::string_view type, const OnDoneCb &cb)
 
 ~Impl ()
 

Public Attributes

std::weak_ptr< JamiAccountaccount_
 
std::string accountId_ {}
 
std::vector< std::map< std::string, std::string > > activeCalls_ {}
 
std::mutex activeCallsMtx_ {}
 
std::filesystem::path activeCallsPath_ {}
 
std::function< void()> bootstrapCb_
 
std::set< std::string > checkedMembers_
 
std::filesystem::path conversationDataPath_ {}
 
std::string deviceId_
 
std::unique_ptr< asio::steady_timer > fallbackTimer_
 
std::filesystem::path fetchedPath_ {}
 
std::map< std::string, std::deque< std::pair< std::string, OnPullCb > > > fetchingRemotes_ {}
 
std::string fmtStr_
 
std::map< std::string, std::map< std::string, int32_t > > futureStatus
 
GitSocketList gitSocketList_ {}
 
std::map< std::string, uint64_thostedCalls_ {}
 
std::filesystem::path hostedCallsPath_ {}
 
std::shared_ptr< asio::io_context > ioContext_
 
std::atomic_bool isRemoving_ {false}
 
History loadedHistory_ {}
 Loaded history represents the linearized history to show for clients.
 
std::mutex membersMtx_ {}
 
std::map< std::string, int32_tmemberToStatus
 Status: 0 = commited, 1 = fetched, 2 = read This cache the curent status to add in the messages.
 
std::map< std::string, std::map< std::string, std::string > > messagesStatus_ {}
 
std::function< void(const std::map< std::string, std::map< std::string, std::string > > &)> messageStatusCb_ {}
 
std::mutex messageStatusMtx_
 {uri, { {"fetch", "commitId"}, {"fetched_ts", "timestamp"}, {"read", "commitId"}, {"read_ts", "timestamp"} } }
 
OnMembersChanged onMembersChanged_ {}
 
std::filesystem::path preferencesPath_ {}
 
std::mutex pullcbsMtx_ {}
 
std::unique_ptr< ConversationRepositoryrepository_
 
std::filesystem::path sendingPath_ {}
 
std::filesystem::path statusPath_ {}
 
std::shared_ptr< SwarmManagerswarmManager_
 
std::shared_ptr< TransferManagertransferManager_ {}
 
std::shared_ptr< Typerstypers_
 
std::string userId_
 
std::mutex writeMtx_ {}
 

Detailed Description

Definition at line 134 of file conversation.cpp.

Constructor & Destructor Documentation

◆ Impl() [1/3]

jami::Conversation::Impl::Impl ( const std::shared_ptr< JamiAccount > &  account,
ConversationMode  mode,
const std::string &  otherMember = "" 
)
inline

Definition at line 137 of file conversation.cpp.

References jami::emitSignal(), init(), and repository_.

Here is the call graph for this function:

◆ Impl() [2/3]

jami::Conversation::Impl::Impl ( const std::shared_ptr< JamiAccount > &  account,
const std::string &  conversationId 
)
inline

Definition at line 152 of file conversation.cpp.

References jami::emitSignal(), init(), and repository_.

Here is the call graph for this function:

◆ Impl() [3/3]

jami::Conversation::Impl::Impl ( const std::shared_ptr< JamiAccount > &  account,
const std::string &  remoteDevice,
const std::string &  conversationId 
)
inline

◆ ~Impl()

jami::Conversation::Impl::~Impl ( )
inline

Definition at line 229 of file conversation.cpp.

References jami::emitSignal(), fallbackTimer_, JAMI_ERROR, and toString().

Here is the call graph for this function:

Member Function Documentation

◆ addGitSocket()

void jami::Conversation::Impl::addGitSocket ( const DeviceId deviceId,
const std::shared_ptr< dhtnet::ChannelSocket > &  socket 
)
inline

Definition at line 590 of file conversation.cpp.

References gitSocketList_.

◆ addToHistory()

std::vector< std::shared_ptr< libjami::SwarmMessage > > jami::Conversation::Impl::addToHistory ( History history,
const std::vector< std::map< std::string, std::string > > &  commits,
bool  messageReceived = false,
bool  commitFromSelf = false 
)

Definition at line 1150 of file conversation.cpp.

References libjami::Account::DISPLAYED, jami::emitSignal(), libjami::Account::SENDING, and libjami::Account::SENT.

Referenced by announce().

Here is the call graph for this function:

◆ announce() [1/3]

void jami::Conversation::Impl::announce ( const std::string &  commitId,
bool  commitFromSelf = false 
)
inline

Definition at line 248 of file conversation.cpp.

References announce(), and jami::emitSignal().

Referenced by announce(), announce(), and voteUnban().

Here is the call graph for this function:

◆ announce() [2/3]

void jami::Conversation::Impl::announce ( const std::vector< std::map< std::string, std::string > > &  commits,
bool  commitFromSelf = false 
)
inline

◆ announce() [3/3]

void jami::Conversation::Impl::announce ( const std::vector< std::string > &  commits,
bool  commitFromSelf = false 
)
inline

Definition at line 256 of file conversation.cpp.

References announce(), jami::emitSignal(), and repository_.

Here is the call graph for this function:

◆ bannedType()

std::string_view jami::Conversation::Impl::bannedType ( const std::string &  uri) const
inline

Definition at line 565 of file conversation.cpp.

References jami::emitSignal(), and repoPath().

Here is the call graph for this function:

◆ commitsEndedCalls()

std::vector< std::string > jami::Conversation::Impl::commitsEndedCalls ( )

If, for whatever reason, the daemon is stopped while hosting a conference, we need to announce the end of this call when restarting.

To avoid to keep active calls forever.

Definition at line 764 of file conversation.cpp.

References jami::emitSignal(), JAMI_DEBUG, and jami::json::toString().

Here is the call graph for this function:

◆ disconnectFromPeer()

void jami::Conversation::Impl::disconnectFromPeer ( const std::string &  peerUri)

Remove all git sockets and all DRT nodes associated with the given peer.

This is used when a swarm member is banned to ensure that we stop syncing with them or sending them message notifications.

Definition at line 723 of file conversation.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getMembers() [1/2]

std::vector< std::map< std::string, std::string > > jami::Conversation::Impl::getMembers ( bool  includeInvited,
bool  includeLeft 
) const

◆ getMembers() [2/2]

std::vector< std::map< std::string, std::string > > jami::Conversation::Impl::getMembers ( bool  includeInvited,
bool  includeLeft,
bool  includeBanned 
) const

Definition at line 743 of file conversation.cpp.

References jami::BANNED, jami::emitSignal(), jami::INVITED, jami::ConversationMapKeys::LAST_DISPLAYED, and jami::LEFT.

Here is the call graph for this function:

◆ gitSocket()

std::shared_ptr< dhtnet::ChannelSocket > jami::Conversation::Impl::gitSocket ( const DeviceId deviceId) const
inline

Definition at line 584 of file conversation.cpp.

References jami::emitSignal(), and gitSocketList_.

Here is the call graph for this function:

◆ handleEdition()

void jami::Conversation::Impl::handleEdition ( History history,
const std::shared_ptr< libjami::SwarmMessage > &  sharedCommit,
bool  messageReceived 
) const

Definition at line 999 of file conversation.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ handleMessage()

bool jami::Conversation::Impl::handleMessage ( History history,
const std::shared_ptr< libjami::SwarmMessage > &  sharedCommit,
bool  messageReceived 
) const

Definition at line 1073 of file conversation.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ handleReaction()

void jami::Conversation::Impl::handleReaction ( History history,
const std::shared_ptr< libjami::SwarmMessage > &  sharedCommit 
) const

Definition at line 975 of file conversation.cpp.

References accountId_, jami::emitSignal(), and repository_.

Here is the call graph for this function:

◆ init()

◆ initActiveCalls()

void jami::Conversation::Impl::initActiveCalls ( const std::vector< std::map< std::string, std::string > > &  commits) const
inline

Initialize activeCalls_ from the list of commits in the repository.

Parameters
commitsCommits in reverse chronological order (i.e. from newest to oldest)

Definition at line 273 of file conversation.cpp.

References accountId_, activeCalls_, activeCallsMtx_, jami::emitSignal(), repository_, and saveActiveCalls().

Referenced by Impl().

Here is the call graph for this function:

◆ isAdmin()

bool jami::Conversation::Impl::isAdmin ( ) const

Definition at line 716 of file conversation.cpp.

References jami::emitSignal(), jami::fileutils::getFullPath(), repoPath(), and userId_.

Referenced by voteUnban().

Here is the call graph for this function:

◆ loadActiveCalls()

void jami::Conversation::Impl::loadActiveCalls ( ) const
inline

Definition at line 519 of file conversation.cpp.

References activeCalls_, activeCallsMtx_, activeCallsPath_, jami::emitSignal(), and jami::fileutils::loadFile().

Referenced by init().

Here is the call graph for this function:

◆ loadHostedCalls()

void jami::Conversation::Impl::loadHostedCalls ( ) const
inline

Definition at line 539 of file conversation.cpp.

References activeCallsMtx_, jami::emitSignal(), hostedCalls_, hostedCallsPath_, and jami::fileutils::loadFile().

Here is the call graph for this function:

◆ loadMessages()

std::vector< std::map< std::string, std::string > > jami::Conversation::Impl::loadMessages ( const LogOptions options)

Definition at line 809 of file conversation.cpp.

References jami::Break, jami::emitSignal(), jami::Ok, and jami::Skip.

Here is the call graph for this function:

◆ loadMessages2()

std::vector< libjami::SwarmMessage > jami::Conversation::Impl::loadMessages2 ( const LogOptions options,
History optHistory = nullptr 
)

Definition at line 862 of file conversation.cpp.

References jami::Break, jami::emitSignal(), jami::Ok, and jami::Skip.

Here is the call graph for this function:

◆ loadStatus()

void jami::Conversation::Impl::loadStatus ( )
inline

Definition at line 501 of file conversation.cpp.

References jami::emitSignal(), jami::fileutils::loadFile(), messagesStatus_, messageStatusMtx_, and statusPath_.

Referenced by init().

Here is the call graph for this function:

◆ mergeHistory()

std::vector< std::map< std::string, std::string > > jami::Conversation::Impl::mergeHistory ( const std::string &  uri)

Definition at line 1760 of file conversation.cpp.

References jami::emitSignal(), JAMI_ERROR, JAMI_LOG, JAMI_WARNING, and jami::toString().

Here is the call graph for this function:

◆ pull()

void jami::Conversation::Impl::pull ( const std::string &  deviceId)

Definition at line 1834 of file conversation.cpp.

References jami::emitSignal(), JAMI_ERROR, JAMI_WARNING, jami::Conversation::loadMessages(), and jami::LogOptions::to.

Here is the call graph for this function:

◆ rectifyStatus()

void jami::Conversation::Impl::rectifyStatus ( const std::shared_ptr< libjami::SwarmMessage > &  message,
History history 
) const

Definition at line 1120 of file conversation.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ removeGitSocket()

void jami::Conversation::Impl::removeGitSocket ( const DeviceId deviceId)
inline

Definition at line 594 of file conversation.cpp.

References jami::emitSignal(), and gitSocketList_.

Here is the call graph for this function:

◆ repoPath()

std::filesystem::path jami::Conversation::Impl::repoPath ( ) const

Definition at line 803 of file conversation.cpp.

References jami::fileutils::get_data_dir().

Referenced by bannedType(), and isAdmin().

Here is the call graph for this function:

◆ saveActiveCalls()

void jami::Conversation::Impl::saveActiveCalls ( ) const
inline

Definition at line 533 of file conversation.cpp.

References activeCalls_, activeCallsPath_, and jami::emitSignal().

Referenced by initActiveCalls(), and updateActiveCalls().

Here is the call graph for this function:

◆ saveHostedCalls()

void jami::Conversation::Impl::saveHostedCalls ( ) const
inline

Definition at line 553 of file conversation.cpp.

References jami::emitSignal(), hostedCalls_, and hostedCallsPath_.

Here is the call graph for this function:

◆ saveStatus()

void jami::Conversation::Impl::saveStatus ( )
inline

Definition at line 513 of file conversation.cpp.

References jami::emitSignal(), messagesStatus_, and statusPath_.

Here is the call graph for this function:

◆ toString()

std::string jami::Conversation::Impl::toString ( ) const
inline

Definition at line 224 of file conversation.cpp.

References accountId_, jami::emitSignal(), and repository_.

Referenced by ~Impl().

Here is the call graph for this function:

◆ updateActiveCalls()

void jami::Conversation::Impl::updateActiveCalls ( const std::map< std::string, std::string > &  commit,
bool  eraseOnly = false,
bool  emitSig = true 
) const
inline

Update activeCalls_ via announced commits (in load or via new commits)

Parameters
commitCommit to check
eraseOnlyIf we want to ignore added commits
emitSigIf we want to emit to client
Note
eraseOnly is used by loadMessages. This is a fail-safe, this SHOULD NOT happen

Definition at line 332 of file conversation.cpp.

References accountId_, activeCalls_, activeCallsMtx_, jami::emitSignal(), JAMI_DEBUG, JAMI_ERROR, JAMI_WARNING, repository_, and saveActiveCalls().

Referenced by announce().

Here is the call graph for this function:

◆ updateStatus()

void jami::Conversation::Impl::updateStatus ( const std::string &  uri,
libjami::Account::MessageStates  status,
const std::string &  commitId,
const std::string &  ts,
bool  emit = false 
)

Definition at line 2215 of file conversation.cpp.

References _, jami::emitSignal(), jami::Conversation::loadMessages2(), and libjami::Account::SENT.

Here is the call graph for this function:

◆ voteUnban()

void jami::Conversation::Impl::voteUnban ( const std::string &  contactUri,
const std::string_view  type,
const OnDoneCb cb 
)

Definition at line 1429 of file conversation.cpp.

References announce(), jami::emitSignal(), isAdmin(), JAMI_WARN, repository_, and writeMtx_.

Here is the call graph for this function:

Member Data Documentation

◆ account_

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

Definition at line 621 of file conversation.cpp.

Referenced by init().

◆ accountId_

std::string jami::Conversation::Impl::accountId_ {}

◆ activeCalls_

std::vector<std::map<std::string, std::string> > jami::Conversation::Impl::activeCalls_ {}
mutable

◆ activeCallsMtx_

std::mutex jami::Conversation::Impl::activeCallsMtx_ {}
mutable

◆ activeCallsPath_

std::filesystem::path jami::Conversation::Impl::activeCallsPath_ {}

Definition at line 648 of file conversation.cpp.

Referenced by Impl(), init(), loadActiveCalls(), and saveActiveCalls().

◆ bootstrapCb_

std::function<void()> jami::Conversation::Impl::bootstrapCb_

Definition at line 613 of file conversation.cpp.

◆ checkedMembers_

std::set<std::string> jami::Conversation::Impl::checkedMembers_

Definition at line 612 of file conversation.cpp.

◆ conversationDataPath_

std::filesystem::path jami::Conversation::Impl::conversationDataPath_ {}

Definition at line 636 of file conversation.cpp.

Referenced by Impl(), and init().

◆ deviceId_

std::string jami::Conversation::Impl::deviceId_

Definition at line 624 of file conversation.cpp.

Referenced by init().

◆ fallbackTimer_

std::unique_ptr<asio::steady_timer> jami::Conversation::Impl::fallbackTimer_

Definition at line 656 of file conversation.cpp.

Referenced by init(), and ~Impl().

◆ fetchedPath_

std::filesystem::path jami::Conversation::Impl::fetchedPath_ {}

Definition at line 637 of file conversation.cpp.

Referenced by init().

◆ fetchingRemotes_

std::map<std::string, std::deque<std::pair<std::string, OnPullCb> > > jami::Conversation::Impl::fetchingRemotes_ {}

Definition at line 634 of file conversation.cpp.

◆ fmtStr_

std::string jami::Conversation::Impl::fmtStr_
mutable

Definition at line 227 of file conversation.cpp.

◆ futureStatus

std::map<std::string, std::map<std::string, int32_t> > jami::Conversation::Impl::futureStatus
mutable

Definition at line 703 of file conversation.cpp.

◆ gitSocketList_

GitSocketList jami::Conversation::Impl::gitSocketList_ {}

Definition at line 652 of file conversation.cpp.

Referenced by addGitSocket(), gitSocket(), and removeGitSocket().

◆ hostedCalls_

std::map<std::string, uint64_t > jami::Conversation::Impl::hostedCalls_ {}
mutable

Definition at line 646 of file conversation.cpp.

Referenced by loadHostedCalls(), and saveHostedCalls().

◆ hostedCallsPath_

std::filesystem::path jami::Conversation::Impl::hostedCallsPath_ {}

Definition at line 645 of file conversation.cpp.

Referenced by init(), loadHostedCalls(), and saveHostedCalls().

◆ ioContext_

std::shared_ptr<asio::io_context> jami::Conversation::Impl::ioContext_

Definition at line 655 of file conversation.cpp.

Referenced by init().

◆ isRemoving_

std::atomic_bool jami::Conversation::Impl::isRemoving_ {false}

Definition at line 625 of file conversation.cpp.

◆ loadedHistory_

History jami::Conversation::Impl::loadedHistory_ {}

Loaded history represents the linearized history to show for clients.

Definition at line 662 of file conversation.cpp.

Referenced by announce().

◆ membersMtx_

std::mutex jami::Conversation::Impl::membersMtx_ {}

Definition at line 611 of file conversation.cpp.

◆ memberToStatus

std::map<std::string, int32_t> jami::Conversation::Impl::memberToStatus
mutable

Status: 0 = commited, 1 = fetched, 2 = read This cache the curent status to add in the messages.

Definition at line 698 of file conversation.cpp.

◆ messagesStatus_

std::map<std::string, std::map<std::string, std::string> > jami::Conversation::Impl::messagesStatus_ {}
mutable

Definition at line 691 of file conversation.cpp.

Referenced by loadStatus(), and saveStatus().

◆ messageStatusCb_

std::function<void(const std::map<std::string, std::map<std::string, std::string>>&)> jami::Conversation::Impl::messageStatusCb_ {}

Definition at line 689 of file conversation.cpp.

◆ messageStatusMtx_

std::mutex jami::Conversation::Impl::messageStatusMtx_
mutable

{uri, { {"fetch", "commitId"}, {"fetched_ts", "timestamp"}, {"read", "commitId"}, {"read_ts", "timestamp"} } }

Definition at line 688 of file conversation.cpp.

Referenced by loadStatus().

◆ onMembersChanged_

OnMembersChanged jami::Conversation::Impl::onMembersChanged_ {}

Definition at line 642 of file conversation.cpp.

Referenced by announce().

◆ preferencesPath_

std::filesystem::path jami::Conversation::Impl::preferencesPath_ {}

Definition at line 641 of file conversation.cpp.

Referenced by init().

◆ pullcbsMtx_

std::mutex jami::Conversation::Impl::pullcbsMtx_ {}

Definition at line 633 of file conversation.cpp.

◆ repository_

std::unique_ptr<ConversationRepository> jami::Conversation::Impl::repository_

◆ sendingPath_

std::filesystem::path jami::Conversation::Impl::sendingPath_ {}

Definition at line 640 of file conversation.cpp.

Referenced by init().

◆ statusPath_

std::filesystem::path jami::Conversation::Impl::statusPath_ {}

Definition at line 690 of file conversation.cpp.

Referenced by init(), loadStatus(), and saveStatus().

◆ swarmManager_

std::shared_ptr<SwarmManager> jami::Conversation::Impl::swarmManager_

Definition at line 620 of file conversation.cpp.

Referenced by init().

◆ transferManager_

std::shared_ptr<TransferManager> jami::Conversation::Impl::transferManager_ {}

Definition at line 635 of file conversation.cpp.

Referenced by init().

◆ typers_

std::shared_ptr<Typers> jami::Conversation::Impl::typers_

Definition at line 712 of file conversation.cpp.

Referenced by announce(), and init().

◆ userId_

std::string jami::Conversation::Impl::userId_

Definition at line 623 of file conversation.cpp.

Referenced by announce(), and isAdmin().

◆ writeMtx_

std::mutex jami::Conversation::Impl::writeMtx_ {}

Definition at line 618 of file conversation.cpp.

Referenced by voteUnban().


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