aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_lib.c')
-rw-r--r--src/gnunet_chat_lib.c55
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
489const struct GNUNET_CHAT_Contact*
490GNUNET_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
522const struct GNUNET_CHAT_Group*
523GNUNET_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
489void 544void
490GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context, 545GNUNET_CHAT_context_set_user_pointer (struct GNUNET_CHAT_Context *context,
491 void *user_pointer) 546 void *user_pointer)