From 5df74a141a746d53162f3f10e6c468539ae2de13 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Tue, 8 Sep 2015 12:37:33 +0200 Subject: Support g_autoptr() for all libsoup object types This allows using e.g. g_autoptr(SoupSession) in other programs, but does not make libsoup itself use g_autoptr, or require a new enough glib to support it. https://bugzilla.gnome.org/show_bug.cgi?id=754721 --- docs/reference/Makefile.am | 2 +- libsoup/Makefile.am | 1 + libsoup/soup-autocleanups.h | 47 +++++++++++++++++++++++++++++++++++++++++++++ libsoup/soup.h | 1 + 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 libsoup/soup-autocleanups.h diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am index 6011da1d..71306f7c 100644 --- a/docs/reference/Makefile.am +++ b/docs/reference/Makefile.am @@ -29,7 +29,7 @@ HFILE_GLOB= CFILE_GLOB= # Header files to ignore when scanning. -IGNORE_HFILES= soup.h soup-enum-types.h \ +IGNORE_HFILES= soup.h soup-autocleanups.h soup-enum-types.h \ soup-message-private.h soup-session-private.h \ soup-auth-basic.h soup-auth-digest.h soup-auth-ntlm.h \ soup-connection.h soup-connection-auth.h \ diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am index 1740f898..df25985e 100644 --- a/libsoup/Makefile.am +++ b/libsoup/Makefile.am @@ -31,6 +31,7 @@ soup_headers = \ soup-auth-domain-basic.h \ soup-auth-domain-digest.h \ soup-auth-manager.h \ + soup-autocleanups.h \ soup-cache.h \ soup-content-decoder.h \ soup-content-sniffer.h \ diff --git a/libsoup/soup-autocleanups.h b/libsoup/soup-autocleanups.h new file mode 100644 index 00000000..f50a5cd4 --- /dev/null +++ b/libsoup/soup-autocleanups.h @@ -0,0 +1,47 @@ +/* + * Copyright 2015 Red Hat, Inc. + * + * 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 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, see . + */ + +#ifndef SOUP_AUTOCLEANUPS_H +#define SOUP_AUTOCLEANUPS_H + +#include + +#if SOUP_VERSION_MAX_ALLOWED >= SOUP_VERSION_2_52 +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupAddress, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupAuth, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupAuthDomain, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupCookie, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupCookieJar, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupDate, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupMessage, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupRequest, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupRequestHTTP, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupServer, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSession, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionAsync, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionFeature, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionSync, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSocket, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupURI, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupWebsocketConnection, g_object_unref) + +#endif +#endif + +#endif /* SOUP_AUTOCLEANUPS_H */ diff --git a/libsoup/soup.h b/libsoup/soup.h index 7c5f1ba7..9cc191a4 100644 --- a/libsoup/soup.h +++ b/libsoup/soup.h @@ -16,6 +16,7 @@ extern "C" { #include #include #include +#include #include #include #include -- cgit v1.2.1