Skip to content

Commit

Permalink
Add sql for #265.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Rotter committed Feb 2, 2021
1 parent d3cf130 commit 7bef56b
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 17 deletions.
2 changes: 1 addition & 1 deletion resources/desktop/com.github.rssguard.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<url type="donation">https://martinrotter.github.io/donate/</url>
<content_rating type="oars-1.1" />
<releases>
<release version="3.8.4" date="2021-02-01"/>
<release version="3.8.4" date="2021-02-02"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>
Expand Down
2 changes: 2 additions & 0 deletions resources/sql.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<file>sql/db_update_mysql_16_17.sql</file>
<file>sql/db_update_mysql_17_18.sql</file>
<file>sql/db_update_mysql_18_19.sql</file>
<file>sql/db_update_mysql_19_20.sql</file>

<file>sql/db_init_sqlite.sql</file>
<file>sql/db_update_sqlite_1_2.sql</file>
Expand All @@ -39,5 +40,6 @@
<file>sql/db_update_sqlite_16_17.sql</file>
<file>sql/db_update_sqlite_17_18.sql</file>
<file>sql/db_update_sqlite_18_19.sql</file>
<file>sql/db_update_sqlite_19_20.sql</file>
</qresource>
</RCC>
4 changes: 3 additions & 1 deletion resources/sql/db_init_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS Information (
inf_value TEXT NOT NULL
);
-- !
INSERT INTO Information VALUES (1, 'schema_version', '19');
INSERT INTO Information VALUES (1, 'schema_version', '20');
-- !
CREATE TABLE IF NOT EXISTS Accounts (
id INTEGER AUTO_INCREMENT PRIMARY KEY,
Expand Down Expand Up @@ -110,7 +110,9 @@ CREATE TABLE IF NOT EXISTS Feeds (
icon BLOB,
category INTEGER NOT NULL CHECK (category >= -1),
encoding TEXT,
source_type INTEGER,
url VARCHAR(1000),
post_process TEXT,
protected INTEGER(1) NOT NULL CHECK (protected >= 0 AND protected <= 1),
username TEXT,
password TEXT,
Expand Down
4 changes: 3 additions & 1 deletion resources/sql/db_init_sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS Information (
inf_value TEXT NOT NULL
);
-- !
INSERT INTO Information VALUES (1, 'schema_version', '19');
INSERT INTO Information VALUES (1, 'schema_version', '20');
-- !
CREATE TABLE IF NOT EXISTS Accounts (
id INTEGER PRIMARY KEY,
Expand Down Expand Up @@ -104,7 +104,9 @@ CREATE TABLE IF NOT EXISTS Feeds (
icon BLOB,
category INTEGER NOT NULL CHECK (category >= -1),
encoding TEXT,
source_type INTEGER,
url TEXT,
post_process TEXT,
protected INTEGER(1) NOT NULL CHECK (protected >= 0 AND protected <= 1),
username TEXT,
password TEXT,
Expand Down
33 changes: 33 additions & 0 deletions resources/sql/db_update_mysql_19_20.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CREATE TABLE backup_feeds AS SELECT * FROM Feeds;
-- !
DROP TABLE Feeds;
-- !
CREATE TABLE IF NOT EXISTS Feeds (
id INTEGER AUTO_INCREMENT PRIMARY KEY,
title TEXT NOT NULL CHECK (title != ''),
description TEXT,
date_created BIGINT,
icon BLOB,
category INTEGER NOT NULL CHECK (category >= -1),
encoding TEXT,
source_type INTEGER,
url VARCHAR(1000),
post_process TEXT,
protected INTEGER(1) NOT NULL CHECK (protected >= 0 AND protected <= 1),
username TEXT,
password TEXT,
update_type INTEGER(1) NOT NULL CHECK (update_type >= 0),
update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 3),
type INTEGER,
account_id INTEGER NOT NULL,
custom_id TEXT,

FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
INSERT INTO Feeds (id, title, description, date_created, icon, category, encoding, url, protected, username, password, update_type, update_interval, type, account_id, custom_id)
SELECT id, title, description, date_created, icon, category, encoding, url, protected, username, password, update_type, update_interval, type, account_id, custom_id FROM backup_feeds;
-- !
DROP TABLE backup_feeds;
-- !
UPDATE Information SET inf_value = '20' WHERE inf_key = 'schema_version';
33 changes: 33 additions & 0 deletions resources/sql/db_update_sqlite_19_20.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CREATE TABLE backup_feeds AS SELECT * FROM Feeds;
-- !
DROP TABLE Feeds;
-- !
CREATE TABLE IF NOT EXISTS Feeds (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL CHECK (title != ''),
description TEXT,
date_created INTEGER,
icon BLOB,
category INTEGER NOT NULL CHECK (category >= -1),
encoding TEXT,
source_type INTEGER,
url TEXT,
post_process TEXT,
protected INTEGER(1) NOT NULL CHECK (protected >= 0 AND protected <= 1),
username TEXT,
password TEXT,
update_type INTEGER(1) NOT NULL CHECK (update_type >= 0),
update_interval INTEGER NOT NULL CHECK (update_interval >= 3) DEFAULT 15,
type INTEGER,
account_id INTEGER NOT NULL,
custom_id TEXT,

FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
INSERT INTO Feeds (id, title, description, date_created, icon, category, encoding, url, protected, username, password, update_type, update_interval, type, account_id, custom_id)
SELECT id, title, description, date_created, icon, category, encoding, url, protected, username, password, update_type, update_interval, type, account_id, custom_id FROM backup_feeds;
-- !
DROP TABLE backup_feeds;
-- !
UPDATE Information SET inf_value = '20' WHERE inf_key = 'schema_version';
22 changes: 12 additions & 10 deletions src/librssguard/definitions/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
#define APP_DB_SQLITE_FILE "database.db"

// Keep this in sync with schema versions declared in SQL initialization code.
#define APP_DB_SCHEMA_VERSION "19"
#define APP_DB_SCHEMA_VERSION "20"
#define APP_DB_UPDATE_FILE_PATTERN "db_update_%1_%2_%3.sql"
#define APP_DB_COMMENT_SPLIT "-- !\n"
#define APP_DB_NAME_PLACEHOLDER "##"
Expand Down Expand Up @@ -207,15 +207,17 @@
#define FDS_DB_ICON_INDEX 4
#define FDS_DB_CATEGORY_INDEX 5
#define FDS_DB_ENCODING_INDEX 6
#define FDS_DB_URL_INDEX 7
#define FDS_DB_PROTECTED_INDEX 8
#define FDS_DB_USERNAME_INDEX 9
#define FDS_DB_PASSWORD_INDEX 10
#define FDS_DB_UPDATE_TYPE_INDEX 11
#define FDS_DB_UPDATE_INTERVAL_INDEX 12
#define FDS_DB_TYPE_INDEX 13
#define FDS_DB_ACCOUNT_ID_INDEX 14
#define FDS_DB_CUSTOM_ID_INDEX 15
#define FDS_DB_SOURCE_TYPE_INDEX 7
#define FDS_DB_URL_INDEX 8
#define FDS_DB_POST_PROCESS 9
#define FDS_DB_PROTECTED_INDEX 10
#define FDS_DB_USERNAME_INDEX 11
#define FDS_DB_PASSWORD_INDEX 12
#define FDS_DB_UPDATE_TYPE_INDEX 13
#define FDS_DB_UPDATE_INTERVAL_INDEX 14
#define FDS_DB_TYPE_INDEX 15
#define FDS_DB_ACCOUNT_ID_INDEX 16
#define FDS_DB_CUSTOM_ID_INDEX 17

// Indexes of columns for feed models.
#define FDS_MODEL_TITLE_INDEX 0
Expand Down
2 changes: 1 addition & 1 deletion src/librssguard/services/gmail/gui/formaddeditemail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void FormAddEditEmail::onOkClicked() {
.arg(QString(m_ui.m_txtSubject->text().toUtf8().toBase64(QByteArray::Base64Option::Base64UrlEncoding)))
.toStdString();
msg.set_plain(m_ui.m_txtMessage->toPlainText().toStdString());
msg.set_header("Content-Type", "text/plain; charset=utf-8");
msg.set_header(HTTP_HEADERS_CONTENT_TYPE, "text/plain; charset=utf-8");

try {
m_root->network()->sendEmail(msg, m_root->networkProxy(), m_originalMessage);
Expand Down
4 changes: 2 additions & 2 deletions src/librssguard/services/greader/greadernetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ QNetworkReply::NetworkError GreaderNetwork::editLabels(const QString& state,
output,
QNetworkAccessManager::Operation::PostOperation,
{ authHeader(),
{ QSL("Content-Type").toLocal8Bit(),
{ QSL(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(),
QSL("application/x-www-form-urlencoded").toLocal8Bit() } },
false,
{},
Expand Down Expand Up @@ -425,7 +425,7 @@ QString GreaderNetwork::serviceToString(GreaderServiceRoot::Service service) {
}

QPair<QByteArray, QByteArray> GreaderNetwork::authHeader() const {
return { QSL("Authorization").toLocal8Bit(), QSL("GoogleLogin auth=%1").arg(m_authAuth).toLocal8Bit() };
return { QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), QSL("GoogleLogin auth=%1").arg(m_authAuth).toLocal8Bit() };
}

bool GreaderNetwork::ensureLogin(const QNetworkProxy& proxy, QNetworkReply::NetworkError* output) {
Expand Down
14 changes: 13 additions & 1 deletion src/librssguard/services/standard/standardfeed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ StandardFeed::StandardFeed(RootItem* parent_item)
: Feed(parent_item) {
m_networkError = QNetworkReply::NetworkError::NoError;
m_type = Type::Rss0X;
m_sourceType = SourceType::Url;
m_encoding = QString();
}

StandardFeed::StandardFeed(const StandardFeed& other)
: Feed(other) {
m_networkError = other.networkError();
m_type = other.type();
m_sourceType = other.sourceType();
m_encoding = other.encoding();
}

Expand Down Expand Up @@ -139,6 +141,14 @@ void StandardFeed::fetchMetadataForItself() {
}
}

StandardFeed::SourceType StandardFeed::sourceType() const {
return m_sourceType;
}

void StandardFeed::setSourceType(const SourceType& source_type) {
m_sourceType = source_type;
}

QPair<StandardFeed*, QNetworkReply::NetworkError> StandardFeed::guessFeed(const QString& url,
const QString& username,
const QString& password,
Expand Down Expand Up @@ -406,6 +416,7 @@ bool StandardFeed::editItself(StandardFeed* new_feed_data) {
original_feed->setAutoUpdateType(new_feed_data->autoUpdateType());
original_feed->setAutoUpdateInitialInterval(new_feed_data->autoUpdateInitialInterval());
original_feed->setType(new_feed_data->type());
original_feed->setSourceType(new_feed_data->sourceType());

// Editing is done.
return true;
Expand Down Expand Up @@ -506,6 +517,7 @@ QNetworkReply::NetworkError StandardFeed::networkError() const {

StandardFeed::StandardFeed(const QSqlRecord& record) : Feed(record) {
setEncoding(record.value(FDS_DB_ENCODING_INDEX).toString());
setSourceType(SourceType(record.value(FDS_DB_SOURCE_TYPE_INDEX).toInt()));

StandardFeed::Type type = static_cast<StandardFeed::Type>(record.value(FDS_DB_TYPE_INDEX).toInt());

Expand All @@ -520,5 +532,5 @@ StandardFeed::StandardFeed(const QSqlRecord& record) : Feed(record) {
}
}

m_networkError = QNetworkReply::NoError;
m_networkError = QNetworkReply::NetworkError::NoError;
}
10 changes: 10 additions & 0 deletions src/librssguard/services/standard/standardfeed.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class StandardFeed : public Feed {
Q_OBJECT

public:
enum class SourceType {
Url = 0,
Script = 1,
LocalFile = 2
};

enum class Type {
Rss0X = 0,
Rss2X = 1,
Expand Down Expand Up @@ -59,6 +65,9 @@ class StandardFeed : public Feed {
Type type() const;
void setType(Type type);

SourceType sourceType() const;
void setSourceType(const SourceType& source_type);

QString encoding() const;
void setEncoding(const QString& encoding);

Expand All @@ -83,6 +92,7 @@ class StandardFeed : public Feed {
void fetchMetadataForItself();

private:
SourceType m_sourceType;
Type m_type;

QNetworkReply::NetworkError m_networkError;
Expand Down

0 comments on commit 7bef56b

Please sign in to comment.