Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::ContactList Class Reference

#include <contact_list.h>

Collaboration diagram for jami::ContactList:
Collaboration graph

Classes

struct  OnChangeCallback
 

Public Types

using clock = std::chrono::system_clock
 
using OnAcceptConversation = std::function< void(const std::string &, const std::string &)>
 
using OnConfirmation = std::function< void(const std::string &, const std::string &)>
 
using OnContactAdded = std::function< void(const std::string &, bool)>
 
using OnContactRemoved = std::function< void(const std::string &, bool)>
 
using OnDevicesChanged = std::function< void(const std::map< dht::PkId, KnownDevice > &)>
 
using OnIncomingTrustRequest = std::function< void(const std::string &, const std::string &, const std::vector< uint8_t > &, time_t)>
 
using time_point = clock::time_point
 
using VerifyResult = dht::crypto::TrustList::VerifyResult
 

Public Member Functions

void acceptConversation (const std::string &convId, const std::string &deviceId="")
 
bool acceptTrustRequest (const dht::InfoHash &from)
 
const std::string & accountId () const
 
bool addContact (const dht::InfoHash &, bool confirmed=false, const std::string &conversationId="")
 
 ContactList (const std::string &accountId, const std::shared_ptr< crypto::Certificate > &cert, const std::filesystem::path &path, OnChangeCallback cb)
 
bool discardTrustRequest (const dht::InfoHash &from)
 
void foundAccountDevice (const dht::PkId &device, const std::string &name={}, const time_point &last_sync=time_point::min())
 
bool foundAccountDevice (const std::shared_ptr< dht::crypto::Certificate > &crt, const std::string &name={}, const time_point &last_sync=time_point::min(), bool notify=true)
 
std::string getAccountDeviceName (const dht::PkId &device) const
 
std::vector< std::string > getCertificatesByStatus (dhtnet::tls::TrustStore::PermissionStatus status) const
 
dhtnet::tls::TrustStore::PermissionStatus getCertificateStatus (const std::string &cert_id) const
 
std::map< std::string, std::string > getContactDetails (const dht::InfoHash &) const
 
std::optional< ContactgetContactInfo (const dht::InfoHash &) const
 
const std::map< dht::InfoHash, Contact > & getContacts () const
 
const std::map< dht::PkId, KnownDevice > & getKnownDevices () const
 
DeviceSync getSyncData () const
 
std::map< std::string, std::string > getTrustRequest (const dht::InfoHash &from) const
 
std::vector< std::map< std::string, std::string > > getTrustRequests () const
 
bool isAllowed (const crypto::Certificate &crt, bool allowPublic)
 
VerifyResult isValidAccountDevice (const crypto::Certificate &crt) const
 
void load ()
 
bool onTrustRequest (const dht::InfoHash &peer_account, const std::shared_ptr< dht::crypto::PublicKey > &peer_device, time_t received, bool confirm, const std::string &conversationId, std::vector< uint8_t > &&payload)
 Inform of a new contact request.
 
const std::filesystem::path & path () const
 
bool removeAccountDevice (const dht::PkId &device)
 
bool removeContact (const dht::InfoHash &, bool ban)
 
bool removeContactConversation (const dht::InfoHash &)
 
void save ()
 
void saveContacts () const
 Should be called only after updateContact.
 
void setAccountDeviceName (const dht::PkId &device, const std::string &name)
 
bool setCertificateStatus (const std::shared_ptr< crypto::Certificate > &cert, dhtnet::tls::TrustStore::PermissionStatus status, bool local=true)
 
bool setCertificateStatus (const std::string &cert_id, const dhtnet::tls::TrustStore::PermissionStatus status)
 
void setContacts (const std::map< dht::InfoHash, Contact > &)
 
bool syncDevice (const dht::PkId &device, const time_point &syncDate)
 
void updateContact (const dht::InfoHash &, const Contact &, bool emit=true)
 
void updateConversation (const dht::InfoHash &h, const std::string &conversationId)
 
 ~ContactList ()
 

Detailed Description

Definition at line 31 of file contact_list.h.

Member Typedef Documentation

◆ clock

using jami::ContactList::clock = std::chrono::system_clock

Definition at line 34 of file contact_list.h.

◆ OnAcceptConversation

using jami::ContactList::OnAcceptConversation = std::function<void(const std::string&, const std::string&)>

Definition at line 42 of file contact_list.h.

◆ OnConfirmation

using jami::ContactList::OnConfirmation = std::function<void(const std::string&, const std::string&)>

Definition at line 43 of file contact_list.h.

◆ OnContactAdded

using jami::ContactList::OnContactAdded = std::function<void(const std::string&, bool)>

Definition at line 38 of file contact_list.h.

◆ OnContactRemoved

using jami::ContactList::OnContactRemoved = std::function<void(const std::string&, bool)>

