Imported Upstream version 0.1.17
[platform/upstream/libnice.git] / socket / socket-priv.h
1 /*
2  * This file is part of the Nice GLib ICE library.
3  *
4  * (C) 2008-2009 Collabora Ltd.
5  *  Contact: Youness Alaoui
6  * (C) 2008-2009 Nokia Corporation. All rights reserved.
7  *
8  * The contents of this file are subject to the Mozilla Public License Version
9  * 1.1 (the "License"); you may not use this file except in compliance with
10  * the License. You may obtain a copy of the License at
11  * http://www.mozilla.org/MPL/
12  *
13  * Software distributed under the License is distributed on an "AS IS" basis,
14  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15  * for the specific language governing rights and limitations under the
16  * License.
17  *
18  * The Original Code is the Nice GLib ICE library.
19  *
20  * The Initial Developers of the Original Code are Collabora Ltd and Nokia
21  * Corporation. All Rights Reserved.
22  *
23  * Contributors:
24  *   Youness Alaoui, Collabora Ltd.
25  *
26  * Alternatively, the contents of this file may be used under the terms of the
27  * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
28  * case the provisions of LGPL are applicable instead of those above. If you
29  * wish to allow use of your version of this file only under the terms of the
30  * LGPL and not to allow others to use your version of this file under the
31  * MPL, indicate your decision by deleting the provisions above and replace
32  * them with the notice and other provisions required by the LGPL. If you do
33  * not delete the provisions above, a recipient may use your version of this
34  * file under either the MPL or the LGPL.
35  */
36
37 #ifndef _SOCKET_PRIV_H
38 #define _SOCKET_PRIV_H
39
40 #include "socket.h"
41
42 G_BEGIN_DECLS
43
44 /**
45  * nice_socket_queue_send:
46  * @send_queue: The queue to add to
47  * @to : Destination
48  * @messages: Messages to queue
49  * @n_messages: Number of messages to queue
50  *
51  * Queue messages to be sent later into the GQueue
52  */
53 void nice_socket_queue_send (GQueue *send_queue, const NiceAddress *to,
54     const NiceOutputMessage *messages, guint n_messages);
55
56 /**
57  * nice_socket_queue_send_with_callback:
58  * @send_queue: The queue to add to
59  * @message: The message to queue
60  * @message_offset: Number of bytes to skip in the message
61  * @message_len: Total length of the message
62  * @head: Whether to add the message to the head of the queue or the tail
63  * @gsock: The #GSocket to create the callback on
64  * @io_source: Pointer to #GSource pointer to store the created source
65  * @context: #GMainContext to attach the @io_source to
66  * @cb: Callback function to call when the @gsock is writable
67  * @user_data: User data for @cb
68  *
69  * Queue (partial) message to be sent later and create a source to call @cb
70  * when the @gsock becomes writable.
71  * The @message_offset can be used if a partial write happened and some bytes
72  * were already written, in which case @head should be set to TRUE to add the
73  * message to the head of the queue.
74  */
75 void nice_socket_queue_send_with_callback (GQueue *send_queue,
76     const NiceOutputMessage *message, gsize message_offset, gsize message_len,
77     gboolean head, GSocket *gsock, GSource **io_source, GMainContext *context,
78     GSocketSourceFunc cb, gpointer user_data);
79
80 /**
81  * nice_socket_flush_send_queue:
82  * @base_socket: Base socket to send on
83  * @send_queue: Queue to flush
84  *
85  * Send all the queued messages reliably to the base socket. We assume only
86  * reliable messages were queued and the underlying socket will handle the
87  * send.
88  */
89 void nice_socket_flush_send_queue (NiceSocket *base_socket, GQueue *send_queue);
90
91 /**
92  * nice_socket_flush_send_queue_to_socket:
93  * @gsock: GSocket to send on
94  * @send_queue: Queue to flush
95  *
96  * Send all the queued messages to the socket. If any message fails to be sent
97  * it will be readded to the queue and #FALSE will be returned, in which case
98  * the IO source must be kept to allow flushing the next time the socket
99  * is writable.
100  * If the queue gets flushed, #TRUE will be returned, in which case, the IO
101  * source should be destroyed.
102  *
103  * Returns: #TRUE if the queue was emptied, #FALSE if the socket would block.
104  */
105 gboolean nice_socket_flush_send_queue_to_socket (GSocket *gsock,
106     GQueue *send_queue);
107
108 /**
109  * nice_socket_free_send_queue:
110  * @send_queue: The send queue
111  *
112  * Frees every item in the send queue without sending them and empties the queue
113  */
114 void nice_socket_free_send_queue (GQueue *send_queue);
115
116 G_END_DECLS
117
118 #endif /* _SOCKET_PRIV_H */
119