libsoup r1082 - trunk/python



Author: danw
Date: Sat Feb  9 23:33:22 2008
New Revision: 1082
URL: http://svn.gnome.org/viewvc/libsoup?rev=1082&view=rev

Log:
	First draft of libsoup python bindings. Not complete, not final,
	etc. (And not built by default and not installed.)


Added:
   trunk/python/   (props changed)
   trunk/python/AUTHORS
   trunk/python/ChangeLog
   trunk/python/Makefile.am
   trunk/python/NEWS
   trunk/python/README
   trunk/python/SoupLogger.override
   trunk/python/SoupMessageBody.override
   trunk/python/SoupMessageHeaders.override
   trunk/python/SoupURI.override
   trunk/python/acinclude.m4
   trunk/python/configure.in
   trunk/python/libsoup-ignore.defs
   trunk/python/libsoup.defs
   trunk/python/libsoup.override
   trunk/python/libsoupmodule.c
   trunk/python/soup-forms.override
   trunk/python/soup-headers.override
   trunk/python/soup-xmlrpc.override

Added: trunk/python/AUTHORS
==============================================================================

Added: trunk/python/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/python/Makefile.am	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,24 @@
+AUTOMAKE_OPTIONS=1.5
+
+INCLUDES =			\
+	$(PYTHON_INCLUDES)	\
+	$(PYGOBJECT_CFLAGS)	\
+	$(SOUP_CFLAGS)
+
+noinst_LTLIBRARIES = soup.la
+soup_la_LDFLAGS = -module -avoid-version -export-symbols-regex initsoup
+soup_la_LIBADD = $(SOUP_LIBS)
+soup_la_SOURCES = libsoupmodule.c
+nodist_soup_la_SOURCES = libsoup.c
+libsoup.c: libsoup.defs *.override
+CLEANFILES = libsoup.c
+EXTRA_DIST = *.override
+
+.defs.c:
+	(cd $(srcdir)\
+	 && pygtk-codegen-2.0 \
+		--register $(GIO_DEFS) \
+		--override $*.override \
+		--prefix py$* $*.defs) > gen-$*.c \
+	&& cp gen-$*.c $*.c \
+	&& rm -f gen-$*.c

Added: trunk/python/NEWS
==============================================================================

Added: trunk/python/README
==============================================================================
--- (empty file)
+++ trunk/python/README	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,6 @@
+Incomplete, unfinished, not heavily tested, etc, etc, etc
+
+If you want to use these, you'll have to copy the sources into your
+project and build them locally.
+
+Eventually they will be installed along with libsoup...

Added: trunk/python/SoupLogger.override
==============================================================================
--- (empty file)
+++ trunk/python/SoupLogger.override	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,140 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * SoupLogger.override: overrides for SoupLogger
+ */
+%%
+override soup_logger_set_request_filter kwargs
+
+static SoupLoggerLogLevel
+pysoup_logger_filter (SoupLogger *logger, SoupMessage *msg, gpointer user_data)
+{
+    PySoupCallback *psc = user_data;
+    PyGILState_STATE state;
+    PyObject *py_msg, *py_ret;
+    SoupLoggerLogLevel ret = SOUP_LOGGER_LOG_NONE;
+ 
+    state = pyg_gil_state_ensure ();
+ 
+    py_msg = pygobject_new ((GObject *)msg);
+    if (psc->data)
+        py_ret = PyEval_CallFunction (psc->func, "(NO)", py_msg, psc->data);
+    else
+        py_ret = PyEval_CallFunction (psc->func, "(N)", py_msg);
+
+    if (py_ret != NULL) {
+	if (pyg_enum_get_value (SOUP_TYPE_LOGGER_LOG_LEVEL,
+				py_ret, (gpointer)&ret) != 0)
+	    PyErr_Print ();
+	Py_DECREF (py_ret);
+    } else
+	PyErr_Print ();
+
+    pyg_gil_state_release (state);
+    return ret;
+}
+
+static PyObject *
+_wrap_soup_logger_set_request_filter (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "request_filter", "filter_data", NULL };
+    PyObject *pyfunc, *pyarg = NULL;
+    PySoupCallback *psc;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "O|O:SoupLogger.set_request_filter",
+				      kwlist, &pyfunc, &pyarg))
+        return NULL;
+    if (!PyCallable_Check (pyfunc)) {
+        PyErr_SetString (PyExc_TypeError, "request_filter must be a callable object");
+        return NULL;
+    }
+
+    psc = pysoup_callback_new (pyfunc, pyarg);
+    soup_logger_set_request_filter (SOUP_LOGGER (self->obj),
+				    pysoup_logger_filter, psc,
+				    pysoup_callback_destroy_notify);
+
+    Py_INCREF (Py_None);
+    return Py_None;
+}
+%%
+override soup_logger_set_response_filter kwargs
+static PyObject *
+_wrap_soup_logger_set_response_filter (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "response_filter", "filter_data", NULL };
+    PyObject *pyfunc, *pyarg = NULL;
+    PySoupCallback *psc;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "O|O:SoupLogger.set_response_filter",
+				      kwlist, &pyfunc, &pyarg))
+        return NULL;
+    if (!PyCallable_Check (pyfunc)) {
+        PyErr_SetString (PyExc_TypeError, "response_filter must be a callable object");
+        return NULL;
+    }
+
+    psc = pysoup_callback_new (pyfunc, pyarg);
+    soup_logger_set_response_filter (SOUP_LOGGER (self->obj),
+				    pysoup_logger_filter, psc,
+				    pysoup_callback_destroy_notify);
+
+    Py_INCREF (Py_None);
+    return Py_None;
+}
+%%
+override soup_logger_set_printer kwargs
+
+static void
+pysoup_printer (SoupLogger *logger, SoupLoggerLogLevel level,
+		char direction, const char *data, gpointer user_data)
+{
+    PySoupCallback *psc = user_data;
+    PyGILState_STATE state;
+    PyObject *py_level, *py_ret;
+ 
+    state = pyg_gil_state_ensure ();
+ 
+    py_level = pyg_enum_from_gtype (SOUP_TYPE_LOGGER_LOG_LEVEL, level);
+
+    if (psc->data) {
+        py_ret = PyEval_CallFunction (psc->func, "(NcsO)", py_level,
+				      direction, data, psc->data);
+    } else {
+        py_ret = PyEval_CallFunction (psc->func, "(Ncs)", py_level,
+				      direction, data);
+    }
+
+    if (py_ret != NULL)
+	Py_DECREF (py_ret);
+    else
+	PyErr_Print ();
+
+    pyg_gil_state_release (state);
+}
+
+static PyObject *
+_wrap_soup_logger_set_printer (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "printer", "filter_data", NULL };
+    PyObject *pyfunc, *pyarg = NULL;
+    PySoupCallback *psc;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "O|O:SoupLogger.set_printer",
+				      kwlist, &pyfunc, &pyarg))
+        return NULL;
+    if (!PyCallable_Check (pyfunc)) {
+        PyErr_SetString (PyExc_TypeError, "printer must be a callable object");
+        return NULL;
+    }
+
+    psc = pysoup_callback_new (pyfunc, pyarg);
+    soup_logger_set_printer (SOUP_LOGGER (self->obj),
+			     pysoup_printer, psc,
+			     pysoup_callback_destroy_notify);
+
+    Py_INCREF (Py_None);
+    return Py_None;
+}

Added: trunk/python/SoupMessageBody.override
==============================================================================
--- (empty file)
+++ trunk/python/SoupMessageBody.override	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,60 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * SoupMessageBody.override: overrides for SoupMessageBody
+ */
+%%
+override soup_message_body_append kwargs
+static PyObject *
+_wrap_soup_message_body_append (PyObject *self,
+				PyObject *args,
+				PyObject *kwargs)
+{
+    static char *kwlist[] = { "data", "length", NULL };
+    char *data;
+    int length, caller_length = 0;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "s#|i:SoupMessageBody.append",
+				      kwlist, &data, &length, &caller_length))
+	return NULL;
+
+    if (caller_length)
+	length = caller_length;
+
+    /* FIXME: Add a way to create a SoupBuffer that refs data's PyObject */
+    soup_message_body_append (pyg_boxed_get(self, SoupMessageBody),
+			      SOUP_MEMORY_COPY, data, length);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+%%
+override soup_message_body_get_chunk kwargs
+static PyObject *
+_wrap_soup_message_body_get_chunk (PyObject *self,
+				   PyObject *args,
+				   PyObject *kwargs)
+{
+    static char *kwlist[] = { "offset", NULL };
+    long long offset;
+    SoupBuffer *chunk;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "L:SoupMessageBody.get_chunk",
+				      kwlist, &offset))
+	return NULL;
+
+    chunk = soup_message_body_get_chunk (pyg_boxed_get(self, SoupMessageBody),
+					 offset);
+    return pyg_boxed_new(SOUP_TYPE_BUFFER, chunk, TRUE, TRUE);
+}
+%%
+override-attr SoupMessageBody.length
+static PyObject *
+_wrap_soup_message_body__get_length(PyObject *self, void *closure)
+{
+    goffset length;
+
+    length = pyg_boxed_get(self, SoupMessageBody)->length;
+    return PyLong_FromLongLong(length);
+}

Added: trunk/python/SoupMessageHeaders.override
==============================================================================
--- (empty file)
+++ trunk/python/SoupMessageHeaders.override	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,156 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * SoupMessageHeaders.override: overrides for SoupMessageHeaders
+ */
+%%
+ignore
+  soup_message_headers_foreach
+%%
+override-slot SoupMessageHeaders.tp_as_mapping
+static PyObject *
+_wrap_soup_message_headers_tp_getitem (PyGObject *self, PyObject *item)
+{
+    char *name;
+    const char *value;
+
+    if (!PyString_Check (item)) {
+        PyErr_SetString (PyExc_TypeError,
+			 "could not parse subscript as a header name");
+        return NULL;
+    }
+
+    name = PyString_AsString (item);
+    value = soup_message_headers_get ((SoupMessageHeaders *)self->obj, name);
+    return Py_BuildValue ("s", value);
+
+}
+static int
+_wrap_soup_message_headers_tp_setitem (PyGObject *self, PyObject *item,
+				       PyObject *value)
+{
+    char *name, *string_value;
+
+    if (!PyString_Check (item)) {
+        PyErr_SetString (PyExc_TypeError,
+			 "could not parse subscript as a header name");
+        return -1;
+    }
+    name = PyString_AsString (item);
+
+    if (!PyString_Check (value)) {
+        PyErr_SetString (PyExc_TypeError,
+			 "could not parse value as a string");
+        return -1;
+    }
+    string_value = PyString_AsString (value);
+
+    soup_message_headers_replace ((SoupMessageHeaders *)self->obj, name,
+				  string_value);
+    return 0;
+}
+
+static PyMappingMethods _wrap_soup_message_headers_tp_as_mapping = {
+    (lenfunc) NULL,
+    (binaryfunc)_wrap_soup_message_headers_tp_getitem,
+    (objobjargproc)_wrap_soup_message_headers_tp_setitem
+};
+%%
+override-slot SoupMessageHeaders.tp_iter
+
+typedef struct {
+    PyObject_HEAD
+
+    SoupMessageHeadersIter iter;
+} PySoupMessageHeadersIter;
+
+static void
+pysoup_message_headers_iter_dealloc (PySoupMessageHeadersIter *iter)
+{
+    soup_message_headers_iter_free (&iter->iter);
+    PyObject_Del ((PyObject*) iter);
+}
+
+static PyObject *
+pysoup_message_headers_iter_next (PySoupMessageHeadersIter *iter)
+{
+    const char *name, *value;
+
+    if (!soup_message_headers_iter_next (&iter->iter, &name, &value)) {
+        PyErr_SetNone (PyExc_StopIteration);
+        return NULL;
+    }
+
+    return Py_BuildValue ("(ss)", name, value);
+}
+
+static PyTypeObject PySoupMessageHeadersIter_Type = {
+	PyObject_HEAD_INIT(NULL)
+	0,					/* ob_size */
+	"soup.SoupMessageHeadersIter",		/* tp_name */
+	sizeof (PySoupMessageHeadersIter),	/* tp_basicsize */
+	0,					/* tp_itemsize */
+	(destructor)pysoup_message_headers_iter_dealloc, /* tp_dealloc */
+	0,					/* tp_print */
+	0,					/* tp_getattr */
+	0,					/* tp_setattr */
+	0,					/* tp_compare */
+	0,					/* tp_repr */
+	0,					/* tp_as_number */
+	0,					/* tp_as_sequence */
+	0,		       			/* tp_as_mapping */
+	0,					/* tp_hash */
+	0,					/* tp_call */
+	0,					/* tp_str */
+	0,					/* tp_getattro */
+	0,					/* tp_setattro */
+	0,					/* tp_as_buffer */
+	Py_TPFLAGS_DEFAULT,			/* tp_flags */
+ 	"SoupMessageHeaders iterator",		/* tp_doc */
+	0,					/* tp_traverse */
+ 	0,					/* tp_clear */
+	0,					/* tp_richcompare */
+	0,					/* tp_weaklistoffset */
+	0,					/* tp_iter */
+	(iternextfunc)pysoup_message_headers_iter_next, /* tp_iternext */
+};
+
+static PyObject *
+_wrap_soup_message_headers_tp_iter (PyGObject *self)
+{
+    PySoupMessageHeadersIter *iter;
+
+    iter = PyObject_NEW (PySoupMessageHeadersIter,
+			 &PySoupMessageHeadersIter_Type);
+    soup_message_headers_iter_init (&iter->iter,
+				    (SoupMessageHeaders *)self->obj);
+    return (PyObject *) iter;
+}
+%%
+override soup_message_headers_get_content_length
+static PyObject *
+_wrap_soup_message_headers_get_content_length (PyObject *self)
+{
+    goffset content_length;
+
+    content_length = soup_message_headers_get_content_length (pyg_boxed_get (self, SoupMessageHeaders));
+
+    return PyLong_FromLongLong (content_length);
+}
+%%
+override soup_message_headers_set_content_length
+static PyObject *
+_wrap_soup_message_headers_set_content_length (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "content_length", NULL };
+    long long content_length;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+				     "L:SoupMessageHeaders.set_content_length",
+				     kwlist, &content_length))
+        return NULL;
+    
+    soup_message_headers_set_content_length (pyg_boxed_get (self, SoupMessageHeaders), content_length);
+    
+    Py_INCREF(Py_None);
+    return Py_None;
+}

