cleanup
[platform/upstream/glib.git] / gio / gsocketlistener.h
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright © 2008 Christian Kellner, Samuel Cormier-Iijima
4  * Copyright © 2009 Codethink Limited
5  * Copyright © 2009 Red Hat, Inc
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published
9  * by the Free Software Foundation; either version 2 of the licence or (at
10  * your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General
18  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19  *
20  * Authors: Christian Kellner <gicmo@gnome.org>
21  *          Samuel Cormier-Iijima <sciyoshi@gmail.com>
22  *          Ryan Lortie <desrt@desrt.ca>
23  *          Alexander Larsson <alexl@redhat.com>
24  */
25
26 #ifndef __G_SOCKET_LISTENER_H__
27 #define __G_SOCKET_LISTENER_H__
28
29 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
30 #error "Only <gio/gio.h> can be included directly."
31 #endif
32
33 #include <gio/giotypes.h>
34
35 G_BEGIN_DECLS
36
37 #define G_TYPE_SOCKET_LISTENER                              (g_socket_listener_get_type ())
38 #define G_SOCKET_LISTENER(inst)                             (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
39                                                              G_TYPE_SOCKET_LISTENER, GSocketListener))
40 #define G_SOCKET_LISTENER_CLASS(class)                      (G_TYPE_CHECK_CLASS_CAST ((class),                       \
41                                                              G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
42 #define G_IS_SOCKET_LISTENER(inst)                          (G_TYPE_CHECK_INSTANCE_TYPE ((inst),                     \
43                                                              G_TYPE_SOCKET_LISTENER))
44 #define G_IS_SOCKET_LISTENER_CLASS(class)                   (G_TYPE_CHECK_CLASS_TYPE ((class),                       \
45                                                              G_TYPE_SOCKET_LISTENER))
46 #define G_SOCKET_LISTENER_GET_CLASS(inst)                   (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
47                                                              G_TYPE_SOCKET_LISTENER, GSocketListenerClass))
48
49 typedef struct _GSocketListenerPrivate                      GSocketListenerPrivate;
50 typedef struct _GSocketListenerClass                        GSocketListenerClass;
51
52 /**
53  * GSocketListenerClass:
54  * @changed: virtual method called when the set of socket listened to changes
55  **/
56 struct _GSocketListenerClass
57 {
58   GObjectClass parent_class;
59
60   void (* changed) (GSocketListener *listener);
61
62   /* Padding for future expansion */
63   void (*_g_reserved1) (void);
64   void (*_g_reserved2) (void);
65   void (*_g_reserved3) (void);
66   void (*_g_reserved4) (void);
67   void (*_g_reserved5) (void);
68   void (*_g_reserved6) (void);
69 };
70
71 struct _GSocketListener
72 {
73   GObject parent_instance;
74   GSocketListenerPrivate *priv;
75 };
76
77 GLIB_AVAILABLE_IN_ALL
78 GType                   g_socket_listener_get_type                      (void) G_GNUC_CONST;
79
80 GLIB_AVAILABLE_IN_ALL
81 GSocketListener *       g_socket_listener_new                           (void);
82
83 GLIB_AVAILABLE_IN_ALL
84 void                    g_socket_listener_set_backlog                   (GSocketListener     *listener,
85                                                                          int                  listen_backlog);
86
87 GLIB_AVAILABLE_IN_ALL
88 gboolean                g_socket_listener_add_socket                    (GSocketListener     *listener,
89                                                                          GSocket             *socket,
90                                                                          GObject             *source_object,
91                                                                          GError             **error);
92 GLIB_AVAILABLE_IN_ALL
93 gboolean                g_socket_listener_add_address                   (GSocketListener     *listener,
94                                                                          GSocketAddress      *address,
95                                                                          GSocketType          type,
96                                                                          GSocketProtocol      protocol,
97                                                                          GObject             *source_object,
98                                                                          GSocketAddress     **effective_address,
99                                                                          GError             **error);
100 GLIB_AVAILABLE_IN_ALL
101 gboolean                g_socket_listener_add_inet_port                 (GSocketListener     *listener,
102                                                                          guint16              port,
103                                                                          GObject             *source_object,
104                                                                          GError             **error);
105 GLIB_AVAILABLE_IN_ALL
106 guint16                 g_socket_listener_add_any_inet_port             (GSocketListener     *listener,
107                                                                          GObject             *source_object,
108                                                                          GError             **error);
109
110 GLIB_AVAILABLE_IN_ALL
111 GSocket *               g_socket_listener_accept_socket                 (GSocketListener      *listener,
112                                                                          GObject             **source_object,
113                                                                          GCancellable         *cancellable,
114                                                                          GError              **error);
115 GLIB_AVAILABLE_IN_ALL
116 void                    g_socket_listener_accept_socket_async           (GSocketListener      *listener,
117                                                                          GCancellable         *cancellable,
118                                                                          GAsyncReadyCallback   callback,
119                                                                          gpointer              user_data);
120 GLIB_AVAILABLE_IN_ALL
121 GSocket *               g_socket_listener_accept_socket_finish          (GSocketListener      *listener,
122                                                                          GAsyncResult         *result,
123                                                                          GObject             **source_object,
124                                                                          GError              **error);
125
126
127 GLIB_AVAILABLE_IN_ALL
128 GSocketConnection *     g_socket_listener_accept                        (GSocketListener      *listener,
129                                                                          GObject             **source_object,
130                                                                          GCancellable         *cancellable,
131                                                                          GError              **error);
132
133 GLIB_AVAILABLE_IN_ALL
134 void                    g_socket_listener_accept_async                  (GSocketListener      *listener,
135                                                                          GCancellable         *cancellable,
136                                                                          GAsyncReadyCallback   callback,
137                                                                          gpointer              user_data);
138
139 GLIB_AVAILABLE_IN_ALL
140 GSocketConnection *     g_socket_listener_accept_finish                 (GSocketListener      *listener,
141                                                                          GAsyncResult         *result,
142                                                                          GObject             **source_object,
143                                                                          GError              **error);
144
145 GLIB_AVAILABLE_IN_ALL
146 void                    g_socket_listener_close                         (GSocketListener      *listener);
147
148 G_END_DECLS
149
150 #endif /* __G_SOCKET_LISTENER_H__ */