Definition at line 39 of file contact_list.h.

◆ OnDevicesChanged

using jami::ContactList::OnDevicesChanged = std::function<void(const std::map<dht::PkId, KnownDevice>&)>

Definition at line 44 of file contact_list.h.

◆ OnIncomingTrustRequest

using jami::ContactList::OnIncomingTrustRequest = std::function< void(const std::string&, const std::string&, const std::vector<uint8_t>&, time_t)>

Definition at line 40 of file contact_list.h.

◆ time_point

using jami::ContactList::time_point = clock::time_point

Definition at line 35 of file contact_list.h.

◆ VerifyResult

using jami::ContactList::VerifyResult = dht::crypto::TrustList::VerifyResult

Definition at line 36 of file contact_list.h.

Constructor & Destructor Documentation

◆ ContactList()

jami::ContactList::ContactList ( const std::string &  accountId,
const std::shared_ptr< crypto::Certificate > &  cert,
const std::filesystem::path &  path,
OnChangeCallback  cb 
)

Definition at line 34 of file contact_list.cpp.

References jami::emitSignal(), and jami::Manager::instance().

Here is the call graph for this function:

◆ ~ContactList()

jami::ContactList::~ContactList ( )

Definition at line 48 of file contact_list.cpp.

Member Function Documentation

◆ acceptConversation()

void jami::ContactList::acceptConversation ( const std::string &  convId,
const std::string &  deviceId = "" 
)

Definition at line 424 of file contact_list.cpp.

References jami::ContactList::OnChangeCallback::acceptConversation, and jami::emitSignal().

Here is the call graph for this function:

◆ acceptTrustRequest()

bool jami::ContactList::acceptTrustRequest ( const dht::InfoHash &  from)

Definition at line 407 of file contact_list.cpp.

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

Here is the call graph for this function:

◆ accountId()

const std::string & jami::ContactList::accountId ( ) const
inline

Definition at line 62 of file contact_list.h.

◆ addContact()

bool jami::ContactList::addContact ( const dht::InfoHash &  h,
bool  confirmed = false,
const std::string &  conversationId = "" 
)

Definition at line 86 of file contact_list.cpp.

References jami::ContactList::OnChangeCallback::contactAdded, jami::emitSignal(), JAMI_WARNING, and saveContacts().

Referenced by acceptTrustRequest().

Here is the call graph for this function:

◆ discardTrustRequest()

bool jami::ContactList::discardTrustRequest ( const dht::InfoHash &  from)

Definition at line 431 of file contact_list.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ foundAccountDevice() [1/2]

void jami::ContactList::foundAccountDevice ( const dht::PkId &  device,
const std::string &  name = {},
const time_point last_sync = time_point::min() 
)

Definition at line 486 of file contact_list.cpp.

References jami::ContactList::OnChangeCallback::devicesChanged, jami::emitSignal(), and JAMI_LOG.

Here is the call graph for this function:

◆ foundAccountDevice() [2/2]

bool jami::ContactList::foundAccountDevice ( const std::shared_ptr< dht::crypto::Certificate > &  crt,
const std::string &  name = {},
const time_point last_sync = time_point::min(),
bool  notify = true 
)

◆ getAccountDeviceName()

std::string jami::ContactList::getAccountDeviceName ( const dht::PkId &  device) const

Definition at line 581 of file contact_list.cpp.

◆ getCertificatesByStatus()

std::vector< std::string > jami::ContactList::getCertificatesByStatus ( dhtnet::tls::TrustStore::PermissionStatus  status) const
inline

Definition at line 90 of file contact_list.h.

◆ getCertificateStatus()

dhtnet::tls::TrustStore::PermissionStatus jami::ContactList::getCertificateStatus ( const std::string &  cert_id) const
inline

Definition at line 85 of file contact_list.h.

References jami::emitSignal().

Here is the call graph for this function:

◆ getContactDetails()

std::map< std::string, std::string > jami::ContactList::getContactDetails ( const dht::InfoHash &  h) const

Definition at line 160 of file contact_list.cpp.

References jami::emitSignal(), and JAMI_WARNING.

Here is the call graph for this function:

◆ getContactInfo()

std::optional< Contact > jami::ContactList::getContactInfo ( const dht::InfoHash &  h) const

Definition at line 176 of file contact_list.cpp.

References JAMI_WARNING.

◆ getContacts()

const std::map< dht::InfoHash, Contact > & jami::ContactList::getContacts ( ) const

Definition at line 187 of file contact_list.cpp.

Referenced by getSyncData().

◆ getKnownDevices()

const std::map< dht::PkId, KnownDevice > & jami::ContactList::getKnownDevices ( ) const
inline

Definition at line 131 of file contact_list.h.

◆ getSyncData()

DeviceSync jami::ContactList::getSyncData ( ) const

