1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * soup-proxy-uri-resolver.c: HTTP proxy resolver interface, take 2
4 *
5 * Copyright (C) 2009 Red Hat, Inc.
6 */
7
8 #ifdef HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #undef SOUP_VERSION_MIN_REQUIRED
13 #define SOUP_VERSION_MIN_REQUIRED SOUP_VERSION_2_42
14
15 #include "soup-proxy-uri-resolver.h"
16 #include "soup.h"
17
18 /**
19 * SECTION:soup-proxy-uri-resolver
20 * @short_description: Interface for locating HTTP proxies
21 *
22 * #SoupProxyURIResolver is an interface for finding appropriate HTTP
23 * proxies to use.
24 *
25 * Deprecated: #SoupSession now has a #SoupSession:proxy-resolver
26 * property that takes a #GProxyResolver (which is semantically
27 * identical to #SoupProxyURIResolver).
28 *
29 * Even in older releases of libsoup, you are not likely to have to
30 * implement this interface on your own; instead, you should usually
31 * just be able to use #SoupProxyResolverDefault.
32 */
33
G_DEFINE_INTERFACE_WITH_CODE(SoupProxyURIResolver,soup_proxy_uri_resolver,G_TYPE_OBJECT,g_type_interface_add_prerequisite (g_define_type_id,SOUP_TYPE_SESSION_FEATURE);)34 G_DEFINE_INTERFACE_WITH_CODE (SoupProxyURIResolver, soup_proxy_uri_resolver, G_TYPE_OBJECT,
35 g_type_interface_add_prerequisite (g_define_type_id, SOUP_TYPE_SESSION_FEATURE);
36 )
37
38 static void
39 soup_proxy_uri_resolver_default_init (SoupProxyURIResolverInterface *iface)
40 {
41 }
42
43 /**
44 * SoupProxyURIResolverCallback:
45 * @resolver: the #SoupProxyURIResolver
46 * @status: a #SoupStatus
47 * @proxy_uri: the resolved proxy URI, or %NULL
48 * @user_data: data passed to soup_proxy_uri_resolver_get_proxy_uri_async()
49 *
50 * Callback for soup_proxy_uri_resolver_get_proxy_uri_async()
51 */
52
53 /**
54 * soup_proxy_uri_resolver_get_proxy_uri_async:
55 * @proxy_uri_resolver: the #SoupProxyURIResolver
56 * @uri: the #SoupURI you want a proxy for
57 * @async_context: (allow-none): the #GMainContext to invoke @callback in
58 * @cancellable: a #GCancellable, or %NULL
59 * @callback: (scope async): callback to invoke with the proxy address
60 * @user_data: data for @callback
61 *
62 * Asynchronously determines a proxy URI to use for @msg and calls
63 * @callback.
64 *
65 * Since: 2.26.3
66 *
67 * Deprecated: #SoupProxyURIResolver is deprecated in favor of
68 * #GProxyResolver
69 */
70 void
soup_proxy_uri_resolver_get_proxy_uri_async(SoupProxyURIResolver * proxy_uri_resolver,SoupURI * uri,GMainContext * async_context,GCancellable * cancellable,SoupProxyURIResolverCallback callback,gpointer user_data)71 soup_proxy_uri_resolver_get_proxy_uri_async (SoupProxyURIResolver *proxy_uri_resolver,
72 SoupURI *uri,
73 GMainContext *async_context,
74 GCancellable *cancellable,
75 SoupProxyURIResolverCallback callback,
76 gpointer user_data)
77 {
78 SOUP_PROXY_URI_RESOLVER_GET_CLASS (proxy_uri_resolver)->
79 get_proxy_uri_async (proxy_uri_resolver, uri,
80 async_context, cancellable,
81 callback, user_data);
82 }
83
84 /**
85 * soup_proxy_uri_resolver_get_proxy_uri_sync:
86 * @proxy_uri_resolver: the #SoupProxyURIResolver
87 * @uri: the #SoupURI you want a proxy for
88 * @cancellable: a #GCancellable, or %NULL
89 * @proxy_uri: (out): on return, will contain the proxy URI
90 *
91 * Synchronously determines a proxy URI to use for @uri. If @uri
92 * should be sent via proxy, *@proxy_uri will be set to the URI of the
93 * proxy, else it will be set to %NULL.
94 *
95 * Return value: %SOUP_STATUS_OK if successful, or a transport-level
96 * error.
97 *
98 * Since: 2.26.3
99 *
100 * Deprecated: #SoupProxyURIResolver is deprecated in favor of
101 * #GProxyResolver
102 */
103 guint
soup_proxy_uri_resolver_get_proxy_uri_sync(SoupProxyURIResolver * proxy_uri_resolver,SoupURI * uri,GCancellable * cancellable,SoupURI ** proxy_uri)104 soup_proxy_uri_resolver_get_proxy_uri_sync (SoupProxyURIResolver *proxy_uri_resolver,
105 SoupURI *uri,
106 GCancellable *cancellable,
107 SoupURI **proxy_uri)
108 {
109 return SOUP_PROXY_URI_RESOLVER_GET_CLASS (proxy_uri_resolver)->
110 get_proxy_uri_sync (proxy_uri_resolver, uri, cancellable, proxy_uri);
111 }
112