rename url -> source, start adding custom data API to feeds too
This commit is contained in:
parent
6558b9ea03
commit
0610e17128
28 changed files with 97 additions and 67 deletions
|
@ -37,16 +37,9 @@ CREATE TABLE Feeds (
|
||||||
date_created INTEGER,
|
date_created INTEGER,
|
||||||
icon BLOB,
|
icon BLOB,
|
||||||
category INTEGER NOT NULL CHECK (category >= -1), /* Root feeds contain -1 here. */
|
category INTEGER NOT NULL CHECK (category >= -1), /* Root feeds contain -1 here. */
|
||||||
encoding TEXT,
|
source 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_type INTEGER(1) NOT NULL CHECK (update_type >= 0),
|
||||||
update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 1),
|
update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 1),
|
||||||
type INTEGER,
|
|
||||||
account_id INTEGER NOT NULL,
|
account_id INTEGER NOT NULL,
|
||||||
custom_id TEXT,
|
custom_id TEXT,
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ void FeedDownloader::stopRunningUpdate() {
|
||||||
void FeedDownloader::updateOneFeed(Feed* feed) {
|
void FeedDownloader::updateOneFeed(Feed* feed) {
|
||||||
qDebugNN << LOGSEC_FEEDDOWNLOADER
|
qDebugNN << LOGSEC_FEEDDOWNLOADER
|
||||||
<< "Downloading new messages for feed ID '"
|
<< "Downloading new messages for feed ID '"
|
||||||
<< feed->customId() << "' URL: '" << feed->url() << "' title: '" << feed->title() << "' in thread: '"
|
<< feed->customId() << "' URL: '" << feed->source() << "' title: '" << feed->title() << "' in thread: '"
|
||||||
<< QThread::currentThreadId() << "'.";
|
<< QThread::currentThreadId() << "'.";
|
||||||
|
|
||||||
bool error_during_obtaining = false;
|
bool error_during_obtaining = false;
|
||||||
|
@ -123,7 +123,7 @@ void FeedDownloader::updateOneFeed(Feed* feed) {
|
||||||
QList<Message> msgs = feed->obtainNewMessages(&error_during_obtaining);
|
QList<Message> msgs = feed->obtainNewMessages(&error_during_obtaining);
|
||||||
|
|
||||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Downloaded " << msgs.size() << " messages for feed ID '"
|
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Downloaded " << msgs.size() << " messages for feed ID '"
|
||||||
<< feed->customId() << "' URL: '" << feed->url() << "' title: '" << feed->title() << "' in thread: '"
|
<< feed->customId() << "' URL: '" << feed->source() << "' title: '" << feed->title() << "' in thread: '"
|
||||||
<< QThread::currentThreadId() << "'. Operation took " << tmr.nsecsElapsed() / 1000 << " microseconds.";
|
<< QThread::currentThreadId() << "'. Operation took " << tmr.nsecsElapsed() / 1000 << " microseconds.";
|
||||||
|
|
||||||
// Now, sanitize messages (tweak encoding etc.).
|
// Now, sanitize messages (tweak encoding etc.).
|
||||||
|
@ -290,7 +290,7 @@ void FeedDownloader::updateOneFeed(Feed* feed) {
|
||||||
|
|
||||||
// Now make sure, that messages are actually stored to SQL in a locked state.
|
// Now make sure, that messages are actually stored to SQL in a locked state.
|
||||||
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Saving messages of feed ID '"
|
qDebugNN << LOGSEC_FEEDDOWNLOADER << "Saving messages of feed ID '"
|
||||||
<< feed->customId() << "' URL: '" << feed->url() << "' title: '" << feed->title() << "' in thread: '"
|
<< feed->customId() << "' URL: '" << feed->source() << "' title: '" << feed->title() << "' in thread: '"
|
||||||
<< QThread::currentThreadId() << "'.";
|
<< QThread::currentThreadId() << "'.";
|
||||||
|
|
||||||
int updated_messages = feed->updateMessages(msgs, error_during_obtaining);
|
int updated_messages = feed->updateMessages(msgs, error_during_obtaining);
|
||||||
|
|
|
@ -133,8 +133,8 @@ void FeedsView::copyUrlOfSelectedFeeds() const {
|
||||||
QStringList urls;
|
QStringList urls;
|
||||||
|
|
||||||
for (const auto* feed : feeds) {
|
for (const auto* feed : feeds) {
|
||||||
if (!feed->url().isEmpty()) {
|
if (!feed->source().isEmpty()) {
|
||||||
urls << feed->url();
|
urls << feed->source();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1510,7 +1510,7 @@ bool DatabaseQueries::storeAccountTree(const QSqlDatabase& db, RootItem* tree_ro
|
||||||
|
|
||||||
query_feed.bindValue(QSL(":title"), feed->title());
|
query_feed.bindValue(QSL(":title"), feed->title());
|
||||||
query_feed.bindValue(QSL(":icon"), qApp->icons()->toByteArray(feed->icon()));
|
query_feed.bindValue(QSL(":icon"), qApp->icons()->toByteArray(feed->icon()));
|
||||||
query_feed.bindValue(QSL(":url"), feed->url());
|
query_feed.bindValue(QSL(":url"), feed->source());
|
||||||
query_feed.bindValue(QSL(":category"), feed->parent()->id());
|
query_feed.bindValue(QSL(":category"), feed->parent()->id());
|
||||||
query_feed.bindValue(QSL(":protected"), 0);
|
query_feed.bindValue(QSL(":protected"), 0);
|
||||||
query_feed.bindValue(QSL(":update_type"), int(feed->autoUpdateType()));
|
query_feed.bindValue(QSL(":update_type"), int(feed->autoUpdateType()));
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
Feed::Feed(RootItem* parent)
|
Feed::Feed(RootItem* parent)
|
||||||
: RootItem(parent), m_url(QString()), m_status(Status::Normal), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate),
|
: RootItem(parent), m_source(QString()), m_status(Status::Normal), m_autoUpdateType(AutoUpdateType::DefaultAutoUpdate),
|
||||||
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
|
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
|
||||||
m_messageFilters(QList<QPointer<MessageFilter>>()) {
|
m_messageFilters(QList<QPointer<MessageFilter>>()) {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ Feed::Feed(RootItem* parent)
|
||||||
Feed::Feed(const QSqlRecord& record) : Feed(nullptr) {
|
Feed::Feed(const QSqlRecord& record) : Feed(nullptr) {
|
||||||
setTitle(record.value(FDS_DB_TITLE_INDEX).toString());
|
setTitle(record.value(FDS_DB_TITLE_INDEX).toString());
|
||||||
setId(record.value(FDS_DB_ID_INDEX).toInt());
|
setId(record.value(FDS_DB_ID_INDEX).toInt());
|
||||||
setUrl(record.value(FDS_DB_URL_INDEX).toString());
|
setSource(record.value(FDS_DB_URL_INDEX).toString());
|
||||||
setCustomId(record.value(FDS_DB_CUSTOM_ID_INDEX).toString());
|
setCustomId(record.value(FDS_DB_CUSTOM_ID_INDEX).toString());
|
||||||
|
|
||||||
if (customId().isEmpty()) {
|
if (customId().isEmpty()) {
|
||||||
|
@ -66,7 +66,7 @@ Feed::Feed(const Feed& other) : RootItem(other) {
|
||||||
|
|
||||||
setCountOfAllMessages(other.countOfAllMessages());
|
setCountOfAllMessages(other.countOfAllMessages());
|
||||||
setCountOfUnreadMessages(other.countOfUnreadMessages());
|
setCountOfUnreadMessages(other.countOfUnreadMessages());
|
||||||
setUrl(other.url());
|
setSource(other.source());
|
||||||
setStatus(other.status());
|
setStatus(other.status());
|
||||||
setAutoUpdateType(other.autoUpdateType());
|
setAutoUpdateType(other.autoUpdateType());
|
||||||
setAutoUpdateInitialInterval(other.autoUpdateInitialInterval());
|
setAutoUpdateInitialInterval(other.autoUpdateInitialInterval());
|
||||||
|
@ -144,6 +144,14 @@ int Feed::countOfUnreadMessages() const {
|
||||||
return m_unreadCount;
|
return m_unreadCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantHash Feed::customDatabaseData() const {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void Feed::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
|
Q_UNUSED(data)
|
||||||
|
}
|
||||||
|
|
||||||
void Feed::setCountOfAllMessages(int count_all_messages) {
|
void Feed::setCountOfAllMessages(int count_all_messages) {
|
||||||
m_totalCount = count_all_messages;
|
m_totalCount = count_all_messages;
|
||||||
}
|
}
|
||||||
|
@ -218,12 +226,12 @@ void Feed::setStatus(const Feed::Status& status) {
|
||||||
m_status = status;
|
m_status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Feed::url() const {
|
QString Feed::source() const {
|
||||||
return m_url;
|
return m_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Feed::setUrl(const QString& url) {
|
void Feed::setSource(const QString& source) {
|
||||||
m_url = url;
|
m_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Feed::appendMessageFilter(MessageFilter* filter) {
|
void Feed::appendMessageFilter(MessageFilter* filter) {
|
||||||
|
@ -290,7 +298,7 @@ int Feed::updateMessages(const QList<Message>& messages, bool error_during_obtai
|
||||||
qApp->database()->connection(QSL("feed_upd"));
|
qApp->database()->connection(QSL("feed_upd"));
|
||||||
|
|
||||||
updated_messages = DatabaseQueries::updateMessages(database, messages, custom_id, account_id,
|
updated_messages = DatabaseQueries::updateMessages(database, messages, custom_id, account_id,
|
||||||
url(), force_update, &anything_updated, &ok);
|
source(), force_update, &anything_updated, &ok);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebugNN << LOGSEC_CORE
|
qDebugNN << LOGSEC_CORE
|
||||||
|
|
|
@ -49,6 +49,8 @@ class Feed : public RootItem {
|
||||||
virtual QList<Message> obtainNewMessages(bool* error_during_obtaining);
|
virtual QList<Message> obtainNewMessages(bool* error_during_obtaining);
|
||||||
virtual int countOfAllMessages() const;
|
virtual int countOfAllMessages() const;
|
||||||
virtual int countOfUnreadMessages() const;
|
virtual int countOfUnreadMessages() const;
|
||||||
|
virtual QVariantHash customDatabaseData() const;
|
||||||
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
void setCountOfAllMessages(int count_all_messages);
|
void setCountOfAllMessages(int count_all_messages);
|
||||||
void setCountOfUnreadMessages(int count_unread_messages);
|
void setCountOfUnreadMessages(int count_unread_messages);
|
||||||
|
@ -72,8 +74,8 @@ class Feed : public RootItem {
|
||||||
Status status() const;
|
Status status() const;
|
||||||
void setStatus(const Status& status);
|
void setStatus(const Status& status);
|
||||||
|
|
||||||
QString url() const;
|
QString source() const;
|
||||||
void setUrl(const QString& url);
|
void setSource(const QString& source);
|
||||||
|
|
||||||
bool passwordProtected() const;
|
bool passwordProtected() const;
|
||||||
void setPasswordProtected(bool passwordProtected);
|
void setPasswordProtected(bool passwordProtected);
|
||||||
|
@ -99,7 +101,7 @@ class Feed : public RootItem {
|
||||||
QString getStatusDescription() const;
|
QString getStatusDescription() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_url;
|
QString m_source;
|
||||||
Status m_status;
|
Status m_status;
|
||||||
AutoUpdateType m_autoUpdateType;
|
AutoUpdateType m_autoUpdateType;
|
||||||
int m_autoUpdateInitialInterval{};
|
int m_autoUpdateInitialInterval{};
|
||||||
|
|
|
@ -288,7 +288,7 @@ QVariantHash ServiceRoot::customDatabaseData() const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceRoot::setCustomDatabaseData(const QVariantHash& data) const {
|
void ServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
Q_UNUSED(data)
|
Q_UNUSED(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ QStringList ServiceRoot::textualFeedUrls(const QList<Feed*>& feeds) const {
|
||||||
stringy_urls.reserve(feeds.size());
|
stringy_urls.reserve(feeds.size());
|
||||||
|
|
||||||
for (const Feed* feed : feeds) {
|
for (const Feed* feed : feeds) {
|
||||||
stringy_urls.append(!feed->url().isEmpty() ? feed->url() : QL1S("no-url"));
|
stringy_urls.append(!feed->source().isEmpty() ? feed->source() : QL1S("no-url"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringy_urls;
|
return stringy_urls;
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ServiceRoot : public RootItem {
|
||||||
virtual LabelOperation supportedLabelOperations() const;
|
virtual LabelOperation supportedLabelOperations() const;
|
||||||
virtual void saveAccountDataToDatabase();
|
virtual void saveAccountDataToDatabase();
|
||||||
virtual QVariantHash customDatabaseData() const;
|
virtual QVariantHash customDatabaseData() const;
|
||||||
virtual void setCustomDatabaseData(const QVariantHash& json) const;
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
// 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:
|
||||||
|
|
|
@ -60,7 +60,7 @@ QVariantHash FeedlyServiceRoot::customDatabaseData() const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedlyServiceRoot::setCustomDatabaseData(const QVariantHash& data) const {
|
void FeedlyServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
m_network->setUsername(data["username"].toString());
|
m_network->setUsername(data["username"].toString());
|
||||||
m_network->setDeveloperAccessToken(data["dat"].toString());
|
m_network->setDeveloperAccessToken(data["dat"].toString());
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class FeedlyServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
virtual LabelOperation supportedLabelOperations() const;
|
virtual LabelOperation supportedLabelOperations() const;
|
||||||
virtual QVariantHash customDatabaseData() const;
|
virtual QVariantHash customDatabaseData() const;
|
||||||
virtual void setCustomDatabaseData(const QVariantHash& data) const;
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
FeedlyNetwork* network() const;
|
FeedlyNetwork* network() const;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ QVariantHash GmailServiceRoot::customDatabaseData() const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GmailServiceRoot::setCustomDatabaseData(const QVariantHash& data) const {
|
void GmailServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
m_network->setUsername(data["username"].toString());
|
m_network->setUsername(data["username"].toString());
|
||||||
m_network->setBatchSize(data["batch_size"].toInt());
|
m_network->setBatchSize(data["batch_size"].toInt());
|
||||||
m_network->oauth()->setClientId(data["client_id"].toString());
|
m_network->oauth()->setClientId(data["client_id"].toString());
|
||||||
|
|
|
@ -30,7 +30,7 @@ class GmailServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
virtual QString additionalTooltip() const;
|
virtual QString additionalTooltip() const;
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
virtual QVariantHash customDatabaseData() const;
|
virtual QVariantHash customDatabaseData() const;
|
||||||
virtual void setCustomDatabaseData(const QVariantHash& data) const;
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual RootItem* obtainNewTreeForSyncIn() const;
|
virtual RootItem* obtainNewTreeForSyncIn() const;
|
||||||
|
|
|
@ -292,7 +292,7 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
|
||||||
auto* feed = new GreaderFeed();
|
auto* feed = new GreaderFeed();
|
||||||
|
|
||||||
feed->setDescription(url);
|
feed->setDescription(url);
|
||||||
feed->setUrl(url);
|
feed->setSource(url);
|
||||||
feed->setTitle(title);
|
feed->setTitle(title);
|
||||||
feed->setCustomId(id);
|
feed->setCustomId(id);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ QVariantHash GreaderServiceRoot::customDatabaseData() const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) const {
|
void GreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
m_network->setService(GreaderServiceRoot::Service(data["service"].toInt()));
|
m_network->setService(GreaderServiceRoot::Service(data["service"].toInt()));
|
||||||
m_network->setUsername(data["username"].toString());
|
m_network->setUsername(data["username"].toString());
|
||||||
TextFactory::decrypt(data["password"].toString());
|
TextFactory::decrypt(data["password"].toString());
|
||||||
|
|
|
@ -30,7 +30,7 @@ class GreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
virtual LabelOperation supportedLabelOperations() const;
|
virtual LabelOperation supportedLabelOperations() const;
|
||||||
virtual QVariantHash customDatabaseData() const;
|
virtual QVariantHash customDatabaseData() const;
|
||||||
virtual void setCustomDatabaseData(const QVariantHash& data) const;
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
GreaderNetwork* network() const;
|
GreaderNetwork* network() const;
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ
|
||||||
auto* feed = new InoreaderFeed();
|
auto* feed = new InoreaderFeed();
|
||||||
|
|
||||||
feed->setDescription(url);
|
feed->setDescription(url);
|
||||||
feed->setUrl(url);
|
feed->setSource(url);
|
||||||
feed->setTitle(title);
|
feed->setTitle(title);
|
||||||
feed->setCustomId(id);
|
feed->setCustomId(id);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ QVariantHash InoreaderServiceRoot::customDatabaseData() const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InoreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) const {
|
void InoreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
m_network->setUsername(data["username"].toString());
|
m_network->setUsername(data["username"].toString());
|
||||||
m_network->setBatchSize(data["batch_size"].toInt());
|
m_network->setBatchSize(data["batch_size"].toInt());
|
||||||
m_network->oauth()->setClientId(data["client_id"].toString());
|
m_network->oauth()->setClientId(data["client_id"].toString());
|
||||||
|
|
|
@ -28,7 +28,7 @@ class InoreaderServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
virtual QString additionalTooltip() const;
|
virtual QString additionalTooltip() const;
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
virtual QVariantHash customDatabaseData() const;
|
virtual QVariantHash customDatabaseData() const;
|
||||||
virtual void setCustomDatabaseData(const QVariantHash& data) const;
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual RootItem* obtainNewTreeForSyncIn() const;
|
virtual RootItem* obtainNewTreeForSyncIn() const;
|
||||||
|
|
|
@ -531,16 +531,16 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
||||||
}
|
}
|
||||||
|
|
||||||
feed->setCustomId(QString::number(item["id"].toInt()));
|
feed->setCustomId(QString::number(item["id"].toInt()));
|
||||||
feed->setUrl(item["url"].toString());
|
feed->setSource(item["url"].toString());
|
||||||
|
|
||||||
if (feed->url().isEmpty()) {
|
if (feed->source().isEmpty()) {
|
||||||
feed->setUrl(item["link"].toString());
|
feed->setSource(item["link"].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
feed->setTitle(item["title"].toString());
|
feed->setTitle(item["title"].toString());
|
||||||
|
|
||||||
if (feed->title().isEmpty()) {
|
if (feed->title().isEmpty()) {
|
||||||
if (feed->url().isEmpty()) {
|
if (feed->source().isEmpty()) {
|
||||||
// We cannot add feed which has no title and no url to RSS Guard!!!
|
// We cannot add feed which has no title and no url to RSS Guard!!!
|
||||||
qCriticalNN << LOGSEC_NEXTCLOUD
|
qCriticalNN << LOGSEC_NEXTCLOUD
|
||||||
<< "Skipping feed with custom ID"
|
<< "Skipping feed with custom ID"
|
||||||
|
@ -549,7 +549,7 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
feed->setTitle(feed->url());
|
feed->setTitle(feed->source());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ QVariantHash OwnCloudServiceRoot::customDatabaseData() const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OwnCloudServiceRoot::setCustomDatabaseData(const QVariantHash& data) const {
|
void OwnCloudServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
m_network->setAuthUsername(data["auth_username"].toString());
|
m_network->setAuthUsername(data["auth_username"].toString());
|
||||||
m_network->setAuthPassword(TextFactory::decrypt(data["auth_password"].toString()));
|
m_network->setAuthPassword(TextFactory::decrypt(data["auth_password"].toString()));
|
||||||
m_network->setUrl(data["url"].toString());
|
m_network->setUrl(data["url"].toString());
|
||||||
|
|
|
@ -27,7 +27,7 @@ class OwnCloudServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
virtual QString code() const;
|
virtual QString code() const;
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
virtual QVariantHash customDatabaseData() const;
|
virtual QVariantHash customDatabaseData() const;
|
||||||
virtual void setCustomDatabaseData(const QVariantHash& data) const;
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
OwnCloudNetworkFactory* network() const;
|
OwnCloudNetworkFactory* network() const;
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ void FormStandardFeedDetails::apply() {
|
||||||
new_feed->setType(type);
|
new_feed->setType(type);
|
||||||
new_feed->setSourceType(m_standardFeedDetails->sourceType());
|
new_feed->setSourceType(m_standardFeedDetails->sourceType());
|
||||||
new_feed->setPostProcessScript(m_standardFeedDetails->m_ui.m_txtPostProcessScript->textEdit()->toPlainText());
|
new_feed->setPostProcessScript(m_standardFeedDetails->m_ui.m_txtPostProcessScript->textEdit()->toPlainText());
|
||||||
new_feed->setUrl(m_standardFeedDetails->m_ui.m_txtSource->textEdit()->toPlainText());
|
new_feed->setSource(m_standardFeedDetails->m_ui.m_txtSource->textEdit()->toPlainText());
|
||||||
new_feed->setPasswordProtected(m_authDetails->m_gbAuthentication->isChecked());
|
new_feed->setPasswordProtected(m_authDetails->m_gbAuthentication->isChecked());
|
||||||
new_feed->setUsername(m_authDetails->m_txtUsername->lineEdit()->text());
|
new_feed->setUsername(m_authDetails->m_txtUsername->lineEdit()->text());
|
||||||
new_feed->setPassword(m_authDetails->m_txtPassword->lineEdit()->text());
|
new_feed->setPassword(m_authDetails->m_txtPassword->lineEdit()->text());
|
||||||
|
|
|
@ -329,7 +329,7 @@ void StandardFeedDetails::setExistingFeed(StandardFeed* feed) {
|
||||||
m_ui.m_txtTitle->lineEdit()->setText(feed->title());
|
m_ui.m_txtTitle->lineEdit()->setText(feed->title());
|
||||||
m_ui.m_txtDescription->lineEdit()->setText(feed->description());
|
m_ui.m_txtDescription->lineEdit()->setText(feed->description());
|
||||||
m_ui.m_btnIcon->setIcon(feed->icon());
|
m_ui.m_btnIcon->setIcon(feed->icon());
|
||||||
m_ui.m_txtSource->textEdit()->setPlainText(feed->url());
|
m_ui.m_txtSource->textEdit()->setPlainText(feed->source());
|
||||||
m_ui.m_txtPostProcessScript->textEdit()->setPlainText(feed->postProcessScript());
|
m_ui.m_txtPostProcessScript->textEdit()->setPlainText(feed->postProcessScript());
|
||||||
m_ui.m_cmbType->setCurrentIndex(m_ui.m_cmbType->findData(QVariant::fromValue(int(feed->type()))));
|
m_ui.m_cmbType->setCurrentIndex(m_ui.m_cmbType->findData(QVariant::fromValue(int(feed->type()))));
|
||||||
m_ui.m_cmbEncoding->setCurrentIndex(m_ui.m_cmbEncoding->findData(feed->encoding(),
|
m_ui.m_cmbEncoding->setCurrentIndex(m_ui.m_cmbEncoding->findData(feed->encoding(),
|
||||||
|
|
|
@ -98,6 +98,30 @@ bool StandardFeed::deleteViaGui() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantHash StandardFeed::customDatabaseData() const {
|
||||||
|
QVariantHash data;
|
||||||
|
|
||||||
|
data["source_type"] = int(sourceType());
|
||||||
|
data["type"] = int(type());
|
||||||
|
data["encoding"] = encoding();
|
||||||
|
data["post_process"] = postProcessScript();
|
||||||
|
data["protected"] = passwordProtected();
|
||||||
|
data["username"] = username();
|
||||||
|
data["password"] = TextFactory::encrypt(password());
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StandardFeed::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
|
setSourceType(SourceType(data["source_type"].toInt()));
|
||||||
|
setType(Type(data["type"].toInt()));
|
||||||
|
setEncoding(data["encoding"].toString());
|
||||||
|
setPostProcessScript(data["post_process"].toString());
|
||||||
|
setPasswordProtected(data["protected"].toBool());
|
||||||
|
setUsername(data["username"].toString());
|
||||||
|
setPassword(TextFactory::decrypt(data["password"].toString()));
|
||||||
|
}
|
||||||
|
|
||||||
QString StandardFeed::typeToString(StandardFeed::Type type) {
|
QString StandardFeed::typeToString(StandardFeed::Type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Type::Atom10:
|
case Type::Atom10:
|
||||||
|
@ -137,7 +161,7 @@ QString StandardFeed::sourceTypeToString(StandardFeed::SourceType type) {
|
||||||
void StandardFeed::fetchMetadataForItself() {
|
void StandardFeed::fetchMetadataForItself() {
|
||||||
bool result;
|
bool result;
|
||||||
StandardFeed* metadata = guessFeed(sourceType(),
|
StandardFeed* metadata = guessFeed(sourceType(),
|
||||||
url(),
|
source(),
|
||||||
postProcessScript(),
|
postProcessScript(),
|
||||||
&result,
|
&result,
|
||||||
username(),
|
username(),
|
||||||
|
@ -147,7 +171,7 @@ void StandardFeed::fetchMetadataForItself() {
|
||||||
if (metadata != nullptr && result) {
|
if (metadata != nullptr && result) {
|
||||||
// Some properties are not updated when new metadata are fetched.
|
// Some properties are not updated when new metadata are fetched.
|
||||||
metadata->setParent(parent());
|
metadata->setParent(parent());
|
||||||
metadata->setUrl(url());
|
metadata->setSource(source());
|
||||||
metadata->setPasswordProtected(passwordProtected());
|
metadata->setPasswordProtected(passwordProtected());
|
||||||
metadata->setUsername(username());
|
metadata->setUsername(username());
|
||||||
metadata->setPassword(password());
|
metadata->setPassword(password());
|
||||||
|
@ -181,7 +205,7 @@ StandardFeed::SourceType StandardFeed::sourceType() const {
|
||||||
return m_sourceType;
|
return m_sourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandardFeed::setSourceType(const SourceType& source_type) {
|
void StandardFeed::setSourceType(SourceType source_type) {
|
||||||
m_sourceType = source_type;
|
m_sourceType = source_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +502,7 @@ bool StandardFeed::addItself(RootItem* parent) {
|
||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||||
bool ok;
|
bool ok;
|
||||||
int new_id = DatabaseQueries::addStandardFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(),
|
int new_id = DatabaseQueries::addStandardFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(),
|
||||||
title(), description(), creationDate(), icon(), encoding(), url(),
|
title(), description(), creationDate(), icon(), encoding(), source(),
|
||||||
passwordProtected(), username(), password(), autoUpdateType(),
|
passwordProtected(), username(), password(), autoUpdateType(),
|
||||||
autoUpdateInitialInterval(), sourceType(), postProcessScript(),
|
autoUpdateInitialInterval(), sourceType(), postProcessScript(),
|
||||||
type(), &ok);
|
type(), &ok);
|
||||||
|
@ -502,7 +526,7 @@ bool StandardFeed::editItself(StandardFeed* new_feed_data) {
|
||||||
|
|
||||||
if (!DatabaseQueries::editStandardFeed(database, new_parent->id(), original_feed->id(), new_feed_data->title(),
|
if (!DatabaseQueries::editStandardFeed(database, new_parent->id(), original_feed->id(), new_feed_data->title(),
|
||||||
new_feed_data->description(), new_feed_data->icon(),
|
new_feed_data->description(), new_feed_data->icon(),
|
||||||
new_feed_data->encoding(), new_feed_data->url(), new_feed_data->passwordProtected(),
|
new_feed_data->encoding(), new_feed_data->source(), new_feed_data->passwordProtected(),
|
||||||
new_feed_data->username(), new_feed_data->password(),
|
new_feed_data->username(), new_feed_data->password(),
|
||||||
new_feed_data->autoUpdateType(), new_feed_data->autoUpdateInitialInterval(),
|
new_feed_data->autoUpdateType(), new_feed_data->autoUpdateInitialInterval(),
|
||||||
new_feed_data->sourceType(), new_feed_data->postProcessScript(),
|
new_feed_data->sourceType(), new_feed_data->postProcessScript(),
|
||||||
|
@ -519,7 +543,7 @@ bool StandardFeed::editItself(StandardFeed* new_feed_data) {
|
||||||
original_feed->setIcon(new_feed_data->icon());
|
original_feed->setIcon(new_feed_data->icon());
|
||||||
original_feed->setEncoding(new_feed_data->encoding());
|
original_feed->setEncoding(new_feed_data->encoding());
|
||||||
original_feed->setDescription(new_feed_data->description());
|
original_feed->setDescription(new_feed_data->description());
|
||||||
original_feed->setUrl(new_feed_data->url());
|
original_feed->setSource(new_feed_data->source());
|
||||||
original_feed->setPasswordProtected(new_feed_data->passwordProtected());
|
original_feed->setPasswordProtected(new_feed_data->passwordProtected());
|
||||||
original_feed->setUsername(new_feed_data->username());
|
original_feed->setUsername(new_feed_data->username());
|
||||||
original_feed->setPassword(new_feed_data->password());
|
original_feed->setPassword(new_feed_data->password());
|
||||||
|
@ -556,14 +580,14 @@ QList<Message> StandardFeed::obtainNewMessages(bool* error_during_obtaining) {
|
||||||
if (sourceType() == SourceType::Url) {
|
if (sourceType() == SourceType::Url) {
|
||||||
qDebugNN << LOGSEC_CORE
|
qDebugNN << LOGSEC_CORE
|
||||||
<< "Downloading URL"
|
<< "Downloading URL"
|
||||||
<< QUOTE_W_SPACE(url())
|
<< QUOTE_W_SPACE(source())
|
||||||
<< "to obtain feed data.";
|
<< "to obtain feed data.";
|
||||||
|
|
||||||
QByteArray feed_contents;
|
QByteArray feed_contents;
|
||||||
QList<QPair<QByteArray, QByteArray>> headers;
|
QList<QPair<QByteArray, QByteArray>> headers;
|
||||||
|
|
||||||
headers << NetworkFactory::generateBasicAuthHeader(username(), password());
|
headers << NetworkFactory::generateBasicAuthHeader(username(), password());
|
||||||
m_networkError = NetworkFactory::performNetworkOperation(url(),
|
m_networkError = NetworkFactory::performNetworkOperation(source(),
|
||||||
download_timeout,
|
download_timeout,
|
||||||
QByteArray(),
|
QByteArray(),
|
||||||
feed_contents,
|
feed_contents,
|
||||||
|
@ -579,7 +603,7 @@ QList<Message> StandardFeed::obtainNewMessages(bool* error_during_obtaining) {
|
||||||
<< "Error"
|
<< "Error"
|
||||||
<< QUOTE_W_SPACE(m_networkError)
|
<< QUOTE_W_SPACE(m_networkError)
|
||||||
<< "during fetching of new messages for feed"
|
<< "during fetching of new messages for feed"
|
||||||
<< QUOTE_W_SPACE_DOT(url());
|
<< QUOTE_W_SPACE_DOT(source());
|
||||||
setStatus(Status::NetworkError);
|
setStatus(Status::NetworkError);
|
||||||
*error_during_obtaining = true;
|
*error_during_obtaining = true;
|
||||||
return QList<Message>();
|
return QList<Message>();
|
||||||
|
@ -603,12 +627,12 @@ QList<Message> StandardFeed::obtainNewMessages(bool* error_during_obtaining) {
|
||||||
else {
|
else {
|
||||||
qDebugNN << LOGSEC_CORE
|
qDebugNN << LOGSEC_CORE
|
||||||
<< "Running custom script"
|
<< "Running custom script"
|
||||||
<< QUOTE_W_SPACE(url())
|
<< QUOTE_W_SPACE(source())
|
||||||
<< "to obtain feed data.";
|
<< "to obtain feed data.";
|
||||||
|
|
||||||
// Use script to generate feed file.
|
// Use script to generate feed file.
|
||||||
try {
|
try {
|
||||||
formatted_feed_contents = generateFeedFileWithScript(url(), download_timeout);
|
formatted_feed_contents = generateFeedFileWithScript(source(), download_timeout);
|
||||||
}
|
}
|
||||||
catch (const ScriptException& ex) {
|
catch (const ScriptException& ex) {
|
||||||
qCriticalNN << LOGSEC_CORE
|
qCriticalNN << LOGSEC_CORE
|
||||||
|
|
|
@ -53,6 +53,9 @@ class StandardFeed : public Feed {
|
||||||
bool editViaGui();
|
bool editViaGui();
|
||||||
bool deleteViaGui();
|
bool deleteViaGui();
|
||||||
|
|
||||||
|
virtual QVariantHash customDatabaseData() const;
|
||||||
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
// Obtains data related to this feed.
|
// Obtains data related to this feed.
|
||||||
Qt::ItemFlags additionalFlags() const;
|
Qt::ItemFlags additionalFlags() const;
|
||||||
bool performDragDropChange(RootItem* target_item);
|
bool performDragDropChange(RootItem* target_item);
|
||||||
|
@ -66,7 +69,7 @@ class StandardFeed : public Feed {
|
||||||
void setType(Type type);
|
void setType(Type type);
|
||||||
|
|
||||||
SourceType sourceType() const;
|
SourceType sourceType() const;
|
||||||
void setSourceType(const SourceType& source_type);
|
void setSourceType(SourceType source_type);
|
||||||
|
|
||||||
QString encoding() const;
|
QString encoding() const;
|
||||||
void setEncoding(const QString& encoding);
|
void setEncoding(const QString& encoding);
|
||||||
|
|
|
@ -89,7 +89,7 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
|
||||||
|
|
||||||
outline_feed.setAttribute(QSL("type"), QSL("rss"));
|
outline_feed.setAttribute(QSL("type"), QSL("rss"));
|
||||||
outline_feed.setAttribute(QSL("text"), child_feed->title());
|
outline_feed.setAttribute(QSL("text"), child_feed->title());
|
||||||
outline_feed.setAttribute(QSL("xmlUrl"), child_feed->url());
|
outline_feed.setAttribute(QSL("xmlUrl"), child_feed->source());
|
||||||
outline_feed.setAttribute(QSL("description"), child_feed->description());
|
outline_feed.setAttribute(QSL("description"), child_feed->description());
|
||||||
outline_feed.setAttribute(QSL("encoding"), child_feed->encoding());
|
outline_feed.setAttribute(QSL("encoding"), child_feed->encoding());
|
||||||
outline_feed.setAttribute(QSL("title"), child_feed->title());
|
outline_feed.setAttribute(QSL("title"), child_feed->title());
|
||||||
|
@ -196,7 +196,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
custom_proxy)) != nullptr &&
|
custom_proxy)) != nullptr &&
|
||||||
result) {
|
result) {
|
||||||
// We should obtain fresh metadata from online feed source.
|
// We should obtain fresh metadata from online feed source.
|
||||||
guessed->setUrl(feed_url);
|
guessed->setSource(feed_url);
|
||||||
active_model_item->appendChild(guessed);
|
active_model_item->appendChild(guessed);
|
||||||
succeded++;
|
succeded++;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
new_feed->setTitle(feed_title);
|
new_feed->setTitle(feed_title);
|
||||||
new_feed->setDescription(feed_description);
|
new_feed->setDescription(feed_description);
|
||||||
new_feed->setEncoding(feed_encoding);
|
new_feed->setEncoding(feed_encoding);
|
||||||
new_feed->setUrl(feed_url);
|
new_feed->setSource(feed_url);
|
||||||
new_feed->setCreationDate(QDateTime::currentDateTime());
|
new_feed->setCreationDate(QDateTime::currentDateTime());
|
||||||
new_feed->setIcon(feed_icon);
|
new_feed->setIcon(feed_icon);
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
|
|
||||||
bool FeedsImportExportModel::exportToTxtURLPerLine(QByteArray& result) {
|
bool FeedsImportExportModel::exportToTxtURLPerLine(QByteArray& result) {
|
||||||
for (const Feed* const feed : sourceModel()->rootItem()->getSubTreeFeeds()) {
|
for (const Feed* const feed : sourceModel()->rootItem()->getSubTreeFeeds()) {
|
||||||
result += feed->url() + QL1S("\n");
|
result += feed->source() + QL1S("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -318,14 +318,14 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
|
||||||
url, {}, &result, {}, {},
|
url, {}, &result, {}, {},
|
||||||
custom_proxy)) != nullptr &&
|
custom_proxy)) != nullptr &&
|
||||||
result) {
|
result) {
|
||||||
guessed->setUrl(url);
|
guessed->setSource(url);
|
||||||
root_item->appendChild(guessed);
|
root_item->appendChild(guessed);
|
||||||
succeded++;
|
succeded++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto* feed = new StandardFeed();
|
auto* feed = new StandardFeed();
|
||||||
|
|
||||||
feed->setUrl(url);
|
feed->setSource(url);
|
||||||
feed->setTitle(url);
|
feed->setTitle(url);
|
||||||
feed->setCreationDate(QDateTime::currentDateTime());
|
feed->setCreationDate(QDateTime::currentDateTime());
|
||||||
feed->setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
|
feed->setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
|
||||||
|
|
|
@ -200,7 +200,7 @@ QVariantHash TtRssServiceRoot::customDatabaseData() const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TtRssServiceRoot::setCustomDatabaseData(const QVariantHash& data) const {
|
void TtRssServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
|
||||||
m_network->setUsername( data["username"].toString());
|
m_network->setUsername( data["username"].toString());
|
||||||
m_network->setPassword(TextFactory::decrypt(data["password"].toString()));
|
m_network->setPassword(TextFactory::decrypt(data["password"].toString()));
|
||||||
m_network->setAuthIsUsed(data["auth_protected"].toBool());
|
m_network->setAuthIsUsed(data["auth_protected"].toBool());
|
||||||
|
|
|
@ -32,7 +32,7 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
||||||
virtual QString additionalTooltip() const;
|
virtual QString additionalTooltip() const;
|
||||||
virtual void saveAllCachedData(bool ignore_errors);
|
virtual void saveAllCachedData(bool ignore_errors);
|
||||||
virtual QVariantHash customDatabaseData() const;
|
virtual QVariantHash customDatabaseData() const;
|
||||||
virtual void setCustomDatabaseData(const QVariantHash& data) const;
|
virtual void setCustomDatabaseData(const QVariantHash& data);
|
||||||
|
|
||||||
// Access to network.
|
// Access to network.
|
||||||
TtRssNetworkFactory* network() const;
|
TtRssNetworkFactory* network() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue