1/* GIO - GLib Input, Output and Streaming Library
2 *
3 * Copyright © 2008, 2009 Codethink Limited
4 * Copyright © 2009 Red Hat, Inc
5 *
6 * SPDX-License-Identifier: LGPL-2.1-or-later
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General
19 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 *
21 * Authors: Ryan Lortie <desrt@desrt.ca>
22 * Alexander Larsson <alexl@redhat.com>
23 */
24
25#ifndef __G_SOCKET_CLIENT_H__
26#define __G_SOCKET_CLIENT_H__
27
28#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
29#error "Only <gio/gio.h> can be included directly."
30#endif
31
32#include <gio/giotypes.h>
33
34G_BEGIN_DECLS
35
36#define G_TYPE_SOCKET_CLIENT (g_socket_client_get_type ())
37#define G_SOCKET_CLIENT(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
38 G_TYPE_SOCKET_CLIENT, GSocketClient))
39#define G_SOCKET_CLIENT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
40 G_TYPE_SOCKET_CLIENT, GSocketClientClass))
41#define G_IS_SOCKET_CLIENT(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
42 G_TYPE_SOCKET_CLIENT))
43#define G_IS_SOCKET_CLIENT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
44 G_TYPE_SOCKET_CLIENT))
45#define G_SOCKET_CLIENT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
46 G_TYPE_SOCKET_CLIENT, GSocketClientClass))
47
48typedef struct _GSocketClientPrivate GSocketClientPrivate;
49typedef struct _GSocketClientClass GSocketClientClass;
50
51struct _GSocketClientClass
52{
53 GObjectClass parent_class;
54
55 void (* event) (GSocketClient *client,
56 GSocketClientEvent event,
57 GSocketConnectable *connectable,
58 GIOStream *connection);
59
60 /* Padding for future expansion */
61 void (*_g_reserved1) (void);
62 void (*_g_reserved2) (void);
63 void (*_g_reserved3) (void);
64 void (*_g_reserved4) (void);
65};
66
67struct _GSocketClient
68{
69 GObject parent_instance;
70 GSocketClientPrivate *priv;
71};
72
73GIO_AVAILABLE_IN_ALL
74GType g_socket_client_get_type (void) G_GNUC_CONST;
75
76GIO_AVAILABLE_IN_ALL
77GSocketClient *g_socket_client_new (void);
78
79GIO_AVAILABLE_IN_ALL
80GSocketFamily g_socket_client_get_family (GSocketClient *client);
81GIO_AVAILABLE_IN_ALL
82void g_socket_client_set_family (GSocketClient *client,
83 GSocketFamily family);
84GIO_AVAILABLE_IN_ALL
85GSocketType g_socket_client_get_socket_type (GSocketClient *client);
86GIO_AVAILABLE_IN_ALL
87void g_socket_client_set_socket_type (GSocketClient *client,
88 GSocketType type);
89GIO_AVAILABLE_IN_ALL
90GSocketProtocol g_socket_client_get_protocol (GSocketClient *client);
91GIO_AVAILABLE_IN_ALL
92void g_socket_client_set_protocol (GSocketClient *client,
93 GSocketProtocol protocol);
94GIO_AVAILABLE_IN_ALL
95GSocketAddress *g_socket_client_get_local_address (GSocketClient *client);
96GIO_AVAILABLE_IN_ALL
97void g_socket_client_set_local_address (GSocketClient *client,
98 GSocketAddress *address);
99GIO_AVAILABLE_IN_ALL
100guint g_socket_client_get_timeout (GSocketClient *client);
101GIO_AVAILABLE_IN_ALL
102void g_socket_client_set_timeout (GSocketClient *client,
103 guint timeout);
104GIO_AVAILABLE_IN_ALL
105gboolean g_socket_client_get_enable_proxy (GSocketClient *client);
106GIO_AVAILABLE_IN_ALL
107void g_socket_client_set_enable_proxy (GSocketClient *client,
108 gboolean enable);
109
110GIO_AVAILABLE_IN_2_28
111gboolean g_socket_client_get_tls (GSocketClient *client);
112GIO_AVAILABLE_IN_2_28
113void g_socket_client_set_tls (GSocketClient *client,
114 gboolean tls);
115GIO_DEPRECATED_IN_2_72
116GTlsCertificateFlags g_socket_client_get_tls_validation_flags (GSocketClient *client);
117GIO_DEPRECATED_IN_2_72
118void g_socket_client_set_tls_validation_flags (GSocketClient *client,
119 GTlsCertificateFlags flags);
120GIO_AVAILABLE_IN_2_36
121GProxyResolver *g_socket_client_get_proxy_resolver (GSocketClient *client);
122GIO_AVAILABLE_IN_2_36
123void g_socket_client_set_proxy_resolver (GSocketClient *client,
124 GProxyResolver *proxy_resolver);
125
126GIO_AVAILABLE_IN_ALL
127GSocketConnection * g_socket_client_connect (GSocketClient *client,
128 GSocketConnectable *connectable,
129 GCancellable *cancellable,
130 GError **error);
131GIO_AVAILABLE_IN_ALL
132GSocketConnection * g_socket_client_connect_to_host (GSocketClient *client,
133 const gchar *host_and_port,
134 guint16 default_port,
135 GCancellable *cancellable,
136 GError **error);
137GIO_AVAILABLE_IN_ALL
138GSocketConnection * g_socket_client_connect_to_service (GSocketClient *client,
139 const gchar *domain,
140 const gchar *service,
141 GCancellable *cancellable,
142 GError **error);
143GIO_AVAILABLE_IN_2_26
144GSocketConnection * g_socket_client_connect_to_uri (GSocketClient *client,
145 const gchar *uri,
146 guint16 default_port,
147 GCancellable *cancellable,
148 GError **error);
149GIO_AVAILABLE_IN_ALL
150void g_socket_client_connect_async (GSocketClient *client,
151 GSocketConnectable *connectable,
152 GCancellable *cancellable,
153 GAsyncReadyCallback callback,
154 gpointer user_data);
155GIO_AVAILABLE_IN_ALL
156GSocketConnection * g_socket_client_connect_finish (GSocketClient *client,
157 GAsyncResult *result,
158 GError **error);
159GIO_AVAILABLE_IN_ALL
160void g_socket_client_connect_to_host_async (GSocketClient *client,
161 const gchar *host_and_port,
162 guint16 default_port,
163 GCancellable *cancellable,
164 GAsyncReadyCallback callback,
165 gpointer user_data);
166GIO_AVAILABLE_IN_ALL
167GSocketConnection * g_socket_client_connect_to_host_finish (GSocketClient *client,
168 GAsyncResult *result,
169 GError **error);
170
171GIO_AVAILABLE_IN_ALL
172void g_socket_client_connect_to_service_async (GSocketClient *client,
173 const gchar *domain,
174 const gchar *service,
175 GCancellable *cancellable,
176 GAsyncReadyCallback callback,
177 gpointer user_data);
178GIO_AVAILABLE_IN_ALL
179GSocketConnection * g_socket_client_connect_to_service_finish (GSocketClient *client,
180 GAsyncResult *result,
181 GError **error);
182GIO_AVAILABLE_IN_ALL
183void g_socket_client_connect_to_uri_async (GSocketClient *client,
184 const gchar *uri,
185 guint16 default_port,
186 GCancellable *cancellable,
187 GAsyncReadyCallback callback,
188 gpointer user_data);
189GIO_AVAILABLE_IN_ALL
190GSocketConnection * g_socket_client_connect_to_uri_finish (GSocketClient *client,
191 GAsyncResult *result,
192 GError **error);
193GIO_AVAILABLE_IN_ALL
194void g_socket_client_add_application_proxy (GSocketClient *client,
195 const gchar *protocol);
196
197G_END_DECLS
198
199#endif /* __G_SOCKET_CLIENT_H___ */
200