Starting to work on #349.
This commit is contained in:
parent
bafa3292c4
commit
a9fe39df92
24 changed files with 1034 additions and 5 deletions
BIN
resources/graphics/misc/google.png
Normal file
BIN
resources/graphics/misc/google.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9 KiB |
|
@ -17,6 +17,7 @@
|
||||||
<file>graphics/misc/adblock.png</file>
|
<file>graphics/misc/adblock.png</file>
|
||||||
<file>graphics/misc/adblock-disabled.png</file>
|
<file>graphics/misc/adblock-disabled.png</file>
|
||||||
<file>graphics/misc/gmail.png</file>
|
<file>graphics/misc/gmail.png</file>
|
||||||
|
<file>graphics/misc/google.png</file>
|
||||||
<file>graphics/misc/image-placeholder.png</file>
|
<file>graphics/misc/image-placeholder.png</file>
|
||||||
<file>graphics/misc/inoreader.png</file>
|
<file>graphics/misc/inoreader.png</file>
|
||||||
<file>graphics/misc/nextcloud.png</file>
|
<file>graphics/misc/nextcloud.png</file>
|
||||||
|
|
12
resources/sql/db_update_mysql_18_19.sql
Executable file
12
resources/sql/db_update_mysql_18_19.sql
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS GoogleReaderApiAccounts (
|
||||||
|
id INTEGER,
|
||||||
|
type INTEGER NOT NULL CHECK (type >= 1),
|
||||||
|
username TEXT NOT NULL,
|
||||||
|
password TEXT,
|
||||||
|
url TEXT NOT NULL,
|
||||||
|
msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1),
|
||||||
|
|
||||||
|
FOREIGN KEY (id) REFERENCES Accounts (id)
|
||||||
|
);
|
||||||
|
-- !
|
||||||
|
UPDATE Information SET inf_value = '19' WHERE inf_key = 'schema_version';
|
12
resources/sql/db_update_sqlite_18_19.sql
Executable file
12
resources/sql/db_update_sqlite_18_19.sql
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS GoogleReaderApiAccounts (
|
||||||
|
id INTEGER,
|
||||||
|
type INTEGER NOT NULL CHECK (type >= 1),
|
||||||
|
username TEXT NOT NULL,
|
||||||
|
password TEXT,
|
||||||
|
url TEXT NOT NULL,
|
||||||
|
msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1),
|
||||||
|
|
||||||
|
FOREIGN KEY (id) REFERENCES Accounts (id)
|
||||||
|
);
|
||||||
|
-- !
|
||||||
|
UPDATE Information SET inf_value = '19' WHERE inf_key = 'schema_version';
|
|
@ -12,6 +12,7 @@
|
||||||
#define SERVICE_CODE_STD_RSS "std-rss"
|
#define SERVICE_CODE_STD_RSS "std-rss"
|
||||||
#define SERVICE_CODE_TT_RSS "tt-rss"
|
#define SERVICE_CODE_TT_RSS "tt-rss"
|
||||||
#define SERVICE_CODE_OWNCLOUD "owncloud"
|
#define SERVICE_CODE_OWNCLOUD "owncloud"
|
||||||
|
#define SERVICE_CODE_GREADER "greader"
|
||||||
#define SERVICE_CODE_INOREADER "inoreader"
|
#define SERVICE_CODE_INOREADER "inoreader"
|
||||||
#define SERVICE_CODE_GMAIL "gmail"
|
#define SERVICE_CODE_GMAIL "gmail"
|
||||||
|
|
||||||
|
@ -103,6 +104,7 @@
|
||||||
#define LOGSEC_CORE "core: "
|
#define LOGSEC_CORE "core: "
|
||||||
#define LOGSEC_DB "database: "
|
#define LOGSEC_DB "database: "
|
||||||
#define LOGSEC_NEXTCLOUD "nextcloud: "
|
#define LOGSEC_NEXTCLOUD "nextcloud: "
|
||||||
|
#define LOGSEC_GREADER "greader: "
|
||||||
#define LOGSEC_INOREADER "inoreader: "
|
#define LOGSEC_INOREADER "inoreader: "
|
||||||
#define LOGSEC_TTRSS "tt-rss: "
|
#define LOGSEC_TTRSS "tt-rss: "
|
||||||
#define LOGSEC_GMAIL "gmail: "
|
#define LOGSEC_GMAIL "gmail: "
|
||||||
|
|
|
@ -150,6 +150,13 @@ HEADERS += core/feeddownloader.h \
|
||||||
services/gmail/gui/formeditgmailaccount.h \
|
services/gmail/gui/formeditgmailaccount.h \
|
||||||
services/gmail/gui/gmailaccountdetails.h \
|
services/gmail/gui/gmailaccountdetails.h \
|
||||||
services/gmail/network/gmailnetworkfactory.h \
|
services/gmail/network/gmailnetworkfactory.h \
|
||||||
|
services/greader/definitions.h \
|
||||||
|
services/greader/greaderentrypoint.h \
|
||||||
|
services/greader/greaderfeed.h \
|
||||||
|
services/greader/greadernetwork.h \
|
||||||
|
services/greader/greaderserviceroot.h \
|
||||||
|
services/greader/gui/formeditgreaderaccount.h \
|
||||||
|
services/greader/gui/greaderaccountdetails.h \
|
||||||
services/inoreader/definitions.h \
|
services/inoreader/definitions.h \
|
||||||
services/inoreader/gui/formeditinoreaderaccount.h \
|
services/inoreader/gui/formeditinoreaderaccount.h \
|
||||||
services/inoreader/gui/inoreaderaccountdetails.h \
|
services/inoreader/gui/inoreaderaccountdetails.h \
|
||||||
|
@ -310,6 +317,12 @@ SOURCES += core/feeddownloader.cpp \
|
||||||
services/gmail/gui/formeditgmailaccount.cpp \
|
services/gmail/gui/formeditgmailaccount.cpp \
|
||||||
services/gmail/gui/gmailaccountdetails.cpp \
|
services/gmail/gui/gmailaccountdetails.cpp \
|
||||||
services/gmail/network/gmailnetworkfactory.cpp \
|
services/gmail/network/gmailnetworkfactory.cpp \
|
||||||
|
services/greader/greaderentrypoint.cpp \
|
||||||
|
services/greader/greaderfeed.cpp \
|
||||||
|
services/greader/greadernetwork.cpp \
|
||||||
|
services/greader/greaderserviceroot.cpp \
|
||||||
|
services/greader/gui/formeditgreaderaccount.cpp \
|
||||||
|
services/greader/gui/greaderaccountdetails.cpp \
|
||||||
services/inoreader/gui/formeditinoreaderaccount.cpp \
|
services/inoreader/gui/formeditinoreaderaccount.cpp \
|
||||||
services/inoreader/gui/inoreaderaccountdetails.cpp \
|
services/inoreader/gui/inoreaderaccountdetails.cpp \
|
||||||
services/inoreader/inoreaderentrypoint.cpp \
|
services/inoreader/inoreaderentrypoint.cpp \
|
||||||
|
@ -384,6 +397,7 @@ FORMS += gui/dialogs/formabout.ui \
|
||||||
services/abstract/gui/formfeeddetails.ui \
|
services/abstract/gui/formfeeddetails.ui \
|
||||||
services/abstract/gui/authenticationdetails.ui \
|
services/abstract/gui/authenticationdetails.ui \
|
||||||
services/gmail/gui/gmailaccountdetails.ui \
|
services/gmail/gui/gmailaccountdetails.ui \
|
||||||
|
services/greader/gui/greaderaccountdetails.ui \
|
||||||
services/inoreader/gui/inoreaderaccountdetails.ui \
|
services/inoreader/gui/inoreaderaccountdetails.ui \
|
||||||
services/owncloud/gui/owncloudaccountdetails.ui \
|
services/owncloud/gui/owncloudaccountdetails.ui \
|
||||||
services/standard/gui/formstandardcategorydetails.ui \
|
services/standard/gui/formstandardcategorydetails.ui \
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
#include "services/gmail/gmailfeed.h"
|
#include "services/gmail/gmailfeed.h"
|
||||||
#include "services/gmail/gmailserviceroot.h"
|
#include "services/gmail/gmailserviceroot.h"
|
||||||
#include "services/gmail/network/gmailnetworkfactory.h"
|
#include "services/gmail/network/gmailnetworkfactory.h"
|
||||||
|
#include "services/greader/definitions.h"
|
||||||
|
#include "services/greader/greadernetwork.h"
|
||||||
|
#include "services/greader/greaderserviceroot.h"
|
||||||
#include "services/inoreader/definitions.h"
|
#include "services/inoreader/definitions.h"
|
||||||
#include "services/inoreader/inoreaderfeed.h"
|
#include "services/inoreader/inoreaderfeed.h"
|
||||||
#include "services/inoreader/inoreaderserviceroot.h"
|
#include "services/inoreader/inoreaderserviceroot.h"
|
||||||
|
@ -1675,6 +1678,46 @@ void DatabaseQueries::fillBaseAccountData(const QSqlDatabase& db, ServiceRoot* a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<ServiceRoot*> DatabaseQueries::getGreaderAccounts(const QSqlDatabase& db, bool* ok) {
|
||||||
|
QSqlQuery query(db);
|
||||||
|
QList<ServiceRoot*> roots;
|
||||||
|
|
||||||
|
if (query.exec("SELECT * FROM GoogleReaderApiAccounts;")) {
|
||||||
|
while (query.next()) {
|
||||||
|
auto* root = new GreaderServiceRoot();
|
||||||
|
|
||||||
|
root->setId(query.value(0).toInt());
|
||||||
|
root->setAccountId(query.value(0).toInt());
|
||||||
|
root->network()->setService(GreaderServiceRoot::Service(query.value(1).toInt()));
|
||||||
|
root->network()->setUsername(query.value(2).toString());
|
||||||
|
root->network()->setPassword(TextFactory::decrypt(query.value(3).toString()));
|
||||||
|
root->network()->setBaseUrl(query.value(4).toString());
|
||||||
|
root->network()->setBatchSize(query.value(5).toInt());
|
||||||
|
root->updateTitle();
|
||||||
|
|
||||||
|
fillBaseAccountData(db, root);
|
||||||
|
|
||||||
|
roots.append(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok != nullptr) {
|
||||||
|
*ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qWarningNN << LOGSEC_GREADER
|
||||||
|
<< "Getting list of activated accounts failed: '"
|
||||||
|
<< query.lastError().text()
|
||||||
|
<< "'.";
|
||||||
|
|
||||||
|
if (ok != nullptr) {
|
||||||
|
*ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return roots;
|
||||||
|
}
|
||||||
|
|
||||||
QList<ServiceRoot*> DatabaseQueries::getOwnCloudAccounts(const QSqlDatabase& db, bool* ok) {
|
QList<ServiceRoot*> DatabaseQueries::getOwnCloudAccounts(const QSqlDatabase& db, bool* ok) {
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
QList<ServiceRoot*> roots;
|
QList<ServiceRoot*> roots;
|
||||||
|
@ -1768,6 +1811,32 @@ bool DatabaseQueries::deleteOwnCloudAccount(const QSqlDatabase& db, int account_
|
||||||
return q.exec();
|
return q.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DatabaseQueries::overwriteGreaderAccount(const QSqlDatabase& db, const QString& username, const QString& password,
|
||||||
|
const QString& url, int batch_size, int account_id) {
|
||||||
|
QSqlQuery query(db);
|
||||||
|
|
||||||
|
query.prepare("UPDATE GoogleReaderApiAccounts "
|
||||||
|
"SET username = :username, password = :password, url = :url, "
|
||||||
|
"msg_limit = :msg_limit "
|
||||||
|
"WHERE id = :id;");
|
||||||
|
query.bindValue(QSL(":username"), username);
|
||||||
|
query.bindValue(QSL(":password"), TextFactory::encrypt(password));
|
||||||
|
query.bindValue(QSL(":url"), url);
|
||||||
|
query.bindValue(QSL(":id"), account_id);
|
||||||
|
query.bindValue(QSL(":msg_limit"), batch_size <= 0 ? GREADER_UNLIMITED_BATCH_SIZE : batch_size);
|
||||||
|
|
||||||
|
if (query.exec()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qWarningNN << LOGSEC_GREADER
|
||||||
|
<< "Updating account failed: '"
|
||||||
|
<< query.lastError().text()
|
||||||
|
<< "'.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DatabaseQueries::overwriteOwnCloudAccount(const QSqlDatabase& db, const QString& username, const QString& password,
|
bool DatabaseQueries::overwriteOwnCloudAccount(const QSqlDatabase& db, const QString& username, const QString& password,
|
||||||
const QString& url, bool force_server_side_feed_update, int batch_size,
|
const QString& url, bool force_server_side_feed_update, int batch_size,
|
||||||
bool download_only_unread_messages, int account_id) {
|
bool download_only_unread_messages, int account_id) {
|
||||||
|
@ -1797,6 +1866,32 @@ bool DatabaseQueries::overwriteOwnCloudAccount(const QSqlDatabase& db, const QSt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DatabaseQueries::createGreaderAccount(const QSqlDatabase& db, int id_to_assign, const QString& username,
|
||||||
|
const QString& password, GreaderServiceRoot::Service service,
|
||||||
|
const QString& url, int batch_size) {
|
||||||
|
QSqlQuery q(db);
|
||||||
|
|
||||||
|
q.prepare("INSERT INTO GoogleReaderApiAccounts (id, type, username, password, url, msg_limit) "
|
||||||
|
"VALUES (:id, :service, :username, :password, :url, :msg_limit);");
|
||||||
|
q.bindValue(QSL(":id"), id_to_assign);
|
||||||
|
q.bindValue(QSL(":username"), username);
|
||||||
|
q.bindValue(QSL(":service"), int(service));
|
||||||
|
q.bindValue(QSL(":password"), TextFactory::encrypt(password));
|
||||||
|
q.bindValue(QSL(":url"), url);
|
||||||
|
q.bindValue(QSL(":msg_limit"), batch_size <= 0 ? GREADER_UNLIMITED_BATCH_SIZE : batch_size);
|
||||||
|
|
||||||
|
if (q.exec()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qWarningNN << LOGSEC_GREADER
|
||||||
|
<< "Inserting of new account failed: '"
|
||||||
|
<< q.lastError().text()
|
||||||
|
<< "'.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DatabaseQueries::createOwnCloudAccount(const QSqlDatabase& db, int id_to_assign, const QString& username,
|
bool DatabaseQueries::createOwnCloudAccount(const QSqlDatabase& db, int id_to_assign, const QString& username,
|
||||||
const QString& password, const QString& url,
|
const QString& password, const QString& url,
|
||||||
bool force_server_side_feed_update,
|
bool force_server_side_feed_update,
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "services/abstract/category.h"
|
#include "services/abstract/category.h"
|
||||||
#include "services/abstract/label.h"
|
#include "services/abstract/label.h"
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
|
#include "services/greader/greaderserviceroot.h"
|
||||||
#include "services/standard/standardfeed.h"
|
#include "services/standard/standardfeed.h"
|
||||||
|
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
|
@ -147,14 +148,22 @@ class DatabaseQueries {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void fillFeedData(T* feed, const QSqlRecord& sql_record);
|
static void fillFeedData(T* feed, const QSqlRecord& sql_record);
|
||||||
|
|
||||||
|
// Greader account.
|
||||||
|
static QList<ServiceRoot*> getGreaderAccounts(const QSqlDatabase& db, bool* ok = nullptr);
|
||||||
|
static bool createGreaderAccount(const QSqlDatabase& db, int id_to_assign, const QString& username,
|
||||||
|
const QString& password, GreaderServiceRoot::Service service,
|
||||||
|
const QString& url, int batch_size);
|
||||||
|
static bool overwriteGreaderAccount(const QSqlDatabase& db, const QString& username, const QString& password,
|
||||||
|
const QString& url, int batch_size, int account_id);
|
||||||
|
|
||||||
// Nextcloud account.
|
// Nextcloud account.
|
||||||
static QList<ServiceRoot*> getOwnCloudAccounts(const QSqlDatabase& db, bool* ok = nullptr);
|
static QList<ServiceRoot*> getOwnCloudAccounts(const QSqlDatabase& db, bool* ok = nullptr);
|
||||||
static bool deleteOwnCloudAccount(const QSqlDatabase& db, int account_id);
|
static bool deleteOwnCloudAccount(const QSqlDatabase& db, int account_id);
|
||||||
static bool overwriteOwnCloudAccount(const QSqlDatabase& db, const QString& username, const QString& password,
|
static bool overwriteOwnCloudAccount(const QSqlDatabase& db, const QString& username, const QString& password,
|
||||||
const QString& url, bool force_server_side_feed_update, int batch_size,
|
const QString& url, bool force_server_side_feed_update, int batch_size,
|
||||||
bool download_only_unread_messages, int account_id);
|
bool download_only_unread_messages, int account_id);
|
||||||
static bool createOwnCloudAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, const QString& password,
|
static bool createOwnCloudAccount(const QSqlDatabase& db, int id_to_assign, const QString& username,
|
||||||
const QString& url, bool force_server_side_feed_update,
|
const QString& password, const QString& url, bool force_server_side_feed_update,
|
||||||
bool download_only_unread_messages, int batch_size);
|
bool download_only_unread_messages, int batch_size);
|
||||||
|
|
||||||
// TT-RSS acccount.
|
// TT-RSS acccount.
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "services/abstract/cacheforserviceroot.h"
|
#include "services/abstract/cacheforserviceroot.h"
|
||||||
#include "services/abstract/serviceroot.h"
|
#include "services/abstract/serviceroot.h"
|
||||||
#include "services/gmail/gmailentrypoint.h"
|
#include "services/gmail/gmailentrypoint.h"
|
||||||
|
#include "services/greader/greaderentrypoint.h"
|
||||||
#include "services/inoreader/inoreaderentrypoint.h"
|
#include "services/inoreader/inoreaderentrypoint.h"
|
||||||
#include "services/owncloud/owncloudserviceentrypoint.h"
|
#include "services/owncloud/owncloudserviceentrypoint.h"
|
||||||
#include "services/standard/standardserviceentrypoint.h"
|
#include "services/standard/standardserviceentrypoint.h"
|
||||||
|
@ -55,6 +56,7 @@ QList<ServiceEntryPoint*> FeedReader::feedServices() {
|
||||||
if (m_feedServices.isEmpty()) {
|
if (m_feedServices.isEmpty()) {
|
||||||
// NOTE: All installed services create their entry points here.
|
// NOTE: All installed services create their entry points here.
|
||||||
m_feedServices.append(new GmailEntryPoint());
|
m_feedServices.append(new GmailEntryPoint());
|
||||||
|
m_feedServices.append(new GreaderEntryPoint());
|
||||||
m_feedServices.append(new InoreaderEntryPoint());
|
m_feedServices.append(new InoreaderEntryPoint());
|
||||||
m_feedServices.append(new OwnCloudServiceEntryPoint());
|
m_feedServices.append(new OwnCloudServiceEntryPoint());
|
||||||
m_feedServices.append(new StandardServiceEntryPoint());
|
m_feedServices.append(new StandardServiceEntryPoint());
|
||||||
|
|
|
@ -73,11 +73,9 @@ inline bool FormAccountDetails::applyInternal() {
|
||||||
QSqlDatabase database = qApp->database()->connection(QSL("FormAccountDetails"));
|
QSqlDatabase database = qApp->database()->connection(QSL("FormAccountDetails"));
|
||||||
bool creating = m_account == nullptr;
|
bool creating = m_account == nullptr;
|
||||||
|
|
||||||
if (m_account == nullptr) {
|
if (creating) {
|
||||||
m_account = new T();
|
m_account = new T();
|
||||||
m_account->setAccountId(DatabaseQueries::createBaseAccount(database, m_account->code()));
|
m_account->setAccountId(DatabaseQueries::createBaseAccount(database, m_account->code()));
|
||||||
|
|
||||||
//m_account->setId(m_account->accountId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_account->setNetworkProxy(m_proxyDetails->proxy());
|
m_account->setNetworkProxy(m_proxyDetails->proxy());
|
||||||
|
|
6
src/librssguard/services/greader/definitions.h
Executable file
6
src/librssguard/services/greader/definitions.h
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef GREADER_DEFINITIONS_H
|
||||||
|
#define GREADER_DEFINITIONS_H
|
||||||
|
|
||||||
|
#define GREADER_UNLIMITED_BATCH_SIZE -1
|
||||||
|
|
||||||
|
#endif // GREADER_DEFINITIONS_H
|
44
src/librssguard/services/greader/greaderentrypoint.cpp
Executable file
44
src/librssguard/services/greader/greaderentrypoint.cpp
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "services/greader/greaderentrypoint.h"
|
||||||
|
|
||||||
|
#include "definitions/definitions.h"
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
|
#include "miscellaneous/databasequeries.h"
|
||||||
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
#include "services/greader/definitions.h"
|
||||||
|
#include "services/greader/greaderserviceroot.h"
|
||||||
|
#include "services/greader/gui/formeditgreaderaccount.h"
|
||||||
|
|
||||||
|
ServiceRoot* GreaderEntryPoint::createNewRoot() const {
|
||||||
|
FormEditGreaderAccount form_acc(qApp->mainFormWidget());
|
||||||
|
|
||||||
|
return form_acc.addEditAccount<GreaderServiceRoot>();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<ServiceRoot*> GreaderEntryPoint::initializeSubtree() const {
|
||||||
|
QSqlDatabase database = qApp->database()->connection(QSL("GreaderEntryPoint"));
|
||||||
|
|
||||||
|
return DatabaseQueries::getGreaderAccounts(database);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderEntryPoint::name() const {
|
||||||
|
return QSL("Google Reader API");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderEntryPoint::code() const {
|
||||||
|
return SERVICE_CODE_GREADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderEntryPoint::description() const {
|
||||||
|
return QObject::tr("Google Reader API is used by many online RSS readers. This is here to support") +
|
||||||
|
QSL(" FreshRSS, Bazqux, TheOldReader.");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderEntryPoint::author() const {
|
||||||
|
return APP_AUTHOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon GreaderEntryPoint::icon() const {
|
||||||
|
return qApp->icons()->miscIcon(QSL("google"));
|
||||||
|
}
|
19
src/librssguard/services/greader/greaderentrypoint.h
Executable file
19
src/librssguard/services/greader/greaderentrypoint.h
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef GREADERENTRYPOINT_H
|
||||||
|
#define GREADERENTRYPOINT_H
|
||||||
|
|
||||||
|
#include "services/abstract/serviceentrypoint.h"
|
||||||
|
|
||||||
|
class GreaderEntryPoint : public ServiceEntryPoint {
|
||||||
|
public:
|
||||||
|
virtual ServiceRoot* createNewRoot() const;
|
||||||
|
virtual QList<ServiceRoot*> initializeSubtree() const;
|
||||||
|
virtual QString name() const;
|
||||||
|
virtual QString code() const;
|
||||||
|
virtual QString description() const;
|
||||||
|
virtual QString author() const;
|
||||||
|
virtual QIcon icon() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GREADERENTRYPOINT_H
|
29
src/librssguard/services/greader/greaderfeed.cpp
Executable file
29
src/librssguard/services/greader/greaderfeed.cpp
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "services/greader/greaderfeed.h"
|
||||||
|
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
#include "services/greader/greadernetwork.h"
|
||||||
|
#include "services/greader/greaderserviceroot.h"
|
||||||
|
|
||||||
|
GreaderFeed::GreaderFeed(RootItem* parent) : Feed(parent) {}
|
||||||
|
|
||||||
|
GreaderFeed::GreaderFeed(const QSqlRecord& record) : Feed(record) {}
|
||||||
|
|
||||||
|
GreaderServiceRoot* GreaderFeed::serviceRoot() const {
|
||||||
|
return qobject_cast<GreaderServiceRoot*>(getParentServiceRoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Message> GreaderFeed::obtainNewMessages(bool* error_during_obtaining) {
|
||||||
|
Feed::Status error = Feed::Status::Normal;
|
||||||
|
QList<Message> messages = serviceRoot()->network()->messages(getParentServiceRoot(), customId(), error);
|
||||||
|
|
||||||
|
setStatus(error);
|
||||||
|
|
||||||
|
if (error == Feed::Status::NetworkError || error == Feed::Status::AuthError) {
|
||||||
|
*error_during_obtaining = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
19
src/librssguard/services/greader/greaderfeed.h
Executable file
19
src/librssguard/services/greader/greaderfeed.h
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef GREADERFEED_H
|
||||||
|
#define GREADERFEED_H
|
||||||
|
|
||||||
|
#include "services/abstract/feed.h"
|
||||||
|
|
||||||
|
class GreaderServiceRoot;
|
||||||
|
|
||||||
|
class GreaderFeed : public Feed {
|
||||||
|
public:
|
||||||
|
explicit GreaderFeed(RootItem* parent = nullptr);
|
||||||
|
explicit GreaderFeed(const QSqlRecord& record);
|
||||||
|
|
||||||
|
GreaderServiceRoot* serviceRoot() const;
|
||||||
|
QList<Message> obtainNewMessages(bool* error_during_obtaining);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GREADERFEED_H
|
70
src/librssguard/services/greader/greadernetwork.cpp
Executable file
70
src/librssguard/services/greader/greadernetwork.cpp
Executable file
|
@ -0,0 +1,70 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "services/greader/greadernetwork.h"
|
||||||
|
|
||||||
|
GreaderNetwork::GreaderNetwork(QObject* parent)
|
||||||
|
: QObject(parent), m_service(GreaderServiceRoot::Service::FreshRss) {}
|
||||||
|
|
||||||
|
QList<Message> GreaderNetwork::messages(ServiceRoot* root, const QString& stream_id, Feed::Status& error) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkResult GreaderNetwork::status(const QNetworkProxy& custom_proxy) const {
|
||||||
|
return NetworkResult(QNetworkReply::NetworkError::NoError, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
GreaderServiceRoot::Service GreaderNetwork::service() const {
|
||||||
|
return m_service;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderNetwork::setService(const GreaderServiceRoot::Service& service) {
|
||||||
|
m_service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderNetwork::username() const {
|
||||||
|
return m_username;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderNetwork::setUsername(const QString& username) {
|
||||||
|
m_username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderNetwork::password() const {
|
||||||
|
return m_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderNetwork::setPassword(const QString& password) {
|
||||||
|
m_password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderNetwork::baseUrl() const {
|
||||||
|
return m_baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderNetwork::setBaseUrl(const QString& base_url) {
|
||||||
|
m_baseUrl = base_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderNetwork::serviceToString(GreaderServiceRoot::Service service) {
|
||||||
|
switch (service) {
|
||||||
|
case GreaderServiceRoot::Service::FreshRss:
|
||||||
|
return QSL("FreshRSS");
|
||||||
|
|
||||||
|
case GreaderServiceRoot::Service::Bazqux:
|
||||||
|
return QSL("Bazqux");
|
||||||
|
|
||||||
|
case GreaderServiceRoot::Service::TheOldReader:
|
||||||
|
return QSL("TheOldReader");
|
||||||
|
|
||||||
|
default:
|
||||||
|
return tr("Unknown service");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int GreaderNetwork::batchSize() const {
|
||||||
|
return m_batchSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderNetwork::setBatchSize(int batch_size) {
|
||||||
|
m_batchSize = batch_size;
|
||||||
|
}
|
49
src/librssguard/services/greader/greadernetwork.h
Executable file
49
src/librssguard/services/greader/greadernetwork.h
Executable file
|
@ -0,0 +1,49 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef GREADERNETWORK_H
|
||||||
|
#define GREADERNETWORK_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "network-web/networkfactory.h"
|
||||||
|
#include "services/abstract/feed.h"
|
||||||
|
#include "services/greader/greaderserviceroot.h"
|
||||||
|
|
||||||
|
class GreaderNetwork : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit GreaderNetwork(QObject* parent = nullptr);
|
||||||
|
|
||||||
|
// Network operations.
|
||||||
|
QList<Message> messages(ServiceRoot* root, const QString& stream_id, Feed::Status& error);
|
||||||
|
|
||||||
|
NetworkResult status(const QNetworkProxy& custom_proxy) const;
|
||||||
|
|
||||||
|
// Metadata.
|
||||||
|
GreaderServiceRoot::Service service() const;
|
||||||
|
void setService(const GreaderServiceRoot::Service& service);
|
||||||
|
|
||||||
|
QString username() const;
|
||||||
|
void setUsername(const QString& username);
|
||||||
|
|
||||||
|
QString password() const;
|
||||||
|
void setPassword(const QString& password);
|
||||||
|
|
||||||
|
QString baseUrl() const;
|
||||||
|
void setBaseUrl(const QString& base_url);
|
||||||
|
|
||||||
|
static QString serviceToString(GreaderServiceRoot::Service service);
|
||||||
|
|
||||||
|
int batchSize() const;
|
||||||
|
void setBatchSize(int batch_size);
|
||||||
|
|
||||||
|
private:
|
||||||
|
GreaderServiceRoot::Service m_service;
|
||||||
|
QString m_username;
|
||||||
|
QString m_password;
|
||||||
|
QString m_baseUrl;
|
||||||
|
int m_batchSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GREADERNETWORK_H
|
153
src/librssguard/services/greader/greaderserviceroot.cpp
Executable file
153
src/librssguard/services/greader/greaderserviceroot.cpp
Executable file
|
@ -0,0 +1,153 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "services/greader/greaderserviceroot.h"
|
||||||
|
|
||||||
|
#include "definitions/definitions.h"
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
|
#include "miscellaneous/databasequeries.h"
|
||||||
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
#include "miscellaneous/mutex.h"
|
||||||
|
#include "miscellaneous/textfactory.h"
|
||||||
|
#include "services/abstract/importantnode.h"
|
||||||
|
#include "services/abstract/recyclebin.h"
|
||||||
|
#include "services/greader/greaderentrypoint.h"
|
||||||
|
#include "services/greader/greaderfeed.h"
|
||||||
|
#include "services/greader/greadernetwork.h"
|
||||||
|
#include "services/greader/gui/formeditgreaderaccount.h"
|
||||||
|
|
||||||
|
GreaderServiceRoot::GreaderServiceRoot(RootItem* parent)
|
||||||
|
: ServiceRoot(parent), m_network(new GreaderNetwork(this)) {
|
||||||
|
setIcon(GreaderEntryPoint().icon());
|
||||||
|
}
|
||||||
|
|
||||||
|
GreaderServiceRoot::~GreaderServiceRoot() {}
|
||||||
|
|
||||||
|
bool GreaderServiceRoot::isSyncable() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GreaderServiceRoot::canBeEdited() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GreaderServiceRoot::canBeDeleted() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GreaderServiceRoot::editViaGui() {
|
||||||
|
FormEditGreaderAccount form_pointer(qApp->mainFormWidget());
|
||||||
|
|
||||||
|
form_pointer.addEditAccount(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GreaderServiceRoot::deleteViaGui() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderServiceRoot::start(bool freshly_activated) {
|
||||||
|
Q_UNUSED(freshly_activated)
|
||||||
|
loadFromDatabase();
|
||||||
|
loadCacheFromFile();
|
||||||
|
|
||||||
|
if (childCount() <= 3) {
|
||||||
|
syncIn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GreaderServiceRoot::code() const {
|
||||||
|
return GreaderEntryPoint().code();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderServiceRoot::saveAllCachedData(bool ignore_errors) {
|
||||||
|
auto msg_cache = takeMessageCache();
|
||||||
|
|
||||||
|
/*
|
||||||
|
QMapIterator<RootItem::ReadStatus, QStringList> i(msg_cache.m_cachedStatesRead);
|
||||||
|
|
||||||
|
// Save the actual data read/unread.
|
||||||
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
auto key = i.key();
|
||||||
|
QStringList ids = i.value();
|
||||||
|
|
||||||
|
if (!ids.isEmpty()) {
|
||||||
|
auto res = network()->markMessagesRead(key, ids, networkProxy());
|
||||||
|
|
||||||
|
if (!ignore_errors && res.first != QNetworkReply::NetworkError::NoError) {
|
||||||
|
addMessageStatesToCache(ids, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMapIterator<RootItem::Importance, QList<Message>> j(msg_cache.m_cachedStatesImportant);
|
||||||
|
|
||||||
|
// Save the actual data important/not important.
|
||||||
|
while (j.hasNext()) {
|
||||||
|
j.next();
|
||||||
|
auto key = j.key();
|
||||||
|
QList<Message> messages = j.value();
|
||||||
|
|
||||||
|
if (!messages.isEmpty()) {
|
||||||
|
QStringList feed_ids, guid_hashes;
|
||||||
|
|
||||||
|
for (const Message& msg : messages) {
|
||||||
|
feed_ids.append(msg.m_feedId);
|
||||||
|
guid_hashes.append(msg.m_customHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto res = network()->markMessagesStarred(key, feed_ids, guid_hashes, networkProxy());
|
||||||
|
|
||||||
|
if (!ignore_errors && res.first != QNetworkReply::NetworkError::NoError) {
|
||||||
|
addMessageStatesToCache(messages, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderServiceRoot::updateTitle() {
|
||||||
|
setTitle(QString("%1 (%2)").arg(m_network->username(),
|
||||||
|
m_network->serviceToString(m_network->service())));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderServiceRoot::saveAccountDataToDatabase(bool creating_new) {
|
||||||
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||||
|
|
||||||
|
if (!creating_new) {
|
||||||
|
if (DatabaseQueries::overwriteGreaderAccount(database, m_network->username(),
|
||||||
|
m_network->password(), m_network->baseUrl(),
|
||||||
|
m_network->batchSize(), accountId())) {
|
||||||
|
updateTitle();
|
||||||
|
itemChanged(QList<RootItem*>() << this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (DatabaseQueries::createGreaderAccount(database, accountId(), m_network->username(),
|
||||||
|
m_network->password(), m_network->service(),
|
||||||
|
m_network->baseUrl(), m_network->batchSize())) {
|
||||||
|
updateTitle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RootItem* GreaderServiceRoot::obtainNewTreeForSyncIn() const {
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
/*OwnCloudGetFeedsCategoriesResponse feed_cats_response = m_network->feedsCategories(networkProxy());
|
||||||
|
|
||||||
|
if (feed_cats_response.networkError() == QNetworkReply::NetworkError::NoError) {
|
||||||
|
return feed_cats_response.feedsCategories(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nullptr;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderServiceRoot::loadFromDatabase() {
|
||||||
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||||
|
Assignment categories = DatabaseQueries::getCategories<Category>(database, accountId());
|
||||||
|
Assignment feeds = DatabaseQueries::getFeeds<GreaderFeed>(database, qApp->feedReader()->messageFilters(), accountId());
|
||||||
|
auto labels = DatabaseQueries::getLabels(database, accountId());
|
||||||
|
|
||||||
|
performInitialAssembly(categories, feeds, labels);
|
||||||
|
}
|
61
src/librssguard/services/greader/greaderserviceroot.h
Executable file
61
src/librssguard/services/greader/greaderserviceroot.h
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef GREADERSERVICEROOT_H
|
||||||
|
#define GREADERSERVICEROOT_H
|
||||||
|
|
||||||
|
#include "services/abstract/cacheforserviceroot.h"
|
||||||
|
#include "services/abstract/serviceroot.h"
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
class GreaderNetwork;
|
||||||
|
|
||||||
|
class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum class Service {
|
||||||
|
FreshRss = 1,
|
||||||
|
TheOldReader = 2,
|
||||||
|
Bazqux = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit GreaderServiceRoot(RootItem* parent = nullptr);
|
||||||
|
virtual ~GreaderServiceRoot();
|
||||||
|
|
||||||
|
virtual bool isSyncable() const;
|
||||||
|
virtual bool canBeEdited() const;
|
||||||
|
virtual bool canBeDeleted() const;
|
||||||
|
virtual bool editViaGui();
|
||||||
|
virtual bool deleteViaGui();
|
||||||
|
virtual void start(bool freshly_activated);
|
||||||
|
virtual QString code() const;
|
||||||
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
|
|
||||||
|
void setNetwork(GreaderNetwork* network);
|
||||||
|
GreaderNetwork* network() const;
|
||||||
|
|
||||||
|
void updateTitle();
|
||||||
|
void saveAccountDataToDatabase(bool creating_new);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual RootItem* obtainNewTreeForSyncIn() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void loadFromDatabase();
|
||||||
|
|
||||||
|
private:
|
||||||
|
GreaderNetwork* m_network;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(GreaderServiceRoot::Service)
|
||||||
|
|
||||||
|
inline void GreaderServiceRoot::setNetwork(GreaderNetwork* network) {
|
||||||
|
m_network = network;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GreaderNetwork* GreaderServiceRoot::network() const {
|
||||||
|
return m_network;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GREADERSERVICEROOT_H
|
55
src/librssguard/services/greader/gui/formeditgreaderaccount.cpp
Executable file
55
src/librssguard/services/greader/gui/formeditgreaderaccount.cpp
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "services/greader/gui/formeditgreaderaccount.h"
|
||||||
|
|
||||||
|
#include "gui/guiutilities.h"
|
||||||
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
#include "network-web/networkfactory.h"
|
||||||
|
#include "services/greader/definitions.h"
|
||||||
|
#include "services/greader/greadernetwork.h"
|
||||||
|
#include "services/greader/greaderserviceroot.h"
|
||||||
|
#include "services/greader/gui/greaderaccountdetails.h"
|
||||||
|
|
||||||
|
FormEditGreaderAccount::FormEditGreaderAccount(QWidget* parent)
|
||||||
|
: FormAccountDetails(qApp->icons()->miscIcon(QSL("google")), parent), m_details(new GreaderAccountDetails(this)) {
|
||||||
|
insertCustomTab(m_details, tr("Server setup"), 0);
|
||||||
|
activateTab(0);
|
||||||
|
|
||||||
|
connect(m_details->m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditGreaderAccount::performTest);
|
||||||
|
|
||||||
|
m_details->m_ui.m_txtUrl->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormEditGreaderAccount::apply() {
|
||||||
|
bool editing_account = !applyInternal<GreaderServiceRoot>();
|
||||||
|
|
||||||
|
account<GreaderServiceRoot>()->network()->setBaseUrl(m_details->m_ui.m_txtUrl->lineEdit()->text());
|
||||||
|
account<GreaderServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
|
||||||
|
account<GreaderServiceRoot>()->network()->setPassword(m_details->m_ui.m_txtPassword->lineEdit()->text());
|
||||||
|
account<GreaderServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
||||||
|
account<GreaderServiceRoot>()->network()->setService(m_details->service());
|
||||||
|
|
||||||
|
account<GreaderServiceRoot>()->saveAccountDataToDatabase(!editing_account);
|
||||||
|
accept();
|
||||||
|
|
||||||
|
if (editing_account) {
|
||||||
|
account<GreaderServiceRoot>()->completelyRemoveAllData();
|
||||||
|
account<GreaderServiceRoot>()->syncIn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormEditGreaderAccount::setEditableAccount(ServiceRoot* editable_account) {
|
||||||
|
FormAccountDetails::setEditableAccount(editable_account);
|
||||||
|
|
||||||
|
GreaderServiceRoot* existing_root = account<GreaderServiceRoot>();
|
||||||
|
|
||||||
|
m_details->setService(existing_root->network()->service());
|
||||||
|
m_details->m_ui.m_txtUsername->lineEdit()->setText(existing_root->network()->username());
|
||||||
|
m_details->m_ui.m_txtPassword->lineEdit()->setText(existing_root->network()->password());
|
||||||
|
m_details->m_ui.m_txtUrl->lineEdit()->setText(existing_root->network()->baseUrl());
|
||||||
|
m_details->m_ui.m_spinLimitMessages->setValue(existing_root->network()->batchSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormEditGreaderAccount::performTest() {
|
||||||
|
m_details->performTest(m_proxyDetails->proxy());
|
||||||
|
}
|
30
src/librssguard/services/greader/gui/formeditgreaderaccount.h
Executable file
30
src/librssguard/services/greader/gui/formeditgreaderaccount.h
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef FORMEDITGREADERACCOUNT_H
|
||||||
|
#define FORMEDITGREADERACCOUNT_H
|
||||||
|
|
||||||
|
#include "services/abstract/gui/formaccountdetails.h"
|
||||||
|
|
||||||
|
class GreaderAccountDetails;
|
||||||
|
class GreaderServiceRoot;
|
||||||
|
|
||||||
|
class FormEditGreaderAccount : public FormAccountDetails {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit FormEditGreaderAccount(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
virtual void apply();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void setEditableAccount(ServiceRoot* editable_account);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void performTest();
|
||||||
|
|
||||||
|
private:
|
||||||
|
GreaderAccountDetails* m_details;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FORMEDITGREADERACCOUNT_H
|
125
src/librssguard/services/greader/gui/greaderaccountdetails.cpp
Executable file
125
src/librssguard/services/greader/gui/greaderaccountdetails.cpp
Executable file
|
@ -0,0 +1,125 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "services/greader/gui/greaderaccountdetails.h"
|
||||||
|
|
||||||
|
#include "definitions/definitions.h"
|
||||||
|
#include "gui/guiutilities.h"
|
||||||
|
#include "miscellaneous/systemfactory.h"
|
||||||
|
#include "services/greader/definitions.h"
|
||||||
|
#include "services/greader/greadernetwork.h"
|
||||||
|
|
||||||
|
GreaderAccountDetails::GreaderAccountDetails(QWidget* parent) : QWidget(parent) {
|
||||||
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
|
for (auto serv : { GreaderServiceRoot::Service::FreshRss,
|
||||||
|
GreaderServiceRoot::Service::Bazqux,
|
||||||
|
GreaderServiceRoot::Service::TheOldReader }) {
|
||||||
|
m_ui.m_cmbService->addItem(GreaderNetwork::serviceToString(serv),
|
||||||
|
QVariant::fromValue(serv));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ui.m_lblTestResult->label()->setWordWrap(true);
|
||||||
|
m_ui.m_txtPassword->lineEdit()->setPlaceholderText(tr("Password for your Nextcloud account"));
|
||||||
|
m_ui.m_txtUsername->lineEdit()->setPlaceholderText(tr("Username for your Nextcloud account"));
|
||||||
|
m_ui.m_txtUrl->lineEdit()->setPlaceholderText(tr("URL of your Nextcloud server, without any API path"));
|
||||||
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
|
||||||
|
tr("No test done yet."),
|
||||||
|
tr("Here, results of connection test are shown."));
|
||||||
|
m_ui.m_lblLimitMessages->setText(
|
||||||
|
tr("Limiting number of downloaded messages per feed makes updating of feeds faster but if your feed contains "
|
||||||
|
"bigger number of messages than specified limit, then some messages might not be downloaded during feed update."));
|
||||||
|
|
||||||
|
connect(m_ui.m_spinLimitMessages, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=](int value) {
|
||||||
|
if (value <= 0) {
|
||||||
|
m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("= unlimited"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("messages"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
GuiUtilities::setLabelAsNotice(*m_ui.m_lblLimitMessages, true);
|
||||||
|
|
||||||
|
connect(m_ui.m_checkShowPassword, &QCheckBox::toggled, this, &GreaderAccountDetails::displayPassword);
|
||||||
|
connect(m_ui.m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &GreaderAccountDetails::onPasswordChanged);
|
||||||
|
connect(m_ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &GreaderAccountDetails::onUsernameChanged);
|
||||||
|
connect(m_ui.m_txtUrl->lineEdit(), &BaseLineEdit::textChanged, this, &GreaderAccountDetails::onUrlChanged);
|
||||||
|
|
||||||
|
setTabOrder(m_ui.m_cmbService, m_ui.m_txtUrl->lineEdit());
|
||||||
|
setTabOrder(m_ui.m_txtUrl->lineEdit(), m_ui.m_spinLimitMessages);
|
||||||
|
setTabOrder(m_ui.m_spinLimitMessages, m_ui.m_txtUsername->lineEdit());
|
||||||
|
setTabOrder(m_ui.m_txtUsername->lineEdit(), m_ui.m_txtPassword->lineEdit());
|
||||||
|
setTabOrder(m_ui.m_txtPassword->lineEdit(), m_ui.m_checkShowPassword);
|
||||||
|
setTabOrder(m_ui.m_checkShowPassword, m_ui.m_btnTestSetup);
|
||||||
|
|
||||||
|
onPasswordChanged();
|
||||||
|
onUsernameChanged();
|
||||||
|
onUrlChanged();
|
||||||
|
displayPassword(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
GreaderServiceRoot::Service GreaderAccountDetails::service() const {
|
||||||
|
return m_ui.m_cmbService->currentData().value<GreaderServiceRoot::Service>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderAccountDetails::setService(GreaderServiceRoot::Service service) {
|
||||||
|
m_ui.m_cmbService->setCurrentIndex(m_ui.m_cmbService->findData(QVariant::fromValue(service)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderAccountDetails::displayPassword(bool display) {
|
||||||
|
m_ui.m_txtPassword->lineEdit()->setEchoMode(display ? QLineEdit::Normal : QLineEdit::Password);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderAccountDetails::performTest(const QNetworkProxy& custom_proxy) {
|
||||||
|
GreaderNetwork factory;
|
||||||
|
|
||||||
|
factory.setUsername(m_ui.m_txtUsername->lineEdit()->text());
|
||||||
|
factory.setPassword(m_ui.m_txtPassword->lineEdit()->text());
|
||||||
|
factory.setBaseUrl(m_ui.m_txtUrl->lineEdit()->text());
|
||||||
|
|
||||||
|
NetworkResult result = factory.status(custom_proxy);
|
||||||
|
|
||||||
|
if (result.first != QNetworkReply::NetworkError::NoError) {
|
||||||
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(result.first)),
|
||||||
|
tr("Network error, have you entered correct Nextcloud endpoint and password?"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Unspecified error, did you enter correct URL?"),
|
||||||
|
tr("Unspecified error, did you enter correct URL?"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderAccountDetails::onUsernameChanged() {
|
||||||
|
const QString username = m_ui.m_txtUsername->lineEdit()->text();
|
||||||
|
|
||||||
|
if (username.isEmpty()) {
|
||||||
|
m_ui.m_txtUsername->setStatus(WidgetWithStatus::StatusType::Error, tr("Username cannot be empty."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_txtUsername->setStatus(WidgetWithStatus::StatusType::Ok, tr("Username is okay."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderAccountDetails::onPasswordChanged() {
|
||||||
|
const QString password = m_ui.m_txtPassword->lineEdit()->text();
|
||||||
|
|
||||||
|
if (password.isEmpty()) {
|
||||||
|
m_ui.m_txtPassword->setStatus(WidgetWithStatus::StatusType::Error, tr("Password cannot be empty."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_txtPassword->setStatus(WidgetWithStatus::StatusType::Ok, tr("Password is okay."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GreaderAccountDetails::onUrlChanged() {
|
||||||
|
const QString url = m_ui.m_txtUrl->lineEdit()->text();
|
||||||
|
|
||||||
|
if (url.isEmpty()) {
|
||||||
|
m_ui.m_txtUrl->setStatus(WidgetWithStatus::StatusType::Error, tr("URL cannot be empty."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_txtUrl->setStatus(WidgetWithStatus::StatusType::Ok, tr("URL is okay."));
|
||||||
|
}
|
||||||
|
}
|
36
src/librssguard/services/greader/gui/greaderaccountdetails.h
Executable file
36
src/librssguard/services/greader/gui/greaderaccountdetails.h
Executable file
|
@ -0,0 +1,36 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef GREADERACCOUNTDETAILS_H
|
||||||
|
#define GREADERACCOUNTDETAILS_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "ui_greaderaccountdetails.h"
|
||||||
|
|
||||||
|
#include "services/greader/greaderserviceroot.h"
|
||||||
|
|
||||||
|
#include <QNetworkProxy>
|
||||||
|
|
||||||
|
class GreaderAccountDetails : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
friend class FormEditGreaderAccount;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit GreaderAccountDetails(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
GreaderServiceRoot::Service service() const;
|
||||||
|
void setService(GreaderServiceRoot::Service service);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void displayPassword(bool display);
|
||||||
|
void performTest(const QNetworkProxy& custom_proxy);
|
||||||
|
void onUsernameChanged();
|
||||||
|
void onPasswordChanged();
|
||||||
|
void onUrlChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::GreaderAccountDetails m_ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GREADERACCOUNTDETAILS_H
|
188
src/librssguard/services/greader/gui/greaderaccountdetails.ui
Executable file
188
src/librssguard/services/greader/gui/greaderaccountdetails.ui
Executable file
|
@ -0,0 +1,188 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>GreaderAccountDetails</class>
|
||||||
|
<widget class="QWidget" name="GreaderAccountDetails">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>430</width>
|
||||||
|
<height>390</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Service</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="m_cmbService"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="m_lblTitle">
|
||||||
|
<property name="text">
|
||||||
|
<string>URL</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_txtUrl</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Only download newest X messages per feed</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_spinLimitMessages</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="m_spinLimitMessages">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> = unlimited</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1000</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="m_lblLimitMessages">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0" colspan="2">
|
||||||
|
<widget class="QGroupBox" name="m_gbAuthentication">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Authentication</string>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Username</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_txtUsername</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Password</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_txtPassword</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="LineEditWithStatus" name="m_txtPassword" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="LineEditWithStatus" name="m_txtUsername" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="m_checkShowPassword">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show password</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="m_btnTestSetup">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Test setup</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="LabelWithStatus" name="m_lblTestResult" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="layoutDirection">
|
||||||
|
<enum>Qt::RightToLeft</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0" colspan="2">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>409</width>
|
||||||
|
<height>60</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LineEditWithStatus</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>lineeditwithstatus.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LabelWithStatus</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>labelwithstatus.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_spinLimitMessages</tabstop>
|
||||||
|
<tabstop>m_checkShowPassword</tabstop>
|
||||||
|
<tabstop>m_btnTestSetup</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Add table
Reference in a new issue