Added network wrapper for inoreader.

This commit is contained in:
Martin Rotter 2017-09-21 08:11:23 +02:00
parent 82c2970e1d
commit bbc81a8e2a
6 changed files with 108 additions and 13 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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);

View File

@ -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();

View File

@ -0,0 +1,65 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
#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();
*/

View File

@ -0,0 +1,35 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2017 by Martin Rotter <rotter.martinos@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
#ifndef INOREADERNETWORKFACTORY_H
#define INOREADERNETWORKFACTORY_H
#include <QObject>
class InoreaderNetworkFactory : public QObject {
Q_OBJECT
public:
explicit InoreaderNetworkFactory(QObject* parent = nullptr);
signals:
public slots:
};
#endif // INOREADERNETWORKFACTORY_H