Fix restart application and remote provisionning with bearer.
This commit is contained in:
parent
84cc47e7dc
commit
40ed719c98
13 changed files with 126 additions and 97 deletions
|
|
@ -89,7 +89,7 @@ macosx-ninja-novideo:
|
||||||
# Package - Nightly
|
# Package - Nightly
|
||||||
#################################################
|
#################################################
|
||||||
# WAIT for QT6 for arm64
|
# WAIT for QT6 for arm64
|
||||||
macosx-makefile-package:
|
macosx-ninja-package:
|
||||||
stage: package
|
stage: package
|
||||||
tags: [ "macos-xcode13" ]
|
tags: [ "macos-xcode13" ]
|
||||||
dependencies: []
|
dependencies: []
|
||||||
|
|
@ -102,7 +102,7 @@ macosx-makefile-package:
|
||||||
variables:
|
variables:
|
||||||
CMAKE_OPTIONS: -DENABLE_APP_PACKAGING=ON -DENABLE_GPL_THIRD_PARTIES=ON -DENABLE_G729=ON
|
CMAKE_OPTIONS: -DENABLE_APP_PACKAGING=ON -DENABLE_GPL_THIRD_PARTIES=ON -DENABLE_G729=ON
|
||||||
RELEASE_FILE: -DLINPHONE_SDK_MAKE_RELEASE_FILE_URL=$MAKE_RELEASE_FILE_URL/$MACOSX_PLATFORM/$APP_FOLDER
|
RELEASE_FILE: -DLINPHONE_SDK_MAKE_RELEASE_FILE_URL=$MAKE_RELEASE_FILE_URL/$MACOSX_PLATFORM/$APP_FOLDER
|
||||||
extends: macosx-makefile
|
extends: macosx-ninja
|
||||||
script:
|
script:
|
||||||
- if [[ $MAKE_RELEASE_FILE_URL == "" ]]; then export RELEASE_FILE=""; fi
|
- if [[ $MAKE_RELEASE_FILE_URL == "" ]]; then export RELEASE_FILE=""; fi
|
||||||
- *build_all_script
|
- *build_all_script
|
||||||
|
|
@ -117,7 +117,7 @@ macosx-codesigning:
|
||||||
stage: signing
|
stage: signing
|
||||||
tags: [ "macos-xcode13" ]
|
tags: [ "macos-xcode13" ]
|
||||||
needs:
|
needs:
|
||||||
- macosx-makefile-package
|
- macosx-ninja-package
|
||||||
rules:
|
rules:
|
||||||
- !reference [.rules-merge-request-manual, rules]
|
- !reference [.rules-merge-request-manual, rules]
|
||||||
- if: $NIGHTLY_MASTER
|
- if: $NIGHTLY_MASTER
|
||||||
|
|
@ -138,7 +138,7 @@ macosx-codesigning:
|
||||||
# Deploy - Nightly
|
# Deploy - Nightly
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
macosx-makefile-deploy:
|
macosx-deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
tags: [ "macos-xcode13" ]
|
tags: [ "macos-xcode13" ]
|
||||||
needs:
|
needs:
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@
|
||||||
#include "core/logger/QtLogger.hpp"
|
#include "core/logger/QtLogger.hpp"
|
||||||
#include "core/login/LoginPage.hpp"
|
#include "core/login/LoginPage.hpp"
|
||||||
#include "core/notifier/Notifier.hpp"
|
#include "core/notifier/Notifier.hpp"
|
||||||
#include "core/participant/ParticipantDeviceCore.hpp"
|
|
||||||
#include "core/participant/ParticipantDeviceProxy.hpp"
|
#include "core/participant/ParticipantDeviceProxy.hpp"
|
||||||
#include "core/participant/ParticipantGui.hpp"
|
#include "core/participant/ParticipantGui.hpp"
|
||||||
#include "core/participant/ParticipantProxy.hpp"
|
#include "core/participant/ParticipantProxy.hpp"
|
||||||
|
|
@ -76,7 +75,6 @@
|
||||||
#include "core/search/MagicSearchProxy.hpp"
|
#include "core/search/MagicSearchProxy.hpp"
|
||||||
#include "core/setting/SettingsCore.hpp"
|
#include "core/setting/SettingsCore.hpp"
|
||||||
#include "core/singleapplication/singleapplication.h"
|
#include "core/singleapplication/singleapplication.h"
|
||||||
#include "core/timezone/TimeZone.hpp"
|
|
||||||
#include "core/timezone/TimeZoneProxy.hpp"
|
#include "core/timezone/TimeZoneProxy.hpp"
|
||||||
#include "core/variant/VariantList.hpp"
|
#include "core/variant/VariantList.hpp"
|
||||||
#include "core/videoSource/VideoSourceDescriptorGui.hpp"
|
#include "core/videoSource/VideoSourceDescriptorGui.hpp"
|
||||||
|
|
@ -89,7 +87,7 @@
|
||||||
#include "tool/providers/AvatarProvider.hpp"
|
#include "tool/providers/AvatarProvider.hpp"
|
||||||
#include "tool/providers/ImageProvider.hpp"
|
#include "tool/providers/ImageProvider.hpp"
|
||||||
#include "tool/providers/ScreenProvider.hpp"
|
#include "tool/providers/ScreenProvider.hpp"
|
||||||
#include "tool/request/AuthenticationDialog.hpp"
|
#include "tool/request/CallbackHelper.hpp"
|
||||||
#include "tool/request/RequestDialog.hpp"
|
#include "tool/request/RequestDialog.hpp"
|
||||||
#include "tool/thread/Thread.hpp"
|
#include "tool/thread/Thread.hpp"
|
||||||
|
|
||||||
|
|
@ -356,34 +354,12 @@ void App::setSelf(QSharedPointer<App>(me)) {
|
||||||
mCoreModelConnection->invokeToCore([this] { setCoreStarted(true); });
|
mCoreModelConnection->invokeToCore([this] { setCoreStarted(true); });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mCoreModelConnection->makeConnectToModel(
|
mCoreModelConnection->makeConnectToModel(&CoreModel::authenticationRequested, &App::onAuthenticationRequested);
|
||||||
&CoreModel::authenticationRequested,
|
|
||||||
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
// Synchronize state for because linphoneCore was ran before any connections.
|
||||||
linphone::AuthMethod method) {
|
mCoreModelConnection->invokeToModel([this]() {
|
||||||
mCoreModelConnection->invokeToCore([this, core, authInfo, method]() {
|
auto state = CoreModel::getInstance()->getCore()->getGlobalState();
|
||||||
if (method == linphone::AuthMethod::HttpDigest) {
|
mCoreModelConnection->invokeToCore([this, state] { setCoreStarted(state == linphone::GlobalState::On); });
|
||||||
auto window = App::getInstance()->getMainWindow();
|
|
||||||
auto username = authInfo->getUsername();
|
|
||||||
auto domain = authInfo->getDomain();
|
|
||||||
AuthenticationDialog *obj = new AuthenticationDialog(Utils::coreStringToAppString(username),
|
|
||||||
Utils::coreStringToAppString(domain));
|
|
||||||
connect(obj, &AuthenticationDialog::result, this, [this, obj, authInfo, core](QString password) {
|
|
||||||
mCoreModelConnection->invokeToModel([this, core, authInfo, password] {
|
|
||||||
mustBeInLinphoneThread("[App] reauthenticate");
|
|
||||||
if (password.isEmpty()) {
|
|
||||||
lDebug() << "ERROR : empty password";
|
|
||||||
} else {
|
|
||||||
lDebug() << "reset password for" << authInfo->getUsername();
|
|
||||||
authInfo->setPassword(Utils::appStringToCoreString(password));
|
|
||||||
core->addAuthInfo(authInfo);
|
|
||||||
core->refreshRegisters();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
obj->deleteLater();
|
|
||||||
});
|
|
||||||
QMetaObject::invokeMethod(window, "reauthenticateAccount", QVariant::fromValue(obj));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
//---------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------
|
||||||
mCliModelConnection = QSharedPointer<SafeConnection<App, CliModel>>(
|
mCliModelConnection = QSharedPointer<SafeConnection<App, CliModel>>(
|
||||||
|
|
@ -450,13 +426,12 @@ void App::initCore() {
|
||||||
lInfo() << log().arg("Starting Core");
|
lInfo() << log().arg("Starting Core");
|
||||||
CoreModel::getInstance()->start();
|
CoreModel::getInstance()->start();
|
||||||
ToolModel::loadDownloadedCodecs();
|
ToolModel::loadDownloadedCodecs();
|
||||||
auto coreStarted = CoreModel::getInstance()->getCore()->getGlobalState() == linphone::GlobalState::On;
|
|
||||||
lDebug() << log().arg("Creating SettingsModel");
|
lDebug() << log().arg("Creating SettingsModel");
|
||||||
SettingsModel::create();
|
SettingsModel::create();
|
||||||
lDebug() << log().arg("Creating SettingsCore");
|
lDebug() << log().arg("Creating SettingsCore");
|
||||||
if (!settings) settings = SettingsCore::create();
|
if (!settings) settings = SettingsCore::create();
|
||||||
lDebug() << log().arg("Creating Ui");
|
lDebug() << log().arg("Creating Ui");
|
||||||
QMetaObject::invokeMethod(App::getInstance()->thread(), [this, settings, coreStarted] {
|
QMetaObject::invokeMethod(App::getInstance()->thread(), [this, settings] {
|
||||||
// QML
|
// QML
|
||||||
mEngine = new QQmlApplicationEngine(this);
|
mEngine = new QQmlApplicationEngine(this);
|
||||||
assert(mEngine);
|
assert(mEngine);
|
||||||
|
|
@ -507,7 +482,6 @@ void App::initCore() {
|
||||||
else mAccountList->lUpdate();
|
else mAccountList->lUpdate();
|
||||||
if (!mCallList) setCallList(CallList::create());
|
if (!mCallList) setCallList(CallList::create());
|
||||||
else mCallList->lUpdate();
|
else mCallList->lUpdate();
|
||||||
|
|
||||||
if (!mSettings) {
|
if (!mSettings) {
|
||||||
mSettings = settings;
|
mSettings = settings;
|
||||||
setLocale(settings->getConfigLocale());
|
setLocale(settings->getConfigLocale());
|
||||||
|
|
@ -535,7 +509,7 @@ void App::initCore() {
|
||||||
const QUrl url("qrc:/qt/qml/Linphone/view/Page/Window/Main/MainWindow.qml");
|
const QUrl url("qrc:/qt/qml/Linphone/view/Page/Window/Main/MainWindow.qml");
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
mEngine, &QQmlApplicationEngine::objectCreated, this,
|
mEngine, &QQmlApplicationEngine::objectCreated, this,
|
||||||
[this, url, coreStarted](QObject *obj, const QUrl &objUrl) {
|
[this, url](QObject *obj, const QUrl &objUrl) {
|
||||||
if (url == objUrl) {
|
if (url == objUrl) {
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
lCritical() << log().arg("MainWindow.qml couldn't be load. The app will exit");
|
lCritical() << log().arg("MainWindow.qml couldn't be load. The app will exit");
|
||||||
|
|
@ -543,7 +517,6 @@ void App::initCore() {
|
||||||
}
|
}
|
||||||
auto window = qobject_cast<QQuickWindow *>(obj);
|
auto window = qobject_cast<QQuickWindow *>(obj);
|
||||||
setMainWindow(window);
|
setMainWindow(window);
|
||||||
setCoreStarted(coreStarted);
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
// Enable TrayIconSystem.
|
// Enable TrayIconSystem.
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable())
|
if (!QSystemTrayIcon::isSystemTrayAvailable())
|
||||||
|
|
@ -643,8 +616,6 @@ void App::initCppInterfaces() {
|
||||||
|
|
||||||
qmlRegisterUncreatableType<RequestDialog>(Constants::MainQmlUri, 1, 0, "RequestDialog",
|
qmlRegisterUncreatableType<RequestDialog>(Constants::MainQmlUri, 1, 0, "RequestDialog",
|
||||||
QLatin1String("Uncreatable"));
|
QLatin1String("Uncreatable"));
|
||||||
qmlRegisterUncreatableType<AuthenticationDialog>(Constants::MainQmlUri, 1, 0, "AuthenticationDialogCpp",
|
|
||||||
QLatin1String("Uncreatable"));
|
|
||||||
qmlRegisterType<LdapGui>(Constants::MainQmlUri, 1, 0, "LdapGui");
|
qmlRegisterType<LdapGui>(Constants::MainQmlUri, 1, 0, "LdapGui");
|
||||||
qmlRegisterType<LdapProxy>(Constants::MainQmlUri, 1, 0, "LdapProxy");
|
qmlRegisterType<LdapProxy>(Constants::MainQmlUri, 1, 0, "LdapProxy");
|
||||||
qmlRegisterType<CarddavGui>(Constants::MainQmlUri, 1, 0, "CarddavGui");
|
qmlRegisterType<CarddavGui>(Constants::MainQmlUri, 1, 0, "CarddavGui");
|
||||||
|
|
@ -683,6 +654,8 @@ void App::restart() {
|
||||||
mCoreModelConnection->invokeToModel([this]() {
|
mCoreModelConnection->invokeToModel([this]() {
|
||||||
CoreModel::getInstance()->getCore()->stop();
|
CoreModel::getInstance()->getCore()->stop();
|
||||||
mCoreModelConnection->invokeToCore([this]() {
|
mCoreModelConnection->invokeToCore([this]() {
|
||||||
|
closeCallsWindow();
|
||||||
|
setMainWindow(nullptr);
|
||||||
mEngine->clearComponentCache();
|
mEngine->clearComponentCache();
|
||||||
mEngine->clearSingletons();
|
mEngine->clearSingletons();
|
||||||
delete mEngine;
|
delete mEngine;
|
||||||
|
|
@ -890,6 +863,48 @@ void App::onExitOnCloseChanged() {
|
||||||
if (mSettings) setAutoStart(mSettings->getAutoStart());
|
if (mSettings) setAutoStart(mSettings->getAutoStart());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void App::onAuthenticationRequested(const std::shared_ptr<linphone::Core> &core,
|
||||||
|
const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
||||||
|
linphone::AuthMethod method) {
|
||||||
|
mCoreModelConnection->invokeToCore([this, core, authInfo, method]() {
|
||||||
|
auto window = App::getInstance()->getMainWindow();
|
||||||
|
if (!window) {
|
||||||
|
// Note: we can do connection with shared pointers because of SingleShotConnection
|
||||||
|
connect(
|
||||||
|
this, &App::mainWindowChanged, this,
|
||||||
|
[this, core, authInfo, method]() { onAuthenticationRequested(core, authInfo, method); },
|
||||||
|
Qt::SingleShotConnection);
|
||||||
|
} else {
|
||||||
|
if (method == linphone::AuthMethod::HttpDigest) {
|
||||||
|
lInfo() << log().arg("Received HttpDigest");
|
||||||
|
auto username = Utils::coreStringToAppString(authInfo->getUsername());
|
||||||
|
auto domain = Utils::coreStringToAppString(authInfo->getDomain());
|
||||||
|
CallbackHelper *callback = new CallbackHelper();
|
||||||
|
auto cb = [this, authInfo, core](QVariant vPassword) {
|
||||||
|
mCoreModelConnection->invokeToModel([this, core, authInfo, vPassword] {
|
||||||
|
QString password = vPassword.toString();
|
||||||
|
mustBeInLinphoneThread("[App] reauthenticate");
|
||||||
|
if (password.isEmpty()) {
|
||||||
|
lDebug() << log().arg("ERROR : empty password");
|
||||||
|
} else {
|
||||||
|
lDebug() << log()
|
||||||
|
.arg("Reset password for %1")
|
||||||
|
.arg(Utils::coreStringToAppString(authInfo->getUsername()));
|
||||||
|
authInfo->setPassword(Utils::appStringToCoreString(password));
|
||||||
|
core->addAuthInfo(authInfo);
|
||||||
|
core->refreshRegisters();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
connect(callback, &CallbackHelper::cb, cb);
|
||||||
|
QMetaObject::invokeMethod(window, "reauthenticateAccount", Qt::DirectConnection,
|
||||||
|
Q_ARG(QVariant, username), Q_ARG(QVariant, domain),
|
||||||
|
QVariant::fromValue(callback));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
QString App::getApplicationPath() const {
|
QString App::getApplicationPath() const {
|
||||||
const QString binPath(QCoreApplication::applicationFilePath());
|
const QString binPath(QCoreApplication::applicationFilePath());
|
||||||
|
|
@ -1006,10 +1021,9 @@ bool App::event(QEvent *event) {
|
||||||
void App::setSysTrayIcon() {
|
void App::setSysTrayIcon() {
|
||||||
QQuickWindow *root = getMainWindow();
|
QQuickWindow *root = getMainWindow();
|
||||||
QSystemTrayIcon *systemTrayIcon =
|
QSystemTrayIcon *systemTrayIcon =
|
||||||
(mSystemTrayIcon
|
(mSystemTrayIcon ? mSystemTrayIcon
|
||||||
? mSystemTrayIcon
|
: new QSystemTrayIcon(nullptr)); // Workaround : QSystemTrayIcon cannot be deleted because
|
||||||
: new QSystemTrayIcon(
|
// of setContextMenu (indirectly)
|
||||||
nullptr)); // Workaround : QSystemTrayIcon cannot be deleted because of setContextMenu (indirectly)
|
|
||||||
|
|
||||||
// trayIcon: Right click actions.
|
// trayIcon: Right click actions.
|
||||||
QAction *restoreAction = nullptr;
|
QAction *restoreAction = nullptr;
|
||||||
|
|
@ -1045,8 +1059,8 @@ void App::setSysTrayIcon() {
|
||||||
}
|
}
|
||||||
menu->addAction(quitAction);
|
menu->addAction(quitAction);
|
||||||
if (!mSystemTrayIcon) {
|
if (!mSystemTrayIcon) {
|
||||||
systemTrayIcon->setContextMenu(menu); // This is a Qt bug. We cannot call setContextMenu more than once. So we
|
systemTrayIcon->setContextMenu(menu); // This is a Qt bug. We cannot call setContextMenu more than once. So
|
||||||
// have to keep an instance of the menu.
|
// we have to keep an instance of the menu.
|
||||||
connect(systemTrayIcon, &QSystemTrayIcon::activated, this, [this](QSystemTrayIcon::ActivationReason reason) {
|
connect(systemTrayIcon, &QSystemTrayIcon::activated, this, [this](QSystemTrayIcon::ActivationReason reason) {
|
||||||
// Left-Click and Double Left-Click
|
// Left-Click and Double Left-Click
|
||||||
if (reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::DoubleClick) {
|
if (reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::DoubleClick) {
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,9 @@ public:
|
||||||
QSharedPointer<SettingsCore> getSettings() const;
|
QSharedPointer<SettingsCore> getSettings() const;
|
||||||
|
|
||||||
void onExitOnCloseChanged(); // Can be used for UniqueConnection
|
void onExitOnCloseChanged(); // Can be used for UniqueConnection
|
||||||
|
void onAuthenticationRequested(const std::shared_ptr<linphone::Core> &core,
|
||||||
|
const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
||||||
|
linphone::AuthMethod method);
|
||||||
|
|
||||||
QString getShortApplicationVersion();
|
QString getShortApplicationVersion();
|
||||||
QString getGitBranchName();
|
QString getGitBranchName();
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,15 @@ OIDCModel::OIDCModel(const std::shared_ptr<linphone::AuthInfo> &authInfo, QObjec
|
||||||
mOidc.setClientIdentifier(OIDCClientId);
|
mOidc.setClientIdentifier(OIDCClientId);
|
||||||
mAuthInfo->setClientId(OIDCClientId);
|
mAuthInfo->setClientId(OIDCClientId);
|
||||||
mOidc.setScope(OIDCScope);
|
mOidc.setScope(OIDCScope);
|
||||||
|
mTimeout.setInterval(1000 * 60 * 2); // 2minutes
|
||||||
|
|
||||||
|
connect(&mTimeout, &QTimer::timeout, [this]() {
|
||||||
|
qWarning() << log().arg("Timeout reached for OpenID connection.");
|
||||||
|
dynamic_cast<OAuthHttpServerReplyHandler *>(mOidc.replyHandler())->close();
|
||||||
|
CoreModel::getInstance()->getCore()->abortAuthentication(mAuthInfo);
|
||||||
|
emit statusChanged("Timeout: Not authenticated");
|
||||||
|
emit finished();
|
||||||
|
});
|
||||||
connect(mOidc.networkAccessManager(), &QNetworkAccessManager::authenticationRequired,
|
connect(mOidc.networkAccessManager(), &QNetworkAccessManager::authenticationRequired,
|
||||||
[=](QNetworkReply *reply, QAuthenticator *authenticator) {
|
[=](QNetworkReply *reply, QAuthenticator *authenticator) {
|
||||||
lWarning() << log().arg("authenticationRequired received but not implemented");
|
lWarning() << log().arg("authenticationRequired received but not implemented");
|
||||||
|
|
@ -65,11 +73,13 @@ OIDCModel::OIDCModel(const std::shared_ptr<linphone::AuthInfo> &authInfo, QObjec
|
||||||
connect(&mOidc, &QOAuth2AuthorizationCodeFlow::statusChanged, [=](QAbstractOAuth::Status status) {
|
connect(&mOidc, &QOAuth2AuthorizationCodeFlow::statusChanged, [=](QAbstractOAuth::Status status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case QAbstractOAuth::Status::Granted: {
|
case QAbstractOAuth::Status::Granted: {
|
||||||
|
mTimeout.stop();
|
||||||
emit statusChanged("Authentication granted");
|
emit statusChanged("Authentication granted");
|
||||||
emit authenticated();
|
emit authenticated();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QAbstractOAuth::Status::NotAuthenticated: {
|
case QAbstractOAuth::Status::NotAuthenticated: {
|
||||||
|
mTimeout.stop();
|
||||||
emit statusChanged("Not authenticated");
|
emit statusChanged("Not authenticated");
|
||||||
emit finished();
|
emit finished();
|
||||||
break;
|
break;
|
||||||
|
|
@ -88,6 +98,7 @@ OIDCModel::OIDCModel(const std::shared_ptr<linphone::AuthInfo> &authInfo, QObjec
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(&mOidc, &QOAuth2AuthorizationCodeFlow::requestFailed, [=](QAbstractOAuth::Error error) {
|
connect(&mOidc, &QOAuth2AuthorizationCodeFlow::requestFailed, [=](QAbstractOAuth::Error error) {
|
||||||
|
mTimeout.stop();
|
||||||
qWarning() << "RequestFailed:" << (int)error;
|
qWarning() << "RequestFailed:" << (int)error;
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case QAbstractOAuth::Error::NetworkError:
|
case QAbstractOAuth::Error::NetworkError:
|
||||||
|
|
@ -114,6 +125,7 @@ OIDCModel::OIDCModel(const std::shared_ptr<linphone::AuthInfo> &authInfo, QObjec
|
||||||
connect(&mOidc, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, [this](const QUrl &url) {
|
connect(&mOidc, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, [this](const QUrl &url) {
|
||||||
qDebug() << "Browser authentication url : " << url;
|
qDebug() << "Browser authentication url : " << url;
|
||||||
emit statusChanged("Requesting authorization from browser");
|
emit statusChanged("Requesting authorization from browser");
|
||||||
|
mTimeout.start();
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -177,12 +189,12 @@ void OIDCModel::openIdConfigReceived() {
|
||||||
|
|
||||||
void OIDCModel::setBearers() {
|
void OIDCModel::setBearers() {
|
||||||
auto expiration = QDateTime::currentDateTime().secsTo(mOidc.expirationAt());
|
auto expiration = QDateTime::currentDateTime().secsTo(mOidc.expirationAt());
|
||||||
|
auto timeT = mOidc.expirationAt().toSecsSinceEpoch();
|
||||||
qDebug() << "Authenticated for " << expiration << "s";
|
qDebug() << "Authenticated for " << expiration << "s";
|
||||||
auto refreshBearer =
|
auto refreshBearer =
|
||||||
linphone::Factory::get()->createBearerToken(Utils::appStringToCoreString(mOidc.refreshToken()), expiration);
|
linphone::Factory::get()->createBearerToken(Utils::appStringToCoreString(mOidc.refreshToken()), timeT);
|
||||||
|
|
||||||
auto accessBearer =
|
auto accessBearer = linphone::Factory::get()->createBearerToken(Utils::appStringToCoreString(mOidc.token()), timeT);
|
||||||
linphone::Factory::get()->createBearerToken(Utils::appStringToCoreString(mOidc.token()), expiration);
|
|
||||||
mAuthInfo->setRefreshToken(refreshBearer);
|
mAuthInfo->setRefreshToken(refreshBearer);
|
||||||
mAuthInfo->setAccessToken(accessBearer);
|
mAuthInfo->setAccessToken(accessBearer);
|
||||||
CoreModel::getInstance()->getCore()->addAuthInfo(mAuthInfo);
|
CoreModel::getInstance()->getCore()->addAuthInfo(mAuthInfo);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "tool/AbstractObject.hpp"
|
#include "tool/AbstractObject.hpp"
|
||||||
#include <QOAuth2AuthorizationCodeFlow>
|
#include <QOAuth2AuthorizationCodeFlow>
|
||||||
|
#include <QTimer>
|
||||||
#include <linphone++/linphone.hh>
|
#include <linphone++/linphone.hh>
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
@ -45,6 +46,7 @@ signals:
|
||||||
private:
|
private:
|
||||||
QOAuth2AuthorizationCodeFlow mOidc;
|
QOAuth2AuthorizationCodeFlow mOidc;
|
||||||
std::shared_ptr<linphone::AuthInfo> mAuthInfo;
|
std::shared_ptr<linphone::AuthInfo> mAuthInfo;
|
||||||
|
QTimer mTimeout;
|
||||||
|
|
||||||
DECLARE_ABSTRACT_OBJECT
|
DECLARE_ABSTRACT_OBJECT
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -243,14 +243,13 @@ void CoreModel::onAuthenticationRequested(const std::shared_ptr<linphone::Core>
|
||||||
const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
const std::shared_ptr<linphone::AuthInfo> &authInfo,
|
||||||
linphone::AuthMethod method) {
|
linphone::AuthMethod method) {
|
||||||
if (method == linphone::AuthMethod::Bearer) {
|
if (method == linphone::AuthMethod::Bearer) {
|
||||||
auto serverUrl = authInfo->getAuthorizationServer();
|
auto serverUrl = Utils::coreStringToAppString(authInfo->getAuthorizationServer());
|
||||||
auto username = authInfo->getUsername();
|
auto username = Utils::coreStringToAppString(authInfo->getUsername());
|
||||||
auto realm = authInfo->getRealm();
|
auto realm = Utils::coreStringToAppString(authInfo->getRealm());
|
||||||
if (!serverUrl.empty()) {
|
if (!serverUrl.isEmpty()) {
|
||||||
qDebug() << "onAuthenticationRequested for Bearer. Initialize OpenID connection for " << username.c_str()
|
qDebug() << "onAuthenticationRequested for Bearer. Initialize OpenID connection for " << username << "@"
|
||||||
<< " at " << serverUrl.c_str();
|
<< realm << " at " << serverUrl;
|
||||||
QString key = Utils::coreStringToAppString(username) + '@' + Utils::coreStringToAppString(realm) + ' ' +
|
QString key = username + '@' + realm + ' ' + serverUrl;
|
||||||
Utils::coreStringToAppString(serverUrl);
|
|
||||||
if (mOpenIdConnections.contains(key)) mOpenIdConnections[key]->deleteLater();
|
if (mOpenIdConnections.contains(key)) mOpenIdConnections[key]->deleteLater();
|
||||||
mOpenIdConnections[key] = new OIDCModel(authInfo, this);
|
mOpenIdConnections[key] = new OIDCModel(authInfo, this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ list(APPEND _LINPHONEAPP_SOURCES
|
||||||
tool/native/DesktopTools.hpp
|
tool/native/DesktopTools.hpp
|
||||||
|
|
||||||
tool/request/RequestDialog.cpp
|
tool/request/RequestDialog.cpp
|
||||||
tool/request/AuthenticationDialog.cpp
|
tool/request/CallbackHelper.cpp
|
||||||
|
|
||||||
tool/file/FileDownloader.cpp
|
tool/file/FileDownloader.cpp
|
||||||
tool/file/FileExtractor.cpp
|
tool/file/FileExtractor.cpp
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,10 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AuthenticationDialog.hpp"
|
#include "CallbackHelper.hpp"
|
||||||
|
#include "core/App.hpp"
|
||||||
|
#include <QQmlEngine>
|
||||||
|
|
||||||
AuthenticationDialog::AuthenticationDialog(QString username, QString domain, QObject *parent)
|
CallbackHelper::CallbackHelper(QObject *parent) : QObject(parent) {
|
||||||
: QObject(parent), mUsername(username), mDomain(domain) {
|
App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
|
||||||
}
|
}
|
||||||
|
|
@ -18,25 +18,18 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AUTHENTICATION_DIALOG_H_
|
#ifndef CALLBACK_HELPER_H_
|
||||||
#define AUTHENTICATION_DIALOG_H_
|
#define CALLBACK_HELPER_H_
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class AuthenticationDialog : public QObject {
|
class CallbackHelper : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString username MEMBER mUsername NOTIFY usernameChanged)
|
|
||||||
Q_PROPERTY(QString domain MEMBER mDomain NOTIFY domainChanged)
|
|
||||||
public:
|
public:
|
||||||
AuthenticationDialog(QString username, QString domain, QObject *parent = nullptr);
|
CallbackHelper(QObject *parent = nullptr);
|
||||||
|
|
||||||
QString mUsername;
|
|
||||||
QString mDomain;
|
|
||||||
signals:
|
signals:
|
||||||
void usernameChanged();
|
void cb(QVariant arg);
|
||||||
void domainChanged();
|
|
||||||
void result(QString password);
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -10,17 +10,27 @@ import SettingsCpp
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: mainItem
|
id: mainItem
|
||||||
|
|
||||||
property string identity
|
property string identity
|
||||||
property string domain
|
property string domain
|
||||||
readonly property string password: passwordEdit.text
|
readonly property string password: passwordEdit.text
|
||||||
onRejected: close()
|
property var callback// Define cb(var) function
|
||||||
modal: true
|
|
||||||
closePolicy: Popup.NoAutoClose
|
|
||||||
topPadding: 20 * DefaultStyle.dp
|
topPadding: 20 * DefaultStyle.dp
|
||||||
bottomPadding: 20 * DefaultStyle.dp
|
bottomPadding: 20 * DefaultStyle.dp
|
||||||
leftPadding: 20 * DefaultStyle.dp
|
leftPadding: 20 * DefaultStyle.dp
|
||||||
rightPadding: 20 * DefaultStyle.dp
|
rightPadding: 20 * DefaultStyle.dp
|
||||||
width: 637 * DefaultStyle.dp
|
width: 637 * DefaultStyle.dp
|
||||||
|
modal: true
|
||||||
|
closePolicy: Popup.NoAutoClose
|
||||||
|
|
||||||
|
onAccepted: {
|
||||||
|
if( callback) callback.cb(password)
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
onRejected: close()
|
||||||
|
Component.onDestruction: if(callback) callback.destroy()
|
||||||
|
|
||||||
content: ColumnLayout {
|
content: ColumnLayout {
|
||||||
spacing: 20 * DefaultStyle.dp
|
spacing: 20 * DefaultStyle.dp
|
||||||
id: contentLayout
|
id: contentLayout
|
||||||
|
|
@ -60,7 +70,7 @@ Dialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FormItemLayout {
|
FormItemLayout {
|
||||||
id: password
|
id: passwordItem
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
label: qsTr("Mot de passe")
|
label: qsTr("Mot de passe")
|
||||||
enableErrorText: true
|
enableErrorText: true
|
||||||
|
|
@ -68,7 +78,7 @@ Dialog {
|
||||||
contentItem: TextField {
|
contentItem: TextField {
|
||||||
id: passwordEdit
|
id: passwordEdit
|
||||||
hidden: true
|
hidden: true
|
||||||
isError: password.errorTextVisible
|
isError: passwordItem.errorTextVisible
|
||||||
KeyNavigation.up: usernameEdit
|
KeyNavigation.up: usernameEdit
|
||||||
KeyNavigation.down: cancelButton
|
KeyNavigation.down: cancelButton
|
||||||
}
|
}
|
||||||
|
|
@ -93,9 +103,9 @@ Dialog {
|
||||||
KeyNavigation.up: passwordEdit
|
KeyNavigation.up: passwordEdit
|
||||||
KeyNavigation.right: cancelButton
|
KeyNavigation.right: cancelButton
|
||||||
onClicked: {
|
onClicked: {
|
||||||
password.errorMessage = ""
|
passwordItem.errorMessage = ""
|
||||||
if (passwordEdit.text.length == 0) {
|
if (passwordEdit.text.length == 0) {
|
||||||
password.errorMessage = qsTr("Veuillez saisir un mot de passe")
|
passwordItem.errorMessage = qsTr("Veuillez saisir un mot de passe")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mainItem.accepted()
|
mainItem.accepted()
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ FocusScope {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Switch {
|
Switch {
|
||||||
text: qsTr("Envoyerune invitation aux participants")
|
text: qsTr("Envoyer une invitation aux participants")
|
||||||
checked: mainItem.conferenceInfoGui.core.inviteEnabled
|
checked: mainItem.conferenceInfoGui.core.inviteEnabled
|
||||||
onToggled: mainItem.conferenceInfoGui.core.inviteEnabled = checked
|
onToggled: mainItem.conferenceInfoGui.core.inviteEnabled = checked
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,24 +68,18 @@ AbstractWindow {
|
||||||
Component {
|
Component {
|
||||||
id: authenticationPopupComp
|
id: authenticationPopupComp
|
||||||
AuthenticationDialog{
|
AuthenticationDialog{
|
||||||
property var authenticationDialog
|
|
||||||
property var callback: authenticationDialog.result
|
|
||||||
identity: authenticationDialog.username
|
|
||||||
domain: authenticationDialog.domain
|
|
||||||
onAccepted: {
|
|
||||||
authenticationDialog ? authenticationDialog.result(password) : callback(password)
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
onOpened: mainWindow.authenticationPopupOpened = true
|
onOpened: mainWindow.authenticationPopupOpened = true
|
||||||
onClosed: mainWindow.authenticationPopupOpened = false
|
onClosed: {
|
||||||
|
mainWindow.authenticationPopupOpened = false
|
||||||
|
destroy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reauthenticateAccount(authenticationDialog){
|
function reauthenticateAccount(identity, domain, callback){
|
||||||
if (mainWindowStackView.currentItem.objectName !== "mainPage") return
|
|
||||||
if (authenticationPopupOpened) return
|
if (authenticationPopupOpened) return
|
||||||
console.log("Showing authentication dialog")
|
console.log("Showing authentication dialog")
|
||||||
var popup = authenticationPopupComp.createObject(mainWindow, {"authenticationDialog": authenticationDialog})
|
var popup = authenticationPopupComp.createObject(mainWindow, {"identity": identity, "domain": domain, "callback":callback}) // Callback ownership is not passed
|
||||||
popup.open()
|
popup.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
external/linphone-sdk
vendored
2
external/linphone-sdk
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit bc6747f61ebc40ab1432966414cfce0e2b832206
|
Subproject commit ec80377f302c9282b983fdbeebeaadb0a693986f
|
||||||
Loading…
Reference in a new issue