2014-03-27 20:58:31 +04:00
|
|
|
/*
|
2015-06-15 16:53:45 +03:00
|
|
|
* Copyright (C) by Klaas Freitag <freitag@kde.org>
|
|
|
|
* Copyright (C) by Olivier Goffart <ogoffart@woboq.com>
|
2014-03-27 20:58:31 +04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2015-06-15 16:53:45 +03:00
|
|
|
#include "creds/httpcredentials.h"
|
2017-03-28 11:31:38 +03:00
|
|
|
#include "creds/oauth.h"
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QTcpServer>
|
2014-03-27 20:58:31 +04:00
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2014-03-27 20:58:31 +04:00
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
|
|
|
* @brief The HttpCredentialsGui class
|
|
|
|
* @ingroup gui
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2015-06-18 11:24:40 +03:00
|
|
|
class HttpCredentialsGui : public HttpCredentials
|
|
|
|
{
|
2014-03-27 20:58:31 +04:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-06-15 16:53:45 +03:00
|
|
|
explicit HttpCredentialsGui()
|
|
|
|
: HttpCredentials()
|
|
|
|
{
|
|
|
|
}
|
2019-02-19 13:38:46 +03:00
|
|
|
HttpCredentialsGui(const QString &user, const QString &password,
|
|
|
|
const QByteArray &clientCertBundle, const QByteArray &clientCertPassword)
|
|
|
|
: HttpCredentials(user, password, clientCertBundle, clientCertPassword)
|
2017-01-02 10:34:02 +03:00
|
|
|
{
|
|
|
|
}
|
2017-03-28 11:31:38 +03:00
|
|
|
HttpCredentialsGui(const QString &user, const QString &password, const QString &refreshToken,
|
2019-02-19 13:38:46 +03:00
|
|
|
const QByteArray &clientCertBundle, const QByteArray &clientCertPassword)
|
|
|
|
: HttpCredentials(user, password, clientCertBundle, clientCertPassword)
|
2017-03-28 11:31:38 +03:00
|
|
|
{
|
|
|
|
_refreshToken = refreshToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This will query the server and either uses OAuth via _asyncAuth->start()
|
|
|
|
* or call showDialog to ask the password
|
|
|
|
*/
|
2018-11-11 13:09:29 +03:00
|
|
|
void askFromUser() override;
|
2017-07-13 12:27:02 +03:00
|
|
|
/**
|
|
|
|
* In case of oauth, return an URL to the link to open the browser.
|
|
|
|
* An invalid URL otherwise
|
|
|
|
*/
|
|
|
|
QUrl authorisationLink() const { return _asyncAuth ? _asyncAuth->authorisationLink() : QUrl(); }
|
|
|
|
|
2016-06-28 13:25:04 +03:00
|
|
|
|
|
|
|
static QString requestAppPasswordText(const Account *account);
|
2017-03-28 11:31:38 +03:00
|
|
|
private slots:
|
|
|
|
void asyncAuthResult(OAuth::Result, const QString &user, const QString &accessToken, const QString &refreshToken);
|
|
|
|
void showDialog();
|
2017-10-11 16:22:51 +03:00
|
|
|
void askFromUserAsync();
|
2017-03-28 11:31:38 +03:00
|
|
|
|
2017-07-13 12:27:02 +03:00
|
|
|
signals:
|
|
|
|
void authorisationLinkChanged();
|
|
|
|
|
2017-03-28 11:31:38 +03:00
|
|
|
private:
|
2017-09-07 12:10:23 +03:00
|
|
|
|
2017-03-28 11:31:38 +03:00
|
|
|
QScopedPointer<OAuth, QScopedPointerObjectDeleteLater<OAuth>> _asyncAuth;
|
2014-03-27 20:58:31 +04:00
|
|
|
};
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
} // namespace OCC
|