diff --git a/rssguard.pro b/rssguard.pro index 3a6790e3f..4ad8b1ddb 100755 --- a/rssguard.pro +++ b/rssguard.pro @@ -166,7 +166,7 @@ message(rssguard: Prefix directory: \"$$PREFIX\".) message(rssguard: Build revision: \"$$APP_REVISION\".) message(rssguard: lrelease executable name: \"$$LRELEASE_EXECUTABLE\".) -QT += core gui widgets sql network xml +QT += core gui widgets sql network networkauth xml CONFIG *= c++11 debug_and_release warn_on DEFINES *= QT_USE_QSTRINGBUILDER QT_USE_FAST_CONCATENATION QT_USE_FAST_OPERATOR_PLUS UNICODE _UNICODE @@ -333,7 +333,8 @@ HEADERS += src/core/feeddownloader.h \ src/services/abstract/label.h \ src/miscellaneous/externaltool.h \ src/services/inoreader/definitions.h \ - src/services/inoreader/inoreaderentrypoint.h + src/services/inoreader/inoreaderentrypoint.h \ + src/services/inoreader/network/inoreadernetworkfactory.h SOURCES += src/core/feeddownloader.cpp \ src/core/feedsmodel.cpp \ @@ -456,7 +457,8 @@ SOURCES += src/core/feeddownloader.cpp \ src/services/abstract/labelsrootitem.cpp \ src/services/abstract/label.cpp \ src/miscellaneous/externaltool.cpp \ - src/services/inoreader/inoreaderentrypoint.cpp + src/services/inoreader/inoreaderentrypoint.cpp \ + src/services/inoreader/network/inoreadernetworkfactory.cpp OBJECTIVE_SOURCES += src/miscellaneous/disablewindowtabbing.mm diff --git a/src/gui/webbrowser.cpp b/src/gui/webbrowser.cpp index fa2d91c6f..bd9c093a5 100755 --- a/src/gui/webbrowser.cpp +++ b/src/gui/webbrowser.cpp @@ -48,6 +48,8 @@ void WebBrowser::createConnections() { // Forward title/icon changes. connect(m_webView, &WebViewer::titleChanged, this, &WebBrowser::onTitleChanged); connect(m_webView, &WebViewer::iconChanged, this, &WebBrowser::onIconChanged); + + connect(m_webView->page(), &WebPage::windowCloseRequested, this, &WebBrowser::closeRequested); } void WebBrowser::updateUrl(const QUrl& url) { diff --git a/src/gui/webbrowser.h b/src/gui/webbrowser.h index 773eef7a8..c50516599 100755 --- a/src/gui/webbrowser.h +++ b/src/gui/webbrowser.h @@ -85,8 +85,7 @@ class WebBrowser : public TabContent { void onIconChanged(const QIcon& icon); signals: - - // Title/icon is changed. + void closeRequested(); void iconChanged(int index, const QIcon& icon); void titleChanged(int index, const QString& title); diff --git a/src/network-web/webfactory.h b/src/network-web/webfactory.h index 8dc87fc08..e8975691b 100755 --- a/src/network-web/webfactory.h +++ b/src/network-web/webfactory.h @@ -37,11 +37,7 @@ class WebFactory : public QObject { Q_OBJECT public: - - // Constructor. explicit WebFactory(QObject* parent = nullptr); - - // Destructor. virtual ~WebFactory(); // Strips "<....>" (HTML, XML) tags from given text. @@ -58,8 +54,6 @@ class WebFactory : public QObject { #endif public slots: - - // Opens given string URL in external browser. bool openUrlInExternalBrowser(const QString& url); bool sendMessageViaEmail(const Message& message); @@ -74,8 +68,6 @@ class WebFactory : public QObject { #endif private: - - // Escape sequences generators. void genereteEscapes(); void generateDeescapes(); diff --git a/src/services/inoreader/network/inoreadernetworkfactory.cpp b/src/services/inoreader/network/inoreadernetworkfactory.cpp new file mode 100755 index 000000000..3c149e683 --- /dev/null +++ b/src/services/inoreader/network/inoreadernetworkfactory.cpp @@ -0,0 +1,65 @@ +// This file is part of RSS Guard. + +// +// Copyright (C) 2011-2017 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + +#include "services/inoreader/network/inoreadernetworkfactory.h" + +InoreaderNetworkFactory::InoreaderNetworkFactory(QObject* parent) : QObject(parent) {} + +/* + QOAuth2AuthorizationCodeFlow* oauth2 = new QOAuth2AuthorizationCodeFlow("1000000604", + QUrl("https://www.inoreader.com/oauth2/auth"), + QUrl("https://www.inoreader.com/oauth2/token"), + new SilentNetworkAccessManager(), + this); + auto replyHandler = new QOAuthHttpServerReplyHandler(8080, this); + + replyHandler->setCallbackPath(""); + + oauth2->setReplyHandler(replyHandler); + oauth2->setClientIdentifierSharedKey("gsStoZ3aAoQJCgQxoFSuXkWI7Sly87yK"); + oauth2->setContentType(QAbstractOAuth::ContentType::Json); + oauth2->setScope("read write"); + + connect(oauth2, &QOAuth2AuthorizationCodeFlow::statusChanged, [=]( + QAbstractOAuth::Status status) { + if (status == QAbstractOAuth::Status::Granted) { + int a = 5; + } + }); + + oauth2->setModifyParametersFunction([&](QAbstractOAuth::Stage stage, QVariantMap* parameters) { + if (stage == QAbstractOAuth::Stage::RequestingAuthorization) { + int b = 6; + } + }); + connect(oauth2, &QOAuth2AuthorizationCodeFlow::granted, [ = ] { + int c = 45; + + auto* reply = oauth2->get(QUrl("https://www.inoreader.com/reader/api/0/subscription/list")); + + connect(reply, &QNetworkReply::finished, [=]() { + const auto json = reply->readAll(); + const auto document = QJsonDocument::fromJson(json); + }); + }); + connect(oauth2, &QOAuth2AuthorizationCodeFlow::error, [](const QString& error, const QString& errorDescription, const QUrl& uri) { + int d = 5; + }); + connect(oauth2, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl); + oauth2->grant(); + */ diff --git a/src/services/inoreader/network/inoreadernetworkfactory.h b/src/services/inoreader/network/inoreadernetworkfactory.h new file mode 100755 index 000000000..676d2e184 --- /dev/null +++ b/src/services/inoreader/network/inoreadernetworkfactory.h @@ -0,0 +1,35 @@ +// This file is part of RSS Guard. + +// +// Copyright (C) 2011-2017 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + +#ifndef INOREADERNETWORKFACTORY_H +#define INOREADERNETWORKFACTORY_H + +#include + +class InoreaderNetworkFactory : public QObject { + Q_OBJECT + + public: + explicit InoreaderNetworkFactory(QObject* parent = nullptr); + + signals: + + public slots: +}; + +#endif // INOREADERNETWORKFACTORY_H