Added: trunk/python/SoupURI.override
==============================================================================
--- (empty file)
+++ trunk/python/SoupURI.override	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,153 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * SoupURI.override: overrides for SoupURI
+ */
+%%
+ignore-glob
+  soup_uri_set_*
+%%
+override-slot SoupURI.tp_str
+static PyObject *
+_wrap_soup_uri_tp_str (PyObject *self)
+{
+    char *str;
+    PyObject *ret;
+
+    str = soup_uri_to_string (pyg_boxed_get (self, SoupURI), FALSE);
+    ret = PyString_FromString (str);
+    g_free (str);
+
+    return ret;
+}
+%%
+override-slot SoupURI.tp_repr
+static PyObject *
+_wrap_soup_uri_tp_repr (PyObject *self)
+{
+    SoupURI *uri = pyg_boxed_get (self, SoupURI);
+    char *str, *repr;
+    PyObject *ret;
+
+    str = soup_uri_to_string (uri, FALSE);
+    repr = g_strdup_printf ("<SoupURI '%s' at %p>", str, uri);
+    ret = PyString_FromString (repr);
+    g_free (repr);
+    g_free (str);
+
+    return ret;
+}
+%%
+override-attr SoupURI.scheme
+static int
+_wrap_soup_uri__set_scheme (PyObject *self, PyObject *value, void *closure)
+{
+    char *scheme = PyString_AsString (value);
+
+    if (!scheme)
+	return -1;
+    soup_uri_set_scheme (pyg_boxed_get (self, SoupURI), scheme);
+
+    return 0;
+}
+%%
+override-attr SoupURI.user
+static int
+_wrap_soup_uri__set_user (PyObject *self, PyObject *value, void *closure)
+{
+    char *user = PyString_AsString (value);
+
+    if (!user)
+	return -1;
+    soup_uri_set_user (pyg_boxed_get (self, SoupURI), user);
+
+    return 0;
+}
+%%
+override-attr SoupURI.password
+static int
+_wrap_soup_uri__set_password (PyObject *self, PyObject *value, void *closure)
+{
+    char *password = PyString_AsString (value);
+
+    if (!password)
+	return -1;
+    soup_uri_set_password (pyg_boxed_get (self, SoupURI), password);
+
+    return 0;
+}
+%%
+override-attr SoupURI.host
+static int
+_wrap_soup_uri__set_host (PyObject *self, PyObject *value, void *closure)
+{
+    char *host = PyString_AsString (value);
+
+    if (!host)
+	return -1;
+    soup_uri_set_host (pyg_boxed_get (self, SoupURI), host);
+
+    return 0;
+}
+%%
+override-attr SoupURI.port
+static int
+_wrap_soup_uri__set_port (PyObject *self, PyObject *value, void *closure)
+{
+    int port = PyInt_AsLong (value);
+
+    if (PyErr_Occurred())
+	return -1;
+    soup_uri_set_port (pyg_boxed_get (self, SoupURI), port);
+
+    return 0;
+}
+%%
+override-attr SoupURI.path
+static int
+_wrap_soup_uri__set_path (PyObject *self, PyObject *value, void *closure)
+{
+    char *path = PyString_AsString (value);
+
+    if (!path)
+	return -1;
+    soup_uri_set_path (pyg_boxed_get (self, SoupURI), path);
+
+    return 0;
+}
+%%
+override-attr SoupURI.query
+static int
+_wrap_soup_uri__set_query (PyObject *self, PyObject *value, void *closure)
+{
+    if (PyString_Check (value)) {
+	char *string_query = PyString_AsString (value);
+
+	soup_uri_set_query (pyg_boxed_get (self, SoupURI), string_query);
+    } else if (PyDict_Check (value)) {
+	GHashTable *dict_query = pysoup_pydict_to_ghashtable (value);
+
+	if (!dict_query)
+	    return -1;
+
+	soup_uri_set_query_from_form (pyg_boxed_get (self, SoupURI), dict_query);
+	g_hash_table_destroy (dict_query);
+    } else {
+	PyErr_SetString (PyExc_TypeError, "query value must be a string or a dict");
+	return -1;
+    }
+
+    return 0;
+}
+%%
+override-attr SoupURI.fragment
+static int
+_wrap_soup_uri__set_fragment (PyObject *self, PyObject *value, void *closure)
+{
+    char *fragment = PyString_AsString (value);
+
+    if (!fragment)
+	return -1;
+    soup_uri_set_fragment (pyg_boxed_get (self, SoupURI), fragment);
+
+    return 0;
+}

