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