Added empty gmail entry point.

This commit is contained in:
Martin Rotter 2017-10-16 14:36:53 +02:00
parent a10a78ab47
commit 67254d209c
8 changed files with 172 additions and 45 deletions

View File

@ -497,7 +497,9 @@ equals(USE_WEBENGINE, true) {
src/services/inoreader/gui/formeditinoreaderaccount.h \
src/services/inoreader/inoreaderfeed.h \
src/network-web/oauth2service.h \
src/gui/dialogs/oauthlogin.h
src/gui/dialogs/oauthlogin.h \
src/services/gmail/definitions.h \
src/services/gmail/gmailentrypoint.h
SOURCES += src/gui/locationlineedit.cpp \
src/gui/webviewer.cpp \
@ -512,7 +514,8 @@ equals(USE_WEBENGINE, true) {
src/services/inoreader/gui/formeditinoreaderaccount.cpp \
src/services/inoreader/inoreaderfeed.cpp \
src/network-web/oauth2service.cpp \
src/gui/dialogs/oauthlogin.cpp
src/gui/dialogs/oauthlogin.cpp \
src/services/gmail/gmailentrypoint.cpp
# Add AdBlock sources.
HEADERS += src/network-web/adblock/adblockaddsubscriptiondialog.h \

View File

@ -25,6 +25,7 @@
#define SERVICE_CODE_TT_RSS "tt-rss"
#define SERVICE_CODE_OWNCLOUD "owncloud"
#define SERVICE_CODE_INOREADER "inoreader"
#define SERVICE_CODE_GMAIL "gmail"
#define ARGUMENTS_LIST_SEPARATOR "\n"

View File

@ -175,58 +175,58 @@ int main(int argc, char* argv[]) {
qApp->showPolls();
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates();
/*
OAuth2Service * srv = new OAuth2Service(
"https://accounts.google.com/o/oauth2/auth",
"https://accounts.google.com/o/oauth2/token",
"369069180494-j66bgeciouinec1eem7fhvj6qm0as7q3.apps.googleusercontent.com",
"vppQtxrEeBkImiXcjGYl9NxZ",
"https://mail.google.com/");
/*
OAuth2Service* srv = new OAuth2Service(
"https://accounts.google.com/o/oauth2/auth",
"https://accounts.google.com/o/oauth2/token",
"369069180494-j66bgeciouinec1eem7fhvj6qm0as7q3.apps.googleusercontent.com",
"vppQtxrEeBkImiXcjGYl9NxZ",
"https://mail.google.com/");
srv->setRefreshToken("1/RKE3oohSoTHE54L0IPflvndK-DcI7l0of3lVdLa1Q9Q");
QObject::connect(srv, &OAuth2Service::authCodeObtained, [](QString auth_code) {
int a = 5;
});
QObject::connect(srv, &OAuth2Service::authFailed, []() {
int a = 5;
});
QObject::connect(srv, &OAuth2Service::tokensReceived, [srv](QString acc, QString ref, int exp) {
srv->setRefreshToken("1/RKE3oohSoTHE54L0IPflvndK-DcI7l0of3lVdLa1Q9Q");
QObject::connect(srv, &OAuth2Service::authCodeObtained, [](QString auth_code) {
int a = 5;
});
QObject::connect(srv, &OAuth2Service::authFailed, []() {
int a = 5;
});
QObject::connect(srv, &OAuth2Service::tokensReceived, [srv](QString acc, QString ref, int exp) {
QHttpMultiPart* multi = new QHttpMultiPart(srv);
QHttpPart p1;
QHttpPart p2;
QHttpMultiPart* multi = new QHttpMultiPart(srv);
QHttpPart p1;
QHttpPart p2;
multi->setContentType(QHttpMultiPart::ContentType::MixedType);
p1.setRawHeader("Content-Type", "application/http");
p2.setRawHeader("Content-Type", "application/http");
p1.setBody("GET /gmail/v1/users/me/messages\r\n");
p2.setBody("GET /gmail/v1/users/me/labels\r\n");
multi->append(p1);
multi->append(p2);
QNetworkRequest req;
multi->setContentType(QHttpMultiPart::ContentType::MixedType);
p1.setRawHeader("Content-Type", "application/http");
p2.setRawHeader("Content-Type", "application/http");
p1.setBody("GET /gmail/v1/users/me/messages\r\n");
p2.setBody("GET /gmail/v1/users/me/labels\r\n");
multi->append(p1);
multi->append(p2);
QNetworkRequest req;
auto bearer = srv->bearer();
req.setRawHeader(QString("Authorization").toLocal8Bit(), bearer.toLocal8Bit());
auto bearer = srv->bearer();
req.setRawHeader(QString("Authorization").toLocal8Bit(), bearer.toLocal8Bit());
req.setUrl(QUrl::fromUserInput("https://www.googleapis.com/batch"));
auto* repl = SilentNetworkAccessManager::instance()->post(req, multi);
req.setUrl(QUrl::fromUserInput("https://www.googleapis.com/batch"));
auto* repl = SilentNetworkAccessManager::instance()->post(req, multi);
//req.setUrl(QUrl::fromUserInput("https://www.googleapis.com/gmail/v1/users/me/labels"));
//auto* repl = SilentNetworkAccessManager::instance()->get(req);
//req.setUrl(QUrl::fromUserInput("https://www.googleapis.com/gmail/v1/users/me/labels"));
//auto* repl = SilentNetworkAccessManager::instance()->get(req);
QObject::connect(repl, &QNetworkReply::finished, [repl]() {
QObject::connect(repl, &QNetworkReply::finished, [repl]() {
auto resp = repl->readAll();
auto a = 8;
IOFactory::writeTextFile("b.html", resp);
});
});
int a = 5;
});
QObject::connect(srv, &OAuth2Service::tokensRetrieveError, [](QString err, QString desc) {
int a = 5;
});
srv->login(); */
int a = 5;
});
QObject::connect(srv, &OAuth2Service::tokensRetrieveError, [](QString err, QString desc) {
int a = 5;
});
srv->login();*/
// Enter global event loop.
return Application::exec();

View File

@ -21,6 +21,7 @@
#include "services/abstract/serviceroot.h"
#if defined(USE_WEBENGINE)
#include "services/gmail/gmailentrypoint.h"
#include "services/inoreader/inoreaderentrypoint.h"
#endif
@ -70,6 +71,7 @@ QList<ServiceEntryPoint*> FeedReader::feedServices() {
if (m_feedServices.isEmpty()) {
// NOTE: All installed services create their entry points here.
#if defined(USE_WEBENGINE)
m_feedServices.append(new GmailEntryPoint());
m_feedServices.append(new InoreaderEntryPoint());
#endif
m_feedServices.append(new OwnCloudServiceEntryPoint());

View File

@ -289,9 +289,10 @@ void OAuth2Service::killRefreshTimer() {
void OAuth2Service::retrieveAuthCode() {
QString auth_url = m_authUrl + QString("?client_id=%1&scope=%2&"
"redirect_uri=%3&response_type=code&state=abcdef").arg(m_clientId,
m_scope,
m_redirectUrl);
"redirect_uri=%3&response_type=code&state=abcdef&"
"prompt=consent&access_type=offline").arg(m_clientId,
m_scope,
m_redirectUrl);
OAuthLogin login_page(qApp->mainFormWidget());
connect(&login_page, &OAuthLogin::authGranted, this, &OAuth2Service::authCodeObtained);

View File

@ -0,0 +1,22 @@
// 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 GMAIL_DEFINITIONS_H
#define GMAIL_DEFINITIONS_H
#endif // GMAIL_DEFINITIONS_H

View File

@ -0,0 +1,61 @@
// 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/gmail/gmailentrypoint.h"
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "miscellaneous/databasequeries.h"
#include "miscellaneous/iconfactory.h"
#include "services/gmail/definitions.h"
ServiceRoot* GmailEntryPoint::createNewRoot() const {
return nullptr;
}
QList<ServiceRoot*> GmailEntryPoint::initializeSubtree() const {
QSqlDatabase database = qApp->database()->connection(QSL("GmailEntryPoint"), DatabaseFactory::FromSettings);
return QList<ServiceRoot*>();
//return DatabaseQueries::getInoreaderAccounts(database);
}
bool GmailEntryPoint::isSingleInstanceService() const {
return false;
}
QString GmailEntryPoint::name() const {
return QSL("Gmail (not yet implemented)");
}
QString GmailEntryPoint::code() const {
return SERVICE_CODE_GMAIL;
}
QString GmailEntryPoint::description() const {
return QObject::tr("Simple Gmail integration via JSON API. Allows sending e-mails too.");
}
QString GmailEntryPoint::author() const {
return APP_AUTHOR;
}
QIcon GmailEntryPoint::icon() const {
return qApp->icons()->miscIcon(QSL("gmail"));
}

View File

@ -0,0 +1,37 @@
// 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 GMAILENTRYPOINT_H
#define GMAILENTRYPOINT_H
#include "services/abstract/serviceentrypoint.h"
class GmailEntryPoint : public ServiceEntryPoint {
public:
ServiceRoot* createNewRoot() const;
QList<ServiceRoot*> initializeSubtree() const;
bool isSingleInstanceService() const;
QString name() const;
QString code() const;
QString description() const;
QString author() const;
QIcon icon() const;
};
#endif // GMAILENTRYPOINT_H