libre.patch 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. diff -Naurp1 a/CMakeLists.txt b/CMakeLists.txt
  2. --- a/CMakeLists.txt 2020-11-03 06:47:22.000000000 +0600
  3. +++ b/CMakeLists.txt 2020-12-02 20:12:30.622015158 +0600
  4. @@ -43,3 +43,3 @@ find_package(Qt5 ${QT_REQUIRED_VERSION}
  5. Widgets
  6. - WebEngineWidgets
  7. + WebKitWidgets
  8. Xml
  9. diff -Naurp1 a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
  10. --- a/src/core/CMakeLists.txt 2020-10-09 11:36:57.000000000 +0600
  11. +++ b/src/core/CMakeLists.txt 2020-12-02 20:13:03.016013654 +0600
  12. @@ -75,3 +75,3 @@ PRIVATE
  13. KF5::Wallet
  14. - Qt5::WebEngineWidgets
  15. + Qt5::WebKitWidgets
  16. PUBLIC
  17. diff -Naurp1 a/src/core/private/newtokensfetchjob.cpp b/src/core/private/newtokensfetchjob.cpp
  18. --- a/src/core/private/newtokensfetchjob.cpp 2020-10-09 11:36:57.000000000 +0600
  19. +++ b/src/core/private/newtokensfetchjob.cpp 2020-12-02 20:14:23.388009922 +0600
  20. @@ -31,3 +31,2 @@ class Q_DECL_HIDDEN NewTokensFetchJob::P
  21. QString secretKey;
  22. - int localPort;
  23. @@ -38,3 +37,3 @@ class Q_DECL_HIDDEN NewTokensFetchJob::P
  24. -NewTokensFetchJob::NewTokensFetchJob(const QString &tmpToken, const QString &apiKey, const QString &secretKey, int localPort, QObject *parent):
  25. +NewTokensFetchJob::NewTokensFetchJob(const QString &tmpToken, const QString &apiKey, const QString &secretKey, QObject *parent):
  26. Job(parent),
  27. @@ -45,3 +44,2 @@ NewTokensFetchJob::NewTokensFetchJob(con
  28. d->secretKey = secretKey;
  29. - d->localPort = localPort;
  30. }
  31. @@ -94,3 +92,3 @@ void NewTokensFetchJob::start()
  32. params.addQueryItem(QStringLiteral("code"), d->tmpToken);
  33. - params.addQueryItem(QStringLiteral("redirect_uri"), QStringLiteral("http://127.0.0.1:%1").arg(d->localPort)); // we need to use the same URL as in AuthWidget
  34. + params.addQueryItem(QStringLiteral("redirect_uri"), QStringLiteral("urn:ietf:wg:oauth:2.0:oob"));
  35. params.addQueryItem(QStringLiteral("grant_type"), QStringLiteral("authorization_code"));
  36. diff -Naurp1 a/src/core/private/newtokensfetchjob_p.h b/src/core/private/newtokensfetchjob_p.h
  37. --- a/src/core/private/newtokensfetchjob_p.h 2020-10-09 11:36:57.000000000 +0600
  38. +++ b/src/core/private/newtokensfetchjob_p.h 2020-12-02 20:14:55.075008451 +0600
  39. @@ -26,3 +26,3 @@ class KGAPICORE_EXPORT NewTokensFetchJob
  40. public:
  41. - explicit NewTokensFetchJob(const QString &tmpToken, const QString &apiKey, const QString &secretKey, int localPort, QObject* parent = nullptr);
  42. + explicit NewTokensFetchJob(const QString &tmpToken, const QString &apiKey, const QString &secretKey, QObject* parent = nullptr);
  43. ~NewTokensFetchJob() override;
  44. diff -Naurp1 a/src/core/ui/authwidget.cpp b/src/core/ui/authwidget.cpp
  45. --- a/src/core/ui/authwidget.cpp 2020-10-09 11:36:57.000000000 +0600
  46. +++ b/src/core/ui/authwidget.cpp 2020-12-02 20:17:37.273000921 +0600
  47. @@ -10,5 +10,2 @@
  48. -#include <QTcpServer>
  49. -#include <QTcpSocket>
  50. -#include <QAbstractSocket>
  51. #include <QUrlQuery>
  52. @@ -22,10 +19,2 @@ AuthWidget::AuthWidget(QWidget* parent):
  53. {
  54. - d->setupUi();
  55. -}
  56. -
  57. -AuthWidget::AuthWidget(AuthWidgetPrivate *dptr, QWidget *parent)
  58. - : QWidget(parent)
  59. - , d(dptr)
  60. -{
  61. - d->setupUi();
  62. }
  63. @@ -98,24 +87,2 @@ void AuthWidget::authenticate()
  64. - d->server = new QTcpServer(this);
  65. - if (!d->server->listen(QHostAddress::LocalHost, d->serverPort)) {
  66. - Q_EMIT error(InvalidAccount, tr("Could not start oauth http server"));
  67. - return;
  68. - }
  69. - connect(d->server, &QTcpServer::acceptError, d, &AuthWidgetPrivate::socketError);
  70. - d->serverPort = d->server->serverPort();
  71. - connect(d->server, &QTcpServer::newConnection, [&]() {
  72. - d->connection = d->server->nextPendingConnection();
  73. - d->connection->setParent(this);
  74. -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
  75. - connect(d->connection, static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>
  76. - (&QAbstractSocket::error), d, &AuthWidgetPrivate::socketError);
  77. -#else
  78. - connect(d->connection, static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>
  79. - (&QAbstractSocket::errorOccurred), d, &AuthWidgetPrivate::socketError);
  80. -#endif
  81. - connect(d->connection, &QTcpSocket::readyRead, d, &AuthWidgetPrivate::socketReady);
  82. - d->server->close();
  83. - d->server->deleteLater();
  84. - });
  85. -
  86. QUrl url(QStringLiteral("https://accounts.google.com/o/oauth2/auth"));
  87. @@ -123,3 +90,3 @@ void AuthWidget::authenticate()
  88. query.addQueryItem(QStringLiteral("client_id"), d->apiKey);
  89. - query.addQueryItem(QStringLiteral("redirect_uri"), QStringLiteral("http://127.0.0.1:%1").arg(d->serverPort));
  90. + query.addQueryItem(QStringLiteral("redirect_uri"), QStringLiteral("urn:ietf:wg:oauth:2.0:oob"));
  91. query.addQueryItem(QStringLiteral("scope"), scopes.join(QLatin1Char(' ')));
  92. @@ -130,4 +97,7 @@ void AuthWidget::authenticate()
  93. - d->setVisible(true);
  94. - d->setUrl(url);
  95. + d->webview->setVisible(true);
  96. + if (d->showProgressBar) {
  97. + d->progressbar->setVisible(true);
  98. + }
  99. + d->webview->setUrl(url);
  100. d->setProgress(AuthWidget::UserLogin);
  101. diff -Naurp1 a/src/core/ui/authwidget_p.cpp b/src/core/ui/authwidget_p.cpp
  102. --- a/src/core/ui/authwidget_p.cpp 2020-10-09 11:36:57.000000000 +0600
  103. +++ b/src/core/ui/authwidget_p.cpp 2020-12-02 20:31:20.566962697 +0600
  104. @@ -13,72 +13,21 @@
  105. -#include <QWebEngineProfile>
  106. -#include <QWebEngineCertificateError>
  107. -#include <QContextMenuEvent>
  108. -
  109. -#include <QtGlobal>
  110. -#include <QVBoxLayout>
  111. -#include <QLabel>
  112. -#include <QTimer>
  113. -#include <QMessageBox>
  114. -#include <QAbstractSocket>
  115. -#include <QUrlQuery>
  116. +#include <QWebView>
  117. +#include <QWebFrame>
  118. +#include <QWebElement>
  119. +#include <QNetworkReply>
  120. +
  121. #include <QDateTime>
  122. -#include <QWebEngineView>
  123. -using namespace KGAPI2;
  124. +#include <KIO/AccessManager>
  125. -namespace
  126. -{
  127. +using namespace KGAPI2;
  128. -class WebView : public QWebEngineView
  129. +WebView::WebView(QWidget *parent)
  130. + : QWebView(parent)
  131. {
  132. - Q_OBJECT
  133. -public:
  134. - explicit WebView(QWidget *parent = nullptr)
  135. - : QWebEngineView(parent)
  136. - {
  137. - // Don't store cookies, so that subsequent invocations of AuthJob won't remember
  138. - // the previous accounts.
  139. - QWebEngineProfile::defaultProfile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
  140. - }
  141. +}
  142. - void contextMenuEvent(QContextMenuEvent *e) override
  143. - {
  144. - // No menu
  145. - e->accept();
  146. - }
  147. -};
  148. -class WebPage : public QWebEnginePage
  149. +WebView::~WebView()
  150. {
  151. - Q_OBJECT
  152. -public:
  153. - explicit WebPage(QObject *parent = nullptr)
  154. - : QWebEnginePage(parent)
  155. - , mLastError(nullptr)
  156. - {
  157. - }
  158. -
  159. - QWebEngineCertificateError *lastCertificateError() const
  160. - {
  161. - return mLastError;
  162. - }
  163. -
  164. - bool certificateError(const QWebEngineCertificateError &err) override
  165. - {
  166. - if (mLastError) {
  167. - delete mLastError;
  168. - }
  169. - mLastError = new QWebEngineCertificateError(err.error(), err.url(), err.isOverridable(), err.errorDescription());
  170. - Q_EMIT sslError();
  171. -
  172. - return false; // don't let it through
  173. - }
  174. -
  175. -Q_SIGNALS:
  176. - void sslError();
  177. -
  178. -private:
  179. - QWebEngineCertificateError *mLastError;
  180. -};
  181. @@ -86,4 +35,6 @@ private:
  182. -
  183. -
  184. +void WebView::contextMenuEvent(QContextMenuEvent *)
  185. +{
  186. + //Not menu
  187. +}
  188. @@ -95,2 +46,3 @@ AuthWidgetPrivate::AuthWidgetPrivate(Aut
  189. {
  190. + setupUi();
  191. }
  192. @@ -101,11 +53,2 @@ AuthWidgetPrivate::~AuthWidgetPrivate()
  193. -void AuthWidgetPrivate::setSslIcon(const QString &iconName)
  194. -{
  195. - // FIXME: workaround for silly Breeze icons: the small 22x22 icons are
  196. - // monochromatic, which is absolutely useless since we are trying to security
  197. - // information here, so instead we force use the bigger 48x48 icons which
  198. - // have colors and downscale them
  199. - sslIndicator->setIcon(QIcon::fromTheme(iconName).pixmap(48));
  200. -}
  201. -
  202. void AuthWidgetPrivate::setupUi()
  203. @@ -122,22 +65,2 @@ void AuthWidgetPrivate::setupUi()
  204. - auto hbox = new QHBoxLayout;
  205. - hbox->setSpacing(0);
  206. - sslIndicator = new QToolButton(q);
  207. - connect(sslIndicator, &QToolButton::clicked,
  208. - this, [this]() {
  209. - auto page = qobject_cast<WebPage*>(webview->page());
  210. - if (auto err = page->lastCertificateError()) {
  211. - QMessageBox msg;
  212. - msg.setIconPixmap(QIcon::fromTheme(QStringLiteral("security-low")).pixmap(64));
  213. - msg.setText(err->errorDescription());
  214. - msg.addButton(QMessageBox::Ok);
  215. - msg.exec();
  216. - }
  217. - });
  218. - hbox->addWidget(sslIndicator);
  219. - urlEdit = new QLineEdit(q);
  220. - urlEdit->setReadOnly(true);
  221. - hbox->addWidget(urlEdit);
  222. - vbox->addLayout(hbox);
  223. -
  224. progressbar = new QProgressBar(q);
  225. @@ -149,32 +72,20 @@ void AuthWidgetPrivate::setupUi()
  226. webview = new WebView(q);
  227. + KIO::AccessManager *m = new KIO::AccessManager(webview);
  228. + webview->page()->networkAccessManager()->setProxyFactory(m->proxyFactory());
  229. + connect(webview->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors,
  230. + this, &AuthWidgetPrivate::onSslError);
  231. - auto webpage = new WebPage(webview);
  232. - connect(webpage, &WebPage::sslError,
  233. - this, [this]() {
  234. - setSslIcon(QStringLiteral("security-low"));
  235. - });
  236. - webview->setPage(webpage);
  237. vbox->addWidget(webview);
  238. - connect(webview, &QWebEngineView::loadProgress, progressbar, &QProgressBar::setValue);
  239. - connect(webview, &QWebEngineView::urlChanged, this, &AuthWidgetPrivate::webviewUrlChanged);
  240. - connect(webview, &QWebEngineView::loadFinished, this, &AuthWidgetPrivate::webviewFinished);
  241. + connect(webview, &QWebView::loadProgress, progressbar, &QProgressBar::setValue);
  242. + connect(webview, &QWebView::urlChanged, this, &AuthWidgetPrivate::webviewUrlChanged);
  243. + connect(webview, &QWebView::loadFinished, this, &AuthWidgetPrivate::webviewFinished);
  244. }
  245. -void AuthWidgetPrivate::setUrl(const QUrl &url)
  246. +void AuthWidgetPrivate::onSslError(QNetworkReply *reply, const QList<QSslError> &errors)
  247. {
  248. - webview->setUrl(url);
  249. - webview->setFocus();
  250. -}
  251. -
  252. -void AuthWidgetPrivate::setVisible(bool visible)
  253. -{
  254. - sslIndicator->setVisible(visible);
  255. - urlEdit->setVisible(visible);
  256. - webview->setVisible(visible);
  257. - if (showProgressBar && visible) {
  258. - progressbar->setVisible(visible);
  259. - } else {
  260. - progressbar->setVisible(visible);
  261. + Q_FOREACH (const QSslError &error, errors) {
  262. + qCDebug(KGAPIDebug) << "SSL ERROR: " << error.errorString();
  263. }
  264. + reply->ignoreSslErrors();
  265. }
  266. @@ -194,4 +105,2 @@ void AuthWidgetPrivate::emitError(const
  267. label->setVisible(true);
  268. - sslIndicator->setVisible(false);
  269. - urlEdit->setVisible(false);
  270. webview->setVisible(false);
  271. @@ -208,47 +117,12 @@ void AuthWidgetPrivate::webviewUrlChange
  272. {
  273. - qCDebug(KGAPIDebug) << "URLChange:" << url;
  274. -
  275. - // Whoa! That should not happen!
  276. - if (url.scheme() != QLatin1String("https")) {
  277. - QTimer::singleShot(0, this, [this, url]() {
  278. - QUrl sslUrl = url;
  279. - sslUrl.setScheme(QStringLiteral("https"));
  280. - webview->setUrl(sslUrl);
  281. - });
  282. - return;
  283. - }
  284. -
  285. - if (!isGoogleHost(url)) {
  286. - // We handled SSL above, so we are secure. We are however outside of
  287. - // accounts.google.com, which is a little suspicious in context of this class
  288. - setSslIcon(QStringLiteral("security-medium"));
  289. - return;
  290. - }
  291. -
  292. - if (qobject_cast<WebPage*>(webview->page())->lastCertificateError()) {
  293. - setSslIcon(QStringLiteral("security-low"));
  294. - } else {
  295. - // We have no way of obtaining current SSL certificate from QWebEngine, but we
  296. - // handled SSL and accounts.google.com cases above and QWebEngine did not report
  297. - // any SSL error to us, so we can assume we are safe.
  298. - setSslIcon(QStringLiteral("security-high"));
  299. - }
  300. + qCDebug(KGAPIDebug) << url;
  301. + /* Access token here - hide browser and tell user to wait until we
  302. + * finish the authentication process ourselves */
  303. + if (url.host() == QLatin1String("accounts.google.com") && url.path() == QLatin1String("/o/oauth2/approval")) {
  304. + webview->setVisible(false);
  305. + progressbar->setVisible(false);
  306. + label->setVisible(true);
  307. - // Username and password inputs are loaded dynamically, so we only get
  308. - // urlChanged, but not urlFinished.
  309. - if (isUsernameFrame(url)) {
  310. - if (!username.isEmpty()) {
  311. - webview->page()->runJavaScript(QStringLiteral("document.getElementById(\"identifierId\").value = \"%1\";").arg(username));
  312. - }
  313. - } else if (isPasswordFrame(url)) {
  314. - if (!password.isEmpty()) {
  315. - webview->page()->runJavaScript(QStringLiteral("var elems = document.getElementsByTagName(\"input\");"
  316. - "for (var i = 0; i < elems.length; i++) {"
  317. - " if (elems[i].type == \"password\" && elems[i].name == \"password\") {"
  318. - " elems[i].value = \"%1\";"
  319. - " break;"
  320. - " }"
  321. - "}").arg(password));
  322. - }
  323. + setProgress(AuthWidget::TokensRetrieval);
  324. }
  325. @@ -262,36 +136,25 @@ void AuthWidgetPrivate::webviewFinished(
  326. - const QUrl url = webview->url();
  327. - urlEdit->setText(url.toDisplayString(QUrl::PrettyDecoded));
  328. - urlEdit->setCursorPosition(0);
  329. - qCDebug(KGAPIDebug) << "URLFinished:" << url;
  330. -}
  331. -
  332. -void AuthWidgetPrivate::socketError(QAbstractSocket::SocketError socketError)
  333. -{
  334. - if (connection)
  335. - connection->deleteLater();
  336. - qCDebug(KGAPIDebug) << QStringLiteral("Socket error when receiving response: %1").arg(socketError);
  337. - emitError(InvalidResponse, tr("Error receiving response: %1").arg(socketError));
  338. -}
  339. -
  340. -void AuthWidgetPrivate::socketReady()
  341. -{
  342. - Q_ASSERT(connection);
  343. - const QByteArray data = connection->readLine();
  344. - connection->write("HTTP/1.1 200 OK\n");
  345. - connection->flush();
  346. - connection->deleteLater();
  347. - qCDebug(KGAPIDebug) << QStringLiteral("Got connection on socket");
  348. - if (webview) { // when running in tests we don't have webview or any other widgets
  349. - webview->stop();
  350. - }
  351. - setVisible(false);
  352. - if (label) {
  353. - label->setVisible(true);
  354. - }
  355. + QUrl url = webview->url();
  356. + qCDebug(KGAPIDebug) << url;
  357. +
  358. + if (url.host() == QLatin1String("accounts.google.com") && url.path() == QLatin1String("/ServiceLogin")) {
  359. + if (username.isEmpty() && password.isEmpty()) {
  360. + return;
  361. + }
  362. +
  363. + QWebFrame *frame = webview->page()->mainFrame();
  364. + if (!username.isEmpty()) {
  365. + QWebElement email = frame->findFirstElement(QStringLiteral("input#Email"));
  366. + if (!email.isNull()) {
  367. + email.setAttribute(QStringLiteral("value"), username);
  368. + }
  369. + }
  370. +
  371. + if (!password.isEmpty()) {
  372. + QWebElement passd = frame->findFirstElement(QStringLiteral("input#Passwd"));
  373. + if (!passd.isNull()) {
  374. + passd.setAttribute(QStringLiteral("value"), password);
  375. + }
  376. + }
  377. - const auto line = data.split(' ');
  378. - if (line.size() != 3 || line.at(0) != QByteArray("GET") || !line.at(2).startsWith(QByteArray("HTTP/1.1"))) {
  379. - qCDebug(KGAPIDebug) << QStringLiteral("Token response invalid");
  380. - emitError(InvalidResponse, tr("Token response invalid"));
  381. return;
  382. @@ -299,21 +162,28 @@ void AuthWidgetPrivate::socketReady()
  383. - //qCDebug(KGAPIDebug) << "Receiving data on socket: " << data;
  384. - const QUrl url(QString::fromLatin1(line.at(1)));
  385. - const QUrlQuery query(url);
  386. - const QString code = query.queryItemValue(QStringLiteral("code"));
  387. - if (code.isEmpty()) {
  388. - const QString error = query.queryItemValue(QStringLiteral("error"));
  389. - if (!error.isEmpty()) {
  390. - emitError(UnknownError, error);
  391. - qCDebug(KGAPIDebug) << error;
  392. + if (url.host() == QLatin1String("accounts.google.com") && url.path() == QLatin1String("/o/oauth2/approval")) {
  393. + QString title = webview->title();
  394. + QString token;
  395. +
  396. + if (title.startsWith(QLatin1String("success"), Qt::CaseInsensitive)) {
  397. + int pos = title.indexOf(QLatin1String("code="));
  398. + /* Skip the 'code=' string as well */
  399. + token = title.mid (pos + 5);
  400. } else {
  401. - qCDebug(KGAPIDebug) << QStringLiteral("Could not extract token from HTTP answer");
  402. - emitError(InvalidResponse, tr("Could not extract token from HTTP answer"));
  403. + qCDebug(KGAPIDebug) << "Parsing token page failed. Title:" << title;
  404. + qCDebug(KGAPIDebug) << webview->page()->mainFrame()->toHtml();
  405. + emitError(AuthError, tr("Parsing token page failed."));
  406. + return;
  407. }
  408. - return;
  409. - }
  410. - Q_ASSERT(serverPort != -1);
  411. - auto fetch = new KGAPI2::NewTokensFetchJob(code, apiKey, secretKey, serverPort);
  412. - connect(fetch, &Job::finished, this, &AuthWidgetPrivate::tokensReceived);
  413. + if (token.isEmpty()) {
  414. + qCDebug(KGAPIDebug) << "Failed to obtain token.";
  415. + qCDebug(KGAPIDebug) << webview->page()->mainFrame()->toHtml();
  416. + emitError(AuthError, tr("Failed to obtain token."));
  417. + return;
  418. + }
  419. +
  420. + KGAPI2::NewTokensFetchJob *fetchJob = new KGAPI2::NewTokensFetchJob(token, apiKey, secretKey);
  421. + connect(fetchJob, &Job::finished,
  422. + this, &AuthWidgetPrivate::tokensReceived);
  423. + }
  424. }
  425. @@ -356,3 +226 @@ void AuthWidgetPrivate::accountInfoRecei
  426. -
  427. -#include "authwidget_p.moc"
  428. diff -Naurp1 a/src/core/ui/authwidget_p.h b/src/core/ui/authwidget_p.h
  429. --- a/src/core/ui/authwidget_p.h 2020-10-09 11:36:57.000000000 +0600
  430. +++ b/src/core/ui/authwidget_p.h 2020-12-02 20:34:35.819953632 +0600
  431. @@ -15,12 +15,6 @@
  432. -#include <QLineEdit>
  433. -#include <QToolButton>
  434. #include <QProgressBar>
  435. -#include <QAbstractSocket>
  436. -
  437. -class QVBoxLayout;
  438. -class QLabel;
  439. -class QWebEngineView;
  440. -class QTcpServer;
  441. -class QTcpSocket;
  442. +#include <QVBoxLayout>
  443. +#include <QWebView>
  444. +#include <QLabel>
  445. @@ -30,2 +24,14 @@ class Job;
  446. +class WebView : public QWebView
  447. +{
  448. + Q_OBJECT
  449. +public:
  450. + explicit WebView(QWidget *parent=0);
  451. + ~WebView();
  452. +
  453. +protected:
  454. + void contextMenuEvent( QContextMenuEvent *);
  455. +};
  456. +
  457. +
  458. // Exported for tests, otherwise internal
  459. @@ -37,5 +43,2 @@ class KGAPICORE_EXPORT AuthWidgetPrivate
  460. explicit AuthWidgetPrivate(AuthWidget *parent);
  461. - virtual void setupUi();
  462. - virtual void setUrl(const QUrl &url);
  463. - virtual void setVisible(bool visible);
  464. @@ -52,14 +55,10 @@ class KGAPICORE_EXPORT AuthWidgetPrivate
  465. - QToolButton *sslIndicator = nullptr;
  466. - QLineEdit *urlEdit = nullptr;
  467. - QProgressBar *progressbar = nullptr;
  468. - QVBoxLayout *vbox = nullptr;
  469. - QWebEngineView *webview = nullptr;
  470. - QLabel *label = nullptr;
  471. -
  472. - QTcpServer *server = nullptr;
  473. - int serverPort = 0;
  474. - QTcpSocket *connection = nullptr;
  475. + QProgressBar *progressbar;
  476. + QVBoxLayout *vbox;
  477. + WebView *webview;
  478. + QLabel *label;
  479. private Q_SLOTS:
  480. + void onSslError(QNetworkReply *reply, const QList<QSslError> &errors);
  481. +
  482. void emitError(const KGAPI2::Error errCode, const QString &msg);
  483. @@ -68,4 +67,2 @@ class KGAPICORE_EXPORT AuthWidgetPrivate
  484. - void socketReady();
  485. - void socketError(QAbstractSocket::SocketError error);
  486. void tokensReceived(KGAPI2::Job *job);
  487. @@ -74,11 +71,5 @@ class KGAPICORE_EXPORT AuthWidgetPrivate
  488. private:
  489. + void setupUi();
  490. void setProgress(AuthWidget::Progress progress);
  491. - bool isGoogleHost(const QUrl &url) const { return url.host() == QLatin1String("accounts.google.com"); }
  492. - bool isSigninPage(const QUrl &url) const { return url.path() == QLatin1String("/signin/oauth"); }
  493. - bool isUsernameFrame(const QUrl &url) { return url.path() == QLatin1String("/signin/oauth/identifier"); }
  494. - bool isPasswordFrame(const QUrl &url) { return url.path() == QLatin1String("/signin/v2/challenge/pwd"); }
  495. -
  496. - void setSslIcon(const QString &icon);
  497. -
  498. AuthWidget *const q;