From 1118d278d6afe8772af8e9e79f2859e586ea5ae0 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 26 Feb 2021 12:55:15 +0100 Subject: [PATCH] massive cleanups of redundant code --- .../miscellaneous/databasequeries.cpp | 483 +----------------- .../miscellaneous/databasequeries.h | 65 --- .../abstract/gui/formaccountdetails.cpp | 9 - .../services/abstract/serviceroot.cpp | 10 + .../services/abstract/serviceroot.h | 2 + .../services/feedly/feedlyserviceroot.cpp | 62 +-- .../services/feedly/feedlyserviceroot.h | 3 - .../feedly/gui/formeditfeedlyaccount.cpp | 2 +- .../services/gmail/gmailserviceroot.cpp | 46 +- .../services/gmail/gmailserviceroot.h | 4 - .../gmail/gui/formeditgmailaccount.cpp | 2 +- .../services/greader/greaderserviceroot.cpp | 39 +- .../services/greader/greaderserviceroot.h | 3 - .../greader/gui/formeditgreaderaccount.cpp | 2 +- .../gui/formeditinoreaderaccount.cpp | 2 +- .../inoreader/inoreaderserviceroot.cpp | 46 +- .../services/inoreader/inoreaderserviceroot.h | 4 - .../owncloud/gui/formeditowncloudaccount.cpp | 2 +- .../services/owncloud/owncloudserviceroot.cpp | 40 +- .../services/owncloud/owncloudserviceroot.h | 3 - .../standardfeedsimportexportmodel.cpp | 8 +- .../services/tt-rss/ttrssserviceroot.cpp | 23 - .../services/tt-rss/ttrssserviceroot.h | 3 - 23 files changed, 38 insertions(+), 825 deletions(-) diff --git a/src/librssguard/miscellaneous/databasequeries.cpp b/src/librssguard/miscellaneous/databasequeries.cpp index 1c4d69941..427884b97 100755 --- a/src/librssguard/miscellaneous/databasequeries.cpp +++ b/src/librssguard/miscellaneous/databasequeries.cpp @@ -1658,201 +1658,6 @@ QStringList DatabaseQueries::customIdsOfMessagesFromFeed(const QSqlDatabase& db, return ids; } -void DatabaseQueries::fillBaseAccountData(const QSqlDatabase& db, ServiceRoot* account, bool* ok) { - QSqlQuery query(db); - - query.prepare(QSL("SELECT * FROM Accounts WHERE id = :id;")); - query.bindValue(QSL(":id"), account->accountId()); - - bool res = query.exec() && query.next(); - - if (res) { - QNetworkProxy proxy(QNetworkProxy::ProxyType(query.value(QSL("proxy_type")).toInt()), - query.value(QSL("proxy_host")).toString(), - query.value(QSL("proxy_port")).toInt(), - query.value(QSL("proxy_username")).toString(), - TextFactory::decrypt(query.value(QSL("proxy_password")).toString())); - - account->setNetworkProxy(proxy); - } - - if (ok != nullptr) { - *ok = res; - } -} - -bool DatabaseQueries::deleteOwnCloudAccount(const QSqlDatabase& db, int account_id) { - QSqlQuery q(db); - - q.setForwardOnly(true); - q.prepare(QSL("DELETE FROM OwnCloudAccounts WHERE id = :id;")); - q.bindValue(QSL(":id"), account_id); - return q.exec(); -} - -bool DatabaseQueries::overwriteOwnCloudAccount(const QSqlDatabase& db, const QString& username, const QString& password, - const QString& url, bool force_server_side_feed_update, int batch_size, - bool download_only_unread_messages, int account_id) { - QSqlQuery query(db); - - query.prepare("UPDATE OwnCloudAccounts " - "SET username = :username, password = :password, url = :url, force_update = :force_update, " - "msg_limit = :msg_limit, update_only_unread = :update_only_unread " - "WHERE id = :id;"); - query.bindValue(QSL(":username"), username); - query.bindValue(QSL(":password"), TextFactory::encrypt(password)); - query.bindValue(QSL(":url"), url); - query.bindValue(QSL(":force_update"), force_server_side_feed_update ? 1 : 0); - query.bindValue(QSL(":id"), account_id); - query.bindValue(QSL(":msg_limit"), batch_size <= 0 ? OWNCLOUD_UNLIMITED_BATCH_SIZE : batch_size); - query.bindValue(QSL(":update_only_unread"), download_only_unread_messages ? 1 : 0); - - if (query.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_NEXTCLOUD - << "Updating account failed: '" - << query.lastError().text() - << "'."; - return false; - } -} - -bool DatabaseQueries::createFeedlyAccount(const QSqlDatabase& db, const QString& username, - const QString& developer_access_token, const QString& refresh_token, - int batch_size, bool download_only_unread_messages, - int account_id) { - QSqlQuery q(db); - - q.prepare("INSERT INTO FeedlyAccounts (id, username, developer_access_token, refresh_token, msg_limit, update_only_unread) " - "VALUES (:id, :username, :developer_access_token, :refresh_token, :msg_limit, :update_only_unread);"); - q.bindValue(QSL(":id"), account_id); - q.bindValue(QSL(":username"), username); - q.bindValue(QSL(":developer_access_token"), developer_access_token); - q.bindValue(QSL(":refresh_token"), refresh_token); - q.bindValue(QSL(":msg_limit"), batch_size <= 0 ? FEEDLY_UNLIMITED_BATCH_SIZE : batch_size); - q.bindValue(QSL(":update_only_unread"), download_only_unread_messages ? 1 : 0); - - if (q.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_FEEDLY - << "Inserting of new account failed:" - << QUOTE_W_SPACE_DOT(q.lastError().text()); - return false; - } -} - -bool DatabaseQueries::overwriteFeedlyAccount(const QSqlDatabase& db, const QString& username, - const QString& developer_access_token, const QString& refresh_token, - int batch_size, bool download_only_unread_messages, - int account_id) { - QSqlQuery query(db); - - query.prepare("UPDATE FeedlyAccounts " - "SET username = :username, developer_access_token = :developer_access_token, " - "refresh_token = :refresh_token, msg_limit = :msg_limit, " - "update_only_unread = :update_only_unread " - "WHERE id = :id;"); - query.bindValue(QSL(":id"), account_id); - query.bindValue(QSL(":username"), username); - query.bindValue(QSL(":developer_access_token"), developer_access_token); - query.bindValue(QSL(":refresh_token"), refresh_token); - query.bindValue(QSL(":msg_limit"), batch_size <= 0 ? FEEDLY_UNLIMITED_BATCH_SIZE : batch_size); - query.bindValue(QSL(":update_only_unread"), download_only_unread_messages ? 1 : 0); - - if (query.exec()) { - return true; - } - else { - qCriticalNN << LOGSEC_FEEDLY << "Updating account failed:" << QUOTE_W_SPACE_DOT(query.lastError().text()); - return false; - } -} - -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::overwriteGreaderAccount(const QSqlDatabase& db, const QString& username, const QString& password, - GreaderServiceRoot::Service service, const QString& url, - int batch_size, int account_id) { - QSqlQuery query(db); - - query.prepare("UPDATE GoogleReaderApiAccounts " - "SET username = :username, password = :password, url = :url, type = :service, 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(":service"), int(service)); - 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::createOwnCloudAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, - const QString& password, const QString& url, - bool force_server_side_feed_update, - bool download_only_unread_messages, int batch_size) { - QSqlQuery q(db); - - q.prepare("INSERT INTO OwnCloudAccounts (id, username, password, url, force_update, msg_limit, update_only_unread) " - "VALUES (:id, :username, :password, :url, :force_update, :msg_limit, :update_only_unread);"); - q.bindValue(QSL(":id"), id_to_assign); - q.bindValue(QSL(":username"), username); - q.bindValue(QSL(":password"), TextFactory::encrypt(password)); - q.bindValue(QSL(":url"), url); - q.bindValue(QSL(":force_update"), force_server_side_feed_update ? 1 : 0); - q.bindValue(QSL(":msg_limit"), batch_size <= 0 ? OWNCLOUD_UNLIMITED_BATCH_SIZE : batch_size); - q.bindValue(QSL(":update_only_unread"), download_only_unread_messages ? 1 : 0); - - if (q.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_NEXTCLOUD - << "Inserting of new account failed: '" - << q.lastError().text() - << "'."; - return false; - } -} - void DatabaseQueries::createOverwriteAccount(const QSqlDatabase& db, ServiceRoot* account) { QSqlQuery q(db); @@ -1910,70 +1715,6 @@ void DatabaseQueries::createOverwriteAccount(const QSqlDatabase& db, ServiceRoot } } -int DatabaseQueries::createBaseAccount(const QSqlDatabase& db, const QString& code, bool* ok) { - QSqlQuery q(db); - - // First obtain the ID, which can be assigned to this new account. - if (!q.exec("SELECT max(id) FROM Accounts;") || !q.next()) { - qWarning("Getting max ID from Accounts table failed: '%s'.", qPrintable(q.lastError().text())); - - if (ok != nullptr) { - *ok = false; - } - - return 0; - } - - int id_to_assign = q.value(0).toInt() + 1; - - q.prepare(QSL("INSERT INTO Accounts (id, type) VALUES (:id, :type);")); - q.bindValue(QSL(":id"), id_to_assign); - q.bindValue(QSL(":type"), code); - - if (q.exec()) { - if (ok != nullptr) { - *ok = true; - } - - return id_to_assign; - } - else { - if (ok != nullptr) { - *ok = false; - } - - qWarningNN << LOGSEC_DB - << "Inserting of new account failed: '" - << q.lastError().text() - << "'."; - return 0; - } -} - -void DatabaseQueries::editBaseAccount(const QSqlDatabase& db, ServiceRoot* account, bool* ok) { - auto proxy = account->networkProxy(); - QSqlQuery q(db); - - q.setForwardOnly(true); - - q.prepare(QSL("UPDATE Accounts " - "SET proxy_type = :proxy_type, proxy_host = :proxy_host, proxy_port = :proxy_port, " - " proxy_username = :proxy_username, proxy_password = :proxy_password " - "WHERE id = :id")); - q.bindValue(QSL(":proxy_type"), proxy.type()); - q.bindValue(QSL(":proxy_host"), proxy.hostName()); - q.bindValue(QSL(":proxy_port"), proxy.port()); - q.bindValue(QSL(":proxy_username"), proxy.user()); - q.bindValue(QSL(":proxy_password"), TextFactory::encrypt(proxy.password())); - q.bindValue(QSL(":id"), account->accountId()); - - bool res = q.exec(); - - if (ok != nullptr) { - *ok = res; - } -} - bool DatabaseQueries::deleteFeed(const QSqlDatabase& db, int feed_custom_id, int account_id) { QSqlQuery q(db); @@ -2410,98 +2151,6 @@ void DatabaseQueries::removeMessageFilterFromFeed(const QSqlDatabase& db, const } } -bool DatabaseQueries::deleteFeedlyAccount(const QSqlDatabase& db, int account_id) { - QSqlQuery q(db); - - q.setForwardOnly(true); - q.prepare(QSL("DELETE FROM FeedlyAccounts WHERE id = :id;")); - q.bindValue(QSL(":id"), account_id); - return q.exec(); -} - -bool DatabaseQueries::deleteGreaderAccount(const QSqlDatabase& db, int account_id) { - QSqlQuery q(db); - - q.setForwardOnly(true); - q.prepare(QSL("DELETE FROM GoogleReaderApiAccounts WHERE id = :id;")); - q.bindValue(QSL(":id"), account_id); - return q.exec(); -} - -bool DatabaseQueries::deleteTtRssAccount(const QSqlDatabase& db, int account_id) { - QSqlQuery q(db); - - q.setForwardOnly(true); - q.prepare(QSL("DELETE FROM TtRssAccounts WHERE id = :id;")); - q.bindValue(QSL(":id"), account_id); - - return q.exec(); -} - -bool DatabaseQueries::overwriteTtRssAccount(const QSqlDatabase& db, const QString& username, - const QString& password, bool auth_protected, - const QString& auth_username, const QString& auth_password, - const QString& url, bool force_server_side_feed_update, - bool download_only_unread_messages, int account_id) { - QSqlQuery q(db); - - q.prepare("UPDATE TtRssAccounts " - "SET username = :username, password = :password, url = :url, auth_protected = :auth_protected, " - "auth_username = :auth_username, auth_password = :auth_password, force_update = :force_update, " - "update_only_unread = :update_only_unread " - "WHERE id = :id;"); - q.bindValue(QSL(":username"), username); - q.bindValue(QSL(":password"), TextFactory::encrypt(password)); - q.bindValue(QSL(":url"), url); - q.bindValue(QSL(":auth_protected"), auth_protected ? 1 : 0); - q.bindValue(QSL(":auth_username"), auth_username); - q.bindValue(QSL(":auth_password"), TextFactory::encrypt(auth_password)); - q.bindValue(QSL(":force_update"), force_server_side_feed_update ? 1 : 0); - q.bindValue(QSL(":update_only_unread"), download_only_unread_messages ? 1 : 0); - q.bindValue(QSL(":id"), account_id); - - if (q.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_TTRSS - << "Updating account failed: '" - << q.lastError().text() - << "'."; - return false; - } -} - -bool DatabaseQueries::createTtRssAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, - const QString& password, bool auth_protected, const QString& auth_username, - const QString& auth_password, const QString& url, - bool force_server_side_feed_update, bool download_only_unread_messages) { - QSqlQuery q(db); - - q.prepare("INSERT INTO TtRssAccounts (id, username, password, auth_protected, auth_username, auth_password, url, force_update, update_only_unread) " - "VALUES (:id, :username, :password, :auth_protected, :auth_username, :auth_password, :url, :force_update, :update_only_unread);"); - q.bindValue(QSL(":id"), id_to_assign); - q.bindValue(QSL(":username"), username); - q.bindValue(QSL(":password"), TextFactory::encrypt(password)); - q.bindValue(QSL(":auth_protected"), auth_protected ? 1 : 0); - q.bindValue(QSL(":auth_username"), auth_username); - q.bindValue(QSL(":auth_password"), TextFactory::encrypt(auth_password)); - q.bindValue(QSL(":url"), url); - q.bindValue(QSL(":force_update"), force_server_side_feed_update ? 1 : 0); - q.bindValue(QSL(":update_only_unread"), download_only_unread_messages ? 1 : 0); - - if (q.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_TTRSS - << "Saving of new account failed: '" - << q.lastError().text() - << "'."; - return false; - } -} - QStringList DatabaseQueries::getAllRecipients(const QSqlDatabase& db, int account_id) { QSqlQuery query(db); QStringList rec; @@ -2524,28 +2173,12 @@ QStringList DatabaseQueries::getAllRecipients(const QSqlDatabase& db, int accoun return rec; } -bool DatabaseQueries::deleteGmailAccount(const QSqlDatabase& db, int account_id) { - QSqlQuery q(db); - - q.setForwardOnly(true); - q.prepare(QSL("DELETE FROM GmailAccounts WHERE id = :id;")); - q.bindValue(QSL(":id"), account_id); - return q.exec(); -} - -bool DatabaseQueries::deleteInoreaderAccount(const QSqlDatabase& db, int account_id) { - QSqlQuery q(db); - - q.setForwardOnly(true); - q.prepare(QSL("DELETE FROM InoreaderAccounts WHERE id = :id;")); - q.bindValue(QSL(":id"), account_id); - return q.exec(); -} - bool DatabaseQueries::storeNewOauthTokens(const QSqlDatabase& db, const QString& table_name, const QString& refresh_token, int account_id) { QSqlQuery query(db); + // TODO:, není funkční + query.prepare(QSL("UPDATE %1 " "SET refresh_token = :refresh_token " "WHERE id = :id;").arg(table_name)); @@ -2562,118 +2195,6 @@ bool DatabaseQueries::storeNewOauthTokens(const QSqlDatabase& db, const QString& } } -bool DatabaseQueries::overwriteGmailAccount(const QSqlDatabase& db, const QString& username, const QString& app_id, - const QString& app_key, const QString& redirect_url, - const QString& refresh_token, int batch_size, int account_id) { - QSqlQuery query(db); - - query.prepare("UPDATE GmailAccounts " - "SET username = :username, app_id = :app_id, app_key = :app_key, " - "redirect_url = :redirect_url, refresh_token = :refresh_token , msg_limit = :msg_limit " - "WHERE id = :id;"); - query.bindValue(QSL(":username"), username); - query.bindValue(QSL(":app_id"), app_id); - query.bindValue(QSL(":app_key"), app_key); - query.bindValue(QSL(":redirect_url"), redirect_url); - query.bindValue(QSL(":refresh_token"), refresh_token); - query.bindValue(QSL(":id"), account_id); - query.bindValue(QSL(":msg_limit"), batch_size <= 0 ? GMAIL_DEFAULT_BATCH_SIZE : batch_size); - - if (query.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_GMAIL - << "Updating account failed: '" - << query.lastError().text() - << "'."; - return false; - } -} - -bool DatabaseQueries::createGmailAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, - const QString& app_id, const QString& app_key, const QString& redirect_url, - const QString& refresh_token, int batch_size) { - QSqlQuery q(db); - - q.prepare("INSERT INTO GmailAccounts (id, username, app_id, app_key, redirect_url, refresh_token, msg_limit) " - "VALUES (:id, :username, :app_id, :app_key, :redirect_url, :refresh_token, :msg_limit);"); - q.bindValue(QSL(":id"), id_to_assign); - q.bindValue(QSL(":username"), username); - q.bindValue(QSL(":app_id"), app_id); - q.bindValue(QSL(":app_key"), app_key); - q.bindValue(QSL(":redirect_url"), redirect_url); - q.bindValue(QSL(":refresh_token"), refresh_token); - q.bindValue(QSL(":msg_limit"), batch_size <= 0 ? GMAIL_DEFAULT_BATCH_SIZE : batch_size); - - if (q.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_GMAIL - << "Inserting of new account failed: '" - << q.lastError().text() - << "'."; - return false; - } -} - -bool DatabaseQueries::overwriteInoreaderAccount(const QSqlDatabase& db, const QString& username, const QString& app_id, - const QString& app_key, const QString& redirect_url, - const QString& refresh_token, int batch_size, int account_id) { - QSqlQuery query(db); - - query.prepare("UPDATE InoreaderAccounts " - "SET username = :username, app_id = :app_id, app_key = :app_key, " - "redirect_url = :redirect_url, refresh_token = :refresh_token , msg_limit = :msg_limit " - "WHERE id = :id;"); - query.bindValue(QSL(":username"), username); - query.bindValue(QSL(":app_id"), app_id); - query.bindValue(QSL(":app_key"), app_key); - query.bindValue(QSL(":redirect_url"), redirect_url); - query.bindValue(QSL(":refresh_token"), refresh_token); - query.bindValue(QSL(":id"), account_id); - query.bindValue(QSL(":msg_limit"), batch_size <= 0 ? INOREADER_DEFAULT_BATCH_SIZE : batch_size); - - if (query.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_INOREADER - << "Updating account failed: '" - << query.lastError().text() - << "'."; - return false; - } -} - -bool DatabaseQueries::createInoreaderAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, - const QString& app_id, const QString& app_key, const QString& redirect_url, - const QString& refresh_token, int batch_size) { - QSqlQuery q(db); - - q.prepare("INSERT INTO InoreaderAccounts (id, username, app_id, app_key, redirect_url, refresh_token, msg_limit) " - "VALUES (:id, :username, :app_id, :app_key, :redirect_url, :refresh_token, :msg_limit);"); - q.bindValue(QSL(":id"), id_to_assign); - q.bindValue(QSL(":username"), username); - q.bindValue(QSL(":app_id"), app_id); - q.bindValue(QSL(":app_key"), app_key); - q.bindValue(QSL(":redirect_url"), redirect_url); - q.bindValue(QSL(":refresh_token"), refresh_token); - q.bindValue(QSL(":msg_limit"), batch_size <= 0 ? INOREADER_DEFAULT_BATCH_SIZE : batch_size); - - if (q.exec()) { - return true; - } - else { - qWarningNN << LOGSEC_INOREADER - << "Inserting of new account failed: '" - << q.lastError().text() - << "'."; - return false; - } -} - QString DatabaseQueries::unnulifyString(const QString& str) { return str.isNull() ? "" : str; } diff --git a/src/librssguard/miscellaneous/databasequeries.h b/src/librssguard/miscellaneous/databasequeries.h index 7f300c719..4e04b2f8e 100644 --- a/src/librssguard/miscellaneous/databasequeries.h +++ b/src/librssguard/miscellaneous/databasequeries.h @@ -94,10 +94,7 @@ class DatabaseQueries { static QList getAccounts(const QSqlDatabase& db, const QString& code, bool* ok = nullptr); static bool storeNewOauthTokens(const QSqlDatabase& db, const QString& table_name, const QString& refresh_token, int account_id); - static void fillBaseAccountData(const QSqlDatabase& db, ServiceRoot* account, bool* ok = nullptr); static void createOverwriteAccount(const QSqlDatabase& db, ServiceRoot* account); - static int createBaseAccount(const QSqlDatabase& db, const QString& code, bool* ok = nullptr); - static void editBaseAccount(const QSqlDatabase& db, ServiceRoot* account, bool* ok = nullptr); static int updateMessages(QSqlDatabase db, const QList& messages, const QString& feed_custom_id, int account_id, const QString& url, bool force_update, bool* any_message_changed, bool* ok = nullptr); static bool deleteAccount(const QSqlDatabase& db, int account_id); @@ -155,70 +152,8 @@ class DatabaseQueries { template static void fillFeedData(T* feed, const QSqlRecord& sql_record); - // Feedly account. - static bool deleteFeedlyAccount(const QSqlDatabase& db, int account_id); - static bool createFeedlyAccount(const QSqlDatabase& db, - const QString& username, - const QString& developer_access_token, - const QString& refresh_token, - int batch_size, - bool download_only_unread_messages, - int account_id); - static bool overwriteFeedlyAccount(const QSqlDatabase& db, - const QString& username, - const QString& developer_access_token, - const QString& refresh_token, - int batch_size, - bool download_only_unread_messages, - int account_id); - - // Greader account. - static bool deleteGreaderAccount(const QSqlDatabase& db, int account_id); - 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, - GreaderServiceRoot::Service service, const QString& url, int batch_size, - int account_id); - - // Nextcloud account. - static bool deleteOwnCloudAccount(const QSqlDatabase& db, int account_id); - static bool overwriteOwnCloudAccount(const QSqlDatabase& db, const QString& username, const QString& password, - const QString& url, bool force_server_side_feed_update, int batch_size, - bool download_only_unread_messages, int account_id); - static bool createOwnCloudAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, - const QString& password, const QString& url, bool force_server_side_feed_update, - bool download_only_unread_messages, int batch_size); - - // TT-RSS acccount. - static bool deleteTtRssAccount(const QSqlDatabase& db, int account_id); - static bool overwriteTtRssAccount(const QSqlDatabase& db, const QString& username, const QString& password, - bool auth_protected, const QString& auth_username, const QString& auth_password, - const QString& url, bool force_server_side_feed_update, - bool download_only_unread_messages, int account_id); - static bool createTtRssAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, - const QString& password, bool auth_protected, const QString& auth_username, - const QString& auth_password, const QString& url, - bool force_server_side_feed_update, bool download_only_unread_messages); - // Gmail account. static QStringList getAllRecipients(const QSqlDatabase& db, int account_id); - static bool deleteGmailAccount(const QSqlDatabase& db, int account_id); - static bool overwriteGmailAccount(const QSqlDatabase& db, const QString& username, const QString& app_id, - const QString& app_key, const QString& redirect_url, const QString& refresh_token, - int batch_size, int account_id); - static bool createGmailAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, - const QString& app_id, const QString& app_key, const QString& redirect_url, - const QString& refresh_token, int batch_size); - - // Inoreader account. - static bool deleteInoreaderAccount(const QSqlDatabase& db, int account_id); - static bool overwriteInoreaderAccount(const QSqlDatabase& db, const QString& username, const QString& app_id, - const QString& app_key, const QString& redirect_url, const QString& refresh_token, - int batch_size, int account_id); - static bool createInoreaderAccount(const QSqlDatabase& db, int id_to_assign, const QString& username, - const QString& app_id, const QString& app_key, const QString& redirect_url, - const QString& refresh_token, int batch_size); private: static QString unnulifyString(const QString& str); diff --git a/src/librssguard/services/abstract/gui/formaccountdetails.cpp b/src/librssguard/services/abstract/gui/formaccountdetails.cpp index b38dd5e2a..b6a07c89a 100644 --- a/src/librssguard/services/abstract/gui/formaccountdetails.cpp +++ b/src/librssguard/services/abstract/gui/formaccountdetails.cpp @@ -21,16 +21,7 @@ FormAccountDetails::FormAccountDetails(const QIcon& icon, QWidget* parent) void FormAccountDetails::apply() { QSqlDatabase database = qApp->database()->connection(QSL("FormAccountDetails")); - /* - if (m_creatingNew) { - m_account->setAccountId(DatabaseQueries::createBaseAccount(database, m_account->code())); - } - */ - m_account->setNetworkProxy(m_proxyDetails->proxy()); - - // NOTE: We edit account common attributes here directly. - //DatabaseQueries::editBaseAccount(database, m_account); } void FormAccountDetails::insertCustomTab(QWidget* custom_tab, const QString& title, int index) { diff --git a/src/librssguard/services/abstract/serviceroot.cpp b/src/librssguard/services/abstract/serviceroot.cpp index 2f31b9770..4c1e97553 100644 --- a/src/librssguard/services/abstract/serviceroot.cpp +++ b/src/librssguard/services/abstract/serviceroot.cpp @@ -157,6 +157,10 @@ void ServiceRoot::updateCounts(bool including_total_count) { } } +bool ServiceRoot::canBeDeleted() const { + return true; +} + void ServiceRoot::completelyRemoveAllData() { // Purge old data from SQL and clean all model items. cleanAllItemsFromModel(); @@ -260,6 +264,12 @@ QList ServiceRoot::customDatabaseAttributes() const { return {}; } +void ServiceRoot::saveAccountDataToDatabase() { + QSqlDatabase database = qApp->database()->connection(metaObject()->className()); + + DatabaseQueries::createOverwriteAccount(database, this); +} + void ServiceRoot::itemChanged(const QList& items) { emit dataChanged(items); } diff --git a/src/librssguard/services/abstract/serviceroot.h b/src/librssguard/services/abstract/serviceroot.h index 1a4119008..81c59b2c9 100644 --- a/src/librssguard/services/abstract/serviceroot.h +++ b/src/librssguard/services/abstract/serviceroot.h @@ -51,6 +51,7 @@ class ServiceRoot : public RootItem { // These methods bellow are part of "interface". virtual void updateCounts(bool including_total_count); + virtual bool canBeDeleted() const; virtual bool deleteViaGui(); virtual bool markAsReadUnread(ReadStatus status); virtual RecycleBin* recycleBin() const; @@ -62,6 +63,7 @@ class ServiceRoot : public RootItem { virtual bool supportsCategoryAdding() const; virtual LabelOperation supportedLabelOperations() const; virtual QList customDatabaseAttributes() const; + virtual void saveAccountDataToDatabase(); // Returns list of specific actions for "Add new item" main window menu. // So typical list of returned actions could look like: diff --git a/src/librssguard/services/feedly/feedlyserviceroot.cpp b/src/librssguard/services/feedly/feedlyserviceroot.cpp index 4555c7a67..6f316173a 100755 --- a/src/librssguard/services/feedly/feedlyserviceroot.cpp +++ b/src/librssguard/services/feedly/feedlyserviceroot.cpp @@ -37,10 +37,6 @@ bool FeedlyServiceRoot::canBeEdited() const { return true; } -bool FeedlyServiceRoot::canBeDeleted() const { - return true; -} - bool FeedlyServiceRoot::editViaGui() { FormEditFeedlyAccount form_pointer(qApp->mainFormWidget()); @@ -48,23 +44,15 @@ bool FeedlyServiceRoot::editViaGui() { return true; } -bool FeedlyServiceRoot::deleteViaGui() { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (DatabaseQueries::deleteFeedlyAccount(database, accountId())) { - return ServiceRoot::deleteViaGui(); - } - else { - return false; - } -} - void FeedlyServiceRoot::start(bool freshly_activated) { - Q_UNUSED(freshly_activated) - loadFromDatabase(); - loadCacheFromFile(); + if (!freshly_activated) { + loadFromDatabase(); + loadCacheFromFile(); + } - if (childCount() <= 3) { + updateTitle(); + + if (getSubTreeFeeds().isEmpty()) { syncIn(); } } @@ -198,42 +186,6 @@ void FeedlyServiceRoot::updateTitle() { setTitle(QString("%1 (Feedly)").arg(TextFactory::extractUsernameFromEmail(m_network->username()))); } -void FeedlyServiceRoot::saveAccountDataToDatabase(bool creating_new) { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (!creating_new) { - if (DatabaseQueries::overwriteFeedlyAccount(database, - m_network->username(), - m_network->developerAccessToken(), -#if defined(FEEDLY_OFFICIAL_SUPPORT) - m_network->oauth()->refreshToken(), -#else - {}, -#endif - m_network->batchSize(), - m_network->downloadOnlyUnreadMessages(), - accountId())) { - updateTitle(); - itemChanged(QList() << this); - } - } - else { - if (DatabaseQueries::createFeedlyAccount(database, - m_network->username(), - m_network->developerAccessToken(), -#if defined(FEEDLY_OFFICIAL_SUPPORT) - m_network->oauth()->refreshToken(), -#else - {}, -#endif - m_network->batchSize(), - m_network->downloadOnlyUnreadMessages(), - accountId())) { - updateTitle(); - } - } -} - RootItem* FeedlyServiceRoot::obtainNewTreeForSyncIn() const { try { auto tree = m_network->collections(true); diff --git a/src/librssguard/services/feedly/feedlyserviceroot.h b/src/librssguard/services/feedly/feedlyserviceroot.h index 076af76fc..b72032813 100755 --- a/src/librssguard/services/feedly/feedlyserviceroot.h +++ b/src/librssguard/services/feedly/feedlyserviceroot.h @@ -16,9 +16,7 @@ class FeedlyServiceRoot : public ServiceRoot, public CacheForServiceRoot { 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); @@ -27,7 +25,6 @@ class FeedlyServiceRoot : public ServiceRoot, public CacheForServiceRoot { FeedlyNetwork* network() const; void updateTitle(); - void saveAccountDataToDatabase(bool creating_new); protected: virtual RootItem* obtainNewTreeForSyncIn() const; diff --git a/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp b/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp index 167d7f1a8..a58ef16ee 100755 --- a/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp +++ b/src/librssguard/services/feedly/gui/formeditfeedlyaccount.cpp @@ -48,7 +48,7 @@ void FormEditFeedlyAccount::apply() { account()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value()); account()->network()->setDeveloperAccessToken(m_details->m_ui.m_txtDeveloperAccessToken->lineEdit()->text()); - account()->saveAccountDataToDatabase(m_creatingNew); + account()->saveAccountDataToDatabase(); accept(); if (!m_creatingNew) { diff --git a/src/librssguard/services/gmail/gmailserviceroot.cpp b/src/librssguard/services/gmail/gmailserviceroot.cpp index 967847a7b..10b9022ae 100644 --- a/src/librssguard/services/gmail/gmailserviceroot.cpp +++ b/src/librssguard/services/gmail/gmailserviceroot.cpp @@ -65,35 +65,6 @@ void GmailServiceRoot::loadFromDatabase() { } } -void GmailServiceRoot::saveAccountDataToDatabase(bool creating_new) { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (!creating_new) { - if (DatabaseQueries::overwriteGmailAccount(database, m_network->username(), - m_network->oauth()->clientId(), - m_network->oauth()->clientSecret(), - m_network->oauth()->redirectUrl(), - m_network->oauth()->refreshToken(), - m_network->batchSize(), - accountId())) { - updateTitle(); - itemChanged(QList() << this); - } - } - else { - if (DatabaseQueries::createGmailAccount(database, - accountId(), - m_network->username(), - m_network->oauth()->clientId(), - m_network->oauth()->clientSecret(), - m_network->oauth()->redirectUrl(), - m_network->oauth()->refreshToken(), - m_network->batchSize())) { - updateTitle(); - } - } -} - bool GmailServiceRoot::downloadAttachmentOnMyOwn(const QUrl& url) const { QString str_url = url.toString(); QString attachment_id = str_url.mid(str_url.indexOf(QL1C('?')) + 1); @@ -171,6 +142,8 @@ void GmailServiceRoot::start(bool freshly_activated) { loadCacheFromFile(); } + updateTitle(); + if (getSubTreeFeeds().isEmpty()) { syncIn(); } @@ -233,18 +206,3 @@ void GmailServiceRoot::saveAllCachedData(bool ignore_errors) { } } } - -bool GmailServiceRoot::canBeDeleted() const { - return true; -} - -bool GmailServiceRoot::deleteViaGui() { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (DatabaseQueries::deleteGmailAccount(database, accountId())) { - return ServiceRoot::deleteViaGui(); - } - else { - return false; - } -} diff --git a/src/librssguard/services/gmail/gmailserviceroot.h b/src/librssguard/services/gmail/gmailserviceroot.h index 1a8301bd2..8f890f453 100644 --- a/src/librssguard/services/gmail/gmailserviceroot.h +++ b/src/librssguard/services/gmail/gmailserviceroot.h @@ -14,8 +14,6 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot { public: explicit GmailServiceRoot(RootItem* parent = nullptr); - void saveAccountDataToDatabase(bool creating_new); - void setNetwork(GmailNetworkFactory* network); GmailNetworkFactory* network() const; @@ -25,8 +23,6 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot { virtual bool isSyncable() const; virtual bool canBeEdited() const; virtual bool editViaGui(); - virtual bool canBeDeleted() const; - virtual bool deleteViaGui(); virtual bool supportsFeedAdding() const; virtual bool supportsCategoryAdding() const; virtual void start(bool freshly_activated); diff --git a/src/librssguard/services/gmail/gui/formeditgmailaccount.cpp b/src/librssguard/services/gmail/gui/formeditgmailaccount.cpp index 1eb377754..2ca311549 100644 --- a/src/librssguard/services/gmail/gui/formeditgmailaccount.cpp +++ b/src/librssguard/services/gmail/gui/formeditgmailaccount.cpp @@ -31,7 +31,7 @@ void FormEditGmailAccount::apply() { account()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text()); account()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value()); - account()->saveAccountDataToDatabase(m_creatingNew); + account()->saveAccountDataToDatabase(); accept(); if (!m_creatingNew) { diff --git a/src/librssguard/services/greader/greaderserviceroot.cpp b/src/librssguard/services/greader/greaderserviceroot.cpp index 57785b431..a4aad4016 100755 --- a/src/librssguard/services/greader/greaderserviceroot.cpp +++ b/src/librssguard/services/greader/greaderserviceroot.cpp @@ -28,10 +28,6 @@ bool GreaderServiceRoot::canBeEdited() const { return true; } -bool GreaderServiceRoot::canBeDeleted() const { - return true; -} - bool GreaderServiceRoot::editViaGui() { FormEditGreaderAccount form_pointer(qApp->mainFormWidget()); @@ -39,24 +35,14 @@ bool GreaderServiceRoot::editViaGui() { return true; } -bool GreaderServiceRoot::deleteViaGui() { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (DatabaseQueries::deleteGreaderAccount(database, accountId())) { - return ServiceRoot::deleteViaGui(); - } - else { - return false; - } -} - void GreaderServiceRoot::start(bool freshly_activated) { if (!freshly_activated) { loadFromDatabase(); loadCacheFromFile(); - } + updateTitleIcon(); + if (getSubTreeFeeds().isEmpty()) { syncIn(); } @@ -169,27 +155,6 @@ void GreaderServiceRoot::updateTitleIcon() { } } -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->service(), - m_network->baseUrl(), m_network->batchSize(), - accountId())) { - updateTitleIcon(); - itemChanged(QList() << this); - } - } - else { - if (DatabaseQueries::createGreaderAccount(database, accountId(), m_network->username(), - m_network->password(), m_network->service(), - m_network->baseUrl(), m_network->batchSize())) { - updateTitleIcon(); - } - } -} - RootItem* GreaderServiceRoot::obtainNewTreeForSyncIn() const { return m_network->categoriesFeedsLabelsTree(true, networkProxy()); } diff --git a/src/librssguard/services/greader/greaderserviceroot.h b/src/librssguard/services/greader/greaderserviceroot.h index 594fcf14a..90f98d84d 100755 --- a/src/librssguard/services/greader/greaderserviceroot.h +++ b/src/librssguard/services/greader/greaderserviceroot.h @@ -24,9 +24,7 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot { 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); @@ -35,7 +33,6 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot { GreaderNetwork* network() const; void updateTitleIcon(); - void saveAccountDataToDatabase(bool creating_new); protected: virtual RootItem* obtainNewTreeForSyncIn() const; diff --git a/src/librssguard/services/greader/gui/formeditgreaderaccount.cpp b/src/librssguard/services/greader/gui/formeditgreaderaccount.cpp index e5a43353f..801095805 100755 --- a/src/librssguard/services/greader/gui/formeditgreaderaccount.cpp +++ b/src/librssguard/services/greader/gui/formeditgreaderaccount.cpp @@ -29,7 +29,7 @@ void FormEditGreaderAccount::apply() { account()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value()); account()->network()->setService(m_details->service()); - account()->saveAccountDataToDatabase(m_creatingNew); + account()->saveAccountDataToDatabase(); accept(); if (!m_creatingNew) { diff --git a/src/librssguard/services/inoreader/gui/formeditinoreaderaccount.cpp b/src/librssguard/services/inoreader/gui/formeditinoreaderaccount.cpp index ad20ce603..57533649a 100644 --- a/src/librssguard/services/inoreader/gui/formeditinoreaderaccount.cpp +++ b/src/librssguard/services/inoreader/gui/formeditinoreaderaccount.cpp @@ -39,7 +39,7 @@ void FormEditInoreaderAccount::apply() { account()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text()); account()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value()); - account()->saveAccountDataToDatabase(m_creatingNew); + account()->saveAccountDataToDatabase(); accept(); if (!m_creatingNew) { diff --git a/src/librssguard/services/inoreader/inoreaderserviceroot.cpp b/src/librssguard/services/inoreader/inoreaderserviceroot.cpp index 390581ff8..230bd6b41 100644 --- a/src/librssguard/services/inoreader/inoreaderserviceroot.cpp +++ b/src/librssguard/services/inoreader/inoreaderserviceroot.cpp @@ -37,35 +37,6 @@ void InoreaderServiceRoot::loadFromDatabase() { performInitialAssembly(categories, feeds, labels); } -void InoreaderServiceRoot::saveAccountDataToDatabase(bool creating_new) { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (!creating_new) { - if (DatabaseQueries::overwriteInoreaderAccount(database, m_network->username(), - m_network->oauth()->clientId(), - m_network->oauth()->clientSecret(), - m_network->oauth()->redirectUrl(), - m_network->oauth()->refreshToken(), - m_network->batchSize(), - accountId())) { - updateTitle(); - itemChanged(QList() << this); - } - } - else { - if (DatabaseQueries::createInoreaderAccount(database, - accountId(), - m_network->username(), - m_network->oauth()->clientId(), - m_network->oauth()->clientSecret(), - m_network->oauth()->redirectUrl(), - m_network->oauth()->refreshToken(), - m_network->batchSize())) { - updateTitle(); - } - } -} - ServiceRoot::LabelOperation InoreaderServiceRoot::supportedLabelOperations() const { return ServiceRoot::LabelOperation(0); } @@ -99,6 +70,8 @@ void InoreaderServiceRoot::start(bool freshly_activated) { loadCacheFromFile(); } + updateTitle(); + if (getSubTreeFeeds().isEmpty()) { m_network->oauth()->login([this]() { syncIn(); @@ -205,18 +178,3 @@ void InoreaderServiceRoot::saveAllCachedData(bool ignore_errors) { } } } - -bool InoreaderServiceRoot::canBeDeleted() const { - return true; -} - -bool InoreaderServiceRoot::deleteViaGui() { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (DatabaseQueries::deleteInoreaderAccount(database, accountId())) { - return ServiceRoot::deleteViaGui(); - } - else { - return false; - } -} diff --git a/src/librssguard/services/inoreader/inoreaderserviceroot.h b/src/librssguard/services/inoreader/inoreaderserviceroot.h index c29c4c5dd..34783c7b8 100644 --- a/src/librssguard/services/inoreader/inoreaderserviceroot.h +++ b/src/librssguard/services/inoreader/inoreaderserviceroot.h @@ -15,16 +15,12 @@ class InoreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot { explicit InoreaderServiceRoot(RootItem* parent = nullptr); virtual ~InoreaderServiceRoot(); - void saveAccountDataToDatabase(bool creating_new); - InoreaderNetworkFactory* network() const; virtual LabelOperation supportedLabelOperations() const; virtual bool isSyncable() const; virtual bool canBeEdited() const; virtual bool editViaGui(); - virtual bool canBeDeleted() const; - virtual bool deleteViaGui(); virtual bool supportsFeedAdding() const; virtual bool supportsCategoryAdding() const; virtual void start(bool freshly_activated); diff --git a/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp b/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp index 54dac1e7e..5cb265740 100644 --- a/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp +++ b/src/librssguard/services/owncloud/gui/formeditowncloudaccount.cpp @@ -30,7 +30,7 @@ void FormEditOwnCloudAccount::apply() { account()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value()); account()->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_checkDownloadOnlyUnreadMessages->isChecked()); - account()->saveAccountDataToDatabase(m_creatingNew); + account()->saveAccountDataToDatabase(); accept(); if (!m_creatingNew) { diff --git a/src/librssguard/services/owncloud/owncloudserviceroot.cpp b/src/librssguard/services/owncloud/owncloudserviceroot.cpp index 32ae88cf7..875e4a45b 100644 --- a/src/librssguard/services/owncloud/owncloudserviceroot.cpp +++ b/src/librssguard/services/owncloud/owncloudserviceroot.cpp @@ -32,10 +32,6 @@ bool OwnCloudServiceRoot::canBeEdited() const { return true; } -bool OwnCloudServiceRoot::canBeDeleted() const { - return true; -} - bool OwnCloudServiceRoot::editViaGui() { QScopedPointer form_pointer(new FormEditOwnCloudAccount(qApp->mainFormWidget())); @@ -43,17 +39,6 @@ bool OwnCloudServiceRoot::editViaGui() { return true; } -bool OwnCloudServiceRoot::deleteViaGui() { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (DatabaseQueries::deleteOwnCloudAccount(database, accountId())) { - return ServiceRoot::deleteViaGui(); - } - else { - return false; - } -} - bool OwnCloudServiceRoot::supportsFeedAdding() const { return false; } @@ -68,6 +53,8 @@ void OwnCloudServiceRoot::start(bool freshly_activated) { loadCacheFromFile(); } + updateTitle(); + if (getSubTreeFeeds().isEmpty()) { syncIn(); } @@ -129,29 +116,6 @@ void OwnCloudServiceRoot::updateTitle() { setTitle(m_network->authUsername() + QSL(" (Nextcloud News)")); } -void OwnCloudServiceRoot::saveAccountDataToDatabase(bool creating_new) { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - if (!creating_new) { - if (DatabaseQueries::overwriteOwnCloudAccount(database, m_network->authUsername(), - m_network->authPassword(), m_network->url(), - m_network->forceServerSideUpdate(), m_network->batchSize(), - m_network->downloadOnlyUnreadMessages(), accountId())) { - updateTitle(); - itemChanged(QList() << this); - } - } - else { - if (DatabaseQueries::createOwnCloudAccount(database, accountId(), m_network->authUsername(), - m_network->authPassword(), m_network->url(), - m_network->forceServerSideUpdate(), - m_network->downloadOnlyUnreadMessages(), - m_network->batchSize())) { - updateTitle(); - } - } -} - RootItem* OwnCloudServiceRoot::obtainNewTreeForSyncIn() const { OwnCloudGetFeedsCategoriesResponse feed_cats_response = m_network->feedsCategories(networkProxy()); diff --git a/src/librssguard/services/owncloud/owncloudserviceroot.h b/src/librssguard/services/owncloud/owncloudserviceroot.h index ac689e6e9..3a0c20550 100644 --- a/src/librssguard/services/owncloud/owncloudserviceroot.h +++ b/src/librssguard/services/owncloud/owncloudserviceroot.h @@ -20,9 +20,7 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot { virtual bool isSyncable() const; virtual bool canBeEdited() const; - virtual bool canBeDeleted() const; virtual bool editViaGui(); - virtual bool deleteViaGui(); virtual bool supportsFeedAdding() const; virtual bool supportsCategoryAdding() const; virtual void start(bool freshly_activated); @@ -32,7 +30,6 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot { OwnCloudNetworkFactory* network() const; void updateTitle(); - void saveAccountDataToDatabase(bool creating_new); protected: virtual RootItem* obtainNewTreeForSyncIn() const; diff --git a/src/librssguard/services/standard/standardfeedsimportexportmodel.cpp b/src/librssguard/services/standard/standardfeedsimportexportmodel.cpp index 1c67d2337..97b368cc7 100644 --- a/src/librssguard/services/standard/standardfeedsimportexportmodel.cpp +++ b/src/librssguard/services/standard/standardfeedsimportexportmodel.cpp @@ -186,8 +186,8 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m QString feed_url = child_element.attribute(QSL("xmlUrl")); if (!feed_url.isEmpty()) { - StandardFeed* guessed; - bool result; + StandardFeed* guessed = nullptr; + bool result = false; if (fetch_metadata_online && (guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url, @@ -310,8 +310,8 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool for (const QByteArray& url : urls) { if (!url.isEmpty()) { - StandardFeed* guessed; - bool result; + StandardFeed* guessed = nullptr; + bool result = false; if (fetch_metadata_online && (guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url, diff --git a/src/librssguard/services/tt-rss/ttrssserviceroot.cpp b/src/librssguard/services/tt-rss/ttrssserviceroot.cpp index 81dc5d5e8..fc5c149dd 100644 --- a/src/librssguard/services/tt-rss/ttrssserviceroot.cpp +++ b/src/librssguard/services/tt-rss/ttrssserviceroot.cpp @@ -71,19 +71,6 @@ bool TtRssServiceRoot::editViaGui() { return true; } -bool TtRssServiceRoot::deleteViaGui() { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - // Remove extra entry in "Tiny Tiny RSS accounts list" and then delete - // all the categories/feeds and messages. - if (DatabaseQueries::deleteTtRssAccount(database, accountId())) { - return ServiceRoot::deleteViaGui(); - } - else { - return false; - } -} - bool TtRssServiceRoot::supportsFeedAdding() const { return true; } @@ -116,10 +103,6 @@ bool TtRssServiceRoot::canBeEdited() const { return true; } -bool TtRssServiceRoot::canBeDeleted() const { - return true; -} - void TtRssServiceRoot::saveAllCachedData(bool ignore_errors) { auto msg_cache = takeMessageCache(); QMapIterator i(msg_cache.m_cachedStatesRead); @@ -223,12 +206,6 @@ TtRssNetworkFactory* TtRssServiceRoot::network() const { return m_network; } -void TtRssServiceRoot::saveAccountDataToDatabase() { - QSqlDatabase database = qApp->database()->connection(metaObject()->className()); - - DatabaseQueries::createOverwriteAccount(database, this); -} - void TtRssServiceRoot::loadFromDatabase() { QSqlDatabase database = qApp->database()->connection(metaObject()->className()); Assignment categories = DatabaseQueries::getCategories(database, accountId()); diff --git a/src/librssguard/services/tt-rss/ttrssserviceroot.h b/src/librssguard/services/tt-rss/ttrssserviceroot.h index ac29851f9..1e1825069 100644 --- a/src/librssguard/services/tt-rss/ttrssserviceroot.h +++ b/src/librssguard/services/tt-rss/ttrssserviceroot.h @@ -33,9 +33,7 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot { virtual QString code() const; virtual bool isSyncable() const; virtual bool canBeEdited() const; - virtual bool canBeDeleted() const; virtual bool editViaGui(); - virtual bool deleteViaGui(); virtual bool supportsFeedAdding() const; virtual bool supportsCategoryAdding() const; virtual void addNewFeed(RootItem* selected_item, const QString& url = QString()); @@ -46,7 +44,6 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot { // Access to network. TtRssNetworkFactory* network() const; - void saveAccountDataToDatabase(); void updateTitle(); // Support for dynamic DB attributes.