diff options
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r-- | src/gnunet_chat_lib.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index e002b89..57744fe 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -486,6 +486,61 @@ GNUNET_CHAT_group_get_context (struct GNUNET_CHAT_Group *group) | |||
486 | } | 486 | } |
487 | 487 | ||
488 | 488 | ||
489 | const struct GNUNET_CHAT_Contact* | ||
490 | GNUNET_CHAT_context_get_contact (const struct GNUNET_CHAT_Context *context) | ||
491 | { | ||
492 | if ((!context) || (GNUNET_CHAT_CONTEXT_TYPE_CONTACT != context->type)) | ||
493 | return NULL; | ||
494 | |||
495 | struct GNUNET_MESSENGER_Room *room = context->room; | ||
496 | struct GNUNET_CHAT_RoomFindContact find; | ||
497 | |||
498 | find.contact = NULL; | ||
499 | |||
500 | GNUNET_MESSENGER_iterate_members( | ||
501 | room, | ||
502 | it_room_find_contact, | ||
503 | &find | ||
504 | ); | ||
505 | |||
506 | if (!find.contact) | ||
507 | return NULL; | ||
508 | |||
509 | struct GNUNET_ShortHashCode shorthash; | ||
510 | util_shorthash_from_member(find.contact, &shorthash); | ||
511 | |||
512 | const struct GNUNET_CHAT_Contact *contact; | ||
513 | contact = GNUNET_CONTAINER_multishortmap_get( | ||
514 | context->handle->contacts, &shorthash | ||
515 | ); | ||
516 | |||
517 | GNUNET_assert((contact == NULL) || (contact->context == context)); | ||
518 | return contact; | ||
519 | } | ||
520 | |||
521 | |||
522 | const struct GNUNET_CHAT_Group* | ||
523 | GNUNET_CHAT_context_get_group (const struct GNUNET_CHAT_Context *context) | ||
524 | { | ||
525 | if ((!context) || (GNUNET_CHAT_CONTEXT_TYPE_GROUP != context->type)) | ||
526 | return NULL; | ||
527 | |||
528 | const struct GNUNET_MESSENGER_Room *room = context->room; | ||
529 | const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room); | ||
530 | |||
531 | if (!key) | ||
532 | return NULL; | ||
533 | |||
534 | const struct GNUNET_CHAT_Group *group; | ||
535 | group = GNUNET_CONTAINER_multihashmap_get( | ||
536 | context->handle->groups, key | ||
537 | ); | ||
538 | |||
539 | GNUNET_assert((group == NULL) || (group->context == context)); | ||
540 | return group; | ||
541 | } | ||
542 | |||
543 | |||
489 | void | 544 | void |
490 | GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context, | 545 | GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context, |
491 | void *user_pointer) | 546 | void *user_pointer) |