Commit ffe49a7d authored by Krzysztof Nowicki's avatar Krzysztof Nowicki
Browse files

Clean up authentication parent widget setting

Use the method in the abstract authentication handler rather than the
specific OAuth2 one. In addition to that clean up parent widget
methods in the request class as they're no longer needed.
parent 79e43f68
......@@ -121,7 +121,6 @@ public:
QString mToken;
const QString mEmail;
const QString mRedirectUri;
QWidget *mParentWindow;
bool mAuthenticated;
QPointer<QDialog> mWebDialog;
......@@ -208,8 +207,7 @@ void EwsOAuthRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info
EwsOAuthPrivate::EwsOAuthPrivate(EwsOAuth *parent, const QString &email, const QString &appId, const QString &redirectUri)
: QObject(nullptr), mWebView(nullptr), mWebProfile(), mWebPage(&mWebProfile), mReplyHandler(this, redirectUri),
mRequestInterceptor(this, redirectUri), mEmail(email), mRedirectUri(redirectUri), mParentWindow(nullptr),
mAuthenticated(false), q_ptr(parent)
mRequestInterceptor(this, redirectUri), mEmail(email), mRedirectUri(redirectUri), mAuthenticated(false), q_ptr(parent)
{
mOAuth2.setReplyHandler(&mReplyHandler);
mOAuth2.setAuthorizationUrl(o365AuthorizationUrl);
......@@ -281,9 +279,11 @@ void EwsOAuthPrivate::modifyParametersFunction(QAbstractOAuth::Stage stage, QVar
void EwsOAuthPrivate::authorizeWithBrowser(const QUrl &url)
{
Q_Q(EwsOAuth);
qCInfoNC(EWSCLI_LOG) << QStringLiteral("Launching browser for authentication");
mWebDialog = new QDialog(mParentWindow);
mWebDialog = new QDialog(q->mAuthParentWidget);
mWebDialog->setObjectName(QStringLiteral("Akonadi EWS Resource - Authentication"));
mWebDialog->setWindowIcon(QIcon("akonadi-ews"));
mWebDialog->resize(400, 500);
......@@ -357,13 +357,6 @@ EwsOAuth::~EwsOAuth()
{
}
void EwsOAuth::setParentWindow(QWidget *window)
{
Q_D(EwsOAuth);
d->mParentWindow = window;
}
void EwsOAuth::init()
{
requestWalletMap();
......
......@@ -35,8 +35,6 @@ public:
EwsOAuth(QObject *parent, const QString &email, const QString &appId, const QString &redirectUri);
~EwsOAuth() override;
void setParentWindow(QWidget *w);
void init() override;
bool getAuthData(QString &username, QString &password, QStringList &customHeaders) override;
void notifyRequestAuthFailed() override;
......
......@@ -27,7 +27,7 @@
#include "auth/ewsabstractauth.h"
EwsRequest::EwsRequest(EwsClient &client, QObject *parent)
: EwsJob(parent), mClient(client), mServerVersion(EwsServerVersion::ewsVersion2007Sp1), mParentWindow(nullptr)
: EwsJob(parent), mClient(client), mServerVersion(EwsServerVersion::ewsVersion2007Sp1)
{
}
......@@ -370,8 +370,3 @@ void EwsRequest::dump() const
qCWarning(EWSCLI_LOG) << "failed to dump request and response";
}
}
void EwsRequest::setParentWindow(QWidget *window)
{
mParentWindow = window;
}
......@@ -81,7 +81,6 @@ public:
}
void dump() const;
void setParentWindow(QWidget *w);
protected:
typedef std::function<bool(QXmlStreamReader &reader)> ContentReaderFn;
......
......@@ -346,7 +346,6 @@ void EwsConfigDialog::dialogAccepted()
connect(mTryConnectJob, &EwsGetFolderRequest::result, this, &EwsConfigDialog::tryConnectFinished);
mProgressDialog = new EwsProgressDialog(this, EwsProgressDialog::TryConnect);
connect(mProgressDialog, &QDialog::rejected, this, &EwsConfigDialog::tryConnectCancelled);
mTryConnectJob->setParentWindow(mProgressDialog);
mTryConnectJob->start();
if (!execJob(mTryConnectJob)) {
if (!mTryConnectJobCancelled) {
......@@ -399,7 +398,6 @@ void EwsConfigDialog::tryConnect()
mProgressDialog = new EwsProgressDialog(this, EwsProgressDialog::TryConnect);
connect(mProgressDialog, &QDialog::rejected, this, &EwsConfigDialog::tryConnectCancelled);
mProgressDialog->show();
mTryConnectJob->setParentWindow(mProgressDialog);
if (!execJob(mTryConnectJob)) {
if (!mTryConnectJobCancelled) {
mUi->serverStatusText->setText(i18nc("Exchange server status", "Failed"));
......@@ -429,15 +427,13 @@ EwsAbstractAuth *EwsConfigDialog::prepareAuth()
#ifdef HAVE_NETWORKAUTH
if (mUi->authOAuth2RadioButton->isChecked()) {
auto oAuth = new EwsOAuth(this, mUi->kcfg_Email->text(), mSettings->oAuth2AppId(), mSettings->oAuth2ReturnUri());
oAuth->setParentWindow(this);
auth = oAuth;
auth = new EwsOAuth(this, mUi->kcfg_Email->text(), mSettings->oAuth2AppId(), mSettings->oAuth2ReturnUri());
} else
#endif
if (mUi->authUsernameRadioButton->isChecked()) {
auth = new EwsPasswordAuth(fullUsername(), this);
}
auth->setAuthParentWidget(this);
connect(auth, &EwsAbstractAuth::requestWalletPassword, this, [&](bool) {
auth->walletPasswordRequestFinished(mUi->passwordEdit->password());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment