From c3a914af1b3476496ced078028785cc408d0dddc Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 26 Sep 2017 13:44:07 +0200 Subject: [PATCH] Now downloading feeds. --- .../network/inoreadernetworkfactory.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/services/inoreader/network/inoreadernetworkfactory.cpp b/src/services/inoreader/network/inoreadernetworkfactory.cpp index 96b5c91c2..1a49f8b64 100755 --- a/src/services/inoreader/network/inoreadernetworkfactory.cpp +++ b/src/services/inoreader/network/inoreadernetworkfactory.cpp @@ -28,6 +28,7 @@ #include "network-web/webfactory.h" #include "services/abstract/category.h" #include "services/inoreader/definitions.h" +#include "services/inoreader/inoreaderfeed.h" #include #include @@ -143,5 +144,37 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ } } + json = QJsonDocument::fromJson(feeds.toUtf8()).object()["subscriptions"].toArray(); + + foreach (const QJsonValue& obj, json) { + auto subscription = obj.toObject(); + QString id = subscription["id"].toString(); + QString title = subscription["title"].toString(); + QString url = subscription["htmlUrl"].toString(); + QString parent_label; + QJsonArray categories = subscription["categories"].toArray(); + + foreach (const QJsonValue& cat, categories) { + QString potential_id = cat.toObject()["id"].toString(); + + if (potential_id.contains(QSL("/label/"))) { + parent_label = potential_id; + break; + } + } + + // We have label (not "state"). + InoreaderFeed* feed = new InoreaderFeed(); + + feed->setDescription(url); + feed->setUrl(url); + feed->setTitle(title); + feed->setCustomId(id); + + if (cats.contains(parent_label)) { + cats[parent_label]->appendChild(feed); + } + } + return parent; }