wait for main window to be created to display fetch config error #LINQT-2413

This commit is contained in:
Gaelle Braud 2026-03-18 12:12:02 +01:00
parent 8a8f095d68
commit 22ca1cec23
3 changed files with 48 additions and 28 deletions

View file

@ -444,6 +444,16 @@ void App::setSelf(QSharedPointer<App>(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<linphone::Core> &core, const std::shared_ptr<linphone::Account> &account) {
@ -821,31 +831,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);
}
}
checkForUpdate();

View file

@ -223,10 +223,7 @@ QString CoreModel::getFetchConfig(QString filePath, bool *error) {
if (!filePath.isEmpty()) filePath = "file://" + filePath;
}
if (filePath.isEmpty()) {
qWarning() << "Remote provisioning 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);
lWarning() << "Remote provisioning path cannot be retrieved. Command have been cleaned";
*error = true;
}
}
@ -247,6 +244,10 @@ void CoreModel::useFetchConfig(QString filePath, bool askForConfirmation) {
this, &CoreModel::globalStateChanged, this, [filePath, this]() { useFetchConfig(filePath); },
Qt::SingleShotConnection);
}
} else {
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"));
}
}

View file

@ -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);