From: Andreas Rottmann <a.rottmann@gmx.at>
Subject: Add gobject-introspection support

- Detect gobject-introspection (g-i) in configure, using the M4 macro
  from the newly-added introspection.m4. This adds
  gobject-introspection as a new *optional* build dependency.

- Integrate the generation of .gir and .typelib files into the build
  build process.

- Add the annotations from gir-repository to the source code.

- Include annotation glossary in "Reference Manual" main file.

See <https://bugzilla.gnome.org/show_bug.cgi?id=576595>.

---
 Makefile.am                          |    5 +-
 configure.ac                         |    4 ++
 docs/reference/libsoup-2.4-docs.sgml |    4 ++
 libsoup/Makefile.am                  |   58 ++++++++++++++++++++-
 libsoup/soup-address.c               |   12 ++--
 libsoup/soup-auth.c                  |    4 +-
 libsoup/soup-cookie.c                |   18 +++---
 libsoup/soup-date.c                  |    2 +-
 libsoup/soup-form.c                  |   10 ++--
 libsoup/soup-headers.c               |   33 +++++++-----
 libsoup/soup-message-body.c          |    2 +-
 libsoup/soup-message-headers.c       |   11 +++--
 libsoup/soup-message.c               |    5 +-
 libsoup/soup-server.c                |   20 ++++---
 libsoup/soup-session.c               |    8 ++--
 libsoup/soup-socket.c                |    6 +-
 libsoup/soup-xmlrpc.c                |    8 ++--
 m4/introspection.m4                  |   94 ++++++++++++++++++++++++++++++++++
 18 files changed, 239 insertions(+), 65 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b845e29..861daff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,9 +7,10 @@ EXTRA_DIST =			\
 	libsoup-2.4.pc.in	\
 	libsoup-gnome-2.4.pc.in	\
 	gtk-doc.make		\
-	libsoup-zip.in
+	libsoup-zip.in		\
+	m4/introspection.m4
 
-DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
+DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection
 
 pkgconfigdir = $(libdir)/pkgconfig
 
diff --git a/configure.ac b/configure.ac
index e298524..19c9021 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,6 +206,10 @@ dnl *** gtk-doc ***
 dnl ***************
 GTK_DOC_CHECK([1.10])
 
+dnl *****************************
+dnl *** gobject-introspection ***
+dnl *****************************
+GOBJECT_INTROSPECTION_CHECK([0.6.7])
 
 dnl *************************************
 dnl *** Warnings to show if using GCC ***
diff --git a/docs/reference/libsoup-2.4-docs.sgml b/docs/reference/libsoup-2.4-docs.sgml
index 3cb3d11..c52208f 100644
--- a/docs/reference/libsoup-2.4-docs.sgml
+++ b/docs/reference/libsoup-2.4-docs.sgml
@@ -68,4 +68,8 @@
     <title>Index</title>
   </index>
 
+  <xi:include href="xml/annotation-glossary.xml">
+    <xi:fallback />
+  </xi:include>
+
 </book>
diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am
index 284d85f..2e7c1fb 100644
--- a/libsoup/Makefile.am
+++ b/libsoup/Makefile.am
@@ -202,7 +202,63 @@ libsoup_gnome_2_4_la_SOURCES =		\
 
 endif
 
