diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 88f3e01f7..6c7602427 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -441,6 +441,16 @@ void App::setSelf(QSharedPointer(me)) { }); } }); + mCoreModelConnection->makeConnectToModel(&CoreModel::fetchConfigFailed, [this](const QString &message) { + if (mMainWindow) { + Utils::showInformationPopup(tr("info_popup_error_title"), message, false); + } else { + connect( + this, &App::mainWindowChanged, this, + [this, message] { Utils::showInformationPopup(tr("info_popup_error_title"), message, false); }, + Qt::SingleShotConnection); + } + }); mCoreModelConnection->makeConnectToModel( &CoreModel::accountAdded, [this](const std::shared_ptr &core, const std::shared_ptr &account) { @@ -822,31 +832,39 @@ void App::initCore() { firstOpen = false; lInfo() << log().arg("Checking remote provisioning"); if (mIsRestarting) { - if (CoreModel::getInstance()->mConfigStatus == linphone::ConfiguringState::Failed) { - QMetaObject::invokeMethod(thread(), [this]() { - mustBeInMainThread(log().arg(Q_FUNC_INFO)); - auto message = CoreModel::getInstance()->mConfigMessage; - //: not reachable - if (message.isEmpty()) message = tr("configuration_error_detail"); - lWarning() << log().arg("Configuration failed (reason: %1)").arg(message); - //: Error - Utils::showInformationPopup( - tr("info_popup_error_title"), - //: Remote provisioning failed : %1 - tr("info_popup_configuration_failed_message").arg(message), false); - }); - } else if (CoreModel::getInstance()->mConfigStatus == - linphone::ConfiguringState::Successful) { - lInfo() << log().arg("Configuration succeed"); - mPossiblyLookForAddedAccount = true; - if (mAccountList && mAccountList->getCount() > 0) { - auto defaultConnected = - mAccountList->getDefaultAccountCore() && - mAccountList->getDefaultAccountCore()->getRegistrationState() == - LinphoneEnums::RegistrationState::Ok; - QMetaObject::invokeMethod(mMainWindow, "openMainPage", Qt::DirectConnection, - Q_ARG(QVariant, defaultConnected)); + auto handleConfigStatus = [this] { + if (CoreModel::getInstance()->mConfigStatus == linphone::ConfiguringState::Failed) { + QMetaObject::invokeMethod(thread(), [this]() { + mustBeInMainThread(log().arg(Q_FUNC_INFO)); + auto message = CoreModel::getInstance()->mConfigMessage; + //: not reachable + if (message.isEmpty()) message = tr("configuration_error_detail"); + lWarning() << log().arg("Configuration failed (reason: %1)").arg(message); + //: Error + Utils::showInformationPopup( + tr("info_popup_error_title"), + //: Remote provisioning failed : %1 + tr("info_popup_configuration_failed_message").arg(message), false); + }); + } else if (CoreModel::getInstance()->mConfigStatus == + linphone::ConfiguringState::Successful) { + lInfo() << log().arg("Configuration succeed"); + mPossiblyLookForAddedAccount = true; + if (mAccountList && mAccountList->getCount() > 0) { + auto defaultConnected = + mAccountList->getDefaultAccountCore() && + mAccountList->getDefaultAccountCore()->getRegistrationState() == + LinphoneEnums::RegistrationState::Ok; + QMetaObject::invokeMethod(mMainWindow, "openMainPage", Qt::DirectConnection, + Q_ARG(QVariant, defaultConnected)); + } } + }; + if (mMainWindow) { + handleConfigStatus(); + } else { + connect(this, &App::mainWindowChanged, this, handleConfigStatus, + Qt::SingleShotConnection); } } if (mSettings->autoCheckForUpdateOnStart()) checkForUpdate(); diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 89c11163e..f221bf707 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -222,9 +222,6 @@ QString CoreModel::getFetchConfig(QString filePath, bool *error) { } if (filePath.isEmpty()) { lWarning() << "Remote provisioning path cannot be retrieved. Command have been cleaned"; - Utils::showInformationPopup(tr("info_popup_error_title"), - //: "Remote provisioning cannot be retrieved" - tr("fetching_config_failed_error_message"), false); *error = true; } } @@ -249,7 +246,9 @@ void CoreModel::useFetchConfig(QString filePath, bool askForConfirmation) { Qt::SingleShotConnection); } } else { - lWarning() << log().arg("Could not get file path for fetching config, return"); + lWarning() << log().arg("Could not get file path for fetching config"); + //: "Could not get file path for fetching config, return" + emit fetchConfigFailed(tr("fetching_config_empty_path_failure_error_message")); } } diff --git a/Linphone/model/core/CoreModel.hpp b/Linphone/model/core/CoreModel.hpp index f9b6c2bbd..08cfe3cf0 100644 --- a/Linphone/model/core/CoreModel.hpp +++ b/Linphone/model/core/CoreModel.hpp @@ -95,6 +95,7 @@ signals: void bearerAccountAdded(); void unreadNotificationsChanged(); void requestFetchConfig(QString path, bool askForConfirmation); + void fetchConfigFailed(const QString &message); void requestRestart(); void enabledLdapAddressBookSaved(); void magicSearchResultReceived(QString filter);