Added: trunk/python/acinclude.m4
==============================================================================
--- (empty file)
+++ trunk/python/acinclude.m4	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,66 @@
+## this one is commonly used with AM_PATH_PYTHONDIR ...
+dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
+dnl Check if a module containing a given symbol is visible to python.
+AC_DEFUN([AM_CHECK_PYMOD],
+[AC_REQUIRE([AM_PATH_PYTHON])
+py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
+AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1)
+AC_CACHE_VAL(py_cv_mod_$py_mod_var, [
+ifelse([$2],[], [prog="
+import sys
+try:
+        import $1
+except ImportError:
+        sys.exit(1)
+except:
+        sys.exit(0)
+sys.exit(0)"], [prog="
+import $1
+$1.$2"])
+if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
+  then
+    eval "py_cv_mod_$py_mod_var=yes"
+  else
+    eval "py_cv_mod_$py_mod_var=no"
+  fi
+])
+py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"`
+if test "x$py_val" != xno; then
+  AC_MSG_RESULT(yes)
+  ifelse([$3], [],, [$3
+])dnl
+else
+  AC_MSG_RESULT(no)
+  ifelse([$4], [],, [$4
+])dnl
+fi
+])
+
+dnl a macro to check for ability to create python extensions
+dnl  AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
+dnl function also defines PYTHON_INCLUDES
+AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
+[AC_REQUIRE([AM_PATH_PYTHON])
+AC_MSG_CHECKING(for headers required to compile python extensions)
+dnl deduce PYTHON_INCLUDES
+py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
+py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
+if test -x "$PYTHON-config"; then
+PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
+else
+PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
+if test "$py_prefix" != "$py_exec_prefix"; then
+  PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+fi
+fi
+AC_SUBST(PYTHON_INCLUDES)
+dnl check if the headers exist:
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
+AC_TRY_CPP([#include <Python.h>],dnl
+[AC_MSG_RESULT(found)
+$1],dnl
+[AC_MSG_RESULT(not found)
+$2])
+CPPFLAGS="$save_CPPFLAGS"
+])

Added: trunk/python/configure.in
==============================================================================
--- (empty file)
+++ trunk/python/configure.in	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,51 @@
+AC_PREREQ(2.53)
+AC_INIT(libsoup-python, 0.0)
+AC_CONFIG_SRCDIR(libsoup.defs)
+AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
+
+AM_MAINTAINER_MODE
+AC_PROG_MAKE_SET
+
+AC_PROG_CC
+AM_PROG_CC_STDC
+AC_HEADER_STDC
+
+AM_PROG_LIBTOOL
+
+AC_ARG_ENABLE(more-warnings,
+	      [  --disable-more-warnings  Inhibit compiler warnings],
+	      set_more_warnings=no)
+
+if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
+	CFLAGS="$CFLAGS \
+		-Wall -Wstrict-prototypes -Wmissing-declarations \
+		-Wmissing-prototypes -Wnested-externs -Wpointer-arith"
+fi
+
+dnl ******
+dnl Python
+dnl ******
+
+AM_PATH_PYTHON()
+AM_CHECK_PYTHON_HEADERS(,AC_MSG_ERROR([install python-devel]))
+PKG_CHECK_MODULES(PYGOBJECT, pygobject-2.0 >= 2.15.0)
+gio_defsdir=`$PKG_CONFIG --variable=defsdir pygobject-2.0`
+if test "$gio_defsdir" = ""; then
+    # kludge until we can depend on pygobject 2.15.1
+    gio_defsdir=`$PKG_CONFIG --variable=fixxref pygobject-2.0 | sed -e 's|xsl/fixxref.py|2.0/defs|'`
+fi
+GIO_DEFS="$gio_defsdir/gio.defs"
+AC_SUBST(GIO_DEFS)
+
+dnl *******
+dnl libsoup
+dnl *******
+
+if test -f ../libsoup/libsoup-2.4.la; then
+	SOUP_CFLAGS=-I..
+	SOUP_LIBS=../libsoup/libsoup-2.4.la
+else
+	PKG_CHECK_MODULES(SOUP, libsoup-2.4)
+fi
+
+AC_OUTPUT([Makefile])

Added: trunk/python/libsoup-ignore.defs
==============================================================================
--- (empty file)
+++ trunk/python/libsoup-ignore.defs	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,5 @@
+(define-boxed Array
+  (in-module "GByte")
+  (c-name "GByteArray")
+  (gtype-id "G_TYPE_BYTE_ARRAY")
+)

Added: trunk/python/libsoup.defs
==============================================================================
--- (empty file)
+++ trunk/python/libsoup.defs	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,2532 @@
+;; -*- scheme -*-
+; boxed definitions ...
+
+(define-boxed Buffer
+  (in-module "Soup")
+  (c-name "SoupBuffer")
+  (gtype-id "SOUP_TYPE_BUFFER")
+  (fields
+    '("const-char*" "data")
+    '("gsize" "length")
+  )
+)
+
+(define-boxed ClientContext
+  (in-module "Soup")
+  (c-name "SoupClientContext")
+  (gtype-id "SOUP_TYPE_CLIENT_CONTEXT")
+)
+
+(define-boxed Date
+  (in-module "Soup")
+  (c-name "SoupDate")
+  (gtype-id "SOUP_TYPE_DATE")
+  (fields
+    '("int" "year")
+    '("int" "month")
+    '("int" "day")
+    '("int" "hour")
+    '("int" "minute")
+    '("int" "second")
+    '("gboolean" "utc")
+    '("int" "offset")
+  )
+)
+
+(define-boxed MessageBody
+  (in-module "Soup")
+  (c-name "SoupMessageBody")
+  (gtype-id "SOUP_TYPE_MESSAGE_BODY")
+  (fields
+    '("const-char*" "data")
+    '("goffset" "length")
+  )
+)
+
+(define-boxed MessageHeaders
+  (in-module "Soup")
+  (c-name "SoupMessageHeaders")
+  (gtype-id "SOUP_TYPE_MESSAGE_HEADERS")
+)
+
+(define-boxed URI
+  (in-module "Soup")
+  (c-name "SoupURI")
+  (gtype-id "SOUP_TYPE_URI")
+  (fields
+    '("const-char*" "scheme")
+    '("char*" "user")
+    '("char*" "password")
+    '("char*" "host")
+    '("int" "port")
+    '("char*" "path")
+    '("char*" "query")
+    '("char*" "fragment")
+  )
+)
+
+; interface definitions ...
+
+; object definitions ...
+
+(define-object Address
+  (in-module "Soup")
+  (parent "GObject")
+  (c-name "SoupAddress")
+  (gtype-id "SOUP_TYPE_ADDRESS")
+)
+
+(define-object Auth
+  (in-module "Soup")
+  (parent "GObject")
+  (c-name "SoupAuth")
+  (gtype-id "SOUP_TYPE_AUTH")
+)
+
+(define-object AuthDomain
+  (in-module "Soup")
+  (parent "GObject")
+  (c-name "SoupAuthDomain")
+  (gtype-id "SOUP_TYPE_AUTH_DOMAIN")
+)
+
+(define-object AuthDomainBasic
+  (in-module "Soup")
+  (parent "SoupAuthDomain")
+  (c-name "SoupAuthDomainBasic")
+  (gtype-id "SOUP_TYPE_AUTH_DOMAIN_BASIC")
+)
+
+(define-object AuthDomainDigest
+  (in-module "Soup")
+  (parent "SoupAuthDomain")
+  (c-name "SoupAuthDomainDigest")
+  (gtype-id "SOUP_TYPE_AUTH_DOMAIN_DIGEST")
+)
+
+(define-object Logger
+  (in-module "Soup")
+  (parent "GObject")
+  (c-name "SoupLogger")
+  (gtype-id "SOUP_TYPE_LOGGER")
+)
+
+(define-object Message
+  (in-module "Soup")
+  (parent "GObject")
+  (c-name "SoupMessage")
+  (gtype-id "SOUP_TYPE_MESSAGE")
+  (fields
+    '("const-char*" "method")
+    '("int" "status_code")
+    '("const-char*" "reason_phrase")
+    '("SoupMessageBody*" "request_body")
+    '("SoupMessageHeaders*" "request_headers")
+    '("SoupMessageBody*" "response_body")
+    '("SoupMessageHeaders*" "response_headers")
+  )
+)
+
+(define-object Server
+  (in-module "Soup")
+  (parent "GObject")
+  (c-name "SoupServer")
+  (gtype-id "SOUP_TYPE_SERVER")
+)
+
+(define-object Session
+  (in-module "Soup")
+  (parent "GObject")
+  (c-name "SoupSession")
+  (gtype-id "SOUP_TYPE_SESSION")
+)
+
+(define-object SessionAsync
+  (in-module "Soup")
+  (parent "SoupSession")
+  (c-name "SoupSessionAsync")
+  (gtype-id "SOUP_TYPE_SESSION_ASYNC")
+)
+
+(define-object SessionSync
+  (in-module "Soup")
+  (parent "SoupSession")
+  (c-name "SoupSessionSync")
+  (gtype-id "SOUP_TYPE_SESSION_SYNC")
+)
+
+(define-object Socket
+  (in-module "Soup")
+  (parent "GObject")
+  (c-name "SoupSocket")
+  (gtype-id "SOUP_TYPE_SOCKET")
+)
+
+; pointer definitions ...
+
+;; Enumerations and Flags ...
+
+(define-enum AddressFamily
+  (in-module "Soup")
+  (c-name "SoupAddressFamily")
+  (gtype-id "SOUP_TYPE_ADDRESS_FAMILY")
+  (values
+    '("invalid" "SOUP_ADDRESS_FAMILY_INVALID")
+    '("ipv4" "SOUP_ADDRESS_FAMILY_IPV4")
+    '("ipv6" "SOUP_ADDRESS_FAMILY_IPV6")
+  )
+)
+
+(define-enum DateFormat
+  (in-module "Soup")
+  (c-name "SoupDateFormat")
+  (gtype-id "SOUP_TYPE_DATE_FORMAT")
+  (values
+    '("http" "SOUP_DATE_HTTP")
+    '("cookie" "SOUP_DATE_COOKIE")
+    '("rfc2822" "SOUP_DATE_RFC2822")
+    '("iso8601-compact" "SOUP_DATE_ISO8601_COMPACT")
+    '("iso8601-full" "SOUP_DATE_ISO8601_FULL")
+    '("iso8601" "SOUP_DATE_ISO8601")
+    '("iso8601-xmlrpc" "SOUP_DATE_ISO8601_XMLRPC")
+  )
+)
+
+(define-enum Encoding
+  (in-module "Soup")
+  (c-name "SoupEncoding")
+  (gtype-id "SOUP_TYPE_ENCODING")
+  (values
+    '("unrecognized" "SOUP_ENCODING_UNRECOGNIZED")
+    '("none" "SOUP_ENCODING_NONE")
+    '("content-length" "SOUP_ENCODING_CONTENT_LENGTH")
+    '("eof" "SOUP_ENCODING_EOF")
+    '("chunked" "SOUP_ENCODING_CHUNKED")
+    '("byteranges" "SOUP_ENCODING_BYTERANGES")
+  )
+)
+
+(define-enum HTTPVersion
+  (in-module "Soup")
+  (c-name "SoupHTTPVersion")
+  (gtype-id "SOUP_TYPE_HTTP_VERSION")
+  (values
+    '("0" "SOUP_HTTP_1_0")
+    '("1" "SOUP_HTTP_1_1")
+  )
+)
+
+(define-enum KnownStatusCode
+  (in-module "Soup")
+  (c-name "SoupKnownStatusCode")
+  (gtype-id "SOUP_TYPE_KNOWN_STATUS_CODE")
+  (values
+    '("none" "SOUP_STATUS_NONE")
+    '("cancelled" "SOUP_STATUS_CANCELLED")
+    '("cant-resolve" "SOUP_STATUS_CANT_RESOLVE")
+    '("cant-resolve-proxy" "SOUP_STATUS_CANT_RESOLVE_PROXY")
+    '("cant-connect" "SOUP_STATUS_CANT_CONNECT")
+    '("cant-connect-proxy" "SOUP_STATUS_CANT_CONNECT_PROXY")
+    '("ssl-failed" "SOUP_STATUS_SSL_FAILED")
+    '("io-error" "SOUP_STATUS_IO_ERROR")
+    '("malformed" "SOUP_STATUS_MALFORMED")
+    '("try-again" "SOUP_STATUS_TRY_AGAIN")
+    '("continue" "SOUP_STATUS_CONTINUE")
+    '("switching-protocols" "SOUP_STATUS_SWITCHING_PROTOCOLS")
+    '("processing" "SOUP_STATUS_PROCESSING")
+    '("ok" "SOUP_STATUS_OK")
+    '("created" "SOUP_STATUS_CREATED")
+    '("accepted" "SOUP_STATUS_ACCEPTED")
+    '("non-authoritative" "SOUP_STATUS_NON_AUTHORITATIVE")
+    '("no-content" "SOUP_STATUS_NO_CONTENT")
+    '("reset-content" "SOUP_STATUS_RESET_CONTENT")
+    '("partial-content" "SOUP_STATUS_PARTIAL_CONTENT")
+    '("multi-status" "SOUP_STATUS_MULTI_STATUS")
+    '("multiple-choices" "SOUP_STATUS_MULTIPLE_CHOICES")
+    '("moved-permanently" "SOUP_STATUS_MOVED_PERMANENTLY")
+    '("found" "SOUP_STATUS_FOUND")
+    '("moved-temporarily" "SOUP_STATUS_MOVED_TEMPORARILY")
+    '("see-other" "SOUP_STATUS_SEE_OTHER")
+    '("not-modified" "SOUP_STATUS_NOT_MODIFIED")
+    '("use-proxy" "SOUP_STATUS_USE_PROXY")
+    '("not-appearing-in-this-protocol" "SOUP_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL")
+    '("temporary-redirect" "SOUP_STATUS_TEMPORARY_REDIRECT")
+    '("bad-request" "SOUP_STATUS_BAD_REQUEST")
+    '("unauthorized" "SOUP_STATUS_UNAUTHORIZED")
+    '("payment-required" "SOUP_STATUS_PAYMENT_REQUIRED")
+    '("forbidden" "SOUP_STATUS_FORBIDDEN")
+    '("not-found" "SOUP_STATUS_NOT_FOUND")
+    '("method-not-allowed" "SOUP_STATUS_METHOD_NOT_ALLOWED")
+    '("not-acceptable" "SOUP_STATUS_NOT_ACCEPTABLE")
+    '("proxy-authentication-required" "SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED")
+    '("proxy-unauthorized" "SOUP_STATUS_PROXY_UNAUTHORIZED")
+    '("request-timeout" "SOUP_STATUS_REQUEST_TIMEOUT")
+    '("conflict" "SOUP_STATUS_CONFLICT")
+    '("gone" "SOUP_STATUS_GONE")
+    '("length-required" "SOUP_STATUS_LENGTH_REQUIRED")
+    '("precondition-failed" "SOUP_STATUS_PRECONDITION_FAILED")
+    '("request-entity-too-large" "SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE")
+    '("request-uri-too-long" "SOUP_STATUS_REQUEST_URI_TOO_LONG")
+    '("unsupported-media-type" "SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE")
+    '("requested-range-not-satisfiable" "SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE")
+    '("invalid-range" "SOUP_STATUS_INVALID_RANGE")
+    '("expectation-failed" "SOUP_STATUS_EXPECTATION_FAILED")
+    '("unprocessable-entity" "SOUP_STATUS_UNPROCESSABLE_ENTITY")
+    '("locked" "SOUP_STATUS_LOCKED")
+    '("failed-dependency" "SOUP_STATUS_FAILED_DEPENDENCY")
+    '("internal-server-error" "SOUP_STATUS_INTERNAL_SERVER_ERROR")
+    '("not-implemented" "SOUP_STATUS_NOT_IMPLEMENTED")
+    '("bad-gateway" "SOUP_STATUS_BAD_GATEWAY")
+    '("service-unavailable" "SOUP_STATUS_SERVICE_UNAVAILABLE")
+    '("gateway-timeout" "SOUP_STATUS_GATEWAY_TIMEOUT")
+    '("http-version-not-supported" "SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED")
+    '("insufficient-storage" "SOUP_STATUS_INSUFFICIENT_STORAGE")
+    '("not-extended" "SOUP_STATUS_NOT_EXTENDED")
+  )
+)
+
+(define-enum LoggerLogLevel
+  (in-module "Soup")
+  (c-name "SoupLoggerLogLevel")
+  (gtype-id "SOUP_TYPE_LOGGER_LOG_LEVEL")
+  (values
+    '("none" "SOUP_LOGGER_LOG_NONE")
+    '("minimal" "SOUP_LOGGER_LOG_MINIMAL")
+    '("headers" "SOUP_LOGGER_LOG_HEADERS")
+    '("body" "SOUP_LOGGER_LOG_BODY")
+  )
+)
+
+(define-enum MemoryUse
+  (in-module "Soup")
+  (c-name "SoupMemoryUse")
+  (gtype-id "SOUP_TYPE_MEMORY_USE")
+  (values
+    '("static" "SOUP_MEMORY_STATIC")
+    '("take" "SOUP_MEMORY_TAKE")
+    '("copy" "SOUP_MEMORY_COPY")
+    '("temporary" "SOUP_MEMORY_TEMPORARY")
+  )
+)
+
+(define-enum MessageHeadersType
+  (in-module "Soup")
+  (c-name "SoupMessageHeadersType")
+  (gtype-id "SOUP_TYPE_MESSAGE_HEADERS_TYPE")
+  (values
+    '("request" "SOUP_MESSAGE_HEADERS_REQUEST")
+    '("response" "SOUP_MESSAGE_HEADERS_RESPONSE")
+  )
+)
+
+(define-enum SSLError
+  (in-module "Soup")
+  (c-name "SoupSSLError")
+  (gtype-id "SOUP_TYPE_SSL_ERROR")
+  (values
+    '("handshake-needs-read" "SOUP_SSL_ERROR_HANDSHAKE_NEEDS_READ")
+    '("handshake-needs-write" "SOUP_SSL_ERROR_HANDSHAKE_NEEDS_WRITE")
+    '("certificate" "SOUP_SSL_ERROR_CERTIFICATE")
+  )
+)
+
+(define-enum SocketIOStatus
+  (in-module "Soup")
+  (c-name "SoupSocketIOStatus")
+  (gtype-id "SOUP_TYPE_SOCKET_IO_STATUS")
+  (values
+    '("ok" "SOUP_SOCKET_OK")
+    '("would-block" "SOUP_SOCKET_WOULD_BLOCK")
+    '("eof" "SOUP_SOCKET_EOF")
+    '("error" "SOUP_SOCKET_ERROR")
+  )
+)
+
+(define-enum XMLRPCError
+  (in-module "Soup")
+  (c-name "SoupXMLRPCError")
+  (gtype-id "SOUP_TYPE_XMLRPC_ERROR")
+  (values
+    '("arguments" "SOUP_XMLRPC_ERROR_ARGUMENTS")
+    '("retval" "SOUP_XMLRPC_ERROR_RETVAL")
+  )
+)
+
+(define-enum XMLRPCFault
+  (in-module "Soup")
+  (c-name "SoupXMLRPCFault")
+  (gtype-id "SOUP_TYPE_XMLRPC_FAULT")
+  (values
+    '("parse-error-not-well-formed" "SOUP_XMLRPC_FAULT_PARSE_ERROR_NOT_WELL_FORMED")
+    '("parse-error-unsupported-encoding" "SOUP_XMLRPC_FAULT_PARSE_ERROR_UNSUPPORTED_ENCODING")
+    '("parse-error-invalid-character-for-encoding" "SOUP_XMLRPC_FAULT_PARSE_ERROR_INVALID_CHARACTER_FOR_ENCODING")
+    '("server-error-invalid-xml-rpc" "SOUP_XMLRPC_FAULT_SERVER_ERROR_INVALID_XML_RPC")
+    '("server-error-requested-method-not-found" "SOUP_XMLRPC_FAULT_SERVER_ERROR_REQUESTED_METHOD_NOT_FOUND")
+    '("server-error-invalid-method-parameters" "SOUP_XMLRPC_FAULT_SERVER_ERROR_INVALID_METHOD_PARAMETERS")
+    '("server-error-internal-xml-rpc-error" "SOUP_XMLRPC_FAULT_SERVER_ERROR_INTERNAL_XML_RPC_ERROR")
+    '("application-error" "SOUP_XMLRPC_FAULT_APPLICATION_ERROR")
+    '("system-error" "SOUP_XMLRPC_FAULT_SYSTEM_ERROR")
+    '("transport-error" "SOUP_XMLRPC_FAULT_TRANSPORT_ERROR")
+  )
+)
+
+(define-flags Expectation
+  (in-module "Soup")
+  (c-name "SoupExpectation")
+  (gtype-id "SOUP_TYPE_EXPECTATION")
+  (values
+    '("unrecognized" "SOUP_EXPECTATION_UNRECOGNIZED")
+    '("continue" "SOUP_EXPECTATION_CONTINUE")
+  )
+)
+
+(define-flags MessageFlags
+  (in-module "Soup")
+  (c-name "SoupMessageFlags")
+  (gtype-id "SOUP_TYPE_MESSAGE_FLAGS")
+  (values
+    '("no-redirect" "SOUP_MESSAGE_NO_REDIRECT")
+    '("overwrite-chunks" "SOUP_MESSAGE_OVERWRITE_CHUNKS")
+  )
+)
+
+
+;; From soup-address.h
+
+(define-function address_get_type
+  (c-name "soup_address_get_type")
+  (return-type "GType")
+)
+
+(define-function address_new
+  (c-name "soup_address_new")
+  (is-constructor-of "SoupAddress")
+  (return-type "SoupAddress*")
+  (parameters
+    '("const-char*" "name")
+    '("guint" "port")
+  )
+)
+
+(define-function address_new_from_sockaddr
+  (c-name "soup_address_new_from_sockaddr")
+  (return-type "SoupAddress*")
+  (parameters
+    '("struct-sockaddr*" "sa")
+    '("int" "len")
+  )
+)
+
+(define-function address_new_any
+  (c-name "soup_address_new_any")
+  (return-type "SoupAddress*")
+  (parameters
+    '("SoupAddressFamily" "family")
+    '("guint" "port")
+  )
+)
+
+(define-method resolve_async
+  (of-object "SoupAddress")
+  (c-name "soup_address_resolve_async")
+  (return-type "none")
+  (parameters
+    '("GMainContext*" "async_context")
+    '("GCancellable*" "cancellable")
+    '("SoupAddressCallback" "callback")
+    '("gpointer" "user_data")
+  )
+)
+
+(define-method resolve_sync
+  (of-object "SoupAddress")
+  (c-name "soup_address_resolve_sync")
+  (return-type "int")
+  (parameters
+    '("GCancellable*" "cancellable")
+  )
+)
+
+(define-method get_name
+  (of-object "SoupAddress")
+  (c-name "soup_address_get_name")
+  (return-type "const-char*")
+)
+
+(define-method get_physical
+  (of-object "SoupAddress")
+  (c-name "soup_address_get_physical")
+  (return-type "const-char*")
+)
+
+(define-method get_port
+  (of-object "SoupAddress")
+  (c-name "soup_address_get_port")
+  (return-type "int")
+)
+
+
+
+;; From soup-auth-domain-basic.h
+
+(define-function auth_domain_basic_get_type
+  (c-name "soup_auth_domain_basic_get_type")
+  (return-type "GType")
+)
+
+(define-function auth_domain_basic_new
+  (c-name "soup_auth_domain_basic_new")
+  (is-constructor-of "SoupAuthDomainBasic")
+  (return-type "SoupAuthDomain*")
+  (parameters
+    '("const-char*" "optname1")
+  )
+  (varargs #t)
+)
+
+(define-method basic_set_auth_callback
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_basic_set_auth_callback")
+  (return-type "none")
+  (parameters
+    '("SoupAuthDomainBasicAuthCallback" "callback")
+    '("gpointer" "user_data")
+    '("GDestroyNotify" "dnotify")
+  )
+)
+
+
+
+;; From soup-auth-domain-digest.h
+
+(define-function auth_domain_digest_get_type
+  (c-name "soup_auth_domain_digest_get_type")
+  (return-type "GType")
+)
+
+(define-function auth_domain_digest_new
+  (c-name "soup_auth_domain_digest_new")
+  (is-constructor-of "SoupAuthDomainDigest")
+  (return-type "SoupAuthDomain*")
+  (parameters
+    '("const-char*" "optname1")
+  )
+  (varargs #t)
+)
+
+(define-method digest_set_auth_callback
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_digest_set_auth_callback")
+  (return-type "none")
+  (parameters
+    '("SoupAuthDomainDigestAuthCallback" "callback")
+    '("gpointer" "user_data")
+    '("GDestroyNotify" "dnotify")
+  )
+)
+
+(define-function auth_domain_digest_encode_password
+  (c-name "soup_auth_domain_digest_encode_password")
+  (return-type "char*")
+  (parameters
+    '("const-char*" "username")
+    '("const-char*" "realm")
+    '("const-char*" "password")
+  )
+)
+
+
+
+;; From soup-auth-domain.h
+
+(define-function auth_domain_get_type
+  (c-name "soup_auth_domain_get_type")
+  (return-type "GType")
+)
+
+(define-method add_path
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_add_path")
+  (return-type "none")
+  (parameters
+    '("const-char*" "path")
+  )
+)
+
+(define-method remove_path
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_remove_path")
+  (return-type "none")
+  (parameters
+    '("const-char*" "path")
+  )
+)
+
+(define-method set_filter
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_set_filter")
+  (return-type "none")
+  (parameters
+    '("SoupAuthDomainFilter" "filter")
+    '("gpointer" "filter_data")
+    '("GDestroyNotify" "dnotify")
+  )
+)
+
+(define-method get_realm
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_get_realm")
+  (return-type "const-char*")
+)
+
+(define-method set_generic_auth_callback
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_set_generic_auth_callback")
+  (return-type "none")
+  (parameters
+    '("SoupAuthDomainGenericAuthCallback" "auth_callback")
+    '("gpointer" "auth_data")
+    '("GDestroyNotify" "dnotify")
+  )
+)
+
+(define-method check_password
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_check_password")
+  (return-type "gboolean")
+  (parameters
+    '("SoupMessage*" "msg")
+    '("const-char*" "username")
+    '("const-char*" "password")
+  )
+)
+
+(define-method covers
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_covers")
+  (return-type "gboolean")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method accepts
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_accepts")
+  (return-type "char*")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method challenge
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_challenge")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method try_generic_auth_callback
+  (of-object "SoupAuthDomain")
+  (c-name "soup_auth_domain_try_generic_auth_callback")
+  (return-type "gboolean")
+  (parameters
+    '("SoupMessage*" "msg")
+    '("const-char*" "username")
+  )
+)
+
+
+
+;; From soup-auth.h
+
+(define-function auth_get_type
+  (c-name "soup_auth_get_type")
+  (return-type "GType")
+)
+
+(define-function auth_new
+  (c-name "soup_auth_new")
+  (is-constructor-of "SoupAuth")
+  (return-type "SoupAuth*")
+  (parameters
+    '("GType" "type")
+    '("SoupMessage*" "msg")
+    '("const-char*" "auth_header")
+  )
+)
+
+(define-method update
+  (of-object "SoupAuth")
+  (c-name "soup_auth_update")
+  (return-type "gboolean")
+  (parameters
+    '("SoupMessage*" "msg")
+    '("const-char*" "auth_header")
+  )
+)
+
+(define-method is_for_proxy
+  (of-object "SoupAuth")
+  (c-name "soup_auth_is_for_proxy")
+  (return-type "gboolean")
+)
+
+(define-method get_scheme_name
+  (of-object "SoupAuth")
+  (c-name "soup_auth_get_scheme_name")
+  (return-type "const-char*")
+)
+
+(define-method get_host
+  (of-object "SoupAuth")
+  (c-name "soup_auth_get_host")
+  (return-type "const-char*")
+)
+
+(define-method get_realm
+  (of-object "SoupAuth")
+  (c-name "soup_auth_get_realm")
+  (return-type "const-char*")
+)
+
+(define-method get_info
+  (of-object "SoupAuth")
+  (c-name "soup_auth_get_info")
+  (return-type "char*")
+)
+
+(define-method authenticate
+  (of-object "SoupAuth")
+  (c-name "soup_auth_authenticate")
+  (return-type "none")
+  (parameters
+    '("const-char*" "username")
+    '("const-char*" "password")
+  )
+)
+
+(define-method is_authenticated
+  (of-object "SoupAuth")
+  (c-name "soup_auth_is_authenticated")
+  (return-type "gboolean")
+)
+
+(define-method get_authorization
+  (of-object "SoupAuth")
+  (c-name "soup_auth_get_authorization")
+  (return-type "char*")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method get_protection_space
+  (of-object "SoupAuth")
+  (c-name "soup_auth_get_protection_space")
+  (return-type "GSList*")
+  (parameters
+    '("SoupURI*" "source_uri")
+  )
+)
+
+(define-method free_protection_space
+  (of-object "SoupAuth")
+  (c-name "soup_auth_free_protection_space")
+  (return-type "none")
+  (parameters
+    '("GSList*" "space")
+  )
+)
+
+
+
+;; From soup-date.h
+
+(define-function date_get_type
+  (c-name "soup_date_get_type")
+  (return-type "GType")
+)
+
+(define-function date_new
+  (c-name "soup_date_new")
+  (is-constructor-of "SoupDate")
+  (return-type "SoupDate*")
+  (parameters
+    '("int" "year")
+    '("int" "month")
+    '("int" "day")
+    '("int" "hour")
+    '("int" "minute")
+    '("int" "second")
+  )
+)
+
+(define-function date_new_from_string
+  (c-name "soup_date_new_from_string")
+  (return-type "SoupDate*")
+  (parameters
+    '("const-char*" "date_string")
+  )
+)
+
+(define-function date_new_from_time_t
+  (c-name "soup_date_new_from_time_t")
+  (return-type "SoupDate*")
+  (parameters
+    '("time_t" "when")
+  )
+)
+
+(define-function date_new_from_now
+  (c-name "soup_date_new_from_now")
+  (return-type "SoupDate*")
+  (parameters
+    '("int" "offset_seconds")
+  )
+)
+
+(define-method to_string
+  (of-object "SoupDate")
+  (c-name "soup_date_to_string")
+  (return-type "char*")
+  (parameters
+    '("SoupDateFormat" "format")
+  )
+)
+
+(define-method to_time_t
+  (of-object "SoupDate")
+  (c-name "soup_date_to_time_t")
+  (return-type "time_t")
+)
+
+(define-method copy
+  (of-object "SoupDate")
+  (c-name "soup_date_copy")
+  (return-type "SoupDate*")
+)
+
+(define-method free
+  (of-object "SoupDate")
+  (c-name "soup_date_free")
+  (return-type "none")
+)
+
+
+
+;; From soup-enum-types.h
+
+(define-function address_family_get_type
+  (c-name "soup_address_family_get_type")
+  (return-type "GType")
+)
+
+(define-function date_format_get_type
+  (c-name "soup_date_format_get_type")
+  (return-type "GType")
+)
+
+(define-function logger_log_level_get_type
+  (c-name "soup_logger_log_level_get_type")
+  (return-type "GType")
+)
+
+(define-function http_version_get_type
+  (c-name "soup_http_version_get_type")
+  (return-type "GType")
+)
+
+(define-function message_flags_get_type
+  (c-name "soup_message_flags_get_type")
+  (return-type "GType")
+)
+
+(define-function memory_use_get_type
+  (c-name "soup_memory_use_get_type")
+  (return-type "GType")
+)
+
+(define-function message_headers_type_get_type
+  (c-name "soup_message_headers_type_get_type")
+  (return-type "GType")
+)
+
+(define-function encoding_get_type
+  (c-name "soup_encoding_get_type")
+  (return-type "GType")
+)
+
+(define-function expectation_get_type
+  (c-name "soup_expectation_get_type")
+  (return-type "GType")
+)
+
+(define-function ssl_error_get_type
+  (c-name "soup_ssl_error_get_type")
+  (return-type "GType")
+)
+
+(define-function socket_io_status_get_type
+  (c-name "soup_socket_io_status_get_type")
+  (return-type "GType")
+)
+
+(define-function known_status_code_get_type
+  (c-name "soup_known_status_code_get_type")
+  (return-type "GType")
+)
+
+(define-function xmlrpc_error_get_type
+  (c-name "soup_xmlrpc_error_get_type")
+  (return-type "GType")
+)
+
+(define-function xmlrpc_fault_get_type
+  (c-name "soup_xmlrpc_fault_get_type")
+  (return-type "GType")
+)
+
+
+
+;; From soup-form.h
+
+(define-function form_decode
+  (c-name "soup_form_decode")
+  (return-type "GHashTable*")
+  (parameters
+    '("const-char*" "encoded_form")
+  )
+)
+
+(define-function form_encode
+  (c-name "soup_form_encode")
+  (return-type "char*")
+  (parameters
+    '("const-char*" "first_field")
+  )
+  (varargs #t)
+)
+
+(define-function form_encode_hash
+  (c-name "soup_form_encode_hash")
+  (return-type "char*")
+  (parameters
+    '("GHashTable*" "form_data_set")
+  )
+)
+
+(define-function form_encode_datalist
+  (c-name "soup_form_encode_datalist")
+  (return-type "char*")
+  (parameters
+    '("GData**" "form_data_set")
+  )
+)
+
+(define-function form_encode_valist
+  (c-name "soup_form_encode_valist")
+  (return-type "char*")
+  (parameters
+    '("const-char*" "first_field")
+    '("va_list" "args")
+  )
+)
+
+(define-function form_request_new
+  (c-name "soup_form_request_new")
+  (return-type "SoupMessage*")
+  (parameters
+    '("const-char*" "method")
+    '("const-char*" "uri")
+    '("const-char*" "first_field")
+  )
+  (varargs #t)
+)
+
+(define-function form_request_new_from_hash
+  (c-name "soup_form_request_new_from_hash")
+  (return-type "SoupMessage*")
+  (parameters
+    '("const-char*" "method")
+    '("const-char*" "uri")
+    '("GHashTable*" "form_data_set")
+  )
+)
+
+(define-function form_request_new_from_datalist
+  (c-name "soup_form_request_new_from_datalist")
+  (return-type "SoupMessage*")
+  (parameters
+    '("const-char*" "method")
+    '("const-char*" "uri")
+    '("GData**" "form_data_set")
+  )
+)
+
+
+
+;; From soup-headers.h
+
+(define-function headers_parse_request
+  (c-name "soup_headers_parse_request")
+  (return-type "int")
+  (parameters
+    '("const-char*" "str")
+    '("int" "len")
+    '("SoupMessageHeaders*" "req_headers")
+    '("char**" "req_method")
+    '("char**" "req_path")
+    '("SoupHTTPVersion*" "ver")
+  )
+)
+
+(define-function headers_parse_status_line
+  (c-name "soup_headers_parse_status_line")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "status_line")
+    '("SoupHTTPVersion*" "ver")
+    '("guint*" "status_code")
+    '("char**" "reason_phrase")
+  )
+)
+
+(define-function headers_parse_response
+  (c-name "soup_headers_parse_response")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "str")
+    '("int" "len")
+    '("SoupMessageHeaders*" "headers")
+    '("SoupHTTPVersion*" "ver")
+    '("guint*" "status_code")
+    '("char**" "reason_phrase")
+  )
+)
+
+(define-function header_parse_list
+  (c-name "soup_header_parse_list")
+  (return-type "GSList*")
+  (parameters
+    '("const-char*" "header")
+  )
+)
+
+(define-function header_parse_quality_list
+  (c-name "soup_header_parse_quality_list")
+  (return-type "GSList*")
+  (parameters
+    '("const-char*" "header")
+    '("GSList**" "unacceptable")
+  )
+)
+
+(define-function header_free_list
+  (c-name "soup_header_free_list")
+  (return-type "none")
+  (parameters
+    '("GSList*" "list")
+  )
+)
+
+(define-function header_contains
+  (c-name "soup_header_contains")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "header")
+    '("const-char*" "token")
+  )
+)
+
+(define-function header_parse_param_list
+  (c-name "soup_header_parse_param_list")
+  (return-type "GHashTable*")
+  (parameters
+    '("const-char*" "header")
+  )
+)
+
+(define-function header_free_param_list
+  (c-name "soup_header_free_param_list")
+  (return-type "none")
+  (parameters
+    '("GHashTable*" "param_list")
+  )
+)
+
+
+
+;; From soup-logger.h
+
+(define-function logger_get_type
+  (c-name "soup_logger_get_type")
+  (return-type "GType")
+)
+
+(define-function logger_new
+  (c-name "soup_logger_new")
+  (is-constructor-of "SoupLogger")
+  (return-type "SoupLogger*")
+  (parameters
+    '("SoupLoggerLogLevel" "level")
+    '("int" "max_body_size")
+  )
+)
+
+(define-method attach
+  (of-object "SoupLogger")
+  (c-name "soup_logger_attach")
+  (return-type "none")
+  (parameters
+    '("SoupSession*" "session")
+  )
+)
+
+(define-method detach
+  (of-object "SoupLogger")
+  (c-name "soup_logger_detach")
+  (return-type "none")
+  (parameters
+    '("SoupSession*" "session")
+  )
+)
+
+(define-method set_request_filter
+  (of-object "SoupLogger")
+  (c-name "soup_logger_set_request_filter")
+  (return-type "none")
+  (parameters
+    '("SoupLoggerFilter" "request_filter")
+    '("gpointer" "filter_data")
+    '("GDestroyNotify" "destroy")
+  )
+)
+
+(define-method set_response_filter
+  (of-object "SoupLogger")
+  (c-name "soup_logger_set_response_filter")
+  (return-type "none")
+  (parameters
+    '("SoupLoggerFilter" "response_filter")
+    '("gpointer" "filter_data")
+    '("GDestroyNotify" "destroy")
+  )
+)
+
+(define-method set_printer
+  (of-object "SoupLogger")
+  (c-name "soup_logger_set_printer")
+  (return-type "none")
+  (parameters
+    '("SoupLoggerPrinter" "printer")
+    '("gpointer" "printer_data")
+    '("GDestroyNotify" "destroy")
+  )
+)
+
+
+
+;; From soup-message-body.h
+
+(define-function buffer_get_type
+  (c-name "soup_buffer_get_type")
+  (return-type "GType")
+)
+
+(define-function buffer_new
+  (c-name "soup_buffer_new")
+  (is-constructor-of "SoupBuffer")
+  (return-type "SoupBuffer*")
+  (parameters
+    '("SoupMemoryUse" "use")
+    '("gconstpointer" "data")
+    '("gsize" "length")
+  )
+)
+
+(define-method new_subbuffer
+  (of-object "SoupBuffer")
+  (c-name "soup_buffer_new_subbuffer")
+  (return-type "SoupBuffer*")
+  (parameters
+    '("gsize" "offset")
+    '("gsize" "length")
+  )
+)
+
+(define-method copy
+  (of-object "SoupBuffer")
+  (c-name "soup_buffer_copy")
+  (return-type "SoupBuffer*")
+)
+
+(define-method free
+  (of-object "SoupBuffer")
+  (c-name "soup_buffer_free")
+  (return-type "none")
+)
+
+(define-function message_body_get_type
+  (c-name "soup_message_body_get_type")
+  (return-type "GType")
+)
+
+(define-function message_body_new
+  (c-name "soup_message_body_new")
+  (is-constructor-of "SoupMessageBody")
+  (return-type "SoupMessageBody*")
+)
+
+(define-method append
+  (of-object "SoupMessageBody")
+  (c-name "soup_message_body_append")
+  (return-type "none")
+  (parameters
+    '("SoupMemoryUse" "use")
+    '("gconstpointer" "data")
+    '("gsize" "length")
+  )
+)
+
+(define-method append_buffer
+  (of-object "SoupMessageBody")
+  (c-name "soup_message_body_append_buffer")
+  (return-type "none")
+  (parameters
+    '("SoupBuffer*" "buffer")
+  )
+)
+
+(define-method truncate
+  (of-object "SoupMessageBody")
+  (c-name "soup_message_body_truncate")
+  (return-type "none")
+)
+
+(define-method complete
+  (of-object "SoupMessageBody")
+  (c-name "soup_message_body_complete")
+  (return-type "none")
+)
+
+(define-method flatten
+  (of-object "SoupMessageBody")
+  (c-name "soup_message_body_flatten")
+  (return-type "SoupBuffer*")
+)
+
+(define-method get_chunk
+  (of-object "SoupMessageBody")
+  (c-name "soup_message_body_get_chunk")
+  (return-type "SoupBuffer*")
+  (parameters
+    '("goffset" "offset")
+  )
+)
+
+(define-method free
+  (of-object "SoupMessageBody")
+  (c-name "soup_message_body_free")
+  (return-type "none")
+)
+
+
+
+;; From soup-message-headers.h
+
+(define-function message_headers_get_type
+  (c-name "soup_message_headers_get_type")
+  (return-type "GType")
+)
+
+(define-function message_headers_new
+  (c-name "soup_message_headers_new")
+  (is-constructor-of "SoupMessageHeaders")
+  (return-type "SoupMessageHeaders*")
+  (parameters
+    '("SoupMessageHeadersType" "type")
+  )
+)
+
+(define-method free
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_free")
+  (return-type "none")
+)
+
+(define-method append
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_append")
+  (return-type "none")
+  (parameters
+    '("const-char*" "name")
+    '("const-char*" "value")
+  )
+)
+
+(define-method replace
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_replace")
+  (return-type "none")
+  (parameters
+    '("const-char*" "name")
+    '("const-char*" "value")
+  )
+)
+
+(define-method remove
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_remove")
+  (return-type "none")
+  (parameters
+    '("const-char*" "name")
+  )
+)
+
+(define-method clear
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_clear")
+  (return-type "none")
+)
+
+(define-method get
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_get")
+  (return-type "const-char*")
+  (parameters
+    '("const-char*" "name")
+  )
+)
+
+(define-method foreach
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_foreach")
+  (return-type "none")
+  (parameters
+    '("SoupMessageHeadersForeachFunc" "func")
+    '("gpointer" "user_data")
+  )
+)
+
+(define-method get_encoding
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_get_encoding")
+  (return-type "SoupEncoding")
+)
+
+(define-method set_encoding
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_set_encoding")
+  (return-type "none")
+  (parameters
+    '("SoupEncoding" "encoding")
+  )
+)
+
+(define-method get_content_length
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_get_content_length")
+  (return-type "goffset")
+)
+
+(define-method set_content_length
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_set_content_length")
+  (return-type "none")
+  (parameters
+    '("goffset" "content_length")
+  )
+)
+
+(define-method get_expectations
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_get_expectations")
+  (return-type "SoupExpectation")
+)
+
+(define-method set_expectations
+  (of-object "SoupMessageHeaders")
+  (c-name "soup_message_headers_set_expectations")
+  (return-type "none")
+  (parameters
+    '("SoupExpectation" "expectations")
+  )
+)
+
+
+
+;; From soup-message.h
+
+(define-function message_get_type
+  (c-name "soup_message_get_type")
+  (return-type "GType")
+)
+
+(define-function message_new
+  (c-name "soup_message_new")
+  (is-constructor-of "SoupMessage")
+  (return-type "SoupMessage*")
+  (parameters
+    '("const-char*" "method")
+    '("const-char*" "uri_string")
+  )
+)
+
+(define-function message_new_from_uri
+  (c-name "soup_message_new_from_uri")
+  (return-type "SoupMessage*")
+  (parameters
+    '("const-char*" "method")
+    '("SoupURI*" "uri")
+  )
+)
+
+(define-method set_request
+  (of-object "SoupMessage")
+  (c-name "soup_message_set_request")
+  (return-type "none")
+  (parameters
+    '("const-char*" "content_type")
+    '("SoupMemoryUse" "req_use")
+    '("const-char*" "req_body")
+    '("gsize" "req_length")
+  )
+)
+
+(define-method set_response
+  (of-object "SoupMessage")
+  (c-name "soup_message_set_response")
+  (return-type "none")
+  (parameters
+    '("const-char*" "content_type")
+    '("SoupMemoryUse" "resp_use")
+    '("const-char*" "resp_body")
+    '("gsize" "resp_length")
+  )
+)
+
+(define-method set_http_version
+  (of-object "SoupMessage")
+  (c-name "soup_message_set_http_version")
+  (return-type "none")
+  (parameters
+    '("SoupHTTPVersion" "version")
+  )
+)
+
+(define-method get_http_version
+  (of-object "SoupMessage")
+  (c-name "soup_message_get_http_version")
+  (return-type "SoupHTTPVersion")
+)
+
+(define-method is_keepalive
+  (of-object "SoupMessage")
+  (c-name "soup_message_is_keepalive")
+  (return-type "gboolean")
+)
+
+(define-method get_uri
+  (of-object "SoupMessage")
+  (c-name "soup_message_get_uri")
+  (return-type "SoupURI*")
+)
+
+(define-method set_uri
+  (of-object "SoupMessage")
+  (c-name "soup_message_set_uri")
+  (return-type "none")
+  (parameters
+    '("SoupURI*" "uri")
+  )
+)
+
+(define-method set_flags
+  (of-object "SoupMessage")
+  (c-name "soup_message_set_flags")
+  (return-type "none")
+  (parameters
+    '("SoupMessageFlags" "flags")
+  )
+)
+
+(define-method get_flags
+  (of-object "SoupMessage")
+  (c-name "soup_message_get_flags")
+  (return-type "SoupMessageFlags")
+)
+
+(define-method add_header_handler
+  (of-object "SoupMessage")
+  (c-name "soup_message_add_header_handler")
+  (return-type "guint")
+  (parameters
+    '("const-char*" "signal")
+    '("const-char*" "header")
+    '("GCallback" "callback")
+    '("gpointer" "user_data")
+  )
+)
+
+(define-method add_status_code_handler
+  (of-object "SoupMessage")
+  (c-name "soup_message_add_status_code_handler")
+  (return-type "guint")
+  (parameters
+    '("const-char*" "signal")
+    '("guint" "status_code")
+    '("GCallback" "callback")
+    '("gpointer" "user_data")
+  )
+)
+
+(define-method set_status
+  (of-object "SoupMessage")
+  (c-name "soup_message_set_status")
+  (return-type "none")
+  (parameters
+    '("guint" "status_code")
+  )
+)
+
+(define-method set_status_full
+  (of-object "SoupMessage")
+  (c-name "soup_message_set_status_full")
+  (return-type "none")
+  (parameters
+    '("guint" "status_code")
+    '("const-char*" "reason_phrase")
+  )
+)
+
+(define-method wrote_informational
+  (of-object "SoupMessage")
+  (c-name "soup_message_wrote_informational")
+  (return-type "none")
+)
+
+(define-method wrote_headers
+  (of-object "SoupMessage")
+  (c-name "soup_message_wrote_headers")
+  (return-type "none")
+)
+
+(define-method wrote_chunk
+  (of-object "SoupMessage")
+  (c-name "soup_message_wrote_chunk")
+  (return-type "none")
+)
+
+(define-method wrote_body
+  (of-object "SoupMessage")
+  (c-name "soup_message_wrote_body")
+  (return-type "none")
+)
+
+(define-method got_informational
+  (of-object "SoupMessage")
+  (c-name "soup_message_got_informational")
+  (return-type "none")
+)
+
+(define-method got_headers
+  (of-object "SoupMessage")
+  (c-name "soup_message_got_headers")
+  (return-type "none")
+)
+
+(define-method got_chunk
+  (of-object "SoupMessage")
+  (c-name "soup_message_got_chunk")
+  (return-type "none")
+  (parameters
+    '("SoupBuffer*" "chunk")
+  )
+)
+
+(define-method got_body
+  (of-object "SoupMessage")
+  (c-name "soup_message_got_body")
+  (return-type "none")
+)
+
+(define-method restarted
+  (of-object "SoupMessage")
+  (c-name "soup_message_restarted")
+  (return-type "none")
+)
+
+(define-method finished
+  (of-object "SoupMessage")
+  (c-name "soup_message_finished")
+  (return-type "none")
+)
+
+
+
+;; From soup-method.h
+
+
+
+;; From soup-misc.h
+
+(define-function add_io_watch
+  (c-name "soup_add_io_watch")
+  (return-type "GSource*")
+  (parameters
+    '("GMainContext*" "async_context")
+    '("GIOChannel*" "chan")
+    '("GIOCondition" "condition")
+    '("GIOFunc" "function")
+    '("gpointer" "data")
+  )
+)
+
+(define-function add_idle
+  (c-name "soup_add_idle")
+  (return-type "GSource*")
+  (parameters
+    '("GMainContext*" "async_context")
+    '("GSourceFunc" "function")
+    '("gpointer" "data")
+  )
+)
+
+(define-function add_timeout
+  (c-name "soup_add_timeout")
+  (return-type "GSource*")
+  (parameters
+    '("GMainContext*" "async_context")
+    '("guint" "interval")
+    '("GSourceFunc" "function")
+    '("gpointer" "data")
+  )
+)
+
+(define-function signal_connect_once
+  (c-name "soup_signal_connect_once")
+  (return-type "guint")
+  (parameters
+    '("gpointer" "instance")
+    '("const-char*" "detailed_signal")
+    '("GCallback" "c_handler")
+    '("gpointer" "data")
+  )
+)
+
+(define-function str_case_hash
+  (c-name "soup_str_case_hash")
+  (return-type "guint")
+  (parameters
+    '("gconstpointer" "key")
+  )
+)
+
+(define-function str_case_equal
+  (c-name "soup_str_case_equal")
+  (return-type "gboolean")
+  (parameters
+    '("gconstpointer" "v1")
+    '("gconstpointer" "v2")
+  )
+)
+
+(define-function ssl_error_quark
+  (c-name "soup_ssl_error_quark")
+  (return-type "GQuark")
+)
+
+
+
+;; From soup-portability.h
+
+
+
+;; From soup-server.h
+
+(define-function client_context_get_type
+  (c-name "soup_client_context_get_type")
+  (return-type "GType")
+)
+
+(define-function server_get_type
+  (c-name "soup_server_get_type")
+  (return-type "GType")
+)
+
+(define-function server_new
+  (c-name "soup_server_new")
+  (is-constructor-of "SoupServer")
+  (return-type "SoupServer*")
+  (parameters
+    '("const-char*" "optname1")
+  )
+  (varargs #t)
+)
+
+(define-method is_https
+  (of-object "SoupServer")
+  (c-name "soup_server_is_https")
+  (return-type "gboolean")
+)
+
+(define-method get_port
+  (of-object "SoupServer")
+  (c-name "soup_server_get_port")
+  (return-type "int")
+)
+
+(define-method get_listener
+  (of-object "SoupServer")
+  (c-name "soup_server_get_listener")
+  (return-type "SoupSocket*")
+)
+
+(define-method run
+  (of-object "SoupServer")
+  (c-name "soup_server_run")
+  (return-type "none")
+)
+
+(define-method run_async
+  (of-object "SoupServer")
+  (c-name "soup_server_run_async")
+  (return-type "none")
+)
+
+(define-method quit
+  (of-object "SoupServer")
+  (c-name "soup_server_quit")
+  (return-type "none")
+)
+
+(define-method get_async_context
+  (of-object "SoupServer")
+  (c-name "soup_server_get_async_context")
+  (return-type "GMainContext*")
+)
+
+(define-method add_handler
+  (of-object "SoupServer")
+  (c-name "soup_server_add_handler")
+  (return-type "none")
+  (parameters
+    '("const-char*" "path")
+    '("SoupServerCallback" "callback")
+    '("gpointer" "user_data")
+    '("GDestroyNotify" "destroy")
+  )
+)
+
+(define-method remove_handler
+  (of-object "SoupServer")
+  (c-name "soup_server_remove_handler")
+  (return-type "none")
+  (parameters
+    '("const-char*" "path")
+  )
+)
+
+(define-method add_auth_domain
+  (of-object "SoupServer")
+  (c-name "soup_server_add_auth_domain")
+  (return-type "none")
+  (parameters
+    '("SoupAuthDomain*" "auth_domain")
+  )
+)
+
+(define-method remove_auth_domain
+  (of-object "SoupServer")
+  (c-name "soup_server_remove_auth_domain")
+  (return-type "none")
+  (parameters
+    '("SoupAuthDomain*" "auth_domain")
+  )
+)
+
+(define-method pause_message
+  (of-object "SoupServer")
+  (c-name "soup_server_pause_message")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method unpause_message
+  (of-object "SoupServer")
+  (c-name "soup_server_unpause_message")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method get_socket
+  (of-object "SoupClientContext")
+  (c-name "soup_client_context_get_socket")
+  (return-type "SoupSocket*")
+)
+
+(define-method get_address
+  (of-object "SoupClientContext")
+  (c-name "soup_client_context_get_address")
+  (return-type "SoupAddress*")
+)
+
+(define-method get_host
+  (of-object "SoupClientContext")
+  (c-name "soup_client_context_get_host")
+  (return-type "const-char*")
+)
+
+(define-method get_auth_domain
+  (of-object "SoupClientContext")
+  (c-name "soup_client_context_get_auth_domain")
+  (return-type "SoupAuthDomain*")
+)
+
+(define-method get_auth_user
+  (of-object "SoupClientContext")
+  (c-name "soup_client_context_get_auth_user")
+  (return-type "const-char*")
+)
+
+
+
+;; From soup-session-async.h
+
+(define-function session_async_get_type
+  (c-name "soup_session_async_get_type")
+  (return-type "GType")
+)
+
+(define-function session_async_new
+  (c-name "soup_session_async_new")
+  (is-constructor-of "SoupSessionAsync")
+  (return-type "SoupSession*")
+)
+
+(define-function session_async_new_with_options
+  (c-name "soup_session_async_new_with_options")
+  (return-type "SoupSession*")
+  (parameters
+    '("const-char*" "optname1")
+  )
+  (varargs #t)
+)
+
+
+
+;; From soup-session-sync.h
+
+(define-function session_sync_get_type
+  (c-name "soup_session_sync_get_type")
+  (return-type "GType")
+)
+
+(define-function session_sync_new
+  (c-name "soup_session_sync_new")
+  (is-constructor-of "SoupSessionSync")
+  (return-type "SoupSession*")
+)
+
+(define-function session_sync_new_with_options
+  (c-name "soup_session_sync_new_with_options")
+  (return-type "SoupSession*")
+  (parameters
+    '("const-char*" "optname1")
+  )
+  (varargs #t)
+)
+
+
+
+;; From soup-session.h
+
+(define-function session_get_type
+  (c-name "soup_session_get_type")
+  (return-type "GType")
+)
+
+(define-method get_async_context
+  (of-object "SoupSession")
+  (c-name "soup_session_get_async_context")
+  (return-type "GMainContext*")
+)
+
+(define-method queue_message
+  (of-object "SoupSession")
+  (c-name "soup_session_queue_message")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+    '("SoupSessionCallback" "callback")
+    '("gpointer" "user_data")
+  )
+)
+
+(define-method requeue_message
+  (of-object "SoupSession")
+  (c-name "soup_session_requeue_message")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method send_message
+  (of-object "SoupSession")
+  (c-name "soup_session_send_message")
+  (return-type "int")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method pause_message
+  (of-object "SoupSession")
+  (c-name "soup_session_pause_message")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method unpause_message
+  (of-object "SoupSession")
+  (c-name "soup_session_unpause_message")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+  )
+)
+
+(define-method cancel_message
+  (of-object "SoupSession")
+  (c-name "soup_session_cancel_message")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+    '("guint" "status_code")
+  )
+)
+
+(define-method abort
+  (of-object "SoupSession")
+  (c-name "soup_session_abort")
+  (return-type "none")
+)
+
+
+
+;; From soup-socket.h
+
+(define-function socket_get_type
+  (c-name "soup_socket_get_type")
+  (return-type "GType")
+)
+
+(define-function socket_new
+  (c-name "soup_socket_new")
+  (is-constructor-of "SoupSocket")
+  (return-type "SoupSocket*")
+  (parameters
+    '("const-char*" "optname1")
+  )
+  (varargs #t)
+)
+
+(define-method connect_async
+  (of-object "SoupSocket")
+  (c-name "soup_socket_connect_async")
+  (return-type "none")
+  (parameters
+    '("GCancellable*" "cancellable")
+    '("SoupSocketCallback" "callback")
+    '("gpointer" "user_data")
+  )
+)
+
+(define-method connect_sync
+  (of-object "SoupSocket")
+  (c-name "soup_socket_connect_sync")
+  (return-type "int")
+  (parameters
+    '("GCancellable*" "cancellable")
+  )
+)
+
+(define-method listen
+  (of-object "SoupSocket")
+  (c-name "soup_socket_listen")
+  (return-type "gboolean")
+)
+
+(define-method start_ssl
+  (of-object "SoupSocket")
+  (c-name "soup_socket_start_ssl")
+  (return-type "gboolean")
+  (parameters
+    '("GCancellable*" "cancellable")
+  )
+)
+
+(define-method start_proxy_ssl
+  (of-object "SoupSocket")
+  (c-name "soup_socket_start_proxy_ssl")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "ssl_host")
+    '("GCancellable*" "cancellable")
+  )
+)
+
+(define-method is_ssl
+  (of-object "SoupSocket")
+  (c-name "soup_socket_is_ssl")
+  (return-type "gboolean")
+)
+
+(define-method disconnect
+  (of-object "SoupSocket")
+  (c-name "soup_socket_disconnect")
+  (return-type "none")
+)
+
+(define-method is_connected
+  (of-object "SoupSocket")
+  (c-name "soup_socket_is_connected")
+  (return-type "gboolean")
+)
+
+(define-method get_local_address
+  (of-object "SoupSocket")
+  (c-name "soup_socket_get_local_address")
+  (return-type "SoupAddress*")
+)
+
+(define-method get_remote_address
+  (of-object "SoupSocket")
+  (c-name "soup_socket_get_remote_address")
+  (return-type "SoupAddress*")
+)
+
+(define-method read
+  (of-object "SoupSocket")
+  (c-name "soup_socket_read")
+  (return-type "SoupSocketIOStatus")
+  (parameters
+    '("gpointer" "buffer")
+    '("gsize" "len")
+    '("gsize*" "nread")
+    '("GCancellable*" "cancellable")
+    '("GError**" "error")
+  )
+)
+
+(define-method read_until
+  (of-object "SoupSocket")
+  (c-name "soup_socket_read_until")
+  (return-type "SoupSocketIOStatus")
+  (parameters
+    '("gpointer" "buffer")
+    '("gsize" "len")
+    '("gconstpointer" "boundary")
+    '("gsize" "boundary_len")
+    '("gsize*" "nread")
+    '("gboolean*" "got_boundary")
+    '("GCancellable*" "cancellable")
+    '("GError**" "error")
+  )
+)
+
+(define-method write
+  (of-object "SoupSocket")
+  (c-name "soup_socket_write")
+  (return-type "SoupSocketIOStatus")
+  (parameters
+    '("gconstpointer" "buffer")
+    '("gsize" "len")
+    '("gsize*" "nwrote")
+    '("GCancellable*" "cancellable")
+    '("GError**" "error")
+  )
+)
+
+
+
+;; From soup-status.h
+
+(define-function status_get_phrase
+  (c-name "soup_status_get_phrase")
+  (return-type "const-char*")
+  (parameters
+    '("guint" "status_code")
+  )
+)
+
+(define-function http_error_quark
+  (c-name "soup_http_error_quark")
+  (return-type "GQuark")
+)
+
+
+
+;; From soup-types.h
+
+
+
+;; From soup-uri.h
+
+(define-function uri_get_type
+  (c-name "soup_uri_get_type")
+  (return-type "GType")
+)
+
+(define-method new_with_base
+  (of-object "SoupURI")
+  (c-name "soup_uri_new_with_base")
+  (return-type "SoupURI*")
+  (parameters
+    '("const-char*" "uri_string")
+  )
+)
+
+(define-function uri_new
+  (c-name "soup_uri_new")
+  (is-constructor-of "SoupURI")
+  (return-type "SoupURI*")
+  (parameters
+    '("const-char*" "uri_string")
+  )
+)
+
+(define-method to_string
+  (of-object "SoupURI")
+  (c-name "soup_uri_to_string")
+  (return-type "char*")
+  (parameters
+    '("gboolean" "just_path_and_query")
+  )
+)
+
+(define-method copy
+  (of-object "SoupURI")
+  (c-name "soup_uri_copy")
+  (return-type "SoupURI*")
+)
+
+(define-method equal
+  (of-object "SoupURI")
+  (c-name "soup_uri_equal")
+  (return-type "gboolean")
+  (parameters
+    '("SoupURI*" "uri2")
+  )
+)
+
+(define-method free
+  (of-object "SoupURI")
+  (c-name "soup_uri_free")
+  (return-type "none")
+)
+
+(define-function uri_encode
+  (c-name "soup_uri_encode")
+  (return-type "char*")
+  (parameters
+    '("const-char*" "part")
+    '("const-char*" "escape_extra")
+  )
+)
+
+(define-function uri_decode
+  (c-name "soup_uri_decode")
+  (return-type "char*")
+  (parameters
+    '("const-char*" "part")
+  )
+)
+
+(define-function uri_normalize
+  (c-name "soup_uri_normalize")
+  (return-type "char*")
+  (parameters
+    '("const-char*" "part")
+    '("const-char*" "unescape_extra")
+  )
+)
+
+(define-method uses_default_port
+  (of-object "SoupURI")
+  (c-name "soup_uri_uses_default_port")
+  (return-type "gboolean")
+)
+
+(define-method set_scheme
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_scheme")
+  (return-type "none")
+  (parameters
+    '("const-char*" "scheme")
+  )
+)
+
+(define-method set_user
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_user")
+  (return-type "none")
+  (parameters
+    '("const-char*" "user")
+  )
+)
+
+(define-method set_password
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_password")
+  (return-type "none")
+  (parameters
+    '("const-char*" "password")
+  )
+)
+
+(define-method set_host
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_host")
+  (return-type "none")
+  (parameters
+    '("const-char*" "host")
+  )
+)
+
+(define-method set_port
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_port")
+  (return-type "none")
+  (parameters
+    '("guint" "port")
+  )
+)
+
+(define-method set_path
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_path")
+  (return-type "none")
+  (parameters
+    '("const-char*" "path")
+  )
+)
+
+(define-method set_query
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_query")
+  (return-type "none")
+  (parameters
+    '("const-char*" "query")
+  )
+)
+
+(define-method set_query_from_form
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_query_from_form")
+  (return-type "none")
+  (parameters
+    '("GHashTable*" "form")
+  )
+)
+
+(define-method set_query_from_fields
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_query_from_fields")
+  (return-type "none")
+  (parameters
+    '("const-char*" "first_field")
+  )
+  (varargs #t)
+)
+
+(define-method set_fragment
+  (of-object "SoupURI")
+  (c-name "soup_uri_set_fragment")
+  (return-type "none")
+  (parameters
+    '("const-char*" "fragment")
+  )
+)
+
+
+
+;; From soup-value-utils.h
+
+(define-function value_hash_new
+  (c-name "soup_value_hash_new")
+  (return-type "GHashTable*")
+)
+
+(define-function value_hash_new_with_vals
+  (c-name "soup_value_hash_new_with_vals")
+  (return-type "GHashTable*")
+  (parameters
+    '("const-char*" "first_key")
+  )
+  (varargs #t)
+)
+
+(define-function value_hash_insert_value
+  (c-name "soup_value_hash_insert_value")
+  (return-type "none")
+  (parameters
+    '("GHashTable*" "hash")
+    '("const-char*" "key")
+    '("GValue*" "value")
+  )
+)
+
+(define-function value_hash_insert
+  (c-name "soup_value_hash_insert")
+  (return-type "none")
+  (parameters
+    '("GHashTable*" "hash")
+    '("const-char*" "key")
+    '("GType" "type")
+  )
+  (varargs #t)
+)
+
+(define-function value_hash_insert_vals
+  (c-name "soup_value_hash_insert_vals")
+  (return-type "none")
+  (parameters
+    '("GHashTable*" "hash")
+    '("const-char*" "first_key")
+  )
+  (varargs #t)
+)
+
+(define-function value_hash_lookup
+  (c-name "soup_value_hash_lookup")
+  (return-type "gboolean")
+  (parameters
+    '("GHashTable*" "hash")
+    '("const-char*" "key")
+    '("GType" "type")
+  )
+  (varargs #t)
+)
+
+(define-function value_hash_lookup_vals
+  (c-name "soup_value_hash_lookup_vals")
+  (return-type "gboolean")
+  (parameters
+    '("GHashTable*" "hash")
+    '("const-char*" "first_key")
+  )
+  (varargs #t)
+)
+
+(define-function value_array_from_args
+  (c-name "soup_value_array_from_args")
+  (return-type "GValueArray*")
+  (parameters
+    '("va_list" "args")
+  )
+)
+
+(define-function value_array_to_args
+  (c-name "soup_value_array_to_args")
+  (return-type "gboolean")
+  (parameters
+    '("GValueArray*" "array")
+    '("va_list" "args")
+  )
+)
+
+(define-function value_array_new
+  (c-name "soup_value_array_new")
+  (return-type "GValueArray*")
+)
+
+(define-function value_array_new_with_vals
+  (c-name "soup_value_array_new_with_vals")
+  (return-type "GValueArray*")
+  (parameters
+    '("GType" "first_type")
+  )
+  (varargs #t)
+)
+
+(define-function value_array_insert
+  (c-name "soup_value_array_insert")
+  (return-type "none")
+  (parameters
+    '("GValueArray*" "array")
+    '("guint" "index_")
+    '("GType" "type")
+  )
+  (varargs #t)
+)
+
+(define-function value_array_append
+  (c-name "soup_value_array_append")
+  (return-type "none")
+  (parameters
+    '("GValueArray*" "array")
+    '("GType" "type")
+  )
+  (varargs #t)
+)
+
+(define-function value_array_append_vals
+  (c-name "soup_value_array_append_vals")
+  (return-type "none")
+  (parameters
+    '("GValueArray*" "array")
+    '("GType" "first_type")
+  )
+  (varargs #t)
+)
+
+(define-function value_array_get_nth
+  (c-name "soup_value_array_get_nth")
+  (return-type "gboolean")
+  (parameters
+    '("GValueArray*" "array")
+    '("guint" "index_")
+    '("GType" "type")
+  )
+  (varargs #t)
+)
+
+(define-function byte_array_get_type
+  (c-name "soup_byte_array_get_type")
+  (return-type "GType")
+)
+
+
+
+;; From soup-xmlrpc.h
+
+(define-function xmlrpc_build_method_call
+  (c-name "soup_xmlrpc_build_method_call")
+  (return-type "char*")
+  (parameters
+    '("const-char*" "method_name")
+    '("GValue*" "params")
+    '("int" "n_params")
+  )
+)
+
+(define-function xmlrpc_request_new
+  (c-name "soup_xmlrpc_request_new")
+  (return-type "SoupMessage*")
+  (parameters
+    '("const-char*" "uri")
+    '("const-char*" "method_name")
+  )
+  (varargs #t)
+)
+
+(define-function xmlrpc_parse_method_response
+  (c-name "soup_xmlrpc_parse_method_response")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "method_response")
+    '("int" "length")
+    '("GValue*" "value")
+    '("GError**" "error")
+  )
+)
+
+(define-function xmlrpc_extract_method_response
+  (c-name "soup_xmlrpc_extract_method_response")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "method_response")
+    '("int" "length")
+    '("GError**" "error")
+    '("GType" "type")
+  )
+  (varargs #t)
+)
+
+(define-function xmlrpc_parse_method_call
+  (c-name "soup_xmlrpc_parse_method_call")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "method_call")
+    '("int" "length")
+    '("char**" "method_name")
+    '("GValueArray**" "params")
+  )
+)
+
+(define-function xmlrpc_extract_method_call
+  (c-name "soup_xmlrpc_extract_method_call")
+  (return-type "gboolean")
+  (parameters
+    '("const-char*" "method_call")
+    '("int" "length")
+    '("char**" "method_name")
+  )
+  (varargs #t)
+)
+
+(define-function xmlrpc_build_method_response
+  (c-name "soup_xmlrpc_build_method_response")
+  (return-type "char*")
+  (parameters
+    '("GValue*" "value")
+  )
+)
+
+(define-function xmlrpc_build_fault
+  (c-name "soup_xmlrpc_build_fault")
+  (return-type "char*")
+  (parameters
+    '("int" "fault_code")
+    '("const-char*" "fault_format")
+  )
+  (varargs #t)
+)
+
+(define-function xmlrpc_set_response
+  (c-name "soup_xmlrpc_set_response")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+    '("GType" "type")
+  )
+  (varargs #t)
+)
+
+(define-function xmlrpc_set_fault
+  (c-name "soup_xmlrpc_set_fault")
+  (return-type "none")
+  (parameters
+    '("SoupMessage*" "msg")
+    '("int" "fault_code")
+    '("const-char*" "fault_format")
+  )
+  (varargs #t)
+)
+
+(define-function xmlrpc_error_quark
+  (c-name "soup_xmlrpc_error_quark")
+  (return-type "GQuark")
+)
+
+(define-function xmlrpc_fault_quark
+  (c-name "soup_xmlrpc_fault_quark")
+  (return-type "GQuark")
+)
+
+
+
+;; From soup.h
+
+

Added: trunk/python/libsoup.override
==============================================================================
--- (empty file)
+++ trunk/python/libsoup.override	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,591 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * libsoup.override: overrides for libsoup
+ */
+%%
+headers
+#define NO_IMPORT_PYGOBJECT
+#include "pygobject.h"
+#include <libsoup/soup.h>
+
+%%
+modulename soup
+%%
+import gobject.GObject as PyGObject_Type
+import gio.GCancellable as PyGCancellable_Type
+%%
+include
+  SoupLogger.override
+  SoupMessageBody.override
+  SoupMessageHeaders.override
+  SoupURI.override
+  soup-forms.override
+  soup-headers.override
+  soup-xmlrpc.override
+%%
+ignore
+  soup_auth_free_protection_space
+  soup_buffer_new
+  soup_message_new_from_uri
+  soup_signal_connect_once
+%%
+ignore-glob
+  *_get_async_context
+  *_get_type
+  *_new_with_options
+  *_quark
+  soup_address_new_*
+  soup_date_new_*
+  soup_value_array_*
+  soup_value_hash_*
+  soup_str_case_*
+  soup_add_*
+%%
+body
+static int
+pysoup_generic_construct (PyGObject *self, PyObject *kwargs)
+{
+    PyObject *key, *item;
+    Py_ssize_t i, n_params;
+    GObjectClass *klass;
+    GParamSpec *pspec;
+    GParameter *params;
+    int ret = -1, n;
+
+    if (!kwargs)
+	return pygobject_constructv (self, 0, NULL);
+
+    klass = g_type_class_ref (pyg_type_from_object((PyObject *) self));
+    n_params = PyDict_Size (kwargs);
+    params = g_new0 (GParameter, n_params);
+
+    i = n = 0;
+    while (PyDict_Next (kwargs, &i, &key, &item)) {
+	params[n].name = PyString_AsString (key);
+
+	pspec = g_object_class_find_property (klass, params[n].name);
+	if (!pspec) {
+	    PyErr_Format (PyExc_TypeError, "'%s' is an invalid keyword argument for this function", params[n].name);
+	    goto cleanup;
+	}
+
+	g_value_init (&params[n].value, pspec->value_type);
+	if (pyg_value_from_pyobject (&params[n].value, item) == -1) {
+	    PyErr_Format(PyExc_TypeError, "could not convert parameter '%s' of type '%s'",
+			 params[n].name, g_type_name (pspec->value_type));
+	    goto cleanup;
+	}
+	n++;
+    }
+
+    ret = pygobject_constructv (self, n_params, params);
+
+cleanup:
+    for (i = 0; i < n_params; i++)
+	g_value_unset (&params[i].value);
+    g_free (params);
+    g_type_class_unref (klass);
+
+    return ret;
+}
+
+static gboolean
+pysoup_value_from_pyobject (GValue *value, PyObject *pyo)
+{
+    memset (value, 0, sizeof (GValue));
+
+    if (PyBool_Check (pyo)) {
+	g_value_init (value, G_TYPE_BOOLEAN);
+	g_value_set_boolean (value, PyObject_IsTrue (pyo));
+    } else if (PyInt_Check (pyo)) {
+	g_value_init (value, G_TYPE_INT);
+	g_value_set_int (value, PyInt_AsLong (pyo));
+    } else if (PyFloat_Check (pyo)) {
+	g_value_init (value, G_TYPE_DOUBLE);
+	g_value_set_double (value, PyFloat_AsDouble (pyo));
+    } else if (PyString_Check (pyo)) {
+	g_value_init (value, G_TYPE_STRING);
+	g_value_set_string (value, PyString_AsString (pyo));
+    } else if (pyg_boxed_check (pyo, SOUP_TYPE_DATE)) {
+	g_value_init (value, SOUP_TYPE_DATE);
+	g_value_set_boxed (value, pyg_boxed_get (pyo, SoupDate));
+    } else if (PyTuple_Check (pyo) && PyTuple_Size (pyo) == 1 &&
+	       PyString_Check (PyTuple_GetItem (pyo, 0))) {
+	GByteArray *ba;
+	char *data;
+	Py_ssize_t len;
+
+	PyString_AsStringAndSize (PyTuple_GetItem (pyo, 0), &data, &len);
+	ba = g_byte_array_new ();
+	g_byte_array_append (ba, (guchar *)data, len);
+	
+	g_value_init (value, SOUP_TYPE_BYTE_ARRAY);
+	g_value_take_boxed (value, ba);
+    } else if (PyDict_Check (pyo)) {
+	GHashTable *dict;
+	Py_ssize_t i = 0;
+	PyObject *key, *item;
+	char *string_key;
+	GValue member;
+
+	dict = soup_value_hash_new ();
+	while (PyDict_Next (pyo, &i, &key, &item)) {
+	    string_key = PyString_AsString (key);
+	    if (!pysoup_value_from_pyobject (&member, item)) {
+		g_hash_table_destroy (dict);
+		return FALSE;
+	    }
+	    g_hash_table_insert (dict, g_strdup (string_key),
+				 g_memdup (&member, sizeof (GValue)));
+	}
+
+	g_value_init (value, G_TYPE_HASH_TABLE);
+	g_value_take_boxed (value, dict);
+    } else if (PyList_Check (pyo)) {
+	GValueArray *array;
+	PyObject *item;
+	Py_ssize_t len, i;
+
+	len = PyList_Size (pyo);
+	array = g_value_array_new (len);
+	for (i = 0; i < len; i++) {
+	    item = PyList_GetItem (pyo, i);
+	    if (!pysoup_value_from_pyobject (&array->values[i], item)) {
+		g_value_array_free (array);
+		return FALSE;
+	    }
+	    array->n_values++;
+	}
+
+	g_value_init (value, G_TYPE_VALUE_ARRAY);
+	g_value_take_boxed (value, array);
+    } else {
+	PyErr_Format(PyExc_TypeError, "Could not convert argument");
+	return FALSE;
+    }
+
+    return TRUE;
+}
+
+static PyObject *
+pysoup_value_to_pyobject (GValue *value)
+{
+    if (G_VALUE_HOLDS_BOOLEAN (value)) {
+	if (g_value_get_boolean (value))
+	    Py_RETURN_TRUE;
+	else
+	    Py_RETURN_FALSE;
+    } else if (G_VALUE_HOLDS_INT (value)) {
+	return PyInt_FromLong (g_value_get_int (value));
+    } else if (G_VALUE_HOLDS_DOUBLE (value)) {
+	return PyFloat_FromDouble (g_value_get_double (value));
+    } else if (G_VALUE_HOLDS_STRING (value)) {
+	return PyString_FromString (g_value_get_string (value));
+    } else if (G_VALUE_TYPE (value) == SOUP_TYPE_DATE) {
+	return pyg_boxed_new (SOUP_TYPE_DATE, g_value_get_boxed (value),
+			      TRUE, TRUE);
+    } else if (G_VALUE_TYPE (value) == SOUP_TYPE_BYTE_ARRAY) {
+	GByteArray *ba = g_value_get_boxed (value);
+
+	return PyString_FromStringAndSize ((char *)ba->data, ba->len);
+    } else if (G_VALUE_TYPE (value) == G_TYPE_HASH_TABLE) {
+	GHashTable *dict = g_value_get_boxed (value);
+	GHashTableIter iter;
+	gpointer key, value;
+	PyObject *py_dict, *py_member;
+
+	py_dict = PyDict_New ();
+	g_hash_table_iter_init (&iter, dict);
+	while (g_hash_table_iter_next (&iter, &key, &value)) {
+	    py_member = pysoup_value_to_pyobject (value);
+	    if (!py_member) {
+		Py_DECREF (py_dict);
+		return NULL;
+	    }
+	    PyDict_SetItemString (py_dict, key, py_member);
+	}
+	return py_dict;
+    } else if (G_VALUE_TYPE (value) == G_TYPE_VALUE_ARRAY) {
+	GValueArray *array = g_value_get_boxed (value);
+	PyObject *py_list, *py_member;
+	int i;
+
+	py_list = PyList_New (array->n_values);
+	for (i = 0; i < array->n_values; i++) {
+	    py_member = pysoup_value_to_pyobject (&array->values[i]);
+	    if (!py_member) {
+		Py_DECREF (py_list);
+		return FALSE;
+	    }
+	    PyList_SetItem (py_list, i, py_member);
+	}
+	return py_list;
+    }
+
+    PyErr_Format(PyExc_TypeError, "Could not convert argument");
+    return NULL;
+}
+
+static PyObject *
+pysoup_gslist_to_pylist (GSList *gslist)
+{
+    PyObject *pylist;
+    int i;
+
+    pylist = PyList_New (g_slist_length (gslist));
+    for (i = 0; gslist; i++, gslist = gslist->next)
+	PyList_SetItem (pylist, i, PyString_FromString (gslist->data));
+    return pylist;
+}
+
+static PyObject *
+pysoup_ghashtable_to_pydict (GHashTable *dict)
+{
+    GHashTableIter iter;
+    gpointer key, value;
+    PyObject *py_dict;
+
+    py_dict = PyDict_New ();
+    g_hash_table_iter_init (&iter, dict);
+    while (g_hash_table_iter_next (&iter, &key, &value)) {
+	PyDict_SetItemString (py_dict, key,
+			      PyString_FromString (value ? value : ""));
+    }
+    return py_dict;
+}
+
+static GHashTable *
+pysoup_pydict_to_ghashtable (PyObject *dict)
+{
+    GHashTable *hash;
+    PyObject *key, *item;
+    char *string_key, *string_item;
+    Py_ssize_t i = 0;
+
+    g_return_val_if_fail (PyDict_Check (dict), NULL);
+
+    hash = g_hash_table_new (g_str_hash, g_str_equal);
+    while (PyDict_Next (dict, &i, &key, &item)) {
+	string_key = PyString_AsString (key);
+	string_item = PyString_AsString (item);
+	if (!string_item) {
+	    PyErr_Format (PyExc_TypeError, "value of key '%s' is not a string", string_key);
+	    g_hash_table_destroy (hash);
+	    return NULL;
+	}
+	g_hash_table_insert (hash, string_key, string_item);
+    }
+
+    return hash;
+}
+
+typedef struct {
+    PyObject *func, *data;
+} PySoupCallback;
+
+static PySoupCallback *
+pysoup_callback_new (PyObject *func, PyObject *data)
+{
+    PySoupCallback *psc;
+
+    psc = g_slice_new (PySoupCallback);
+    psc->func = func;
+    psc->data = data;
+    Py_INCREF (psc->func);
+    Py_XINCREF (psc->data);
+    return psc;
+}
+
+static void
+pysoup_callback_destroy_notify (gpointer data)
+{
+    PySoupCallback *psc = data;
+
+    Py_DECREF (psc->func);
+    Py_XDECREF (psc->data);
+    g_slice_free (PySoupCallback, psc);
+}
+
+%%
+override soup_date_new kwargs
+static int
+_wrap_soup_date_new(PyGBoxed *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "year", "month", "day", "hour", "minute",
+			      "second", "utc", "offset", "date_string",
+			      "time_t", "from_now", NULL };
+    int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
+    int offset = 0, from_now = 0;
+    PyObject *py_utc = NULL;
+    char *date_string = NULL;
+    long timet = 0;
+    SoupDate *date;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|iiiiiiOizli:SoupDate.__init__",
+                                     kwlist, &year, &month, &day, &hour,
+				     &minute, &second, &py_utc, &offset,
+				     &date_string, &timet, &from_now))
+        return -1;
+
+    self->gtype = SOUP_TYPE_DATE;
+    self->free_on_dealloc = FALSE;
+
+    if (date_string) {
+	if (year || month || day || hour || minute || second ||
+	    py_utc || offset || timet || from_now) {
+	    PyErr_SetString(PyExc_TypeError, "SoupDate.__init__() called with contradictory arguments");
+	    return -1;
+	}
+	self->boxed = soup_date_new_from_string (date_string);
+    } else if (timet) {
+	if (year || month || day || hour || minute || second ||
+	    py_utc || offset || from_now) {
+	    PyErr_SetString(PyExc_TypeError, "SoupDate.__init__() called with contradictory arguments");
+	    return -1;
+	}
+	self->boxed = soup_date_new_from_time_t (timet);
+    } else if (year && month && day) {
+	if (from_now) {
+	    PyErr_SetString(PyExc_TypeError, "SoupDate.__init__() called with contradictory arguments");
+	    return -1;
+	}
+	self->boxed = date = soup_date_new (year, month, day, hour, minute, second);
+	if (py_utc && PyObject_IsTrue(py_utc))
+	    date->utc = TRUE;
+	date->offset = offset;
+    } else {
+	if (year && !from_now) {
+	    from_now = year;
+	    year = 0;
+	}
+	if (year || month || day || hour || minute || second ||
+	    py_utc || offset) {
+	    PyErr_SetString(PyExc_TypeError, "SoupDate.__init__() called with incomplete or contradictory arguments");
+	    return -1;
+	}
+	self->boxed = soup_date_new_from_now (from_now);
+    }
+
+    if (!self->boxed) {
+        PyErr_SetString(PyExc_RuntimeError, "could not create SoupDate object");
+        return -1;
+    }
+    self->free_on_dealloc = TRUE;
+    return 0;
+}
+%%
+new-constructor SOUP_TYPE_ADDRESS
+%%
+override soup_address_new kwargs
+static int
+_wrap_soup_address_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "name_or_family", "port", NULL };
+    PyObject *py_name_or_family = NULL;
+    int port = 0;
+    char *name;
+    SoupAddressFamily family;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "O|i:SoupAddress.__init__",
+				      kwlist, &py_name_or_family, &port))
+        return -1;
+    if (PyString_Check (py_name_or_family)) {
+	name = PyString_AsString (py_name_or_family);
+	if (pygobject_construct (self, "name", name, "port", port, NULL) == -1)
+	    return -1;
+    } else {
+	if (pyg_enum_get_value (SOUP_TYPE_ADDRESS_FAMILY, py_name_or_family, (gpointer)&family) == -1) {
+            PyErr_SetString (PyExc_TypeError, "Parameter 'name_or_family' must be a string or a SoupAddressFamily");
+	    return -1;
+	}
+	if (pygobject_construct (self, "family", family, "port", port, NULL) == -1)
+	    return -1;
+    }
+
+    return 0;
+}
+%%
+override soup_auth_get_protection_space kwargs
+static PyObject *
+_wrap_soup_auth_get_protection_space (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "source_uri", NULL };
+    PyObject *py_uri;
+    SoupURI *source_uri;
+    GSList *pspace;
+    PyObject *py_ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "O:SoupAuth.get_protection_space",
+				      kwlist, &py_uri))
+        return NULL;
+    if (!pyg_boxed_check (py_uri, SOUP_TYPE_URI)) {
+	PyErr_SetString (PyExc_TypeError, "source_uri must be a SoupURI");
+	return NULL;
+    }
+    source_uri = pyg_boxed_get (py_uri, SoupURI);
+
+    pspace = soup_auth_get_protection_space (SOUP_AUTH (self->obj), source_uri);
+    py_ret = pysoup_gslist_to_pylist (pspace);
+    soup_auth_free_protection_space (SOUP_AUTH (self->obj), pspace);
+
+    return py_ret;
+}
+
+%%
+new-constructor SOUP_TYPE_AUTH_DOMAIN_BASIC
+%%
+override soup_auth_domain_basic_new kwargs
+static int
+_wrap_soup_auth_domain_basic_new (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    return pysoup_generic_construct (self, kwargs);
+}
+%%
+new-constructor SOUP_TYPE_AUTH_DOMAIN_DIGEST
+%%
+override soup_auth_domain_digest_new kwargs
+static int
+_wrap_soup_auth_domain_digest_new (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    return pysoup_generic_construct (self, kwargs);
+}
+%%
+new-constructor SOUP_TYPE_MESSAGE
+%%
+override soup_message_new kwargs
+static int
+_wrap_soup_message_new(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "method", "uri", NULL };
+    char *method, *uri_str;
+    PyObject *py_uri;
+    SoupURI *uri;
+    gboolean free_uri = FALSE;
+    int ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "sO:SoupMessage.__init__",
+				      kwlist, &method, &py_uri))
+        return -1;
+    if (PyString_Check (py_uri)) {
+	uri_str = PyString_AsString (py_uri);
+	uri = soup_uri_new (uri_str);
+	free_uri = TRUE;
+	if (!uri) {
+	    PyErr_SetString (PyExc_TypeError, "invalid URI");
+	    return -1;
+	}
+    } else if (pyg_boxed_check (py_uri, SOUP_TYPE_URI)) {
+        uri = pyg_boxed_get (py_uri, SoupURI);
+    } else {
+        PyErr_SetString (PyExc_TypeError, "uri should be a string or SoupURI");
+	return -1;
+    }
+
+    ret = pygobject_construct (self, "method", method, "uri", uri, NULL);
+    if (free_uri)
+	soup_uri_free (uri);
+
+    if (ret == -1)
+        PyErr_SetString(PyExc_RuntimeError, "invalid URI");
+    return ret;
+}
+%%
+new-constructor SOUP_TYPE_SERVER
+%%
+override soup_server_new kwargs
+static int
+_wrap_soup_server_new (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    return pysoup_generic_construct (self, kwargs);
+}
+%%
+override soup_session_queue_message
+
+static void
+pysoup_queue_message_callback (SoupSession *session, SoupMessage *msg,
+			       gpointer user_data)
+{
+    PySoupCallback *psc = user_data;
+    PyGILState_STATE state;
+    PyObject *py_session, *py_msg, *py_ret;
+
+    state = pyg_gil_state_ensure ();
+
+    py_session = pygobject_new ((GObject *)session);
+    py_msg = pygobject_new ((GObject *)msg);
+    if (psc->data) {
+        py_ret = PyEval_CallFunction (psc->func, "(NNO)", py_session, py_msg,
+				      psc->data);
+    } else
+        py_ret = PyEval_CallFunction (psc->func, "(NN)", py_session, py_msg);
+
+    if (py_ret != NULL)
+	Py_DECREF (py_ret);
+    else
+	PyErr_Print ();
+
+    pyg_gil_state_release (state);
+}
+
+static PyObject *
+_wrap_soup_session_queue_message (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "msg", "callback", "user_data", NULL };
+    PyGObject *pymsg;
+    PyObject *pyfunc, *pyarg = NULL;
+    PySoupCallback *psc;
+    SoupMessage *msg;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "OO|O:SoupSession.queue_message",
+				      kwlist, &pymsg, pyfunc, &pyarg))
+        return NULL;
+    if (!pygobject_check (pymsg, &PySoupMessage_Type)) {
+        PyErr_SetString (PyExc_TypeError, "msg must be a SoupMessage");
+        return NULL;
+    }
+    if (!PyCallable_Check (pyfunc)) {
+        PyErr_SetString (PyExc_TypeError, "callback must be a callable object");
+        return NULL;
+    }
+
+    /* soup_session_queue_message steals a ref, so add an extra one. */
+    msg = g_object_ref (pymsg->obj);
+
+    psc = pysoup_callback_new (pyfunc, pyarg);
+    soup_session_queue_message (SOUP_SESSION (self->obj), msg,
+				pysoup_queue_message_callback, psc);
+
+    Py_INCREF (Py_None);
+    return Py_None;
+}
+%%
+new-constructor SOUP_TYPE_SESSION_ASYNC
+%%
+override soup_session_async_new kwargs
+static int
+_wrap_soup_session_async_new (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    return pysoup_generic_construct (self, kwargs);
+}
+%%
+new-constructor SOUP_TYPE_SESSION_SYNC
+%%
+override soup_session_sync_new kwargs
+static int
+_wrap_soup_session_sync_new (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    return pysoup_generic_construct (self, kwargs);
+}
+%%
+new-constructor SOUP_TYPE_SOCKET
+%%
+override soup_socket_new kwargs
+static int
+_wrap_soup_socket_new (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    return pysoup_generic_construct (self, kwargs);
+}