+#
+# Introspection support
+#
+include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = --add-include-path=.
+INTROSPECTION_COMPILER_ARGS = --includedir=.
+
+if HAVE_INTROSPECTION
+
+# Core library
+gi_soup_files = \
+	$(filter-out soup.h soup-enum-types.% soup-marshal.%,\
+	   $(soup_headers) $(libsoup_2_4_la_SOURCES))
+gi_built_soup_files = soup-enum-types.h
+
+Soup-2.4.gir: libsoup-2.4.la
+Soup_2_4_gir_INCLUDES = Gio-2.0
+Soup_2_4_gir_CFLAGS = $(INCLUDES)
+Soup_2_4_gir_LIBS = libsoup-2.4.la
+Soup_2_4_gir_FILES = \
+	$(addprefix $(srcdir)/, $(gi_soup_files)) \
+        $(foreach f,$(gi_built_soup_files), \
+	   $(if $(shell test -f $(addprefix $(srcdir)/,$(f)) && echo yes), \
+	      $(addprefix $(srcdir)/,$(f)), \
+	      $(f)))
+
+INTROSPECTION_GIRS += Soup-2.4.gir
+
+if BUILD_LIBSOUP_GNOME
+
+# GNOME extensions
+gi_soup_gnome_files = $(filter-out soup-gnome.h,\
+		          $(libsoupgnomeinclude_HEADERS) \
+	                  $(libsoup_gnome_2_4_la_SOURCES))
+SoupGNOME-2.4.gir: libsoup-gnome-2.4.la Soup-2.4.gir
+SoupGNOME_2_4_gir_SCANNERFLAGS = --strip-prefix=soup
+SoupGNOME_2_4_gir_INCLUDES = Soup-2.4
+SoupGNOME_2_4_gir_CFLAGS = $(INCLUDES)
+SoupGNOME_2_4_gir_LIBS = libsoup-gnome-2.4.la
+SoupGNOME_2_4_gir_FILES = $(addprefix $(srcdir)/,$(gi_soup_gnome_files))
+
+INTROSPECTION_GIRS += SoupGNOME-2.4.gir
+
+endif
+
+girdir = $(datadir)/gir-1.0
+dist_gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(dist_gir_DATA) $(typelib_DATA)
+
+endif
+
 EXTRA_DIST=				\
 	soup-marshal.list		\
 	soup-enum-types.h.tmpl		\
-	soup-enum-types.c.tmpl
\ No newline at end of file
+	soup-enum-types.c.tmpl
diff --git a/libsoup/soup-address.c b/libsoup/soup-address.c
index 605a51b..d8be7bd 100644
--- a/libsoup/soup-address.c
+++ b/libsoup/soup-address.c
@@ -364,7 +364,7 @@ soup_address_new (const char *name, guint port)
  * Returns a #SoupAddress equivalent to @sa (or %NULL if @sa's
  * address family isn't supported)
  *
- * Return value: the new #SoupAddress
+ * Return value: (allow-none): the new #SoupAddress
  **/
 SoupAddress *
 soup_address_new_from_sockaddr (struct sockaddr *sa, int len)
@@ -403,7 +403,7 @@ soup_address_new_from_sockaddr (struct sockaddr *sa, int len)
  * for @family (or %NULL if @family isn't supported), suitable for
  * passing to soup_socket_server_new().
  *
- * Return value: the new #SoupAddress
+ * Return value: (allow-none): the new #SoupAddress
  **/
 SoupAddress *
 soup_address_new_any (SoupAddressFamily family, guint port)
@@ -428,7 +428,7 @@ soup_address_new_any (SoupAddressFamily family, guint port)
  * soup_address_is_resolved() to safely test whether or not an address
  * is resolved before fetching its name or address.
  *
- * Return value: the hostname, or %NULL if it is not known.
+ * Return value: (allow-none): the hostname, or %NULL if it is not known.
  **/
 const char *
 soup_address_get_name (SoupAddress *addr)
@@ -451,7 +451,7 @@ soup_address_get_name (SoupAddress *addr)
  * soup_address_is_resolved() to safely test whether or not an address
  * is resolved before fetching its name or address.
  *
- * Return value: the sockaddr, or %NULL
+ * Return value: (allow-none): the sockaddr, or %NULL
  **/
 struct sockaddr *
 soup_address_get_sockaddr (SoupAddress *addr, int *len)
@@ -493,7 +493,7 @@ soup_address_make_inet_address (SoupAddress *addr)
  * soup_address_is_resolved() to safely test whether or not an address
  * is resolved before fetching its name or address.
  *
- * Return value: the physical address, or %NULL
+ * Return value: (allow-none): the physical address, or %NULL
  **/
 const char *
 soup_address_get_physical (SoupAddress *addr)
@@ -672,7 +672,7 @@ idle_complete_resolve (gpointer addr)
  * @addr: a #SoupAddress
  * @async_context: the #GMainContext to call @callback from
  * @cancellable: a #GCancellable object, or %NULL
- * @callback: callback to call with the result
+ * @callback: (scope async): callback to call with the result
  * @user_data: data for @callback
  *
  * Asynchronously resolves the missing half of @addr (its IP address
diff --git a/libsoup/soup-auth.c b/libsoup/soup-auth.c
index 774cf2c..41d56b2 100644
--- a/libsoup/soup-auth.c
+++ b/libsoup/soup-auth.c
@@ -518,7 +518,7 @@ soup_auth_get_authorization (SoupAuth *auth, SoupMessage *msg)
  * of @auth's protection space, unless otherwise discovered not to
  * be.)
  *
- * Return value: the list of paths, which must be freed with
+ * Return value: (element-type utf8): the list of paths, which can be freed with
  * soup_auth_free_protection_space().
  **/
 GSList *
@@ -531,7 +531,7 @@ soup_auth_get_protection_space (SoupAuth *auth, SoupURI *source_uri)
 }
 
 /**
- * soup_auth_free_protection_space:
+ * soup_auth_free_protection_space: (skip)
  * @auth: a #SoupAuth
  * @space: the return value from soup_auth_get_protection_space()
  *
diff --git a/libsoup/soup-cookie.c b/libsoup/soup-cookie.c
index 7f51496..e31bdd9 100644
--- a/libsoup/soup-cookie.c
+++ b/libsoup/soup-cookie.c
@@ -735,8 +735,8 @@ soup_cookie_free (SoupCookie *cookie)
  * #SoupCookie<!-- -->s. Cookies that do not specify "path" or
  * "domain" attributes will have their values defaulted from @msg.
  *
- * Return value: a #GSList of #SoupCookie<!-- -->s, which can be freed
- * with soup_cookies_free().
+ * Return value: (element-type SoupCookie): a #GSList of
+ * #SoupCookie<!-- -->s, which can be freed with soup_cookies_free().
  *
  * Since: 2.24
  **/
@@ -778,8 +778,8 @@ soup_cookies_from_response (SoupMessage *msg)
  * pass a cookie returned from this method directly to
  * soup_cookies_to_response().)
  *
- * Return value: a #GSList of #SoupCookie<!-- -->s, which can be freed
- * with soup_cookies_free().
+ * Return value: (element-type SoupCookie): a #GSList of
+ * #SoupCookie<!-- -->s, which can be freed with soup_cookies_free().
  *
  * Since: 2.24
  **/
@@ -813,7 +813,7 @@ soup_cookies_from_request (SoupMessage *msg)
 
 /**
  * soup_cookies_to_response:
- * @cookies: a #GSList of #SoupCookie
+ * @cookies: (element-type SoupCookie): a #GSList of #SoupCookie
  * @msg: a #SoupMessage
  *
  * Appends a "Set-Cookie" response header to @msg for each cookie in
@@ -840,7 +840,7 @@ soup_cookies_to_response (GSList *cookies, SoupMessage *msg)
 
 /**
  * soup_cookies_to_request:
- * @cookies: a #GSList of #SoupCookie
+ * @cookies: (element-type SoupCookie): a #GSList of #SoupCookie
  * @msg: a #SoupMessage
  *
  * Adds the name and value of each cookie in @cookies to @msg's
@@ -868,8 +868,8 @@ soup_cookies_to_request (GSList *cookies, SoupMessage *msg)
 }
 
 /**
- * soup_cookies_free:
- * @cookies: a #GSList of #SoupCookie
+ * soup_cookies_free: (skip)
+ * @cookies: (element-type SoupCookie): a #GSList of #SoupCookie
  *
  * Frees @cookies.
  *
@@ -887,7 +887,7 @@ soup_cookies_free (GSList *cookies)
 
 /**
  * soup_cookies_to_cookie_header:
- * @cookies: a #GSList of #SoupCookie
+ * @cookies: (element-type SoupCookie): a #GSList of #SoupCookie
  *
  * Serializes a #GSList of #SoupCookie into a string suitable for
  * setting as the value of the "Cookie" header.
diff --git a/libsoup/soup-date.c b/libsoup/soup-date.c
index 2279786..5509af8 100644
--- a/libsoup/soup-date.c
+++ b/libsoup/soup-date.c
@@ -722,7 +722,7 @@ soup_date_to_time_t (SoupDate *date)
 /**
  * soup_date_to_timeval:
  * @date: a #SoupDate
- * @time: a #GTimeVal structure in which to store the converted time.
+ * @time: (out): a #GTimeVal structure in which to store the converted time.
  *
  * Converts @date to a #GTimeVal.
  *
diff --git a/libsoup/soup-form.c b/libsoup/soup-form.c
index 278d845..477e0c7 100644
--- a/libsoup/soup-form.c
+++ b/libsoup/soup-form.c
@@ -78,8 +78,9 @@ form_decode (char *part)
  * Decodes @form, which is an urlencoded dataset as defined in the
  * HTML 4.01 spec.
  *
- * Return value: a hash table containing the name/value pairs from
- * @encoded_form, which you can free with g_hash_table_destroy().
+ * Return value: (element-type utf8 utf8): a hash table containing the
+ * name/value pairs from @encoded_form, which you can free with
+ * g_hash_table_destroy().
  **/
 GHashTable *
 soup_form_decode (const char *encoded_form)
