diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG
index 0def609a7..727d48199 100755
--- a/resources/text/CHANGELOG
+++ b/resources/text/CHANGELOG
@@ -24,6 +24,7 @@ Fixed:
Changed:
+▪ Increased max feed network download timeout to 45 s.
▪ Adjusted behavior of Google suggestions when no suggestions are available for give text.
▪ Adjusted soěrting, particularly in message list.
▪ Tweaked "remove duplicates" policy.
diff --git a/src/gui/dialogs/formsettings.ui b/src/gui/dialogs/formsettings.ui
index 7b4bf9042..4ce276223 100755
--- a/src/gui/dialogs/formsettings.ui
+++ b/src/gui/dialogs/formsettings.ui
@@ -495,8 +495,8 @@ Authors of this application are NOT responsible for lost data.
0
0
- 776
- 425
+ 167
+ 219
@@ -1404,7 +1404,7 @@ Authors of this application are NOT responsible for lost data.
100
- 15000
+ 45000
100
diff --git a/src/services/owncloud/network/owncloudnetworkfactory.cpp b/src/services/owncloud/network/owncloudnetworkfactory.cpp
index bd7cb0b2a..e11118ba4 100755
--- a/src/services/owncloud/network/owncloudnetworkfactory.cpp
+++ b/src/services/owncloud/network/owncloudnetworkfactory.cpp
@@ -21,6 +21,7 @@
#include "network-web/networkfactory.h"
#include "miscellaneous/application.h"
#include "miscellaneous/settings.h"
+#include "miscellaneous/textfactory.h"
#include "services/abstract/rootitem.h"
#include "services/owncloud/owncloudcategory.h"
#include "services/owncloud/owncloudfeed.h"
@@ -31,7 +32,7 @@
OwnCloudNetworkFactory::OwnCloudNetworkFactory()
: m_url(QString()), m_forceServerSideUpdate(false),
m_authUsername(QString()), m_authPassword(QString()), m_urlUser(QString()), m_urlStatus(QString()),
- m_urlFolders(QString()), m_urlFeeds(QString()), m_userId(QString()) {
+ m_urlFolders(QString()), m_urlFeeds(QString()), m_urlMessages(QString()), m_userId(QString()) {
}
OwnCloudNetworkFactory::~OwnCloudNetworkFactory() {
@@ -57,6 +58,7 @@ void OwnCloudNetworkFactory::setUrl(const QString &url) {
m_urlStatus = working_url + API_PATH + "status";
m_urlFolders = working_url + API_PATH + "folders";
m_urlFeeds = working_url + API_PATH + "feeds";
+ m_urlMessages = working_url + API_PATH + "items?id=%1&batchSize=%2&type=%3";
}
bool OwnCloudNetworkFactory::forceServerSideUpdate() const {
@@ -159,6 +161,27 @@ OwnCloudGetFeedsCategoriesResponse OwnCloudNetworkFactory::feedsCategories() {
return OwnCloudGetFeedsCategoriesResponse(content_categories, content_feeds);
}
+OwnCloudGetMessagesResponse OwnCloudNetworkFactory::getMessages(int feed_id) {
+ QString final_url = m_urlMessages.arg(QString::number(feed_id),
+ QString::number(-1),
+ QString::number(0));
+ QByteArray result_raw;
+ NetworkResult network_reply = NetworkFactory::downloadFile(final_url,
+ qApp->settings()->value(GROUP(Feeds),
+ SETTING(Feeds::UpdateTimeout)).toInt(),
+ result_raw,
+ true, m_authUsername, m_authPassword,
+ true);
+ OwnCloudGetMessagesResponse msgs_response(QString::fromUtf8(result_raw));
+
+ if (network_reply.first != QNetworkReply::NoError) {
+ qWarning("ownCloud: Obtaining messages failed with error %d.", network_reply.first);
+ }
+
+ m_lastError = network_reply.first;
+ return msgs_response;
+}
+
QString OwnCloudNetworkFactory::userId() const {
return m_userId;
}
@@ -312,3 +335,46 @@ RootItem *OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
return parent;
}
+
+
+OwnCloudGetMessagesResponse::OwnCloudGetMessagesResponse(const QString &raw_content) : OwnCloudResponse(raw_content) {
+}
+
+OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() {
+}
+
+QList OwnCloudGetMessagesResponse::messages() const {
+ QList msgs;
+
+ foreach (QVariant message, m_rawContent["items"].toList()) {
+ QMap message_map = message.toMap();
+ Message msg;
+
+ msg.m_author = message_map["author"].toString();
+ msg.m_contents = message_map["body"].toString();
+ msg.m_created = TextFactory::parseDateTime(message_map["pubDate"].value());
+ msg.m_createdFromFeed = true;
+ msg.m_customId = message_map["id"].toString();
+
+ QString enclosure_link = message_map["enclosureLink"].toString();
+
+ if (!enclosure_link.isEmpty()) {
+ Enclosure enclosure;
+
+ enclosure.m_mimeType = message_map["enclosureMime"].toString();
+ enclosure.m_url = enclosure_link;
+
+ msg.m_enclosures.append(enclosure);
+ }
+
+ msg.m_feedId = message_map["feedId"].toString();
+ msg.m_isImportant = message_map["starred"].toBool();
+ msg.m_isRead = !message_map["unread"].toBool();
+ msg.m_title = message_map["title"].toString();
+ msg.m_url = message_map["url"].toString();
+
+ msgs.append(msg);
+ }
+
+ return msgs;
+}
diff --git a/src/services/owncloud/network/owncloudnetworkfactory.h b/src/services/owncloud/network/owncloudnetworkfactory.h
index a810c268c..0a5d2fb8a 100755
--- a/src/services/owncloud/network/owncloudnetworkfactory.h
+++ b/src/services/owncloud/network/owncloudnetworkfactory.h
@@ -24,6 +24,7 @@
#include
#include "qt-json/json.h"
+#include "core/message.h"
class OwnCloudResponse {
@@ -49,6 +50,14 @@ class OwnCloudUserResponse : public OwnCloudResponse {
QIcon avatar() const;
};
+class OwnCloudGetMessagesResponse : public OwnCloudResponse {
+ public:
+ explicit OwnCloudGetMessagesResponse(const QString &raw_content = QString());
+ virtual ~OwnCloudGetMessagesResponse();
+
+ QList messages() const;
+};
+
class OwnCloudStatusResponse : public OwnCloudResponse {
public:
explicit OwnCloudStatusResponse(const QString &raw_content = QString());
@@ -109,6 +118,9 @@ class OwnCloudNetworkFactory {
// Get feeds & categories (used for sync-in).
OwnCloudGetFeedsCategoriesResponse feedsCategories();
+ // Get messages for given feed.
+ OwnCloudGetMessagesResponse getMessages(int feed_id);
+
private:
QString m_url;
bool m_forceServerSideUpdate;
@@ -121,6 +133,7 @@ class OwnCloudNetworkFactory {
QString m_urlStatus;
QString m_urlFolders;
QString m_urlFeeds;
+ QString m_urlMessages;
QString m_userId;
};
diff --git a/src/services/owncloud/owncloudfeed.cpp b/src/services/owncloud/owncloudfeed.cpp
index 96e4332aa..0d67a5328 100755
--- a/src/services/owncloud/owncloudfeed.cpp
+++ b/src/services/owncloud/owncloudfeed.cpp
@@ -18,6 +18,8 @@
#include "owncloudfeed.h"
#include "miscellaneous/iconfactory.h"
+#include "services/owncloud/owncloudserviceroot.h"
+#include "services/owncloud/network/owncloudnetworkfactory.h"
OwnCloudFeed::OwnCloudFeed(RootItem *parent) : Feed(parent) {
@@ -35,9 +37,37 @@ OwnCloudFeed::OwnCloudFeed(const QSqlRecord &record) : Feed(NULL) {
OwnCloudFeed::~OwnCloudFeed() {
}
+OwnCloudServiceRoot *OwnCloudFeed::serviceRoot() const {
+ return qobject_cast(getParentServiceRoot());
+}
+
int OwnCloudFeed::update() {
- // TODO: TODO
- return 0;
+ OwnCloudGetMessagesResponse headlines = serviceRoot()->network()->getMessages(customId());
+
+ if (serviceRoot()->network()->lastError() != QNetworkReply::NoError) {
+ setStatus(Feed::Error);
+ serviceRoot()->itemChanged(QList() << this);
+ return 0;
+ }
+ else {
+ return 0;
+ // TODO: TODO
+ // Udělat změnu tuto v tabulkách které mají sloupec custom_id
+ // Udělat to tak, že custom_id se bude vyplňovat pro všechny
+ // položky v Feeds, Categories a Messages
+ // taky tu property budou mít všechny příslušné objekty
+ // u standardních Feeds, Categories a Message se custom_id == id
+ //
+ // toto pak umožní přesunout všechny metody, které budou s custom ID a ID
+ // pracovat, do třídy předka a ušetřit kód.
+ //
+ /*
+ *UPDATE Categories
+SET custom_id = (SELECT id FROM Categories t WHERE t.id = Categories.id)
+WHERE Categories.custom_id IS NULL;
+ *
+ * //return updateMessages(headlines.messages());
+ }
}
int OwnCloudFeed::messageForeignKeyId() const {
diff --git a/src/services/owncloud/owncloudfeed.h b/src/services/owncloud/owncloudfeed.h
index 67d58b0ad..e9bf218bc 100755
--- a/src/services/owncloud/owncloudfeed.h
+++ b/src/services/owncloud/owncloudfeed.h
@@ -21,12 +21,15 @@
#include "services/abstract/feed.h"
+class OwnCloudServiceRoot;
+
class OwnCloudFeed : public Feed {
public:
explicit OwnCloudFeed(RootItem *parent = NULL);
explicit OwnCloudFeed(const QSqlRecord &record);
virtual ~OwnCloudFeed();
+ OwnCloudServiceRoot *serviceRoot() const;
int update();
int messageForeignKeyId() const;
};
diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp
index 06f918ecf..d9cd02dcd 100755
--- a/src/services/standard/standardfeed.cpp
+++ b/src/services/standard/standardfeed.cpp
@@ -610,7 +610,11 @@ int StandardFeed::messageForeignKeyId() const {
}
int StandardFeed::updateMessages(const QList &messages) {
- int feed_id = id();
+ if (messages.isEmpty()) {
+ return 0;
+ }
+
+ int feed_id = messageForeignKeyId();
int updated_messages = 0;
bool anything_duplicated = false;
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
diff --git a/src/services/tt-rss/ttrssfeed.cpp b/src/services/tt-rss/ttrssfeed.cpp
index 665499e53..f7eed003d 100755
--- a/src/services/tt-rss/ttrssfeed.cpp
+++ b/src/services/tt-rss/ttrssfeed.cpp
@@ -298,7 +298,7 @@ int TtRssFeed::updateMessages(const QList &messages) {
return 0;
}
- int feed_id = customId();
+ int feed_id = messageForeignKeyId();
int updated_messages = 0;
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
int account_id = serviceRoot()->accountId();