diff --git a/configure.ac b/configure.ac index 5808f84..7c6f4b9 100644 --- a/configure.ac +++ b/configure.ac @@ -162,6 +162,10 @@ dnl *** gobject-introspection *** dnl ***************************** GOBJECT_INTROSPECTION_CHECK([0.9.5]) +if test "x$found_introspection" = "xyes"; then + VAPIGEN_CHECK() +fi + AC_MSG_CHECKING([for glib-networking (glib TLS implementation)]) save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am index 1c71dd2..2337045 100644 --- a/libsoup/Makefile.am +++ b/libsoup/Makefile.am @@ -1,6 +1,8 @@ ## Process this file with automake to produce Makefile.in EXTRA_DIST = +CLEANFILES = + include $(GLIB_MAKEFILE) @@ -273,6 +275,15 @@ Soup_2_4_gir_FILES = \ INTROSPECTION_GIRS += Soup-2.4.gir +if ENABLE_VAPIGEN +libsoup-2.4.vapi: Soup-2.4.gir Soup-2.4.metadata Soup-2.4-custom.vala + $(VAPIGEN) --metadatadir=$(top_srcdir)/libsoup --pkg gio-2.0 --library=libsoup-2.4 $^ + +vapidir=$(VAPIDIR) +vapi_DATA=libsoup-2.4.vapi +CLEANFILES += $(vapi_DATA) +endif + if BUILD_LIBSOUP_GNOME # GNOME extensions @@ -300,7 +311,7 @@ gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) -CLEANFILES = $(gir_DATA) $(typelib_DATA) $(BUILT_SOURCES) +CLEANFILES+= $(gir_DATA) $(typelib_DATA) $(BUILT_SOURCES) endif diff --git a/libsoup/Soup-2.4-custom.vala b/libsoup/Soup-2.4-custom.vala new file mode 100644 index 0000000..35449e9 --- /dev/null +++ b/libsoup/Soup-2.4-custom.vala @@ -0,0 +1,168 @@ +namespace Soup { + [CCode (type_id = "soup_auth_domain_basic_get_type ()", cheader_filename = "libsoup/soup.h")] + public class AuthDomainBasic : Soup.AuthDomain { + public static void set_auth_callback (Soup.AuthDomain domain, owned Soup.AuthDomainBasicAuthCallback callback); + } + + [CCode (type_id = "soup_auth_domain_digest_get_type ()", cheader_filename = "libsoup/soup.h")] + public class AuthDomainDigest : Soup.AuthDomain { + public static void set_auth_callback (Soup.AuthDomain domain, owned Soup.AuthDomainDigestAuthCallback callback); + } + + [Compact] + [CCode (copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "soup_buffer_get_type ()", cheader_filename = "libsoup/soup.h")] + public class Buffer { + [CCode (has_construct_function = false)] + public Buffer.subbuffer (Soup.Buffer parent, size_t offset, size_t length); + } + + [Deprecated (replacement = "Soup.ProxyURIResolver")] + [CCode (cheader_filename = "libsoup/soup.h", type_cname = "SoupProxyResolverInterface", type_id = "soup_proxy_resolver_get_type ()")] + public interface ProxyResolver : Soup.SessionFeature, GLib.Object { + public abstract void get_proxy_async (Soup.Message msg, GLib.MainContext async_context, GLib.Cancellable? cancellable, Soup.ProxyResolverCallback callback); + public abstract uint get_proxy_sync (Soup.Message msg, GLib.Cancellable? cancellable, out unowned Soup.Address addr); + } + + public errordomain SSLError { + HANDSHAKE_NEEDS_READ, + HANDSHAKE_NEEDS_WRITE, + CERTIFICATE, + HANDSHAKE_FAILED; + public static GLib.Quark quark (); + } + + [Compact] + [CCode (copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "soup_uri_get_type ()", cheader_filename = "libsoup/soup.h")] + public class URI { + [CCode (has_construct_function = false)] + public URI.with_base (Soup.URI @base, string uri_string); + } + + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.build_fault")] + [PrintfFormat] + public static unowned string xmlrpc_build_fault (int fault_code, string fault_format, ...); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.build_method_call")] + public static unowned string xmlrpc_build_method_call (string method_name, GLib.Value[] @params); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.build_method_response")] + public static unowned string xmlrpc_build_method_response (GLib.Value value); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.error_quark")] + public static GLib.Quark xmlrpc_error_quark (); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.extract_method_call")] + [CCode (sentinel = "G_TYPE_INVALID")] + public static bool xmlrpc_extract_method_call (string method_call, int length, out unowned string method_name, ...); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.extract_method_response")] + [CCode (sentinel = "G_TYPE_INVALID")] + public static bool xmlrpc_extract_method_response (string method_response, int length, ...) throws GLib.Error; + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.fault_quark")] + public static GLib.Quark xmlrpc_fault_quark (); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.parse_method_call")] + public static bool xmlrpc_parse_method_call (string method_call, int length, out unowned string method_name, out unowned GLib.ValueArray @params); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.parse_method_response")] + public static bool xmlrpc_parse_method_response (string method_response, int length, GLib.Value value) throws GLib.Error; + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.request_new")] + [CCode (sentinel = "G_TYPE_INVALID")] + public static unowned Soup.Message xmlrpc_request_new (string uri, string method_name, ...); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.set_fault")] + [PrintfFormat] + public static void xmlrpc_set_fault (Soup.Message msg, int fault_code, string fault_format, ...); + [Deprecated (since = "vala-0.12", replacement = "XMLRPC.set_response")] + [CCode (sentinel = "G_TYPE_INVALID")] + public static void xmlrpc_set_response (Soup.Message msg, ...); + + [Deprecated (since = "vala-0.12", replacement = "Form.decode")] + public static GLib.HashTable form_decode (string encoded_form); + [Deprecated (since = "vala-0.12", replacement = "Form.decode_multipart")] + public static GLib.HashTable form_decode_multipart (Soup.Message msg, string file_control_name, out string filename, out string content_type, out Soup.Buffer file); + [Deprecated (since = "vala-0.12", replacement = "Form.encode")] + public static string form_encode (...); + [Deprecated (since = "vala-0.12", replacement = "Form.encode_datalist")] + public static string form_encode_datalist (void* form_data_set); + [Deprecated (since = "vala-0.12", replacement = "Form.encode_hash")] + public static string form_encode_hash (GLib.HashTable form_data_set); + [Deprecated (since = "vala-0.12")] + public static string form_encode_valist (string first_field, void* args); + [Deprecated (since = "vala-0.12", replacement = "Form.request_new")] + public static Soup.Message form_request_new (string method, string uri, ...); + [Deprecated (since = "vala-0.12", replacement = "Form.request_new_from_datalist")] + public static Soup.Message form_request_new_from_datalist (string method, string uri, void* form_data_set); + [Deprecated (since = "vala-0.12", replacement = "Form.request_new_from_hash")] + public static Soup.Message form_request_new_from_hash (string method, string uri, GLib.HashTable form_data_set); + [Deprecated (since = "vala-0.12", replacement = "Form.request_new_from_multipart")] + public static Soup.Message form_request_new_from_multipart (string uri, Soup.Multipart multipart); + [Deprecated (since = "vala-0.14", replacement = "SSLError.quark")] + public static GLib.Quark ssl_error_quark (); + + [Deprecated (since = "vala-0.22", replacement = "Status.get_phrase")] + public static unowned string status_get_phrase (uint status_code); + [Deprecated (since = "vala-0.22", replacement = "Status.proxify")] + public static uint status_proxify (uint status_code); + [Deprecated (since = "vala-0.22", replacement = "Status")] + [CCode (cheader_filename = "libsoup/soup.h", cprefix = "SOUP_STATUS_", type_id = "soup_known_status_code_get_type ()")] + public enum KnownStatusCode { + NONE, + CANCELLED, + CANT_RESOLVE, + CANT_RESOLVE_PROXY, + CANT_CONNECT, + CANT_CONNECT_PROXY, + SSL_FAILED, + IO_ERROR, + MALFORMED, + TRY_AGAIN, + TOO_MANY_REDIRECTS, + TLS_FAILED, + CONTINUE, + SWITCHING_PROTOCOLS, + PROCESSING, + OK, + CREATED, + ACCEPTED, + NON_AUTHORITATIVE, + NO_CONTENT, + RESET_CONTENT, + PARTIAL_CONTENT, + MULTI_STATUS, + MULTIPLE_CHOICES, + MOVED_PERMANENTLY, + FOUND, + MOVED_TEMPORARILY, + SEE_OTHER, + NOT_MODIFIED, + USE_PROXY, + NOT_APPEARING_IN_THIS_PROTOCOL, + TEMPORARY_REDIRECT, + BAD_REQUEST, + UNAUTHORIZED, + PAYMENT_REQUIRED, + FORBIDDEN, + NOT_FOUND, + METHOD_NOT_ALLOWED, + NOT_ACCEPTABLE, + PROXY_AUTHENTICATION_REQUIRED, + PROXY_UNAUTHORIZED, + REQUEST_TIMEOUT, + CONFLICT, + GONE, + LENGTH_REQUIRED, + PRECONDITION_FAILED, + REQUEST_ENTITY_TOO_LARGE, + REQUEST_URI_TOO_LONG, + UNSUPPORTED_MEDIA_TYPE, + REQUESTED_RANGE_NOT_SATISFIABLE, + INVALID_RANGE, + EXPECTATION_FAILED, + UNPROCESSABLE_ENTITY, + LOCKED, + FAILED_DEPENDENCY, + INTERNAL_SERVER_ERROR, + NOT_IMPLEMENTED, + BAD_GATEWAY, + SERVICE_UNAVAILABLE, + GATEWAY_TIMEOUT, + HTTP_VERSION_NOT_SUPPORTED, + INSUFFICIENT_STORAGE, + NOT_EXTENDED + } + + public delegate void ProxyResolverCallback (Soup.ProxyResolver p1, Soup.Message p2, uint p3, Soup.Address p4); +} diff --git a/libsoup/Soup-2.4.metadata b/libsoup/Soup-2.4.metadata new file mode 100644 index 0000000..8ffb659 --- /dev/null +++ b/libsoup/Soup-2.4.metadata @@ -0,0 +1,99 @@ +// Vala-specific +AuthDomain + .add_path#property skip + .remove_path#property skip +form_* parent="Soup.Form" name="form_(.+)" +form_encode_datalist.form_data_set type_arguments="string" +form_request_new_from_datalist.form_data_set type_arguments="string" +xmlrpc_* parent="Soup.XMLRPC" name="xmlrpc_(.+)" +XMLRPCFault errordomain parent="Soup.XMLRPC" name="Fault" +XMLRPCError parent="Soup.XMLRPC" name="Error" +xmlrpc_set_response.type skip +HTTPVersion.http_* name="http_(.+)" + +// Backwards compatibility +KnownStatusCode skip +Requester deprecated_since="2.42" replacement="Session" +Requester + .request* skip=false unowned=false + +// Report upstream +Soup cheader_filename="libsoup/soup.h" +add_* skip=false type="unowned GLib.TimeoutSource" +AuthDomain + .accepts#method skip + .challenge#virtual_method vfunc_name="challenge" + .basic_set_auth_callback skip + .digest_set_auth_callback skip +AuthDomainBasic.new skip=false +AuthDomainDigest.new skip=false +Buffer.new.data type="uint8[]" array_length_idx=2 +Buffer.new_with_owner.data type="uint8[]" array_length_idx=1 +Buffer.new_subbuffer skip +Buffer.new_with_owner.owner_dnotify nullable +CookieJar.all_cookies type_arguments="Cookie" +ContentSniffer.sniff.params type_arguments="string,string" nullable out unowned=false +form_* skip=false +header_parse_list type_arguments="string" +header_parse_quality_list type_arguments="string" + .unacceptable out type_arguments="string" +Message + .add_header_handler skip=false + .add_status_code_handler skip=false + .request_*#property skip + .response_*#property skip + .set_request.req_body type="uint8[]" array_length_idx=3 +MessageHeaders + .get_ranges.ranges out type="Soup.Range[]" array_length_idx=2 +Server + .new skip=false + .async_context type="GLib.MainContext" +Session + .async_context type="GLib.MainContext" + .get_features type_arguments="weak Soup.SessionFeature" + .send_async.cancellable#parameter default=null +Session*.new_with_options skip=false +Socket + .async_context type="GLib.MainContext" + .new skip=false + .read.buffer type="uint8[]" array_length_idx=1 + .read_until.buffer type="uint8[]" array_length_idx=1 + .read_until.nread out + .write.buffer type="uint8[]" array_length_idx=1 +URI + .new_with_base skip + .set_query_from_fields skip=false +uri_encode.escape_extra nullable +// uri_host_*.* type="Soup.URI" +ProxyURIResolverCallback.user_data skip +xmlrpc_* skip=false +// xmlrpc_build_method_call.params array array_length_idx=2 +xmlrpc_extract_method_response throws="Soup.XMLRPC.Fault" + .error skip + .type skip +value_* skip=false +ProxyURIResolver + .get_proxy_uri_async skip=false + .get_proxy_uri_async.callback owned scope="async" + .get_proxy_uri_async.async_context nullable + .get_proxy_uri_sync.proxy_uri out unowned=false + +// Not enough GIR information +Buffer.data type="uint8[]" array_length_field="length" +MessageBody.data type="uint8[]" array_length_field="length" +xmlrpc_parse_method_response throws="Soup.XMLRPC.Fault" +Date + .new_from_time_t.when type="time_t" + .to_time_t type="time_t" +xmlrpc_extract_method_call sentinel="G_TYPE_INVALID" +xmlrpc_extract_method_response sentinel="G_TYPE_INVALID" +xmlrpc_request_new sentinel="G_TYPE_INVALID" +xmlrpc_set_fault printf_format +xmlrpc_set_response sentinel="G_TYPE_INVALID" +xmlrpc_build_fault printf_format + +// Simplify memory management +Buffer + .new deprecated_since="2.32" replacement="Buffer.take" +MessageBody + .append deprecated_since="2.32" replacement="MessageBody.append_take" \ No newline at end of file diff --git a/m4/vapigen.m4 b/m4/vapigen.m4 new file mode 100644 index 0000000..7a0f1b8 --- /dev/null +++ b/m4/vapigen.m4 @@ -0,0 +1,177 @@ +dnl vapigen.m4 +dnl +dnl Copyright 2012 Evan Nemerson, Daniel Espinosa +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND-INTROSPECTION], [DEFAULT]) +# -------------------------------------- +# Check vapigen existence and version. GObject Introspection is required, then +# set FOUND-INTROSPECTION to [yes] or use call GOBJECT_INTROSPECTION_CHECK or +# GOBJECT_INTROSPECTION_REQUIRE. This is an internal macro, use VAPIGEN_CHECK, +# VAPIGEN_GI_CHECK or VAPIGEN_GI_REQUIRE. +# +# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation +m4_define([_VAPIGEN_CHECK_INTERNAL], +[ + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) + AC_REQUIRE([AM_PROG_VALAC]) + AC_ARG_ENABLE([vala], + [AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings @<:@default=]ifelse($4,,auto,$4)[@:>@])],,[ + AS_IF([ test "x$4" = "x"], [ + enable_vala=auto + ], [ + enable_vala=$4 + ]) + ]) + AS_IF([ test "x$enable_vala" = "xyes" -o "x$enable_vala" = "xauto"], + [ + AS_IF([ test "x$3" != "xyes" -a "x$found_introspection" != "xyes"], [ + AC_MSG_ERROR([Vala bindings require GObject Introspection]) + ]) + ], [ + AS_IF([ test "x$enable_vala" != "no"],[ + vapigen_pkg_found=no + ],[ + AC_MSG_ERROR([Invalid argument passed to --enable-vala, should be one of @<:@no/auto/yes@:>@]) + ]) + ]) + AS_IF([ test "x$2" = "x"], [ + vapigen_pkg_name=vapigen + ], [ + vapigen_pkg_name=vapigen-$2 + ]) + AS_IF([ test "x$1" = "x"], [ + vapigen_pkg="$vapigen_pkg_name" + ], [ + vapigen_pkg="$vapigen_pkg_name >= $1" + ]) + AS_IF([ test "x$enable_vala" = "xyes" -o "x$enable_vala" = "xauto"], [ + AC_MSG_CHECKING([for vapigen $vapigen_pkg_name]) + PKG_CHECK_EXISTS([ $vapigen_pkg ], [ + vapigen_pkg_found=yes + ], [ + vapigen_pkg_found=no + AC_MSG_RESULT([no]) + AC_MSG_NOTICE([Searching for $vapigen_pkg_name program...]) + AC_PATH_PROG(VAPIGEN, [$vapigen_pkg_name], [no]) + if test "x$VAPIGEN" = "xno" + then + check_prog=no + else + check_prog=yes + fi + ]) + + AS_CASE([$vapigen_pkg_found], + [yes], [ + VAPIGEN=`$PKG_CONFIG --variable=vapigen vapigen` + VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir vapigen`/vala/Makefile.vapigen + VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen` + AS_IF([ test "x$2" = "x"], [ + VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen` + ], [ + VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned vapigen` + ]) + ], + [no], [ + AS_CASE([$check_prog],[no],[ + AC_MSG_ERROR([Can't locate $vapigen_pkg program]) + ], [yes], [ + AS_IF([ test "x$2" = "x"], [ + vala_pkg_name=libvala + ], [ + vala_pkg_name=libvala-$2 + ]) + AS_IF([ test "x$1" = "x"], [ + vala_pkg="$vala_pkg_name" + ], [ + vala_pkg="$vala_pkg_name >= $1" + ]) + AC_MSG_CHECKING([for $vala_pkg]) + PKG_CHECK_EXISTS([$vala_pkg], [ + VALA_DATADIR=`pkg-config $vala_pkg --variable=datadir` + VAPIDIR="$VALA_DATADIR/vala/vapi" + VAPIGEN_MAKEFILE="$VALA_DATADIR/vala/Makefile.vapigen" + AS_IF([ test "x$2" = "x"], [ + VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir vapigen` + ], [ + VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned vapigen` + ]) + vapigen_pkg_found=yes + ], [ + AS_CASE([$enable_vala], [yes], [ + AC_MSG_ERROR([$vala_pkg not found]) + ], [auto], [ + vapigen_pkg_found=no + ]) + ]) + ]) + ]) + + AC_MSG_RESULT([$vapigen_pkg_found]) + + + ]) + AC_SUBST([VAPIGEN]) + AC_SUBST([VAPIGEN_VAPIDIR]) + AC_SUBST([VAPIDIR]) + AC_SUBST([VAPIGEN_MAKEFILE]) + + AM_CONDITIONAL(ENABLE_VAPIGEN, test "x$vapigen_pkg_found" = "xyes") +]) + +dnl Check VAPIGEN +# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND-INTROSPECTION], [DEFAULT]) +# -------------------------------------- +# Check vapigen existence and version. Set FOUND-INTROSPECTION to [yes] +# if you have detected GObject Introspection without GOBJECT_INTROSPECTION_CHECK +# or GOBJECT_INTROSPECTION_REQUIRE macros. +# +# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation +AC_DEFUN([VAPIGEN_CHECK], +[ + _VAPIGEN_CHECK_INTERNAL($1,$2,$3,$4) +] +) + +dnl usage: +# VAPIGEN_GI_CHECK([VERSION], [API_VERSION], [DEFAULT]) +# -------------------------------------- +# Check vapigen existence and version. You must call GOBJECT_INTROSPECTION_CHECK +# first in order to call this macro. +# +# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation +AC_DEFUN([VAPIGEN_GI_CHECK], +[ + AC_REQUIRE([GOBJECT_INTROSPECTION_CHECK]) + _VAPIGEN_CHECK_INTERNAL([$1],[$2],[$found_introspection],[$3]) +] +) + +dnl usage: +# VAPIGEN_GI_REQUIRE([VERSION], [API_VERSION], [DEFAULT]) +# -------------------------------------- +# Check vapigen existence and version. You must call GOBJECT_INTROSPECTION_REQUIRE +# first in order to call this macro. +# +# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation +AC_DEFUN([VAPIGEN_GI_REQUIRE], +[ + AC_REQUIRE([GOBJECT_INTROSPECTION_REQUIRE]) + _VAPIGEN_CHECK_INTERNAL([$1],[$2],[$found_introspection],[$3]) +] +) +