- set = dom.firstChildElement();
-
- for(n = set.firstChild(); !n.isNull(); n = n.nextSibling()) {
- e = n.toElement();
- QString name = e.tagName();
- if(name == "entry") {
- Entry entry;
- QString content, summary;
-
- QString locked = e.attribute("gr:is-read-state-locked", "false");
- if(locked == "true")
- entry.flags |= ENTRY_FLAG_LOCKED | ENTRY_FLAG_READ;
-
- entry.crawled = e.attribute("gr:crawl-timestamp-msec", "0").toULongLong();
-
- for(c = n.firstChild(); !c.isNull(); c = c.nextSibling()) {
- e = c.toElement();
- name = e.tagName();
- if(name == "id")
- entry.id = e.text();
- else if(name == "title") {
- QWebPage p;
- p.mainFrame()->setHtml(e.text());
- entry.title = p.mainFrame()->toPlainText();
- }
- else if(name == "published")
- entry.published = QDateTime::fromString(e.text(), "yyyy-MM-dd'T'HH:mm:ss'Z'");
- else if(name == "link")
- entry.link = QUrl(e.attribute("href", ""));
- else if(name == "source")
- entry.source = e.attribute("gr:stream-id", "");
- else if(name == "content")
- content = e.text();
- else if(name == "summary")
- summary = e.text();
- else if(name == "author") {
- e = c.firstChild().toElement();
- entry.author = e.text();
- if(entry.author == "(author unknown)")
- entry.author = "";
- }
- else if(name == "category") {
- QString label = e.attribute("label", "");
- if(label == "read")
- entry.flags |= ENTRY_FLAG_READ;
- else if(label == "starred")
- entry.flags |= ENTRY_FLAG_STARRED;
- else if(label == "broadcast")
- entry.flags |= ENTRY_FLAG_SHARED;
- }
- }
-
- if(content != "")
- entry.content = content;
- else if(summary != "")
- entry.content = summary;
-
- if(!feed)
- feed = feeds.value(feedsource == "" ? entry.source : feedsource);
-
- if(feed) {
- entry.feed = feed;
- feed->addEntry(new Entry(entry));
- }
- }
- else if(name == "gr:continuation") {
- continuation = e.text();
+ id = result["id"].toString();
+ continuation = result["continuation"].toString();
+
+ /* TODO: This hack should not be needed.. Figure out a cleaner way */
+ if(id.endsWith("/state/com.google/starred"))
+ feedsource = "user/-/state/com.google/starred";
+ else if(id.endsWith("/state/com.google/broadcast"))
+ feedsource = "user/-/state/com.google/broadcast";
+
+ foreach(QVariant l, result["items"].toList()) {
+ QVariantMap e = l.toMap();
+ Entry entry;
+ QString content, summary;
+
+ entry.id = e["id"].toString();
+ entry.published = QDateTime::fromTime_t(e["published"].toUInt());
+ entry.author = e["author"].toString();
+ entry.source = (e["origin"].toMap())["streamId"].toString();
+ entry.link = (e["alternate"].toMap())["href"].toString();
+
+ content = (e["content"].toMap())["content"].toString();
+ summary = (e["summary"].toMap())["content"].toString();
+ if(content != "") entry.content = content; else entry.content = summary;
+
+ if(e["isReadStateLocked"].toBool())
+ entry.flags |= ENTRY_FLAG_LOCKED | ENTRY_FLAG_READ;
+
+ QWebPage p;
+ p.mainFrame()->setHtml(e["title"].toString());
+ entry.title = p.mainFrame()->toPlainText();
+
+ foreach(QVariant c, e["categories"].toList()) {
+ QString cat = c.toString();
+ if(cat.endsWith("/state/com.google/read"))
+ entry.flags |= ENTRY_FLAG_READ;
+ else if(cat.endsWith("/state/com.google/starred"))
+ entry.flags |= ENTRY_FLAG_STARRED;
+ else if(cat.endsWith("/state/com.google/broadcast"))
+ entry.flags |= ENTRY_FLAG_SHARED;