@@ -269,7 +270,8 @@ soup_form_encode (const char *first_field, ...)
 
 /**
  * soup_form_encode_hash:
- * @form_data_set: a hash table containing name/value pairs (as strings)
+ * @form_data_set: (element-type utf8 utf8): a hash table containing
+ * name/value pairs (as strings)
  *
  * Encodes @form_data_set into a value of type
  * "application/x-www-form-urlencoded", as defined in the HTML 4.01
@@ -414,7 +416,7 @@ soup_form_request_new (const char *method, const char *uri,
  * soup_form_request_new_from_hash:
  * @method: the HTTP method, either "GET" or "POST"
  * @uri: the URI to send the form data to
- * @form_data_set: the data to send to @uri
+ * @form_data_set: (element-type utf8 utf8): the data to send to @uri
  *
  * Creates a new %SoupMessage and sets it up to send @form_data_set to
  * @uri via @method, as with soup_form_request_new().
diff --git a/libsoup/soup-headers.c b/libsoup/soup-headers.c
index 9835392..36fc614 100644
--- a/libsoup/soup-headers.c
+++ b/libsoup/soup-headers.c
@@ -158,9 +158,12 @@ soup_headers_clean_for_10 (SoupMessageHeaders *hdrs)
  * @str: the header string (including the trailing blank line)
  * @len: length of @str up to (but not including) the terminating blank line.
  * @req_headers: #SoupMessageHeaders to store the header values in
- * @req_method: if non-%NULL, will be filled in with the request method
- * @req_path: if non-%NULL, will be filled in with the request path
- * @ver: if non-%NULL, will be filled in with the HTTP version
+ * @req_method: (out) (allow-none): if non-%NULL, will be filled in with the
+ * request method
+ * @req_path: (out) (allow-none): if non-%NULL, will be filled in with the
+ * request path
+ * @ver: (out) (allow-none): if non-%NULL, will be filled in with the HTTP
+ * version
  *
  * Parses the headers of an HTTP request in @str and stores the
  * results in @req_method, @req_path, @ver, and @req_headers.
@@ -264,10 +267,12 @@ soup_headers_parse_request (const char          *str,
 /**
  * soup_headers_parse_status_line:
  * @status_line: an HTTP Status-Line
- * @ver: if non-%NULL, will be filled in with the HTTP version
- * @status_code: if non-%NULL, will be filled in with the status code
- * @reason_phrase: if non-%NULL, will be filled in with the reason
- * phrase
+ * @ver: (out) (allow-none): if non-%NULL, will be filled in with the HTTP
+ * version
+ * @status_code: (out) (allow-none): if non-%NULL, will be filled in with
+ * the status code
+ * @reason_phrase: (out) (allow-none): if non-%NULL, will be filled in with
+ * the reason phrase
  *
  * Parses the HTTP Status-Line string in @status_line into @ver,
  * @status_code, and @reason_phrase. @status_line must be terminated by
@@ -339,10 +344,12 @@ soup_headers_parse_status_line (const char       *status_line,
  * @str: the header string (including the trailing blank line)
  * @len: length of @str up to (but not including) the terminating blank line.
  * @headers: #SoupMessageheaders to store the header values in
- * @ver: if non-%NULL, will be filled in with the HTTP version
- * @status_code: if non-%NULL, will be filled in with the status code
- * @reason_phrase: if non-%NULL, will be filled in with the reason
- * phrase
+ * @ver: (out) (allow-none): if non-%NULL, will be filled in with the HTTP
+ * version
+ * @status_code: (out) (allow-none): if non-%NULL, will be filled in with
+ * the status code
+ * @reason_phrase: (out) (allow-none): if non-%NULL, will be filled in with
+ * the reason phrase
  *
  * Parses the headers of an HTTP response in @str and stores the
  * results in @ver, @status_code, @reason_phrase, and @headers.
@@ -504,8 +511,8 @@ sort_by_qval (const void *a, const void *b)
 /**
  * soup_header_parse_quality_list:
  * @header: a header value
- * @unacceptable: on return, will contain a list of unacceptable
- * values
+ * @unacceptable: (out) (allow-none): on return, will contain a list of
+ * unacceptable values
  *
  * Parses a header whose content is a list of items with optional
  * "qvalue"s (eg, Accept, Accept-Charset, Accept-Encoding,
diff --git a/libsoup/soup-message-body.c b/libsoup/soup-message-body.c
index 77ff906..f723374 100644
--- a/libsoup/soup-message-body.c
+++ b/libsoup/soup-message-body.c
@@ -413,7 +413,7 @@ append_buffer (SoupMessageBody *body, SoupBuffer *buffer)
  * soup_message_body_append:
  * @body: a #SoupMessageBody
  * @use: how to use @data
- * @data: data to append
+ * @data: (array length=length) (element-type uint8): data to append
  * @length: length of @data
  *
  * Appends @length bytes from @data to @body according to @use.
diff --git a/libsoup/soup-message-headers.c b/libsoup/soup-message-headers.c
index 6acca0c..4a72f6a 100644
--- a/libsoup/soup-message-headers.c
+++ b/libsoup/soup-message-headers.c
@@ -408,7 +408,8 @@ typedef struct {
 
 /**
  * soup_message_headers_iter_init:
- * @iter: a pointer to a %SoupMessageHeadersIter structure
+ * @iter: (out) (transfer none): a pointer to a %SoupMessageHeadersIter
+ * structure
  * @hdrs: a %SoupMessageHeaders
  *
  * Initializes @iter for iterating @hdrs.
@@ -425,9 +426,11 @@ soup_message_headers_iter_init (SoupMessageHeadersIter *iter,
 
 /**
  * soup_message_headers_iter_next:
- * @iter: a %SoupMessageHeadersIter
- * @name: pointer to a variable to return the header name in
- * @value: pointer to a variable to return the header value in
+ * @iter: (inout) (transfer none): a %SoupMessageHeadersIter
+ * @name: (out) (transfer none): pointer to a variable to return
+ * the header name in
+ * @value: (out) (transfer none): pointer to a variable to return
+ * the header value in
  *
  * Yields the next name/value pair in the %SoupMessageHeaders being
  * iterated by @iter. If @iter has already yielded the last header,
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 7c0b802..4738c76 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -764,9 +764,10 @@ soup_message_set_request (SoupMessage    *msg,
 /**
  * soup_message_set_response:
  * @msg: the message
- * @content_type: MIME Content-Type of the body
+ * @content_type: (allow-none): MIME Content-Type of the body
  * @resp_use: a #SoupMemoryUse describing how to handle @resp_body
- * @resp_body: a data buffer containing the body of the message response.
+ * @resp_body: (array length=resp_length) (element-type uint8): a data buffer
+ * containing the body of the message response.
  * @resp_length: the byte length of @resp_body.
  * 
  * Convenience function to set the response body of a #SoupMessage. If
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 0506550..788bb59 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -652,7 +652,7 @@ soup_server_is_https (SoupServer *server)
  * read-only; writing to it or modifiying it may cause @server to
  * malfunction.
  *
- * Return value: the listening socket.
+ * Return value: (transfer none): the listening socket.
  **/
 SoupSocket *
 soup_server_get_listener (SoupServer *server)
