diff --git a/bin/dbus/cx.ring.Ring.ConfigurationManager.xml b/bin/dbus/cx.ring.Ring.ConfigurationManager.xml index d42b6094b5ff48a1b0cffa89ff50544852111014..9a84f2666dae976bf37c40bb69b0bad572b45f68 100644 --- a/bin/dbus/cx.ring.Ring.ConfigurationManager.xml +++ b/bin/dbus/cx.ring.Ring.ConfigurationManager.xml @@ -510,54 +510,6 @@ </arg> </method> - <method name="importAccounts" tp:name-for-bindings="importAccounts"> - <tp:docstring> - Import previously exported accounts - </tp:docstring> - <arg type="s" name="path" direction="in"> - <tp:docstring> - Path of the file to import - </tp:docstring> - </arg> - <arg type="s" name="password" direction="in"> - <tp:docstring> - Decryption password - </tp:docstring> - </arg> - <arg type="i" direction="out"> - <tp:docstring> - <p>Return code, 0 for success.</p> - </tp:docstring> - </arg> - </method> - - <method name="exportAccounts" tp:name-for-bindings="exportAccounts"> - <tp:docstring> - Export account configuration to an encrypted file. - </tp:docstring> - <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="VectorString"/> - <arg type="as" name="accountIDs" direction="in"> - <tp:docstring> - A list of account IDs - </tp:docstring> - </arg> - <arg type="s" name="filepath" direction="in"> - <tp:docstring> - Where to export the account - </tp:docstring> - </arg> - <arg type="s" name="password" direction="in"> - <tp:docstring> - File encryption password - </tp:docstring> - </arg> - <arg type="i" direction="out"> - <tp:docstring> - <p>Return code, 0 for success.</p> - </tp:docstring> - </arg> - </method> - <method name="registerAllAccounts" tp:name-for-bindings="registerAllAccounts"> <tp:docstring> Send account registration (REGISTER) for all accounts, even if they are not enabled. diff --git a/bin/dbus/dbusconfigurationmanager.cpp b/bin/dbus/dbusconfigurationmanager.cpp index c29d2ffe9cb5c6303cb69a3c27ea66991bb09a68..aeeadb13114059b1b9dfa884cda141daefe31be4 100644 --- a/bin/dbus/dbusconfigurationmanager.cpp +++ b/bin/dbus/dbusconfigurationmanager.cpp @@ -737,22 +737,6 @@ DBusConfigurationManager::getVolume(const std::string& device) -> decltype(DRing return DRing::getVolume(device); } -auto -DBusConfigurationManager::exportAccounts(const std::vector<std::string>& accountIDs, - const std::string& filepath, - const std::string& password) - -> decltype(DRing::exportAccounts(accountIDs, filepath, password)) -{ - return DRing::exportAccounts(accountIDs, filepath, password); -} - -auto -DBusConfigurationManager::importAccounts(const std::string& archivePath, const std::string& password) - -> decltype(DRing::importAccounts(archivePath, password)) -{ - return DRing::importAccounts(archivePath, password); -} - void DBusConfigurationManager::connectivityChanged() { diff --git a/bin/dbus/dbusconfigurationmanager.h b/bin/dbus/dbusconfigurationmanager.h index 1400b6b7c3dcf03a321e687ccdbdb9a45d265f69..e0b56ce8835423d9c2a914d7535e87ef2a504ccf 100644 --- a/bin/dbus/dbusconfigurationmanager.h +++ b/bin/dbus/dbusconfigurationmanager.h @@ -173,8 +173,6 @@ public: void removeContact(const std::string& accountId, const std::string& uri, const bool& ban); std::map<std::string, std::string> getContactDetails(const std::string& accountId, const std::string& uri); std::vector<std::map<std::string, std::string>> getContacts(const std::string& accountId); - int exportAccounts(const std::vector<std::string>& accountIDs, const std::string& filepath, const std::string& password); - int importAccounts(const std::string& archivePath, const std::string& password); void connectivityChanged(); std::vector<uint64_t> dataTransferList(); void sendFile(const RingDBusDataTransferInfo& info, uint32_t& error, DRing::DataTransferId& id); diff --git a/bin/jni/configurationmanager.i b/bin/jni/configurationmanager.i index 3a2f9445c9bebb93bb759d59ccaccd7c0a17ce78..66c4916ad6a4f24de843127e8792dedec0a71aec 100644 --- a/bin/jni/configurationmanager.i +++ b/bin/jni/configurationmanager.i @@ -218,9 +218,6 @@ void addContact(const std::string& accountId, const std::string& uri); void removeContact(const std::string& accountId, const std::string& uri, const bool& ban); std::vector<std::map<std::string, std::string>> getContacts(const std::string& accountId); -int exportAccounts(const std::vector<std::string>& accountIDs, const std::string& toDir, const std::string& password); -int importAccounts(const std::string& archivePath, const std::string& password); - void connectivityChanged(); void enableProxyClient(const std::string& accountID, bool enable); diff --git a/bin/nodejs/configurationmanager.i b/bin/nodejs/configurationmanager.i index 596dfd7d77745a0f96b074284500f47ce858c92b..7f2f019c4b26faf3dcdfcf7de7eccb5df345be29 100644 --- a/bin/nodejs/configurationmanager.i +++ b/bin/nodejs/configurationmanager.i @@ -208,9 +208,6 @@ void addContact(const std::string& accountId, const std::string& uri); void removeContact(const std::string& accountId, const std::string& uri, const bool& ban); std::vector<std::map<std::string, std::string>> getContacts(const std::string& accountId); -int exportAccounts(std::vector<std::string> accountIDs, std::string toDir, std::string password); -int importAccounts(std::string archivePath, std::string password); - void connectivityChanged(); bool isAudioMeterActive(const std::string& id); diff --git a/src/archiver.cpp b/src/archiver.cpp index 9650c5c541df356850bf1d5d5a5c6eb993a796fe..776b020514d534faf45c3eaeecc80d441b36b6ae 100644 --- a/src/archiver.cpp +++ b/src/archiver.cpp @@ -106,128 +106,6 @@ accountToJsonValue(const std::map<std::string, std::string>& details) return root; } -int -exportAccounts(const std::vector<std::string>& accountIDs, - const std::string& filepath, - const std::string& password) -{ - if (filepath.empty() || !accountIDs.size()) { - JAMI_ERR("Missing arguments"); - return EINVAL; - } - - std::size_t found = filepath.find_last_of(DIR_SEPARATOR_CH); - auto toDir = filepath.substr(0, found); - auto filename = filepath.substr(found + 1); - - if (!fileutils::isDirectory(toDir)) { - JAMI_ERR("%s is not a directory", toDir.c_str()); - return ENOTDIR; - } - - // Add - Json::Value root; - Json::Value array; - - for (size_t i = 0; i < accountIDs.size(); ++i) { - auto detailsMap = Manager::instance().getAccountDetails(accountIDs[i]); - if (detailsMap.empty()) { - JAMI_WARN("Can't export account %s", accountIDs[i].c_str()); - continue; - } - - auto jsonAccount = accountToJsonValue(detailsMap); - array.append(jsonAccount); - } - root["accounts"] = array; - Json::StreamWriterBuilder wbuilder; - wbuilder["commentStyle"] = "None"; - wbuilder["indentation"] = ""; - auto output = Json::writeString(wbuilder, root); - - // Compress - std::vector<uint8_t> compressed; - try { - compressed = compress(output); - } catch (const std::runtime_error& ex) { - JAMI_ERR("Export failed: %s", ex.what()); - return 1; - } - - // Encrypt using provided password - auto encrypted = dht::crypto::aesEncrypt(compressed, password); - - // Write - try { - fileutils::saveFile(toDir + DIR_SEPARATOR_STR + filename, encrypted); - } catch (const std::runtime_error& ex) { - JAMI_ERR("Export failed: %s", ex.what()); - return EIO; - } - return 0; -} - -int -importAccounts(const std::string& archivePath, const std::string& password) -{ - if (archivePath.empty()) { - JAMI_ERR("Missing arguments"); - return EINVAL; - } - - // Read file - std::vector<uint8_t> file; - try { - file = fileutils::loadFile(archivePath); - } catch (const std::exception& ex) { - JAMI_ERR("Read failed: %s", ex.what()); - return ENOENT; - } - - // Decrypt - try { - file = dht::crypto::aesDecrypt(file, password); - } catch (const std::exception& ex) { - JAMI_ERR("Decryption failed: %s", ex.what()); - return EPERM; - } - - // Decompress - try { - file = decompress(file); - } catch (const std::exception& ex) { - JAMI_ERR("Decompression failed: %s", ex.what()); - return ERANGE; - } - - try { - const auto* char_file_begin = reinterpret_cast<const char*>(&file[0]); - const auto* char_file_end = char_file_begin + file.size(); - - // Add - std::string err; - Json::Value root; - Json::CharReaderBuilder rbuilder; - auto reader = std::unique_ptr<Json::CharReader>(rbuilder.newCharReader()); - if (!reader->parse(char_file_begin, char_file_end, &root, &err)) { - JAMI_ERR() << "Failed to parse " << err; - return ERANGE; - } - - auto& accounts = root["accounts"]; - for (int i = 0, n = accounts.size(); i < n; ++i) { - // Generate a new account id - auto accountId = jami::Manager::instance().getNewAccountId(); - auto details = jsonValueToAccount(accounts[i], accountId); - jami::Manager::instance().addAccount(details, accountId); - } - } catch (const std::exception& ex) { - JAMI_ERR("Import failed: %s", ex.what()); - return ERANGE; - } - return 0; -} - std::vector<uint8_t> compress(const std::string& str) { diff --git a/src/archiver.h b/src/archiver.h index e4333abb4b48481fbedf37e8f5300afbaaac1a58..33553f51a9fee09c7954cd5e1dba8bc9e8c07eb8 100644 --- a/src/archiver.h +++ b/src/archiver.h @@ -42,26 +42,6 @@ namespace archiver { using FileMatchPair = std::function<std::pair<bool, const std::string>(const std::string&)>; -/** - * Create a protected archive containing a list of accounts - * @param accountIDs The accounts to exports - * @param filepath The filepath where to put the resulting archive - * @param password The mandatory password to set on the archive - * @returns 0 for OK, error code otherwise - */ -int exportAccounts(const std::vector<std::string>& accountIDs, - const std::string& filepath, - const std::string& password); - -/** - * Read a protected archive and add accounts found in it - * Warning: this function must be called from a registered pjsip thread - * @param archivePath The path to the archive file - * @param password The password to read the archive - * @returns 0 for OK, error code otherwise - */ -int importAccounts(const std::string& archivePath, const std::string& password); - /** * Compress a STL string using zlib with given compression level and return * the binary data. diff --git a/src/client/configurationmanager.cpp b/src/client/configurationmanager.cpp index ba947450f76cc172f54d521444897cca0698a588..d86f9367dc10fc315440e1f90026aa54e0c68045 100644 --- a/src/client/configurationmanager.cpp +++ b/src/client/configurationmanager.cpp @@ -424,23 +424,6 @@ sendTrustRequest(const std::string& accountId, acc->sendTrustRequest(to, payload); } -/* - * Import/Export accounts - */ -int -exportAccounts(const std::vector<std::string>& accountIDs, - const std::string& filepath, - const std::string& password) -{ - return jami::archiver::exportAccounts(accountIDs, filepath, password); -} - -int -importAccounts(const std::string& archivePath, const std::string& password) -{ - return jami::archiver::importAccounts(archivePath, password); -} - /// This function is used as a base for new accounts for clients that support it std::map<std::string, std::string> getAccountTemplate(const std::string& accountType) diff --git a/src/dring/configurationmanager_interface.h b/src/dring/configurationmanager_interface.h index 1c388d34ebc9b66e3e1d965b3db2057545ee8e1f..e528e504c39760930a0be369940a5bd60bf0f494 100644 --- a/src/dring/configurationmanager_interface.h +++ b/src/dring/configurationmanager_interface.h @@ -239,14 +239,6 @@ DRING_PUBLIC std::map<std::string, std::string> getContactDetails(const std::str DRING_PUBLIC std::vector<std::map<std::string, std::string>> getContacts( const std::string& accountId); -/* - * Import/Export accounts - */ -DRING_PUBLIC int exportAccounts(const std::vector<std::string>& accountIDs, - const std::string& filepath, - const std::string& password); -DRING_PUBLIC int importAccounts(const std::string& archivePath, const std::string& password); - /* * Network connectivity */