Add GSocketClient::event, for tracking socket client status
[platform/upstream/glib.git] / gio / gsocketclient.h
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright © 2008, 2009 Codethink Limited
4  * Copyright © 2009 Red Hat, Inc
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 2 of the licence or (at
9  * your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General
17  * Public License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  * Authors: Ryan Lortie <desrt@desrt.ca>
22  *          Alexander Larsson <alexl@redhat.com>
23  */
24
25 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
26 #error "Only <gio/gio.h> can be included directly."
27 #endif
28
29 #ifndef __G_SOCKET_CLIENT_H__
30 #define __G_SOCKET_CLIENT_H__
31
32 #include <gio/giotypes.h>
33
34 G_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
48 typedef struct _GSocketClientPrivate                        GSocketClientPrivate;
49 typedef struct _GSocketClientClass                          GSocketClientClass;
50
51 struct _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
67 struct _GSocketClient
68 {
69   GObject parent_instance;
70   GSocketClientPrivate *priv;
71 };
72
73 GType                   g_socket_client_get_type                        (void) G_GNUC_CONST;
74
75 GSocketClient          *g_socket_client_new                             (void);
76
77 GSocketFamily           g_socket_client_get_family                      (GSocketClient        *client);
78 void                    g_socket_client_set_family                      (GSocketClient        *client,
79                                                                          GSocketFamily         family);
80 GSocketType             g_socket_client_get_socket_type                 (GSocketClient        *client);
81 void                    g_socket_client_set_socket_type                 (GSocketClient        *client,
82                                                                          GSocketType           type);
83 GSocketProtocol         g_socket_client_get_protocol                    (GSocketClient        *client);
84 void                    g_socket_client_set_protocol                    (GSocketClient        *client,
85                                                                          GSocketProtocol       protocol);
86 GSocketAddress         *g_socket_client_get_local_address               (GSocketClient        *client);
87 void                    g_socket_client_set_local_address               (GSocketClient        *client,
88                                                                          GSocketAddress       *address);
89 guint                   g_socket_client_get_timeout                     (GSocketClient        *client);
90 void                    g_socket_client_set_timeout                     (GSocketClient        *client,
91                                                                          guint                 timeout);
92 gboolean                g_socket_client_get_enable_proxy                (GSocketClient        *client);
93 void                    g_socket_client_set_enable_proxy                (GSocketClient        *client,
94                                                                          gboolean             enable);
95
96 gboolean                g_socket_client_get_tls                         (GSocketClient        *client);
97 void                    g_socket_client_set_tls                         (GSocketClient        *client,
98                                                                          gboolean              tls);
99 GTlsCertificateFlags    g_socket_client_get_tls_validation_flags        (GSocketClient        *client);
100 void                    g_socket_client_set_tls_validation_flags        (GSocketClient        *client,
101                                                                          GTlsCertificateFlags  flags);
102
103 GSocketConnection *     g_socket_client_connect                         (GSocketClient        *client,
104                                                                          GSocketConnectable   *connectable,
105                                                                          GCancellable         *cancellable,
106                                                                          GError              **error);
107 GSocketConnection *     g_socket_client_connect_to_host                 (GSocketClient        *client,
108                                                                          const gchar          *host_and_port,
109                                                                          guint16               default_port,
110                                                                          GCancellable         *cancellable,
111                                                                          GError              **error);
112 GSocketConnection *     g_socket_client_connect_to_service              (GSocketClient        *client,
113                                                                          const gchar          *domain,
114                                                                          const gchar          *service,
115                                                                          GCancellable         *cancellable,
116                                                                          GError              **error);
117 GSocketConnection *     g_socket_client_connect_to_uri                  (GSocketClient        *client,
118                                                                          const gchar          *uri,
119                                                                          guint16               default_port,
120                                                                          GCancellable         *cancellable,
121                                                                          GError              **error);
122 void                    g_socket_client_connect_async                   (GSocketClient        *client,
123                                                                          GSocketConnectable   *connectable,
124                                                                          GCancellable         *cancellable,
125                                                                          GAsyncReadyCallback   callback,
126                                                                          gpointer              user_data);
127 GSocketConnection *     g_socket_client_connect_finish                  (GSocketClient        *client,
128                                                                          GAsyncResult         *result,
129                                                                          GError              **error);
130 void                    g_socket_client_connect_to_host_async           (GSocketClient        *client,
131                                                                          const gchar          *host_and_port,
132                                                                          guint16               default_port,
133                                                                          GCancellable         *cancellable,
134                                                                          GAsyncReadyCallback   callback,
135                                                                          gpointer              user_data);
136 GSocketConnection *     g_socket_client_connect_to_host_finish          (GSocketClient        *client,
137                                                                          GAsyncResult         *result,
138                                                                          GError              **error);
139
140 void                    g_socket_client_connect_to_service_async        (GSocketClient        *client,
141                                                                          const gchar          *domain,
142                                                                          const gchar          *service,
143                                                                          GCancellable         *cancellable,
144                                                                          GAsyncReadyCallback   callback,
145                                                                          gpointer              user_data);
146 GSocketConnection *     g_socket_client_connect_to_service_finish       (GSocketClient        *client,
147                                                                          GAsyncResult         *result,
148                                                                          GError              **error);
149 void                    g_socket_client_connect_to_uri_async            (GSocketClient        *client,
150                                                                          const gchar          *uri,
151                                                                          guint16               default_port,
152                                                                          GCancellable         *cancellable,
153                                                                          GAsyncReadyCallback   callback,
154                                                                          gpointer              user_data);
155 GSocketConnection *     g_socket_client_connect_to_uri_finish           (GSocketClient        *client,
156                                                                          GAsyncResult         *result,
157                                                                          GError              **error);
158 void                    g_socket_client_add_application_proxy           (GSocketClient        *client,
159                                                                          const gchar          *protocol);
160
161 G_END_DECLS
162
163 #endif /* __G_SOCKET_CLIENT_H___ */