@@ -996,7 +996,7 @@ soup_server_quit (SoupServer *server)
  * context, so you will need to ref it yourself if you want it to
  * outlive its server.
  *
- * Return value: @server's #GMainContext, which may be %NULL
+ * Return value: (transfer none): @server's #GMainContext, which may be %NULL
  **/
 GMainContext *
 soup_server_get_async_context (SoupServer *server)
@@ -1053,7 +1053,8 @@ soup_client_context_get_type (void)
  * not get fooled when the allocator reuses the memory address of a
  * previously-destroyed socket to represent a new socket.
  *
- * Return value: the #SoupSocket that @client is associated with.
+ * Return value: (transfer none): the #SoupSocket that @client is
+ * associated with.
  **/
 SoupSocket *
 soup_client_context_get_socket (SoupClientContext *client)
@@ -1070,8 +1071,8 @@ soup_client_context_get_socket (SoupClientContext *client)
  * Retrieves the #SoupAddress associated with the remote end
  * of a connection.
  *
- * Return value: the #SoupAddress associated with the remote end of a
- * connection.
+ * Return value: (transfer none): the #SoupAddress associated with the
+ * remote end of a connection.
  **/
 SoupAddress *
 soup_client_context_get_address (SoupClientContext *client)
@@ -1110,8 +1111,8 @@ soup_client_context_get_host (SoupClientContext *client)
  * authenticated, and if so returns the #SoupAuthDomain that
  * authenticated it.
  *
