From 30b8134016808c100a542d80be51048f4624e19f Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Tue, 21 Jan 2025 10:52:45 +0100 Subject: [PATCH] Import old deprecated friends.db --- Linphone/core/path/Paths.cpp | 8 ++++++++ Linphone/core/path/Paths.hpp | 1 + Linphone/model/core/CoreModel.cpp | 6 ++++++ Linphone/tool/Constants.cpp | 1 + Linphone/tool/Constants.hpp | 1 + 5 files changed, 17 insertions(+) diff --git a/Linphone/core/path/Paths.cpp b/Linphone/core/path/Paths.cpp index 75e24ed1e..a7bb2c568 100644 --- a/Linphone/core/path/Paths.cpp +++ b/Linphone/core/path/Paths.cpp @@ -154,6 +154,10 @@ static inline QString getAppFactoryConfigFilePath() { return getAppPackageDataDirPath() + Constants::PathFactoryConfig; } +static inline QString getAppFriendsFilePath() { + return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathFriendsList; +} + static inline QString getAppRootCaFilePath() { QString rootca = getAppPackageDataDirPath() + Constants::PathRootCa; if (Paths::filePathExists(rootca)) { // Packaged @@ -244,6 +248,10 @@ QString Paths::getFactoryConfigFilePath() { return getReadableFilePath(getAppFactoryConfigFilePath()); } +QString Paths::getFriendsListFilePath() { + return getReadableFilePath(getAppFriendsFilePath()); +} + QString Paths::getDownloadDirPath() { return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QDir::separator()); } diff --git a/Linphone/core/path/Paths.hpp b/Linphone/core/path/Paths.hpp index 166a82e6d..753fcc3eb 100644 --- a/Linphone/core/path/Paths.hpp +++ b/Linphone/core/path/Paths.hpp @@ -40,6 +40,7 @@ QString getConfigFilePath(const QString &configPath = QString(), bool writable = QString getDatabaseFilePath(); QString getDownloadDirPath(); QString getFactoryConfigFilePath(); +QString getFriendsListFilePath(); QString getLimeDatabasePath(); QString getLogsDirPath(); QString getMessageHistoryFilePath(); diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 026cba310..eb6056ffb 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -160,6 +160,12 @@ void CoreModel::setPathBeforeCreation() { } void CoreModel::setPathsAfterCreation() { + auto friendsPath = Paths::getFriendsListFilePath(); + if (!friendsPath.isEmpty() && QFileInfo(friendsPath).exists()) { + lInfo() << log().arg("Using old friends database at %1").arg(friendsPath); + std::shared_ptr config = mCore->getConfig(); + config->setString("storage", "friends_db_uri", Utils::appStringToCoreString(friendsPath)); + } } void CoreModel::setPathAfterStart() { diff --git a/Linphone/tool/Constants.cpp b/Linphone/tool/Constants.cpp index 366d80cc4..2b2c29ae3 100644 --- a/Linphone/tool/Constants.cpp +++ b/Linphone/tool/Constants.cpp @@ -73,6 +73,7 @@ constexpr char Constants::PathCallHistoryList[]; constexpr char Constants::PathConfig[]; constexpr char Constants::PathDatabase[]; constexpr char Constants::PathFactoryConfig[]; +constexpr char Constants::PathFriendsList[]; constexpr char Constants::PathRootCa[]; constexpr char Constants::PathLimeDatabase[]; constexpr char Constants::PathMessageHistoryList[]; diff --git a/Linphone/tool/Constants.hpp b/Linphone/tool/Constants.hpp index b790e945a..ef52f4d33 100644 --- a/Linphone/tool/Constants.hpp +++ b/Linphone/tool/Constants.hpp @@ -147,6 +147,7 @@ public: static constexpr char PathConfig[] = "/linphonerc"; static constexpr char PathDatabase[] = "/linphone.db"; static constexpr char PathFactoryConfig[] = "/" EXECUTABLE_NAME "/linphonerc-factory"; + static constexpr char PathFriendsList[] = "/friends.db"; static constexpr char PathRootCa[] = "/" EXECUTABLE_NAME "/rootca.pem"; static constexpr char PathLimeDatabase[] = "/x3dh.c25519.sqlite3"; static constexpr char PathMessageHistoryList[] = "/message-history.db";