Import old deprecated friends.db

This commit is contained in:
Julien Wadel 2025-01-21 10:52:45 +01:00
parent e79af38bb2
commit 30b8134016
5 changed files with 17 additions and 0 deletions

View file

@ -154,6 +154,10 @@ static inline QString getAppFactoryConfigFilePath() {
return getAppPackageDataDirPath() + Constants::PathFactoryConfig; return getAppPackageDataDirPath() + Constants::PathFactoryConfig;
} }
static inline QString getAppFriendsFilePath() {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathFriendsList;
}
static inline QString getAppRootCaFilePath() { static inline QString getAppRootCaFilePath() {
QString rootca = getAppPackageDataDirPath() + Constants::PathRootCa; QString rootca = getAppPackageDataDirPath() + Constants::PathRootCa;
if (Paths::filePathExists(rootca)) { // Packaged if (Paths::filePathExists(rootca)) { // Packaged
@ -244,6 +248,10 @@ QString Paths::getFactoryConfigFilePath() {
return getReadableFilePath(getAppFactoryConfigFilePath()); return getReadableFilePath(getAppFactoryConfigFilePath());
} }
QString Paths::getFriendsListFilePath() {
return getReadableFilePath(getAppFriendsFilePath());
}
QString Paths::getDownloadDirPath() { QString Paths::getDownloadDirPath() {
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QDir::separator()); return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QDir::separator());
} }

View file

@ -40,6 +40,7 @@ QString getConfigFilePath(const QString &configPath = QString(), bool writable =
QString getDatabaseFilePath(); QString getDatabaseFilePath();
QString getDownloadDirPath(); QString getDownloadDirPath();
QString getFactoryConfigFilePath(); QString getFactoryConfigFilePath();
QString getFriendsListFilePath();
QString getLimeDatabasePath(); QString getLimeDatabasePath();
QString getLogsDirPath(); QString getLogsDirPath();
QString getMessageHistoryFilePath(); QString getMessageHistoryFilePath();

View file

@ -160,6 +160,12 @@ void CoreModel::setPathBeforeCreation() {
} }
void CoreModel::setPathsAfterCreation() { 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<linphone::Config> config = mCore->getConfig();
config->setString("storage", "friends_db_uri", Utils::appStringToCoreString(friendsPath));
}
} }
void CoreModel::setPathAfterStart() { void CoreModel::setPathAfterStart() {

View file

@ -73,6 +73,7 @@ constexpr char Constants::PathCallHistoryList[];
constexpr char Constants::PathConfig[]; constexpr char Constants::PathConfig[];
constexpr char Constants::PathDatabase[]; constexpr char Constants::PathDatabase[];
constexpr char Constants::PathFactoryConfig[]; constexpr char Constants::PathFactoryConfig[];
constexpr char Constants::PathFriendsList[];
constexpr char Constants::PathRootCa[]; constexpr char Constants::PathRootCa[];
constexpr char Constants::PathLimeDatabase[]; constexpr char Constants::PathLimeDatabase[];
constexpr char Constants::PathMessageHistoryList[]; constexpr char Constants::PathMessageHistoryList[];

View file

@ -147,6 +147,7 @@ public:
static constexpr char PathConfig[] = "/linphonerc"; static constexpr char PathConfig[] = "/linphonerc";
static constexpr char PathDatabase[] = "/linphone.db"; static constexpr char PathDatabase[] = "/linphone.db";
static constexpr char PathFactoryConfig[] = "/" EXECUTABLE_NAME "/linphonerc-factory"; 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 PathRootCa[] = "/" EXECUTABLE_NAME "/rootca.pem";
static constexpr char PathLimeDatabase[] = "/x3dh.c25519.sqlite3"; static constexpr char PathLimeDatabase[] = "/x3dh.c25519.sqlite3";
static constexpr char PathMessageHistoryList[] = "/message-history.db"; static constexpr char PathMessageHistoryList[] = "/message-history.db";