diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-03-12 21:20:44 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-03-12 21:20:44 +0100 |
commit | db36b1bec392f6a06773a2b5199d3de424ac8205 (patch) | |
tree | 193a3a06256fc977a389ff1e906ac3a1b56127b6 | |
parent | ba528dd455716f73fbfb3191401b8978e9900453 (diff) | |
download | libgnunetchat-db36b1bec392f6a06773a2b5199d3de424ac8205.tar.gz libgnunetchat-db36b1bec392f6a06773a2b5199d3de424ac8205.zip |
Fixed duplicated context creation and removed debug printing
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | src/gnunet_chat_context.c | 2 | ||||
-rw-r--r-- | src/gnunet_chat_handle.c | 5 | ||||
-rw-r--r-- | src/gnunet_chat_lobby.c | 3 | ||||
-rw-r--r-- | src/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 index 483d673..a4f3db0 100644 --- a/src/gnunet_chat_context.c +++ b/src/gnunet_chat_context.c | |||
@@ -332,8 +332,6 @@ context_write_records (struct GNUNET_CHAT_Context *context) | |||
332 | char *label; | 332 | char *label; |
333 | util_get_context_label(context->type, hash, &label); | 333 | util_get_context_label(context->type, hash, &label); |
334 | 334 | ||
335 | printf("WRITE: %s -> %u (%s, %s)\n", label, count, nick, topic); | ||
336 | |||
337 | GNUNET_NAMESTORE_records_store( | 335 | GNUNET_NAMESTORE_records_store( |
338 | context->handle->namestore, | 336 | context->handle->namestore, |
339 | zone, | 337 | zone, |
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c index de42b83..7b84673 100644 --- a/src/gnunet_chat_handle.c +++ b/src/gnunet_chat_handle.c | |||
@@ -598,9 +598,6 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, | |||
598 | if (context) | 598 | if (context) |
599 | { | 599 | { |
600 | context_read_records(context, label, count, data); | 600 | context_read_records(context, label, count, data); |
601 | |||
602 | printf("PATCH: %s %u %d %s\n", label, count, (int) context->type, context->topic); | ||
603 | |||
604 | return NULL; | 601 | return NULL; |
605 | } | 602 | } |
606 | 603 | ||
@@ -616,8 +613,6 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, | |||
616 | context = context_create_from_room(handle, room); | 613 | context = context_create_from_room(handle, room); |
617 | context_read_records(context, label, count, data); | 614 | context_read_records(context, label, count, data); |
618 | 615 | ||
619 | printf("READ: %s %u %d %s\n", label, count, (int) context->type, context->topic); | ||
620 | |||
621 | handle_send_room_name(handle, room); | 616 | handle_send_room_name(handle, room); |
622 | 617 | ||
623 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( | 618 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( |
diff --git a/src/gnunet_chat_lobby.c b/src/gnunet_chat_lobby.c index e656ebb..23c6d32 100644 --- a/src/gnunet_chat_lobby.c +++ b/src/gnunet_chat_lobby.c | |||
@@ -62,9 +62,6 @@ lobby_destroy (struct GNUNET_CHAT_Lobby *lobby) | |||
62 | if (lobby->uri) | 62 | if (lobby->uri) |
63 | uri_destroy(lobby->uri); | 63 | uri_destroy(lobby->uri); |
64 | 64 | ||
65 | if (lobby->context) | ||
66 | context_destroy(lobby->context); | ||
67 | |||
68 | GNUNET_free(lobby); | 65 | GNUNET_free(lobby); |
69 | } | 66 | } |
70 | 67 | ||
diff --git a/src/gnunet_chat_lobby_intern.c b/src/gnunet_chat_lobby_intern.c index 2c10175..31d1673 100644 --- a/src/gnunet_chat_lobby_intern.c +++ b/src/gnunet_chat_lobby_intern.c | |||
@@ -75,13 +75,11 @@ cont_lobby_identity_create (void *cls, | |||
75 | { | 75 | { |
76 | struct GNUNET_CHAT_Lobby *lobby = cls; | 76 | struct GNUNET_CHAT_Lobby *lobby = cls; |
77 | 77 | ||
78 | char *name; | ||
79 | |||
80 | if (emsg) | 78 | if (emsg) |
81 | { | 79 | { |
82 | handle_send_internal_message( | 80 | handle_send_internal_message( |
83 | lobby->handle, | 81 | lobby->handle, |
84 | NULL, | 82 | lobby->context, |
85 | GNUNET_CHAT_FLAG_WARNING, | 83 | GNUNET_CHAT_FLAG_WARNING, |
86 | emsg | 84 | emsg |
87 | ); | 85 | ); |
@@ -89,30 +87,15 @@ cont_lobby_identity_create (void *cls, | |||
89 | return; | 87 | return; |
90 | } | 88 | } |
91 | 89 | ||
92 | struct GNUNET_MESSENGER_Room *room = GNUNET_MESSENGER_open_room( | 90 | const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key( |
93 | lobby->handle->messenger, | 91 | lobby->context->room |
94 | NULL | ||
95 | ); | 92 | ); |
96 | 93 | ||
97 | if (!room) | 94 | struct GNUNET_MESSENGER_RoomEntryRecord room; |
98 | goto destroy_identity; | 95 | GNUNET_CRYPTO_get_peer_identity(lobby->handle->cfg, &(room.door)); |
99 | 96 | GNUNET_memcpy(&(room.key), key, sizeof(room.key)); | |
100 | const struct GNUNET_HashCode *key = GNUNET_MESSENGER_room_get_key(room); | ||
101 | |||
102 | lobby->context = context_create_from_room(lobby->handle, room); | ||
103 | |||
104 | handle_send_room_name(lobby->handle, room); | ||
105 | 97 | ||
106 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( | 98 | struct GNUNET_GNSRECORD_Data data [1]; |
107 | lobby->handle->contexts, key, lobby->context, | ||
108 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | ||
109 | { | ||
110 | context_destroy(lobby->context); | ||
111 | lobby->context = NULL; | ||
112 | goto destroy_identity; | ||
113 | } | ||
114 | |||
115 | struct GNUNET_GNSRECORD_Data data [3]; | ||
116 | data[0].record_type = GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY; | 99 | data[0].record_type = GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY; |
117 | data[0].data = &room; | 100 | data[0].data = &room; |
118 | data[0].data_size = sizeof(room); | 101 | data[0].data_size = sizeof(room); |
@@ -143,7 +126,7 @@ cont_lobby_identity_create (void *cls, | |||
143 | 126 | ||
144 | context_write_records(lobby->context); | 127 | context_write_records(lobby->context); |
145 | 128 | ||
146 | destroy_identity: | 129 | char *name; |
147 | util_lobby_name(key, &name); | 130 | util_lobby_name(key, &name); |
148 | 131 | ||
149 | lobby->op_delete = GNUNET_IDENTITY_delete( | 132 | lobby->op_delete = GNUNET_IDENTITY_delete( |