diff options
Diffstat (limited to 'src/identity/identity_api.c')
-rw-r--r-- | src/identity/identity_api.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index d5035ba49..57a541471 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -24,14 +24,9 @@ | |||
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_client_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_constants.h" | 28 | #include "gnunet_constants.h" |
29 | #include "gnunet_container_lib.h" | ||
30 | #include "gnunet_arm_service.h" | ||
31 | #include "gnunet_hello_lib.h" | ||
32 | #include "gnunet_protocols.h" | 29 | #include "gnunet_protocols.h" |
33 | #include "gnunet_server_lib.h" | ||
34 | #include "gnunet_time_lib.h" | ||
35 | #include "gnunet_identity_service.h" | 30 | #include "gnunet_identity_service.h" |
36 | #include "identity.h" | 31 | #include "identity.h" |
37 | 32 | ||
@@ -292,6 +287,8 @@ message_handler (void *cls, | |||
292 | GNUNET_CONTAINER_DLL_remove (h->op_head, | 287 | GNUNET_CONTAINER_DLL_remove (h->op_head, |
293 | h->op_tail, | 288 | h->op_tail, |
294 | op); | 289 | op); |
290 | GNUNET_CLIENT_receive (h->client, &message_handler, h, | ||
291 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
295 | if (NULL != op->cont) | 292 | if (NULL != op->cont) |
296 | op->cont (op->cls, | 293 | op->cont (op->cls, |
297 | str); | 294 | str); |
@@ -321,6 +318,8 @@ message_handler (void *cls, | |||
321 | if (GNUNET_YES == ntohs (um->end_of_list)) | 318 | if (GNUNET_YES == ntohs (um->end_of_list)) |
322 | { | 319 | { |
323 | /* end of initial list of data */ | 320 | /* end of initial list of data */ |
321 | GNUNET_CLIENT_receive (h->client, &message_handler, h, | ||
322 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
324 | if (NULL != h->cb) | 323 | if (NULL != h->cb) |
325 | h->cb (h->cb_cls, NULL, NULL, NULL); | 324 | h->cb (h->cb_cls, NULL, NULL, NULL); |
326 | break; | 325 | break; |
@@ -355,12 +354,6 @@ message_handler (void *cls, | |||
355 | ego, | 354 | ego, |
356 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 355 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
357 | } | 356 | } |
358 | /* inform application about change */ | ||
359 | if (NULL != h->cb) | ||
360 | h->cb (h->cb_cls, | ||
361 | ego, | ||
362 | &ego->ctx, | ||
363 | str); | ||
364 | if (NULL == str) | 357 | if (NULL == str) |
365 | { | 358 | { |
366 | /* ego was deleted */ | 359 | /* ego was deleted */ |
@@ -368,16 +361,27 @@ message_handler (void *cls, | |||
368 | GNUNET_CONTAINER_multihashmap_remove (h->egos, | 361 | GNUNET_CONTAINER_multihashmap_remove (h->egos, |
369 | &ego->id, | 362 | &ego->id, |
370 | ego)); | 363 | ego)); |
371 | GNUNET_free (ego->pk); | ||
372 | GNUNET_free (ego->name); | ||
373 | GNUNET_free (ego); | ||
374 | } | 364 | } |
375 | else | 365 | else |
376 | { | 366 | { |
377 | /* ego changed name */ | 367 | /* ego changed name */ |
378 | GNUNET_free (ego->name); | 368 | GNUNET_free (ego->name); |
379 | ego->name = GNUNET_strdup (str); | 369 | ego->name = GNUNET_strdup (str); |
380 | } | 370 | } |
371 | GNUNET_CLIENT_receive (h->client, &message_handler, h, | ||
372 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
373 | /* inform application about change */ | ||
374 | if (NULL != h->cb) | ||
375 | h->cb (h->cb_cls, | ||
376 | ego, | ||
377 | &ego->ctx, | ||
378 | str); | ||
379 | if (NULL == str) | ||
380 | { | ||
381 | GNUNET_free (ego->pk); | ||
382 | GNUNET_free (ego->name); | ||
383 | GNUNET_free (ego); | ||
384 | } | ||
381 | break; | 385 | break; |
382 | case GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT: | 386 | case GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT: |
383 | if (size < sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) | 387 | if (size < sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) |
@@ -416,6 +420,8 @@ message_handler (void *cls, | |||
416 | h->op_tail, | 420 | h->op_tail, |
417 | op); | 421 | op); |
418 | GNUNET_free (ego->name); | 422 | GNUNET_free (ego->name); |
423 | GNUNET_CLIENT_receive (h->client, &message_handler, h, | ||
424 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
419 | if (NULL != op->cb) | 425 | if (NULL != op->cb) |
420 | op->cb (op->cls, | 426 | op->cb (op->cls, |
421 | ego, | 427 | ego, |
@@ -428,8 +434,6 @@ message_handler (void *cls, | |||
428 | reschedule_connect (h); | 434 | reschedule_connect (h); |
429 | return; | 435 | return; |
430 | } | 436 | } |
431 | GNUNET_CLIENT_receive (h->client, &message_handler, h, | ||
432 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
433 | } | 437 | } |
434 | 438 | ||
435 | 439 | ||
@@ -565,7 +569,7 @@ GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
565 | { | 569 | { |
566 | struct GNUNET_IDENTITY_Handle *h; | 570 | struct GNUNET_IDENTITY_Handle *h; |
567 | 571 | ||
568 | h = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Handle)); | 572 | h = GNUNET_new (struct GNUNET_IDENTITY_Handle); |
569 | h->cfg = cfg; | 573 | h->cfg = cfg; |
570 | h->cb = cb; | 574 | h->cb = cb; |
571 | h->cb_cls = cb_cls; | 575 | h->cb_cls = cb_cls; |
@@ -821,7 +825,7 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id, | |||
821 | * @param id identity service to use | 825 | * @param id identity service to use |
822 | * @param name name of the identity to delete | 826 | * @param name name of the identity to delete |
823 | * @param cb function to call with the result (will only be called once) | 827 | * @param cb function to call with the result (will only be called once) |
824 | * @param cb_cls closure for cb | 828 | * @param cb_cls closure for @a cb |
825 | * @return handle to abort the operation | 829 | * @return handle to abort the operation |
826 | */ | 830 | */ |
827 | struct GNUNET_IDENTITY_Operation * | 831 | struct GNUNET_IDENTITY_Operation * |
@@ -910,7 +914,7 @@ GNUNET_IDENTITY_cancel (struct GNUNET_IDENTITY_Operation *op) | |||
910 | * @param cls identity service handle | 914 | * @param cls identity service handle |
911 | * @param key unused | 915 | * @param key unused |
912 | * @param value ego to free | 916 | * @param value ego to free |
913 | * @return GNUNET_OK (continue to iterate) | 917 | * @return #GNUNET_OK (continue to iterate) |
914 | */ | 918 | */ |
915 | static int | 919 | static int |
916 | free_ego (void *cls, | 920 | free_ego (void *cls, |