diff options
author | Jacki <jacki@thejackimonster.de> | 2024-05-06 00:11:44 +0200 |
---|---|---|
committer | Jacki <jacki@thejackimonster.de> | 2024-05-06 00:11:44 +0200 |
commit | c024d2357a996afbaa6f0efa7fa6b6675212065a (patch) | |
tree | 2ade62e149792f550ac995fd4ddaa244b58a797b | |
parent | 02f4a275a04968a889c6bae1a18caaf35cca9168 (diff) | |
download | libgnunetchat-c024d2357a996afbaa6f0efa7fa6b6675212065a.tar.gz libgnunetchat-c024d2357a996afbaa6f0efa7fa6b6675212065a.zip |
Fix message test case and leaving groups
Signed-off-by: Jacki <jacki@thejackimonster.de>
-rw-r--r-- | src/gnunet_chat_context.c | 25 | ||||
-rw-r--r-- | src/gnunet_chat_context.h | 15 | ||||
-rw-r--r-- | src/gnunet_chat_handle.c | 14 | ||||
-rw-r--r-- | src/gnunet_chat_lib.c | 9 | ||||
-rw-r--r-- | src/gnunet_chat_lib_intern.c | 6 |
5 files changed, 50 insertions, 19 deletions
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c index 6c83dd0..8b508d8 100644 --- a/src/gnunet_chat_context.c +++ b/src/gnunet_chat_context.c | |||
@@ -189,7 +189,8 @@ context_request_message (struct GNUNET_CHAT_Context* context, | |||
189 | 189 | ||
190 | void | 190 | void |
191 | context_update_room (struct GNUNET_CHAT_Context *context, | 191 | context_update_room (struct GNUNET_CHAT_Context *context, |
192 | struct GNUNET_MESSENGER_Room *room) | 192 | struct GNUNET_MESSENGER_Room *room, |
193 | enum GNUNET_GenericReturnValue record) | ||
193 | { | 194 | { |
194 | GNUNET_assert(context); | 195 | GNUNET_assert(context); |
195 | 196 | ||
@@ -217,9 +218,12 @@ context_update_room (struct GNUNET_CHAT_Context *context, | |||
217 | GNUNET_CONTAINER_multihashmap_clear(context->invites); | 218 | GNUNET_CONTAINER_multihashmap_clear(context->invites); |
218 | GNUNET_CONTAINER_multihashmap_clear(context->files); | 219 | GNUNET_CONTAINER_multihashmap_clear(context->files); |
219 | 220 | ||
221 | if (context->room) | ||
222 | context_delete(context, GNUNET_YES); | ||
223 | |||
220 | context->room = room; | 224 | context->room = room; |
221 | 225 | ||
222 | if (!(context->room)) | 226 | if ((!(context->room)) || (GNUNET_YES != record)) |
223 | return; | 227 | return; |
224 | 228 | ||
225 | context_write_records(context); | 229 | context_write_records(context); |
@@ -227,7 +231,7 @@ context_update_room (struct GNUNET_CHAT_Context *context, | |||
227 | 231 | ||
228 | void | 232 | void |
229 | context_update_nick (struct GNUNET_CHAT_Context *context, | 233 | context_update_nick (struct GNUNET_CHAT_Context *context, |
230 | const char *nick) | 234 | const char *nick) |
231 | { | 235 | { |
232 | GNUNET_assert(context); | 236 | GNUNET_assert(context); |
233 | 237 | ||
@@ -484,3 +488,18 @@ skip_record_data: | |||
484 | 488 | ||
485 | GNUNET_free(label); | 489 | GNUNET_free(label); |
486 | } | 490 | } |
491 | |||
492 | void | ||
493 | context_delete (struct GNUNET_CHAT_Context *context, | ||
494 | enum GNUNET_GenericReturnValue exit) | ||
495 | { | ||
496 | GNUNET_assert((context) && (context->room)); | ||
497 | |||
498 | context->deleted = GNUNET_YES; | ||
499 | context_write_records(context); | ||
500 | |||
501 | if (GNUNET_YES != exit) | ||
502 | return; | ||
503 | |||
504 | GNUNET_MESSENGER_close_room(context->room); | ||
505 | } | ||
diff --git a/src/gnunet_chat_context.h b/src/gnunet_chat_context.h index a537413..82a0860 100644 --- a/src/gnunet_chat_context.h +++ b/src/gnunet_chat_context.h | |||
@@ -115,10 +115,12 @@ context_request_message (struct GNUNET_CHAT_Context* context, | |||
115 | * | 115 | * |
116 | * @param[in,out] context Chat context | 116 | * @param[in,out] context Chat context |
117 | * @param[in,out] room Messenger room | 117 | * @param[in,out] room Messenger room |
118 | * @param[in] record Write changes to records | ||
118 | */ | 119 | */ |
119 | void | 120 | void |
120 | context_update_room (struct GNUNET_CHAT_Context *context, | 121 | context_update_room (struct GNUNET_CHAT_Context *context, |
121 | struct GNUNET_MESSENGER_Room *room); | 122 | struct GNUNET_MESSENGER_Room *room, |
123 | enum GNUNET_GenericReturnValue record); | ||
122 | 124 | ||
123 | /** | 125 | /** |
124 | * Updates the <i>nick</i> of a selected chat <i>context</i>. | 126 | * Updates the <i>nick</i> of a selected chat <i>context</i>. |
@@ -165,4 +167,15 @@ context_read_records (struct GNUNET_CHAT_Context *context, | |||
165 | void | 167 | void |
166 | context_write_records (struct GNUNET_CHAT_Context *context); | 168 | context_write_records (struct GNUNET_CHAT_Context *context); |
167 | 169 | ||
170 | /** | ||
171 | * Removes the data from a selected chat <i>context</i> from | ||
172 | * the namestore and closes its room optionally. | ||
173 | * | ||
174 | * @param[in,out] context Chat context | ||
175 | * @param[in] exit Closing its room | ||
176 | */ | ||
177 | void | ||
178 | context_delete (struct GNUNET_CHAT_Context *context, | ||
179 | enum GNUNET_GenericReturnValue exit); | ||
180 | |||
168 | #endif /* GNUNET_CHAT_CONTEXT_H_ */ | 181 | #endif /* GNUNET_CHAT_CONTEXT_H_ */ |
diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c index 85c6338..3305ff8 100644 --- a/src/gnunet_chat_handle.c +++ b/src/gnunet_chat_handle.c | |||
@@ -900,8 +900,7 @@ check_type: | |||
900 | check.contact, | 900 | check.contact, |
901 | context))) | 901 | context))) |
902 | { | 902 | { |
903 | context->deleted = GNUNET_YES; | 903 | context_delete(context, GNUNET_NO); |
904 | context_write_records(context); | ||
905 | 904 | ||
906 | context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; | 905 | context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; |
907 | context->deleted = GNUNET_NO; | 906 | context->deleted = GNUNET_NO; |
@@ -910,8 +909,7 @@ check_type: | |||
910 | } | 909 | } |
911 | else if (checks >= minimum_amount_of_other_members_in_group) | 910 | else if (checks >= minimum_amount_of_other_members_in_group) |
912 | { | 911 | { |
913 | context->deleted = GNUNET_YES; | 912 | context_delete(context, GNUNET_NO); |
914 | context_write_records(context); | ||
915 | 913 | ||
916 | context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP; | 914 | context->type = GNUNET_CHAT_CONTEXT_TYPE_GROUP; |
917 | context->deleted = GNUNET_NO; | 915 | context->deleted = GNUNET_NO; |
@@ -1033,7 +1031,7 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, | |||
1033 | &key | 1031 | &key |
1034 | ); | 1032 | ); |
1035 | 1033 | ||
1036 | if (context) | 1034 | if ((context) && (context->room)) |
1037 | { | 1035 | { |
1038 | context_read_records(context, label, count, data); | 1036 | context_read_records(context, label, count, data); |
1039 | return NULL; | 1037 | return NULL; |
@@ -1047,6 +1045,12 @@ handle_process_records (struct GNUNET_CHAT_Handle *handle, | |||
1047 | 1045 | ||
1048 | if (!room) | 1046 | if (!room) |
1049 | return NULL; | 1047 | return NULL; |
1048 | else if (context) | ||
1049 | { | ||
1050 | context_update_room(context, room, GNUNET_NO); | ||
1051 | context_read_records(context, label, count, data); | ||
1052 | return NULL; | ||
1053 | } | ||
1050 | 1054 | ||
1051 | context = context_create_from_room(handle, room); | 1055 | context = context_create_from_room(handle, room); |
1052 | context_read_records(context, label, count, data); | 1056 | context_read_records(context, label, count, data); |
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c index ee7d4a5..7577a6c 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -1080,11 +1080,8 @@ GNUNET_CHAT_contact_delete (struct GNUNET_CHAT_Contact *contact) | |||
1080 | contact->handle->contexts, key, contact->context | 1080 | contact->handle->contexts, key, contact->context |
1081 | ); | 1081 | ); |
1082 | 1082 | ||
1083 | GNUNET_MESSENGER_close_room(contact->context->room); | 1083 | context_delete(contact->context, GNUNET_YES); |
1084 | 1084 | ||
1085 | contact->context->deleted = GNUNET_YES; | ||
1086 | context_write_records(contact->context); | ||
1087 | |||
1088 | context_destroy(contact->context); | 1085 | context_destroy(contact->context); |
1089 | contact_destroy(contact); | 1086 | contact_destroy(contact); |
1090 | return GNUNET_OK; | 1087 | return GNUNET_OK; |
@@ -1567,7 +1564,7 @@ GNUNET_CHAT_context_request (struct GNUNET_CHAT_Context *context) | |||
1567 | if (!room) | 1564 | if (!room) |
1568 | goto cleanup_contact; | 1565 | goto cleanup_contact; |
1569 | 1566 | ||
1570 | context_update_room(context, room); | 1567 | context_update_room(context, room, GNUNET_YES); |
1571 | 1568 | ||
1572 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( | 1569 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( |
1573 | handle->contexts, &key, context, | 1570 | handle->contexts, &key, context, |
diff --git a/src/gnunet_chat_lib_intern.c b/src/gnunet_chat_lib_intern.c index 1f92f07..ad45798 100644 --- a/src/gnunet_chat_lib_intern.c +++ b/src/gnunet_chat_lib_intern.c | |||
@@ -294,14 +294,12 @@ task_group_destruction (void *cls) | |||
294 | group->context->room | 294 | group->context->room |
295 | ), sizeof(key)); | 295 | ), sizeof(key)); |
296 | 296 | ||
297 | GNUNET_MESSENGER_close_room(group->context->room); | ||
298 | group->context->room = NULL; | ||
299 | |||
300 | GNUNET_CONTAINER_multihashmap_remove( | 297 | GNUNET_CONTAINER_multihashmap_remove( |
301 | group->handle->groups, &key, group | 298 | group->handle->groups, &key, group |
302 | ); | 299 | ); |
303 | 300 | ||
304 | context_write_records(group->context); | 301 | context_delete(group->context, GNUNET_YES); |
302 | |||
305 | group->destruction = NULL; | 303 | group->destruction = NULL; |
306 | 304 | ||
307 | group_destroy(group); | 305 | group_destroy(group); |