diff options
Diffstat (limited to 'src/conversation/gnunet-conversation.c')
-rw-r--r-- | src/conversation/gnunet-conversation.c | 1325 |
1 files changed, 674 insertions, 651 deletions
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c index 4c5407cd7..20765bbf6 100644 --- a/src/conversation/gnunet-conversation.c +++ b/src/conversation/gnunet-conversation.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2013 GNUnet e.V. | 3 | Copyright (C) 2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file conversation/gnunet-conversation.c | 21 | * @file conversation/gnunet-conversation.c |
22 | * @brief conversation implementation | 22 | * @brief conversation implementation |
@@ -38,7 +38,7 @@ | |||
38 | */ | 38 | */ |
39 | #define MAX_MESSAGE_LENGTH 1024 | 39 | #define MAX_MESSAGE_LENGTH 1024 |
40 | 40 | ||
41 | #define XSTRINGIFY(x) STRINGIFY (x) | 41 | #define XSTRINGIFY(x) STRINGIFY(x) |
42 | 42 | ||
43 | #define STRINGIFY(x) (#x) | 43 | #define STRINGIFY(x) (#x) |
44 | 44 | ||
@@ -52,8 +52,7 @@ struct GNUNET_HELPER_Handle *stdin_hlp; | |||
52 | /** | 52 | /** |
53 | * Possible states of the phone. | 53 | * Possible states of the phone. |
54 | */ | 54 | */ |
55 | enum PhoneState | 55 | enum PhoneState { |
56 | { | ||
57 | /** | 56 | /** |
58 | * We're waiting for our own idenitty. | 57 | * We're waiting for our own idenitty. |
59 | */ | 58 | */ |
@@ -79,8 +78,7 @@ enum PhoneState | |||
79 | /** | 78 | /** |
80 | * States for current outgoing call. | 79 | * States for current outgoing call. |
81 | */ | 80 | */ |
82 | enum CallState | 81 | enum CallState { |
83 | { | ||
84 | /** | 82 | /** |
85 | * We are looking up some other participant. | 83 | * We are looking up some other participant. |
86 | */ | 84 | */ |
@@ -100,16 +98,13 @@ enum CallState | |||
100 | * The call is currently suspended (by us). | 98 | * The call is currently suspended (by us). |
101 | */ | 99 | */ |
102 | CS_SUSPENDED | 100 | CS_SUSPENDED |
103 | |||
104 | }; | 101 | }; |
105 | 102 | ||
106 | 103 | ||
107 | /** | 104 | /** |
108 | * List of incoming calls | 105 | * List of incoming calls |
109 | */ | 106 | */ |
110 | struct CallList | 107 | struct CallList { |
111 | { | ||
112 | |||
113 | /** | 108 | /** |
114 | * A DLL. | 109 | * A DLL. |
115 | */ | 110 | */ |
@@ -253,63 +248,64 @@ static int verbose; | |||
253 | * @param caller_id public key of the caller (in GNS) | 248 | * @param caller_id public key of the caller (in GNS) |
254 | */ | 249 | */ |
255 | static void | 250 | static void |
256 | phone_event_handler (void *cls, | 251 | phone_event_handler(void *cls, |
257 | enum GNUNET_CONVERSATION_PhoneEventCode code, | 252 | enum GNUNET_CONVERSATION_PhoneEventCode code, |
258 | struct GNUNET_CONVERSATION_Caller *caller, | 253 | struct GNUNET_CONVERSATION_Caller *caller, |
259 | const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) | 254 | const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) |
260 | { | 255 | { |
261 | struct CallList *cl; | 256 | struct CallList *cl; |
262 | 257 | ||
263 | (void) cls; | 258 | (void)cls; |
264 | switch (code) | 259 | switch (code) |
265 | { | ||
266 | case GNUNET_CONVERSATION_EC_PHONE_RING: | ||
267 | /* | ||
268 | * FIXME: we should be playing our ringtones from contrib/sounds now! | ||
269 | * | ||
270 | ring_my_bell(); | ||
271 | * | ||
272 | * see https://gstreamer.freedesktop.org/documentation/application-development/highlevel/playback-components.html on how to play a wav using the gst framework being used here | ||
273 | */ | ||
274 | fprintf ( | ||
275 | stdout, | ||
276 | _ ( | ||
277 | "Incoming call from `%s'. Please /accept %u or /cancel %u the call.\n"), | ||
278 | GNUNET_GNSRECORD_pkey_to_zkey (caller_id), | ||
279 | caller_num_gen, | ||
280 | caller_num_gen); | ||
281 | cl = GNUNET_new (struct CallList); | ||
282 | cl->caller = caller; | ||
283 | cl->caller_id = *caller_id; | ||
284 | cl->caller_num = caller_num_gen++; | ||
285 | GNUNET_CONTAINER_DLL_insert (cl_head, cl_tail, cl); | ||
286 | break; | ||
287 | case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: | ||
288 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
289 | if (caller == cl->caller) | ||
290 | break; | ||
291 | if ((NULL == cl) && (caller == cl_active->caller)) | ||
292 | cl = cl_active; | ||
293 | if (NULL == cl) | ||
294 | { | ||
295 | GNUNET_break (0); | ||
296 | return; | ||
297 | } | ||
298 | fprintf (stdout, | ||
299 | _ ("Call from `%s' terminated\n"), | ||
300 | GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id)); | ||
301 | if (cl == cl_active) | ||
302 | { | 260 | { |
303 | cl_active = NULL; | 261 | case GNUNET_CONVERSATION_EC_PHONE_RING: |
304 | phone_state = PS_LISTEN; | 262 | /* |
305 | } | 263 | * FIXME: we should be playing our ringtones from contrib/sounds now! |
306 | else | 264 | * |
307 | { | 265 | ring_my_bell(); |
308 | GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); | 266 | * |
267 | * see https://gstreamer.freedesktop.org/documentation/application-development/highlevel/playback-components.html on how to play a wav using the gst framework being used here | ||
268 | */ | ||
269 | fprintf( | ||
270 | stdout, | ||
271 | _( | ||
272 | "Incoming call from `%s'. Please /accept %u or /cancel %u the call.\n"), | ||
273 | GNUNET_GNSRECORD_pkey_to_zkey(caller_id), | ||
274 | caller_num_gen, | ||
275 | caller_num_gen); | ||
276 | cl = GNUNET_new(struct CallList); | ||
277 | cl->caller = caller; | ||
278 | cl->caller_id = *caller_id; | ||
279 | cl->caller_num = caller_num_gen++; | ||
280 | GNUNET_CONTAINER_DLL_insert(cl_head, cl_tail, cl); | ||
281 | break; | ||
282 | |||
283 | case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: | ||
284 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
285 | if (caller == cl->caller) | ||
286 | break; | ||
287 | if ((NULL == cl) && (caller == cl_active->caller)) | ||
288 | cl = cl_active; | ||
289 | if (NULL == cl) | ||
290 | { | ||
291 | GNUNET_break(0); | ||
292 | return; | ||
293 | } | ||
294 | fprintf(stdout, | ||
295 | _("Call from `%s' terminated\n"), | ||
296 | GNUNET_GNSRECORD_pkey_to_zkey(&cl->caller_id)); | ||
297 | if (cl == cl_active) | ||
298 | { | ||
299 | cl_active = NULL; | ||
300 | phone_state = PS_LISTEN; | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | GNUNET_CONTAINER_DLL_remove(cl_head, cl_tail, cl); | ||
305 | } | ||
306 | GNUNET_free(cl); | ||
307 | break; | ||
309 | } | 308 | } |
310 | GNUNET_free (cl); | ||
311 | break; | ||
312 | } | ||
313 | } | 309 | } |
314 | 310 | ||
315 | 311 | ||
@@ -320,23 +316,24 @@ phone_event_handler (void *cls, | |||
320 | * @param code type of the event issued by the caller | 316 | * @param code type of the event issued by the caller |
321 | */ | 317 | */ |
322 | static void | 318 | static void |
323 | caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) | 319 | caller_event_handler(void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) |
324 | { | 320 | { |
325 | struct CallList *cl = cls; | 321 | struct CallList *cl = cls; |
326 | 322 | ||
327 | switch (code) | 323 | switch (code) |
328 | { | 324 | { |
329 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: | 325 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: |
330 | fprintf (stdout, | 326 | fprintf(stdout, |
331 | _ ("Call from `%s' suspended by other user\n"), | 327 | _("Call from `%s' suspended by other user\n"), |
332 | GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id)); | 328 | GNUNET_GNSRECORD_pkey_to_zkey(&cl->caller_id)); |
333 | break; | 329 | break; |
334 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: | 330 | |
335 | fprintf (stdout, | 331 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: |
336 | _ ("Call from `%s' resumed by other user\n"), | 332 | fprintf(stdout, |
337 | GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id)); | 333 | _("Call from `%s' resumed by other user\n"), |
338 | break; | 334 | GNUNET_GNSRECORD_pkey_to_zkey(&cl->caller_id)); |
339 | } | 335 | break; |
336 | } | ||
340 | } | 337 | } |
341 | 338 | ||
342 | 339 | ||
@@ -344,42 +341,42 @@ caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) | |||
344 | * Start our phone. | 341 | * Start our phone. |
345 | */ | 342 | */ |
346 | static void | 343 | static void |
347 | start_phone () | 344 | start_phone() |
348 | { | 345 | { |
349 | struct GNUNET_GNSRECORD_Data rd; | 346 | struct GNUNET_GNSRECORD_Data rd; |
350 | 347 | ||
351 | if (NULL == my_caller_id) | 348 | if (NULL == my_caller_id) |
352 | { | 349 | { |
353 | fprintf (stderr, | 350 | fprintf(stderr, |
354 | _ ("Ego `%s' no longer available, phone is now down.\n"), | 351 | _("Ego `%s' no longer available, phone is now down.\n"), |
355 | ego_name); | 352 | ego_name); |
356 | phone_state = PS_LOOKUP_EGO; | 353 | phone_state = PS_LOOKUP_EGO; |
357 | return; | 354 | return; |
358 | } | 355 | } |
359 | GNUNET_assert (NULL == phone); | 356 | GNUNET_assert(NULL == phone); |
360 | phone = GNUNET_CONVERSATION_phone_create (cfg, | 357 | phone = GNUNET_CONVERSATION_phone_create(cfg, |
361 | my_caller_id, | 358 | my_caller_id, |
362 | &phone_event_handler, | 359 | &phone_event_handler, |
363 | NULL); | 360 | NULL); |
364 | /* FIXME: get record and print full GNS record info later here... */ | 361 | /* FIXME: get record and print full GNS record info later here... */ |
365 | if (NULL == phone) | 362 | if (NULL == phone) |
366 | { | 363 | { |
367 | fprintf (stderr, "%s", _ ("Failed to setup phone (internal error)\n")); | 364 | fprintf(stderr, "%s", _("Failed to setup phone (internal error)\n")); |
368 | phone_state = PS_ERROR; | 365 | phone_state = PS_ERROR; |
369 | } | 366 | } |
370 | else | 367 | else |
371 | { | 368 | { |
372 | GNUNET_CONVERSATION_phone_get_record (phone, &rd); | 369 | GNUNET_CONVERSATION_phone_get_record(phone, &rd); |
373 | GNUNET_free_non_null (address); | 370 | GNUNET_free_non_null(address); |
374 | address = | 371 | address = |
375 | GNUNET_GNSRECORD_value_to_string (rd.record_type, rd.data, rd.data_size); | 372 | GNUNET_GNSRECORD_value_to_string(rd.record_type, rd.data, rd.data_size); |
376 | fprintf ( | 373 | fprintf( |
377 | stdout, | 374 | stdout, |
378 | _ ( | 375 | _( |
379 | "Phone active at `%s'. Type `/help' for a list of available commands\n"), | 376 | "Phone active at `%s'. Type `/help' for a list of available commands\n"), |
380 | address); | 377 | address); |
381 | phone_state = PS_LISTEN; | 378 | phone_state = PS_LISTEN; |
382 | } | 379 | } |
383 | } | 380 | } |
384 | 381 | ||
385 | 382 | ||
@@ -390,56 +387,62 @@ start_phone () | |||
390 | * @param code type of the event on the call | 387 | * @param code type of the event on the call |
391 | */ | 388 | */ |
392 | static void | 389 | static void |
393 | call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code) | 390 | call_event_handler(void *cls, enum GNUNET_CONVERSATION_CallEventCode code) |
394 | { | 391 | { |
395 | (void) cls; | 392 | (void)cls; |
396 | 393 | ||
397 | switch (code) | 394 | switch (code) |
398 | { | 395 | { |
399 | case GNUNET_CONVERSATION_EC_CALL_RINGING: | 396 | case GNUNET_CONVERSATION_EC_CALL_RINGING: |
400 | GNUNET_break (CS_RESOLVING == call_state); | 397 | GNUNET_break(CS_RESOLVING == call_state); |
401 | fprintf (stdout, | 398 | fprintf(stdout, |
402 | _ ("Resolved address of `%s'. Now ringing other party.\n"), | 399 | _("Resolved address of `%s'. Now ringing other party.\n"), |
403 | peer_name); | 400 | peer_name); |
404 | call_state = CS_RINGING; | 401 | call_state = CS_RINGING; |
405 | break; | 402 | break; |
406 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: | 403 | |
407 | GNUNET_break (CS_RINGING == call_state); | 404 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: |
408 | fprintf (stdout, _ ("Connection established to `%s'\n"), peer_name); | 405 | GNUNET_break(CS_RINGING == call_state); |
409 | call_state = CS_CONNECTED; | 406 | fprintf(stdout, _("Connection established to `%s'\n"), peer_name); |
410 | break; | 407 | call_state = CS_CONNECTED; |
411 | case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: | 408 | break; |
412 | GNUNET_break (CS_RESOLVING == call_state); | 409 | |
413 | fprintf (stdout, _ ("Failed to resolve `%s'\n"), peer_name); | 410 | case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: |
414 | GNUNET_free (peer_name); | 411 | GNUNET_break(CS_RESOLVING == call_state); |
415 | peer_name = NULL; | 412 | fprintf(stdout, _("Failed to resolve `%s'\n"), peer_name); |
416 | call = NULL; | 413 | GNUNET_free(peer_name); |
417 | break; | 414 | peer_name = NULL; |
418 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: | 415 | call = NULL; |
419 | fprintf (stdout, _ ("Call to `%s' terminated\n"), peer_name); | 416 | break; |
420 | GNUNET_free (peer_name); | 417 | |
421 | peer_name = NULL; | 418 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: |
422 | call = NULL; | 419 | fprintf(stdout, _("Call to `%s' terminated\n"), peer_name); |
423 | break; | 420 | GNUNET_free(peer_name); |
424 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: | 421 | peer_name = NULL; |
425 | GNUNET_break (CS_CONNECTED == call_state); | 422 | call = NULL; |
426 | fprintf (stdout, | 423 | break; |
427 | _ ("Connection to `%s' suspended (by other user)\n"), | 424 | |
428 | peer_name); | 425 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: |
429 | break; | 426 | GNUNET_break(CS_CONNECTED == call_state); |
430 | case GNUNET_CONVERSATION_EC_CALL_RESUMED: | 427 | fprintf(stdout, |
431 | GNUNET_break (CS_CONNECTED == call_state); | 428 | _("Connection to `%s' suspended (by other user)\n"), |
432 | fprintf (stdout, | 429 | peer_name); |
433 | _ ("Connection to `%s' resumed (by other user)\n"), | 430 | break; |
434 | peer_name); | 431 | |
435 | break; | 432 | case GNUNET_CONVERSATION_EC_CALL_RESUMED: |
436 | case GNUNET_CONVERSATION_EC_CALL_ERROR: | 433 | GNUNET_break(CS_CONNECTED == call_state); |
437 | fprintf (stdout, _ ("Error with the call, restarting it\n")); | 434 | fprintf(stdout, |
438 | GNUNET_free (peer_name); | 435 | _("Connection to `%s' resumed (by other user)\n"), |
439 | peer_name = NULL; | 436 | peer_name); |
440 | call = NULL; | 437 | break; |
441 | break; | 438 | |
442 | } | 439 | case GNUNET_CONVERSATION_EC_CALL_ERROR: |
440 | fprintf(stdout, _("Error with the call, restarting it\n")); | ||
441 | GNUNET_free(peer_name); | ||
442 | peer_name = NULL; | ||
443 | call = NULL; | ||
444 | break; | ||
445 | } | ||
443 | } | 446 | } |
444 | 447 | ||
445 | 448 | ||
@@ -454,8 +457,7 @@ typedef void (*ActionFunction) (const char *arguments); | |||
454 | /** | 457 | /** |
455 | * Structure which defines a command | 458 | * Structure which defines a command |
456 | */ | 459 | */ |
457 | struct VoipCommand | 460 | struct VoipCommand { |
458 | { | ||
459 | /** | 461 | /** |
460 | * Command the user needs to enter. | 462 | * Command the user needs to enter. |
461 | */ | 463 | */ |
@@ -479,7 +481,7 @@ struct VoipCommand | |||
479 | * @param args arguments given to the command | 481 | * @param args arguments given to the command |
480 | */ | 482 | */ |
481 | static void | 483 | static void |
482 | do_help (const char *args); | 484 | do_help(const char *args); |
483 | 485 | ||
484 | 486 | ||
485 | /** | 487 | /** |
@@ -488,10 +490,10 @@ do_help (const char *args); | |||
488 | * @param args arguments given to the command | 490 | * @param args arguments given to the command |
489 | */ | 491 | */ |
490 | static void | 492 | static void |
491 | do_quit (const char *args) | 493 | do_quit(const char *args) |
492 | { | 494 | { |
493 | (void) args; | 495 | (void)args; |
494 | GNUNET_SCHEDULER_shutdown (); | 496 | GNUNET_SCHEDULER_shutdown(); |
495 | } | 497 | } |
496 | 498 | ||
497 | 499 | ||
@@ -501,9 +503,9 @@ do_quit (const char *args) | |||
501 | * @param msg arguments given to the command | 503 | * @param msg arguments given to the command |
502 | */ | 504 | */ |
503 | static void | 505 | static void |
504 | do_unknown (const char *msg) | 506 | do_unknown(const char *msg) |
505 | { | 507 | { |
506 | fprintf (stderr, _ ("Unknown command `%s'\n"), msg); | 508 | fprintf(stderr, _("Unknown command `%s'\n"), msg); |
507 | } | 509 | } |
508 | 510 | ||
509 | 511 | ||
@@ -513,54 +515,57 @@ do_unknown (const char *msg) | |||
513 | * @param arg arguments given to the command | 515 | * @param arg arguments given to the command |
514 | */ | 516 | */ |
515 | static void | 517 | static void |
516 | do_call (const char *arg) | 518 | do_call(const char *arg) |
517 | { | 519 | { |
518 | if (NULL == my_caller_id) | 520 | if (NULL == my_caller_id) |
519 | { | 521 | { |
520 | fprintf (stderr, _ ("Ego `%s' not available\n"), ego_name); | 522 | fprintf(stderr, _("Ego `%s' not available\n"), ego_name); |
521 | return; | 523 | return; |
522 | } | 524 | } |
523 | if (NULL != call) | 525 | if (NULL != call) |
524 | { | 526 | { |
525 | fprintf (stderr, | 527 | fprintf(stderr, |
526 | _ ("You are calling someone else already, hang up first!\n")); | 528 | _("You are calling someone else already, hang up first!\n")); |
527 | return; | 529 | return; |
528 | } | 530 | } |
529 | switch (phone_state) | 531 | switch (phone_state) |
530 | { | 532 | { |
531 | case PS_LOOKUP_EGO: | 533 | case PS_LOOKUP_EGO: |
532 | fprintf (stderr, _ ("Ego `%s' not available\n"), ego_name); | 534 | fprintf(stderr, _("Ego `%s' not available\n"), ego_name); |
533 | return; | 535 | return; |
534 | case PS_LISTEN: | 536 | |
535 | /* ok to call! */ | 537 | case PS_LISTEN: |
536 | break; | 538 | /* ok to call! */ |
537 | case PS_ACCEPTED: | 539 | break; |
538 | fprintf ( | 540 | |
539 | stderr, | 541 | case PS_ACCEPTED: |
540 | _ ( | 542 | fprintf( |
541 | "You are answering call from `%s', hang up or suspend that call first!\n"), | 543 | stderr, |
542 | GNUNET_GNSRECORD_pkey_to_zkey (&peer_key)); | 544 | _( |
543 | return; | 545 | "You are answering call from `%s', hang up or suspend that call first!\n"), |
544 | case PS_ERROR: | 546 | GNUNET_GNSRECORD_pkey_to_zkey(&peer_key)); |
545 | /* ok to call */ | 547 | return; |
546 | break; | 548 | |
547 | } | 549 | case PS_ERROR: |
550 | /* ok to call */ | ||
551 | break; | ||
552 | } | ||
548 | if (NULL == arg) | 553 | if (NULL == arg) |
549 | { | 554 | { |
550 | fprintf (stderr, _ ("Call recipient missing.\n")); | 555 | fprintf(stderr, _("Call recipient missing.\n")); |
551 | do_help ("/call"); | 556 | do_help("/call"); |
552 | return; | 557 | return; |
553 | } | 558 | } |
554 | peer_name = GNUNET_strdup (arg); | 559 | peer_name = GNUNET_strdup(arg); |
555 | call_state = CS_RESOLVING; | 560 | call_state = CS_RESOLVING; |
556 | GNUNET_assert (NULL == call); | 561 | GNUNET_assert(NULL == call); |
557 | call = GNUNET_CONVERSATION_call_start (cfg, | 562 | call = GNUNET_CONVERSATION_call_start(cfg, |
558 | my_caller_id, | 563 | my_caller_id, |
559 | arg, | 564 | arg, |
560 | speaker, | 565 | speaker, |
561 | mic, | 566 | mic, |
562 | &call_event_handler, | 567 | &call_event_handler, |
563 | NULL); | 568 | NULL); |
564 | } | 569 | } |
565 | 570 | ||
566 | 571 | ||
@@ -570,67 +575,70 @@ do_call (const char *arg) | |||
570 | * @param args arguments given to the command | 575 | * @param args arguments given to the command |
571 | */ | 576 | */ |
572 | static void | 577 | static void |
573 | do_accept (const char *args) | 578 | do_accept(const char *args) |
574 | { | 579 | { |
575 | struct CallList *cl; | 580 | struct CallList *cl; |
576 | char buf[32]; | 581 | char buf[32]; |
577 | 582 | ||
578 | if ((NULL != call) && (CS_SUSPENDED != call_state)) | 583 | if ((NULL != call) && (CS_SUSPENDED != call_state)) |
579 | { | 584 | { |
580 | fprintf (stderr, | 585 | fprintf(stderr, |
581 | _ ("You are calling someone else already, hang up first!\n")); | 586 | _("You are calling someone else already, hang up first!\n")); |
582 | return; | 587 | return; |
583 | } | 588 | } |
584 | switch (phone_state) | 589 | switch (phone_state) |
585 | { | 590 | { |
586 | case PS_LOOKUP_EGO: | 591 | case PS_LOOKUP_EGO: |
587 | GNUNET_break (0); | 592 | GNUNET_break(0); |
588 | break; | 593 | break; |
589 | case PS_LISTEN: | 594 | |
590 | /* this is the expected state */ | 595 | case PS_LISTEN: |
591 | break; | 596 | /* this is the expected state */ |
592 | case PS_ACCEPTED: | 597 | break; |
593 | fprintf ( | 598 | |
594 | stderr, | 599 | case PS_ACCEPTED: |
595 | _ ( | 600 | fprintf( |
596 | "You are answering call from `%s', hang up or suspend that call first!\n"), | 601 | stderr, |
597 | GNUNET_GNSRECORD_pkey_to_zkey (&peer_key)); | 602 | _( |
598 | return; | 603 | "You are answering call from `%s', hang up or suspend that call first!\n"), |
599 | case PS_ERROR: | 604 | GNUNET_GNSRECORD_pkey_to_zkey(&peer_key)); |
600 | GNUNET_break (0); | 605 | return; |
601 | break; | 606 | |
602 | } | 607 | case PS_ERROR: |
608 | GNUNET_break(0); | ||
609 | break; | ||
610 | } | ||
603 | cl = cl_head; | 611 | cl = cl_head; |
604 | if (NULL == cl) | 612 | if (NULL == cl) |
605 | { | 613 | { |
606 | fprintf (stderr, _ ("There is no incoming call to accept here!\n")); | 614 | fprintf(stderr, _("There is no incoming call to accept here!\n")); |
607 | return; | 615 | return; |
608 | } | 616 | } |
609 | if ((NULL != cl->next) || (NULL != args)) | 617 | if ((NULL != cl->next) || (NULL != args)) |
610 | { | ||
611 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
612 | { | 618 | { |
613 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); | 619 | for (cl = cl_head; NULL != cl; cl = cl->next) |
614 | if (0 == strcmp (buf, args)) | 620 | { |
615 | break; | 621 | GNUNET_snprintf(buf, sizeof(buf), "%u", cl->caller_num); |
622 | if (0 == strcmp(buf, args)) | ||
623 | break; | ||
624 | } | ||
616 | } | 625 | } |
617 | } | ||
618 | if (NULL == cl) | 626 | if (NULL == cl) |
619 | { | 627 | { |
620 | fprintf (stderr, | 628 | fprintf(stderr, |
621 | _ ("There is no incoming call `%s' to accept right now!\n"), | 629 | _("There is no incoming call `%s' to accept right now!\n"), |
622 | args); | 630 | args); |
623 | return; | 631 | return; |
624 | } | 632 | } |
625 | GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); | 633 | GNUNET_CONTAINER_DLL_remove(cl_head, cl_tail, cl); |
626 | cl_active = cl; | 634 | cl_active = cl; |
627 | peer_key = cl->caller_id; | 635 | peer_key = cl->caller_id; |
628 | phone_state = PS_ACCEPTED; | 636 | phone_state = PS_ACCEPTED; |
629 | GNUNET_CONVERSATION_caller_pick_up (cl->caller, | 637 | GNUNET_CONVERSATION_caller_pick_up(cl->caller, |
630 | &caller_event_handler, | 638 | &caller_event_handler, |
631 | cl, | 639 | cl, |
632 | speaker, | 640 | speaker, |
633 | mic); | 641 | mic); |
634 | } | 642 | } |
635 | 643 | ||
636 | 644 | ||
@@ -640,15 +648,15 @@ do_accept (const char *args) | |||
640 | * @param args arguments given to the command | 648 | * @param args arguments given to the command |
641 | */ | 649 | */ |
642 | static void | 650 | static void |
643 | do_address (const char *args) | 651 | do_address(const char *args) |
644 | { | 652 | { |
645 | (void) args; | 653 | (void)args; |
646 | if (NULL == address) | 654 | if (NULL == address) |
647 | { | 655 | { |
648 | fprintf (stdout, "%s", _ ("We currently do not have an address.\n")); | 656 | fprintf(stdout, "%s", _("We currently do not have an address.\n")); |
649 | return; | 657 | return; |
650 | } | 658 | } |
651 | fprintf (stdout, "%s\n", address); | 659 | fprintf(stdout, "%s\n", address); |
652 | } | 660 | } |
653 | 661 | ||
654 | 662 | ||
@@ -658,78 +666,84 @@ do_address (const char *args) | |||
658 | * @param args arguments given to the command | 666 | * @param args arguments given to the command |
659 | */ | 667 | */ |
660 | static void | 668 | static void |
661 | do_status (const char *args) | 669 | do_status(const char *args) |
662 | { | 670 | { |
663 | struct CallList *cl; | 671 | struct CallList *cl; |
664 | 672 | ||
665 | (void) args; | 673 | (void)args; |
666 | switch (phone_state) | 674 | switch (phone_state) |
667 | { | ||
668 | case PS_LOOKUP_EGO: | ||
669 | fprintf ( | ||
670 | stdout, | ||
671 | _ ( | ||
672 | "We are currently trying to locate the private key for the ego `%s'.\n"), | ||
673 | ego_name); | ||
674 | break; | ||
675 | case PS_LISTEN: | ||
676 | fprintf (stdout, | ||
677 | _ ( | ||
678 | "We are listening for incoming calls for ego `%s' on line `%s'.\n"), | ||
679 | ego_name, | ||
680 | line); | ||
681 | break; | ||
682 | case PS_ACCEPTED: | ||
683 | fprintf (stdout, | ||
684 | _ ("You are having a conversation with `%s'.\n"), | ||
685 | GNUNET_GNSRECORD_pkey_to_zkey (&peer_key)); | ||
686 | ; | ||
687 | break; | ||
688 | case PS_ERROR: | ||
689 | fprintf ( | ||
690 | stdout, | ||
691 | _ ( | ||
692 | "We had an internal error setting up our phone line. You can still make calls.\n")); | ||
693 | break; | ||
694 | } | ||
695 | if (NULL != call) | ||
696 | { | ||
697 | switch (call_state) | ||
698 | { | 675 | { |
699 | case CS_RESOLVING: | 676 | case PS_LOOKUP_EGO: |
700 | fprintf (stdout, | 677 | fprintf( |
701 | _ ("We are trying to find the network address to call `%s'.\n"), | 678 | stdout, |
702 | peer_name); | 679 | _( |
680 | "We are currently trying to locate the private key for the ego `%s'.\n"), | ||
681 | ego_name); | ||
703 | break; | 682 | break; |
704 | case CS_RINGING: | 683 | |
705 | fprintf (stdout, | 684 | case PS_LISTEN: |
706 | _ ("We are calling `%s', their phone should be ringing.\n"), | 685 | fprintf(stdout, |
707 | peer_name); | 686 | _( |
687 | "We are listening for incoming calls for ego `%s' on line `%s'.\n"), | ||
688 | ego_name, | ||
689 | line); | ||
708 | break; | 690 | break; |
709 | case CS_CONNECTED: | 691 | |
710 | fprintf (stdout, | 692 | case PS_ACCEPTED: |
711 | _ ("You are having a conversation with `%s'.\n"), | 693 | fprintf(stdout, |
712 | peer_name); | 694 | _("You are having a conversation with `%s'.\n"), |
695 | GNUNET_GNSRECORD_pkey_to_zkey(&peer_key)); | ||
696 | ; | ||
713 | break; | 697 | break; |
714 | case CS_SUSPENDED: | 698 | |
715 | /* ok to accept incoming call right now */ | 699 | case PS_ERROR: |
700 | fprintf( | ||
701 | stdout, | ||
702 | _( | ||
703 | "We had an internal error setting up our phone line. You can still make calls.\n")); | ||
716 | break; | 704 | break; |
717 | } | 705 | } |
718 | } | 706 | if (NULL != call) |
707 | { | ||
708 | switch (call_state) | ||
709 | { | ||
710 | case CS_RESOLVING: | ||
711 | fprintf(stdout, | ||
712 | _("We are trying to find the network address to call `%s'.\n"), | ||
713 | peer_name); | ||
714 | break; | ||
715 | |||
716 | case CS_RINGING: | ||
717 | fprintf(stdout, | ||
718 | _("We are calling `%s', their phone should be ringing.\n"), | ||
719 | peer_name); | ||
720 | break; | ||
721 | |||
722 | case CS_CONNECTED: | ||
723 | fprintf(stdout, | ||
724 | _("You are having a conversation with `%s'.\n"), | ||
725 | peer_name); | ||
726 | break; | ||
727 | |||
728 | case CS_SUSPENDED: | ||
729 | /* ok to accept incoming call right now */ | ||
730 | break; | ||
731 | } | ||
732 | } | ||
719 | if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) | 733 | if ((NULL != cl_head) && ((cl_head != cl_active) || (cl_head != cl_tail))) |
720 | { | ||
721 | fprintf (stdout, "%s", _ ("Calls waiting:\n")); | ||
722 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
723 | { | 734 | { |
724 | if (cl == cl_active) | 735 | fprintf(stdout, "%s", _("Calls waiting:\n")); |
725 | continue; | 736 | for (cl = cl_head; NULL != cl; cl = cl->next) |
726 | fprintf (stdout, | 737 | { |
727 | _ ("#%u: `%s'\n"), | 738 | if (cl == cl_active) |
728 | cl->caller_num, | 739 | continue; |
729 | GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id)); | 740 | fprintf(stdout, |
741 | _("#%u: `%s'\n"), | ||
742 | cl->caller_num, | ||
743 | GNUNET_GNSRECORD_pkey_to_zkey(&cl->caller_id)); | ||
744 | } | ||
745 | fprintf(stdout, "%s", "\n"); | ||
730 | } | 746 | } |
731 | fprintf (stdout, "%s", "\n"); | ||
732 | } | ||
733 | } | 747 | } |
734 | 748 | ||
735 | 749 | ||
@@ -739,41 +753,43 @@ do_status (const char *args) | |||
739 | * @param args arguments given to the command | 753 | * @param args arguments given to the command |
740 | */ | 754 | */ |
741 | static void | 755 | static void |
742 | do_suspend (const char *args) | 756 | do_suspend(const char *args) |
743 | { | 757 | { |
744 | (void) args; | 758 | (void)args; |
745 | if (NULL != call) | 759 | if (NULL != call) |
746 | { | ||
747 | switch (call_state) | ||
748 | { | 760 | { |
749 | case CS_RESOLVING: | 761 | switch (call_state) |
750 | case CS_RINGING: | 762 | { |
751 | case CS_SUSPENDED: | 763 | case CS_RESOLVING: |
752 | fprintf (stderr, | 764 | case CS_RINGING: |
753 | "%s", | 765 | case CS_SUSPENDED: |
754 | _ ("There is no call that could be suspended right now.\n")); | 766 | fprintf(stderr, |
755 | return; | 767 | "%s", |
756 | case CS_CONNECTED: | 768 | _("There is no call that could be suspended right now.\n")); |
757 | call_state = CS_SUSPENDED; | 769 | return; |
758 | GNUNET_CONVERSATION_call_suspend (call); | 770 | |
759 | return; | 771 | case CS_CONNECTED: |
772 | call_state = CS_SUSPENDED; | ||
773 | GNUNET_CONVERSATION_call_suspend(call); | ||
774 | return; | ||
775 | } | ||
760 | } | 776 | } |
761 | } | ||
762 | switch (phone_state) | 777 | switch (phone_state) |
763 | { | 778 | { |
764 | case PS_LOOKUP_EGO: | 779 | case PS_LOOKUP_EGO: |
765 | case PS_LISTEN: | 780 | case PS_LISTEN: |
766 | case PS_ERROR: | 781 | case PS_ERROR: |
767 | fprintf (stderr, | 782 | fprintf(stderr, |
768 | "%s", | 783 | "%s", |
769 | _ ("There is no call that could be suspended right now.\n")); | 784 | _("There is no call that could be suspended right now.\n")); |
770 | return; | 785 | return; |
771 | case PS_ACCEPTED: | 786 | |
772 | /* expected state, do rejection logic */ | 787 | case PS_ACCEPTED: |
773 | break; | 788 | /* expected state, do rejection logic */ |
774 | } | 789 | break; |
775 | GNUNET_assert (NULL != cl_active); | 790 | } |
776 | GNUNET_CONVERSATION_caller_suspend (cl_active->caller); | 791 | GNUNET_assert(NULL != cl_active); |
792 | GNUNET_CONVERSATION_caller_suspend(cl_active->caller); | ||
777 | cl_active = NULL; | 793 | cl_active = NULL; |
778 | phone_state = PS_LISTEN; | 794 | phone_state = PS_LISTEN; |
779 | } | 795 | } |
@@ -785,70 +801,73 @@ do_suspend (const char *args) | |||
785 | * @param args arguments given to the command | 801 | * @param args arguments given to the command |
786 | */ | 802 | */ |
787 | static void | 803 | static void |
788 | do_resume (const char *args) | 804 | do_resume(const char *args) |
789 | { | 805 | { |
790 | struct CallList *cl; | 806 | struct CallList *cl; |
791 | char buf[32]; | 807 | char buf[32]; |
792 | 808 | ||
793 | if (NULL != call) | 809 | if (NULL != call) |
794 | { | ||
795 | switch (call_state) | ||
796 | { | 810 | { |
797 | case CS_RESOLVING: | 811 | switch (call_state) |
798 | case CS_RINGING: | 812 | { |
799 | case CS_CONNECTED: | 813 | case CS_RESOLVING: |
800 | fprintf (stderr, | 814 | case CS_RINGING: |
801 | "%s", | 815 | case CS_CONNECTED: |
802 | _ ("There is no call that could be resumed right now.\n")); | 816 | fprintf(stderr, |
817 | "%s", | ||
818 | _("There is no call that could be resumed right now.\n")); | ||
819 | return; | ||
820 | |||
821 | case CS_SUSPENDED: | ||
822 | call_state = CS_CONNECTED; | ||
823 | GNUNET_CONVERSATION_call_resume(call, speaker, mic); | ||
824 | return; | ||
825 | } | ||
826 | } | ||
827 | switch (phone_state) | ||
828 | { | ||
829 | case PS_LOOKUP_EGO: | ||
830 | case PS_ERROR: | ||
831 | fprintf(stderr, | ||
832 | "%s", | ||
833 | _("There is no call that could be resumed right now.\n")); | ||
803 | return; | 834 | return; |
804 | case CS_SUSPENDED: | 835 | |
805 | call_state = CS_CONNECTED; | 836 | case PS_LISTEN: |
806 | GNUNET_CONVERSATION_call_resume (call, speaker, mic); | 837 | /* expected state, do resume logic */ |
838 | break; | ||
839 | |||
840 | case PS_ACCEPTED: | ||
841 | fprintf(stderr, | ||
842 | _("Already talking with `%s', cannot resume a call right now.\n"), | ||
843 | GNUNET_GNSRECORD_pkey_to_zkey(&peer_key)); | ||
807 | return; | 844 | return; |
808 | } | 845 | } |
809 | } | 846 | GNUNET_assert(NULL == cl_active); |
810 | switch (phone_state) | ||
811 | { | ||
812 | case PS_LOOKUP_EGO: | ||
813 | case PS_ERROR: | ||
814 | fprintf (stderr, | ||
815 | "%s", | ||
816 | _ ("There is no call that could be resumed right now.\n")); | ||
817 | return; | ||
818 | case PS_LISTEN: | ||
819 | /* expected state, do resume logic */ | ||
820 | break; | ||
821 | case PS_ACCEPTED: | ||
822 | fprintf (stderr, | ||
823 | _ ("Already talking with `%s', cannot resume a call right now.\n"), | ||
824 | GNUNET_GNSRECORD_pkey_to_zkey (&peer_key)); | ||
825 | return; | ||
826 | } | ||
827 | GNUNET_assert (NULL == cl_active); | ||
828 | cl = cl_head; | 847 | cl = cl_head; |
829 | if (NULL == cl) | 848 | if (NULL == cl) |
830 | { | 849 | { |
831 | fprintf (stderr, _ ("There is no incoming call to resume here!\n")); | 850 | fprintf(stderr, _("There is no incoming call to resume here!\n")); |
832 | return; | 851 | return; |
833 | } | 852 | } |
834 | if ((NULL != cl->next) || (NULL != args)) | 853 | if ((NULL != cl->next) || (NULL != args)) |
835 | { | ||
836 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
837 | { | 854 | { |
838 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); | 855 | for (cl = cl_head; NULL != cl; cl = cl->next) |
839 | if (0 == strcmp (buf, args)) | 856 | { |
840 | break; | 857 | GNUNET_snprintf(buf, sizeof(buf), "%u", cl->caller_num); |
858 | if (0 == strcmp(buf, args)) | ||
859 | break; | ||
860 | } | ||
841 | } | 861 | } |
842 | } | ||
843 | if (NULL == cl) | 862 | if (NULL == cl) |
844 | { | 863 | { |
845 | fprintf (stderr, | 864 | fprintf(stderr, |
846 | _ ("There is no incoming call `%s' to resume right now!\n"), | 865 | _("There is no incoming call `%s' to resume right now!\n"), |
847 | args); | 866 | args); |
848 | return; | 867 | return; |
849 | } | 868 | } |
850 | cl_active = cl; | 869 | cl_active = cl; |
851 | GNUNET_CONVERSATION_caller_resume (cl_active->caller, speaker, mic); | 870 | GNUNET_CONVERSATION_caller_resume(cl_active->caller, speaker, mic); |
852 | phone_state = PS_ACCEPTED; | 871 | phone_state = PS_ACCEPTED; |
853 | } | 872 | } |
854 | 873 | ||
@@ -859,61 +878,63 @@ do_resume (const char *args) | |||
859 | * @param args arguments given to the command | 878 | * @param args arguments given to the command |
860 | */ | 879 | */ |
861 | static void | 880 | static void |
862 | do_reject (const char *args) | 881 | do_reject(const char *args) |
863 | { | 882 | { |
864 | struct CallList *cl; | 883 | struct CallList *cl; |
865 | char buf[32]; | 884 | char buf[32]; |
866 | 885 | ||
867 | if (NULL != call) | 886 | if (NULL != call) |
868 | { | ||
869 | GNUNET_CONVERSATION_call_stop (call); | ||
870 | call = NULL; | ||
871 | return; | ||
872 | } | ||
873 | switch (phone_state) | ||
874 | { | ||
875 | case PS_LOOKUP_EGO: | ||
876 | case PS_ERROR: | ||
877 | fprintf (stderr, | ||
878 | "%s", | ||
879 | _ ("There is no call that could be cancelled right now.\n")); | ||
880 | return; | ||
881 | case PS_LISTEN: | ||
882 | /* look for active incoming calls to refuse */ | ||
883 | cl = cl_head; | ||
884 | if (NULL == cl) | ||
885 | { | 887 | { |
886 | fprintf (stderr, _ ("There is no incoming call to refuse here!\n")); | 888 | GNUNET_CONVERSATION_call_stop(call); |
889 | call = NULL; | ||
887 | return; | 890 | return; |
888 | } | 891 | } |
889 | if ((NULL != cl->next) || (NULL != args)) | 892 | switch (phone_state) |
890 | { | ||
891 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
892 | { | ||
893 | GNUNET_snprintf (buf, sizeof (buf), "%u", cl->caller_num); | ||
894 | if (0 == strcmp (buf, args)) | ||
895 | break; | ||
896 | } | ||
897 | } | ||
898 | if (NULL == cl) | ||
899 | { | 893 | { |
900 | fprintf (stderr, | 894 | case PS_LOOKUP_EGO: |
901 | _ ("There is no incoming call `%s' to refuse right now!\n"), | 895 | case PS_ERROR: |
902 | args); | 896 | fprintf(stderr, |
897 | "%s", | ||
898 | _("There is no call that could be cancelled right now.\n")); | ||
903 | return; | 899 | return; |
900 | |||
901 | case PS_LISTEN: | ||
902 | /* look for active incoming calls to refuse */ | ||
903 | cl = cl_head; | ||
904 | if (NULL == cl) | ||
905 | { | ||
906 | fprintf(stderr, _("There is no incoming call to refuse here!\n")); | ||
907 | return; | ||
908 | } | ||
909 | if ((NULL != cl->next) || (NULL != args)) | ||
910 | { | ||
911 | for (cl = cl_head; NULL != cl; cl = cl->next) | ||
912 | { | ||
913 | GNUNET_snprintf(buf, sizeof(buf), "%u", cl->caller_num); | ||
914 | if (0 == strcmp(buf, args)) | ||
915 | break; | ||
916 | } | ||
917 | } | ||
918 | if (NULL == cl) | ||
919 | { | ||
920 | fprintf(stderr, | ||
921 | _("There is no incoming call `%s' to refuse right now!\n"), | ||
922 | args); | ||
923 | return; | ||
924 | } | ||
925 | GNUNET_CONVERSATION_caller_hang_up(cl->caller); | ||
926 | GNUNET_CONTAINER_DLL_remove(cl_head, cl_tail, cl); | ||
927 | GNUNET_free(cl); | ||
928 | break; | ||
929 | |||
930 | case PS_ACCEPTED: | ||
931 | /* expected state, do rejection logic */ | ||
932 | GNUNET_assert(NULL != cl_active); | ||
933 | GNUNET_CONVERSATION_caller_hang_up(cl_active->caller); | ||
934 | cl_active = NULL; | ||
935 | phone_state = PS_LISTEN; | ||
936 | break; | ||
904 | } | 937 | } |
905 | GNUNET_CONVERSATION_caller_hang_up (cl->caller); | ||
906 | GNUNET_CONTAINER_DLL_remove (cl_head, cl_tail, cl); | ||
907 | GNUNET_free (cl); | ||
908 | break; | ||
909 | case PS_ACCEPTED: | ||
910 | /* expected state, do rejection logic */ | ||
911 | GNUNET_assert (NULL != cl_active); | ||
912 | GNUNET_CONVERSATION_caller_hang_up (cl_active->caller); | ||
913 | cl_active = NULL; | ||
914 | phone_state = PS_LISTEN; | ||
915 | break; | ||
916 | } | ||
917 | } | 938 | } |
918 | 939 | ||
919 | 940 | ||
@@ -921,35 +942,35 @@ do_reject (const char *args) | |||
921 | * List of supported commands. | 942 | * List of supported commands. |
922 | */ | 943 | */ |
923 | static struct VoipCommand commands[] = { | 944 | static struct VoipCommand commands[] = { |
924 | {"/address", | 945 | { "/address", |
925 | &do_address, | 946 | &do_address, |
926 | gettext_noop ( | 947 | gettext_noop( |
927 | "Use `/address' to find out which address this phone should have in GNS")}, | 948 | "Use `/address' to find out which address this phone should have in GNS") }, |
928 | {"/call", &do_call, gettext_noop ("Use `/call USER.gnu' to call USER")}, | 949 | { "/call", &do_call, gettext_noop("Use `/call USER.gnu' to call USER") }, |
929 | {"/accept", | 950 | { "/accept", |
930 | &do_accept, | 951 | &do_accept, |
931 | gettext_noop ("Use `/accept #NUM' to accept incoming call #NUM")}, | 952 | gettext_noop("Use `/accept #NUM' to accept incoming call #NUM") }, |
932 | {"/suspend", | 953 | { "/suspend", |
933 | &do_suspend, | 954 | &do_suspend, |
934 | gettext_noop ("Use `/suspend' to suspend the active call")}, | 955 | gettext_noop("Use `/suspend' to suspend the active call") }, |
935 | {"/resume", | 956 | { "/resume", |
936 | &do_resume, | 957 | &do_resume, |
937 | gettext_noop ( | 958 | gettext_noop( |
938 | "Use `/resume [#NUM]' to resume a call, #NUM is needed to resume incoming calls, no argument is needed to resume the current outgoing call.")}, | 959 | "Use `/resume [#NUM]' to resume a call, #NUM is needed to resume incoming calls, no argument is needed to resume the current outgoing call.") }, |
939 | {"/cancel", | 960 | { "/cancel", |
940 | &do_reject, | 961 | &do_reject, |
941 | gettext_noop ("Use `/cancel' to reject or terminate a call")}, | 962 | gettext_noop("Use `/cancel' to reject or terminate a call") }, |
942 | {"/status", | 963 | { "/status", |
943 | &do_status, | 964 | &do_status, |
944 | gettext_noop ("Use `/status' to print status information")}, | 965 | gettext_noop("Use `/status' to print status information") }, |
945 | {"/quit", | 966 | { "/quit", |
946 | &do_quit, | 967 | &do_quit, |
947 | gettext_noop ("Use `/quit' to terminate gnunet-conversation")}, | 968 | gettext_noop("Use `/quit' to terminate gnunet-conversation") }, |
948 | {"/help", | 969 | { "/help", |
949 | &do_help, | 970 | &do_help, |
950 | gettext_noop ("Use `/help command' to get help for a specific command")}, | 971 | gettext_noop("Use `/help command' to get help for a specific command") }, |
951 | {"", &do_unknown, NULL}, | 972 | { "", &do_unknown, NULL }, |
952 | {NULL, NULL, NULL}, | 973 | { NULL, NULL, NULL }, |
953 | }; | 974 | }; |
954 | 975 | ||
955 | 976 | ||
@@ -959,30 +980,30 @@ static struct VoipCommand commands[] = { | |||
959 | * @param args arguments given to the command | 980 | * @param args arguments given to the command |
960 | */ | 981 | */ |
961 | static void | 982 | static void |
962 | do_help (const char *args) | 983 | do_help(const char *args) |
963 | { | 984 | { |
964 | unsigned int i; | 985 | unsigned int i; |
965 | 986 | ||
966 | i = 0; | 987 | i = 0; |
967 | while ((NULL != args) && (0 != strlen (args)) && | 988 | while ((NULL != args) && (0 != strlen(args)) && |
968 | (commands[i].Action != &do_help)) | 989 | (commands[i].Action != &do_help)) |
969 | { | ||
970 | if (0 == strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1)) | ||
971 | { | 990 | { |
972 | fprintf (stdout, "%s\n", gettext (commands[i].helptext)); | 991 | if (0 == strncasecmp(&args[1], &commands[i].command[1], strlen(args) - 1)) |
973 | return; | 992 | { |
993 | fprintf(stdout, "%s\n", gettext(commands[i].helptext)); | ||
994 | return; | ||
995 | } | ||
996 | i++; | ||
974 | } | 997 | } |
975 | i++; | ||
976 | } | ||
977 | i = 0; | 998 | i = 0; |
978 | fprintf (stdout, "%s", "Available commands:\n"); | 999 | fprintf(stdout, "%s", "Available commands:\n"); |
979 | while (commands[i].Action != &do_help) | 1000 | while (commands[i].Action != &do_help) |
980 | { | 1001 | { |
981 | fprintf (stdout, "%s\n", gettext (commands[i].command)); | 1002 | fprintf(stdout, "%s\n", gettext(commands[i].command)); |
982 | i++; | 1003 | i++; |
983 | } | 1004 | } |
984 | fprintf (stdout, "%s", "\n"); | 1005 | fprintf(stdout, "%s", "\n"); |
985 | fprintf (stdout, "%s\n", gettext (commands[i].helptext)); | 1006 | fprintf(stdout, "%s\n", gettext(commands[i].helptext)); |
986 | } | 1007 | } |
987 | 1008 | ||
988 | 1009 | ||
@@ -992,43 +1013,43 @@ do_help (const char *args) | |||
992 | * @param cls NULL | 1013 | * @param cls NULL |
993 | */ | 1014 | */ |
994 | static void | 1015 | static void |
995 | do_stop_task (void *cls) | 1016 | do_stop_task(void *cls) |
996 | { | 1017 | { |
997 | (void) cls; | 1018 | (void)cls; |
998 | #ifdef WINDOWS | 1019 | #ifdef WINDOWS |
999 | if (NULL != stdin_hlp) | 1020 | if (NULL != stdin_hlp) |
1000 | { | 1021 | { |
1001 | GNUNET_HELPER_stop (stdin_hlp, GNUNET_NO); | 1022 | GNUNET_HELPER_stop(stdin_hlp, GNUNET_NO); |
1002 | stdin_hlp = NULL; | 1023 | stdin_hlp = NULL; |
1003 | } | 1024 | } |
1004 | #endif | 1025 | #endif |
1005 | if (NULL != call) | 1026 | if (NULL != call) |
1006 | { | 1027 | { |
1007 | GNUNET_CONVERSATION_call_stop (call); | 1028 | GNUNET_CONVERSATION_call_stop(call); |
1008 | call = NULL; | 1029 | call = NULL; |
1009 | } | 1030 | } |
1010 | if (NULL != phone) | 1031 | if (NULL != phone) |
1011 | { | 1032 | { |
1012 | GNUNET_CONVERSATION_phone_destroy (phone); | 1033 | GNUNET_CONVERSATION_phone_destroy(phone); |
1013 | phone = NULL; | 1034 | phone = NULL; |
1014 | } | 1035 | } |
1015 | if (NULL != handle_cmd_task) | 1036 | if (NULL != handle_cmd_task) |
1016 | { | 1037 | { |
1017 | GNUNET_SCHEDULER_cancel (handle_cmd_task); | 1038 | GNUNET_SCHEDULER_cancel(handle_cmd_task); |
1018 | handle_cmd_task = NULL; | 1039 | handle_cmd_task = NULL; |
1019 | } | 1040 | } |
1020 | if (NULL != id) | 1041 | if (NULL != id) |
1021 | { | 1042 | { |
1022 | GNUNET_IDENTITY_disconnect (id); | 1043 | GNUNET_IDENTITY_disconnect(id); |
1023 | id = NULL; | 1044 | id = NULL; |
1024 | } | 1045 | } |
1025 | GNUNET_SPEAKER_destroy (speaker); | 1046 | GNUNET_SPEAKER_destroy(speaker); |
1026 | speaker = NULL; | 1047 | speaker = NULL; |
1027 | GNUNET_MICROPHONE_destroy (mic); | 1048 | GNUNET_MICROPHONE_destroy(mic); |
1028 | mic = NULL; | 1049 | mic = NULL; |
1029 | GNUNET_free (ego_name); | 1050 | GNUNET_free(ego_name); |
1030 | ego_name = NULL; | 1051 | ego_name = NULL; |
1031 | GNUNET_free_non_null (peer_name); | 1052 | GNUNET_free_non_null(peer_name); |
1032 | peer_name = NULL; | 1053 | peer_name = NULL; |
1033 | phone_state = PS_ERROR; | 1054 | phone_state = PS_ERROR; |
1034 | } | 1055 | } |
@@ -1041,7 +1062,7 @@ do_stop_task (void *cls) | |||
1041 | * @param str_len number of bytes to process in @a message | 1062 | * @param str_len number of bytes to process in @a message |
1042 | */ | 1063 | */ |
1043 | static void | 1064 | static void |
1044 | handle_command_string (char *message, size_t str_len) | 1065 | handle_command_string(char *message, size_t str_len) |
1045 | { | 1066 | { |
1046 | size_t i; | 1067 | size_t i; |
1047 | const char *ptr; | 1068 | const char *ptr; |
@@ -1052,49 +1073,50 @@ handle_command_string (char *message, size_t str_len) | |||
1052 | message[str_len - 1] = '\0'; | 1073 | message[str_len - 1] = '\0'; |
1053 | if (message[str_len - 2] == '\r') | 1074 | if (message[str_len - 2] == '\r') |
1054 | message[str_len - 2] = '\0'; | 1075 | message[str_len - 2] = '\0'; |
1055 | if (0 == strlen (message)) | 1076 | if (0 == strlen(message)) |
1056 | return; | 1077 | return; |
1057 | i = 0; | 1078 | i = 0; |
1058 | while ( | 1079 | while ( |
1059 | (NULL != commands[i].command) && | 1080 | (NULL != commands[i].command) && |
1060 | (0 != | 1081 | (0 != |
1061 | strncasecmp (commands[i].command, message, strlen (commands[i].command)))) | 1082 | strncasecmp(commands[i].command, message, strlen(commands[i].command)))) |
1062 | i++; | 1083 | i++; |
1063 | ptr = &message[strlen (commands[i].command)]; | 1084 | ptr = &message[strlen(commands[i].command)]; |
1064 | while (isspace ((unsigned char) *ptr)) | 1085 | while (isspace((unsigned char)*ptr)) |
1065 | ptr++; | 1086 | ptr++; |
1066 | if ('\0' == *ptr) | 1087 | if ('\0' == *ptr) |
1067 | ptr = NULL; | 1088 | ptr = NULL; |
1068 | commands[i].Action (ptr); | 1089 | commands[i].Action(ptr); |
1069 | } | 1090 | } |
1070 | 1091 | ||
1071 | 1092 | ||
1072 | #ifdef WINDOWS | 1093 | #ifdef WINDOWS |
1073 | static int | 1094 | static int |
1074 | console_reader_chars (void *cls, | 1095 | console_reader_chars(void *cls, |
1075 | void *client, | 1096 | void *client, |
1076 | const struct GNUNET_MessageHeader *message) | 1097 | const struct GNUNET_MessageHeader *message) |
1077 | { | 1098 | { |
1078 | char *chars; | 1099 | char *chars; |
1079 | size_t str_size; | 1100 | size_t str_size; |
1080 | 1101 | ||
1081 | (void) cls; | 1102 | (void)cls; |
1082 | switch (ntohs (message->type)) | 1103 | switch (ntohs(message->type)) |
1083 | { | 1104 | { |
1084 | case GNUNET_MESSAGE_TYPE_W32_CONSOLE_HELPER_CHARS: | 1105 | case GNUNET_MESSAGE_TYPE_W32_CONSOLE_HELPER_CHARS: |
1085 | chars = (char *) &message[1]; | 1106 | chars = (char *)&message[1]; |
1086 | str_size = ntohs (message->size) - sizeof (struct GNUNET_MessageHeader); | 1107 | str_size = ntohs(message->size) - sizeof(struct GNUNET_MessageHeader); |
1087 | if (chars[str_size - 1] != '\0') | 1108 | if (chars[str_size - 1] != '\0') |
1088 | return GNUNET_SYSERR; | 1109 | return GNUNET_SYSERR; |
1089 | /* FIXME: is it ok that we pass part of a const struct to | 1110 | /* FIXME: is it ok that we pass part of a const struct to |
1090 | * this function that may mangle the contents? | 1111 | * this function that may mangle the contents? |
1091 | */ | 1112 | */ |
1092 | handle_command_string (chars, str_size - 1); | 1113 | handle_command_string(chars, str_size - 1); |
1093 | break; | 1114 | break; |
1094 | default: | 1115 | |
1095 | GNUNET_break (0); | 1116 | default: |
1096 | break; | 1117 | GNUNET_break(0); |
1097 | } | 1118 | break; |
1119 | } | ||
1098 | return GNUNET_OK; | 1120 | return GNUNET_OK; |
1099 | } | 1121 | } |
1100 | #endif | 1122 | #endif |
@@ -1106,21 +1128,21 @@ console_reader_chars (void *cls, | |||
1106 | * @param cls NULL | 1128 | * @param cls NULL |
1107 | */ | 1129 | */ |
1108 | static void | 1130 | static void |
1109 | handle_command (void *cls) | 1131 | handle_command(void *cls) |
1110 | { | 1132 | { |
1111 | char message[MAX_MESSAGE_LENGTH + 1]; | 1133 | char message[MAX_MESSAGE_LENGTH + 1]; |
1112 | 1134 | ||
1113 | (void) cls; | 1135 | (void)cls; |
1114 | handle_cmd_task = | 1136 | handle_cmd_task = |
1115 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 1137 | GNUNET_SCHEDULER_add_read_file(GNUNET_TIME_UNIT_FOREVER_REL, |
1116 | stdin_fh, | 1138 | stdin_fh, |
1117 | &handle_command, | 1139 | &handle_command, |
1118 | NULL); | 1140 | NULL); |
1119 | /* read message from command line and handle it */ | 1141 | /* read message from command line and handle it */ |
1120 | memset (message, 0, MAX_MESSAGE_LENGTH + 1); | 1142 | memset(message, 0, MAX_MESSAGE_LENGTH + 1); |
1121 | if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin)) | 1143 | if (NULL == fgets(message, MAX_MESSAGE_LENGTH, stdin)) |
1122 | return; | 1144 | return; |
1123 | handle_command_string (message, strlen (message)); | 1145 | handle_command_string(message, strlen(message)); |
1124 | } | 1146 | } |
1125 | 1147 | ||
1126 | 1148 | ||
@@ -1133,35 +1155,35 @@ handle_command (void *cls) | |||
1133 | * @param name name of the ego | 1155 | * @param name name of the ego |
1134 | */ | 1156 | */ |
1135 | static void | 1157 | static void |
1136 | identity_cb (void *cls, | 1158 | identity_cb(void *cls, |
1137 | struct GNUNET_IDENTITY_Ego *ego, | 1159 | struct GNUNET_IDENTITY_Ego *ego, |
1138 | void **ctx, | 1160 | void **ctx, |
1139 | const char *name) | 1161 | const char *name) |
1140 | { | 1162 | { |
1141 | (void) cls; | 1163 | (void)cls; |
1142 | (void) ctx; | 1164 | (void)ctx; |
1143 | if (NULL == name) | 1165 | if (NULL == name) |
1144 | return; | 1166 | return; |
1145 | if (ego == my_caller_id) | 1167 | if (ego == my_caller_id) |
1146 | { | 1168 | { |
1147 | if (verbose) | 1169 | if (verbose) |
1148 | fprintf (stdout, _ ("Name of our ego changed to `%s'\n"), name); | 1170 | fprintf(stdout, _("Name of our ego changed to `%s'\n"), name); |
1149 | GNUNET_free (ego_name); | 1171 | GNUNET_free(ego_name); |
1150 | ego_name = GNUNET_strdup (name); | 1172 | ego_name = GNUNET_strdup(name); |
1151 | return; | 1173 | return; |
1152 | } | 1174 | } |
1153 | if (0 != strcmp (name, ego_name)) | 1175 | if (0 != strcmp(name, ego_name)) |
1154 | return; | 1176 | return; |
1155 | if (NULL == ego) | 1177 | if (NULL == ego) |
1156 | { | 1178 | { |
1157 | if (verbose) | 1179 | if (verbose) |
1158 | fprintf (stdout, _ ("Our ego `%s' was deleted!\n"), ego_name); | 1180 | fprintf(stdout, _("Our ego `%s' was deleted!\n"), ego_name); |
1159 | my_caller_id = NULL; | 1181 | my_caller_id = NULL; |
1160 | return; | 1182 | return; |
1161 | } | 1183 | } |
1162 | my_caller_id = ego; | 1184 | my_caller_id = ego; |
1163 | GNUNET_CONFIGURATION_set_value_string (cfg, "CONVERSATION", "LINE", line); | 1185 | GNUNET_CONFIGURATION_set_value_string(cfg, "CONVERSATION", "LINE", line); |
1164 | start_phone (); | 1186 | start_phone(); |
1165 | } | 1187 | } |
1166 | 1188 | ||
1167 | 1189 | ||
@@ -1174,52 +1196,52 @@ identity_cb (void *cls, | |||
1174 | * @param c configuration | 1196 | * @param c configuration |
1175 | */ | 1197 | */ |
1176 | static void | 1198 | static void |
1177 | run (void *cls, | 1199 | run(void *cls, |
1178 | char *const *args, | 1200 | char *const *args, |
1179 | const char *cfgfile, | 1201 | const char *cfgfile, |
1180 | const struct GNUNET_CONFIGURATION_Handle *c) | 1202 | const struct GNUNET_CONFIGURATION_Handle *c) |
1181 | { | 1203 | { |
1182 | (void) cls; | 1204 | (void)cls; |
1183 | (void) args; | 1205 | (void)args; |
1184 | (void) cfgfile; | 1206 | (void)cfgfile; |
1185 | cfg = GNUNET_CONFIGURATION_dup (c); | 1207 | cfg = GNUNET_CONFIGURATION_dup(c); |
1186 | speaker = GNUNET_SPEAKER_create_from_hardware (cfg); | 1208 | speaker = GNUNET_SPEAKER_create_from_hardware(cfg); |
1187 | mic = GNUNET_MICROPHONE_create_from_hardware (cfg); | 1209 | mic = GNUNET_MICROPHONE_create_from_hardware(cfg); |
1188 | if (NULL == ego_name) | 1210 | if (NULL == ego_name) |
1189 | { | 1211 | { |
1190 | fprintf (stderr, "%s", _ ("You must specify the NAME of an ego to use\n")); | 1212 | fprintf(stderr, "%s", _("You must specify the NAME of an ego to use\n")); |
1191 | return; | 1213 | return; |
1192 | } | 1214 | } |
1193 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); | 1215 | id = GNUNET_IDENTITY_connect(cfg, &identity_cb, NULL); |
1194 | #ifdef WINDOWS | 1216 | #ifdef WINDOWS |
1195 | if (stdin_fh == NULL) | 1217 | if (stdin_fh == NULL) |
1196 | { | ||
1197 | static char cpid[64]; | ||
1198 | static char *args[] = {"gnunet-helper-w32-console.exe", | ||
1199 | "chars", | ||
1200 | XSTRINGIFY (MAX_MESSAGE_LENGTH), | ||
1201 | cpid, | ||
1202 | NULL}; | ||
1203 | snprintf (cpid, 64, "%d", GetCurrentProcessId ()); | ||
1204 | stdin_hlp = GNUNET_HELPER_start (GNUNET_NO, | ||
1205 | "gnunet-helper-w32-console", | ||
1206 | args, | ||
1207 | console_reader_chars, | ||
1208 | NULL, | ||
1209 | NULL); | ||
1210 | if (NULL == stdin_hlp) | ||
1211 | { | 1218 | { |
1212 | fprintf (stderr, "%s", _ ("Failed to start gnunet-helper-w32-console\n")); | 1219 | static char cpid[64]; |
1213 | return; | 1220 | static char *args[] = { "gnunet-helper-w32-console.exe", |
1221 | "chars", | ||
1222 | XSTRINGIFY(MAX_MESSAGE_LENGTH), | ||
1223 | cpid, | ||
1224 | NULL }; | ||
1225 | snprintf(cpid, 64, "%d", GetCurrentProcessId()); | ||
1226 | stdin_hlp = GNUNET_HELPER_start(GNUNET_NO, | ||
1227 | "gnunet-helper-w32-console", | ||
1228 | args, | ||
1229 | console_reader_chars, | ||
1230 | NULL, | ||
1231 | NULL); | ||
1232 | if (NULL == stdin_hlp) | ||
1233 | { | ||
1234 | fprintf(stderr, "%s", _("Failed to start gnunet-helper-w32-console\n")); | ||
1235 | return; | ||
1236 | } | ||
1214 | } | 1237 | } |
1215 | } | ||
1216 | else | 1238 | else |
1217 | #endif | 1239 | #endif |
1218 | handle_cmd_task = | 1240 | handle_cmd_task = |
1219 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, | 1241 | GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_UI, |
1220 | &handle_command, | 1242 | &handle_command, |
1221 | NULL); | 1243 | NULL); |
1222 | GNUNET_SCHEDULER_add_shutdown (&do_stop_task, NULL); | 1244 | GNUNET_SCHEDULER_add_shutdown(&do_stop_task, NULL); |
1223 | } | 1245 | } |
1224 | 1246 | ||
1225 | 1247 | ||
@@ -1231,56 +1253,57 @@ run (void *cls, | |||
1231 | * @return 0 ok, 1 on error | 1253 | * @return 0 ok, 1 on error |
1232 | */ | 1254 | */ |
1233 | int | 1255 | int |
1234 | main (int argc, char *const *argv) | 1256 | main(int argc, char *const *argv) |
1235 | { | 1257 | { |
1236 | struct GNUNET_GETOPT_CommandLineOption options[] = | 1258 | struct GNUNET_GETOPT_CommandLineOption options[] = |
1237 | {GNUNET_GETOPT_option_string ( | 1259 | { GNUNET_GETOPT_option_string( |
1238 | 'e', | 1260 | 'e', |
1239 | "ego", | 1261 | "ego", |
1240 | "NAME", | 1262 | "NAME", |
1241 | gettext_noop ("sets the NAME of the ego to use for the caller ID"), | 1263 | gettext_noop("sets the NAME of the ego to use for the caller ID"), |
1242 | &ego_name), | 1264 | &ego_name), |
1243 | GNUNET_GETOPT_option_string ('p', | 1265 | GNUNET_GETOPT_option_string('p', |
1244 | "phone", | 1266 | "phone", |
1245 | "LINE", | 1267 | "LINE", |
1246 | gettext_noop ( | 1268 | gettext_noop( |
1247 | "sets the LINE to use for the phone"), | 1269 | "sets the LINE to use for the phone"), |
1248 | &line), | 1270 | &line), |
1249 | GNUNET_GETOPT_OPTION_END}; | 1271 | GNUNET_GETOPT_OPTION_END }; |
1250 | int ret; | 1272 | int ret; |
1273 | |||
1251 | #ifndef WINDOWS | 1274 | #ifndef WINDOWS |
1252 | int flags; | 1275 | int flags; |
1253 | flags = fcntl (0, F_GETFL, 0); | 1276 | flags = fcntl(0, F_GETFL, 0); |
1254 | flags |= O_NONBLOCK; | 1277 | flags |= O_NONBLOCK; |
1255 | if (0 != fcntl (0, F_SETFL, flags)) | 1278 | if (0 != fcntl(0, F_SETFL, flags)) |
1256 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "fcntl"); | 1279 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "fcntl"); |
1257 | stdin_fh = GNUNET_DISK_get_handle_from_int_fd (0); | 1280 | stdin_fh = GNUNET_DISK_get_handle_from_int_fd(0); |
1258 | #else | 1281 | #else |
1259 | if (FILE_TYPE_CHAR == GetFileType ((HANDLE) _get_osfhandle (0))) | 1282 | if (FILE_TYPE_CHAR == GetFileType((HANDLE)_get_osfhandle(0))) |
1260 | { | 1283 | { |
1261 | stdin_fh = NULL; | 1284 | stdin_fh = NULL; |
1262 | } | 1285 | } |
1263 | else | 1286 | else |
1264 | stdin_fh = GNUNET_DISK_get_handle_from_int_fd (0); | 1287 | stdin_fh = GNUNET_DISK_get_handle_from_int_fd(0); |
1265 | #endif | 1288 | #endif |
1266 | 1289 | ||
1267 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 1290 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) |
1268 | return 2; | 1291 | return 2; |
1269 | ret = | 1292 | ret = |
1270 | GNUNET_PROGRAM_run (argc, | 1293 | GNUNET_PROGRAM_run(argc, |
1271 | argv, | 1294 | argv, |
1272 | "gnunet-conversation", | 1295 | "gnunet-conversation", |
1273 | gettext_noop ( | 1296 | gettext_noop( |
1274 | "Enables having a conversation with other GNUnet users."), | 1297 | "Enables having a conversation with other GNUnet users."), |
1275 | options, | 1298 | options, |
1276 | &run, | 1299 | &run, |
1277 | NULL); | 1300 | NULL); |
1278 | GNUNET_free ((void *) argv); | 1301 | GNUNET_free((void *)argv); |
1279 | if (NULL != cfg) | 1302 | if (NULL != cfg) |
1280 | { | 1303 | { |
1281 | GNUNET_CONFIGURATION_destroy (cfg); | 1304 | GNUNET_CONFIGURATION_destroy(cfg); |
1282 | cfg = NULL; | 1305 | cfg = NULL; |
1283 | } | 1306 | } |
1284 | return (GNUNET_OK == ret) ? 0 : 1; | 1307 | return (GNUNET_OK == ret) ? 0 : 1; |
1285 | } | 1308 | } |
1286 | 1309 | ||