- * Return value: a #SoupAuthDomain, or %NULL if the request was not
- * authenticated.
+ * Return value: (transfer none) (allow-none): a #SoupAuthDomain, or
+ * %NULL if the request was not authenticated.
  **/
 SoupAuthDomain *
 soup_client_context_get_auth_domain (SoupClientContext *client)
@@ -1145,7 +1146,8 @@ soup_client_context_get_auth_user (SoupClientContext *client)
  * @server: the #SoupServer
  * @msg: the message being processed
  * @path: the path component of @msg's Request-URI
- * @query: the parsed query component of @msg's Request-URI
+ * @query: (element-type utf8 utf8) (allow-none): the parsed query
+ *         component of @msg's Request-URI
  * @client: additional contextual information about the client
  * @user_data: the data passed to @soup_server_add_handler
  *
@@ -1200,7 +1202,7 @@ soup_client_context_get_auth_user (SoupClientContext *client)
 /**
  * soup_server_add_handler:
  * @server: a #SoupServer
- * @path: the toplevel path for the handler
+ * @path: (allow-none): the toplevel path for the handler
  * @callback: callback to invoke for requests under @path
  * @user_data: data for @callback
  * @destroy: destroy notifier to free @user_data
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 4068804..3082223 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1545,10 +1545,10 @@ queue_message (SoupSession *session, SoupMessage *msg,
 /**
  * soup_session_queue_message:
  * @session: a #SoupSession
- * @msg: the message to queue
- * @callback: a #SoupSessionCallback which will be called after the
- * message completes or when an unrecoverable error occurs.
- * @user_data: a pointer passed to @callback.
+ * @msg: (transfer full): the message to queue
+ * @callback: (allow-none) (scope async): a #SoupSessionCallback which will
+ * be called after the message completes or when an unrecoverable error occurs.
+ * @user_data: (allow-none): a pointer passed to @callback.
  * 
  * Queues the message @msg for sending. All messages are processed
  * while the glib main loop runs. If @msg has been processed before,
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index 4f570a7..8f961a1 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -750,7 +750,7 @@ socket_connect_internal (SoupSocket *sock)
  * soup_socket_connect_async:
  * @sock: a client #SoupSocket (which must not already be connected)
  * @cancellable: a #GCancellable, or %NULL
- * @callback: callback to call after connecting
+ * @callback: (scope async): callback to call after connecting
  * @user_data: data to pass to @callback
  *
  * Begins asynchronously connecting to @sock's remote address. The
@@ -1148,7 +1148,7 @@ soup_socket_is_connected (SoupSocket *sock)
  *
  * Returns the #SoupAddress corresponding to the local end of @sock.
  *
- * Return value: the #SoupAddress
+ * Return value: (transfer none): the #SoupAddress
  **/
 SoupAddress *
 soup_socket_get_local_address (SoupSocket *sock)