Added: trunk/python/libsoupmodule.c
==============================================================================
--- (empty file)
+++ trunk/python/libsoupmodule.c	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,48 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * libsoupmodule.c: module wrapping libsoup.
+ *
+ * based off atkmodule.c, Copyright (C) 1998-2003  James Henstridge
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* include this first, before NO_IMPORT_PYGOBJECT is defined */
+#include <pygobject.h>
+
+void pylibsoup_register_classes (PyObject *d);
+void pylibsoup_add_constants(PyObject *module, const gchar *strip_prefix);
+void _pylibsoup_register_boxed_types(void);	
+
+extern PyMethodDef pylibsoup_functions[];
+
+DL_EXPORT(void)
+initsoup(void)
+{
+    PyObject *m, *d;
+
+    init_pygobject ();
+    g_thread_init (NULL);
+
+    m = Py_InitModule ("soup", pylibsoup_functions);
+    d = PyModule_GetDict (m);
+    pylibsoup_register_classes (d);
+    pylibsoup_add_constants(m, "SOUP_");
+}

Added: trunk/python/soup-forms.override
==============================================================================
--- (empty file)
+++ trunk/python/soup-forms.override	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,81 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * soup-forms.override: overrides for soup-forms
+ */
+%%
+ignore-glob
+  soup_form_encode_*
+  soup_form_request_new_*
+%%
+override soup_form_decode kwargs
+static PyObject *
+_wrap_soup_form_decode (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "encoded_form", NULL };
+    char *encoded_form;
+    GHashTable *hash;
+    PyObject *dict;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "s:soup.form_decode",
+				      kwlist, &encoded_form))
+        return NULL;
+
+    hash = soup_form_decode (encoded_form);
+    dict = pysoup_ghashtable_to_pydict (hash);
+    g_hash_table_destroy (hash);
+    return dict;
+}
+%%
+override soup_form_encode kwargs
+static PyObject *
+_wrap_soup_form_encode (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "form_data_set", NULL };
+    PyObject *py_form, *py_encoded;
+    GHashTable *form;
+    char *encoded;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "O:soup.form_encode",
+				      kwlist, &py_form))
+        return NULL;
+    if (!PyDict_Check (py_form)) {
+	PyErr_SetString (PyExc_TypeError, "soup.form_encode: argument must be a dict");
+	return NULL;
+    }
+
+    form = pysoup_pydict_to_ghashtable (py_form);
+    encoded = soup_form_encode_hash (form);
+    py_encoded = PyString_FromString (encoded);
+
+    g_free (encoded);
+    g_hash_table_destroy (form);
+    return py_encoded;
+}
+%%
+override soup_form_request_new kwargs
+static PyObject *
+_wrap_soup_form_request_new (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "method", "uri", "form_data_set", NULL };
+    char *method, *uri;
+    PyObject *py_form;
+    GHashTable *form;
+    SoupMessage *msg;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "ssO:soup.form_request_new",
+				      kwlist, &method, &uri, &py_form))
+        return NULL;
+    if (!PyDict_Check (py_form)) {
+	PyErr_SetString (PyExc_TypeError, "soup.form_request_new: 'form_data_set' must be a dict");
+	return NULL;
+    }
+
+    form = pysoup_pydict_to_ghashtable (py_form);
+    msg = soup_form_request_new_from_hash (method, uri, form);
+
+    g_hash_table_destroy (form);
+    return pygobject_new (G_OBJECT (msg));
+}

