diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-06 08:43:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-06 08:43:16 +0000 |
commit | aece72e29b041e2dfbc5b49d2fd0d49f8ab2124e (patch) | |
tree | cce216b507c99bf6723e15da5158e68a57a55f41 /src/conversation | |
parent | 310f312557954662ffc32f74bbacdb63d76ede3d (diff) | |
download | gnunet-aece72e29b041e2dfbc5b49d2fd0d49f8ab2124e.tar.gz gnunet-aece72e29b041e2dfbc5b49d2fd0d49f8ab2124e.zip |
addressing #3431
Diffstat (limited to 'src/conversation')
-rw-r--r-- | src/conversation/conversation_api.c | 91 | ||||
-rw-r--r-- | src/conversation/gnunet-conversation.c | 86 | ||||
-rw-r--r-- | src/conversation/test_conversation_api.c | 6 | ||||
-rw-r--r-- | src/conversation/test_conversation_api_reject.c | 9 | ||||
-rw-r--r-- | src/conversation/test_conversation_api_twocalls.c | 4 |
5 files changed, 69 insertions, 127 deletions
diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c index 4e9901c81..bc6d0f460 100644 --- a/src/conversation/conversation_api.c +++ b/src/conversation/conversation_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2013 Christian Grothoff (and other contributing authors) | 3 | (C) 2013, 2014 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -38,11 +38,6 @@ | |||
38 | enum CallerState | 38 | enum CallerState |
39 | { | 39 | { |
40 | /** | 40 | /** |
41 | * We still need to reverse lookup the caller ID. | ||
42 | */ | ||
43 | CS_RESOLVE, | ||
44 | |||
45 | /** | ||
46 | * The phone is ringing (user knows about incoming call). | 41 | * The phone is ringing (user knows about incoming call). |
47 | */ | 42 | */ |
48 | CS_RINGING, | 43 | CS_RINGING, |
@@ -112,21 +107,11 @@ struct GNUNET_CONVERSATION_Caller | |||
112 | struct GNUNET_MICROPHONE_Handle *mic; | 107 | struct GNUNET_MICROPHONE_Handle *mic; |
113 | 108 | ||
114 | /** | 109 | /** |
115 | * Active NAMESTORE lookup (or NULL). | ||
116 | */ | ||
117 | struct GNUNET_NAMESTORE_QueueEntry *qe; | ||
118 | |||
119 | /** | ||
120 | * Identity of the person calling us. | 110 | * Identity of the person calling us. |
121 | */ | 111 | */ |
122 | struct GNUNET_CRYPTO_EcdsaPublicKey caller_id; | 112 | struct GNUNET_CRYPTO_EcdsaPublicKey caller_id; |
123 | 113 | ||
124 | /** | 114 | /** |
125 | * Caller ID of the person calling us as a string. | ||
126 | */ | ||
127 | char *caller_id_str; | ||
128 | |||
129 | /** | ||
130 | * Internal handle to identify the caller with the service. | 115 | * Internal handle to identify the caller with the service. |
131 | */ | 116 | */ |
132 | uint32_t cid; | 117 | uint32_t cid; |
@@ -238,40 +223,6 @@ reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone); | |||
238 | 223 | ||
239 | 224 | ||
240 | /** | 225 | /** |
241 | * We have resolved the caller ID using our name service. | ||
242 | * | ||
243 | * @param cls the `struct GNUNET_CONVERSATION_Caller` | ||
244 | * @param zone our zone used for resolution | ||
245 | * @param label name of the caller | ||
246 | * @param rd_count number of records we have in @a rd | ||
247 | * @param rd records we have for the caller's label | ||
248 | */ | ||
249 | static void | ||
250 | handle_caller_name (void *cls, | ||
251 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | ||
252 | const char *label, | ||
253 | unsigned int rd_count, | ||
254 | const struct GNUNET_GNSRECORD_Data *rd) | ||
255 | { | ||
256 | struct GNUNET_CONVERSATION_Caller *caller = cls; | ||
257 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; | ||
258 | char *name; | ||
259 | |||
260 | caller->qe = NULL; | ||
261 | if (NULL == label) | ||
262 | name = GNUNET_strdup (GNUNET_GNSRECORD_pkey_to_zkey (&caller->caller_id)); | ||
263 | else | ||
264 | GNUNET_asprintf (&name, "%s.gnu", label); | ||
265 | caller->caller_id_str = name; | ||
266 | caller->state = CS_RINGING; | ||
267 | phone->event_handler (phone->event_handler_cls, | ||
268 | GNUNET_CONVERSATION_EC_PHONE_RING, | ||
269 | caller, | ||
270 | name); | ||
271 | } | ||
272 | |||
273 | |||
274 | /** | ||
275 | * Process recorded audio data. | 226 | * Process recorded audio data. |
276 | * | 227 | * |
277 | * @param cls closure with the `struct GNUNET_CONVERSATION_Caller` | 228 | * @param cls closure with the `struct GNUNET_CONVERSATION_Caller` |
@@ -323,14 +274,13 @@ handle_phone_ring (void *cls, | |||
323 | GNUNET_CONTAINER_DLL_insert (phone->caller_head, | 274 | GNUNET_CONTAINER_DLL_insert (phone->caller_head, |
324 | phone->caller_tail, | 275 | phone->caller_tail, |
325 | caller); | 276 | caller); |
326 | caller->state = CS_RESOLVE; | ||
327 | caller->caller_id = ring->caller_id; | 277 | caller->caller_id = ring->caller_id; |
328 | caller->cid = ring->cid; | 278 | caller->cid = ring->cid; |
329 | caller->qe = GNUNET_NAMESTORE_zone_to_name (phone->ns, | 279 | caller->state = CS_RINGING; |
330 | &phone->my_zone, | 280 | phone->event_handler (phone->event_handler_cls, |
331 | &ring->caller_id, | 281 | GNUNET_CONVERSATION_EC_PHONE_RING, |
332 | &handle_caller_name, | 282 | caller, |
333 | caller); | 283 | &caller->caller_id); |
334 | break; | 284 | break; |
335 | } | 285 | } |
336 | } | 286 | } |
@@ -364,19 +314,14 @@ handle_phone_hangup (void *cls, | |||
364 | 314 | ||
365 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
366 | "Received HANG_UP message, terminating call with `%s'\n", | 316 | "Received HANG_UP message, terminating call with `%s'\n", |
367 | caller->caller_id_str); | 317 | GNUNET_GNSRECORD_pkey_to_zkey (&caller->caller_id)); |
368 | switch (caller->state) | 318 | switch (caller->state) |
369 | { | 319 | { |
370 | case CS_RESOLVE: | ||
371 | /* application doesn't even know about call yet */ | ||
372 | GNUNET_NAMESTORE_cancel (caller->qe); | ||
373 | caller->qe = NULL; | ||
374 | break; | ||
375 | case CS_RINGING: | 320 | case CS_RINGING: |
376 | phone->event_handler (phone->event_handler_cls, | 321 | phone->event_handler (phone->event_handler_cls, |
377 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | 322 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, |
378 | caller, | 323 | caller, |
379 | caller->caller_id_str); | 324 | &caller->caller_id); |
380 | break; | 325 | break; |
381 | case CS_ACTIVE: | 326 | case CS_ACTIVE: |
382 | caller->speaker->disable_speaker (caller->speaker->cls); | 327 | caller->speaker->disable_speaker (caller->speaker->cls); |
@@ -384,7 +329,7 @@ handle_phone_hangup (void *cls, | |||
384 | phone->event_handler (phone->event_handler_cls, | 329 | phone->event_handler (phone->event_handler_cls, |
385 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | 330 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, |
386 | caller, | 331 | caller, |
387 | caller->caller_id_str); | 332 | &caller->caller_id); |
388 | break; | 333 | break; |
389 | case CS_CALLEE_SUSPENDED: | 334 | case CS_CALLEE_SUSPENDED: |
390 | case CS_CALLER_SUSPENDED: | 335 | case CS_CALLER_SUSPENDED: |
@@ -392,7 +337,7 @@ handle_phone_hangup (void *cls, | |||
392 | phone->event_handler (phone->event_handler_cls, | 337 | phone->event_handler (phone->event_handler_cls, |
393 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | 338 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, |
394 | caller, | 339 | caller, |
395 | caller->caller_id_str); | 340 | &caller->caller_id); |
396 | break; | 341 | break; |
397 | } | 342 | } |
398 | GNUNET_CONTAINER_DLL_remove (phone->caller_head, | 343 | GNUNET_CONTAINER_DLL_remove (phone->caller_head, |
@@ -424,9 +369,6 @@ handle_phone_suspend (void *cls, | |||
424 | return; | 369 | return; |
425 | switch (caller->state) | 370 | switch (caller->state) |
426 | { | 371 | { |
427 | case CS_RESOLVE: | ||
428 | GNUNET_break_op (0); | ||
429 | break; | ||
430 | case CS_RINGING: | 372 | case CS_RINGING: |
431 | GNUNET_break_op (0); | 373 | GNUNET_break_op (0); |
432 | break; | 374 | break; |
@@ -472,9 +414,6 @@ handle_phone_resume (void *cls, | |||
472 | return; | 414 | return; |
473 | switch (caller->state) | 415 | switch (caller->state) |
474 | { | 416 | { |
475 | case CS_RESOLVE: | ||
476 | GNUNET_break_op (0); | ||
477 | break; | ||
478 | case CS_RINGING: | 417 | case CS_RINGING: |
479 | GNUNET_break_op (0); | 418 | GNUNET_break_op (0); |
480 | break; | 419 | break; |
@@ -522,9 +461,6 @@ handle_phone_audio_message (void *cls, | |||
522 | return; | 461 | return; |
523 | switch (caller->state) | 462 | switch (caller->state) |
524 | { | 463 | { |
525 | case CS_RESOLVE: | ||
526 | GNUNET_break_op (0); | ||
527 | break; | ||
528 | case CS_RINGING: | 464 | case CS_RINGING: |
529 | GNUNET_break_op (0); | 465 | GNUNET_break_op (0); |
530 | break; | 466 | break; |
@@ -581,7 +517,7 @@ clean_up_callers (struct GNUNET_CONVERSATION_Phone *phone) | |||
581 | phone->event_handler (phone->event_handler_cls, | 517 | phone->event_handler (phone->event_handler_cls, |
582 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | 518 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, |
583 | caller, | 519 | caller, |
584 | caller->caller_id_str); | 520 | &caller->caller_id); |
585 | GNUNET_CONVERSATION_caller_hang_up (caller); | 521 | GNUNET_CONVERSATION_caller_hang_up (caller); |
586 | } | 522 | } |
587 | } | 523 | } |
@@ -781,10 +717,6 @@ GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller) | |||
781 | 717 | ||
782 | switch (caller->state) | 718 | switch (caller->state) |
783 | { | 719 | { |
784 | case CS_RESOLVE: | ||
785 | GNUNET_NAMESTORE_cancel (caller->qe); | ||
786 | caller->qe = NULL; | ||
787 | break; | ||
788 | case CS_ACTIVE: | 720 | case CS_ACTIVE: |
789 | caller->speaker->disable_speaker (caller->speaker->cls); | 721 | caller->speaker->disable_speaker (caller->speaker->cls); |
790 | caller->mic->disable_microphone (caller->mic->cls); | 722 | caller->mic->disable_microphone (caller->mic->cls); |
@@ -799,7 +731,6 @@ GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller) | |||
799 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | 731 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); |
800 | hang->cid = caller->cid; | 732 | hang->cid = caller->cid; |
801 | GNUNET_MQ_send (phone->mq, e); | 733 | GNUNET_MQ_send (phone->mq, e); |
802 | GNUNET_free_non_null (caller->caller_id_str); | ||
803 | GNUNET_free (caller); | 734 | GNUNET_free (caller); |
804 | } | 735 | } |
805 | 736 | ||
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c index 532107aca..11cad533b 100644 --- a/src/conversation/gnunet-conversation.c +++ b/src/conversation/gnunet-conversation.c | |||
@@ -127,9 +127,9 @@ struct CallList | |||
127 | struct GNUNET_CONVERSATION_Caller *caller; | 127 | struct GNUNET_CONVERSATION_Caller *caller; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * String identifying the caller. | 130 | * Public key identifying the caller. |
131 | */ | 131 | */ |
132 | char *caller_id; | 132 | struct GNUNET_CRYPTO_EcdsaPublicKey caller_id; |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * Unique number of the call. | 135 | * Unique number of the call. |
@@ -193,7 +193,7 @@ static struct GNUNET_CONFIGURATION_Handle *cfg; | |||
193 | /** | 193 | /** |
194 | * Our ego. | 194 | * Our ego. |
195 | */ | 195 | */ |
196 | static struct GNUNET_IDENTITY_Ego *caller_id; | 196 | static struct GNUNET_IDENTITY_Ego *my_caller_id; |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Handle to identity service. | 199 | * Handle to identity service. |
@@ -206,7 +206,12 @@ static struct GNUNET_IDENTITY_Handle *id; | |||
206 | static char *ego_name; | 206 | static char *ego_name; |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * Name of conversation partner (if any). | 209 | * Public key of active conversation partner (if any). |
210 | */ | ||
211 | static struct GNUNET_CRYPTO_EcdsaPublicKey peer_key; | ||
212 | |||
213 | /** | ||
214 | * Name of active conversation partner (if any). | ||
210 | */ | 215 | */ |
211 | static char *peer_name; | 216 | static char *peer_name; |
212 | 217 | ||
@@ -247,13 +252,13 @@ static int verbose; | |||
247 | * @param cls closure | 252 | * @param cls closure |
248 | * @param code type of the event | 253 | * @param code type of the event |
249 | * @param caller handle for the caller | 254 | * @param caller handle for the caller |
250 | * @param caller_id name of the caller in GNS | 255 | * @param caller_id public key of the caller (in GNS) |
251 | */ | 256 | */ |
252 | static void | 257 | static void |
253 | phone_event_handler (void *cls, | 258 | phone_event_handler (void *cls, |
254 | enum GNUNET_CONVERSATION_PhoneEventCode code, | 259 | enum GNUNET_CONVERSATION_PhoneEventCode code, |
255 | struct GNUNET_CONVERSATION_Caller *caller, | 260 | struct GNUNET_CONVERSATION_Caller *caller, |
256 | const char *caller_id) | 261 | const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) |
257 | { | 262 | { |
258 | struct CallList *cl; | 263 | struct CallList *cl; |
259 | 264 | ||
@@ -262,12 +267,12 @@ phone_event_handler (void *cls, | |||
262 | case GNUNET_CONVERSATION_EC_PHONE_RING: | 267 | case GNUNET_CONVERSATION_EC_PHONE_RING: |
263 | FPRINTF (stdout, | 268 | FPRINTF (stdout, |
264 | _("Incoming call from `%s'. Please /accept #%u or /cancel %u the call.\n"), | 269 | _("Incoming call from `%s'. Please /accept #%u or /cancel %u the call.\n"), |
265 | caller_id, | 270 | GNUNET_GNSRECORD_pkey_to_zkey (caller_id), |
266 | caller_num_gen, | 271 | caller_num_gen, |
267 | caller_num_gen); | 272 | caller_num_gen); |
268 | cl = GNUNET_new (struct CallList); | 273 | cl = GNUNET_new (struct CallList); |
269 | cl->caller = caller; | 274 | cl->caller = caller; |
270 | cl->caller_id = GNUNET_strdup (caller_id); | 275 | cl->caller_id = *caller_id; |
271 | cl->caller_num = caller_num_gen++; | 276 | cl->caller_num = caller_num_gen++; |
272 | GNUNET_CONTAINER_DLL_insert (cl_head, | 277 | GNUNET_CONTAINER_DLL_insert (cl_head, |
273 | cl_tail, | 278 | cl_tail, |
@@ -284,11 +289,10 @@ phone_event_handler (void *cls, | |||
284 | } | 289 | } |
285 | FPRINTF (stdout, | 290 | FPRINTF (stdout, |
286 | _("Call from `%s' terminated\n"), | 291 | _("Call from `%s' terminated\n"), |
287 | cl->caller_id); | 292 | GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id)); |
288 | GNUNET_CONTAINER_DLL_remove (cl_head, | 293 | GNUNET_CONTAINER_DLL_remove (cl_head, |
289 | cl_tail, | 294 | cl_tail, |
290 | cl); | 295 | cl); |
291 | GNUNET_free (cl->caller_id); | ||
292 | if (cl == cl_active) | 296 | if (cl == cl_active) |
293 | { | 297 | { |
294 | cl_active = NULL; | 298 | cl_active = NULL; |
@@ -317,12 +321,12 @@ caller_event_handler (void *cls, | |||
317 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: | 321 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: |
318 | FPRINTF (stdout, | 322 | FPRINTF (stdout, |
319 | _("Call from `%s' suspended by other user\n"), | 323 | _("Call from `%s' suspended by other user\n"), |
320 | cl->caller_id); | 324 | GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id)); |
321 | break; | 325 | break; |
322 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: | 326 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: |
323 | FPRINTF (stdout, | 327 | FPRINTF (stdout, |
324 | _("Call from `%s' resumed by other user\n"), | 328 | _("Call from `%s' resumed by other user\n"), |
325 | cl->caller_id); | 329 | GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id)); |
326 | break; | 330 | break; |
327 | } | 331 | } |
328 | } | 332 | } |
@@ -336,7 +340,7 @@ start_phone () | |||
336 | { | 340 | { |
337 | struct GNUNET_GNSRECORD_Data rd; | 341 | struct GNUNET_GNSRECORD_Data rd; |
338 | 342 | ||
339 | if (NULL == caller_id) | 343 | if (NULL == my_caller_id) |
340 | { | 344 | { |
341 | FPRINTF (stderr, | 345 | FPRINTF (stderr, |
342 | _("Ego `%s' no longer available, phone is now down.\n"), | 346 | _("Ego `%s' no longer available, phone is now down.\n"), |
@@ -346,7 +350,7 @@ start_phone () | |||
346 | } | 350 | } |
347 | GNUNET_assert (NULL == phone); | 351 | GNUNET_assert (NULL == phone); |
348 | phone = GNUNET_CONVERSATION_phone_create (cfg, | 352 | phone = GNUNET_CONVERSATION_phone_create (cfg, |
349 | caller_id, | 353 | my_caller_id, |
350 | &phone_event_handler, NULL); | 354 | &phone_event_handler, NULL); |
351 | /* FIXME: get record and print full GNS record info later here... */ | 355 | /* FIXME: get record and print full GNS record info later here... */ |
352 | if (NULL == phone) | 356 | if (NULL == phone) |
@@ -402,13 +406,17 @@ call_event_handler (void *cls, | |||
402 | GNUNET_break (CS_RESOLVING == call_state); | 406 | GNUNET_break (CS_RESOLVING == call_state); |
403 | FPRINTF (stdout, | 407 | FPRINTF (stdout, |
404 | _("Failed to resolve `%s'\n"), | 408 | _("Failed to resolve `%s'\n"), |
405 | ego_name); | 409 | peer_name); |
410 | GNUNET_free (peer_name); | ||
411 | peer_name = NULL; | ||
406 | call = NULL; | 412 | call = NULL; |
407 | break; | 413 | break; |
408 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: | 414 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: |
409 | FPRINTF (stdout, | 415 | FPRINTF (stdout, |
410 | "%s", | 416 | _("Call to `%s' terminated\n"), |
411 | _("Call terminated\n")); | 417 | peer_name); |
418 | GNUNET_free (peer_name); | ||
419 | peer_name = NULL; | ||
412 | call = NULL; | 420 | call = NULL; |
413 | break; | 421 | break; |
414 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: | 422 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: |
@@ -427,6 +435,7 @@ call_event_handler (void *cls, | |||
427 | FPRINTF (stdout, | 435 | FPRINTF (stdout, |
428 | _("Error with the call, restarting it\n")); | 436 | _("Error with the call, restarting it\n")); |
429 | call_state = CS_RESOLVING; | 437 | call_state = CS_RESOLVING; |
438 | // FIXME: is this correct? | ||
430 | break; | 439 | break; |
431 | } | 440 | } |
432 | } | 441 | } |
@@ -505,7 +514,7 @@ do_unknown (const char *msg) | |||
505 | static void | 514 | static void |
506 | do_call (const char *arg) | 515 | do_call (const char *arg) |
507 | { | 516 | { |
508 | if (NULL == caller_id) | 517 | if (NULL == my_caller_id) |
509 | { | 518 | { |
510 | FPRINTF (stderr, | 519 | FPRINTF (stderr, |
511 | _("Ego `%s' not available\n"), | 520 | _("Ego `%s' not available\n"), |
@@ -531,13 +540,12 @@ do_call (const char *arg) | |||
531 | case PS_ACCEPTED: | 540 | case PS_ACCEPTED: |
532 | FPRINTF (stderr, | 541 | FPRINTF (stderr, |
533 | _("You are answering call from `%s', hang up or suspend that call first!\n"), | 542 | _("You are answering call from `%s', hang up or suspend that call first!\n"), |
534 | peer_name); | 543 | GNUNET_GNSRECORD_pkey_to_zkey (&peer_key)); |
535 | return; | 544 | return; |
536 | case PS_ERROR: | 545 | case PS_ERROR: |
537 | /* ok to call */ | 546 | /* ok to call */ |
538 | break; | 547 | break; |
539 | } | 548 | } |
540 | GNUNET_free_non_null (peer_name); | ||
541 | if (NULL == arg) | 549 | if (NULL == arg) |
542 | { | 550 | { |
543 | FPRINTF (stderr, | 551 | FPRINTF (stderr, |
@@ -549,7 +557,7 @@ do_call (const char *arg) | |||
549 | call_state = CS_RESOLVING; | 557 | call_state = CS_RESOLVING; |
550 | GNUNET_assert (NULL == call); | 558 | GNUNET_assert (NULL == call); |
551 | call = GNUNET_CONVERSATION_call_start (cfg, | 559 | call = GNUNET_CONVERSATION_call_start (cfg, |
552 | caller_id, | 560 | my_caller_id, |
553 | arg, | 561 | arg, |
554 | speaker, | 562 | speaker, |
555 | mic, | 563 | mic, |
@@ -586,7 +594,7 @@ do_accept (const char *args) | |||
586 | case PS_ACCEPTED: | 594 | case PS_ACCEPTED: |
587 | FPRINTF (stderr, | 595 | FPRINTF (stderr, |
588 | _("You are answering call from `%s', hang up or suspend that call first!\n"), | 596 | _("You are answering call from `%s', hang up or suspend that call first!\n"), |
589 | peer_name); | 597 | GNUNET_GNSRECORD_pkey_to_zkey (&peer_key)); |
590 | return; | 598 | return; |
591 | case PS_ERROR: | 599 | case PS_ERROR: |
592 | GNUNET_break (0); | 600 | GNUNET_break (0); |
@@ -621,8 +629,7 @@ do_accept (const char *args) | |||
621 | cl_tail, | 629 | cl_tail, |
622 | cl); | 630 | cl); |
623 | cl_active = cl; | 631 | cl_active = cl; |
624 | GNUNET_free_non_null (peer_name); | 632 | peer_key = cl->caller_id; |
625 | peer_name = GNUNET_strdup (cl->caller_id); | ||
626 | phone_state = PS_ACCEPTED; | 633 | phone_state = PS_ACCEPTED; |
627 | GNUNET_CONVERSATION_caller_pick_up (cl->caller, | 634 | GNUNET_CONVERSATION_caller_pick_up (cl->caller, |
628 | &caller_event_handler, | 635 | &caller_event_handler, |
@@ -679,7 +686,7 @@ do_status (const char *args) | |||
679 | case PS_ACCEPTED: | 686 | case PS_ACCEPTED: |
680 | FPRINTF (stdout, | 687 | FPRINTF (stdout, |
681 | _("You are having a conversation with `%s'.\n"), | 688 | _("You are having a conversation with `%s'.\n"), |
682 | peer_name); | 689 | GNUNET_GNSRECORD_pkey_to_zkey (&peer_key));; |
683 | break; | 690 | break; |
684 | case PS_ERROR: | 691 | case PS_ERROR: |
685 | FPRINTF (stdout, | 692 | FPRINTF (stdout, |
@@ -724,7 +731,7 @@ do_status (const char *args) | |||
724 | FPRINTF (stdout, | 731 | FPRINTF (stdout, |
725 | _("#%u: `%s'\n"), | 732 | _("#%u: `%s'\n"), |
726 | cl->caller_num, | 733 | cl->caller_num, |
727 | cl->caller_id); | 734 | GNUNET_GNSRECORD_pkey_to_zkey (&cl->caller_id)); |
728 | } | 735 | } |
729 | FPRINTF (stdout, | 736 | FPRINTF (stdout, |
730 | "%s", | 737 | "%s", |
@@ -822,7 +829,7 @@ do_resume (const char *args) | |||
822 | case PS_ACCEPTED: | 829 | case PS_ACCEPTED: |
823 | FPRINTF (stderr, | 830 | FPRINTF (stderr, |
824 | _("Already talking with `%s', cannot resume a call right now.\n"), | 831 | _("Already talking with `%s', cannot resume a call right now.\n"), |
825 | peer_name); | 832 | GNUNET_GNSRECORD_pkey_to_zkey (&peer_key)); |
826 | return; | 833 | return; |
827 | } | 834 | } |
828 | GNUNET_assert (NULL == cl_active); | 835 | GNUNET_assert (NULL == cl_active); |
@@ -915,7 +922,6 @@ do_reject (const char *args) | |||
915 | GNUNET_CONTAINER_DLL_remove (cl_head, | 922 | GNUNET_CONTAINER_DLL_remove (cl_head, |
916 | cl_tail, | 923 | cl_tail, |
917 | cl); | 924 | cl); |
918 | GNUNET_free (cl->caller_id); | ||
919 | GNUNET_free (cl); | 925 | GNUNET_free (cl); |
920 | break; | 926 | break; |
921 | case PS_ACCEPTED: | 927 | case PS_ACCEPTED: |
@@ -1046,11 +1052,20 @@ do_stop_task (void *cls, | |||
1046 | GNUNET_free (ego_name); | 1052 | GNUNET_free (ego_name); |
1047 | ego_name = NULL; | 1053 | ego_name = NULL; |
1048 | GNUNET_free_non_null (peer_name); | 1054 | GNUNET_free_non_null (peer_name); |
1055 | peer_name = NULL; | ||
1049 | phone_state = PS_ERROR; | 1056 | phone_state = PS_ERROR; |
1050 | } | 1057 | } |
1051 | 1058 | ||
1059 | |||
1060 | /** | ||
1061 | * Handle user command. | ||
1062 | * | ||
1063 | * @param message command the user typed in | ||
1064 | * @param str_len number of bytes to process in @a message | ||
1065 | */ | ||
1052 | static void | 1066 | static void |
1053 | handle_command_string (char *message, size_t str_len) | 1067 | handle_command_string (char *message, |
1068 | size_t str_len) | ||
1054 | { | 1069 | { |
1055 | size_t i; | 1070 | size_t i; |
1056 | const char *ptr; | 1071 | const char *ptr; |
@@ -1078,9 +1093,10 @@ handle_command_string (char *message, size_t str_len) | |||
1078 | 1093 | ||
1079 | 1094 | ||
1080 | #ifdef WINDOWS | 1095 | #ifdef WINDOWS |
1081 | int | 1096 | static int |
1082 | console_reader_chars (void *cls, void *client, | 1097 | console_reader_chars (void *cls, |
1083 | const struct GNUNET_MessageHeader *message) | 1098 | void *client, |
1099 | const struct GNUNET_MessageHeader *message) | ||
1084 | { | 1100 | { |
1085 | char *chars; | 1101 | char *chars; |
1086 | size_t str_size; | 1102 | size_t str_size; |
@@ -1144,7 +1160,7 @@ identity_cb (void *cls, | |||
1144 | { | 1160 | { |
1145 | if (NULL == name) | 1161 | if (NULL == name) |
1146 | return; | 1162 | return; |
1147 | if (ego == caller_id) | 1163 | if (ego == my_caller_id) |
1148 | { | 1164 | { |
1149 | if (verbose) | 1165 | if (verbose) |
1150 | FPRINTF (stdout, | 1166 | FPRINTF (stdout, |
@@ -1163,10 +1179,10 @@ identity_cb (void *cls, | |||
1163 | FPRINTF (stdout, | 1179 | FPRINTF (stdout, |
1164 | _("Our ego `%s' was deleted!\n"), | 1180 | _("Our ego `%s' was deleted!\n"), |
1165 | ego_name); | 1181 | ego_name); |
1166 | caller_id = NULL; | 1182 | my_caller_id = NULL; |
1167 | return; | 1183 | return; |
1168 | } | 1184 | } |
1169 | caller_id = ego; | 1185 | my_caller_id = ego; |
1170 | GNUNET_CONFIGURATION_set_value_number (cfg, | 1186 | GNUNET_CONFIGURATION_set_value_number (cfg, |
1171 | "CONVERSATION", | 1187 | "CONVERSATION", |
1172 | "LINE", | 1188 | "LINE", |
diff --git a/src/conversation/test_conversation_api.c b/src/conversation/test_conversation_api.c index 9714d5a81..862b71e6b 100644 --- a/src/conversation/test_conversation_api.c +++ b/src/conversation/test_conversation_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2013 Christian Grothoff (and other contributing authors) | 3 | (C) 2013, 2014 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -330,13 +330,11 @@ static void | |||
330 | phone_event_handler (void *cls, | 330 | phone_event_handler (void *cls, |
331 | enum GNUNET_CONVERSATION_PhoneEventCode code, | 331 | enum GNUNET_CONVERSATION_PhoneEventCode code, |
332 | struct GNUNET_CONVERSATION_Caller *caller, | 332 | struct GNUNET_CONVERSATION_Caller *caller, |
333 | const char *caller_id) | 333 | const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) |
334 | { | 334 | { |
335 | static enum GNUNET_CONVERSATION_PhoneEventCode expect | 335 | static enum GNUNET_CONVERSATION_PhoneEventCode expect |
336 | = GNUNET_CONVERSATION_EC_PHONE_RING; | 336 | = GNUNET_CONVERSATION_EC_PHONE_RING; |
337 | 337 | ||
338 | GNUNET_break (0 == strcmp (caller_id, | ||
339 | gns_caller_id)); | ||
340 | GNUNET_break (code == expect); | 338 | GNUNET_break (code == expect); |
341 | switch (code) | 339 | switch (code) |
342 | { | 340 | { |
diff --git a/src/conversation/test_conversation_api_reject.c b/src/conversation/test_conversation_api_reject.c index 06e364ec5..8bfaabae9 100644 --- a/src/conversation/test_conversation_api_reject.c +++ b/src/conversation/test_conversation_api_reject.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2013 Christian Grothoff (and other contributing authors) | 3 | (C) 2013, 2014 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -174,13 +174,11 @@ static void | |||
174 | phone_event_handler (void *cls, | 174 | phone_event_handler (void *cls, |
175 | enum GNUNET_CONVERSATION_PhoneEventCode code, | 175 | enum GNUNET_CONVERSATION_PhoneEventCode code, |
176 | struct GNUNET_CONVERSATION_Caller *caller, | 176 | struct GNUNET_CONVERSATION_Caller *caller, |
177 | const char *caller_id) | 177 | const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) |
178 | { | 178 | { |
179 | static enum GNUNET_CONVERSATION_PhoneEventCode expect | 179 | static enum GNUNET_CONVERSATION_PhoneEventCode expect |
180 | = GNUNET_CONVERSATION_EC_PHONE_RING; | 180 | = GNUNET_CONVERSATION_EC_PHONE_RING; |
181 | 181 | ||
182 | GNUNET_break (0 == strcmp (caller_id, | ||
183 | gns_caller_id)); | ||
184 | GNUNET_break (code == expect); | 182 | GNUNET_break (code == expect); |
185 | switch (code) | 183 | switch (code) |
186 | { | 184 | { |
@@ -242,7 +240,8 @@ namestore_put_cont (void *cls, | |||
242 | GNUNET_assert (GNUNET_YES == success); | 240 | GNUNET_assert (GNUNET_YES == success); |
243 | GNUNET_assert (NULL == emsg); | 241 | GNUNET_assert (NULL == emsg); |
244 | GNUNET_assert (NULL == op); | 242 | GNUNET_assert (NULL == op); |
245 | op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL); | 243 | op = GNUNET_IDENTITY_create (id, "caller-ego", |
244 | &caller_ego_create_cont, NULL); | ||
246 | } | 245 | } |
247 | 246 | ||
248 | 247 | ||
diff --git a/src/conversation/test_conversation_api_twocalls.c b/src/conversation/test_conversation_api_twocalls.c index 3f461231d..130edbc27 100644 --- a/src/conversation/test_conversation_api_twocalls.c +++ b/src/conversation/test_conversation_api_twocalls.c | |||
@@ -406,12 +406,10 @@ static void | |||
406 | phone_event_handler (void *cls, | 406 | phone_event_handler (void *cls, |
407 | enum GNUNET_CONVERSATION_PhoneEventCode code, | 407 | enum GNUNET_CONVERSATION_PhoneEventCode code, |
408 | struct GNUNET_CONVERSATION_Caller *caller, | 408 | struct GNUNET_CONVERSATION_Caller *caller, |
409 | const char *caller_id) | 409 | const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) |
410 | { | 410 | { |
411 | const char *cid; | 411 | const char *cid; |
412 | 412 | ||
413 | GNUNET_break (0 == strcmp (caller_id, | ||
414 | gns_caller_id)); | ||
415 | switch (code) | 413 | switch (code) |
416 | { | 414 | { |
417 | case GNUNET_CONVERSATION_EC_PHONE_RING: | 415 | case GNUNET_CONVERSATION_EC_PHONE_RING: |