From 62f26f24fdbcda1c1601061c4170d882b30af02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Mon, 5 Oct 2020 14:08:42 -0400 Subject: [PATCH] account manager: check for the dht, cleanup Change-Id: If9665ff40b4e8fff09d66bdb9c0fb557dafbe0c0 --- src/jamidht/archive_account_manager.cpp | 2 +- src/jamidht/jamiaccount.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/jamidht/archive_account_manager.cpp b/src/jamidht/archive_account_manager.cpp index 19f77647d4..90b7c06a4d 100644 --- a/src/jamidht/archive_account_manager.cpp +++ b/src/jamidht/archive_account_manager.cpp @@ -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(), diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 8d15d33cfa..9313f6220a 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -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()); -- GitLab