Added: trunk/python/soup-headers.override
==============================================================================
--- (empty file)
+++ trunk/python/soup-headers.override	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,215 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * soup-headers.override: overrides for soup-headers
+ */
+%%
+ignore
+  soup_header_free_list
+  soup_header_free_param_list
+%%
+override soup_header_parse_list kwargs
+static PyObject *
+_wrap_soup_header_parse_list (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "header", NULL };
+    char *header;
+    GSList *parsed;
+    PyObject *ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "s:soup.header_parse_list",
+				      kwlist, &header))
+        return NULL;
+
+    parsed = soup_header_parse_list (header);
+    ret = pysoup_gslist_to_pylist (parsed);
+    soup_header_free_list (parsed);
+
+    return ret;
+}
+%%
+override soup_header_parse_quality_list kwargs
+static PyObject *
+_wrap_soup_header_parse_quality_list (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "header", NULL };
+    char *header;
+    GSList *acceptable, *unacceptable;
+    PyObject *py_acceptable, *py_unacceptable, *ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "s:soup.header_parse_quality_list",
+				      kwlist, &header))
+        return NULL;
+
+    acceptable = soup_header_parse_quality_list (header, &unacceptable);
+    py_acceptable = pysoup_gslist_to_pylist (acceptable);
+    py_unacceptable = pysoup_gslist_to_pylist (unacceptable);
+    soup_header_free_list (acceptable);
+    soup_header_free_list (unacceptable);
+
+    ret = PyTuple_New (2);
+    PyTuple_SetItem (ret, 0, py_acceptable);
+    PyTuple_SetItem (ret, 1, py_unacceptable);
+    return ret;
+}
+%%
+override soup_header_parse_param_list kwargs
+static PyObject *
+_wrap_soup_header_parse_param_list (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "header", NULL };
+    char *header;
+    GHashTable *params;
+    PyObject *ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "s:soup.header_parse_quality_list",
+				      kwlist, &header))
+        return NULL;
+
+    params = soup_header_parse_param_list (header);
+    ret = pysoup_ghashtable_to_pydict (params);
+    soup_header_free_param_list (params);
+    return ret;
+}
+%%
+override soup_headers_parse_request kwargs
+static PyObject *
+_wrap_soup_headers_parse_request (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "str", "len", NULL };
+    char *str;
+    int len = -1, status_code;
+    SoupMessageHeaders *headers;
+    char *method, *path;
+    SoupHTTPVersion version;
+    PyObject *ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "s|i:soup.headers_parse_request",
+				      kwlist, &str, &len))
+        return NULL;
+    if (len == -1)
+	len = strlen (str);
+
+    headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_REQUEST);
+    status_code = soup_headers_parse_request (str, len, headers,
+					      &method, &path, &version);
+
+    ret = PyTuple_New (5);
+    PyTuple_SetItem (ret, 0, PyInt_FromLong (status_code));
+    if (SOUP_STATUS_IS_SUCCESSFUL (status_code)) {
+	PyTuple_SetItem (ret, 1, pyg_boxed_new (SOUP_TYPE_MESSAGE_HEADERS,
+						headers, FALSE, TRUE));
+	PyTuple_SetItem (ret, 2, PyString_FromString (method));
+	PyTuple_SetItem (ret, 3, PyString_FromString (path));
+	PyTuple_SetItem (ret, 4, pyg_enum_from_gtype (SOUP_TYPE_HTTP_VERSION, version));
+
+	g_free (method);
+	g_free (path);
+    } else {
+	soup_message_headers_free (headers);
+
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 1, Py_None);
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 2, Py_None);
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 3, Py_None);
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 4, Py_None);
+    }
+
+    return ret;
+}
+%%
+override soup_headers_parse_response kwargs
+static PyObject *
+_wrap_soup_headers_parse_response (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "str", "len", NULL };
+    char *str;
+    int len = -1;
+    SoupMessageHeaders *headers;
+    SoupHTTPVersion version;
+    guint status_code;
+    char *reason_phrase;
+    gboolean ok;
+    PyObject *ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "s|i:soup.headers_parse_response",
+				      kwlist, &str, &len))
+        return NULL;
+    if (len == -1)
+	len = strlen (str);
+
+    headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_RESPONSE);
+    ok = soup_headers_parse_response (str, len, headers,
+				     &version, &status_code, &reason_phrase);
+
+    ret = PyTuple_New (4);
+    if (ok) {
+	PyTuple_SetItem (ret, 0, pyg_boxed_new (SOUP_TYPE_MESSAGE_HEADERS,
+						headers, FALSE, TRUE));
+	PyTuple_SetItem (ret, 1, pyg_enum_from_gtype (SOUP_TYPE_HTTP_VERSION, version));
+	PyTuple_SetItem (ret, 2, PyInt_FromLong (status_code));
+	PyTuple_SetItem (ret, 3, PyString_FromString (reason_phrase));
+
+	g_free (reason_phrase);
+    } else {
+	soup_message_headers_free (headers);
+
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 0, Py_None);
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 1, Py_None);
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 2, Py_None);
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 3, Py_None);
+    }
+
+    return ret;
+}
+%%
+override soup_headers_parse_status_line kwargs
+static PyObject *
+_wrap_soup_headers_parse_status_line (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "status_line", NULL };
+    char *status_line;
+    SoupHTTPVersion version;
+    guint status_code;
+    char *reason_phrase;
+    gboolean ok;
+    PyObject *ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "s:soup.headers_parse_response",
+				      kwlist, &status_line))
+        return NULL;
+
+    ok = soup_headers_parse_status_line (status_line,
+					 &version, &status_code,
+					 &reason_phrase);
+
+    ret = PyTuple_New (3);
+    if (ok) {
+	PyTuple_SetItem (ret, 0, pyg_enum_from_gtype (SOUP_TYPE_HTTP_VERSION, version));
+	PyTuple_SetItem (ret, 1, PyInt_FromLong (status_code));
+	PyTuple_SetItem (ret, 2, PyString_FromString (reason_phrase));
+
+	g_free (reason_phrase);
+    } else {
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 0, Py_None);
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 1, Py_None);
+	Py_INCREF(Py_None);
+	PyTuple_SetItem (ret, 2, Py_None);
+    }
+
+    return ret;
+}

