diff options
author | Jacki <jacki@thejackimonster.de> | 2024-02-10 05:06:43 +0100 |
---|---|---|
committer | Jacki <jacki@thejackimonster.de> | 2024-02-10 05:06:43 +0100 |
commit | ff5b51e8b00440dcf7ee252451947ce0622fd9c1 (patch) | |
tree | 208ada9766122094850b02dca9f79c8f324618cb /src/gnunet_chat_context.c | |
parent | 8842c8b412921fe9318d2caf0a418257b72cf31d (diff) | |
download | libgnunetchat-ff5b51e8b00440dcf7ee252451947ce0622fd9c1.tar.gz libgnunetchat-ff5b51e8b00440dcf7ee252451947ce0622fd9c1.zip |
Add dependencies for messages to handle reverse order from requests
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat (limited to 'src/gnunet_chat_context.c')
-rw-r--r-- | src/gnunet_chat_context.c | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c index ea188e7..128fe8b 100644 --- a/src/gnunet_chat_context.c +++ b/src/gnunet_chat_context.c | |||
@@ -32,39 +32,50 @@ | |||
32 | static const unsigned int initial_map_size_of_room = 8; | 32 | static const unsigned int initial_map_size_of_room = 8; |
33 | static const unsigned int initial_map_size_of_contact = 4; | 33 | static const unsigned int initial_map_size_of_contact = 4; |
34 | 34 | ||
35 | struct GNUNET_CHAT_Context* | 35 | static void |
36 | context_create_from_room (struct GNUNET_CHAT_Handle *handle, | 36 | init_new_context (struct GNUNET_CHAT_Context *context, |
37 | struct GNUNET_MESSENGER_Room *room) | 37 | unsigned int initial_map_size) |
38 | { | 38 | { |
39 | GNUNET_assert((handle) && (room)); | 39 | GNUNET_assert(context); |
40 | |||
41 | struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context); | ||
42 | |||
43 | context->handle = handle; | ||
44 | 40 | ||
45 | context->type = GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN; | ||
46 | context->nick[0] = '\0'; | 41 | context->nick[0] = '\0'; |
47 | context->topic = NULL; | 42 | context->topic = NULL; |
48 | context->deleted = GNUNET_NO; | 43 | context->deleted = GNUNET_NO; |
49 | 44 | ||
50 | context->timestamps = GNUNET_CONTAINER_multishortmap_create( | 45 | context->timestamps = GNUNET_CONTAINER_multishortmap_create( |
51 | initial_map_size_of_room, GNUNET_NO); | 46 | initial_map_size, GNUNET_NO); |
47 | context->dependencies = GNUNET_CONTAINER_multihashmap_create( | ||
48 | initial_map_size, GNUNET_NO); | ||
52 | context->messages = GNUNET_CONTAINER_multihashmap_create( | 49 | context->messages = GNUNET_CONTAINER_multihashmap_create( |
53 | initial_map_size_of_room, GNUNET_NO); | 50 | initial_map_size, GNUNET_NO); |
54 | context->invites = GNUNET_CONTAINER_multihashmap_create( | 51 | context->invites = GNUNET_CONTAINER_multihashmap_create( |
55 | initial_map_size_of_room, GNUNET_NO); | 52 | initial_map_size, GNUNET_NO); |
56 | context->files = GNUNET_CONTAINER_multihashmap_create( | 53 | context->files = GNUNET_CONTAINER_multihashmap_create( |
57 | initial_map_size_of_room, GNUNET_NO); | 54 | initial_map_size, GNUNET_NO); |
58 | 55 | ||
59 | context->room = room; | ||
60 | context->contact = NULL; | ||
61 | |||
62 | context->user_pointer = NULL; | 56 | context->user_pointer = NULL; |
63 | 57 | ||
64 | context->member_pointers = GNUNET_CONTAINER_multishortmap_create( | 58 | context->member_pointers = GNUNET_CONTAINER_multishortmap_create( |
65 | initial_map_size_of_room, GNUNET_NO); | 59 | initial_map_size, GNUNET_NO); |
66 | 60 | ||
67 | context->query = NULL; | 61 | context->query = NULL; |
62 | } | ||
63 | |||
64 | struct GNUNET_CHAT_Context* | ||
65 | context_create_from_room (struct GNUNET_CHAT_Handle *handle, | ||
66 | struct GNUNET_MESSENGER_Room *room) | ||
67 | { | ||
68 | GNUNET_assert((handle) && (room)); | ||
69 | |||
70 | struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context); | ||
71 | |||
72 | context->handle = handle; | ||
73 | context->type = GNUNET_CHAT_CONTEXT_TYPE_UNKNOWN; | ||
74 | |||
75 | init_new_context(context, initial_map_size_of_room); | ||
76 | |||
77 | context->room = room; | ||
78 | context->contact = NULL; | ||
68 | 79 | ||
69 | return context; | 80 | return context; |
70 | } | 81 | } |
@@ -78,31 +89,13 @@ context_create_from_contact (struct GNUNET_CHAT_Handle *handle, | |||
78 | struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context); | 89 | struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context); |
79 | 90 | ||
80 | context->handle = handle; | 91 | context->handle = handle; |
81 | |||
82 | context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; | 92 | context->type = GNUNET_CHAT_CONTEXT_TYPE_CONTACT; |
83 | context->nick[0] = '\0'; | ||
84 | context->topic = NULL; | ||
85 | context->deleted = GNUNET_NO; | ||
86 | 93 | ||
87 | context->timestamps = GNUNET_CONTAINER_multishortmap_create( | 94 | init_new_context(context, initial_map_size_of_contact); |
88 | initial_map_size_of_contact, GNUNET_NO); | ||
89 | context->messages = GNUNET_CONTAINER_multihashmap_create( | ||
90 | initial_map_size_of_contact, GNUNET_NO); | ||
91 | context->invites = GNUNET_CONTAINER_multihashmap_create( | ||
92 | initial_map_size_of_contact, GNUNET_NO); | ||
93 | context->files = GNUNET_CONTAINER_multihashmap_create( | ||
94 | initial_map_size_of_contact, GNUNET_NO); | ||
95 | 95 | ||
96 | context->room = NULL; | 96 | context->room = NULL; |
97 | context->contact = contact; | 97 | context->contact = contact; |
98 | 98 | ||
99 | context->user_pointer = NULL; | ||
100 | |||
101 | context->member_pointers = GNUNET_CONTAINER_multishortmap_create( | ||
102 | initial_map_size_of_contact, GNUNET_NO); | ||
103 | |||
104 | context->query = NULL; | ||
105 | |||
106 | return context; | 99 | return context; |
107 | } | 100 | } |
108 | 101 | ||
@@ -112,6 +105,7 @@ context_destroy (struct GNUNET_CHAT_Context *context) | |||
112 | GNUNET_assert( | 105 | GNUNET_assert( |
113 | (context) && | 106 | (context) && |
114 | (context->timestamps) && | 107 | (context->timestamps) && |
108 | (context->dependencies) && | ||
115 | (context->messages) && | 109 | (context->messages) && |
116 | (context->invites) && | 110 | (context->invites) && |
117 | (context->files) | 111 | (context->files) |
@@ -124,6 +118,7 @@ context_destroy (struct GNUNET_CHAT_Context *context) | |||
124 | context->timestamps, it_destroy_context_timestamps, NULL | 118 | context->timestamps, it_destroy_context_timestamps, NULL |
125 | ); | 119 | ); |
126 | 120 | ||
121 | GNUNET_CONTAINER_multihashmap_clear(context->dependencies); | ||
127 | GNUNET_CONTAINER_multihashmap_iterate( | 122 | GNUNET_CONTAINER_multihashmap_iterate( |
128 | context->messages, it_destroy_context_messages, NULL | 123 | context->messages, it_destroy_context_messages, NULL |
129 | ); | 124 | ); |
@@ -135,6 +130,7 @@ context_destroy (struct GNUNET_CHAT_Context *context) | |||
135 | GNUNET_CONTAINER_multishortmap_destroy(context->member_pointers); | 130 | GNUNET_CONTAINER_multishortmap_destroy(context->member_pointers); |
136 | 131 | ||
137 | GNUNET_CONTAINER_multishortmap_destroy(context->timestamps); | 132 | GNUNET_CONTAINER_multishortmap_destroy(context->timestamps); |
133 | GNUNET_CONTAINER_multihashmap_destroy(context->dependencies); | ||
138 | GNUNET_CONTAINER_multihashmap_destroy(context->messages); | 134 | GNUNET_CONTAINER_multihashmap_destroy(context->messages); |
139 | GNUNET_CONTAINER_multihashmap_destroy(context->invites); | 135 | GNUNET_CONTAINER_multihashmap_destroy(context->invites); |
140 | GNUNET_CONTAINER_multihashmap_destroy(context->files); | 136 | GNUNET_CONTAINER_multihashmap_destroy(context->files); |