Definition at line 591 of file contact_list.cpp.

References jami::DeviceSync::date, jami::TrustRequest::device, jami::emitSignal(), and getContacts().

Here is the call graph for this function:

◆ getTrustRequest()

std::map< std::string, std::string > jami::ContactList::getTrustRequest ( const dht::InfoHash &  from) const

◆ getTrustRequests()

std::vector< std::map< std::string, std::string > > jami::ContactList::getTrustRequests ( ) const

◆ isAllowed()

bool jami::ContactList::isAllowed ( const crypto::Certificate &  crt,
bool  allowPublic 
)
inline

Definition at line 95 of file contact_list.h.

References jami::emitSignal().

Here is the call graph for this function:

◆ isValidAccountDevice()

VerifyResult jami::ContactList::isValidAccountDevice ( const crypto::Certificate &  crt) const
inline

Definition at line 100 of file contact_list.h.

References jami::emitSignal().

Here is the call graph for this function:

◆ load()

void jami::ContactList::load ( )

Definition at line 51 of file contact_list.cpp.

◆ onTrustRequest()

bool jami::ContactList::onTrustRequest ( const dht::InfoHash &  peer_account,
const std::shared_ptr< dht::crypto::PublicKey > &  peer_device,
time_t  received,
bool  confirm,
const std::string &  conversationId,
std::vector< uint8_t > &&  payload 
)

Inform of a new contact request.

Returns true if the request should be immediatly accepted (already a contact)

Definition at line 306 of file contact_list.cpp.

References jami::ContactList::OnChangeCallback::contactAdded, jami::emitSignal(), JAMI_LOG, jami::ContactList::OnChangeCallback::onConfirmation, and jami::ContactList::OnChangeCallback::trustRequest.

Here is the call graph for this function:

◆ path()

const std::filesystem::path & jami::ContactList::path ( ) const
inline

Definition at line 112 of file contact_list.h.

◆ removeAccountDevice()

bool jami::ContactList::removeAccountDevice ( const dht::PkId &  device)

Definition at line 558 of file contact_list.cpp.

◆ removeContact()

bool jami::ContactList::removeContact ( const dht::InfoHash &  h,
bool  ban 
)

Definition at line 119 of file contact_list.cpp.

References jami::ContactList::OnChangeCallback::contactRemoved, jami::emitSignal(), jami::Manager::instance(), JAMI_WARNING, and saveContacts().

Here is the call graph for this function:

◆ removeContactConversation()

bool jami::ContactList::removeContactConversation ( const dht::InfoHash &  h)

Definition at line 149 of file contact_list.cpp.

References saveContacts().

Here is the call graph for this function:

◆ save()

void jami::ContactList::save ( )

Definition at line 59 of file contact_list.cpp.

References saveContacts().

Here is the call graph for this function:

◆ saveContacts()

void jami::ContactList::saveContacts ( ) const

Should be called only after updateContact.

Definition at line 262 of file contact_list.cpp.

References jami::emitSignal(), and JAMI_LOG.

Referenced by addContact(), removeContact(), removeContactConversation(), save(), setContacts(), and updateConversation().

Here is the call graph for this function:

◆ setAccountDeviceName()

void jami::ContactList::setAccountDeviceName ( const dht::PkId &  device,
const std::string &  name 
)

◆ setCertificateStatus() [1/2]

bool jami::ContactList::setCertificateStatus ( const std::shared_ptr< crypto::Certificate > &  cert,
dhtnet::tls::TrustStore::PermissionStatus  status,
bool  local = true 
)

Definition at line 78 of file contact_list.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ setCertificateStatus() [2/2]

bool jami::ContactList::setCertificateStatus ( const std::string &  cert_id,
const dhtnet::tls::TrustStore::PermissionStatus  status 
)

Definition at line 67 of file contact_list.cpp.

References jami::emitSignal(), and JAMI_LOG.

Here is the call graph for this function:

◆ setContacts()

void jami::ContactList::setContacts ( const std::map< dht::InfoHash, Contact > &  contacts)

Definition at line 193 of file contact_list.cpp.

References jami::ContactList::OnChangeCallback::contactAdded, JAMI_LOG, and saveContacts().

Here is the call graph for this function:

◆ syncDevice()

bool jami::ContactList::syncDevice ( const dht::PkId &  device,
const time_point syncDate 
)

Definition at line 635 of file contact_list.cpp.

References JAMI_LOG, and JAMI_WARNING.

◆ updateContact()

void jami::ContactList::updateContact ( const dht::InfoHash &  id,
const Contact contact,
bool  emit = true 
)

◆ updateConversation()

void jami::ContactList::updateConversation ( const dht::InfoHash &  h,
const std::string &  conversationId 
)

Definition at line 109 of file contact_list.cpp.

References saveContacts().

Here is the call graph for this function:

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