libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit db36b1bec392f6a06773a2b5199d3de424ac8205
parent ba528dd455716f73fbfb3191401b8978e9900453
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Sat, 12 Mar 2022 21:20:44 +0100

Fixed duplicated context creation and removed debug printing

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
Msrc/gnunet_chat_context.c | 2--
Msrc/gnunet_chat_handle.c | 5-----
Msrc/gnunet_chat_lobby.c | 3---
Msrc/gnunet_chat_lobby_intern.c | 33++++++++-------------------------
4 files changed, 8 insertions(+), 35 deletions(-)

diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c @@ -332,8 +332,6 @@ context_write_records (struct GNUNET_CHAT_Context *context) char *label; util_get_context_label(context->type, hash, &label); - printf("WRITE: %s -> %u (%s, %s)\n", label, count, nick, topic); - GNUNET_NAMESTORE_records_store( context->handle->namestore, zone, diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c @@ -598,9 +598,6 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, if (context) { context_read_records(context, label, count, data); - - printf("PATCH: %s %u %d %s\n", label, count, (int) context->type, context->topic); - return NULL; } @@ -616,8 +613,6 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, context = context_create_from_room(handle, room); context_read_records(context, label, count, data); - printf("READ: %s %u %d %s\n", label, count, (int) context->type, context->topic); - handle_send_room_name(handle, room); if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( diff --git a/src/gnunet_chat_lobby.c b/src/gnunet_chat_lobby.c @@ -62,9 +62,6 @@ lobby_destroy (struct GNUNET_CHAT_Lobby *lobby) if (lobby->uri) uri_destroy(lobby->uri); - if (lobby->context) - context_destroy(lobby->context); - GNUNET_free(lobby); } diff --git a/src/gnunet_chat_lobby_intern.c b/src/gnunet_chat_lobby_intern.c @@ -75,13 +75,11 @@ cont_lobby_identity_create (void *cls, { struct GNUNET_CHAT_Lobby *lobby = cls; - char *name; - if (emsg) { handle_send_internal_message( lobby->handle, - NULL, + lobby->context, GNUNET_CHAT_FLAG_WARNING, emsg ); @@ -89,30 +87,15 @@ cont_lobby_identity_create (void *cls, return; } - struct GNUNET_MESSENGER_Room *room = GNUNET_MESSENGER_open_room( - lobby->handle->messenger, - NULL + const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key( + lobby->context->room ); - if (!room) - goto destroy_identity; - - const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room); - - lobby->context = context_create_from_room(lobby->handle, room); - - handle_send_room_name(lobby->handle, room); + struct GNUNET_MESSENGER_RoomEntryRecord room; + GNUNET_CRYPTO_get_peer_identity(lobby->handle->cfg, &(room.door)); + GNUNET_memcpy(&(room.key), key, sizeof(room.key)); - if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( - lobby->handle->contexts, key, lobby->context, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) - { - context_destroy(lobby->context); - lobby->context = NULL; - goto destroy_identity; - } - - struct GNUNET_GNSRECORD_Data data [3]; + struct GNUNET_GNSRECORD_Data data [1]; data[0].record_type = GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY; data[0].data = &room; data[0].data_size = sizeof(room); @@ -143,7 +126,7 @@ cont_lobby_identity_create (void *cls, context_write_records(lobby->context); -destroy_identity: + char *name; util_lobby_name(key, &name); lobby->op_delete = GNUNET_IDENTITY_delete(