diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-04 23:11:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-04 23:11:32 +0000 |
commit | b8332eb85822d0b4b944e3a7fa24ecf303a73398 (patch) | |
tree | e211176c29f9fbe362f98ef158c9f99dfd8f165f /src/conversation | |
parent | d7ae29278f7249516ff8a0ebe5479103ba7eca9d (diff) | |
download | gnunet-b8332eb85822d0b4b944e3a7fa24ecf303a73398.tar.gz gnunet-b8332eb85822d0b4b944e3a7fa24ecf303a73398.zip |
-misc minor fixes
Diffstat (limited to 'src/conversation')
-rw-r--r-- | src/conversation/conversation_api2.c | 8 | ||||
-rw-r--r-- | src/conversation/gnunet-conversation-new.c | 67 |
2 files changed, 58 insertions, 17 deletions
diff --git a/src/conversation/conversation_api2.c b/src/conversation/conversation_api2.c index dfba3366c..6ce198e64 100644 --- a/src/conversation/conversation_api2.c +++ b/src/conversation/conversation_api2.c | |||
@@ -1088,18 +1088,20 @@ GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call, | |||
1088 | { | 1088 | { |
1089 | if (NULL != reason) | 1089 | if (NULL != reason) |
1090 | { | 1090 | { |
1091 | // FIXME: transmit reason to service... | 1091 | // FIXME: transmit reason to service... (not implemented!) |
1092 | GNUNET_break (0); | 1092 | GNUNET_break (0); |
1093 | // return; | 1093 | // return; |
1094 | } | 1094 | } |
1095 | if (NULL != call->speaker) | 1095 | if (NULL != call->speaker) |
1096 | { | 1096 | { |
1097 | call->speaker->disable_speaker (call->speaker->cls); | 1097 | if (CS_ACTIVE == call->state) |
1098 | call->speaker->disable_speaker (call->speaker->cls); | ||
1098 | call->speaker = NULL; | 1099 | call->speaker = NULL; |
1099 | } | 1100 | } |
1100 | if (NULL != call->mic) | 1101 | if (NULL != call->mic) |
1101 | { | 1102 | { |
1102 | call->mic->disable_microphone (call->mic->cls); | 1103 | if (CS_ACTIVE == call->state) |
1104 | call->mic->disable_microphone (call->mic->cls); | ||
1103 | call->mic =NULL; | 1105 | call->mic =NULL; |
1104 | } | 1106 | } |
1105 | if (NULL != call->mq) | 1107 | if (NULL != call->mq) |
diff --git a/src/conversation/gnunet-conversation-new.c b/src/conversation/gnunet-conversation-new.c index d8b25ef78..57315ac0d 100644 --- a/src/conversation/gnunet-conversation-new.c +++ b/src/conversation/gnunet-conversation-new.c | |||
@@ -64,7 +64,7 @@ static struct GNUNET_MICROPHONE_Handle *mic; | |||
64 | /** | 64 | /** |
65 | * Our configuration. | 65 | * Our configuration. |
66 | */ | 66 | */ |
67 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 67 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Our ego. | 70 | * Our ego. |
@@ -81,6 +81,11 @@ static struct GNUNET_IDENTITY_Handle *id; | |||
81 | */ | 81 | */ |
82 | static char *ego_name; | 82 | static char *ego_name; |
83 | 83 | ||
84 | /** | ||
85 | * File handle for stdin. | ||
86 | */ | ||
87 | static struct GNUNET_DISK_FileHandle *stdin_fh; | ||
88 | |||
84 | 89 | ||
85 | /** | 90 | /** |
86 | * Function called with an event emitted by a phone. | 91 | * Function called with an event emitted by a phone. |
@@ -271,8 +276,11 @@ do_call (const char *arg) | |||
271 | return; | 276 | return; |
272 | } | 277 | } |
273 | /* FIXME: also check that we do NOT have a running conversation or ring */ | 278 | /* FIXME: also check that we do NOT have a running conversation or ring */ |
274 | GNUNET_CONVERSATION_phone_destroy (phone); | 279 | if (NULL != phone) |
275 | phone = NULL; | 280 | { |
281 | GNUNET_CONVERSATION_phone_destroy (phone); | ||
282 | phone = NULL; | ||
283 | } | ||
276 | call = GNUNET_CONVERSATION_call_start (cfg, | 284 | call = GNUNET_CONVERSATION_call_start (cfg, |
277 | caller_id, | 285 | caller_id, |
278 | arg, | 286 | arg, |
@@ -309,8 +317,19 @@ static void | |||
309 | do_reject (const char *args) | 317 | do_reject (const char *args) |
310 | { | 318 | { |
311 | /* FIXME: also check that we do have a running conversation or ring */ | 319 | /* FIXME: also check that we do have a running conversation or ring */ |
312 | GNUNET_CONVERSATION_phone_hang_up (phone, | 320 | if (NULL == call) |
313 | args); | 321 | { |
322 | GNUNET_CONVERSATION_phone_hang_up (phone, | ||
323 | args); | ||
324 | } | ||
325 | else | ||
326 | { | ||
327 | GNUNET_CONVERSATION_call_stop (call, args); | ||
328 | call = NULL; | ||
329 | phone = GNUNET_CONVERSATION_phone_create (cfg, | ||
330 | caller_id, | ||
331 | &phone_event_handler, NULL); | ||
332 | } | ||
314 | } | 333 | } |
315 | 334 | ||
316 | 335 | ||
@@ -318,7 +337,7 @@ do_reject (const char *args) | |||
318 | * List of supported commands. | 337 | * List of supported commands. |
319 | */ | 338 | */ |
320 | static struct VoipCommand commands[] = { | 339 | static struct VoipCommand commands[] = { |
321 | {"/call ", &do_call, | 340 | {"/call", &do_call, |
322 | gettext_noop ("Use `/call USER.gnu'")}, | 341 | gettext_noop ("Use `/call USER.gnu'")}, |
323 | {"/accept", &do_accept, | 342 | {"/accept", &do_accept, |
324 | gettext_noop ("Use `/accept MESSAGE' to accept an incoming call")}, | 343 | gettext_noop ("Use `/accept MESSAGE' to accept an incoming call")}, |
@@ -362,11 +381,11 @@ do_help (const char *args) | |||
362 | i = 0; | 381 | i = 0; |
363 | FPRINTF (stdout, | 382 | FPRINTF (stdout, |
364 | "%s", | 383 | "%s", |
365 | "Available commands:"); | 384 | "Available commands:\n"); |
366 | while (commands[i].Action != &do_help) | 385 | while (commands[i].Action != &do_help) |
367 | { | 386 | { |
368 | FPRINTF (stdout, | 387 | FPRINTF (stdout, |
369 | "%s", | 388 | "%s\n", |
370 | gettext (commands[i].command)); | 389 | gettext (commands[i].command)); |
371 | i++; | 390 | i++; |
372 | } | 391 | } |
@@ -415,6 +434,8 @@ do_stop_task (void *cls, | |||
415 | mic = NULL; | 434 | mic = NULL; |
416 | GNUNET_free (ego_name); | 435 | GNUNET_free (ego_name); |
417 | ego_name = NULL; | 436 | ego_name = NULL; |
437 | GNUNET_CONFIGURATION_destroy (cfg); | ||
438 | cfg = NULL; | ||
418 | } | 439 | } |
419 | 440 | ||
420 | 441 | ||
@@ -429,12 +450,13 @@ handle_command (void *cls, | |||
429 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 450 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
430 | { | 451 | { |
431 | char message[MAX_MESSAGE_LENGTH + 1]; | 452 | char message[MAX_MESSAGE_LENGTH + 1]; |
453 | const char *ptr; | ||
432 | int i; | 454 | int i; |
433 | 455 | ||
434 | handle_cmd_task = | 456 | handle_cmd_task = |
435 | GNUNET_SCHEDULER_add_delayed_with_priority (GNUNET_TIME_UNIT_FOREVER_REL, | 457 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, |
436 | GNUNET_SCHEDULER_PRIORITY_UI, | 458 | stdin_fh, |
437 | &handle_command, NULL); | 459 | &handle_command, NULL); |
438 | /* read message from command line and handle it */ | 460 | /* read message from command line and handle it */ |
439 | memset (message, 0, MAX_MESSAGE_LENGTH + 1); | 461 | memset (message, 0, MAX_MESSAGE_LENGTH + 1); |
440 | if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin)) | 462 | if (NULL == fgets (message, MAX_MESSAGE_LENGTH, stdin)) |
@@ -450,7 +472,10 @@ handle_command (void *cls, | |||
450 | (0 != strncasecmp (commands[i].command, message, | 472 | (0 != strncasecmp (commands[i].command, message, |
451 | strlen (commands[i].command)))) | 473 | strlen (commands[i].command)))) |
452 | i++; | 474 | i++; |
453 | commands[i].Action (&message[strlen (commands[i].command)]); | 475 | ptr = &message[strlen (commands[i].command)]; |
476 | while (isspace ((int) *ptr)) | ||
477 | ptr++; | ||
478 | commands[i].Action (ptr); | ||
454 | } | 479 | } |
455 | 480 | ||
456 | 481 | ||
@@ -488,9 +513,23 @@ identity_cb (void *cls, | |||
488 | return; | 513 | return; |
489 | } | 514 | } |
490 | caller_id = ego; | 515 | caller_id = ego; |
516 | GNUNET_CONFIGURATION_set_value_number (cfg, | ||
517 | "CONVERSATION", | ||
518 | "LINE", | ||
519 | line); | ||
491 | phone = GNUNET_CONVERSATION_phone_create (cfg, | 520 | phone = GNUNET_CONVERSATION_phone_create (cfg, |
492 | caller_id, | 521 | caller_id, |
493 | &phone_event_handler, NULL); | 522 | &phone_event_handler, NULL); |
523 | /* FIXME: get record and print full GNS record info later here... */ | ||
524 | if (NULL == phone) | ||
525 | { | ||
526 | fprintf (stderr, | ||
527 | _("Failed to setup phone (internal error)\n")); | ||
528 | } | ||
529 | else | ||
530 | fprintf (stdout, | ||
531 | _("Phone active on line %u\n"), | ||
532 | (unsigned int) line); | ||
494 | } | 533 | } |
495 | 534 | ||
496 | 535 | ||
@@ -508,7 +547,7 @@ run (void *cls, | |||
508 | const char *cfgfile, | 547 | const char *cfgfile, |
509 | const struct GNUNET_CONFIGURATION_Handle *c) | 548 | const struct GNUNET_CONFIGURATION_Handle *c) |
510 | { | 549 | { |
511 | cfg = c; | 550 | cfg = GNUNET_CONFIGURATION_dup (c); |
512 | speaker = GNUNET_SPEAKER_create_from_hardware (cfg); | 551 | speaker = GNUNET_SPEAKER_create_from_hardware (cfg); |
513 | mic = GNUNET_MICROPHONE_create_from_hardware (cfg); | 552 | mic = GNUNET_MICROPHONE_create_from_hardware (cfg); |
514 | if (NULL == ego_name) | 553 | if (NULL == ego_name) |
@@ -554,7 +593,7 @@ main (int argc, char *const *argv) | |||
554 | flags = fcntl (0, F_GETFL, 0); | 593 | flags = fcntl (0, F_GETFL, 0); |
555 | flags |= O_NONBLOCK; | 594 | flags |= O_NONBLOCK; |
556 | fcntl (0, F_SETFL, flags); | 595 | fcntl (0, F_SETFL, flags); |
557 | 596 | stdin_fh = GNUNET_DISK_get_handle_from_int_fd (0); | |
558 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 597 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
559 | return 2; | 598 | return 2; |
560 | ret = GNUNET_PROGRAM_run (argc, argv, | 599 | ret = GNUNET_PROGRAM_run (argc, argv, |