fix fetch config with url and do not display confirmation popup if fetching from url or cli

This commit is contained in:
Gaelle Braud 2026-02-06 12:46:49 +01:00
parent da15f94443
commit bbb60d884a
4 changed files with 28 additions and 13 deletions

View file

@ -363,9 +363,13 @@ void App::setSelf(QSharedPointer<App>(me)) {
restart();
});
});
mCoreModelConnection->makeConnectToModel(&CoreModel::requestFetchConfig, [this](QString path) {
mCoreModelConnection->invokeToCore([this, path]() {
auto callback = [this, path]() {
mCoreModelConnection->makeConnectToModel(&CoreModel::requestFetchConfig, [this](QString path,
bool askForConfirmation) {
mCoreModelConnection->invokeToCore([this, path, askForConfirmation]() {
auto apply = [this, path] {
mCoreModelConnection->invokeToModel([this, path]() { CoreModel::getInstance()->setFetchConfig(path); });
};
auto callback = [this, path, askForConfirmation]() {
//: Voulez-vous télécharger et appliquer la configuration depuis cette adresse ?
RequestDialog *obj = new RequestDialog(tr("remote_provisioning_dialog"), path);
connect(obj, &RequestDialog::result, this, [this, obj, path](int result) {
@ -380,9 +384,12 @@ void App::setSelf(QSharedPointer<App>(me)) {
QMetaObject::invokeMethod(getMainWindow(), "showConfirmationPopup", QVariant::fromValue(obj));
};
if (!getMainWindow()) { // Delay
connect(this, &App::mainWindowChanged, this, callback, Qt::SingleShotConnection);
if (askForConfirmation)
connect(this, &App::mainWindowChanged, this, callback, Qt::SingleShotConnection);
else connect(this, &App::mainWindowChanged, this, apply, Qt::SingleShotConnection);
} else {
callback();
if (askForConfirmation) callback();
else apply();
}
});
});

View file

@ -133,7 +133,7 @@ void CliModel::cliFetchConfig(QHash<QString, QString> args) {
connect(
CoreModel::getInstance().get(), &CoreModel::globalStateChanged, this,
[this, args]() { cliFetchConfig(args); }, Qt::SingleShotConnection);
else CoreModel::getInstance()->useFetchConfig(args["fetch-config"]);
else CoreModel::getInstance()->useFetchConfig(args["fetch-config"], false);
}
}
@ -310,13 +310,21 @@ void CliModel::Command::executeUrl(const QString &pUrl, CliModel *parent) {
QStringList urlParts = pUrl.split('?');
QString query = (urlParts.size() > 1 ? urlParts[1] : urlParts[0]);
QString authority = (urlParts.size() > 1 && urlParts[0].contains(':') ? urlParts[0].split(':')[1] : "");
lDebug() << QStringLiteral("CliModel : execute url : %1").arg(query);
QStringList parameters = query.split('&');
for (int i = 0; i < parameters.size(); ++i) {
QStringList parameter = parameters[i].split('=');
if (parameter[0] != "method") {
if (parameter.size() > 1) args[parameter[0]] = QByteArray::fromBase64(parameter[1].toUtf8());
else args[parameter[0]] = "";
lDebug() << QStringLiteral("CliModel : Detecting parameter : %1").arg(parameter[0]);
QHash<QString, QString> args = parent->parseArgs(parameters[i]);
for (auto it = args.begin(); it != args.end(); ++it) {
auto subfonction = parent->parseFunctionName(it.key(), true);
if (!subfonction.isEmpty()) {
QHash<QString, QString> arg;
arg[it.key()] = QByteArray::fromBase64(it.value().toUtf8());
lDebug() << "parsing parameters" << it.key() << it.value();
parent->addProcess(ProcessCommand(mCommands[it.key()], arg, 1, parent));
}
}
}
if (!authority.isEmpty()) args["sip-address"] = authority;

View file

@ -229,7 +229,7 @@ QString CoreModel::getFetchConfig(QString filePath, bool *error) {
return filePath;
}
void CoreModel::useFetchConfig(QString filePath) {
void CoreModel::useFetchConfig(QString filePath, bool askForConfirmation) {
bool error = false;
filePath = getFetchConfig(filePath, &error);
if (!error && !filePath.isEmpty()) {
@ -237,7 +237,7 @@ void CoreModel::useFetchConfig(QString filePath) {
if (mCore && mCore->getGlobalState() == linphone::GlobalState::On) {
// TODO
// if (mSettings->getAutoApplyProvisioningConfigUriHandlerEnabled()) setFetchConfig(filePath); else
emit requestFetchConfig(filePath);
emit requestFetchConfig(filePath, askForConfirmation);
} else {
connect(
this, &CoreModel::globalStateChanged, this, [filePath, this]() { useFetchConfig(filePath); },

View file

@ -65,7 +65,7 @@ public:
void refreshOidcRemainingTime();
QString getFetchConfig(QString filePath, bool *error);
void useFetchConfig(QString filePath);
void useFetchConfig(QString filePath, bool askForConfirmation = true);
bool setFetchConfig(QString filePath);
void migrate();
@ -94,7 +94,7 @@ signals:
void friendUpdated(const std::shared_ptr<linphone::Friend> &f);
void bearerAccountAdded();
void unreadNotificationsChanged();
void requestFetchConfig(QString path);
void requestFetchConfig(QString path, bool askForConfirmation);
void requestRestart();
void enabledLdapAddressBookSaved();
void magicSearchResultReceived(QString filter);