-towards canonical header structure 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_GENERIC = 0,
46   REJECT_REASON_NOT_AVAILABLE,
47   REJECT_REASON_NO_CLIENT,
48   REJECT_REASON_ACTIVE_CALL,
49   REJECT_REASON_NOT_WANTED,
50   REJECT_REASON_NO_ANSWER
51
52 };
53
54 enum GNUNET_CONVERSATION_NotificationType
55 {
56   NotificationType_SERVICE_BLOCKED = 0,
57   NotificationType_NO_PEER,
58   NotificationType_NO_ANSWER,
59   NotificationType_AVAILABLE_AGAIN,
60   NotificationType_CALL_ACCEPTED,
61   NotificationType_CALL_TERMINATED
62 };
63
64
65
66 /**
67 *
68 */
69 struct GNUNET_CONVERSATION_MissedCall
70 {
71   struct GNUNET_PeerIdentity peer;
72   struct GNUNET_TIME_Absolute time;
73
74 };
75
76 struct GNUNET_CONVERSATION_MissedCallNotification
77 {
78   int number;
79   struct GNUNET_CONVERSATION_MissedCall *calls;
80 };
81
82 struct GNUNET_CONVERSATION_CallInformation;
83 struct GNUNET_CONVERSATION_Handle;
84
85 /**
86  * Method called whenever a call is incoming
87  *
88  * @param cls closure
89  * @param handle to the conversation session
90  * @param caller peer that calls you
91  */
92 typedef void (GNUNET_CONVERSATION_CallHandler) (void *cls,
93                                         struct
94                                         GNUNET_CONVERSATION_Handle
95                                         * handle,
96                                         const struct
97                                         GNUNET_PeerIdentity * caller);
98
99 /**
100  * Method called whenever a call is rejected
101  *
102  * @param cls closure
103  * @param handle to the conversation session
104  * @param peer peer that rejected your call
105  */
106 typedef void (GNUNET_CONVERSATION_RejectHandler) (void *cls,
107                                           struct
108                                           GNUNET_CONVERSATION_Handle
109                                           * handle,
110                                           int
111                                           reason,
112                                           const struct
113                                           GNUNET_PeerIdentity * peer);
114
115 /**
116  * Method called whenever a notification is there
117  *
118  * @param cls closure
119  * @param handle to the conversation session
120  * @param type the type of the notification
121  * @param peer peer that the notification is about
122  */
123 typedef void (GNUNET_CONVERSATION_NotificationHandler) (void *cls,
124                                                 struct
125                                                 GNUNET_CONVERSATION_Handle
126                                                 * handle,
127                                                 int
128                                                 type,
129                                                 const struct
130                                                 GNUNET_PeerIdentity * peer);
131
132 /**
133  * Method called whenever a notification for missed calls is there
134  *
135  * @param cls closure
136  * @param handle to the conversation session
137  * @param missed_calls a list of missed calls
138  */
139 typedef void (GNUNET_CONVERSATION_MissedCallHandler) (void *cls,
140                                               struct
141                                               GNUNET_CONVERSATION_Handle
142                                               * handle,
143                                               struct
144                                               GNUNET_CONVERSATION_MissedCallNotification
145                                               * missed_calls);
146
147 /**
148  * Connect to the VoIP service
149  *
150  * @param cfg configuration
151  * @param cls NULL
152  * @param call_handler the callback which is called when a call is incoming
153  * @param reject_handler the callback which is called when a call is rejected
154  * @param notification_handler the callback which is called when there is a notification
155  * @param missed_call_handler the callback which is called when the service notifies the client aabout missed clients
156  * @return handle to the connection to the conversation service
157  */
158 struct GNUNET_CONVERSATION_Handle *GNUNET_CONVERSATION_connect (const struct
159                                                 GNUNET_CONFIGURATION_Handle
160                                                 *cfg, void *cls,
161                                                 GNUNET_CONVERSATION_CallHandler *
162                                                 call_handler,
163                                                 GNUNET_CONVERSATION_RejectHandler *
164                                                 reject_handler,
165                                                 GNUNET_CONVERSATION_NotificationHandler
166                                                 * notification_handler,
167                                                 GNUNET_CONVERSATION_MissedCallHandler
168                                                 * missed_call_handler);
169
170 /**
171  * Disconnect from the VoIP service
172  *
173  * @param handle handle to the VoIP connection
174  */
175 void GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle);
176
177 /**
178  * Establish a call
179  *
180  * @param handle handle to the VoIP connection
181  * @param callee the peer (PeerIdentity or GNS name) to call
182  * @param doGnsLookup 0 = no GNS lookup or 1  = GNS lookup
183  */
184 void
185 GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *handle, const char *callee,
186                   int doGnsLookup);
187
188 /**
189  * Terminate the active call
190  *
191  * @param handle handle to the VoIP connection
192  */
193 void GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *handle);
194
195 /**
196  * Accept an incoming call
197  *
198  * @param handle handle to the VoIP connection
199  */
200 void GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *handle);
201
202 /**
203  * Reject an incoming call
204  *
205  * @param handle handle to the VoIP connection
206  */
207 void GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle);
208
209 #if 0                           /* keep Emacsens' auto-indent happy */
210 {
211 #endif
212 #ifdef __cplusplus
213 }
214 #endif
215
216 #endif