Fixed #151.
This commit is contained in:
parent
b71547ecf9
commit
0a2774893e
@ -7,6 +7,9 @@ PLEASE, FILL THIS SURVEY.
|
||||
http://goo.gl/forms/GcvPYgS2a8
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
Added:
|
||||
▪ User is now able to delete TT-RSS feeds. (issue #151)
|
||||
|
||||
Fixed:
|
||||
▪ Fixed some problems, that "Add category to selected account" was enabled when it shouldn't be.
|
||||
▪ ♥ Auto-updating of feeds fixed (again?!). ♥
|
||||
|
@ -271,7 +271,7 @@ TtRssUnsubscribeFeedResponse TtRssNetworkFactory::unsubscribeFeed(int feed_id) {
|
||||
QtJson::JsonObject json;
|
||||
json["op"] = "unsubscribeFeed";
|
||||
json["sid"] = m_sessionId;
|
||||
json["cat_id"] = feed_id;
|
||||
json["feed_id"] = feed_id;
|
||||
|
||||
QByteArray result_raw;
|
||||
NetworkResult network_reply = NetworkFactory::uploadData(m_url, DOWNLOAD_TIMEOUT, QtJson::serialize(json), CONTENT_TYPE, result_raw,
|
||||
@ -296,36 +296,6 @@ TtRssUnsubscribeFeedResponse TtRssNetworkFactory::unsubscribeFeed(int feed_id) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
TtRssGetConfigResponse TtRssNetworkFactory::getConfig() {
|
||||
QtJson::JsonObject json;
|
||||
json["op"] = "getConfig";
|
||||
json["sid"] = m_sessionId;
|
||||
|
||||
QByteArray result_raw;
|
||||
NetworkResult network_reply = NetworkFactory::uploadData(m_url, DOWNLOAD_TIMEOUT, QtJson::serialize(json), CONTENT_TYPE, result_raw,
|
||||
m_authIsUsed, m_authUsername, m_authPassword);
|
||||
TtRssGetConfigResponse result(QString::fromUtf8(result_raw));
|
||||
|
||||
if (result.isNotLoggedIn()) {
|
||||
// We are not logged in.
|
||||
login();
|
||||
json["sid"] = m_sessionId;
|
||||
|
||||
network_reply = NetworkFactory::uploadData(m_url, DOWNLOAD_TIMEOUT, QtJson::serialize(json), CONTENT_TYPE, result_raw,
|
||||
m_authIsUsed, m_authUsername, m_authPassword);
|
||||
result = TtRssGetConfigResponse(QString::fromUtf8(result_raw));
|
||||
}
|
||||
|
||||
if (network_reply.first != QNetworkReply::NoError) {
|
||||
qWarning("TT-RSS: getConfig failed with error %d.", network_reply.first);
|
||||
}
|
||||
|
||||
m_lastError = network_reply.first;
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
bool TtRssNetworkFactory::forceServerSideUpdate() const {
|
||||
return m_forceServerSideUpdate;
|
||||
}
|
||||
@ -391,6 +361,10 @@ bool TtRssResponse::isNotLoggedIn() const {
|
||||
return status() == API_STATUS_ERR && hasError() && error() == NOT_LOGGED_IN;
|
||||
}
|
||||
|
||||
QString TtRssResponse::toString() const {
|
||||
return QtJson::serializeStr(m_rawContent);
|
||||
}
|
||||
|
||||
TtRssLoginResponse::TtRssLoginResponse(const QString &raw_content) : TtRssResponse(raw_content) {
|
||||
}
|
||||
|
||||
@ -593,17 +567,7 @@ int TtRssUpdateArticleResponse::articlesUpdated() const {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
TtRssGetConfigResponse::TtRssGetConfigResponse(const QString &raw_content) : TtRssResponse(raw_content) {
|
||||
}
|
||||
|
||||
TtRssGetConfigResponse::~TtRssGetConfigResponse() {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
TtRssSubscribeToFeedResponse::TtRssSubscribeToFeedResponse(const QString &raw_content) : TtRssResponse(raw_content) {
|
||||
|
||||
}
|
||||
|
||||
TtRssSubscribeToFeedResponse::~TtRssSubscribeToFeedResponse() {
|
||||
|
@ -42,6 +42,7 @@ class TtRssResponse {
|
||||
QString error() const;
|
||||
bool hasError() const;
|
||||
bool isNotLoggedIn() const;
|
||||
QString toString() const;
|
||||
|
||||
protected:
|
||||
QtJson::JsonObject m_rawContent;
|
||||
@ -100,14 +101,6 @@ class TtRssUnsubscribeFeedResponse : public TtRssResponse {
|
||||
QString code() const;
|
||||
};
|
||||
|
||||
/*
|
||||
class TtRssGetConfigResponse : public TtRssResponse {
|
||||
public:
|
||||
explicit TtRssGetConfigResponse(const QString &raw_content = QString());
|
||||
virtual ~TtRssGetConfigResponse();
|
||||
};
|
||||
*/
|
||||
|
||||
namespace UpdateArticle {
|
||||
enum Mode {
|
||||
SetToFalse = 0,
|
||||
|
@ -150,6 +150,20 @@ bool TtRssFeed::editViaGui() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TtRssFeed::canBeDeleted() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TtRssFeed::deleteViaGui() {
|
||||
if (removeItself()) {
|
||||
serviceRoot()->requestItemRemoval(this);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int TtRssFeed::countOfAllMessages() const {
|
||||
return m_totalCount;
|
||||
}
|
||||
@ -267,6 +281,37 @@ bool TtRssFeed::editItself(TtRssFeed *new_feed_data) {
|
||||
}
|
||||
}
|
||||
|
||||
bool TtRssFeed::removeItself() {
|
||||
TtRssUnsubscribeFeedResponse response = serviceRoot()->network()->unsubscribeFeed(customId());
|
||||
|
||||
if (response.code() == UFF_OK) {
|
||||
// Feed was removed online from server, remove local data.
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||
QSqlQuery query_remove(database);
|
||||
|
||||
query_remove.setForwardOnly(true);
|
||||
|
||||
// Remove all messages from this standard feed.
|
||||
query_remove.prepare(QSL("DELETE FROM Messages WHERE feed = :feed;"));
|
||||
query_remove.bindValue(QSL(":feed"), customId());
|
||||
|
||||
if (!query_remove.exec()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove feed itself.
|
||||
query_remove.prepare(QSL("DELETE FROM Feeds WHERE custom_id = :feed;"));
|
||||
query_remove.bindValue(QSL(":feed"), customId());
|
||||
|
||||
return query_remove.exec();
|
||||
}
|
||||
else {
|
||||
qWarning("TT-RSS: Unsubscribing from feed failed, received JSON: '%s'", qPrintable(response.toString()));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int TtRssFeed::updateMessages(const QList<Message> &messages) {
|
||||
if (messages.isEmpty()) {
|
||||
return 0;
|
||||
|
@ -44,6 +44,9 @@ class TtRssFeed : public Feed {
|
||||
bool canBeEdited() const;
|
||||
bool editViaGui();
|
||||
|
||||
bool canBeDeleted() const;
|
||||
bool deleteViaGui();
|
||||
|
||||
int countOfAllMessages() const;
|
||||
int countOfUnreadMessages() const;
|
||||
|
||||
@ -59,6 +62,8 @@ class TtRssFeed : public Feed {
|
||||
bool editItself(TtRssFeed *new_feed_data);
|
||||
|
||||
private:
|
||||
bool removeItself();
|
||||
|
||||
int updateMessages(const QList<Message> &messages);
|
||||
|
||||
int m_customId;
|
||||
|
Loading…
x
Reference in New Issue
Block a user