Added missing header file for conversation
[oweals/gnunet.git] / src / include / gnunet_conversation_service.h
1 /*
2       This file is part of GNUnet
3       (C) 
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 2, or (at your
8       option) any later version.
9
10       GNUnet is distributed in the hope that it will be useful, but
11       WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file include/gnunet_conversation_service.h
23  * @brief API to the conversation service
24  * @author Simon Dieterle
25  * @author Andreas Fuchs
26  */
27 #ifndef GNUNET_CONVERSATION_SERVICE_H
28 #define GNUNET_CONVERSATION_SERVICE_H
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #if 0                           /* keep Emacsens' auto-indent happy */
34 }
35 #endif
36 #endif
37
38 /**
39  * Version of the conversation API.
40  */
41 #define GNUNET_conversation_VERSION 0x00000001
42
43 enum GNUNET_CONVERSATION_RejectReason
44 {
45   REJECT_REASON_NO_CLIENT = 0,
46   REJECT_REASON_ACTIVE_CALL,
47   REJECT_REASON_NOT_WANTED
48 };
49
50 enum GNUNET_CONVERSATION_NotificationType
51 {
52   NotificationType_SERVICE_BLOCKED = 0,
53   NotificationType_NO_PEER,
54   NotificationType_NO_ANSWER,
55   NotificationType_AVAILABLE_AGAIN,
56   NotificationType_CALL_ACCEPTED,
57   NotificationType_CALL_TERMINATED
58 };
59
60 /**
61 *
62 */
63 struct GNUNET_CONVERSATION_MissedCall
64 {
65   struct GNUNET_PeerIdentity peer;
66   struct GNUNET_TIME_Absolute time;
67
68 };
69
70 struct GNUNET_CONVERSATION_MissedCallNotification
71 {
72   int number;
73   struct GNUNET_CONVERSATION_MissedCall *calls;
74 };
75
76 struct GNUNET_CONVERSATION_CallInformation;
77 struct GNUNET_CONVERSATION_Handle;
78
79 /**
80  * Method called whenever a call is incoming
81  *
82  * @param cls closure
83  * @param handle to the conversation session
84  * @param caller peer that calls you
85  */
86 typedef void (GNUNET_CONVERSATION_CallHandler) (void *cls,
87                                         struct
88                                         GNUNET_CONVERSATION_Handle
89                                         * handle,
90                                         const struct
91                                         GNUNET_PeerIdentity * caller);
92
93 /**
94  * Method called whenever a call is rejected
95  *
96  * @param cls closure
97  * @param handle to the conversation session
98  * @param peer peer that rejected your call
99  */
100 typedef void (GNUNET_CONVERSATION_RejectHandler) (void *cls,
101                                           struct
102                                           GNUNET_CONVERSATION_Handle
103                                           * handle,
104                                           int
105                                           reason,
106                                           const struct
107                                           GNUNET_PeerIdentity * peer);
108
109 /**
110  * Method called whenever a notification is there
111  *
112  * @param cls closure
113  * @param handle to the conversation session
114  * @param type the type of the notification
115  * @param peer peer that the notification is about
116  */
117 typedef void (GNUNET_CONVERSATION_NotificationHandler) (void *cls,
118                                                 struct
119                                                 GNUNET_CONVERSATION_Handle
120                                                 * handle,
121                                                 int
122                                                 type,
123                                                 const struct
124                                                 GNUNET_PeerIdentity * peer);
125
126 /**
127  * Method called whenever a notification for missed calls is there
128  *
129  * @param cls closure
130  * @param handle to the conversation session
131  * @param missed_calls a list of missed calls
132  */
133 typedef void (GNUNET_CONVERSATION_MissedCallHandler) (void *cls,
134                                               struct
135                                               GNUNET_CONVERSATION_Handle
136                                               * handle,
137                                               struct
138                                               GNUNET_CONVERSATION_MissedCallNotification
139                                               * missed_calls);
140
141 /**
142  * Connect to the VoIP service
143  *
144  * @param cfg configuration
145  * @param cls NULL
146  * @param call_handler the callback which is called when a call is incoming
147  * @param reject_handler the callback which is called when a call is rejected
148  * @param notification_handler the callback which is called when there is a notification
149  * @param missed_call_handler the callback which is called when the service notifies the client aabout missed clients
150  * @return handle to the connection to the conversation service
151  */
152 struct GNUNET_CONVERSATION_Handle *GNUNET_CONVERSATION_connect (const struct
153                                                 GNUNET_CONFIGURATION_Handle
154                                                 *cfg, void *cls,
155                                                 GNUNET_CONVERSATION_CallHandler *
156                                                 call_handler,
157                                                 GNUNET_CONVERSATION_RejectHandler *
158                                                 reject_handler,
159                                                 GNUNET_CONVERSATION_NotificationHandler
160                                                 * notification_handler,
161                                                 GNUNET_CONVERSATION_MissedCallHandler
162                                                 * missed_call_handler);
163
164 /**
165  * Disconnect from the VoIP service
166  *
167  * @param handle handle to the VoIP connection
168  */
169 void GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle);
170
171 /**
172  * Establish a call
173  *
174  * @param handle handle to the VoIP connection
175  * @param callee the peer (PeerIdentity or GNS name) to call
176  * @param doGnsLookup 0 = no GNS lookup or 1  = GNS lookup
177  */
178 void
179 GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *handle, const char *callee,
180                   int doGnsLookup);
181
182 /**
183  * Terminate the active call
184  *
185  * @param handle handle to the VoIP connection
186  */
187 void GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *handle);
188
189 /**
190  * Accept an incoming call
191  *
192  * @param handle handle to the VoIP connection
193  */
194 void GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *handle);
195
196 /**
197  * Reject an incoming call
198  *
199  * @param handle handle to the VoIP connection
200  */
201 void GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle);
202
203 #if 0                           /* keep Emacsens' auto-indent happy */
204 {
205 #endif
206 #ifdef __cplusplus
207 }
208 #endif
209
210 #endif