Added: trunk/python/soup-xmlrpc.override
==============================================================================
--- (empty file)
+++ trunk/python/soup-xmlrpc.override	Sat Feb  9 23:33:22 2008
@@ -0,0 +1,134 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ *
+ * soup-xmlrpc.override: overrides for soup-xmlrpc
+ */
+%%
+ignore
+  soup_xmlrpc_extract_method_response
+%%
+override soup_xmlrpc_build_method_call
+
+static char *
+pysoup_xmlrpc_build_method_call (PyObject *args, int name_arg)
+{
+    PyObject *py_method_name, *py_param;
+    Py_ssize_t size, i;
+    char *method_name, *method_call;
+    GValueArray *params;
+    GValue value;
+
+    size = PyTuple_Size (args);
+    if (size <= name_arg) {
+	PyErr_SetString (PyExc_TypeError, "soup.xmlrpc_build_method_call: 'method_name' not specified");
+	return NULL;
+    }
+    py_method_name = PyTuple_GetItem (args, name_arg);
+    if (!PyString_Check (py_method_name)) {
+	PyErr_SetString (PyExc_TypeError, "soup.xmlrpc_build_method_call: 'method_name' must be a string");
+	return NULL;
+    }
+    method_name = PyString_AsString (py_method_name);
+
+    params = g_value_array_new (size - name_arg - 1);
+    for (i = name_arg + 1; i < size; i++) {
+	py_param = PyTuple_GetItem (args, i);
+	if (!pysoup_value_from_pyobject (&value, py_param)) {
+	    PyErr_Format (PyExc_TypeError, "soup.xmlrpc_build_method_call: parameter %d could not be converted", (int)i);
+	    g_value_array_free (params);
+	    return NULL;
+	}
+	g_value_array_append (params, &value);
+	g_value_unset (&value);
+    }
+
+    method_call = soup_xmlrpc_build_method_call (method_name, params->values,
+						 params->n_values);
+    g_value_array_free (params);
+    
+    return method_call;
+}
+
+static PyObject *
+_wrap_soup_xmlrpc_build_method_call (PyObject *self, PyObject *args)
+{
+    char *method_call;
+    PyObject *py_ret;
+
+    method_call = pysoup_xmlrpc_build_method_call (args, 0);
+    if (!method_call)
+	return NULL;
+
+    py_ret = PyString_FromString (method_call);
+    g_free (method_call);
+    
+    return py_ret;
+}
+%%
+override soup_xmlrpc_request_new
+static PyObject *
+_wrap_soup_xmlrpc_request_new (PyObject *self, PyObject *args)
+{
+    char *uri, *method_call;
+    SoupMessage *msg;
+    PyObject *py_uri;
+
+    if (PyTuple_Size (args) < 1) {
+	PyErr_SetString (PyExc_TypeError, "soup.xmlrpc_request_new: 'uri' not specified");
+	return NULL;
+    }
+    py_uri = PyTuple_GetItem (args, 0);
+    if (!PyString_Check (py_uri)) {
+	PyErr_SetString (PyExc_TypeError, "soup.xmlrpc_request_new: 'uri' must be a string");
+	return NULL;
+    }
+    uri = PyString_AsString (py_uri);
+
+    method_call = pysoup_xmlrpc_build_method_call (args, 1);
+    if (!method_call)
+	return NULL;
+
+    msg = soup_message_new ("POST", uri);
+    soup_message_set_request (msg, "text/xml", SOUP_MEMORY_TAKE,
+			      method_call, strlen (method_call));    
+
+    return pygobject_new (G_OBJECT (msg));
+}
+%%
+override soup_xmlrpc_parse_method_response kwargs
+static PyObject *
+_wrap_soup_xmlrpc_parse_method_response (PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "method_response", NULL };
+    PyObject *py_method_response;
+    char *method_response;
+    Py_ssize_t length;
+    GError *error = NULL;
+    GValue value;
+    PyObject *py_ret;
+
+    if (!PyArg_ParseTupleAndKeywords (args, kwargs,
+				      "O:soup.xmlrpc_parse_method_response",
+				      kwlist, &py_method_response))
+        return NULL;
+
+    if (PyString_Check (py_method_response))
+	PyString_AsStringAndSize (py_method_response, &method_response, &length);
+    else if (pygobject_check (py_method_response, &PySoupMessage_Type)) {
+	SoupMessage *msg = (SoupMessage *)(((PyGObject *)py_method_response)->obj);
+	method_response = (char *)msg->response_body->data;
+	length = msg->response_body->length;
+    } else {
+	PyErr_SetString (PyExc_TypeError, "method_response should be a string or SoupMessage");
+	return NULL;
+    }
+
+    if (!soup_xmlrpc_parse_method_response (method_response, length,
+					    &value, &error)) {
+	pyg_error_check (&error);
+	return NULL;
+    }
+
+    py_ret = pysoup_value_to_pyobject (&value);
+    g_value_unset (&value);
+    return py_ret;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]