From f96659e59301af90fd058031486a98317b077caa Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Fri, 26 Apr 2013 21:54:56 +0000 Subject: [PATCH] --- Makefile | 4 ++-- config.status | 6 +++--- src/log.c | 2 +- src/ttrss_ws.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 52 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index f894675..5c37ab8 100644 --- a/Makefile +++ b/Makefile @@ -184,7 +184,7 @@ GMSGFMT = /usr/bin/msgfmt GMSGFMT_015 = /usr/bin/msgfmt GREP = /bin/grep GSETTINGS_DISABLE_SCHEMAS_COMPILE = -GTK_CFLAGS = -pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -DGTK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGSEAL_ENABLE +GTK_CFLAGS = -pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -DGTK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGSEAL_ENABLE GTK_LIBS = -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 HAVE_CPPCHECK = yes HELP2MAN = help2man @@ -228,7 +228,7 @@ SHELL = /bin/bash STRIP = USE_NLS = yes VERSION = 0.0.x -WEBKIT_CFLAGS = -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/libsoup-2.4 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/libxml2 -I/usr/include/webkitgtk-3.0 +WEBKIT_CFLAGS = -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/libsoup-2.4 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/libxml2 -I/usr/include/webkitgtk-3.0 WEBKIT_LIBS = -lwebkitgtk-3.0 -lgtk-3 -lsoup-2.4 -ljavascriptcoregtk-3.0 -lgdk-3 -latk-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgio-2.0 -lgobject-2.0 -lglib-2.0 X11_CFLAGS = X11_LIBS = -lX11 diff --git a/config.status b/config.status index 870123f..ef4001c 100755 --- a/config.status +++ b/config.status @@ -620,7 +620,7 @@ S["WEBKIT_LIBS"]="-lwebkitgtk-3.0 -lgtk-3 -lsoup-2.4 -ljavascriptcoregtk-3.0 -lg "lgio-2.0 -lgobject-2.0 -lglib-2.0 " S["WEBKIT_CFLAGS"]="-pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/libsoup-2.4 -I/usr/include/atk-1"\ ".0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/in"\ -"clude/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/libxml2 -I/usr/include/webkitgtk-3.0 " +"clude/harfbuzz -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/libxml2 -I/usr/include/webkitgtk-3.0 " S["GSETTINGS_RULES"]="\n"\ ".PHONY : uninstall-gsettings-schemas install-gsettings-schemas clean-gsettings-schemas\n"\ "\n"\ @@ -673,8 +673,8 @@ S["CURL_LIBS"]="-lcurl " S["CURL_CFLAGS"]=" " S["GTK_LIBS"]="-lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 " S["GTK_CFLAGS"]="-pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/i"\ -"nclude/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/incl"\ -"ude/pixman-1 -I/usr/include/libpng12 -DGTK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGSEAL_ENABLE " +"nclude/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/inclu"\ +"de/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12 -DGTK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGSEAL_ENABLE " S["XEXT_LIBS"]="-lXext " S["XEXT_CFLAGS"]=" " S["X11_LIBS"]="-lX11 " diff --git a/src/log.c b/src/log.c index 3009e5d..f5185d3 100644 --- a/src/log.c +++ b/src/log.c @@ -87,7 +87,7 @@ static void vlogf(int lvl, const char *fmt, va_list ap) "[%ld.%06ld] %s %s\n", tv.tv_sec, tv.tv_usec, - lvl_str, + lvl_str, buffer); fflush(file); } diff --git a/src/ttrss_ws.c b/src/ttrss_ws.c index 94f0fee..8ec1746 100644 --- a/src/ttrss_ws.c +++ b/src/ttrss_ws.c @@ -88,25 +88,59 @@ struct json_object *ws_reply_get_content(struct json_object *rp) return json_object_object_get(rp, "content"); } -struct json_object *ws_execute(struct json_object *rq) +static struct json_object *execute(struct json_object *rq, char **err) { - struct json_object *rp, *content; + struct json_object *rp, *content, *jerror; + const char *str; rp = http_json_get(session_url, rq); + content = NULL; + if (rp) { content = ws_reply_get_content(rp); - if (content && !json_object_object_get(rp, "error")) { - json_object_get(content); - json_object_put(rp); - return content; + if (content) { + jerror = json_object_object_get(content, "error"); + if (jerror) { + if (err) { + str = json_object_get_string(jerror); + *err = strdup(str); + } + content = NULL; + } else { + json_object_get(content); + } } json_object_put(rp); } - return NULL; + return content; +} + +struct json_object *ws_execute(struct json_object *rq) +{ + char *err; + struct json_object *result; + + log_debug("ws_execute()"); + + err = NULL; + result = execute(rq, &err); + + if (err) { + log_debug("ws_execute(): error=%s\n", err); + + if (!strcmp(err, "NOT_LOGGED_IN")) { + ws_open_session(); + result = execute(rq, NULL); + } + + free(err); + } + + return result; } int ws_get_api_version() @@ -151,7 +185,7 @@ char *ws_login() str = strdup(json_object_get_string(j)); json_object_put(rp); - } + } return str; } @@ -160,6 +194,8 @@ int ws_open_session() { int version, result; + log_debug("ws_open_session()"); + if (session_id) free(session_id); @@ -315,7 +351,8 @@ struct feed **ws_update_feeds(struct feed **feeds) void ws_set_article_unread(int id, int unread) { struct json_object *rp, *rq; - + + log_debug("ws_set_article_unread(%d,%d)", id, unread); rq = ws_request_new("updateArticle"); -- 2.7.4