diff --git a/bin/dbus/cx.ring.Ring.ConfigurationManager.xml b/bin/dbus/cx.ring.Ring.ConfigurationManager.xml index 59d9dbd9bb43a8fea64604a1a8b2db22ad1b438f..348f7ab247182ed1e2dd45f7588433dd59f71153 100644 --- a/bin/dbus/cx.ring.Ring.ConfigurationManager.xml +++ b/bin/dbus/cx.ring.Ring.ConfigurationManager.xml @@ -178,6 +178,8 @@ </arg> <arg type="s" name="destinationPath" direction="in"> </arg> + <arg type="s" name="password" direction="in"> + </arg> <arg type="b" name="success" direction="out"> <tp:docstring> True if the operation was initialized successfully. diff --git a/bin/dbus/dbusconfigurationmanager.cpp b/bin/dbus/dbusconfigurationmanager.cpp index 94d1a264fe8a8658e3ded53c9fa76d537dfadff7..248e94198d7155d75a5d1b0ed32979844ca98cc8 100644 --- a/bin/dbus/dbusconfigurationmanager.cpp +++ b/bin/dbus/dbusconfigurationmanager.cpp @@ -82,9 +82,9 @@ DBusConfigurationManager::exportOnRing(const std::string& accountID, const std:: } auto -DBusConfigurationManager::exportToFile(const std::string& accountID, const std::string& destinationPath) -> decltype(DRing::exportToFile(accountID, destinationPath)) +DBusConfigurationManager::exportToFile(const std::string& accountID, const std::string& destinationPath, const std::string& password) -> decltype(DRing::exportToFile(accountID, destinationPath, password)) { - return DRing::exportToFile(accountID, destinationPath); + return DRing::exportToFile(accountID, destinationPath, password); } auto diff --git a/bin/dbus/dbusconfigurationmanager.h b/bin/dbus/dbusconfigurationmanager.h index 73033cdbc70e0c17bf10a1bf906042921105ddc6..b12f7e0f51493fe4a831c35560e5cac16a911eaf 100644 --- a/bin/dbus/dbusconfigurationmanager.h +++ b/bin/dbus/dbusconfigurationmanager.h @@ -71,7 +71,7 @@ class DRING_PUBLIC DBusConfigurationManager : std::map<std::string, std::string> getAccountTemplate(const std::string& accountType); std::string addAccount(const std::map<std::string, std::string>& details); bool exportOnRing(const std::string& accountID, const std::string& password); - bool exportToFile(const std::string& accountID, const std::string& destinationPath); + bool exportToFile(const std::string& accountID, const std::string& destinationPath, const std::string& password = {}); bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& device); std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID); bool changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new); diff --git a/bin/jni/configurationmanager.i b/bin/jni/configurationmanager.i index 324ababcd7912c80da6a2ccadd4b90da5eebd622..62430da0ce0a28083b6ffdded9b9c8acc6fd811e 100644 --- a/bin/jni/configurationmanager.i +++ b/bin/jni/configurationmanager.i @@ -98,7 +98,7 @@ std::map<std::string, std::string> getCodecDetails(const std::string& accountID, bool setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details); std::vector<unsigned> getActiveCodecList(const std::string& accountID); bool exportOnRing(const std::string& accountID, const std::string& password); -bool exportToFile(const std::string& accountID, const std::string& destinationPath); +bool exportToFile(const std::string& accountID, const std::string& destinationPath, const std::string& password); std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID); bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID); diff --git a/bin/nodejs/configurationmanager.i b/bin/nodejs/configurationmanager.i index af83132312d42fc89282b6ee2f103ae48e656613..a86d6aae579a79b11022ccbae2af94b31f86db1a 100644 --- a/bin/nodejs/configurationmanager.i +++ b/bin/nodejs/configurationmanager.i @@ -94,7 +94,7 @@ std::map<std::string, std::string> getCodecDetails(const std::string& accountID, bool setCodecDetails(const std::string& accountID, const unsigned& codecId, const std::map<std::string, std::string>& details); std::vector<unsigned> getActiveCodecList(const std::string& accountID); bool exportOnRing(const std::string& accountID, const std::string& password); -bool exportToFile(const std::string& accountID, const std::string& destinationPath); +bool exportToFile(const std::string& accountID, const std::string& destinationPath, const std::string& password); std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID); bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID); diff --git a/configure.ac b/configure.ac index 5419cc2c2e2cff1194ed5fe89e11fe04cdabaf92..8fbc2827629836f500fb9ed7a5ee1cc56a5b8daa 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Jami - configure.ac for automake 1.9 and autoconf 2.59 dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([Ring Daemon],[7.1.0],[ring@gnu.org],[ring]) +AC_INIT([Ring Daemon],[7.2.0],[ring@gnu.org],[ring]) AC_COPYRIGHT([[Copyright (c) Savoir-faire Linux 2004-2018]]) AC_REVISION([$Revision$]) diff --git a/src/client/configurationmanager.cpp b/src/client/configurationmanager.cpp index 88c7da174bda4a85ea095d7af0b0e9a68f6e572b..c567bf8a8f4e531a64178dad43551c455137a926 100644 --- a/src/client/configurationmanager.cpp +++ b/src/client/configurationmanager.cpp @@ -284,10 +284,10 @@ exportOnRing(const std::string& accountID, const std::string& password) } bool -exportToFile(const std::string& accountID, const std::string& destinationPath) +exportToFile(const std::string& accountID, const std::string& destinationPath, const std::string& password) { if (const auto account = ring::Manager::instance().getAccount<ring::RingAccount>(accountID)) { - return account->exportArchive(destinationPath); + return account->exportArchive(destinationPath, password); } return false; } diff --git a/src/dring/configurationmanager_interface.h b/src/dring/configurationmanager_interface.h index edca75c4b2553c89f7567cfffdfa52d82f0ff69e..9e6d4a918428d329b180a0bcad2d5f30f2451250 100644 --- a/src/dring/configurationmanager_interface.h +++ b/src/dring/configurationmanager_interface.h @@ -60,7 +60,7 @@ DRING_PUBLIC void setAccountActive(const std::string& accountID, bool active); DRING_PUBLIC std::map<std::string, std::string> getAccountTemplate(const std::string& accountType); DRING_PUBLIC std::string addAccount(const std::map<std::string, std::string>& details); DRING_PUBLIC bool exportOnRing(const std::string& accountID, const std::string& password); -DRING_PUBLIC bool exportToFile(const std::string& accountID, const std::string& destinationPath); +DRING_PUBLIC bool exportToFile(const std::string& accountID, const std::string& destinationPath, const std::string& password = {}); DRING_PUBLIC bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID); DRING_PUBLIC std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID); DRING_PUBLIC bool changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new); diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index cb72bf260a4cab1956cd9cb5c4d7838d7e8b7021..522fd58f2003027b206deb76f603de878d0cd410 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -1086,9 +1086,17 @@ RingAccount::addDevice(const std::string& password) } bool -RingAccount::exportArchive(const std::string& destinationPath) +RingAccount::exportArchive(const std::string& destinationPath, const std::string& password) { try { + // Save contacts if possible before exporting + AccountArchive archive; + if (!archiveHasPassword_ || !password.empty()) { + archive = readArchive(password); + updateArchive(archive); + archive.save(fileutils::getFullPath(idPath_, archivePath_), password); + } + // Export the file auto sourcePath = fileutils::getFullPath(idPath_, archivePath_); std::ifstream src(sourcePath, std::ios::in | std::ios::binary); if (!src) return false; @@ -1097,6 +1105,9 @@ RingAccount::exportArchive(const std::string& destinationPath) } catch (const std::runtime_error& ex) { RING_ERR("[Account %s] Can't export archive: %s", getAccountID().c_str(), ex.what()); return false; + } catch (...) { + RING_ERR("[Account %s] Can't export archive: can't read archive", getAccountID().c_str()); + return false; } return true; } diff --git a/src/ringdht/ringaccount.h b/src/ringdht/ringaccount.h index ea8d3da485e5d6abf6a20fa83ebb565c0bb1bccc..2bf02d69c046c1799b8a583aafcb70daab57de4e 100644 --- a/src/ringdht/ringaccount.h +++ b/src/ringdht/ringaccount.h @@ -313,7 +313,13 @@ class RingAccount : public SIPAccountBase { /* Devices */ void addDevice(const std::string& password); - bool exportArchive(const std::string& destinationPath); + /** + * Export the archive to a file + * @param destinationPath + * @param (optional) password, if not provided, will update the contacts only if the archive doesn't have a password + * @return if the archive was exported + */ + bool exportArchive(const std::string& destinationPath, const std::string& password = {}); bool revokeDevice(const std::string& password, const std::string& device); std::map<std::string, std::string> getKnownDevices() const;