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.c53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 16fb27d..8c6a109 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -310,6 +310,8 @@ GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle,
310 310
311 context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP; 311 context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP;
312 312
313 util_set_name_field(topic, &(context->topic));
314
313 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( 315 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(
314 handle->contexts, &key, context, 316 handle->contexts, &key, context,
315 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 317 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
@@ -317,15 +319,16 @@ GNUNET_CHAT_group_create (struct GNUNET_CHAT_Handle *handle,
317 319
318 struct GNUNET_CHAT_Group *group = group_create_from_context(handle, context); 320 struct GNUNET_CHAT_Group *group = group_create_from_context(handle, context);
319 321
320 util_set_name_field(topic, &(group->topic)); 322 if (context->topic)
321
322 if (group->topic)
323 group_publish(group); 323 group_publish(group);
324 324
325 if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put( 325 if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put(
326 handle->groups, &key, group, 326 handle->groups, &key, group,
327 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 327 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
328 {
329 context_write_records(context);
328 return group; 330 return group;
331 }
329 332
330 group_destroy(group); 333 group_destroy(group);
331 334
@@ -513,10 +516,13 @@ GNUNET_CHAT_group_set_name (struct GNUNET_CHAT_Group *group,
513const char* 516const char*
514GNUNET_CHAT_group_get_name (const struct GNUNET_CHAT_Group *group) 517GNUNET_CHAT_group_get_name (const struct GNUNET_CHAT_Group *group)
515{ 518{
516 if (!group) 519 if ((!group) || (!(group->context)))
517 return NULL; 520 return NULL;
518 521
519 return group->context->nick; 522 if (group->context->nick)
523 return group->context->nick;
524
525 return group->context->topic;
520} 526}
521 527
522 528
@@ -911,6 +917,43 @@ GNUNET_CHAT_context_iterate_files (struct GNUNET_CHAT_Context *context,
911} 917}
912 918
913 919
920void
921GNUNET_CHAT_member_set_user_pointer (struct GNUNET_CHAT_Context *context,
922 const struct GNUNET_CHAT_Contact *member,
923 void *user_pointer)
924{
925 if ((!context) || (!member))
926 return;
927
928 struct GNUNET_ShortHashCode hash;
929 util_shorthash_from_member(member->member, &hash);
930
931 GNUNET_CONTAINER_multishortmap_put(
932 context->member_pointers,
933 &hash,
934 user_pointer,
935 GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
936 );
937}
938
939
940void*
941GNUNET_CHAT_member_get_user_pointer (const struct GNUNET_CHAT_Context *context,
942 const struct GNUNET_CHAT_Contact *member)
943{
944 if ((!context) || (!member))
945 return NULL;
946
947 struct GNUNET_ShortHashCode hash;
948 util_shorthash_from_member(member->member, &hash);
949
950 return GNUNET_CONTAINER_multishortmap_get(
951 context->member_pointers,
952 &hash
953 );
954}
955
956
914enum GNUNET_CHAT_MessageKind 957enum GNUNET_CHAT_MessageKind
915GNUNET_CHAT_message_get_kind (const struct GNUNET_CHAT_Message *message) 958GNUNET_CHAT_message_get_kind (const struct GNUNET_CHAT_Message *message)
916{ 959{