From: Philip Chimento Date: Sat, 16 Jul 2011 21:51:47 +0000 (+0200) Subject: Ported babeltest to libsoup X-Git-Tag: v0.9~65 X-Git-Url: https://git.stderr.nl/gitweb?p=projects%2Fchimara%2Fchimara.git;a=commitdiff_plain;h=4a0178d00f3ab8741f5ef10a44a63d49e19d0cd3 Ported babeltest to libsoup --- diff --git a/configure.ac b/configure.ac index 3fb5d01..fa284e1 100644 --- a/configure.ac +++ b/configure.ac @@ -133,11 +133,18 @@ PKG_CHECK_MODULES([CHIMARA], [ ]) CHIMARA_LIBS="$CHIMARA_LIBS -lm" AC_SUBST(CHIMARA_LIBS) +# Libraries needed to build Chimara player +PKG_CHECK_MODULES([PLAYER], [ + glib-2.0 >= $GLIB_REQUIRED_VERSION + gtk+-2.0 >= $GTK_REQUIRED_VERSION + gmodule-2.0 + libgda-4.0 + libsoup-2.4 +]) # Libraries needed to build test programs PKG_CHECK_MODULES([TEST], [ gtk+-2.0 >= $GTK_REQUIRED_VERSION gmodule-2.0 >= $GLIB_REQUIRED_VERSION - libgda-4.0 ]) # GStreamer plugins needed to run library diff --git a/player/Makefile.am b/player/Makefile.am index 2482798..588f183 100644 --- a/player/Makefile.am +++ b/player/Makefile.am @@ -21,8 +21,8 @@ chimara_CPPFLAGS = $(AM_CPPFLAGS) \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \ -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" -chimara_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS) -chimara_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la +chimara_CFLAGS = @PLAYER_CFLAGS@ $(AM_CFLAGS) +chimara_LDADD = @PLAYER_LIBS@ $(top_builddir)/libchimara/libchimara.la gsettings_SCHEMAS = org.chimara-if.gschema.xml @GSETTINGS_RULES@ diff --git a/tests/Makefile.am b/tests/Makefile.am index 8f987c6..1fed105 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -30,8 +30,8 @@ test_close_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS) test_close_LDADD = @TEST_LIBS@ $(top_builddir)/libchimara/libchimara.la babeltest_SOURCES = babeltest.c -babeltest_CFLAGS = @TEST_CFLAGS@ $(AM_CFLAGS) -babeltest_LDADD = @TEST_LIBS@ $(top_builddir)/babel/libbabel_functions.la $(top_builddir)/babel/libbabel.la $(top_builddir)/babel/libifiction.la -lghttp +babeltest_CFLAGS = @PLAYER_CFLAGS@ $(AM_CFLAGS) +babeltest_LDADD = @PLAYER_LIBS@ $(top_builddir)/babel/libbabel_functions.la $(top_builddir)/babel/libbabel.la $(top_builddir)/babel/libifiction.la noinst_LTLIBRARIES = first.la model.la gridtest.la splittest.la multiwin.la \ styletest.la soundtest.la test-userstyle.la fileio.la diff --git a/tests/babeltest.c b/tests/babeltest.c index 011b83b..2e8827e 100644 --- a/tests/babeltest.c +++ b/tests/babeltest.c @@ -6,8 +6,8 @@ #include #include #include -#include -#include +#include +#include typedef struct _metadata { const gchar *element_name; @@ -123,6 +123,8 @@ int main(int argc, char **argv) { return 1; } + g_type_init(); + babel_init(argv[1]); int len = babel_treaty(GET_STORY_FILE_METADATA_EXTENT_SEL, NULL, 0); gchar *ifiction; @@ -143,17 +145,18 @@ int main(int argc, char **argv) { printf("Looking up IFID: %s.\n", ifid); babel_release(); - ghttp_request *request = ghttp_request_new(); - ghttp_set_uri(request, g_strconcat("http://ifdb.tads.org/viewgame?ifiction&ifid=", ifid, NULL)); - ghttp_set_header(request, http_hdr_Connection, "close"); - ghttp_prepare(request); - ghttp_process(request); - - ifiction = g_strndup( ghttp_get_body(request), ghttp_get_body_len(request) ); - ghttp_request_destroy(request); + SoupSession *session = soup_session_async_new(); + char *uri_string = g_strconcat("http://ifdb.tads.org/viewgame?ifiction&ifid=", ifid, NULL); + SoupMessage *message = soup_message_new("GET", uri_string); + g_free(uri_string); + soup_message_headers_append(message->request_headers, "Connection", "close"); + if(soup_session_send_message(session, message) != 200) + g_printerr("ERROR: did not get HTTP status 200\n"); + ifiction = g_strndup(message->response_body->data, message->response_body->length); + g_object_unref(message); + g_object_unref(session); } - ifiction = g_strchomp(ifiction); GMarkupParser xml_parser = {start_element, end_element, text, NULL, NULL};