diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index a9d37dbe3..93cb51182 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -363,9 +363,13 @@ void App::setSelf(QSharedPointer(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(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(); } }); }); diff --git a/Linphone/model/cli/CliModel.cpp b/Linphone/model/cli/CliModel.cpp index ef905e009..3e88506bd 100644 --- a/Linphone/model/cli/CliModel.cpp +++ b/Linphone/model/cli/CliModel.cpp @@ -133,7 +133,7 @@ void CliModel::cliFetchConfig(QHash 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 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 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; diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 4f19d150e..32cb83da7 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -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); }, diff --git a/Linphone/model/core/CoreModel.hpp b/Linphone/model/core/CoreModel.hpp index 742141f51..8170da951 100644 --- a/Linphone/model/core/CoreModel.hpp +++ b/Linphone/model/core/CoreModel.hpp @@ -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 &f); void bearerAccountAdded(); void unreadNotificationsChanged(); - void requestFetchConfig(QString path); + void requestFetchConfig(QString path, bool askForConfirmation); void requestRestart(); void enabledLdapAddressBookSaved(); void magicSearchResultReceived(QString filter);