CURL_CFLAGS =
CURL_LIBS = -lcurl
CYGPATH_W = echo
-DEFS = -DPACKAGE_NAME=\"prss\" -DPACKAGE_TARNAME=\"prss\" -DPACKAGE_VERSION=\"0.0.x\" -DPACKAGE_STRING=\"prss\ 0.0.x\" -DPACKAGE_BUGREPORT=\"jeanfi@gmail.com\" -DPACKAGE_URL=\"http://wpitchoune.net/prss\" -DPACKAGE=\"prss\" -DVERSION=\"0.0.x\" -DENABLE_NLS=1 -DHAVE_GETTEXT=1 -DHAVE_DCGETTEXT=1
+DEFS = -DPACKAGE_NAME=\"prss\" -DPACKAGE_TARNAME=\"prss\" -DPACKAGE_VERSION=\"0.0.x\" -DPACKAGE_STRING=\"prss\ 0.0.x\" -DPACKAGE_BUGREPORT=\"jeanfi@gmail.com\" -DPACKAGE_URL=\"http://wpitchoune.net/prss\" -DPACKAGE=\"prss\" -DVERSION=\"0.0.x\" -DENABLE_NLS=1 -DHAVE_GETTEXT=1 -DHAVE_DCGETTEXT=1 -DHAVE_LIBPTHREAD=1
DEPDIR = .deps
ECHO_C =
ECHO_N = -n
LIBICONV = -liconv
LIBINTL =
LIBOBJS =
-LIBS =
+LIBS = -lpthread
LTLIBICONV = -liconv
LTLIBINTL =
LTLIBOBJS =
PKG_CONFIG_LIBDIR =
PKG_CONFIG_PATH =
POSUB = po
+PTHREAD_LIBS = -pthread
SET_MAKE =
SHELL = /bin/bash
STRIP =
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POSUB = @POSUB@
+PTHREAD_LIBS = @PTHREAD_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
S["CPPCHECK_TRUE"]=""
S["HAVE_CPPCHECK"]="yes"
S["HELP2MAN"]="help2man"
+S["PTHREAD_LIBS"]="-pthread"
S["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 "
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"\
S["target_alias"]=""
S["host_alias"]=""
S["build_alias"]=""
-S["LIBS"]=""
+S["LIBS"]="-lpthread "
S["ECHO_T"]=""
S["ECHO_N"]="-n"
S["ECHO_C"]=""
S["DEFS"]="-DPACKAGE_NAME=\\\"prss\\\" -DPACKAGE_TARNAME=\\\"prss\\\" -DPACKAGE_VERSION=\\\"0.0.x\\\" -DPACKAGE_STRING=\\\"prss\\ 0.0.x\\\" -DPACKAGE_BUGREPORT=\\\"jeanfi@gmail.c"\
-"om\\\" -DPACKAGE_URL=\\\"http://wpitchoune.net/prss\\\" -DPACKAGE=\\\"prss\\\" -DVERSION=\\\"0.0.x\\\" -DENABLE_NLS=1 -DHAVE_GETTEXT=1 -DHAVE_DCGETTEXT=1"
+"om\\\" -DPACKAGE_URL=\\\"http://wpitchoune.net/prss\\\" -DPACKAGE=\\\"prss\\\" -DVERSION=\\\"0.0.x\\\" -DENABLE_NLS=1 -DHAVE_GETTEXT=1 -DHAVE_DCGETTEXT=1 -DHAVE_L"\
+"IBPTHREAD=1"
S["mandir"]="${datarootdir}/man"
S["localedir"]="${datarootdir}/locale"
S["libdir"]="${exec_prefix}/lib"
CPPCHECK_TRUE
HAVE_CPPCHECK
HELP2MAN
+PTHREAD_LIBS
WEBKIT_LIBS
WEBKIT_CFLAGS
GSETTINGS_RULES
+# Checks pthread
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
+$as_echo_n "checking for pthread_create in -lpthread... " >&6; }
+if ${ac_cv_lib_pthread_pthread_create+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_create ();
+int
+main ()
+{
+return pthread_create ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_pthread_pthread_create=yes
+else
+ ac_cv_lib_pthread_pthread_create=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPTHREAD 1
+_ACEOF
+
+ LIBS="-lpthread $LIBS"
+
+fi
+
+PTHREAD_LIBS=-pthread
+
+
ac_config_files="$ac_config_files Makefile po/Makefile.in src/Makefile src/glade/Makefile tests/Makefile"
AC_SUBST(WEBKIT_CFLAGS)
AC_SUBST(WEBKIT_LIBS)
+# Checks pthread
+AC_CHECK_LIB(pthread, pthread_create)
+PTHREAD_LIBS=-pthread
+AC_SUBST(PTHREAD_LIBS)
+
AC_CONFIG_FILES([
Makefile
po/Makefile.in
DEFS = -DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" -DLOCALEDIR=\"$(localedir)\" @DEFS@
-LIBS = $(CURL_LIBS) $(JSON_LIBS) $(GTK_LIBS) $(WEBKIT_LIBS)
+LIBS = $(CURL_LIBS) $(JSON_LIBS) $(GTK_LIBS) $(PTHREAD_LIBS) $(WEBKIT_LIBS)
bin_PROGRAMS = prss
http.h \
io.c \
io.h \
+ list.c \
+ list.h \
log.c \
log.h \
ttrss.c \
ttrss_model.h \
ttrss_ws.c \
ttrss_ws.h \
+ ttrss_wsasync.c \
+ ttrss_wsasync.h \
url.c \
url.h \
webbrowser.c \
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
PROGRAMS = $(bin_PROGRAMS)
am_prss_OBJECTS = main.$(OBJEXT) http.$(OBJEXT) io.$(OBJEXT) \
- log.$(OBJEXT) ttrss.$(OBJEXT) ttrss_model.$(OBJEXT) \
- ttrss_ws.$(OBJEXT) url.$(OBJEXT) webbrowser.$(OBJEXT)
+ list.$(OBJEXT) log.$(OBJEXT) ttrss.$(OBJEXT) \
+ ttrss_model.$(OBJEXT) ttrss_ws.$(OBJEXT) \
+ ttrss_wsasync.$(OBJEXT) url.$(OBJEXT) webbrowser.$(OBJEXT)
prss_OBJECTS = $(am_prss_OBJECTS)
prss_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I.@am__isrc@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
-LIBS = $(CURL_LIBS) $(JSON_LIBS) $(GTK_LIBS) $(WEBKIT_LIBS)
+LIBS = $(CURL_LIBS) $(JSON_LIBS) $(GTK_LIBS) $(PTHREAD_LIBS) $(WEBKIT_LIBS)
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POSUB = @POSUB@
+PTHREAD_LIBS = @PTHREAD_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
http.h \
io.c \
io.h \
+ list.c \
+ list.h \
log.c \
log.h \
ttrss.c \
ttrss_model.h \
ttrss_ws.c \
ttrss_ws.h \
+ ttrss_wsasync.c \
+ ttrss_wsasync.h \
url.c \
url.h \
webbrowser.c \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttrss.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttrss_model.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttrss_ws.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttrss_wsasync.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/url.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webbrowser.Po@am__quote@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POSUB = @POSUB@
+PTHREAD_LIBS = @PTHREAD_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
--- /dev/null
+/*
+ * Copyright (C) 2010-2013 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "list.h"
+
+int list_length(void **list)
+{
+ int n;
+
+ if (!list)
+ return 0;
+
+ n = 0;
+ while (*list) {
+ n++;
+ list++;
+ }
+
+ return n;
+}
+
+void **list_add(void **list, void *item)
+{
+ int n;
+ void **result;
+
+ n = list_length(list);
+
+ result = malloc((n + 1 + 1) * sizeof(void *));
+
+ if (list)
+ memcpy(result, list, n * sizeof(void *));
+
+ result[n] = item;
+ result[n + 1] = NULL;
+
+ return result;
+}
+
+void list_free(void **list)
+{
+ free(list);
+}
--- /dev/null
+/*
+ * Copyright (C) 2010-2013 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _TTRSS_LIST_H_
+#define _TTRSS_LIST_H_
+
+int list_length(void **list);
+void **list_add(void **list, void *item);
+void list_free(void **list);
+
+#endif
#include "http.h"
#include "io.h"
#include "log.h"
-#include "ttrss_ws.h"
+#include "ttrss_wsasync.h"
#include "url.h"
static struct feed **data;
{
log_debug("ttrss_set_article_unread(%d,%d)", id, unread);
- ws_set_article_unread(id, unread);
+ ws_async_set_article_unread(id, unread);
log_debug("ttrss_set_article_unread(%d,%d)", id, unread);
}
#include <stdio.h>
#include <string.h>
+#include "list.h"
#include "ttrss_model.h"
-static int list_length(void **list)
-{
- int n;
-
- if (!list)
- return 0;
-
- n = 0;
- while (*list) {
- n++;
- list++;
- }
-
- return n;
-}
-
-static void **list_add(void **list, void *item)
-{
- int n;
- void **result;
-
- n = list_length(list);
-
- result = malloc((n + 1 + 1) * sizeof(void *));
-
- if (list)
- memcpy(result, list, n * sizeof(void *));
-
- result[n] = item;
- result[n + 1] = NULL;
-
- return result;
-}
-
struct headline **headlines_add(struct headline **list, struct headline *h)
{
return (struct headline **)list_add((void **)list, (void *)h);
if (session_id)
free(session_id);
+ session_id = NULL;
session_id = ws_login();
if (session_id) {
return feeds;
}
-void ws_set_article_unread(int id, int unread)
+struct json_object *ws_request_new_set_article_unread(int id, int unread)
{
- struct json_object *rp, *rq;
-
-
- log_debug("ws_set_article_unread(%d,%d)", id, unread);
+ struct json_object *rq;
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));
+ return rq;
+}
+
+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_set_article_unread(id, unread);
+
rp = ws_execute(rq);
json_object_put(rq);
int ws_update_headlines(struct feed *feed);
char *ws_get_article_content(int id);
void ws_set_article_unread(int id, int unread);
+struct json_object *ws_request_new_set_article_unread(int id, int unread);
#endif
--- /dev/null
+/*
+ * Copyright (C) 2010-2013 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <unistd.h>
+
+#include <pthread.h>
+
+#include <json/json.h>
+
+#include "list.h"
+#include "log.h"
+#include "ttrss_ws.h"
+#include "ttrss_wsasync.h"
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+static struct json_object **requests;
+
+static pthread_t *thread;
+
+void *loop()
+{
+ struct json_object **tmp, **cur, *rp, *rq;
+
+ while (1) {
+ log_debug("loop()");
+
+ pthread_mutex_lock(&lock);
+ if (requests) {
+ tmp = requests;
+ requests = NULL;
+ } else {
+ tmp = NULL;
+ }
+ pthread_mutex_unlock(&lock);
+
+ if (tmp) {
+ cur = tmp;
+ while (*cur) {
+ rq = *cur;
+ rp = ws_execute(rq);
+ json_object_put(rq);
+ if (rp)
+ json_object_put(rp);
+ cur++;
+ }
+ free(tmp);
+ }
+
+ log_debug("loop() done");
+ sleep(1);
+ }
+
+ pthread_exit(NULL);
+}
+
+void ws_async_set_article_unread(int id, int unread)
+{
+ struct json_object *rq, **tmp;
+
+ log_debug("ws_async_set_article_unread(%d,%d)", id, unread);
+
+ rq = ws_request_new_set_article_unread(id, unread);
+
+ pthread_mutex_lock(&lock);
+ if (!thread) {
+ thread = malloc(sizeof(pthread_t));
+ pthread_create(thread, NULL, loop, NULL);
+ }
+
+ tmp = (struct json_object **)list_add((void **)requests, rq);
+ list_free((void **)requests);
+ requests = tmp;
+ pthread_mutex_unlock(&lock);
+
+ log_debug("ws_async_set_article_unread(%d,%d) done", id, unread);
+}
--- /dev/null
+/*
+ * Copyright (C) 2010-2013 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _TTRSS_MODEL_WS_ASYNC_H_
+#define _TTRSS_MODEL_WS_ASYNC_H_
+
+#include "ttrss_ws.h"
+
+void ws_async_set_article_unread(int id, int unread);
+
+#endif
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POSUB = @POSUB@
+PTHREAD_LIBS = @PTHREAD_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@