fixed code style
[prss.git] / src / ttrss_ws.c
index 12595d3..e9680f4 100644 (file)
@@ -134,8 +134,10 @@ execute(struct http_session *sess, struct json_object *rq, char **err)
 
                        if (str) {
                                log_debug("execute() err=%s", str);
-                               *err = strdup(str);
                                content = NULL;
+
+                               if (err)
+                                       *err = strdup(str);
                        } else {
                                json_object_get(content);
                        }
@@ -144,6 +146,8 @@ execute(struct http_session *sess, struct json_object *rq, char **err)
                json_object_put(rp);
        }
 
+       log_debug("execute() done");
+
        return content;
 }
 
@@ -255,32 +259,56 @@ int ws_open_session()
        return result;
 }
 
-char *ws_get_article_content(int id)
+struct json_object *ws_request_new_get_article_content(int id)
 {
-       struct json_object *rp, *rq, *content, *item;
-       char *str;
+       struct json_object *rq;
 
        rq = ws_request_new("getArticle");
        ws_request_add_att_int(rq, "article_id", id);
 
-       rp = ws_execute(rq);
-
-       json_object_put(rq);
+       return rq;
+}
 
-       str = NULL;
+const char *ws_reply_get_article_content(struct json_object *rp)
+{
+       struct json_object *item, *content;
 
        if (rp) {
                item = json_object_array_get_idx(rp, 0);
 
                if (item) {
                        content = json_object_object_get(item, "content");
-                       str = strdup(json_object_get_string(content));
+                       return json_object_get_string(content);
                }
+       }
 
-               json_object_put(rp);
+       return NULL;
+}
+
+char *ws_get_article_content(int id)
+{
+       struct json_object *rp, *rq;
+       const char *content;
+       char *str;
+
+       rq = ws_request_new("getArticle");
+       ws_request_add_att_int(rq, "article_id", id);
+
+       rp = ws_execute(rq);
+
+       json_object_put(rq);
+
+       if (rp) {
+               content = ws_reply_get_article_content(rp);
+
+               if (content) {
+                       str = strdup(content);
+                       json_object_put(rp);
+                       return str;
+               }
        }
 
-       return str;
+       return NULL;
 }
 
 int ws_update_headlines(struct feed *feed)
@@ -292,7 +320,6 @@ int ws_update_headlines(struct feed *feed)
 
        rq = ws_request_new("getHeadlines");
        ws_request_add_att_int(rq, "feed_id", feed->id);
-       ws_request_add_att_bool(rq, "show_excerpt", 1);
 
        rp = ws_execute(rq);
 
@@ -317,10 +344,6 @@ int ws_update_headlines(struct feed *feed)
                                h = headline_new(hid, url, title);
 
                                j = json_object_object_get(jheadline,
-                                                          "excerpt");
-                               h->excerpt = strdup(json_object_get_string(j));
-
-                               j = json_object_object_get(jheadline,
                                                           "updated");
                                h->date = json_object_get_int(j);