Switchable server-side update for TT-RSS.

This commit is contained in:
Martin Rotter 2015-12-15 09:13:35 +01:00
parent bd7c37dc66
commit e729ccb3bd
12 changed files with 86 additions and 44 deletions

View File

@ -29,6 +29,7 @@ CREATE TABLE IF NOT EXISTS TtRssAccounts (
auth_username TEXT, auth_username TEXT,
auth_password TEXT, auth_password TEXT,
url TEXT NOT NULL, url TEXT NOT NULL,
force_update INTEGER(1) NOT NULL CHECK (force_update >= 0 AND force_update <= 1) DEFAULT 0,
FOREIGN KEY (id) REFERENCES Accounts (id) FOREIGN KEY (id) REFERENCES Accounts (id)
); );
@ -62,7 +63,7 @@ CREATE TABLE IF NOT EXISTS Feeds (
username TEXT, username TEXT,
password TEXT, password TEXT,
update_type INTEGER(1) NOT NULL CHECK (update_type >= 0), update_type INTEGER(1) NOT NULL CHECK (update_type >= 0),
update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 5), update_interval INTEGER NOT NULL CHECK (update_interval >= 5) DEFAULT 15,
type INTEGER, type INTEGER,
account_id INTEGER NOT NULL, account_id INTEGER NOT NULL,
custom_id TEXT, custom_id TEXT,
@ -74,16 +75,16 @@ DROP TABLE IF EXISTS Messages;
-- ! -- !
CREATE TABLE IF NOT EXISTS Messages ( CREATE TABLE IF NOT EXISTS Messages (
id INTEGER AUTO_INCREMENT PRIMARY KEY, id INTEGER AUTO_INCREMENT PRIMARY KEY,
is_read INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_read >= 0 AND is_read <= 1), is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT 0,
is_deleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_deleted >= 0 AND is_deleted <= 1), is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT 0,
is_important INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_important >= 0 AND is_important <= 1), is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT 0 ,
feed TEXT NOT NULL, feed TEXT NOT NULL,
title TEXT NOT NULL CHECK (title != ''), title TEXT NOT NULL CHECK (title != ''),
url TEXT, url TEXT,
author TEXT, author TEXT,
date_created BIGINT NOT NULL CHECK (date_created != 0), date_created BIGINT NOT NULL CHECK (date_created != 0),
contents TEXT, contents TEXT,
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1), is_pdeleted INTEGER(1) NOT NULL CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1) DEFAULT 0 ,
enclosures TEXT, enclosures TEXT,
account_id INTEGER NOT NULL, account_id INTEGER NOT NULL,
custom_id TEXT, custom_id TEXT,

View File

@ -23,6 +23,7 @@ CREATE TABLE IF NOT EXISTS TtRssAccounts (
auth_username TEXT, auth_username TEXT,
auth_password TEXT, auth_password TEXT,
url TEXT NOT NULL, url TEXT NOT NULL,
force_update INTEGER(1) NOT NULL CHECK (force_update >= 0 AND force_update <= 1) DEFAULT 0,
FOREIGN KEY (id) REFERENCES Accounts (id) FOREIGN KEY (id) REFERENCES Accounts (id)
); );
@ -69,16 +70,16 @@ DROP TABLE IF EXISTS Messages;
-- ! -- !
CREATE TABLE IF NOT EXISTS Messages ( CREATE TABLE IF NOT EXISTS Messages (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT (0), is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT 0,
is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT (0), is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT 0,
is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT (0), is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT 0,
feed TEXT NOT NULL, feed TEXT NOT NULL,
title TEXT NOT NULL CHECK (title != ''), title TEXT NOT NULL CHECK (title != ''),
url TEXT, url TEXT,
author TEXT, author TEXT,
date_created INTEGER NOT NULL CHECK (date_created != 0), date_created INTEGER NOT NULL CHECK (date_created != 0),
contents TEXT, contents TEXT,
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1), is_pdeleted INTEGER(1) NOT NULL CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1) DEFAULT 0,
enclosures TEXT, enclosures TEXT,
account_id INTEGER NOT NULL, account_id INTEGER NOT NULL,
custom_id TEXT, custom_id TEXT,

View File

@ -15,12 +15,13 @@ CREATE TABLE TtRssAccounts (
auth_username TEXT, auth_username TEXT,
auth_password TEXT, auth_password TEXT,
url TEXT NOT NULL, url TEXT NOT NULL,
force_update INTEGER(1) NOT NULL CHECK (force_update >= 0 AND force_update <= 1) DEFAULT 0,
FOREIGN KEY (id) REFERENCES Accounts (id) FOREIGN KEY (id) REFERENCES Accounts (id)
); );
-- ! -- !
ALTER TABLE Messages ALTER TABLE Messages
ADD COLUMN account_id INTEGER NOT NULL DEFAULT (1); ADD COLUMN account_id INTEGER NOT NULL DEFAULT 1;
-- ! -- !
ALTER TABLE Messages ALTER TABLE Messages
ADD COLUMN custom_id TEXT; ADD COLUMN custom_id TEXT;
@ -38,7 +39,7 @@ ALTER TABLE Messages
MODIFY url TEXT; MODIFY url TEXT;
-- ! -- !
ALTER TABLE Feeds ALTER TABLE Feeds
ADD COLUMN account_id INTEGER NOT NULL DEFAULT (1); ADD COLUMN account_id INTEGER NOT NULL DEFAULT 1;
-- ! -- !
ALTER TABLE Feeds ALTER TABLE Feeds
ADD COLUMN custom_id TEXT; ADD COLUMN custom_id TEXT;
@ -56,7 +57,7 @@ ALTER TABLE Feeds
MODIFY type INTEGER; MODIFY type INTEGER;
-- ! -- !
ALTER TABLE Categories ALTER TABLE Categories
ADD COLUMN account_id INTEGER NOT NULL DEFAULT (1); ADD COLUMN account_id INTEGER NOT NULL DEFAULT 1;
-- ! -- !
ALTER TABLE Categories ALTER TABLE Categories
ADD COLUMN custom_id TEXT; ADD COLUMN custom_id TEXT;

View File

@ -15,6 +15,7 @@ CREATE TABLE TtRssAccounts (
auth_username TEXT, auth_username TEXT,
auth_password TEXT, auth_password TEXT,
url TEXT NOT NULL, url TEXT NOT NULL,
force_update INTEGER(1) NOT NULL CHECK (force_update >= 0 AND force_update <= 1) DEFAULT 0,
FOREIGN KEY (id) REFERENCES Accounts (id) FOREIGN KEY (id) REFERENCES Accounts (id)
); );
@ -25,16 +26,16 @@ DROP TABLE Messages;
-- ! -- !
CREATE TABLE Messages ( CREATE TABLE Messages (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT (0), is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT 0,
is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT (0), is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT 0,
is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT (0), is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT 0,
feed TEXT NOT NULL, feed TEXT NOT NULL,
title TEXT NOT NULL CHECK (title != ''), title TEXT NOT NULL CHECK (title != ''),
url TEXT, url TEXT,
author TEXT, author TEXT,
date_created INTEGER NOT NULL CHECK (date_created != 0), date_created INTEGER NOT NULL CHECK (date_created != 0),
contents TEXT, contents TEXT,
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1), is_pdeleted INTEGER(1) NOT NULL CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1) DEFAULT 0,
enclosures TEXT, enclosures TEXT,
account_id INTEGER NOT NULL, account_id INTEGER NOT NULL,
custom_id TEXT, custom_id TEXT,

View File

@ -59,9 +59,7 @@ void FormAddAccount::addSelectedAccount() {
m_model->addServiceAccount(new_root); m_model->addServiceAccount(new_root);
} }
else { else {
qApp->showGuiMessage(tr("Cannot add account"), qCritical("Cannot create new account.");
tr("Some critical error occurred, report this to developers."),
QSystemTrayIcon::Critical, parentWidget(), true);
} }
} }

View File

@ -42,12 +42,12 @@ FormEditAccount::FormEditAccount(QWidget *parent)
tr("No test done yet."), tr("No test done yet."),
tr("Here, results of connection test are shown.")); tr("Here, results of connection test are shown."));
setTabOrder(m_ui->m_txtUrl->lineEdit(), m_ui->m_txtUsername->lineEdit()); setTabOrder(m_ui->m_txtUrl->lineEdit(), m_ui->m_checkServerSideUpdate);
setTabOrder(m_ui->m_checkServerSideUpdate, m_ui->m_txtUsername->lineEdit());
setTabOrder(m_ui->m_txtUsername->lineEdit(), m_ui->m_txtPassword->lineEdit()); setTabOrder(m_ui->m_txtUsername->lineEdit(), m_ui->m_txtPassword->lineEdit());
setTabOrder(m_ui->m_txtPassword->lineEdit(), m_ui->m_checkShowPassword); setTabOrder(m_ui->m_txtPassword->lineEdit(), m_ui->m_checkShowPassword);
setTabOrder(m_ui->m_checkShowPassword, m_ui->m_gbHttpAuthentication); setTabOrder(m_ui->m_checkShowPassword, m_ui->m_gbHttpAuthentication);
setTabOrder(m_ui->m_gbHttpAuthentication, m_ui->m_txtHttpUsername->lineEdit()); setTabOrder(m_ui->m_gbHttpAuthentication, m_ui->m_txtHttpUsername->lineEdit());
setTabOrder(m_ui->m_txtHttpUsername->lineEdit(), m_ui->m_txtHttpPassword->lineEdit()); setTabOrder(m_ui->m_txtHttpUsername->lineEdit(), m_ui->m_txtHttpPassword->lineEdit());
setTabOrder(m_ui->m_txtHttpPassword->lineEdit(), m_ui->m_checkShowHttpPassword); setTabOrder(m_ui->m_txtHttpPassword->lineEdit(), m_ui->m_checkShowHttpPassword);
setTabOrder(m_ui->m_checkShowHttpPassword, m_ui->m_btnTestSetup); setTabOrder(m_ui->m_checkShowHttpPassword, m_ui->m_btnTestSetup);
@ -99,6 +99,7 @@ void FormEditAccount::execForEdit(TtRssServiceRoot *existing_root) {
m_ui->m_txtUsername->lineEdit()->setText(existing_root->network()->username()); m_ui->m_txtUsername->lineEdit()->setText(existing_root->network()->username());
m_ui->m_txtPassword->lineEdit()->setText(existing_root->network()->password()); m_ui->m_txtPassword->lineEdit()->setText(existing_root->network()->password());
m_ui->m_txtUrl->lineEdit()->setText(existing_root->network()->url()); m_ui->m_txtUrl->lineEdit()->setText(existing_root->network()->url());
m_ui->m_checkServerSideUpdate->setChecked(existing_root->network()->forceServerSideUpdate());
exec(); exec();
} }
@ -120,6 +121,7 @@ void FormEditAccount::performTest() {
factory.setAuthIsUsed(m_ui->m_gbHttpAuthentication->isChecked()); factory.setAuthIsUsed(m_ui->m_gbHttpAuthentication->isChecked());
factory.setAuthUsername(m_ui->m_txtHttpUsername->lineEdit()->text()); factory.setAuthUsername(m_ui->m_txtHttpUsername->lineEdit()->text());
factory.setAuthPassword(m_ui->m_txtHttpPassword->lineEdit()->text()); factory.setAuthPassword(m_ui->m_txtHttpPassword->lineEdit()->text());
factory.setForceServerSideUpdate(m_ui->m_checkServerSideUpdate->isChecked());
TtRssLoginResponse result = factory.login(); TtRssLoginResponse result = factory.login();
@ -179,6 +181,7 @@ void FormEditAccount::onClickedOk() {
m_editableRoot->network()->setAuthIsUsed(m_ui->m_gbHttpAuthentication->isChecked()); m_editableRoot->network()->setAuthIsUsed(m_ui->m_gbHttpAuthentication->isChecked());
m_editableRoot->network()->setAuthUsername(m_ui->m_txtHttpUsername->lineEdit()->text()); m_editableRoot->network()->setAuthUsername(m_ui->m_txtHttpUsername->lineEdit()->text());
m_editableRoot->network()->setAuthPassword(m_ui->m_txtHttpPassword->lineEdit()->text()); m_editableRoot->network()->setAuthPassword(m_ui->m_txtHttpPassword->lineEdit()->text());
m_editableRoot->network()->setForceServerSideUpdate(m_ui->m_checkServerSideUpdate->isChecked());
m_editableRoot->saveAccountDataToDatabase(); m_editableRoot->saveAccountDataToDatabase();
accept(); accept();

View File

@ -14,7 +14,7 @@
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="1" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="m_gbAuthentication"> <widget class="QGroupBox" name="m_gbAuthentication">
<property name="toolTip"> <property name="toolTip">
<string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string> <string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string>
@ -65,7 +65,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="m_gbHttpAuthentication"> <widget class="QGroupBox" name="m_gbHttpAuthentication">
<property name="toolTip"> <property name="toolTip">
<string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string> <string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string>
@ -80,7 +80,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>false</bool>
</property> </property>
<layout class="QFormLayout" name="formLayout_3"> <layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0"> <item row="0" column="0">
@ -119,7 +119,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<widget class="LabelWithStatus" name="m_lblTestResult" native="true"> <widget class="LabelWithStatus" name="m_lblTestResult" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
@ -132,7 +132,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="m_buttonBox"> <widget class="QDialogButtonBox" name="m_buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -159,13 +159,23 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QPushButton" name="m_btnTestSetup"> <widget class="QPushButton" name="m_btnTestSetup">
<property name="text"> <property name="text">
<string>&amp;Test setup</string> <string>&amp;Test setup</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="m_checkServerSideUpdate">
<property name="text">
<string>Force execution of server-side update when updating feeds from RSS Guard</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View File

@ -31,7 +31,7 @@
TtRssNetworkFactory::TtRssNetworkFactory() TtRssNetworkFactory::TtRssNetworkFactory()
: m_url(QString()), m_username(QString()), m_password(QString()), m_authIsUsed(false), : m_url(QString()), m_username(QString()), m_password(QString()), m_forceServerSideUpdate(false), m_authIsUsed(false),
m_authUsername(QString()), m_authPassword(QString()), m_sessionId(QString()), m_authUsername(QString()), m_authPassword(QString()), m_sessionId(QString()),
m_lastLoginTime(QDateTime()), m_lastError(QNetworkReply::NoError) { m_lastLoginTime(QDateTime()), m_lastError(QNetworkReply::NoError) {
} }
@ -145,14 +145,14 @@ TtRssGetFeedsCategoriesResponse TtRssNetworkFactory::getFeedsCategories() {
return result; return result;
} }
TtRssGetHeadlinesResponse TtRssNetworkFactory::getHeadlines(int feed_id, bool force_update, int limit, int skip, TtRssGetHeadlinesResponse TtRssNetworkFactory::getHeadlines(int feed_id, int limit, int skip,
bool show_content, bool include_attachments, bool show_content, bool include_attachments,
bool sanitize) { bool sanitize) {
QtJson::JsonObject json; QtJson::JsonObject json;
json["op"] = "getHeadlines"; json["op"] = "getHeadlines";
json["sid"] = m_sessionId; json["sid"] = m_sessionId;
json["feed_id"] = feed_id; json["feed_id"] = feed_id;
json["force_update"] = force_update; json["force_update"] = m_forceServerSideUpdate;
json["limit"] = limit; json["limit"] = limit;
json["skip"] = skip; json["skip"] = skip;
json["show_content"] = show_content; json["show_content"] = show_content;
@ -206,8 +206,16 @@ TtRssUpdateArticleResponse TtRssNetworkFactory::updateArticles(const QStringList
m_lastError = network_reply.first; m_lastError = network_reply.first;
return result; return result;
} }
bool TtRssNetworkFactory::authIsUsed() const
{ bool TtRssNetworkFactory::forceServerSideUpdate() const {
return m_forceServerSideUpdate;
}
void TtRssNetworkFactory::setForceServerSideUpdate(bool force_server_side_update) {
m_forceServerSideUpdate = force_server_side_update;
}
bool TtRssNetworkFactory::authIsUsed() const {
return m_authIsUsed; return m_authIsUsed;
} }

View File

@ -120,6 +120,10 @@ class TtRssNetworkFactory {
QString authPassword() const; QString authPassword() const;
void setAuthPassword(const QString &auth_password); void setAuthPassword(const QString &auth_password);
bool forceServerSideUpdate() const;
void setForceServerSideUpdate(bool force_server_side_update);
// Metadata. // Metadata.
QDateTime lastLoginTime() const; QDateTime lastLoginTime() const;
@ -137,7 +141,7 @@ class TtRssNetworkFactory {
TtRssGetFeedsCategoriesResponse getFeedsCategories(); TtRssGetFeedsCategoriesResponse getFeedsCategories();
// Gets headlines (messages) from the server. // Gets headlines (messages) from the server.
TtRssGetHeadlinesResponse getHeadlines(int feed_id, bool force_update, int limit, int skip, TtRssGetHeadlinesResponse getHeadlines(int feed_id, int limit, int skip,
bool show_content, bool include_attachments, bool show_content, bool include_attachments,
bool sanitize); bool sanitize);
@ -148,6 +152,7 @@ class TtRssNetworkFactory {
QString m_url; QString m_url;
QString m_username; QString m_username;
QString m_password; QString m_password;
bool m_forceServerSideUpdate;
bool m_authIsUsed; bool m_authIsUsed;
QString m_authUsername; QString m_authUsername;
QString m_authPassword; QString m_authPassword;

View File

@ -91,7 +91,7 @@ int TtRssFeed::update() {
int skip = 0; int skip = 0;
do { do {
TtRssGetHeadlinesResponse headlines = serviceRoot()->network()->getHeadlines(customId(), true, limit, skip, TtRssGetHeadlinesResponse headlines = serviceRoot()->network()->getHeadlines(customId(), limit, skip,
true, true, false); true, true, false);
if (serviceRoot()->network()->lastError() != QNetworkReply::NoError) { if (serviceRoot()->network()->lastError() != QNetworkReply::NoError) {

View File

@ -87,12 +87,12 @@ QList<ServiceRoot*> TtRssServiceEntryPoint::initializeSubtree() {
root->setAccountId(query.value(0).toInt()); root->setAccountId(query.value(0).toInt());
root->network()->setUsername(query.value(1).toString()); root->network()->setUsername(query.value(1).toString());
root->network()->setPassword(TextFactory::decrypt(query.value(2).toString())); root->network()->setPassword(TextFactory::decrypt(query.value(2).toString()));
root->network()->setAuthIsUsed(query.value(3).toBool()); root->network()->setAuthIsUsed(query.value(3).toBool());
root->network()->setAuthUsername(query.value(4).toString()); root->network()->setAuthUsername(query.value(4).toString());
root->network()->setAuthPassword(TextFactory::decrypt(query.value(5).toString())); root->network()->setAuthPassword(TextFactory::decrypt(query.value(5).toString()));
root->network()->setUrl(query.value(6).toString()); root->network()->setUrl(query.value(6).toString());
root->network()->setForceServerSideUpdate(query.value(7).toBool());
root->updateTitle(); root->updateTitle();
roots.append(root); roots.append(root);
} }

View File

@ -426,7 +426,7 @@ void TtRssServiceRoot::saveAccountDataToDatabase() {
query.prepare("UPDATE TtRssAccounts " query.prepare("UPDATE TtRssAccounts "
"SET username = :username, password = :password, url = :url, auth_protected = :auth_protected, " "SET username = :username, password = :password, url = :url, auth_protected = :auth_protected, "
"auth_username = :auth_username, auth_password = :auth_password " "auth_username = :auth_username, auth_password = :auth_password, force_update = :force_update "
"WHERE id = :id;"); "WHERE id = :id;");
query.bindValue(QSL(":username"), m_network->username()); query.bindValue(QSL(":username"), m_network->username());
query.bindValue(QSL(":password"), TextFactory::encrypt(m_network->password())); query.bindValue(QSL(":password"), TextFactory::encrypt(m_network->password()));
@ -434,6 +434,7 @@ void TtRssServiceRoot::saveAccountDataToDatabase() {
query.bindValue(QSL(":auth_protected"), m_network->authIsUsed()); query.bindValue(QSL(":auth_protected"), m_network->authIsUsed());
query.bindValue(QSL(":auth_username"), m_network->authUsername()); query.bindValue(QSL(":auth_username"), m_network->authUsername());
query.bindValue(QSL(":auth_password"), TextFactory::encrypt(m_network->authPassword())); query.bindValue(QSL(":auth_password"), TextFactory::encrypt(m_network->authPassword()));
query.bindValue(QSL(":force_update"), m_network->forceServerSideUpdate());
query.bindValue(QSL(":id"), accountId()); query.bindValue(QSL(":id"), accountId());
if (query.exec()) { if (query.exec()) {
@ -452,13 +453,26 @@ void TtRssServiceRoot::saveAccountDataToDatabase() {
} }
int id_to_assign = query.value(0).toInt() + 1; int id_to_assign = query.value(0).toInt() + 1;
bool saved = true;
bool saved = query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assign), query.prepare(QSL("INSERT INTO Accounts (id, type) VALUES (:id, :type);"));
SERVICE_CODE_TT_RSS)) && query.bindValue(QSL(":id"), id_to_assign);
query.exec(QString("INSERT INTO TtRssAccounts (id, username, password, url) VALUES (%1, '%2', '%3', '%4');").arg(QString::number(id_to_assign), query.bindValue(QSL(":type"), SERVICE_CODE_TT_RSS);
network()->username(),
network()->password(), saved &= query.exec();
network()->url()));
query.prepare("INSERT INTO TtRssAccounts (id, username, password, auth_protected, auth_username, auth_password, url, force_update) "
"VALUES (:id, :username, :password, :auth_protected, :auth_username, :auth_password, :url, :force_update);");
query.bindValue(QSL(":id"), id_to_assign);
query.bindValue(QSL(":username"), m_network->username());
query.bindValue(QSL(":password"), TextFactory::encrypt(m_network->password()));
query.bindValue(QSL(":auth_protected"), m_network->authIsUsed());
query.bindValue(QSL(":auth_username"), m_network->authUsername());
query.bindValue(QSL(":auth_password"), TextFactory::encrypt(m_network->authPassword()));
query.bindValue(QSL(":url"), m_network->url());
query.bindValue(QSL(":force_update"), m_network->forceServerSideUpdate());
saved &= query.exec();
if (saved) { if (saved) {
setId(id_to_assign); setId(id_to_assign);