Blame libsoup/soup-socket-properties.c

rpm-build 4f3c61
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
rpm-build 4f3c61
/*
rpm-build 4f3c61
 * Copyright 2013 Red Hat, Inc.
rpm-build 4f3c61
 */
rpm-build 4f3c61
rpm-build 4f3c61
#ifdef HAVE_CONFIG_H
rpm-build 4f3c61
#include <config.h>
rpm-build 4f3c61
#endif
rpm-build 4f3c61
rpm-build 4f3c61
#include "soup-socket-private.h"
rpm-build 4f3c61
#include "soup.h"
rpm-build 4f3c61
rpm-build 4f3c61
SoupSocketProperties *
rpm-build 4f3c61
soup_socket_properties_new (GMainContext    *async_context,
rpm-build 4f3c61
			    gboolean         use_thread_context,
rpm-build 4f3c61
			    GProxyResolver  *proxy_resolver,
rpm-build 4f3c61
			    SoupAddress     *local_addr,
rpm-build 4f3c61
			    GTlsDatabase    *tlsdb,
rpm-build 4f3c61
			    GTlsInteraction *tls_interaction,
rpm-build 4f3c61
			    gboolean         ssl_strict,
rpm-build 4f3c61
			    guint            io_timeout,
rpm-build 4f3c61
			    guint            idle_timeout)
rpm-build 4f3c61
{
rpm-build 4f3c61
	SoupSocketProperties *props;
rpm-build 4f3c61
rpm-build 4f3c61
	props = g_slice_new (SoupSocketProperties);
rpm-build 4f3c61
	props->ref_count = 1;
rpm-build 4f3c61
rpm-build 4f3c61
	props->async_context = async_context ? g_main_context_ref (async_context) : NULL;
rpm-build 4f3c61
	props->use_thread_context = use_thread_context;
rpm-build 4f3c61
rpm-build 4f3c61
	props->proxy_resolver = proxy_resolver ? g_object_ref (proxy_resolver) : NULL;
rpm-build 4f3c61
	props->local_addr = local_addr ? g_object_ref (local_addr) : NULL;
rpm-build 4f3c61
rpm-build 4f3c61
	props->tlsdb = tlsdb ? g_object_ref (tlsdb) : NULL;
rpm-build 4f3c61
	props->tls_interaction = tls_interaction ? g_object_ref (tls_interaction) : NULL;
rpm-build 4f3c61
	props->ssl_strict = ssl_strict;
rpm-build 4f3c61
rpm-build 4f3c61
	props->io_timeout = io_timeout;
rpm-build 4f3c61
	props->idle_timeout = idle_timeout;
rpm-build 4f3c61
rpm-build 4f3c61
	return props;
rpm-build 4f3c61
}
rpm-build 4f3c61
rpm-build 4f3c61
SoupSocketProperties *
rpm-build 4f3c61
soup_socket_properties_ref (SoupSocketProperties *props)
rpm-build 4f3c61
{
rpm-build 4f3c61
	g_atomic_int_inc (&props->ref_count);
rpm-build 4f3c61
	return props;
rpm-build 4f3c61
}
rpm-build 4f3c61
rpm-build 4f3c61
void
rpm-build 4f3c61
soup_socket_properties_unref (SoupSocketProperties *props)
rpm-build 4f3c61
{
rpm-build 4f3c61
	if (!g_atomic_int_dec_and_test (&props->ref_count))
rpm-build 4f3c61
		return;
rpm-build 4f3c61
rpm-build 4f3c61
	g_clear_pointer (&props->async_context, g_main_context_unref);
rpm-build 4f3c61
	g_clear_object (&props->proxy_resolver);
rpm-build 4f3c61
	g_clear_object (&props->local_addr);
rpm-build 4f3c61
	g_clear_object (&props->tlsdb);
rpm-build 4f3c61
	g_clear_object (&props->tls_interaction);
rpm-build 4f3c61
rpm-build 4f3c61
	g_slice_free (SoupSocketProperties, props);
rpm-build 4f3c61
}
rpm-build 4f3c61
rpm-build 4f3c61
void
rpm-build 4f3c61
soup_socket_properties_push_async_context (SoupSocketProperties *props)
rpm-build 4f3c61
{
rpm-build 4f3c61
	if (props->async_context && !props->use_thread_context)
rpm-build 4f3c61
		g_main_context_push_thread_default (props->async_context);
rpm-build 4f3c61
}
rpm-build 4f3c61
rpm-build 4f3c61
void
rpm-build 4f3c61
soup_socket_properties_pop_async_context (SoupSocketProperties *props)
rpm-build 4f3c61
{
rpm-build 4f3c61
	if (props->async_context && !props->use_thread_context)
rpm-build 4f3c61
		g_main_context_pop_thread_default (props->async_context);
rpm-build 4f3c61
}
rpm-build 4f3c61
rpm-build 4f3c61
G_DEFINE_BOXED_TYPE (SoupSocketProperties, soup_socket_properties, soup_socket_properties_ref, soup_socket_properties_unref)