diff options
-rw-r--r-- | src/conversation/gnunet-conversation.c | 297 | ||||
-rw-r--r-- | src/include/gnunet_conversation_service.h | 97 |
2 files changed, 227 insertions, 167 deletions
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c index f778c4c01..dffe9b4b6 100644 --- a/src/conversation/gnunet-conversation.c +++ b/src/conversation/gnunet-conversation.c | |||
@@ -24,9 +24,9 @@ | |||
24 | * @author Simon Dieterle | 24 | * @author Simon Dieterle |
25 | * @author Andreas Fuchs | 25 | * @author Andreas Fuchs |
26 | */ | 26 | */ |
27 | #include <gnunet/platform.h> | 27 | #include "platform.h" |
28 | #include <gnunet/gnunet_constants.h> | 28 | #include "gnunet_util_lib.h" |
29 | #include <gnunet/gnunet_util_lib.h> | 29 | #include "gnunet_constants.h" |
30 | #include "gnunet_conversation_service.h" | 30 | #include "gnunet_conversation_service.h" |
31 | #include <fcntl.h> | 31 | #include <fcntl.h> |
32 | 32 | ||
@@ -75,29 +75,37 @@ static int do_help (const char *args, const void *xtra); | |||
75 | * @param handle to the conversation session | 75 | * @param handle to the conversation session |
76 | * @param caller peer that calls you | 76 | * @param caller peer that calls you |
77 | */ | 77 | */ |
78 | void | 78 | static void |
79 | call_handler (void *cls, struct GNUNET_CONVERSATION_Handle *handle, | 79 | call_handler (void *cls, |
80 | struct GNUNET_CONVERSATION_Handle *handle, | ||
80 | const struct GNUNET_PeerIdentity *caller) | 81 | const struct GNUNET_PeerIdentity *caller) |
81 | { | 82 | { |
82 | FPRINTF (stdout, _("Incoming call from peer: %s\n"), | 83 | FPRINTF (stdout, |
84 | _("Incoming call from peer: %s\n"), | ||
83 | GNUNET_i2s_full (caller)); | 85 | GNUNET_i2s_full (caller)); |
84 | } | 86 | } |
85 | 87 | ||
88 | |||
86 | /** | 89 | /** |
87 | * Method called whenever a call is rejected | 90 | * Method called whenever a call is rejected |
88 | * | 91 | * |
89 | * @param cls closure | 92 | * @param cls closure |
90 | * @param handle to the conversation session | 93 | * @param handle to the conversation session |
94 | * @param reason given reason why the call was rejected | ||
91 | * @param peer peer that rejected your call | 95 | * @param peer peer that rejected your call |
92 | */ | 96 | */ |
93 | void | 97 | static void |
94 | reject_handler (void *cls, struct GNUNET_CONVERSATION_Handle *handle, int reason, | 98 | reject_handler (void *cls, |
99 | struct GNUNET_CONVERSATION_Handle *handle, | ||
100 | enum GNUNET_CONVERSATION_RejectReason reason, | ||
95 | const struct GNUNET_PeerIdentity *peer) | 101 | const struct GNUNET_PeerIdentity *peer) |
96 | { | 102 | { |
97 | FPRINTF (stdout, _("Peer %s rejected your call. Reason: %d\n"), | 103 | FPRINTF (stdout, |
104 | _("Peer %s rejected your call. Reason: %d\n"), | ||
98 | GNUNET_i2s_full (peer), reason); | 105 | GNUNET_i2s_full (peer), reason); |
99 | } | 106 | } |
100 | 107 | ||
108 | |||
101 | /** | 109 | /** |
102 | * Method called whenever a notification is there | 110 | * Method called whenever a notification is there |
103 | * | 111 | * |
@@ -106,48 +114,48 @@ reject_handler (void *cls, struct GNUNET_CONVERSATION_Handle *handle, int reason | |||
106 | * @param type the type of the notification | 114 | * @param type the type of the notification |
107 | * @param peer peer that the notification is about | 115 | * @param peer peer that the notification is about |
108 | */ | 116 | */ |
109 | void | 117 | static void |
110 | notification_handler (void *cls, struct GNUNET_CONVERSATION_Handle *handle, int type, | 118 | notification_handler (void *cls, |
119 | struct GNUNET_CONVERSATION_Handle *handle, | ||
120 | enum GNUNET_CONVERSATION_NotificationType type, | ||
111 | const struct GNUNET_PeerIdentity *peer) | 121 | const struct GNUNET_PeerIdentity *peer) |
112 | { | 122 | { |
113 | switch (type) | 123 | switch (type) |
114 | { | 124 | { |
115 | case GNUNET_CONVERSATION_NT_SERVICE_BLOCKED: | 125 | case GNUNET_CONVERSATION_NT_SERVICE_BLOCKED: |
116 | FPRINTF (stdout, _("The service is already in use. Try again later.")); | 126 | FPRINTF (stdout, |
117 | 127 | _("The service is already in use. Try again later.")); | |
118 | break; | 128 | break; |
119 | 129 | case GNUNET_CONVERSATION_NT_NO_PEER: | |
120 | case GNUNET_CONVERSATION_NT_NO_PEER: | 130 | FPRINTF (stdout, |
121 | FPRINTF (stdout, _("The Peer you were calling is no correct peer.\n")); | 131 | _("The Peer you were calling is no correct peer.\n")); |
122 | 132 | break; | |
123 | break; | 133 | case GNUNET_CONVERSATION_NT_NO_ANSWER: |
124 | 134 | FPRINTF (stdout, | |
125 | case GNUNET_CONVERSATION_NT_NO_ANSWER: | 135 | _("Peer %s did not answer your call.\n"), |
126 | FPRINTF (stdout, _("Peer %s did not answer your call.\n"), | 136 | GNUNET_i2s_full (peer)); |
127 | GNUNET_i2s_full (peer)); | 137 | break; |
128 | 138 | case GNUNET_CONVERSATION_NT_AVAILABLE_AGAIN: | |
129 | break; | 139 | FPRINTF (stdout, |
130 | 140 | _("Peer %s is now available.\n"), | |
131 | case GNUNET_CONVERSATION_NT_AVAILABLE_AGAIN: | 141 | GNUNET_i2s_full (peer)); |
132 | FPRINTF (stdout, _("Peer %s is now available.\n"), | 142 | break; |
133 | GNUNET_i2s_full (peer)); | 143 | case GNUNET_CONVERSATION_NT_CALL_ACCEPTED: |
134 | 144 | FPRINTF (stdout, | |
135 | break; | 145 | _("Peer %s has accepted your call.\n"), |
136 | 146 | GNUNET_i2s_full (peer)); | |
137 | case GNUNET_CONVERSATION_NT_CALL_ACCEPTED: | 147 | break; |
138 | FPRINTF (stdout, _("Peer %s has accepted your call.\n"), | 148 | case GNUNET_CONVERSATION_NT_CALL_TERMINATED: |
139 | GNUNET_i2s_full (peer)); | 149 | FPRINTF (stdout, |
140 | 150 | _("Peer %s has terminated the call.\n"), | |
141 | break; | 151 | GNUNET_i2s_full (peer)); |
142 | 152 | break; | |
143 | case GNUNET_CONVERSATION_NT_CALL_TERMINATED: | 153 | default: |
144 | FPRINTF (stdout, _("Peer %s has terminated the call.\n"), | 154 | GNUNET_break (0); |
145 | GNUNET_i2s_full (peer)); | 155 | } |
146 | break; | ||
147 | } | ||
148 | |||
149 | } | 156 | } |
150 | 157 | ||
158 | |||
151 | /** | 159 | /** |
152 | * Method called whenever a notification for missed calls is there | 160 | * Method called whenever a notification for missed calls is there |
153 | * | 161 | * |
@@ -155,94 +163,118 @@ notification_handler (void *cls, struct GNUNET_CONVERSATION_Handle *handle, int | |||
155 | * @param handle to the conversation session | 163 | * @param handle to the conversation session |
156 | * @param missed_calls a list of missed calls | 164 | * @param missed_calls a list of missed calls |
157 | */ | 165 | */ |
158 | void | 166 | static void |
159 | missed_call_handler (void *cls, struct GNUNET_CONVERSATION_Handle *handle, | 167 | missed_call_handler (void *cls, |
168 | struct GNUNET_CONVERSATION_Handle *handle, | ||
160 | struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls) | 169 | struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls) |
161 | { | 170 | { |
162 | FPRINTF (stdout, _("You have missed calls.\n")); | 171 | FPRINTF (stdout, _("You have missed calls.\n")); |
163 | } | 172 | } |
164 | 173 | ||
174 | |||
165 | /** | 175 | /** |
166 | * Terminating the client | 176 | * Terminating the client |
167 | */ | 177 | */ |
168 | static int | 178 | static int |
169 | do_quit (const char *args, const void *xtra) | 179 | do_quit (const char *args, |
180 | const void *xtra) | ||
170 | { | 181 | { |
171 | return GNUNET_SYSERR; | 182 | return GNUNET_SYSERR; |
172 | } | 183 | } |
173 | 184 | ||
185 | |||
174 | /** | 186 | /** |
175 | * | 187 | * |
176 | */ | 188 | */ |
177 | static int | 189 | static int |
178 | do_unknown (const char *msg, const void *xtra) | 190 | do_unknown (const char *msg, |
191 | const void *xtra) | ||
179 | { | 192 | { |
180 | FPRINTF (stderr, _("Unknown command `%s'\n"), msg); | 193 | FPRINTF (stderr, _("Unknown command `%s'\n"), msg); |
181 | return GNUNET_OK; | 194 | return GNUNET_OK; |
182 | } | 195 | } |
183 | 196 | ||
197 | |||
184 | /** | 198 | /** |
185 | * Initiating a new call | 199 | * Initiating a new call |
186 | */ | 200 | */ |
187 | static int | 201 | static int |
188 | do_call (const char *arg, const void *xtra) | 202 | do_call (const char *arg, |
203 | const void *xtra) | ||
189 | { | 204 | { |
190 | char *callee = GNUNET_strdup (arg); | 205 | char *callee = GNUNET_strdup (arg); |
191 | FPRINTF (stdout, _("Initiating call to: %s\n"), callee); | ||
192 | GNUNET_CONVERSATION_call (conversation, callee, GNUNET_YES); | ||
193 | 206 | ||
207 | FPRINTF (stdout, | ||
208 | _("Initiating call to: %s\n"), | ||
209 | callee); | ||
210 | GNUNET_CONVERSATION_call (conversation, | ||
211 | callee, | ||
212 | GNUNET_YES); | ||
194 | return GNUNET_OK; | 213 | return GNUNET_OK; |
195 | } | 214 | } |
196 | 215 | ||
216 | |||
197 | /** | 217 | /** |
198 | * Initiating a new call | 218 | * Initiating a new call |
199 | */ | 219 | */ |
200 | static int | 220 | static int |
201 | do_call_peer (const char *arg, const void *xtra) | 221 | do_call_peer (const char *arg, |
222 | const void *xtra) | ||
202 | { | 223 | { |
203 | char *callee = GNUNET_strdup (arg); | 224 | char *callee = GNUNET_strdup (arg); |
204 | FPRINTF (stdout, _("Initiating call to: %s\n"), callee); | ||
205 | GNUNET_CONVERSATION_call (conversation, callee, GNUNET_NO); | ||
206 | 225 | ||
226 | FPRINTF (stdout, | ||
227 | _("Initiating call to: %s\n"), | ||
228 | callee); | ||
229 | GNUNET_CONVERSATION_call (conversation, callee, GNUNET_NO); | ||
230 | |||
207 | return GNUNET_OK; | 231 | return GNUNET_OK; |
208 | } | 232 | } |
209 | 233 | ||
234 | |||
210 | /** | 235 | /** |
211 | * Accepting an incoming call | 236 | * Accepting an incoming call |
212 | */ | 237 | */ |
213 | static int | 238 | static int |
214 | do_accept (const char *args, const void *xtra) | 239 | do_accept (const char *args, |
240 | const void *xtra) | ||
215 | { | 241 | { |
216 | FPRINTF (stdout, _("Accepting the call\n")); | 242 | FPRINTF (stdout, |
243 | _("Accepting the call\n")); | ||
217 | GNUNET_CONVERSATION_accept (conversation); | 244 | GNUNET_CONVERSATION_accept (conversation); |
218 | 245 | ||
219 | return GNUNET_OK; | 246 | return GNUNET_OK; |
220 | } | 247 | } |
221 | 248 | ||
249 | |||
222 | /** | 250 | /** |
223 | * Rejecting a call | 251 | * Rejecting a call |
224 | */ | 252 | */ |
225 | static int | 253 | static int |
226 | do_reject (const char *args, const void *xtra) | 254 | do_reject (const char *args, |
255 | const void *xtra) | ||
227 | { | 256 | { |
228 | FPRINTF (stdout, _("Rejecting the call\n")); | 257 | FPRINTF (stdout, |
258 | _("Rejecting the call\n")); | ||
229 | GNUNET_CONVERSATION_reject (conversation); | 259 | GNUNET_CONVERSATION_reject (conversation); |
230 | |||
231 | return GNUNET_OK; | 260 | return GNUNET_OK; |
232 | } | 261 | } |
233 | 262 | ||
263 | |||
234 | /** | 264 | /** |
235 | * Terminating a call | 265 | * Terminating a call |
236 | */ | 266 | */ |
237 | static int | 267 | static int |
238 | do_hang_up (const char *args, const void *xtra) | 268 | do_hang_up (const char *args, |
269 | const void *xtra) | ||
239 | { | 270 | { |
240 | FPRINTF (stdout, _("Terminating the call\n")); | 271 | FPRINTF (stdout, |
241 | GNUNET_CONVERSATION_hangup (conversation); | 272 | _("Terminating the call\n")); |
242 | 273 | GNUNET_CONVERSATION_hangup (conversation); | |
243 | return GNUNET_OK; | 274 | return GNUNET_OK; |
244 | } | 275 | } |
245 | 276 | ||
277 | |||
246 | /** | 278 | /** |
247 | * List of supported commands. | 279 | * List of supported commands. |
248 | */ | 280 | */ |
@@ -264,61 +296,78 @@ static struct VoipCommand commands[] = { | |||
264 | {NULL, NULL, NULL}, | 296 | {NULL, NULL, NULL}, |
265 | }; | 297 | }; |
266 | 298 | ||
299 | |||
267 | /** | 300 | /** |
268 | * | 301 | * |
269 | */ | 302 | */ |
270 | static int | 303 | static int |
271 | do_help (const char *args, const void *xtra) | 304 | do_help (const char *args, |
305 | const void *xtra) | ||
272 | { | 306 | { |
273 | int i; | 307 | int i; |
274 | 308 | ||
275 | i = 0; | 309 | i = 0; |
276 | while ((NULL != args) && (0 != strlen (args)) && | 310 | while ((NULL != args) && (0 != strlen (args)) && |
277 | (commands[i].Action != &do_help)) | 311 | (commands[i].Action != &do_help)) |
312 | { | ||
313 | if (0 == | ||
314 | strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1)) | ||
278 | { | 315 | { |
279 | if (0 == | 316 | FPRINTF (stdout, |
280 | strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1)) | 317 | "%s\n", |
281 | { | 318 | gettext (commands[i].helptext)); |
282 | FPRINTF (stdout, "%s\n", gettext (commands[i].helptext)); | 319 | return GNUNET_OK; |
283 | return GNUNET_OK; | ||
284 | } | ||
285 | i++; | ||
286 | } | 320 | } |
321 | i++; | ||
322 | } | ||
287 | i = 0; | 323 | i = 0; |
288 | FPRINTF (stdout, "%s", "Available commands:"); | 324 | FPRINTF (stdout, |
325 | "%s", | ||
326 | "Available commands:"); | ||
289 | while (commands[i].Action != &do_help) | 327 | while (commands[i].Action != &do_help) |
290 | { | 328 | { |
291 | FPRINTF (stdout, " %s", gettext (commands[i].command)); | 329 | FPRINTF (stdout, |
292 | i++; | 330 | " %s", |
293 | } | 331 | gettext (commands[i].command)); |
294 | FPRINTF (stdout, "%s", "\n"); | 332 | i++; |
295 | FPRINTF (stdout, "%s\n", gettext (commands[i].helptext)); | 333 | } |
334 | FPRINTF (stdout, | ||
335 | "%s", | ||
336 | "\n"); | ||
337 | FPRINTF (stdout, | ||
338 | "%s\n", | ||
339 | gettext (commands[i].helptext)); | ||
296 | return GNUNET_OK; | 340 | return GNUNET_OK; |
297 | } | 341 | } |
298 | 342 | ||
343 | |||
299 | /** | 344 | /** |
300 | * | 345 | * |
301 | */ | 346 | */ |
302 | static void | 347 | static void |
303 | do_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 348 | do_stop_task (void *cls, |
349 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
304 | { | 350 | { |
305 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running shutdown task\n"); | 351 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
352 | "Running shutdown task\n"); | ||
306 | GNUNET_CONVERSATION_disconnect (conversation); | 353 | GNUNET_CONVERSATION_disconnect (conversation); |
307 | 354 | ||
308 | if (handle_cmd_task != GNUNET_SCHEDULER_NO_TASK) | 355 | if (handle_cmd_task != GNUNET_SCHEDULER_NO_TASK) |
309 | { | 356 | { |
310 | GNUNET_SCHEDULER_cancel (handle_cmd_task); | 357 | GNUNET_SCHEDULER_cancel (handle_cmd_task); |
311 | handle_cmd_task = GNUNET_SCHEDULER_NO_TASK; | 358 | handle_cmd_task = GNUNET_SCHEDULER_NO_TASK; |
312 | } | 359 | } |
313 | 360 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | |
314 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Running shutdown task finished\n"); | 361 | "Running shutdown task finished\n"); |
315 | } | 362 | } |
316 | 363 | ||
364 | |||
317 | /** | 365 | /** |
318 | * | 366 | * |
319 | */ | 367 | */ |
320 | void | 368 | static void |
321 | handle_command (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 369 | handle_command (void *cls, |
370 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
322 | { | 371 | { |
323 | char message[MAX_MESSAGE_LENGTH + 1]; | 372 | char message[MAX_MESSAGE_LENGTH + 1]; |
324 | int i; | 373 | int i; |
@@ -357,6 +406,7 @@ out: | |||
357 | GNUNET_SCHEDULER_shutdown (); | 406 | GNUNET_SCHEDULER_shutdown (); |
358 | } | 407 | } |
359 | 408 | ||
409 | |||
360 | /** | 410 | /** |
361 | * Main function that will be run by the scheduler. | 411 | * Main function that will be run by the scheduler. |
362 | * | 412 | * |
@@ -366,17 +416,24 @@ out: | |||
366 | * @param c configuration | 416 | * @param c configuration |
367 | */ | 417 | */ |
368 | static void | 418 | static void |
369 | run (void *cls, char *const *args, const char *cfgfile, | 419 | run (void *cls, |
420 | char *const *args, | ||
421 | const char *cfgfile, | ||
370 | const struct GNUNET_CONFIGURATION_Handle *c) | 422 | const struct GNUNET_CONFIGURATION_Handle *c) |
371 | { | 423 | { |
372 | if (NULL == | 424 | if (NULL == |
373 | (conversation = | 425 | (conversation = |
374 | GNUNET_CONVERSATION_connect (c, NULL, &call_handler, &reject_handler, | 426 | GNUNET_CONVERSATION_connect (c, NULL, |
375 | ¬ification_handler, &missed_call_handler))) | 427 | &call_handler, |
376 | { | 428 | &reject_handler, |
377 | FPRINTF (stderr, "%s", _("Could not access CONVERSATION service. Exiting.\n")); | 429 | ¬ification_handler, |
378 | return; | 430 | &missed_call_handler))) |
379 | } | 431 | { |
432 | FPRINTF (stderr, | ||
433 | "%s", | ||
434 | _("Could not access CONVERSATION service. Exiting.\n")); | ||
435 | return; | ||
436 | } | ||
380 | 437 | ||
381 | handle_cmd_task = | 438 | handle_cmd_task = |
382 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, | 439 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, |
@@ -385,7 +442,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
385 | NULL); | 442 | NULL); |
386 | } | 443 | } |
387 | 444 | ||
388 | /** * The main function to conversation. | 445 | |
446 | /** | ||
447 | * The main function to conversation. | ||
389 | * | 448 | * |
390 | * @param argc number of arguments from the command line | 449 | * @param argc number of arguments from the command line |
391 | * @param argv command line arguments | 450 | * @param argv command line arguments |
diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h index efe4c4d4c..ef02aaf11 100644 --- a/src/include/gnunet_conversation_service.h +++ b/src/include/gnunet_conversation_service.h | |||
@@ -40,6 +40,7 @@ extern "C" | |||
40 | */ | 40 | */ |
41 | #define GNUNET_CONVERSATION_VERSION 0x00000001 | 41 | #define GNUNET_CONVERSATION_VERSION 0x00000001 |
42 | 42 | ||
43 | |||
43 | enum GNUNET_CONVERSATION_RejectReason | 44 | enum GNUNET_CONVERSATION_RejectReason |
44 | { | 45 | { |
45 | GNUNET_CONVERSATION_REJECT_REASON_GENERIC = 0, | 46 | GNUNET_CONVERSATION_REJECT_REASON_GENERIC = 0, |
@@ -51,6 +52,7 @@ enum GNUNET_CONVERSATION_RejectReason | |||
51 | 52 | ||
52 | }; | 53 | }; |
53 | 54 | ||
55 | |||
54 | enum GNUNET_CONVERSATION_NotificationType | 56 | enum GNUNET_CONVERSATION_NotificationType |
55 | { | 57 | { |
56 | GNUNET_CONVERSATION_NT_SERVICE_BLOCKED = 0, | 58 | GNUNET_CONVERSATION_NT_SERVICE_BLOCKED = 0, |
@@ -62,17 +64,16 @@ enum GNUNET_CONVERSATION_NotificationType | |||
62 | }; | 64 | }; |
63 | 65 | ||
64 | 66 | ||
65 | |||
66 | /** | 67 | /** |
67 | * | 68 | * |
68 | */ | 69 | */ |
69 | struct GNUNET_CONVERSATION_MissedCall | 70 | struct GNUNET_CONVERSATION_MissedCall |
70 | { | 71 | { |
71 | struct GNUNET_PeerIdentity peer; | 72 | struct GNUNET_PeerIdentity peer; |
72 | struct GNUNET_TIME_Absolute time; | 73 | struct GNUNET_TIME_Absolute time; |
73 | |||
74 | }; | 74 | }; |
75 | 75 | ||
76 | |||
76 | struct GNUNET_CONVERSATION_MissedCallNotification | 77 | struct GNUNET_CONVERSATION_MissedCallNotification |
77 | { | 78 | { |
78 | int number; | 79 | int number; |
@@ -80,8 +81,10 @@ struct GNUNET_CONVERSATION_MissedCallNotification | |||
80 | }; | 81 | }; |
81 | 82 | ||
82 | struct GNUNET_CONVERSATION_CallInformation; | 83 | struct GNUNET_CONVERSATION_CallInformation; |
84 | |||
83 | struct GNUNET_CONVERSATION_Handle; | 85 | struct GNUNET_CONVERSATION_Handle; |
84 | 86 | ||
87 | |||
85 | /** | 88 | /** |
86 | * Method called whenever a call is incoming | 89 | * Method called whenever a call is incoming |
87 | * | 90 | * |
@@ -90,27 +93,24 @@ struct GNUNET_CONVERSATION_Handle; | |||
90 | * @param caller peer that calls you | 93 | * @param caller peer that calls you |
91 | */ | 94 | */ |
92 | typedef void (GNUNET_CONVERSATION_CallHandler) (void *cls, | 95 | typedef void (GNUNET_CONVERSATION_CallHandler) (void *cls, |
93 | struct | 96 | struct |
94 | GNUNET_CONVERSATION_Handle | 97 | GNUNET_CONVERSATION_Handle *handle, |
95 | * handle, | 98 | const struct GNUNET_PeerIdentity *caller); |
96 | const struct | 99 | |
97 | GNUNET_PeerIdentity * caller); | ||
98 | 100 | ||
99 | /** | 101 | /** |
100 | * Method called whenever a call is rejected | 102 | * Method called whenever a call is rejected |
101 | * | 103 | * |
102 | * @param cls closure | 104 | * @param cls closure |
103 | * @param handle to the conversation session | 105 | * @param handle to the conversation session |
106 | * @param reason reason given for rejecting the call | ||
104 | * @param peer peer that rejected your call | 107 | * @param peer peer that rejected your call |
105 | */ | 108 | */ |
106 | typedef void (GNUNET_CONVERSATION_RejectHandler) (void *cls, | 109 | typedef void (GNUNET_CONVERSATION_RejectHandler) (void *cls, |
107 | struct | 110 | struct GNUNET_CONVERSATION_Handle *handle, |
108 | GNUNET_CONVERSATION_Handle | 111 | enum GNUNET_CONVERSATION_RejectReason reason, |
109 | * handle, | 112 | const struct GNUNET_PeerIdentity *peer); |
110 | int | 113 | |
111 | reason, | ||
112 | const struct | ||
113 | GNUNET_PeerIdentity * peer); | ||
114 | 114 | ||
115 | /** | 115 | /** |
116 | * Method called whenever a notification is there | 116 | * Method called whenever a notification is there |
@@ -121,13 +121,10 @@ typedef void (GNUNET_CONVERSATION_RejectHandler) (void *cls, | |||
121 | * @param peer peer that the notification is about | 121 | * @param peer peer that the notification is about |
122 | */ | 122 | */ |
123 | typedef void (GNUNET_CONVERSATION_NotificationHandler) (void *cls, | 123 | typedef void (GNUNET_CONVERSATION_NotificationHandler) (void *cls, |
124 | struct | 124 | struct GNUNET_CONVERSATION_Handle *handle, |
125 | GNUNET_CONVERSATION_Handle | 125 | enum GNUNET_CONVERSATION_NotificationType type, |
126 | * handle, | 126 | const struct GNUNET_PeerIdentity *peer); |
127 | int | 127 | |
128 | type, | ||
129 | const struct | ||
130 | GNUNET_PeerIdentity * peer); | ||
131 | 128 | ||
132 | /** | 129 | /** |
133 | * Method called whenever a notification for missed calls is there | 130 | * Method called whenever a notification for missed calls is there |
@@ -137,12 +134,9 @@ typedef void (GNUNET_CONVERSATION_NotificationHandler) (void *cls, | |||
137 | * @param missed_calls a list of missed calls | 134 | * @param missed_calls a list of missed calls |
138 | */ | 135 | */ |
139 | typedef void (GNUNET_CONVERSATION_MissedCallHandler) (void *cls, | 136 | typedef void (GNUNET_CONVERSATION_MissedCallHandler) (void *cls, |
140 | struct | 137 | struct GNUNET_CONVERSATION_Handle *handle, |
141 | GNUNET_CONVERSATION_Handle | 138 | struct GNUNET_CONVERSATION_MissedCallNotification *missed_calls); |
142 | * handle, | 139 | |
143 | struct | ||
144 | GNUNET_CONVERSATION_MissedCallNotification | ||
145 | * missed_calls); | ||
146 | 140 | ||
147 | /** | 141 | /** |
148 | * Connect to the VoIP service | 142 | * Connect to the VoIP service |
@@ -152,27 +146,26 @@ typedef void (GNUNET_CONVERSATION_MissedCallHandler) (void *cls, | |||
152 | * @param call_handler the callback which is called when a call is incoming | 146 | * @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 | 147 | * @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 | 148 | * @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 | 149 | * @param missed_call_handler the callback which is called when the service notifies the client about missed clients |
156 | * @return handle to the connection to the conversation service | 150 | * @return handle to the connection to the conversation service |
157 | */ | 151 | */ |
158 | struct GNUNET_CONVERSATION_Handle *GNUNET_CONVERSATION_connect (const struct | 152 | struct GNUNET_CONVERSATION_Handle * |
159 | GNUNET_CONFIGURATION_Handle | 153 | GNUNET_CONVERSATION_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
160 | *cfg, void *cls, | 154 | void *cls, |
161 | GNUNET_CONVERSATION_CallHandler * | 155 | GNUNET_CONVERSATION_CallHandler call_handler, |
162 | call_handler, | 156 | GNUNET_CONVERSATION_RejectHandler reject_handler, |
163 | GNUNET_CONVERSATION_RejectHandler * | 157 | GNUNET_CONVERSATION_NotificationHandler notification_handler, |
164 | reject_handler, | 158 | GNUNET_CONVERSATION_MissedCallHandler missed_call_handler); |
165 | GNUNET_CONVERSATION_NotificationHandler | 159 | |
166 | * notification_handler, | ||
167 | GNUNET_CONVERSATION_MissedCallHandler | ||
168 | * missed_call_handler); | ||
169 | 160 | ||
170 | /** | 161 | /** |
171 | * Disconnect from the VoIP service | 162 | * Disconnect from the VoIP service |
172 | * | 163 | * |
173 | * @param handle handle to the VoIP connection | 164 | * @param handle handle to the VoIP connection |
174 | */ | 165 | */ |
175 | void GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle); | 166 | void |
167 | GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle); | ||
168 | |||
176 | 169 | ||
177 | /** | 170 | /** |
178 | * Establish a call | 171 | * Establish a call |
@@ -182,29 +175,37 @@ void GNUNET_CONVERSATION_disconnect (struct GNUNET_CONVERSATION_Handle *handle); | |||
182 | * @param doGnsLookup 0 = no GNS lookup or 1 = GNS lookup | 175 | * @param doGnsLookup 0 = no GNS lookup or 1 = GNS lookup |
183 | */ | 176 | */ |
184 | void | 177 | void |
185 | GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *handle, const char *callee, | 178 | GNUNET_CONVERSATION_call (struct GNUNET_CONVERSATION_Handle *handle, |
186 | int doGnsLookup); | 179 | const char *callee, |
180 | int doGnsLookup); | ||
181 | |||
187 | 182 | ||
188 | /** | 183 | /** |
189 | * Terminate the active call | 184 | * Terminate the active call |
190 | * | 185 | * |
191 | * @param handle handle to the VoIP connection | 186 | * @param handle handle to the VoIP connection |
192 | */ | 187 | */ |
193 | void GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *handle); | 188 | void |
189 | GNUNET_CONVERSATION_hangup (struct GNUNET_CONVERSATION_Handle *handle); | ||
190 | |||
194 | 191 | ||
195 | /** | 192 | /** |
196 | * Accept an incoming call | 193 | * Accept an incoming call |
197 | * | 194 | * |
198 | * @param handle handle to the VoIP connection | 195 | * @param handle handle to the VoIP connection |
199 | */ | 196 | */ |
200 | void GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *handle); | 197 | void |
198 | GNUNET_CONVERSATION_accept (struct GNUNET_CONVERSATION_Handle *handle); | ||
199 | |||
201 | 200 | ||
202 | /** | 201 | /** |
203 | * Reject an incoming call | 202 | * Reject an incoming call |
204 | * | 203 | * |
205 | * @param handle handle to the VoIP connection | 204 | * @param handle handle to the VoIP connection |
206 | */ | 205 | */ |
207 | void GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle); | 206 | void |
207 | GNUNET_CONVERSATION_reject (struct GNUNET_CONVERSATION_Handle *handle); | ||
208 | |||
208 | 209 | ||
209 | #if 0 /* keep Emacsens' auto-indent happy */ | 210 | #if 0 /* keep Emacsens' auto-indent happy */ |
210 | { | 211 | { |