-
- json_object_put(rp);
- return !err;
-}
-
-const char *ttrss_get_headline_content(struct headline *h)
-{
- if (!h->content)
- h->content = ws_get_article_content(h->id);
-
- return h->content;
-}
-
-
-struct feed **ttrss_get_feeds()
-{
- struct json_object *rp, *rq, *content, *jfeed, *j;
- int i, n;
- struct feed **feeds, *feed, **tmp;
-
- printf("ttrss_get_feeds\n");
-
- rq = ws_request_new("getFeeds");
-
- rp = http_json_get(session_url, rq);
- json_object_put(rq);
-
- content = json_object_object_get(rp, "content");
-
- if (content) {
- n = json_object_array_length(content);
-
- feeds = NULL;
- for (i = 0; i < n; i++) {
- jfeed = json_object_array_get_idx(content, i);
-
- feed = malloc(sizeof(struct feed));
-
- j = json_object_object_get(jfeed, "title");
- feed->title = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jfeed, "feed_url");
- feed->url = strdup(json_object_get_string(j));
-
- j = json_object_object_get(jfeed, "id");
- feed->id = json_object_get_int(j);
-
- j = json_object_object_get(jfeed, "unread");
- feed->unread = json_object_get_int(j);
-
- feed->headlines = NULL;
-
- tmp = (struct feed **)list_add((void **)feeds, feed);
- free(feeds);
- feeds = tmp;
- }
- } else {
- feeds = NULL;
- }
-
- json_object_put(rp);
-
- printf("ttrss_get_feeds ended\n");
-
- return feeds;
-}
-
-struct headline **ttrss_get_headlines(struct feed *f)
-{
- if (!f->headlines)
- ws_update_headlines(f);
-
- return f->headlines;
-}
-
-void ttrss_set_article_unread(int id, int unread)
-{
- struct json_object *rp, *rq;
-
- printf("ttrss_set_article_unread %d %d\n", id, unread);
-
- rq = ws_request_new("updateArticle");
- json_object_object_add(rq, "article_ids", json_object_new_int(id));
- json_object_object_add(rq, "field", json_object_new_int(2));
- json_object_object_add(rq, "mode", json_object_new_int(unread));
-
- rp = http_json_get(session_url, rq);
-
- json_object_put(rq);
- json_object_put(rp);