Ring Daemon 16.0.0
|
#include <conversation.h>
Classes | |
class | Impl |
Public Member Functions | |
void | addGitSocket (const DeviceId &deviceId, const std::shared_ptr< dhtnet::ChannelSocket > &socket) |
void | addMember (const std::string &contactUri, const OnDoneCb &cb={}) |
Add conversation member. | |
void | addSwarmChannel (std::shared_ptr< dhtnet::ChannelSocket > channel) |
Add swarm connection to the DRT. | |
void | bootstrap (std::function< void()> onBootstraped, const std::vector< DeviceId > &knownDevices) |
Bootstrap swarm manager to other peers. | |
void | clearCache () |
Clear all cached messages. | |
void | clearFetched () |
Reset fetched information. | |
std::vector< std::string > | commitsEndedCalls () |
Refresh active calls. | |
void | connectivityChanged () |
If we change from one network to one another, we will need to update the state of the connections. | |
Conversation (const std::shared_ptr< JamiAccount > &account, const std::string &conversationId="") | |
Conversation (const std::shared_ptr< JamiAccount > &account, const std::string &remoteDevice, const std::string &conversationId) | |
Conversation (const std::shared_ptr< JamiAccount > &account, ConversationMode mode, const std::string &otherMember="") | |
uint32_t | countInteractions (const std::string &toId, const std::string &fromId="", const std::string &authorUri="") const |
Retrieve how many interactions there is from HEAD to interactionId. | |
std::vector< std::map< std::string, std::string > > | currentCalls () const |
Return current detected calls. | |
std::shared_ptr< TransferManager > | dataTransfer () const |
Access to transfer manager. | |
bool | downloadFile (const std::string &interactionId, const std::string &fileId, const std::string &path, const std::string &member="", const std::string &deviceId="") |
Adds a file to the waiting list and ask members. | |
void | erase () |
Erase all related datas. | |
std::map< std::string, std::string > | generateInvitation () const |
Generate an invitation to send to new contacts. | |
std::optional< std::map< std::string, std::string > > | getCommit (const std::string &commitId) const |
Retrieve one commit. | |
std::vector< jami::DeviceId > | getDeviceIdList () const |
std::vector< std::string > | getInitialMembers () const |
One to one util, get initial members. | |
std::vector< std::map< std::string, std::string > > | getMembers (bool includeInvited=false, bool includeLeft=false, bool includeBanned=false) const |
std::shared_ptr< dhtnet::ChannelSocket > | gitSocket (const DeviceId &deviceId) const |
Git operations will need a ChannelSocket for cloning/fetching commits Because libgit2 is a C library, we store the pointer in the corresponding conversation and the GitTransport will inject to libgit2 whenever needed. | |
void | hasFetched (const std::string &deviceId, const std::string &commitId) |
Store information about who fetch or not. | |
bool | hasSwarmChannel (const std::string &deviceId) |
Used to avoid multiple connections, we just check if we got a swarm channel with a specific device. | |
void | hostConference (Json::Value &&message, OnDoneCb &&cb={}) |
Host a conference in the conversation. | |
std::string | id () const |
Get conversation's id. | |
std::map< std::string, std::string > | infos () const |
Retrieve current infos (title, description, avatar, mode) | |
bool | isBanned (const std::string &uri) const |
bool | isBootstraped () const |
Check if we're at least connected to one node. | |
bool | isHosting (const std::string &confId) const |
Check if we're currently hosting this conference. | |
bool | isInitialMember (const std::string &uri) const |
bool | isMember (const std::string &uri, bool includeInvited=false) const |
Test if an URI is a member. | |
bool | isRemoving () |
Check if we are removing the conversation. | |
std::string | join () |
Join a conversation. | |
std::string | lastCommitId () const |
Get last commit id. | |
std::string | leave () |
Leave a conversation. | |
void | loadMessages (OnLoadMessages cb, const LogOptions &options) |
Get a range of messages. | |
void | loadMessages2 (const OnLoadMessages2 &cb, const LogOptions &options) |
Get a range of messages. | |
std::set< std::string > | memberUris (std::string_view filter={}, const std::set< MemberRole > &filteredRoles={MemberRole::INVITED, MemberRole::LEFT, MemberRole::BANNED}) const |
std::map< std::string, std::map< std::string, std::string > > | messageStatus () const |
Retrieve last displayed and fetch status per member. | |
ConversationMode | mode () const |
Get conversation's mode. | |
void | monitor () |
Print the state of the DRT linked to the conversation. | |
bool | onFileChannelRequest (const std::string &member, const std::string &fileId, std::filesystem::path &path, std::string &sha3sum) const |
Choose if we can accept channel request. | |
void | onMembersChanged (OnMembersChanged &&cb) |
void | onMessageStatusChanged (const std::function< void(const std::map< std::string, std::map< std::string, std::string > > &)> &cb) |
void | onNeedSocket (NeedSocketCb cb) |
Set the callback that will be called whenever a new socket will be needed. | |
std::vector< NodeId > | peersToSyncWith () const |
Get peers to sync with. | |
std::map< std::string, std::string > | preferences (bool includeLastModified) const |
Retrieve current preferences (color, notification, etc) | |
bool | pull (const std::string &deviceId, OnPullCb &&cb, std::string commitId="") |
Fetch and merge from peer. | |
void | removeActiveConference (Json::Value &&message, OnDoneCb &&cb={}) |
Announce the end of a call. | |
void | removeGitSocket (const DeviceId &deviceId) |
void | removeMember (const std::string &contactUri, bool isDevice, const OnDoneCb &cb={}) |
void | search (uint32_t req, const Filter &filter, const std::shared_ptr< std::atomic_int > &flag) const |
Search in the conversation via a filter. | |
void | sendMessage (Json::Value &&message, const std::string &replyTo="", OnCommitCb &&onCommit={}, OnDoneCb &&cb={}) |
void | sendMessage (std::string &&message, const std::string &type="text/plain", const std::string &replyTo="", OnCommitCb &&onCommit={}, OnDoneCb &&cb={}) |
void | sendMessages (std::vector< Json::Value > &&messages, OnMultiDoneCb &&cb={}) |
bool | setMessageDisplayed (const std::string &uri, const std::string &interactionId) |
Store last read commit (returned in getMembers) | |
void | setRemovingFlag () |
Set a conversation as removing (when loading convInfo and still not sync) | |
void | shutdownConnections () |
Stop SwarmManager, bootstrap and gitSockets. | |
void | sync (const std::string &member, const std::string &deviceId, OnPullCb &&cb, std::string commitId="") |
Fetch new commits and re-ask for waiting files. | |
std::shared_ptr< Typers > | typers () const |
Get Typers object. | |
void | updateInfos (const std::map< std::string, std::string > &map, const OnDoneCb &cb={}) |
Change repository's infos. | |
void | updateMessageStatus (const std::map< std::string, std::map< std::string, std::string > > &messageStatus) |
Update fetch/read status. | |
void | updatePreferences (const std::map< std::string, std::string > &map) |
Change user's preferences. | |
std::string | uriFromDevice (const std::string &deviceId) const |
Retrieve the uri from a deviceId. | |
std::vector< uint8_t > | vCard () const |
~Conversation () | |
Definition at line 148 of file conversation.h.
jami::Conversation::Conversation | ( | const std::shared_ptr< JamiAccount > & | account, |
ConversationMode | mode, | ||
const std::string & | otherMember = "" |
||
) |
Definition at line 1288 of file conversation.cpp.
jami::Conversation::Conversation | ( | const std::shared_ptr< JamiAccount > & | account, |
const std::string & | conversationId = "" |
||
) |
Definition at line 1294 of file conversation.cpp.
jami::Conversation::Conversation | ( | const std::shared_ptr< JamiAccount > & | account, |
const std::string & | remoteDevice, | ||
const std::string & | conversationId | ||
) |
Definition at line 1299 of file conversation.cpp.
jami::Conversation::~Conversation | ( | ) |
Definition at line 1305 of file conversation.cpp.
void jami::Conversation::addGitSocket | ( | const DeviceId & | deviceId, |
const std::shared_ptr< dhtnet::ChannelSocket > & | socket | ||
) |
Definition at line 1378 of file conversation.cpp.
Add conversation member.
uri | Member to add |
cb | On done cb |
Definition at line 1314 of file conversation.cpp.
References jami::emitSignal(), getInitialMembers(), isBanned(), isMember(), JAMI_WARN, mode(), and jami::ONE_TO_ONE.
void jami::Conversation::addSwarmChannel | ( | std::shared_ptr< dhtnet::ChannelSocket > | channel | ) |
Add swarm connection to the DRT.
channel | Related channel |
Definition at line 2531 of file conversation.cpp.
References jami::emitSignal().
void jami::Conversation::bootstrap | ( | std::function< void()> | onBootstraped, |
const std::vector< DeviceId > & | knownDevices | ||
) |
Bootstrap swarm manager to other peers.
onBootstraped | Callback called when connection is successfully established |
knownDevices | List of account's known devices |
Definition at line 2417 of file conversation.cpp.
References jami::emitSignal(), isBanned(), and JAMI_DEBUG.
void jami::Conversation::clearCache | ( | ) |
Clear all cached messages.
Definition at line 1727 of file conversation.cpp.
References jami::emitSignal().
void jami::Conversation::clearFetched | ( | ) |
Reset fetched information.
std::vector< std::string > jami::Conversation::commitsEndedCalls | ( | ) |
Refresh active calls.
Definition at line 2495 of file conversation.cpp.
References jami::emitSignal().
void jami::Conversation::connectivityChanged | ( | ) |
If we change from one network to one another, we will need to update the state of the connections.
Definition at line 1402 of file conversation.cpp.
uint32_t jami::Conversation::countInteractions | ( | const std::string & | toId, |
const std::string & | fromId = "" , |
||
const std::string & | authorUri = "" |
||
) | const |
Retrieve how many interactions there is from HEAD to interactionId.
toId | "" for getting the whole history |
fromId | "" => HEAD |
authorURI | author to stop counting |
Definition at line 2552 of file conversation.cpp.
References jami::emitSignal(), and jami::LogOptions::to.
std::vector< std::map< std::string, std::string > > jami::Conversation::currentCalls | ( | ) | const |
Return current detected calls.
Definition at line 2714 of file conversation.cpp.
References jami::emitSignal().
std::shared_ptr< TransferManager > jami::Conversation::dataTransfer | ( | ) | const |
Access to transfer manager.
Definition at line 2096 of file conversation.cpp.
Referenced by onFileChannelRequest().
bool jami::Conversation::downloadFile | ( | const std::string & | interactionId, |
const std::string & | fileId, | ||
const std::string & | path, | ||
const std::string & | member = "" , |
||
const std::string & | deviceId = "" |
||
) |
Adds a file to the waiting list and ask members.
interactionId | Related interaction id |
fileId | Related id |
path | Destination |
member | Member if we know from who to pull file |
deviceId | Device if we know from who to pull file |
Definition at line 2133 of file conversation.cpp.
References jami::emitSignal(), getCommit(), and JAMI_ERROR.
void jami::Conversation::erase | ( | ) |
Erase all related datas.
Definition at line 1989 of file conversation.cpp.
References jami::emitSignal().
std::map< std::string, std::string > jami::Conversation::generateInvitation | ( | ) | const |
Generate an invitation to send to new contacts.
Definition at line 1952 of file conversation.cpp.
References jami::ConversationMapKeys::CONVERSATIONID, jami::emitSignal(), id(), infos(), JAMI_WARNING, jami::ConversationMapKeys::METADATAS, and jami::json::toString().
std::optional< std::map< std::string, std::string > > jami::Conversation::getCommit | ( | const std::string & | commitId | ) | const |
Retrieve one commit.
commitId |
Definition at line 1693 of file conversation.cpp.
References jami::emitSignal().
Referenced by downloadFile(), and onFileChannelRequest().
std::vector< jami::DeviceId > jami::Conversation::getDeviceIdList | ( | ) | const |
Definition at line 1409 of file conversation.cpp.
std::vector< std::string > jami::Conversation::getInitialMembers | ( | ) | const |
One to one util, get initial members.
Definition at line 2006 of file conversation.cpp.
Referenced by addMember(), isInitialMember(), and isMember().
std::vector< std::map< std::string, std::string > > jami::Conversation::getMembers | ( | bool | includeInvited = false , |
bool | includeLeft = false , |
||
bool | includeBanned = false |
||
) | const |
includeInvited | If we want invited members |
includeLeft | If we want left members |
includeBanned | If we want banned members |
Definition at line 1537 of file conversation.cpp.
References jami::emitSignal().
std::shared_ptr< dhtnet::ChannelSocket > jami::Conversation::gitSocket | ( | const DeviceId & | deviceId | ) | const |
Git operations will need a ChannelSocket for cloning/fetching commits Because libgit2 is a C library, we store the pointer in the corresponding conversation and the GitTransport will inject to libgit2 whenever needed.
Definition at line 1372 of file conversation.cpp.
Store information about who fetch or not.
This simplify sync (sync when a device without the last fetch is detected)
deviceId | |
commitId |
Definition at line 2198 of file conversation.cpp.
References jami::emitSignal(), and libjami::Account::SENT.
Used to avoid multiple connections, we just check if we got a swarm channel with a specific device.
deviceId |
Definition at line 1421 of file conversation.cpp.
Host a conference in the conversation.
message | message to commit |
cb | callback triggered when committed |
Definition at line 2665 of file conversation.cpp.
References jami::emitSignal(), JAMI_ERROR, and sendMessage().
std::string jami::Conversation::id | ( | ) | const |
Get conversation's id.
Definition at line 1308 of file conversation.cpp.
Referenced by generateInvitation(), search(), and jami::ConversationModule::Impl::sendMessageNotification().
std::map< std::string, std::string > jami::Conversation::infos | ( | ) | const |
Retrieve current infos (title, description, avatar, mode)
Definition at line 2037 of file conversation.cpp.
Referenced by generateInvitation(), and isHosting().
Definition at line 1625 of file conversation.cpp.
Referenced by addMember(), and bootstrap().
bool jami::Conversation::isBootstraped | ( | ) | const |
Check if we're at least connected to one node.
Definition at line 1565 of file conversation.cpp.
References jami::emitSignal().
Referenced by jami::ConversationModule::Impl::sendMessageNotification().
Check if we're currently hosting this conference.
confId |
Definition at line 2684 of file conversation.cpp.
References jami::emitSignal(), and infos().
Definition at line 2012 of file conversation.cpp.
References getInitialMembers().
Test if an URI is a member.
uri | URI to test |
Definition at line 1590 of file conversation.cpp.
References jami::emitSignal(), getInitialMembers(), JAMI_WARNING, mode(), and jami::ONE_TO_ONE.
Referenced by addMember(), and onFileChannelRequest().
bool jami::Conversation::isRemoving | ( | ) |
Check if we are removing the conversation.
Definition at line 1983 of file conversation.cpp.
std::string jami::Conversation::join | ( | ) |
std::string jami::Conversation::lastCommitId | ( | ) | const |
Get last commit id.
Definition at line 1741 of file conversation.cpp.
References jami::emitSignal(), and jami::LogOptions::nbOfCommits.
Referenced by jami::ConversationModule::Impl::sendMessageNotification().
std::string jami::Conversation::leave | ( | ) |
Leave a conversation.
Definition at line 1969 of file conversation.cpp.
References jami::emitSignal(), and setRemovingFlag().
void jami::Conversation::loadMessages | ( | OnLoadMessages | cb, |
const LogOptions & | options | ||
) |
Get a range of messages.
cb | The callback when loaded |
options | The log options |
Definition at line 1702 of file conversation.cpp.
References jami::emitSignal().
Referenced by jami::Conversation::Impl::pull().
void jami::Conversation::loadMessages2 | ( | const OnLoadMessages2 & | cb, |
const LogOptions & | options | ||
) |
Get a range of messages.
cb | The callback when loaded |
options | The log options |
Definition at line 1714 of file conversation.cpp.
References jami::emitSignal().
Referenced by jami::Conversation::Impl::updateStatus().
std::set< std::string > jami::Conversation::memberUris | ( | std::string_view | filter = {} , |
const std::set< MemberRole > & | filteredRoles = {MemberRole::INVITED, MemberRole::LEFT, MemberRole::BANNED} |
||
) | const |
filter | If we want to remove one member |
filteredRoles | If we want to ignore some roles |
Definition at line 1543 of file conversation.cpp.
References jami::emitSignal().
Referenced by onMembersChanged(), and jami::ConversationModule::Impl::sendMessageNotification().
std::map< std::string, std::map< std::string, std::string > > jami::Conversation::messageStatus | ( | ) | const |
Retrieve last displayed and fetch status per member.
Definition at line 2289 of file conversation.cpp.
References jami::emitSignal().
Referenced by updateMessageStatus().
ConversationMode jami::Conversation::mode | ( | ) | const |
Get conversation's mode.
Definition at line 2000 of file conversation.cpp.
Referenced by addMember(), and isMember().
void jami::Conversation::monitor | ( | ) |
Print the state of the DRT linked to the conversation.
Definition at line 1578 of file conversation.cpp.
bool jami::Conversation::onFileChannelRequest | ( | const std::string & | member, |
const std::string & | fileId, | ||
std::filesystem::path & | path, | ||
std::string & | sha3sum | ||
) | const |
Choose if we can accept channel request.
member | member to check |
fileId | file transfer to check (needs to be waiting) |
verifyShaSum | for debug only |
Definition at line 2102 of file conversation.cpp.
References dataTransfer(), jami::emitSignal(), getCommit(), isMember(), and JAMI_WARNING.
void jami::Conversation::onMembersChanged | ( | OnMembersChanged && | cb | ) |
Definition at line 2511 of file conversation.cpp.
References jami::emitSignal(), and memberUris().
void jami::Conversation::onMessageStatusChanged | ( | const std::function< void(const std::map< std::string, std::map< std::string, std::string > > &)> & | cb | ) |
Definition at line 2321 of file conversation.cpp.
References jami::emitSignal().
void jami::Conversation::onNeedSocket | ( | NeedSocketCb | cb | ) |
Set the callback that will be called whenever a new socket will be needed.
cb |
Definition at line 2521 of file conversation.cpp.
References jami::emitSignal().
std::vector< NodeId > jami::Conversation::peersToSyncWith | ( | ) | const |
Get peers to sync with.
This is mostly managed by the DRT
Definition at line 1549 of file conversation.cpp.
References _, and jami::emitSignal().
Referenced by jami::ConversationModule::Impl::sendMessageNotification().
std::map< std::string, std::string > jami::Conversation::preferences | ( | bool | includeLastModified | ) | const |
Retrieve current preferences (color, notification, etc)
includeLastModified | If we want to know when the preferences were modified |
Definition at line 2069 of file conversation.cpp.
References jami::emitSignal(), jami::LAST_MODIFIED, jami::fileutils::lastWriteTimeInSeconds(), jami::fileutils::loadFile(), and preferences().
Referenced by preferences().
bool jami::Conversation::pull | ( | const std::string & | deviceId, |
OnPullCb && | cb, | ||
std::string | commitId = "" |
||
) |
Fetch and merge from peer.
deviceId | Peer device |
cb | On pulled callback |
commitId | Commit id that triggered this fetch |
Definition at line 1810 of file conversation.cpp.
References jami::emitSignal(), and JAMI_DEBUG.
Referenced by sync().
Announce the end of a call.
message | message to commit |
cb | callback triggered when committed |
Definition at line 2694 of file conversation.cpp.
References jami::emitSignal(), JAMI_ERROR, and sendMessage().
Definition at line 1385 of file conversation.cpp.
void jami::Conversation::removeMember | ( | const std::string & | contactUri, |
bool | isDevice, | ||
const OnDoneCb & | cb = {} |
||
) |
Definition at line 1467 of file conversation.cpp.
References jami::ADMIN, jami::emitSignal(), jami::INVITED, JAMI_WARN, and jami::MEMBER.
void jami::Conversation::search | ( | uint32_t | req, |
const Filter & | filter, | ||
const std::shared_ptr< std::atomic_int > & | flag | ||
) | const |
Search in the conversation via a filter.
req | Id of the request |
filter | Parameters for the search |
flag | To check when search is finished |
Definition at line 2569 of file conversation.cpp.
References jami::Break, jami::emitSignal(), id(), jami::Ok, std::regex_search(), and jami::Skip.
void jami::Conversation::sendMessage | ( | Json::Value && | message, |
const std::string & | replyTo = "" , |
||
OnCommitCb && | onCommit = {} , |
||
OnDoneCb && | cb = {} |
||
) |
Definition at line 1644 of file conversation.cpp.
References jami::emitSignal(), and JAMI_ERR.
void jami::Conversation::sendMessage | ( | std::string && | message, |
const std::string & | type = "text/plain" , |
||
const std::string & | replyTo = "" , |
||
OnCommitCb && | onCommit = {} , |
||
OnDoneCb && | cb = {} |
||
) |
Definition at line 1631 of file conversation.cpp.
References jami::emitSignal(), and sendMessage().
Referenced by hostConference(), removeActiveConference(), and sendMessage().
void jami::Conversation::sendMessages | ( | std::vector< Json::Value > && | messages, |
OnMultiDoneCb && | cb = {} |
||
) |
Definition at line 1673 of file conversation.cpp.
References jami::emitSignal().
bool jami::Conversation::setMessageDisplayed | ( | const std::string & | uri, |
const std::string & | interactionId | ||
) |
Store last read commit (returned in getMembers)
uri | Of the member |
interactionId | Last interaction displayed |
Definition at line 2274 of file conversation.cpp.
References libjami::Account::DISPLAYED, and jami::emitSignal().
void jami::Conversation::setRemovingFlag | ( | ) |
Set a conversation as removing (when loading convInfo and still not sync)
Definition at line 1977 of file conversation.cpp.
Referenced by leave().
void jami::Conversation::shutdownConnections | ( | ) |
Stop SwarmManager, bootstrap and gitSockets.
Definition at line 1391 of file conversation.cpp.
References jami::emitSignal().
void jami::Conversation::sync | ( | const std::string & | member, |
const std::string & | deviceId, | ||
OnPullCb && | cb, | ||
std::string | commitId = "" |
||
) |
Fetch new commits and re-ask for waiting files.
Definition at line 1936 of file conversation.cpp.
References jami::emitSignal(), and pull().
std::shared_ptr< Typers > jami::Conversation::typers | ( | ) | const |
void jami::Conversation::updateInfos | ( | const std::map< std::string, std::string > & | map, |
const OnDoneCb & | cb = {} |
||
) |
Change repository's infos.
map | New infos (supported keys: title, description, avatar) |
cb | On commited |
Definition at line 2019 of file conversation.cpp.
References jami::emitSignal().
void jami::Conversation::updateMessageStatus | ( | const std::map< std::string, std::map< std::string, std::string > > & | messageStatus | ) |
Update fetch/read status.
messageStatus | A map with the following structure: {uri, { {"fetch", "commitId"}, {"fetched_ts", "timestamp"}, {"read", "commitId"}, {"read_ts", "timestamp"} } } |
Definition at line 2296 of file conversation.cpp.
References libjami::Account::DISPLAYED, jami::emitSignal(), messageStatus(), and libjami::Account::SENT.
Change user's preferences.
map | New preferences |
Definition at line 2043 of file conversation.cpp.
References jami::emitSignal(), jami::LAST_MODIFIED, and jami::fileutils::lastWriteTimeInSeconds().
std::string jami::Conversation::uriFromDevice | ( | const std::string & | deviceId | ) | const |
Retrieve the uri from a deviceId.
deviceId |
Definition at line 1572 of file conversation.cpp.
Referenced by jami::ConversationModule::Impl::sendMessageNotification().
std::vector< uint8_t > jami::Conversation::vCard | ( | ) | const |
Definition at line 2086 of file conversation.cpp.
References jami::fileutils::loadFile().