diff --git a/src/components/core/CoreManager.cpp b/src/components/core/CoreManager.cpp index e99c37221..3e36a6ba5 100644 --- a/src/components/core/CoreManager.cpp +++ b/src/components/core/CoreManager.cpp @@ -74,7 +74,7 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : mInstance->mAccountSettingsModel = new AccountSettingsModel(mInstance); mInstance->mStarted = true; - + mInstance->migrate(); emit mInstance->coreStarted(); }); @@ -234,6 +234,32 @@ void CoreManager::createLinphoneCore (const QString &configPath) { setOtherPaths(); } +#define RC_VERSION_NAME "rc_version" +#define RC_VERSION_CURRENT 1 + +void CoreManager::migrate () { + shared_ptr config = mCore->getConfig(); + int rcVersion = config->getInt(SettingsModel::UI_SECTION, RC_VERSION_NAME, 0); + if (rcVersion == RC_VERSION_CURRENT) + return; + if (rcVersion > RC_VERSION_CURRENT) { + qWarning() << "RC file version (" << rcVersion << ") is more recent than app rc file version (" << RC_VERSION_CURRENT << ")!!!"; + return; + } + + qInfo() << "Migrate from old rc file (" << rcVersion << "to" << RC_VERSION_CURRENT << ")."; + + // Add message_expires param on old proxy configs. + for (const auto &proxyConfig : mCore->getProxyConfigList()) { + if (proxyConfig->getDomain() == "sip.linphone.org") { + proxyConfig->setContactParameters("message-expires=604800"); + proxyConfig->setExpires(3600); + proxyConfig->done(); + } + } + config->setInt(SettingsModel::UI_SECTION, RC_VERSION_NAME, RC_VERSION_CURRENT); +} + // ----------------------------------------------------------------------------- QString CoreManager::getVersion () const { diff --git a/src/components/core/CoreManager.hpp b/src/components/core/CoreManager.hpp index f0c0e51b7..90300db20 100644 --- a/src/components/core/CoreManager.hpp +++ b/src/components/core/CoreManager.hpp @@ -143,6 +143,7 @@ private: void setResourcesPaths (); void createLinphoneCore (const QString &configPath); + void migrate(); QString getVersion () const;