diff --git a/resources/rssguard.qrc b/resources/rssguard.qrc index 9416e1a28..559a134ee 100755 --- a/resources/rssguard.qrc +++ b/resources/rssguard.qrc @@ -4,26 +4,6 @@ text/COPYING_BSD text/COPYING_GNU_GPL text/COPYING_GNU_GPL_HTML - sql/db_init_mysql.sql - sql/db_init_sqlite.sql - sql/db_update_mysql_1_2.sql - sql/db_update_mysql_2_3.sql - sql/db_update_mysql_3_4.sql - sql/db_update_mysql_4_5.sql - sql/db_update_mysql_5_6.sql - sql/db_update_mysql_6_7.sql - sql/db_update_mysql_7_8.sql - sql/db_update_mysql_8_9.sql - sql/db_update_mysql_9_10.sql - sql/db_update_sqlite_1_2.sql - sql/db_update_sqlite_2_3.sql - sql/db_update_sqlite_3_4.sql - sql/db_update_sqlite_4_5.sql - sql/db_update_sqlite_5_6.sql - sql/db_update_sqlite_6_7.sql - sql/db_update_sqlite_7_8.sql - sql/db_update_sqlite_8_9.sql - sql/db_update_sqlite_9_10.sql graphics/rssguard.ico graphics/rssguard.png graphics/rssguard_plain.png diff --git a/resources/scripts/.travis-install-linux.sh b/resources/scripts/.travis-install-linux.sh index 618debe3b..aabfb1818 100755 --- a/resources/scripts/.travis-install-linux.sh +++ b/resources/scripts/.travis-install-linux.sh @@ -28,9 +28,9 @@ set -- R*.AppImage imagename="$1" if [ "$USE_WEBENGINE" = true ]; then - imagenamenospace="rssguard-$(git rev-parse --short HEAD)-linux.AppImage" + imagenamenospace="rssguard-$(git rev-parse --short HEAD)-linux64.AppImage" else - imagenamenospace="rssguard-$(git rev-parse --short HEAD)-nowebengine-linux.AppImage" + imagenamenospace="rssguard-$(git rev-parse --short HEAD)-nowebengine-linux64.AppImage" fi echo "File to upload: $imagename" diff --git a/resources/sql.qrc b/resources/sql.qrc new file mode 100755 index 000000000..c41153c35 --- /dev/null +++ b/resources/sql.qrc @@ -0,0 +1,26 @@ + + + sql/db_init_mysql.sql + sql/db_init_sqlite.sql + sql/db_update_mysql_1_2.sql + sql/db_update_mysql_2_3.sql + sql/db_update_mysql_3_4.sql + sql/db_update_mysql_4_5.sql + sql/db_update_mysql_5_6.sql + sql/db_update_mysql_6_7.sql + sql/db_update_mysql_7_8.sql + sql/db_update_mysql_8_9.sql + sql/db_update_mysql_9_10.sql + sql/db_update_mysql_10_11.sql + sql/db_update_sqlite_1_2.sql + sql/db_update_sqlite_2_3.sql + sql/db_update_sqlite_3_4.sql + sql/db_update_sqlite_4_5.sql + sql/db_update_sqlite_5_6.sql + sql/db_update_sqlite_6_7.sql + sql/db_update_sqlite_7_8.sql + sql/db_update_sqlite_8_9.sql + sql/db_update_sqlite_9_10.sql + sql/db_update_sqlite_10_11.sql + + \ No newline at end of file diff --git a/resources/sql/db_init_mysql.sql b/resources/sql/db_init_mysql.sql index 0fe05913a..6d965be04 100644 --- a/resources/sql/db_init_mysql.sql +++ b/resources/sql/db_init_mysql.sql @@ -55,6 +55,18 @@ CREATE TABLE IF NOT EXISTS InoreaderAccounts ( FOREIGN KEY (id) REFERENCES Accounts (id) ); -- ! +CREATE TABLE IF NOT EXISTS GmailAccounts ( + id INTEGER, + username TEXT NOT NULL, + app_id TEXT, + app_key TEXT, + redirect_url TEXT, + refresh_token TEXT, + msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1), + + FOREIGN KEY (id) REFERENCES Accounts (id) +); +-- ! DROP TABLE IF EXISTS Categories; -- ! CREATE TABLE IF NOT EXISTS Categories ( diff --git a/resources/sql/db_init_sqlite.sql b/resources/sql/db_init_sqlite.sql index ca8378050..dd73d3d09 100644 --- a/resources/sql/db_init_sqlite.sql +++ b/resources/sql/db_init_sqlite.sql @@ -49,6 +49,18 @@ CREATE TABLE IF NOT EXISTS InoreaderAccounts ( FOREIGN KEY (id) REFERENCES Accounts (id) ); -- ! +CREATE TABLE IF NOT EXISTS GmailAccounts ( + id INTEGER, + username TEXT NOT NULL, + app_id TEXT, + app_key TEXT, + redirect_url TEXT, + refresh_token TEXT, + msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1), + + FOREIGN KEY (id) REFERENCES Accounts (id) +); +-- ! DROP TABLE IF EXISTS Categories; -- ! CREATE TABLE IF NOT EXISTS Categories ( diff --git a/resources/sql/db_update_mysql_10_11.sql b/resources/sql/db_update_mysql_10_11.sql new file mode 100755 index 000000000..90521b49b --- /dev/null +++ b/resources/sql/db_update_mysql_10_11.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS GmailAccounts ( + id INTEGER, + username TEXT NOT NULL, + app_id TEXT, + app_key TEXT, + redirect_url TEXT, + refresh_token TEXT, + msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1), + + FOREIGN KEY (id) REFERENCES Accounts (id) +); +-- ! +UPDATE Information SET inf_value = '11' WHERE inf_key = 'schema_version'; \ No newline at end of file diff --git a/resources/sql/db_update_sqlite_10_11.sql b/resources/sql/db_update_sqlite_10_11.sql new file mode 100755 index 000000000..ef6a5048e --- /dev/null +++ b/resources/sql/db_update_sqlite_10_11.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS GmailAccounts ( + id INTEGER, + username TEXT NOT NULL, + app_id TEXT, + app_key TEXT, + redirect_url TEXT, + refresh_token TEXT, + msg_limit INTEGER NOT NULL DEFAULT -1 CHECK (msg_limit >= -1), + + FOREIGN KEY (id) REFERENCES Accounts (id) +); +-- ! +UPDATE Information SET inf_value = '11' WHERE inf_key = 'schema_version'; \ No newline at end of file diff --git a/rssguard.pro b/rssguard.pro index c1461bf4e..ee3588bd5 100755 --- a/rssguard.pro +++ b/rssguard.pro @@ -208,7 +208,9 @@ win32 { QMAKE_TARGET_PRODUCT = $$APP_NAME } -RESOURCES += resources/rssguard.qrc +CONFIG *= resources_big +RESOURCES += resources/sql.qrc \ + resources/rssguard.qrc HEADERS += src/core/feeddownloader.h \ src/core/feedsmodel.h \ diff --git a/src/definitions/definitions.h b/src/definitions/definitions.h index 38d71afff..622a2b4ed 100755 --- a/src/definitions/definitions.h +++ b/src/definitions/definitions.h @@ -128,7 +128,7 @@ #define APP_DB_SQLITE_FILE "database.db" // Keep this in sync with schema versions declared in SQL initialization code. -#define APP_DB_SCHEMA_VERSION "10" +#define APP_DB_SCHEMA_VERSION "11" #define APP_DB_UPDATE_FILE_PATTERN "db_update_%1_%2_%3.sql" #define APP_DB_COMMENT_SPLIT "-- !\n" #define APP_DB_NAME_PLACEHOLDER "##" diff --git a/src/main.cpp b/src/main.cpp index 9aa4d2977..8d4c334b2 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -175,22 +175,21 @@ int main(int argc, char* argv[]) { qApp->showPolls(); qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates(); -/* - OAuth2Service* srv = new OAuth2Service( + 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) { + srv->setRefreshToken("1/RKE3oohSoTHE54L0IPflvndK-DcI7l0of3lVdLa1Q9Q"); + QObject::connect(srv, &OAuth2Service::authCodeObtained, [](QString auth_code) { int a = 5; - }); - QObject::connect(srv, &OAuth2Service::authFailed, []() { + }); + QObject::connect(srv, &OAuth2Service::authFailed, []() { int a = 5; - }); - QObject::connect(srv, &OAuth2Service::tokensReceived, [srv](QString acc, QString ref, int exp) { + }); + QObject::connect(srv, &OAuth2Service::tokensReceived, [srv](QString acc, QString ref, int exp) { QHttpMultiPart* multi = new QHttpMultiPart(srv); QHttpPart p1; @@ -222,11 +221,11 @@ int main(int argc, char* argv[]) { }); int a = 5; - }); - QObject::connect(srv, &OAuth2Service::tokensRetrieveError, [](QString err, QString desc) { + }); + QObject::connect(srv, &OAuth2Service::tokensRetrieveError, [](QString err, QString desc) { int a = 5; - }); - srv->login();*/ + }); + srv->login(); // Enter global event loop. return Application::exec(); diff --git a/src/miscellaneous/databasequeries.cpp b/src/miscellaneous/databasequeries.cpp index 1bfba9bf5..76e556431 100755 --- a/src/miscellaneous/databasequeries.cpp +++ b/src/miscellaneous/databasequeries.cpp @@ -476,7 +476,8 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, // The two message are the "same" if: // 1) they belong to the same feed AND, // 2) they have same URL AND, - // 3) they have same AUTHOR. + // 3) they have same AUTHOR AND, + // 4) they have same title. query_select_with_url.setForwardOnly(true); query_select_with_url.prepare("SELECT id, date_created, is_read, is_important, contents FROM Messages " "WHERE feed = :feed AND title = :title AND url = :url AND author = :author AND account_id = :account_id;"); @@ -527,7 +528,7 @@ int DatabaseQueries::updateMessages(QSqlDatabase db, QString contents_existing_message; if (message.m_customId.isEmpty()) { - // We need to recognize existing messages according URL & AUTHOR. + // We need to recognize existing messages according URL & AUTHOR & TITLE. // NOTE: This particularly concerns messages from standard account. query_select_with_url.bindValue(QSL(":feed"), feed_custom_id); query_select_with_url.bindValue(QSL(":title"), message.m_title); @@ -1491,6 +1492,42 @@ Assignment DatabaseQueries::getCategories(QSqlDatabase db, int account_id, bool* } #if defined(USE_WEBENGINE) +QList DatabaseQueries::getGmailAccounts(QSqlDatabase db, bool* ok) { + QSqlQuery query(db); + + QList roots; + + if (query.exec("SELECT * FROM GmailAccounts;")) { + while (query.next()) { + /*GmailServiceRoot* root = new GmailServiceRoot(nullptr); + + root->setId(query.value(0).toInt()); + root->setAccountId(query.value(0).toInt()); + root->network()->setUsername(query.value(1).toString()); + root->network()->oauth()->setClientId(query.value(2).toString()); + root->network()->oauth()->setClientSecret(query.value(3).toString()); + root->network()->oauth()->setRedirectUrl(query.value(4).toString()); + root->network()->oauth()->setRefreshToken(query.value(5).toString()); + root->network()->setBatchSize(query.value(6).toInt()); + root->updateTitle(); + roots.append(root);*/ + } + + if (ok != nullptr) { + *ok = true; + } + } + else { + qWarning("Gmail: Getting list of activated accounts failed: '%s'.", qPrintable(query.lastError().text())); + + if (ok != nullptr) { + *ok = false; + } + } + + return roots; +} + bool DatabaseQueries::deleteInoreaderAccount(QSqlDatabase db, int account_id) { QSqlQuery q(db); diff --git a/src/miscellaneous/databasequeries.h b/src/miscellaneous/databasequeries.h index d7a1a716d..d53bb25cf 100755 --- a/src/miscellaneous/databasequeries.h +++ b/src/miscellaneous/databasequeries.h @@ -78,8 +78,12 @@ class DatabaseQueries { int auto_update_interval); static Assignment getCategories(QSqlDatabase db, int account_id, bool* ok = nullptr); - // Inoreader account. #if defined(USE_WEBENGINE) + + // Gmail account. + static QList getGmailAccounts(QSqlDatabase db, bool* ok = nullptr); + + // Inoreader account. static bool deleteInoreaderAccount(QSqlDatabase db, int account_id); static Assignment getInoreaderFeeds(QSqlDatabase db, int account_id, bool* ok = nullptr); static bool storeNewInoreaderTokens(QSqlDatabase db, const QString& refresh_token, int account_id); diff --git a/src/services/gmail/gmailentrypoint.cpp b/src/services/gmail/gmailentrypoint.cpp index 02199a9ff..e2e8e621d 100755 --- a/src/services/gmail/gmailentrypoint.cpp +++ b/src/services/gmail/gmailentrypoint.cpp @@ -33,7 +33,7 @@ QList GmailEntryPoint::initializeSubtree() const { return QList(); - //return DatabaseQueries::getInoreaderAccounts(database); + return DatabaseQueries::getGmailAccounts(database); } bool GmailEntryPoint::isSingleInstanceService() const {