massive cleanups of redundant code
This commit is contained in:
parent
f2a8f63f91
commit
1118d278d6
23 changed files with 38 additions and 825 deletions
|
@ -1658,201 +1658,6 @@ QStringList DatabaseQueries::customIdsOfMessagesFromFeed(const QSqlDatabase& db,
|
||||||
return ids;
|
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) {
|
void DatabaseQueries::createOverwriteAccount(const QSqlDatabase& db, ServiceRoot* account) {
|
||||||
QSqlQuery q(db);
|
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) {
|
bool DatabaseQueries::deleteFeed(const QSqlDatabase& db, int feed_custom_id, int account_id) {
|
||||||
QSqlQuery q(db);
|
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) {
|
QStringList DatabaseQueries::getAllRecipients(const QSqlDatabase& db, int account_id) {
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
QStringList rec;
|
QStringList rec;
|
||||||
|
@ -2524,28 +2173,12 @@ QStringList DatabaseQueries::getAllRecipients(const QSqlDatabase& db, int accoun
|
||||||
return rec;
|
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,
|
bool DatabaseQueries::storeNewOauthTokens(const QSqlDatabase& db, const QString& table_name,
|
||||||
const QString& refresh_token, int account_id) {
|
const QString& refresh_token, int account_id) {
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
|
|
||||||
|
// TODO:, není funkční
|
||||||
|
|
||||||
query.prepare(QSL("UPDATE %1 "
|
query.prepare(QSL("UPDATE %1 "
|
||||||
"SET refresh_token = :refresh_token "
|
"SET refresh_token = :refresh_token "
|
||||||
"WHERE id = :id;").arg(table_name));
|
"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) {
|
QString DatabaseQueries::unnulifyString(const QString& str) {
|
||||||
return str.isNull() ? "" : str;
|
return str.isNull() ? "" : str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,10 +94,7 @@ class DatabaseQueries {
|
||||||
static QList<ServiceRoot*> getAccounts(const QSqlDatabase& db, const QString& code, bool* ok = nullptr);
|
static QList<ServiceRoot*> getAccounts(const QSqlDatabase& db, const QString& code, bool* ok = nullptr);
|
||||||
static bool storeNewOauthTokens(const QSqlDatabase& db, const QString& table_name,
|
static bool storeNewOauthTokens(const QSqlDatabase& db, const QString& table_name,
|
||||||
const QString& refresh_token, int account_id);
|
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 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<Message>& messages, const QString& feed_custom_id,
|
static int updateMessages(QSqlDatabase db, const QList<Message>& messages, const QString& feed_custom_id,
|
||||||
int account_id, const QString& url, bool force_update, bool* any_message_changed, bool* ok = nullptr);
|
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);
|
static bool deleteAccount(const QSqlDatabase& db, int account_id);
|
||||||
|
@ -155,70 +152,8 @@ 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);
|
||||||
|
|
||||||
// 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.
|
// Gmail account.
|
||||||
static QStringList getAllRecipients(const QSqlDatabase& db, int account_id);
|
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:
|
private:
|
||||||
static QString unnulifyString(const QString& str);
|
static QString unnulifyString(const QString& str);
|
||||||
|
|
|
@ -21,16 +21,7 @@ FormAccountDetails::FormAccountDetails(const QIcon& icon, QWidget* parent)
|
||||||
void FormAccountDetails::apply() {
|
void FormAccountDetails::apply() {
|
||||||
QSqlDatabase database = qApp->database()->connection(QSL("FormAccountDetails"));
|
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());
|
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) {
|
void FormAccountDetails::insertCustomTab(QWidget* custom_tab, const QString& title, int index) {
|
||||||
|
|
|
@ -157,6 +157,10 @@ void ServiceRoot::updateCounts(bool including_total_count) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServiceRoot::canBeDeleted() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ServiceRoot::completelyRemoveAllData() {
|
void ServiceRoot::completelyRemoveAllData() {
|
||||||
// Purge old data from SQL and clean all model items.
|
// Purge old data from SQL and clean all model items.
|
||||||
cleanAllItemsFromModel();
|
cleanAllItemsFromModel();
|
||||||
|
@ -260,6 +264,12 @@ QList<CustomDatabaseEntry> ServiceRoot::customDatabaseAttributes() const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServiceRoot::saveAccountDataToDatabase() {
|
||||||
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||||
|
|
||||||
|
DatabaseQueries::createOverwriteAccount(database, this);
|
||||||
|
}
|
||||||
|
|
||||||
void ServiceRoot::itemChanged(const QList<RootItem*>& items) {
|
void ServiceRoot::itemChanged(const QList<RootItem*>& items) {
|
||||||
emit dataChanged(items);
|
emit dataChanged(items);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ class ServiceRoot : public RootItem {
|
||||||
|
|
||||||
// These methods bellow are part of "interface".
|
// These methods bellow are part of "interface".
|
||||||
virtual void updateCounts(bool including_total_count);
|
virtual void updateCounts(bool including_total_count);
|
||||||
|
virtual bool canBeDeleted() const;
|
||||||
virtual bool deleteViaGui();
|
virtual bool deleteViaGui();
|
||||||
virtual bool markAsReadUnread(ReadStatus status);
|
virtual bool markAsReadUnread(ReadStatus status);
|
||||||
virtual RecycleBin* recycleBin() const;
|
virtual RecycleBin* recycleBin() const;
|
||||||
|
@ -62,6 +63,7 @@ class ServiceRoot : public RootItem {
|
||||||
virtual bool supportsCategoryAdding() const;
|
virtual bool supportsCategoryAdding() const;
|
||||||
virtual LabelOperation supportedLabelOperations() const;
|
virtual LabelOperation supportedLabelOperations() const;
|
||||||
virtual QList<CustomDatabaseEntry> customDatabaseAttributes() const;
|
virtual QList<CustomDatabaseEntry> customDatabaseAttributes() const;
|
||||||
|
virtual void saveAccountDataToDatabase();
|
||||||
|
|
||||||
// Returns list of specific actions for "Add new item" main window menu.
|
// Returns list of specific actions for "Add new item" main window menu.
|
||||||
// So typical list of returned actions could look like:
|
// So typical list of returned actions could look like:
|
||||||
|
|
|
@ -37,10 +37,6 @@ bool FeedlyServiceRoot::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedlyServiceRoot::canBeDeleted() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FeedlyServiceRoot::editViaGui() {
|
bool FeedlyServiceRoot::editViaGui() {
|
||||||
FormEditFeedlyAccount form_pointer(qApp->mainFormWidget());
|
FormEditFeedlyAccount form_pointer(qApp->mainFormWidget());
|
||||||
|
|
||||||
|
@ -48,23 +44,15 @@ bool FeedlyServiceRoot::editViaGui() {
|
||||||
return true;
|
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) {
|
void FeedlyServiceRoot::start(bool freshly_activated) {
|
||||||
Q_UNUSED(freshly_activated)
|
if (!freshly_activated) {
|
||||||
loadFromDatabase();
|
loadFromDatabase();
|
||||||
loadCacheFromFile();
|
loadCacheFromFile();
|
||||||
|
}
|
||||||
|
|
||||||
if (childCount() <= 3) {
|
updateTitle();
|
||||||
|
|
||||||
|
if (getSubTreeFeeds().isEmpty()) {
|
||||||
syncIn();
|
syncIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,42 +186,6 @@ void FeedlyServiceRoot::updateTitle() {
|
||||||
setTitle(QString("%1 (Feedly)").arg(TextFactory::extractUsernameFromEmail(m_network->username())));
|
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<RootItem*>() << 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 {
|
RootItem* FeedlyServiceRoot::obtainNewTreeForSyncIn() const {
|
||||||
try {
|
try {
|
||||||
auto tree = m_network->collections(true);
|
auto tree = m_network->collections(true);
|
||||||
|
|
|
@ -16,9 +16,7 @@ class FeedlyServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
|
|
||||||
virtual bool isSyncable() const;
|
virtual bool isSyncable() const;
|
||||||
virtual bool canBeEdited() const;
|
virtual bool canBeEdited() const;
|
||||||
virtual bool canBeDeleted() const;
|
|
||||||
virtual bool editViaGui();
|
virtual bool editViaGui();
|
||||||
virtual bool deleteViaGui();
|
|
||||||
virtual void start(bool freshly_activated);
|
virtual void start(bool freshly_activated);
|
||||||
virtual QString code() const;
|
virtual QString code() const;
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
|
@ -27,7 +25,6 @@ class FeedlyServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
FeedlyNetwork* network() const;
|
FeedlyNetwork* network() const;
|
||||||
|
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
void saveAccountDataToDatabase(bool creating_new);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual RootItem* obtainNewTreeForSyncIn() const;
|
virtual RootItem* obtainNewTreeForSyncIn() const;
|
||||||
|
|
|
@ -48,7 +48,7 @@ void FormEditFeedlyAccount::apply() {
|
||||||
account<FeedlyServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
account<FeedlyServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
||||||
account<FeedlyServiceRoot>()->network()->setDeveloperAccessToken(m_details->m_ui.m_txtDeveloperAccessToken->lineEdit()->text());
|
account<FeedlyServiceRoot>()->network()->setDeveloperAccessToken(m_details->m_ui.m_txtDeveloperAccessToken->lineEdit()->text());
|
||||||
|
|
||||||
account<FeedlyServiceRoot>()->saveAccountDataToDatabase(m_creatingNew);
|
account<FeedlyServiceRoot>()->saveAccountDataToDatabase();
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
if (!m_creatingNew) {
|
if (!m_creatingNew) {
|
||||||
|
|
|
@ -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<RootItem*>() << 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 {
|
bool GmailServiceRoot::downloadAttachmentOnMyOwn(const QUrl& url) const {
|
||||||
QString str_url = url.toString();
|
QString str_url = url.toString();
|
||||||
QString attachment_id = str_url.mid(str_url.indexOf(QL1C('?')) + 1);
|
QString attachment_id = str_url.mid(str_url.indexOf(QL1C('?')) + 1);
|
||||||
|
@ -171,6 +142,8 @@ void GmailServiceRoot::start(bool freshly_activated) {
|
||||||
loadCacheFromFile();
|
loadCacheFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTitle();
|
||||||
|
|
||||||
if (getSubTreeFeeds().isEmpty()) {
|
if (getSubTreeFeeds().isEmpty()) {
|
||||||
syncIn();
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,8 +14,6 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
public:
|
public:
|
||||||
explicit GmailServiceRoot(RootItem* parent = nullptr);
|
explicit GmailServiceRoot(RootItem* parent = nullptr);
|
||||||
|
|
||||||
void saveAccountDataToDatabase(bool creating_new);
|
|
||||||
|
|
||||||
void setNetwork(GmailNetworkFactory* network);
|
void setNetwork(GmailNetworkFactory* network);
|
||||||
GmailNetworkFactory* network() const;
|
GmailNetworkFactory* network() const;
|
||||||
|
|
||||||
|
@ -25,8 +23,6 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
virtual bool isSyncable() const;
|
virtual bool isSyncable() const;
|
||||||
virtual bool canBeEdited() const;
|
virtual bool canBeEdited() const;
|
||||||
virtual bool editViaGui();
|
virtual bool editViaGui();
|
||||||
virtual bool canBeDeleted() const;
|
|
||||||
virtual bool deleteViaGui();
|
|
||||||
virtual bool supportsFeedAdding() const;
|
virtual bool supportsFeedAdding() const;
|
||||||
virtual bool supportsCategoryAdding() const;
|
virtual bool supportsCategoryAdding() const;
|
||||||
virtual void start(bool freshly_activated);
|
virtual void start(bool freshly_activated);
|
||||||
|
|
|
@ -31,7 +31,7 @@ void FormEditGmailAccount::apply() {
|
||||||
account<GmailServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
|
account<GmailServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
|
||||||
account<GmailServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
account<GmailServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
||||||
|
|
||||||
account<GmailServiceRoot>()->saveAccountDataToDatabase(m_creatingNew);
|
account<GmailServiceRoot>()->saveAccountDataToDatabase();
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
if (!m_creatingNew) {
|
if (!m_creatingNew) {
|
||||||
|
|
|
@ -28,10 +28,6 @@ bool GreaderServiceRoot::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GreaderServiceRoot::canBeDeleted() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GreaderServiceRoot::editViaGui() {
|
bool GreaderServiceRoot::editViaGui() {
|
||||||
FormEditGreaderAccount form_pointer(qApp->mainFormWidget());
|
FormEditGreaderAccount form_pointer(qApp->mainFormWidget());
|
||||||
|
|
||||||
|
@ -39,24 +35,14 @@ bool GreaderServiceRoot::editViaGui() {
|
||||||
return true;
|
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) {
|
void GreaderServiceRoot::start(bool freshly_activated) {
|
||||||
if (!freshly_activated) {
|
if (!freshly_activated) {
|
||||||
loadFromDatabase();
|
loadFromDatabase();
|
||||||
loadCacheFromFile();
|
loadCacheFromFile();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTitleIcon();
|
||||||
|
|
||||||
if (getSubTreeFeeds().isEmpty()) {
|
if (getSubTreeFeeds().isEmpty()) {
|
||||||
syncIn();
|
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<RootItem*>() << 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 {
|
RootItem* GreaderServiceRoot::obtainNewTreeForSyncIn() const {
|
||||||
return m_network->categoriesFeedsLabelsTree(true, networkProxy());
|
return m_network->categoriesFeedsLabelsTree(true, networkProxy());
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,7 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
|
|
||||||
virtual bool isSyncable() const;
|
virtual bool isSyncable() const;
|
||||||
virtual bool canBeEdited() const;
|
virtual bool canBeEdited() const;
|
||||||
virtual bool canBeDeleted() const;
|
|
||||||
virtual bool editViaGui();
|
virtual bool editViaGui();
|
||||||
virtual bool deleteViaGui();
|
|
||||||
virtual void start(bool freshly_activated);
|
virtual void start(bool freshly_activated);
|
||||||
virtual QString code() const;
|
virtual QString code() const;
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
|
@ -35,7 +33,6 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
GreaderNetwork* network() const;
|
GreaderNetwork* network() const;
|
||||||
|
|
||||||
void updateTitleIcon();
|
void updateTitleIcon();
|
||||||
void saveAccountDataToDatabase(bool creating_new);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual RootItem* obtainNewTreeForSyncIn() const;
|
virtual RootItem* obtainNewTreeForSyncIn() const;
|
||||||
|
|
|
@ -29,7 +29,7 @@ void FormEditGreaderAccount::apply() {
|
||||||
account<GreaderServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
account<GreaderServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
||||||
account<GreaderServiceRoot>()->network()->setService(m_details->service());
|
account<GreaderServiceRoot>()->network()->setService(m_details->service());
|
||||||
|
|
||||||
account<GreaderServiceRoot>()->saveAccountDataToDatabase(m_creatingNew);
|
account<GreaderServiceRoot>()->saveAccountDataToDatabase();
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
if (!m_creatingNew) {
|
if (!m_creatingNew) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ void FormEditInoreaderAccount::apply() {
|
||||||
account<InoreaderServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
|
account<InoreaderServiceRoot>()->network()->setUsername(m_details->m_ui.m_txtUsername->lineEdit()->text());
|
||||||
account<InoreaderServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
account<InoreaderServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
||||||
|
|
||||||
account<InoreaderServiceRoot>()->saveAccountDataToDatabase(m_creatingNew);
|
account<InoreaderServiceRoot>()->saveAccountDataToDatabase();
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
if (!m_creatingNew) {
|
if (!m_creatingNew) {
|
||||||
|
|
|
@ -37,35 +37,6 @@ void InoreaderServiceRoot::loadFromDatabase() {
|
||||||
performInitialAssembly(categories, feeds, labels);
|
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<RootItem*>() << 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 {
|
ServiceRoot::LabelOperation InoreaderServiceRoot::supportedLabelOperations() const {
|
||||||
return ServiceRoot::LabelOperation(0);
|
return ServiceRoot::LabelOperation(0);
|
||||||
}
|
}
|
||||||
|
@ -99,6 +70,8 @@ void InoreaderServiceRoot::start(bool freshly_activated) {
|
||||||
loadCacheFromFile();
|
loadCacheFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTitle();
|
||||||
|
|
||||||
if (getSubTreeFeeds().isEmpty()) {
|
if (getSubTreeFeeds().isEmpty()) {
|
||||||
m_network->oauth()->login([this]() {
|
m_network->oauth()->login([this]() {
|
||||||
syncIn();
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -15,16 +15,12 @@ class InoreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
explicit InoreaderServiceRoot(RootItem* parent = nullptr);
|
explicit InoreaderServiceRoot(RootItem* parent = nullptr);
|
||||||
virtual ~InoreaderServiceRoot();
|
virtual ~InoreaderServiceRoot();
|
||||||
|
|
||||||
void saveAccountDataToDatabase(bool creating_new);
|
|
||||||
|
|
||||||
InoreaderNetworkFactory* network() const;
|
InoreaderNetworkFactory* network() const;
|
||||||
|
|
||||||
virtual LabelOperation supportedLabelOperations() const;
|
virtual LabelOperation supportedLabelOperations() const;
|
||||||
virtual bool isSyncable() const;
|
virtual bool isSyncable() const;
|
||||||
virtual bool canBeEdited() const;
|
virtual bool canBeEdited() const;
|
||||||
virtual bool editViaGui();
|
virtual bool editViaGui();
|
||||||
virtual bool canBeDeleted() const;
|
|
||||||
virtual bool deleteViaGui();
|
|
||||||
virtual bool supportsFeedAdding() const;
|
virtual bool supportsFeedAdding() const;
|
||||||
virtual bool supportsCategoryAdding() const;
|
virtual bool supportsCategoryAdding() const;
|
||||||
virtual void start(bool freshly_activated);
|
virtual void start(bool freshly_activated);
|
||||||
|
|
|
@ -30,7 +30,7 @@ void FormEditOwnCloudAccount::apply() {
|
||||||
account<OwnCloudServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
account<OwnCloudServiceRoot>()->network()->setBatchSize(m_details->m_ui.m_spinLimitMessages->value());
|
||||||
account<OwnCloudServiceRoot>()->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_checkDownloadOnlyUnreadMessages->isChecked());
|
account<OwnCloudServiceRoot>()->network()->setDownloadOnlyUnreadMessages(m_details->m_ui.m_checkDownloadOnlyUnreadMessages->isChecked());
|
||||||
|
|
||||||
account<OwnCloudServiceRoot>()->saveAccountDataToDatabase(m_creatingNew);
|
account<OwnCloudServiceRoot>()->saveAccountDataToDatabase();
|
||||||
accept();
|
accept();
|
||||||
|
|
||||||
if (!m_creatingNew) {
|
if (!m_creatingNew) {
|
||||||
|
|
|
@ -32,10 +32,6 @@ bool OwnCloudServiceRoot::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OwnCloudServiceRoot::canBeDeleted() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OwnCloudServiceRoot::editViaGui() {
|
bool OwnCloudServiceRoot::editViaGui() {
|
||||||
QScopedPointer<FormEditOwnCloudAccount> form_pointer(new FormEditOwnCloudAccount(qApp->mainFormWidget()));
|
QScopedPointer<FormEditOwnCloudAccount> form_pointer(new FormEditOwnCloudAccount(qApp->mainFormWidget()));
|
||||||
|
|
||||||
|
@ -43,17 +39,6 @@ bool OwnCloudServiceRoot::editViaGui() {
|
||||||
return true;
|
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 {
|
bool OwnCloudServiceRoot::supportsFeedAdding() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +53,8 @@ void OwnCloudServiceRoot::start(bool freshly_activated) {
|
||||||
loadCacheFromFile();
|
loadCacheFromFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTitle();
|
||||||
|
|
||||||
if (getSubTreeFeeds().isEmpty()) {
|
if (getSubTreeFeeds().isEmpty()) {
|
||||||
syncIn();
|
syncIn();
|
||||||
}
|
}
|
||||||
|
@ -129,29 +116,6 @@ void OwnCloudServiceRoot::updateTitle() {
|
||||||
setTitle(m_network->authUsername() + QSL(" (Nextcloud News)"));
|
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<RootItem*>() << 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 {
|
RootItem* OwnCloudServiceRoot::obtainNewTreeForSyncIn() const {
|
||||||
OwnCloudGetFeedsCategoriesResponse feed_cats_response = m_network->feedsCategories(networkProxy());
|
OwnCloudGetFeedsCategoriesResponse feed_cats_response = m_network->feedsCategories(networkProxy());
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,7 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
|
|
||||||
virtual bool isSyncable() const;
|
virtual bool isSyncable() const;
|
||||||
virtual bool canBeEdited() const;
|
virtual bool canBeEdited() const;
|
||||||
virtual bool canBeDeleted() const;
|
|
||||||
virtual bool editViaGui();
|
virtual bool editViaGui();
|
||||||
virtual bool deleteViaGui();
|
|
||||||
virtual bool supportsFeedAdding() const;
|
virtual bool supportsFeedAdding() const;
|
||||||
virtual bool supportsCategoryAdding() const;
|
virtual bool supportsCategoryAdding() const;
|
||||||
virtual void start(bool freshly_activated);
|
virtual void start(bool freshly_activated);
|
||||||
|
@ -32,7 +30,6 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
OwnCloudNetworkFactory* network() const;
|
OwnCloudNetworkFactory* network() const;
|
||||||
|
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
void saveAccountDataToDatabase(bool creating_new);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual RootItem* obtainNewTreeForSyncIn() const;
|
virtual RootItem* obtainNewTreeForSyncIn() const;
|
||||||
|
|
|
@ -186,8 +186,8 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
QString feed_url = child_element.attribute(QSL("xmlUrl"));
|
QString feed_url = child_element.attribute(QSL("xmlUrl"));
|
||||||
|
|
||||||
if (!feed_url.isEmpty()) {
|
if (!feed_url.isEmpty()) {
|
||||||
StandardFeed* guessed;
|
StandardFeed* guessed = nullptr;
|
||||||
bool result;
|
bool result = false;
|
||||||
|
|
||||||
if (fetch_metadata_online &&
|
if (fetch_metadata_online &&
|
||||||
(guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url,
|
(guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url,
|
||||||
|
@ -310,8 +310,8 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
|
||||||
|
|
||||||
for (const QByteArray& url : urls) {
|
for (const QByteArray& url : urls) {
|
||||||
if (!url.isEmpty()) {
|
if (!url.isEmpty()) {
|
||||||
StandardFeed* guessed;
|
StandardFeed* guessed = nullptr;
|
||||||
bool result;
|
bool result = false;
|
||||||
|
|
||||||
if (fetch_metadata_online &&
|
if (fetch_metadata_online &&
|
||||||
(guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url,
|
(guessed = StandardFeed::guessFeed(StandardFeed::SourceType::Url,
|
||||||
|
|
|
@ -71,19 +71,6 @@ bool TtRssServiceRoot::editViaGui() {
|
||||||
return true;
|
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 {
|
bool TtRssServiceRoot::supportsFeedAdding() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -116,10 +103,6 @@ bool TtRssServiceRoot::canBeEdited() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TtRssServiceRoot::canBeDeleted() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TtRssServiceRoot::saveAllCachedData(bool ignore_errors) {
|
void TtRssServiceRoot::saveAllCachedData(bool ignore_errors) {
|
||||||
auto msg_cache = takeMessageCache();
|
auto msg_cache = takeMessageCache();
|
||||||
QMapIterator<RootItem::ReadStatus, QStringList> i(msg_cache.m_cachedStatesRead);
|
QMapIterator<RootItem::ReadStatus, QStringList> i(msg_cache.m_cachedStatesRead);
|
||||||
|
@ -223,12 +206,6 @@ TtRssNetworkFactory* TtRssServiceRoot::network() const {
|
||||||
return m_network;
|
return m_network;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TtRssServiceRoot::saveAccountDataToDatabase() {
|
|
||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
|
||||||
|
|
||||||
DatabaseQueries::createOverwriteAccount(database, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TtRssServiceRoot::loadFromDatabase() {
|
void TtRssServiceRoot::loadFromDatabase() {
|
||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||||
Assignment categories = DatabaseQueries::getCategories<Category>(database, accountId());
|
Assignment categories = DatabaseQueries::getCategories<Category>(database, accountId());
|
||||||
|
|
|
@ -33,9 +33,7 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
virtual QString code() const;
|
virtual QString code() const;
|
||||||
virtual bool isSyncable() const;
|
virtual bool isSyncable() const;
|
||||||
virtual bool canBeEdited() const;
|
virtual bool canBeEdited() const;
|
||||||
virtual bool canBeDeleted() const;
|
|
||||||
virtual bool editViaGui();
|
virtual bool editViaGui();
|
||||||
virtual bool deleteViaGui();
|
|
||||||
virtual bool supportsFeedAdding() const;
|
virtual bool supportsFeedAdding() const;
|
||||||
virtual bool supportsCategoryAdding() const;
|
virtual bool supportsCategoryAdding() const;
|
||||||
virtual void addNewFeed(RootItem* selected_item, const QString& url = QString());
|
virtual void addNewFeed(RootItem* selected_item, const QString& url = QString());
|
||||||
|
@ -46,7 +44,6 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
// Access to network.
|
// Access to network.
|
||||||
TtRssNetworkFactory* network() const;
|
TtRssNetworkFactory* network() const;
|
||||||
|
|
||||||
void saveAccountDataToDatabase();
|
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
|
|
||||||
// Support for dynamic DB attributes.
|
// Support for dynamic DB attributes.
|
||||||
|
|
Loading…
Add table
Reference in a new issue