mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Add paths settings to SDK.
This commit is contained in:
parent
b6ff625370
commit
57b678674f
3 changed files with 73 additions and 6 deletions
|
|
@ -40,6 +40,6 @@ QString Settings::getConfigPath(const QCommandLineParser &parser) {
|
|||
// Utils::coreStringToAppString(Paths::getConfigDirPath(false)), true));
|
||||
}
|
||||
if (configPath == "") configPath = Paths::getConfigFilePath(filePath, false);
|
||||
if (configPath == "") configPath = Paths::getConfigFilePath("", false);
|
||||
if (configPath == "" && !filePath.isEmpty()) configPath = Paths::getConfigFilePath("", false);
|
||||
return configPath;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <QSysInfo>
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/path/Paths.hpp"
|
||||
#include "tool/Utils.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -41,10 +42,14 @@ CoreModel::~CoreModel() {
|
|||
}
|
||||
|
||||
void CoreModel::start() {
|
||||
auto configPath = Utils::appStringToCoreString(mConfigPath);
|
||||
mCore = linphone::Factory::get()->createCore(configPath, "", nullptr);
|
||||
mCore->enableAutoIterate(true);
|
||||
setPathBeforeCreation();
|
||||
mCore =
|
||||
linphone::Factory::get()->createCore(Utils::appStringToCoreString(Paths::getConfigFilePath(mConfigPath)),
|
||||
Utils::appStringToCoreString(Paths::getFactoryConfigFilePath()), nullptr);
|
||||
setPathsAfterCreation();
|
||||
mCore->start();
|
||||
setPathAfterStart();
|
||||
mCore->enableAutoIterate(true);
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -55,3 +60,56 @@ CoreModel *CoreModel::getInstance() {
|
|||
std::shared_ptr<linphone::Core> CoreModel::getCore() {
|
||||
return mCore;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
void CoreModel::setConfigPath(QString path) {
|
||||
if (mConfigPath != path) {
|
||||
mConfigPath = path;
|
||||
if (!mCore) {
|
||||
qWarning() << "[CoreModel] Setting config path after core creation is not yet supported";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// PATHS
|
||||
//-------------------------------------------------------------------------------
|
||||
#define SET_FACTORY_PATH(TYPE, PATH) \
|
||||
do { \
|
||||
qInfo() << QStringLiteral("[CoreModel] Set `%1` factory path: `%2`").arg(#TYPE).arg(PATH); \
|
||||
factory->set##TYPE##Dir(Utils::appStringToCoreString(PATH)); \
|
||||
} while (0);
|
||||
|
||||
void CoreModel::setPathBeforeCreation() {
|
||||
std::shared_ptr<linphone::Factory> factory = linphone::Factory::get();
|
||||
SET_FACTORY_PATH(Msplugins, Paths::getPackageMsPluginsDirPath());
|
||||
SET_FACTORY_PATH(TopResources, Paths::getPackageTopDirPath());
|
||||
SET_FACTORY_PATH(SoundResources, Paths::getPackageSoundsResourcesDirPath());
|
||||
SET_FACTORY_PATH(DataResources, Paths::getPackageDataDirPath());
|
||||
SET_FACTORY_PATH(Data, Paths::getAppLocalDirPath());
|
||||
SET_FACTORY_PATH(Download, Paths::getDownloadDirPath());
|
||||
SET_FACTORY_PATH(Config, Paths::getConfigDirPath(true));
|
||||
}
|
||||
|
||||
void CoreModel::setPathsAfterCreation() {
|
||||
QString friendsDb = Paths::getFriendsListFilePath();
|
||||
qInfo() << QStringLiteral("[CoreModel] Set Database `Friends` path: `%1`").arg(friendsDb);
|
||||
mCore->setFriendsDatabasePath(Utils::appStringToCoreString(friendsDb));
|
||||
}
|
||||
|
||||
void CoreModel::setPathAfterStart() {
|
||||
// Use application path if Linphone default is not available
|
||||
if (mCore->getZrtpSecretsFile().empty() ||
|
||||
!Paths::filePathExists(Utils::coreStringToAppString(mCore->getZrtpSecretsFile()), true))
|
||||
mCore->setZrtpSecretsFile(Utils::appStringToCoreString(Paths::getZrtpSecretsFilePath()));
|
||||
qInfo() << "[CoreModel] Using ZrtpSecrets path : " << QString::fromStdString(mCore->getZrtpSecretsFile());
|
||||
// Use application path if Linphone default is not available
|
||||
if (mCore->getUserCertificatesPath().empty() ||
|
||||
!Paths::filePathExists(Utils::coreStringToAppString(mCore->getUserCertificatesPath()), true))
|
||||
mCore->setUserCertificatesPath(Utils::appStringToCoreString(Paths::getUserCertificatesDirPath()));
|
||||
qInfo() << "[CoreModel] Using UserCertificate path : " << QString::fromStdString(mCore->getUserCertificatesPath());
|
||||
// Use application path if Linphone default is not available
|
||||
if (mCore->getRootCa().empty() || !Paths::filePathExists(Utils::coreStringToAppString(mCore->getRootCa())))
|
||||
mCore->setRootCa(Utils::appStringToCoreString(Paths::getRootCaFilePath()));
|
||||
qInfo() << "[CoreModel] Using RootCa path : " << QString::fromStdString(mCore->getRootCa());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,15 +42,24 @@ public:
|
|||
void start();
|
||||
|
||||
static CoreModel *getInstance();
|
||||
|
||||
void setConfigPath(QString path);
|
||||
|
||||
|
||||
bool mEnd = false;
|
||||
QString mConfigPath;
|
||||
|
||||
std::shared_ptr<linphone::Core> mCore;
|
||||
std::shared_ptr<LoggerModel> mLogger;
|
||||
|
||||
signals:
|
||||
void loggerInitialized();
|
||||
private:
|
||||
QString mConfigPath;
|
||||
|
||||
void setPathBeforeCreation();
|
||||
void setPathsAfterCreation();
|
||||
void setPathAfterStart();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue