diff --git a/src/dring/account_const.h b/src/dring/account_const.h index 8258a362944907fc5c6751ed3c996e01e6445e50..d3ea1705ab929f5a86ee52195c214a1d7c1f15f3 100644 --- a/src/dring/account_const.h +++ b/src/dring/account_const.h @@ -130,6 +130,7 @@ constexpr static const char ALLOW_CERT_FROM_HISTORY [] = "Account.allowCertFromH constexpr static const char ALLOW_CERT_FROM_CONTACT [] = "Account.allowCertFromContact"; constexpr static const char ALLOW_CERT_FROM_TRUSTED [] = "Account.allowCertFromTrusted"; constexpr static const char ARCHIVE_PASSWORD [] = "Account.archivePassword"; +constexpr static const char ARCHIVE_HAS_PASSWORD [] = "Account.archiveHasPassword"; constexpr static const char ARCHIVE_PATH [] = "Account.archivePath"; constexpr static const char ARCHIVE_PIN [] = "Account.archivePIN"; constexpr static const char RING_DEVICE_ID [] = "Account.deviceID"; diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index 301ae8b9a5c99d11e3315730703d25c72fc7e647..693b9b2e50d70e566a6a00666ac0cb0571b3d721 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -621,6 +621,7 @@ void RingAccount::serialize(YAML::Emitter &out) #endif out << YAML::Key << DRing::Account::ConfProperties::ARCHIVE_PATH << YAML::Value << archivePath_; + out << YAML::Key << DRing::Account::ConfProperties::ARCHIVE_HAS_PASSWORD << YAML::Value << archiveHasPassword_; out << YAML::Key << Conf::RING_ACCOUNT_RECEIPT << YAML::Value << receipt_; out << YAML::Key << Conf::RING_ACCOUNT_RECEIPT_SIG << YAML::Value << YAML::Binary(receiptSignature_.data(), receiptSignature_.size()); out << YAML::Key << DRing::Account::ConfProperties::RING_DEVICE_NAME << YAML::Value << ringDeviceName_; @@ -667,8 +668,10 @@ void RingAccount::unserialize(const YAML::Node &node) try { parsePath(node, DRing::Account::ConfProperties::ARCHIVE_PATH, archivePath_, idPath_); + parseValue(node, DRing::Account::ConfProperties::ARCHIVE_HAS_PASSWORD, archiveHasPassword_); } catch (const std::exception& e) { RING_WARN("can't read archive path: %s", e.what()); + archiveHasPassword_ = true; } try { @@ -920,6 +923,7 @@ RingAccount::saveArchive(AccountArchive& archive, const std::string& pwd) if (archivePath_.empty()) archivePath_ = "export.gz"; archive.save(fileutils::getFullPath(idPath_, archivePath_), pwd); + archiveHasPassword_ = not pwd.empty(); } catch (const std::runtime_error& ex) { RING_ERR("[Account %s] Can't export archive: %s", getAccountID().c_str(), ex.what()); return; @@ -932,6 +936,7 @@ RingAccount::changeArchivePassword(const std::string& password_old, const std::s auto path = fileutils::getFullPath(idPath_, archivePath_); try { AccountArchive(path, password_old).save(path, password_new); + archiveHasPassword_ = not password_new.empty(); } catch (const std::exception& ex) { RING_ERR("[Account %s] Can't change archive password: %s", getAccountID().c_str(), ex.what()); return false; @@ -1451,6 +1456,8 @@ RingAccount::getAccountDetails() const a.emplace(DRing::Account::ConfProperties::RING_DEVICE_ID, ringDeviceId_); a.emplace(DRing::Account::ConfProperties::RING_DEVICE_NAME, ringDeviceName_); a.emplace(DRing::Account::ConfProperties::Presence::SUPPORT_SUBSCRIBE, TRUE_STR); + if (not archivePath_.empty()) + a.emplace(DRing::Account::ConfProperties::ARCHIVE_HAS_PASSWORD, archiveHasPassword_ ? TRUE_STR : FALSE_STR); /* these settings cannot be changed (read only), but clients should still be * able to read what they are */ diff --git a/src/ringdht/ringaccount.h b/src/ringdht/ringaccount.h index 472259cb3789e0828ebc538cf5c99d38729c19ad..5b36df9647a32a051437b56afa16c089ae981f08 100644 --- a/src/ringdht/ringaccount.h +++ b/src/ringdht/ringaccount.h @@ -451,6 +451,7 @@ class RingAccount : public SIPAccountBase { std::string ethAccount_ {}; std::string archivePath_ {}; + bool archiveHasPassword_ {true}; std::string receipt_ {}; std::vector<uint8_t> receiptSignature_ {};