@@ -1178,7 +1178,7 @@ soup_socket_get_local_address (SoupSocket *sock)
  *
  * Returns the #SoupAddress corresponding to the remote end of @sock.
  *
- * Return value: the #SoupAddress
+ * Return value: (transfer none): the #SoupAddress
  **/
 SoupAddress *
 soup_socket_get_remote_address (SoupSocket *sock)
diff --git a/libsoup/soup-xmlrpc.c b/libsoup/soup-xmlrpc.c
index 63277b8..a3bd34d 100644
--- a/libsoup/soup-xmlrpc.c
+++ b/libsoup/soup-xmlrpc.c
@@ -545,8 +545,8 @@ parse_value (xmlNode *xmlvalue, GValue *value)
  * soup_xmlrpc_parse_method_call:
  * @method_call: the XML-RPC methodCall string
  * @length: the length of @method_call, or -1 if it is NUL-terminated
- * @method_name: on return, the methodName from @method_call
- * @params: on return, the parameters from @method_call
+ * @method_name: (out): on return, the methodName from @method_call
+ * @params: (out): on return, the parameters from @method_call
  *
  * Parses @method_call to get the name and parameters, and returns the
  * parameter values in a #GValueArray; see also
@@ -612,7 +612,7 @@ fail:
  * soup_xmlrpc_extract_method_call:
  * @method_call: the XML-RPC methodCall string
  * @length: the length of @method_call, or -1 if it is NUL-terminated
- * @method_name: on return, the methodName from @method_call
+ * @method_name: (out): on return, the methodName from @method_call
  * @...: return types and locations for parameters
  *
  * Parses @method_call to get the name and parameters, and puts
@@ -652,7 +652,7 @@ soup_xmlrpc_extract_method_call (const char *method_call, int length,
  * soup_xmlrpc_parse_method_response:
  * @method_response: the XML-RPC methodResponse string
  * @length: the length of @method_response, or -1 if it is NUL-terminated
- * @value: on return, the return value from @method_call
+ * @value: (out): on return, the return value from @method_call
  * @error: error return value
  *
  * Parses @method_response and returns the return value in @value. If
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644
index 0000000..589721c
--- /dev/null
+++ b/m4/introspection.m4
@@ -0,0 +1,94 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+    dnl enable/disable introspection
+    m4_if([$2], [require],
+    [dnl
+        enable_introspection=yes
+    ],[dnl
+        AC_ARG_ENABLE(introspection,
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+                                 [Enable introspection for this build]),, 
+                                 [enable_introspection=auto])
+    ])dnl
+
+    AC_MSG_CHECKING([for gobject-introspection])
+
+    dnl presence/version checking
+    AS_CASE([$enable_introspection],
+    [no], [dnl
+        found_introspection="no (disabled, use --enable-introspection to enable)"
+    ],dnl
+    [yes],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+                         found_introspection=yes,
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME]))
+    ],dnl
+    [auto],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+    ],dnl
+    [dnl	
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+    ])dnl
+
+    AC_MSG_RESULT([$found_introspection])
+
+    INTROSPECTION_SCANNER=
+    INTROSPECTION_COMPILER=
+    INTROSPECTION_GENERATE=
+    INTROSPECTION_GIRDIR=
+    INTROSPECTION_TYPELIBDIR=
+    if test "x$found_introspection" = "xyes"; then
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+    AC_SUBST(INTROSPECTION_CFLAGS)
+    AC_SUBST(INTROSPECTION_LIBS)
+    AC_SUBST(INTROSPECTION_MAKEFILE)
+
+    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])
-- 
tg: (502b432..) t/g-i (depends on: master t/build-fixes)
