diff options
Diffstat (limited to 'src/gnunet_chat_handle_intern.c')
-rw-r--r-- | src/gnunet_chat_handle_intern.c | 137 |
1 files changed, 92 insertions, 45 deletions
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c index 8b792f1..0b719a6 100644 --- a/src/gnunet_chat_handle_intern.c +++ b/src/gnunet_chat_handle_intern.c | |||
@@ -287,6 +287,9 @@ on_handle_gnunet_identity(void *cls, | |||
287 | accounts | 287 | accounts |
288 | ); | 288 | ); |
289 | 289 | ||
290 | if (accounts->identifier) | ||
291 | GNUNET_free(accounts->identifier); | ||
292 | |||
290 | GNUNET_free(accounts); | 293 | GNUNET_free(accounts); |
291 | } | 294 | } |
292 | 295 | ||
@@ -347,6 +350,9 @@ cb_account_creation (void *cls, | |||
347 | accounts | 350 | accounts |
348 | ); | 351 | ); |
349 | 352 | ||
353 | if (accounts->identifier) | ||
354 | GNUNET_free(accounts->identifier); | ||
355 | |||
350 | GNUNET_free(accounts); | 356 | GNUNET_free(accounts); |
351 | 357 | ||
352 | if (GNUNET_EC_NONE != ec) | 358 | if (GNUNET_EC_NONE != ec) |
@@ -382,6 +388,9 @@ cb_account_deletion (void *cls, | |||
382 | accounts | 388 | accounts |
383 | ); | 389 | ); |
384 | 390 | ||
391 | if (accounts->identifier) | ||
392 | GNUNET_free(accounts->identifier); | ||
393 | |||
385 | GNUNET_free(accounts); | 394 | GNUNET_free(accounts); |
386 | 395 | ||
387 | if (GNUNET_EC_NONE != ec) | 396 | if (GNUNET_EC_NONE != ec) |
@@ -397,6 +406,89 @@ cb_account_deletion (void *cls, | |||
397 | } | 406 | } |
398 | } | 407 | } |
399 | 408 | ||
409 | void | ||
410 | cb_account_rename (void *cls, | ||
411 | enum GNUNET_ErrorCode ec) | ||
412 | { | ||
413 | GNUNET_assert(cls); | ||
414 | |||
415 | struct GNUNET_CHAT_InternalAccounts *accounts = ( | ||
416 | (struct GNUNET_CHAT_InternalAccounts*) cls | ||
417 | ); | ||
418 | |||
419 | struct GNUNET_CHAT_Handle *handle = accounts->handle; | ||
420 | |||
421 | GNUNET_CONTAINER_DLL_remove( | ||
422 | handle->accounts_head, | ||
423 | handle->accounts_tail, | ||
424 | accounts | ||
425 | ); | ||
426 | |||
427 | if (accounts->identifier) | ||
428 | GNUNET_free(accounts->identifier); | ||
429 | |||
430 | GNUNET_free(accounts); | ||
431 | |||
432 | if (GNUNET_EC_NONE != ec) | ||
433 | { | ||
434 | handle_send_internal_message( | ||
435 | handle, | ||
436 | NULL, | ||
437 | GNUNET_CHAT_FLAG_WARNING, | ||
438 | GNUNET_ErrorCode_get_hint(ec) | ||
439 | ); | ||
440 | |||
441 | return; | ||
442 | } | ||
443 | } | ||
444 | |||
445 | static void | ||
446 | cb_account_update_completion (void *cls, | ||
447 | const struct GNUNET_IDENTITY_PrivateKey *key, | ||
448 | enum GNUNET_ErrorCode ec) | ||
449 | { | ||
450 | GNUNET_assert(cls); | ||
451 | |||
452 | struct GNUNET_CHAT_InternalAccounts *accounts = ( | ||
453 | (struct GNUNET_CHAT_InternalAccounts*) cls | ||
454 | ); | ||
455 | |||
456 | struct GNUNET_CHAT_Handle *handle = accounts->handle; | ||
457 | |||
458 | if ((GNUNET_EC_NONE == ec) && (key)) | ||
459 | GNUNET_MESSENGER_set_key(handle->messenger, key); | ||
460 | |||
461 | cb_account_creation(cls, key, ec); | ||
462 | } | ||
463 | |||
464 | void | ||
465 | cb_account_update (void *cls, | ||
466 | enum GNUNET_ErrorCode ec) | ||
467 | { | ||
468 | GNUNET_assert(cls); | ||
469 | |||
470 | struct GNUNET_CHAT_InternalAccounts *accounts = ( | ||
471 | (struct GNUNET_CHAT_InternalAccounts*) cls | ||
472 | ); | ||
473 | |||
474 | struct GNUNET_CHAT_Handle *handle = accounts->handle; | ||
475 | |||
476 | if ((GNUNET_EC_NONE != ec) || (!accounts->identifier)) | ||
477 | { | ||
478 | cb_account_deletion(cls, ec); | ||
479 | return; | ||
480 | } | ||
481 | |||
482 | accounts->op = GNUNET_IDENTITY_create( | ||
483 | handle->identity, | ||
484 | accounts->identifier, | ||
485 | NULL, | ||
486 | GNUNET_IDENTITY_TYPE_ECDSA, | ||
487 | cb_account_update_completion, | ||
488 | accounts | ||
489 | ); | ||
490 | } | ||
491 | |||
400 | int | 492 | int |
401 | intern_provide_contact_for_member(struct GNUNET_CHAT_Handle *handle, | 493 | intern_provide_contact_for_member(struct GNUNET_CHAT_Handle *handle, |
402 | const struct GNUNET_MESSENGER_Contact *member, | 494 | const struct GNUNET_MESSENGER_Contact *member, |
@@ -517,51 +609,6 @@ on_monitor_namestore_record(void *cls, | |||
517 | } | 609 | } |
518 | 610 | ||
519 | void | 611 | void |
520 | on_handle_identity(void *cls, | ||
521 | GNUNET_UNUSED struct GNUNET_MESSENGER_Handle *messenger) | ||
522 | { | ||
523 | struct GNUNET_CHAT_Handle *handle = cls; | ||
524 | |||
525 | GNUNET_assert((handle) && | ||
526 | (handle->contexts) && | ||
527 | (handle->groups) && | ||
528 | (handle->contacts)); | ||
529 | |||
530 | handle_update_key(handle); | ||
531 | |||
532 | if ((0 < GNUNET_CONTAINER_multihashmap_size(handle->contexts)) || | ||
533 | (0 < GNUNET_CONTAINER_multihashmap_size(handle->groups)) || | ||
534 | (0 < GNUNET_CONTAINER_multishortmap_size(handle->contacts))) | ||
535 | return; | ||
536 | |||
537 | GNUNET_assert(handle->messenger); | ||
538 | |||
539 | handle_send_internal_message( | ||
540 | handle, | ||
541 | NULL, | ||
542 | GNUNET_CHAT_FLAG_LOGIN, | ||
543 | NULL | ||
544 | ); | ||
545 | |||
546 | const struct GNUNET_IDENTITY_PrivateKey *zone = handle_get_key(handle); | ||
547 | |||
548 | if ((!zone) || (handle->monitor)) | ||
549 | return; | ||
550 | |||
551 | handle->monitor = GNUNET_NAMESTORE_zone_monitor_start( | ||
552 | handle->cfg, | ||
553 | zone, | ||
554 | GNUNET_YES, | ||
555 | NULL, | ||
556 | NULL, | ||
557 | on_monitor_namestore_record, | ||
558 | handle, | ||
559 | NULL, | ||
560 | NULL | ||
561 | ); | ||
562 | } | ||
563 | |||
564 | void | ||
565 | on_handle_message_callback(void *cls) | 612 | on_handle_message_callback(void *cls) |
566 | { | 613 | { |
567 | struct GNUNET_CHAT_Message *message = (struct GNUNET_CHAT_Message*) cls; | 614 | struct GNUNET_CHAT_Message *message = (struct GNUNET_CHAT_Message*) cls; |