Commit 62f26f24 authored by Adrien Béraud's avatar Adrien Béraud

account manager: check for the dht, cleanup

Change-Id: If9665ff40b4e8fff09d66bdb9c0fb557dafbe0c0
parent 739f823f
......@@ -617,7 +617,7 @@ ArchiveAccountManager::addDevice(const std::string& password, AddDeviceCallback
try {
this_.updateArchive(a);
auto encrypted = dht::crypto::aesEncrypt(archiver::compress(a.serialize()), key);
if (not this_.dht_->isRunning())
if (not this_.dht_ or not this_.dht_->isRunning())
throw std::runtime_error("DHT is not running..");
JAMI_WARN("[Auth] exporting account with PIN: %s at %s (size %zu)",
pin_str.c_str(),
......
......@@ -979,12 +979,16 @@ JamiAccount::changeArchivePassword(const std::string& password_old, const std::s
bool
JamiAccount::isPasswordValid(const std::string& password)
{
return accountManager_->isPasswordValid(password);
return accountManager_ and accountManager_->isPasswordValid(password);
}
void
JamiAccount::addDevice(const std::string& password)
{
if (not accountManager_) {
emitSignal<DRing::ConfigurationSignal::ExportOnRingEnded>(getAccountID(), 2, "");
return;
}
accountManager_
->addDevice(password, [this](AccountManager::AddDeviceResult result, std::string pin) {
switch (result) {
......@@ -3491,7 +3495,7 @@ JamiAccount::requestSIPConnection(const std::string& peerId, const std::string&
{
// If a connection already exists or is in progress, no need to do this
std::lock_guard<std::mutex> lk(sipConnectionsMtx_);
auto id = std::make_pair<std::string, std::string>(std::string(peerId), std::string(deviceId));
const auto& id = std::make_pair(peerId, deviceId);
if (!sipConnections_[peerId][deviceId].empty()
|| pendingSipConnections_.find(id) != pendingSipConnections_.end()) {
JAMI_DBG("A SIP connection with %s already exists", deviceId.c_str());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment