Initial implementation of password-protected feeds.
This commit is contained in:
parent
c8991206e3
commit
e39c2e62cc
@ -1,8 +1,8 @@
|
||||
DROP TABLE IF EXISTS Information;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Information (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
-- !
|
||||
INSERT INTO Information VALUES ('schema_version', '0.0.1');
|
||||
@ -10,13 +10,13 @@ INSERT INTO Information VALUES ('schema_version', '0.0.1');
|
||||
DROP TABLE IF EXISTS Categories;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Categories (
|
||||
id INTEGER PRIMARY KEY,
|
||||
parent_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL UNIQUE CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
icon BLOB,
|
||||
type INTEGER NOT NULL,
|
||||
id INTEGER PRIMARY KEY,
|
||||
parent_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL UNIQUE CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
icon BLOB,
|
||||
type INTEGER NOT NULL,
|
||||
|
||||
FOREIGN KEY (parent_id) REFERENCES Categories (id)
|
||||
);
|
||||
@ -24,23 +24,26 @@ CREATE TABLE IF NOT EXISTS Categories (
|
||||
DROP TABLE IF EXISTS Feeds;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Feeds (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
icon BLOB,
|
||||
category INTEGER NOT NULL CHECK (category >= -1),
|
||||
encoding TEXT NOT NULL CHECK (encoding != ''),
|
||||
url TEXT NOT NULL UNIQUE CHECK (url != ''),
|
||||
type INTEGER NOT NULL CHECK (type >= 0)
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
icon BLOB,
|
||||
category INTEGER NOT NULL CHECK (category >= -1),
|
||||
encoding TEXT NOT NULL CHECK (encoding != ''),
|
||||
url TEXT NOT NULL UNIQUE CHECK (url != ''),
|
||||
protected INTEGER(1) NOT NULL CHECK (protected >= 0 AND protected <= 1),
|
||||
username TEXT,
|
||||
password TEXT,
|
||||
type INTEGER NOT NULL CHECK (type >= 0)
|
||||
);
|
||||
-- !
|
||||
DROP TABLE IF EXISTS FeedsData;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS FeedsData (
|
||||
feed_id INTEGER NOT NULL,
|
||||
key TEXT NOT NULL,
|
||||
value TEXT,
|
||||
feed_id INTEGER NOT NULL,
|
||||
key TEXT NOT NULL,
|
||||
value TEXT,
|
||||
|
||||
PRIMARY KEY (feed_id, key),
|
||||
FOREIGN KEY (feed_id) REFERENCES Feeds (id)
|
||||
@ -49,16 +52,16 @@ CREATE TABLE IF NOT EXISTS FeedsData (
|
||||
DROP TABLE IF EXISTS Messages;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Messages (
|
||||
id INTEGER PRIMARY KEY,
|
||||
read INTEGER(1) NOT NULL CHECK (read >= 0 AND read <= 1) DEFAULT (0),
|
||||
deleted INTEGER(1) NOT NULL CHECK (deleted >= 0 AND deleted <= 1) DEFAULT (0),
|
||||
important INTEGER(1) NOT NULL CHECK (important >= 0 AND important <= 1) DEFAULT (0),
|
||||
feed INTEGER NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT,
|
||||
author TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
contents TEXT,
|
||||
id INTEGER PRIMARY KEY,
|
||||
read INTEGER(1) NOT NULL CHECK (read >= 0 AND read <= 1) DEFAULT (0),
|
||||
deleted INTEGER(1) NOT NULL CHECK (deleted >= 0 AND deleted <= 1) DEFAULT (0),
|
||||
important INTEGER(1) NOT NULL CHECK (important >= 0 AND important <= 1) DEFAULT (0),
|
||||
feed INTEGER NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT,
|
||||
author TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
contents TEXT,
|
||||
|
||||
FOREIGN KEY (feed) REFERENCES Feeds (id)
|
||||
);
|
||||
@ -67,14 +70,14 @@ INSERT INTO Categories (id, parent_id, title, description, date_created, type, i
|
||||
-- !
|
||||
INSERT INTO Categories (id, parent_id, title, description, date_created, type, icon) VALUES (2, -1, 'RSS Guard', 'News and updates on RSS Guard.', 1388678961000, 0, 'AAAAIgBRAFAAaQB4AG0AYQBwAEkAYwBvAG4ARQBuAGcAaQBuAGUAAAABAAAAAYlQTkcNChoKAAAADUlIRFIAAABAAAAAQAgGAAAAqmlx3gAAAAlwSFlzAAAOxAAADsQBlSsOGwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxMS0wNy0yOVQxNToxOTo1MCswMzowMMnGKbgAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTEtMDctMjlUMTU6MTg6MzcrMDM6MDBUkc0zAAAHP0lEQVR4nO1bzW4byRGu6u6RhqRImiJlErQBWQgPWgJrR9cY2D3swTDyBntIgN08RE55gCB5gzxA7jn5sMcA0cJGYishEIRrQ7sytdFfRIW0VsPpqhw0Qw+H3UOO5RVHm/2AAcmZ/qmqrv66qtkD8CP+v4FzPMc5ysXBkSvTSFJM1ut1t1gs5jc3N6u5XM5J0a5++fLlwbNnz04BwL+ijN8rlOW+qFar+XK5XHv48OGnlUrll4hYRMSZI8rMCACj27dv/1Ep9fvt7e0jANDvVer3CKMB2u22Ojw8LFQqlc1CofArrfU95nTe7DjO561W6+n29vafAOA7yOh0MBpgOBwKIYQLAFUiKvu+D2kNoJRaLRaLnz548ODPz58//zcs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uAHQAcwAvAFAAcgBvAGoAZQBrAHQAeQAvAHIAcwBzAGcAdQBhAHIAZAAtAGIAdQBpAGwAZAAvAGkAYwBvAG4AcwAvAG0AaQBuAGkALQBrAGYAYQBlAG4AegBhAC8AZgBvAGwAZABlAHIALQBiAGwAYQBjAGsALgBwAG4AZwAAAEAAAABAAAAAAAAAAAE=');
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, type) VALUES ('Linux Today', 'Linux Today - Linux News on Internet Time.', 1388678961000, 1, 'UTF-8', 'http://feeds.feedburner.com/linuxtoday/linux?format=xml', 1);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('Linux Today', 'Linux Today - Linux News on Internet Time.', 1388678961000, 1, 'UTF-8', 'http://feeds.feedburner.com/linuxtoday/linux?format=xml', 0, 1);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, type) VALUES ('LinuxInsider', 'LinuxInsider: Linux News & Information from Around the World.', 1388678961000, 1, 'UTF-8', 'http://www.linuxinsider.com/perl/syndication/rssfull.pl', 2);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('LinuxInsider', 'LinuxInsider: Linux News & Information from Around the World.', 1388678961000, 1, 'UTF-8', 'http://www.linuxinsider.com/perl/syndication/rssfull.pl', 0, 2);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, type) VALUES ('LXer: Linux News', 'The world is talking about GNU/Linux and Free/Open Source Software.', 1388678961000, 1, 'UTF-8', 'http://lxer.com/module/newswire/headlines.rss', 2);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('LXer: Linux News', 'The world is talking about GNU/Linux and Free/Open Source Software.', 1388678961000, 1, 'UTF-8', 'http://lxer.com/module/newswire/headlines.rss', 0, 2);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, type) VALUES ('Recent Commits', 'Recent commits for RSS Guard project.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter/rssguard/commits/master.atom', 3);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('Recent Commits', 'Recent commits for RSS Guard project.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter/rssguard/commits/master.atom', 0, 3);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, type) VALUES ('Releases', 'Releases for RSS Guard.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter/rssguard/releases.atom', 3);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('Releases', 'Releases for RSS Guard.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter/rssguard/releases.atom', 0, 3);
|
||||
-- !
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, type) VALUES ('Author''s Activity', 'RSS Guard author public activity overview.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter.atom', 3);
|
||||
INSERT INTO Feeds (title, description, date_created, category, encoding, url, protected, type) VALUES ('Author''s Activity', 'RSS Guard author public activity overview.', 1388678961000, 2, 'UTF-8', 'https://github.com/martinrotter.atom', 0, 3);
|
@ -1,20 +1,22 @@
|
||||
DROP TABLE IF EXISTS Information;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Information (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
-- !
|
||||
INSERT INTO Information VALUES ('schema_version', '0.0.1');
|
||||
-- !
|
||||
DROP TABLE IF EXISTS Categories;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Categories (
|
||||
id INTEGER PRIMARY KEY,
|
||||
parent_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL UNIQUE CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
icon BLOB,
|
||||
type INTEGER NOT NULL,
|
||||
id INTEGER PRIMARY KEY,
|
||||
parent_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL UNIQUE CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
icon BLOB,
|
||||
type INTEGER NOT NULL,
|
||||
|
||||
FOREIGN KEY (parent_id) REFERENCES Categories (id)
|
||||
);
|
||||
@ -22,23 +24,26 @@ CREATE TABLE IF NOT EXISTS Categories (
|
||||
DROP TABLE IF EXISTS Feeds;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Feeds (
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
icon BLOB,
|
||||
category INTEGER NOT NULL CHECK (category >= -1),
|
||||
encoding TEXT NOT NULL CHECK (encoding != ''),
|
||||
url TEXT NOT NULL UNIQUE CHECK (url != ''),
|
||||
type INTEGER NOT NULL CHECK (type >= 0)
|
||||
id INTEGER PRIMARY KEY,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
description TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
icon BLOB,
|
||||
category INTEGER NOT NULL CHECK (category >= -1),
|
||||
encoding TEXT NOT NULL CHECK (encoding != ''),
|
||||
url TEXT NOT NULL UNIQUE CHECK (url != ''),
|
||||
protected INTEGER(1) NOT NULL CHECK (protected >= 0 AND protected <= 1),
|
||||
username TEXT,
|
||||
password TEXT,
|
||||
type INTEGER NOT NULL CHECK (type >= 0)
|
||||
);
|
||||
-- !
|
||||
DROP TABLE IF EXISTS FeedsData;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS FeedsData (
|
||||
feed_id INTEGER NOT NULL,
|
||||
key TEXT NOT NULL,
|
||||
value TEXT,
|
||||
feed_id INTEGER NOT NULL,
|
||||
key TEXT NOT NULL,
|
||||
value TEXT,
|
||||
|
||||
PRIMARY KEY (feed_id, key),
|
||||
FOREIGN KEY (feed_id) REFERENCES Feeds (id)
|
||||
@ -47,16 +52,16 @@ CREATE TABLE IF NOT EXISTS FeedsData (
|
||||
DROP TABLE IF EXISTS Messages;
|
||||
-- !
|
||||
CREATE TABLE IF NOT EXISTS Messages (
|
||||
id INTEGER PRIMARY KEY,
|
||||
read INTEGER(1) NOT NULL CHECK (read >= 0 AND read <= 1) DEFAULT (0),
|
||||
deleted INTEGER(1) NOT NULL CHECK (deleted >= 0 AND deleted <= 1) DEFAULT (0),
|
||||
important INTEGER(1) NOT NULL CHECK (important >= 0 AND important <= 1) DEFAULT (0),
|
||||
feed INTEGER NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT,
|
||||
author TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
contents TEXT,
|
||||
id INTEGER PRIMARY KEY,
|
||||
read INTEGER(1) NOT NULL CHECK (read >= 0 AND read <= 1) DEFAULT (0),
|
||||
deleted INTEGER(1) NOT NULL CHECK (deleted >= 0 AND deleted <= 1) DEFAULT (0),
|
||||
important INTEGER(1) NOT NULL CHECK (important >= 0 AND important <= 1) DEFAULT (0),
|
||||
feed INTEGER NOT NULL,
|
||||
title TEXT NOT NULL CHECK (title != ''),
|
||||
url TEXT,
|
||||
author TEXT,
|
||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||
contents TEXT,
|
||||
|
||||
FOREIGN KEY (feed) REFERENCES Feeds (id)
|
||||
);
|
@ -96,9 +96,10 @@
|
||||
#define FDS_DB_CATEGORY_INDEX 5
|
||||
#define FDS_DB_ENCODING_INDEX 6
|
||||
#define FDS_DB_URL_INDEX 7
|
||||
#define FDS_DB_TYPE_INDEX 8
|
||||
//#define FDS_DB_LANGUAGE_INDEX 8
|
||||
//#define FDS_DB_TYPE_INDEX 9
|
||||
#define FDS_DB_PROTECTED_INDEX 8
|
||||
#define FDS_DB_USERNAME_INDEX 9
|
||||
#define FDS_DB_PASSWORD_INDEX 10
|
||||
#define FDS_DB_TYPE_INDEX 11
|
||||
|
||||
// Indexes of columns for feed models.
|
||||
#define FDS_MODEL_TITLE_INDEX 0
|
||||
|
@ -274,8 +274,8 @@ bool FeedsModel::addStandardFeed(FeedsModelStandardFeed *feed,
|
||||
|
||||
query_add_feed.setForwardOnly(true);
|
||||
query_add_feed.prepare("INSERT INTO Feeds "
|
||||
"(title, description, date_created, icon, category, encoding, url, type) "
|
||||
"VALUES (:title, :description, :date_created, :icon, :category, :encoding, :url, :type);");
|
||||
"(title, description, date_created, icon, category, encoding, url, protected, username, password, type) "
|
||||
"VALUES (:title, :description, :date_created, :icon, :category, :encoding, :url, :protected, :username, :password, :type);");
|
||||
query_add_feed.bindValue(":title", feed->title());
|
||||
query_add_feed.bindValue(":description", feed->description());
|
||||
query_add_feed.bindValue(":date_created", feed->creationDate().toMSecsSinceEpoch());
|
||||
@ -283,6 +283,9 @@ bool FeedsModel::addStandardFeed(FeedsModelStandardFeed *feed,
|
||||
query_add_feed.bindValue(":category", parent->id());
|
||||
query_add_feed.bindValue(":encoding", feed->encoding());
|
||||
query_add_feed.bindValue(":url", feed->url());
|
||||
query_add_feed.bindValue(":protected", (int) feed->passwordProtected());
|
||||
query_add_feed.bindValue(":username", feed->username());
|
||||
query_add_feed.bindValue(":password", feed->password());
|
||||
query_add_feed.bindValue(":type", (int) FeedsModelCategory::Standard);
|
||||
|
||||
if (!query_add_feed.exec()) {
|
||||
@ -321,7 +324,7 @@ bool FeedsModel::editStandardFeed(FeedsModelStandardFeed *original_feed,
|
||||
|
||||
query_update_feed.setForwardOnly(true);
|
||||
query_update_feed.prepare("UPDATE Feeds "
|
||||
"SET title = :title, description = :description, icon = :icon, category = :category, encoding = :encoding, url = :url, type = :type "
|
||||
"SET title = :title, description = :description, icon = :icon, category = :category, encoding = :encoding, url = :url, protected = :protected, username = :username, password = :password, type = :type "
|
||||
"WHERE id = :id;");
|
||||
query_update_feed.bindValue(":title", new_feed->title());
|
||||
query_update_feed.bindValue(":description", new_feed->description());
|
||||
@ -329,10 +332,15 @@ bool FeedsModel::editStandardFeed(FeedsModelStandardFeed *original_feed,
|
||||
query_update_feed.bindValue(":category", new_parent->id());
|
||||
query_update_feed.bindValue(":encoding", new_feed->encoding());
|
||||
query_update_feed.bindValue(":url", new_feed->url());
|
||||
query_update_feed.bindValue(":protected", (int) new_feed->passwordProtected());
|
||||
query_update_feed.bindValue(":username", new_feed->username());
|
||||
query_update_feed.bindValue(":password", new_feed->password());
|
||||
query_update_feed.bindValue(":type", new_feed->type());
|
||||
query_update_feed.bindValue(":id", original_feed->id());
|
||||
|
||||
if (!query_update_feed.exec()) {
|
||||
QString aaa = query_update_feed.lastError().databaseText();
|
||||
|
||||
// Persistent storage update failed, no way to continue now.
|
||||
return false;
|
||||
}
|
||||
@ -344,6 +352,9 @@ bool FeedsModel::editStandardFeed(FeedsModelStandardFeed *original_feed,
|
||||
original_feed->setEncoding(new_feed->encoding());
|
||||
original_feed->setDescription(new_feed->description());
|
||||
original_feed->setUrl(new_feed->url());
|
||||
original_feed->setPasswordProtected(new_feed->passwordProtected());
|
||||
original_feed->setUsername(new_feed->username());
|
||||
original_feed->setPassword(new_feed->password());
|
||||
original_feed->setType(new_feed->type());
|
||||
|
||||
if (original_parent != new_parent) {
|
||||
|
@ -67,3 +67,6 @@ void FeedsModelFeed::updateCounts(bool including_total_count) {
|
||||
m_unreadCount = query_all.value(0).toInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -48,6 +48,30 @@ class FeedsModelFeed : public FeedsModelRootItem {
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
inline bool passwordProtected() const {
|
||||
return m_passwordProtected;
|
||||
}
|
||||
|
||||
inline void setPasswordProtected(bool passwordProtected) {
|
||||
m_passwordProtected = passwordProtected;
|
||||
}
|
||||
|
||||
inline QString username() const {
|
||||
return m_username;
|
||||
}
|
||||
|
||||
inline void setUsername(const QString &username) {
|
||||
m_username = username;
|
||||
}
|
||||
|
||||
inline QString password() const {
|
||||
return m_password;
|
||||
}
|
||||
|
||||
inline void setPassword(const QString &password) {
|
||||
m_password = password;
|
||||
}
|
||||
|
||||
// Converts particular feed type to string.
|
||||
static QString typeToString(Type type);
|
||||
|
||||
@ -56,6 +80,10 @@ class FeedsModelFeed : public FeedsModelRootItem {
|
||||
void updateCounts(bool including_total_count = true);
|
||||
|
||||
protected:
|
||||
bool m_passwordProtected;
|
||||
QString m_username;
|
||||
QString m_password;
|
||||
|
||||
Type m_type;
|
||||
int m_totalCount;
|
||||
int m_unreadCount;
|
||||
|
@ -32,6 +32,9 @@ FeedsModelStandardFeed *FeedsModelStandardFeed::loadFromRecord(const QSqlRecord
|
||||
feed->setIcon(IconFactory::fromByteArray(record.value(FDS_DB_ICON_INDEX).toByteArray()));
|
||||
feed->setEncoding(record.value(FDS_DB_ENCODING_INDEX).toString());
|
||||
feed->setUrl(record.value(FDS_DB_URL_INDEX).toString());
|
||||
feed->setPasswordProtected(record.value(FDS_DB_PROTECTED_INDEX).toBool());
|
||||
feed->setUsername(record.value(FDS_DB_USERNAME_INDEX).toString());
|
||||
feed->setPassword(record.value(FDS_DB_PASSWORD_INDEX).toString());
|
||||
feed->updateCounts();
|
||||
|
||||
return feed;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "core/networkfactory.h"
|
||||
|
||||
#include "core/silentnetworkaccessmanager.h"
|
||||
#include "core/feedsmodelstandardfeed.h"
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
@ -25,8 +26,10 @@ QNetworkReply::NetworkError NetworkFactory::downloadFeedFile(const QString &url,
|
||||
QNetworkReply *reply;
|
||||
QObject originatingObject;
|
||||
|
||||
// Set feed as originating object.
|
||||
originatingObject.setProperty("feed", QVariant::fromValue((void*) feed));
|
||||
// Set credential information as originating object.
|
||||
originatingObject.setProperty("protected", feed->passwordProtected());
|
||||
originatingObject.setProperty("username", feed->username());
|
||||
originatingObject.setProperty("password", feed->password());
|
||||
request.setOriginatingObject(&originatingObject);
|
||||
|
||||
// Set url for this reques.
|
||||
|
@ -30,17 +30,19 @@ void SilentNetworkAccessManager::onSslErrors(QNetworkReply *reply,
|
||||
|
||||
void SilentNetworkAccessManager::onAuthenticationRequired(QNetworkReply *reply,
|
||||
QAuthenticator *authenticator) {
|
||||
FeedsModelStandardFeed *feed = static_cast<FeedsModelStandardFeed*>(reply->request().originatingObject()->property("feed").value<void*>());
|
||||
QObject *originating_object = reply->request().originatingObject();
|
||||
|
||||
// TODO: tady do autenticatoru dosadit udaje z feedu
|
||||
// pokud je obsahuje
|
||||
// a taky promyslet zda to delat takhle vubec, ale funguje
|
||||
// to
|
||||
/*
|
||||
*authenticator->setUser("rotter.martinos");
|
||||
*authenticator->setPassword("gorottin0151");
|
||||
*/
|
||||
if (originating_object->property("protected").toBool()) {
|
||||
// This feed contains authentication information, it is good.
|
||||
authenticator->setUser(originating_object->property("username").toString());
|
||||
authenticator->setPassword(originating_object->property("password").toString());
|
||||
|
||||
qDebug("Authentication problems for '%s'.",
|
||||
qPrintable(reply->url().toString()));
|
||||
qDebug("Feed '%s' requested authentication and got it.",
|
||||
qPrintable(reply->url().toString()));
|
||||
}
|
||||
else {
|
||||
// Authentication is required but this feed does not contain it.
|
||||
qDebug("Feed '%s' requested authentication but username/password is not available.",
|
||||
qPrintable(reply->url().toString()));
|
||||
}
|
||||
}
|
||||
|
@ -181,6 +181,9 @@ void FormStandardFeedDetails::apply() {
|
||||
new_feed->setEncoding(m_ui->m_cmbEncoding->currentText());
|
||||
new_feed->setType(type);
|
||||
new_feed->setUrl(m_ui->m_txtUrl->lineEdit()->text());
|
||||
new_feed->setPasswordProtected(m_ui->m_gbAuthentication->isChecked());
|
||||
new_feed->setUsername(m_ui->m_txtUsername->lineEdit()->text());
|
||||
new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text());
|
||||
new_feed->setParent(parent);
|
||||
|
||||
if (m_editableFeed == NULL) {
|
||||
@ -235,6 +238,9 @@ void FormStandardFeedDetails::setEditableFeed(FeedsModelStandardFeed *editable_f
|
||||
m_ui->m_btnIcon->setIcon(editable_feed->icon());
|
||||
m_ui->m_cmbType->setCurrentIndex(m_ui->m_cmbType->findData(QVariant::fromValue((int) editable_feed->type())));
|
||||
m_ui->m_cmbEncoding->setCurrentIndex(m_ui->m_cmbEncoding->findData(editable_feed->encoding(), Qt::DisplayRole));
|
||||
m_ui->m_gbAuthentication->setChecked(editable_feed->passwordProtected());
|
||||
m_ui->m_txtUsername->lineEdit()->setText(editable_feed->username());
|
||||
m_ui->m_txtPassword->lineEdit()->setText(editable_feed->password());
|
||||
m_ui->m_txtUrl->lineEdit()->setText(editable_feed->url());
|
||||
}
|
||||
|
||||
@ -306,6 +312,18 @@ void FormStandardFeedDetails::initialize() {
|
||||
m_iconMenu->addAction(m_actionUseDefaultIcon);
|
||||
m_iconMenu->addAction(m_actionNoIcon);
|
||||
m_ui->m_btnIcon->setMenu(m_iconMenu);
|
||||
|
||||
// Set tab order.
|
||||
setTabOrder(m_ui->m_buttonBox, m_ui->m_cmbParentCategory);
|
||||
setTabOrder(m_ui->m_cmbParentCategory, m_ui->m_cmbType);
|
||||
setTabOrder(m_ui->m_cmbType, m_ui->m_txtTitle->lineEdit());
|
||||
setTabOrder(m_ui->m_txtTitle->lineEdit(), m_ui->m_txtDescription->lineEdit());
|
||||
setTabOrder(m_ui->m_txtDescription->lineEdit(), m_ui->m_txtUrl->lineEdit());
|
||||
setTabOrder(m_ui->m_txtUrl->lineEdit(), m_ui->m_cmbEncoding);
|
||||
setTabOrder(m_ui->m_cmbEncoding, m_ui->m_btnIcon);
|
||||
setTabOrder(m_ui->m_btnIcon, m_ui->m_gbAuthentication);
|
||||
setTabOrder(m_ui->m_gbAuthentication, m_ui->m_txtUsername->lineEdit());
|
||||
setTabOrder(m_ui->m_txtUsername->lineEdit(), m_ui->m_txtPassword->lineEdit());
|
||||
}
|
||||
|
||||
void FormStandardFeedDetails::loadCategories(const QList<FeedsModelCategory*> categories,
|
||||
|
Loading…
x
Reference in New Issue
Block a user