aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/messenger_api_room.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/messenger_api_room.c')
-rw-r--r--src/messenger/messenger_api_room.c75
1 files changed, 51 insertions, 24 deletions
diff --git a/src/messenger/messenger_api_room.c b/src/messenger/messenger_api_room.c
index 0d9237a2e..6e2d33f48 100644
--- a/src/messenger/messenger_api_room.c
+++ b/src/messenger/messenger_api_room.c
@@ -28,7 +28,8 @@
28#include "messenger_api_handle.h" 28#include "messenger_api_handle.h"
29 29
30struct GNUNET_MESSENGER_Room* 30struct GNUNET_MESSENGER_Room*
31create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key) 31create_room (struct GNUNET_MESSENGER_Handle *handle,
32 const struct GNUNET_HashCode *key)
32{ 33{
33 GNUNET_assert((handle) && (key)); 34 GNUNET_assert((handle) && (key));
34 35
@@ -49,7 +50,9 @@ create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCod
49} 50}
50 51
51static int 52static int
52iterate_destroy_message (void *cls, const struct GNUNET_HashCode *key, void *value) 53iterate_destroy_message (void *cls,
54 const struct GNUNET_HashCode *key,
55 void *value)
53{ 56{
54 struct GNUNET_MESSENGER_RoomMessageEntry *entry = value; 57 struct GNUNET_MESSENGER_RoomMessageEntry *entry = value;
55 58
@@ -83,7 +86,8 @@ destroy_room (struct GNUNET_MESSENGER_Room *room)
83} 86}
84 87
85const struct GNUNET_MESSENGER_Message* 88const struct GNUNET_MESSENGER_Message*
86get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash) 89get_room_message (const struct GNUNET_MESSENGER_Room *room,
90 const struct GNUNET_HashCode *hash)
87{ 91{
88 GNUNET_assert((room) && (hash)); 92 GNUNET_assert((room) && (hash));
89 93
@@ -95,7 +99,8 @@ get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_
95} 99}
96 100
97struct GNUNET_MESSENGER_Contact* 101struct GNUNET_MESSENGER_Contact*
98get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash) 102get_room_sender (const struct GNUNET_MESSENGER_Room *room,
103 const struct GNUNET_HashCode *hash)
99{ 104{
100 GNUNET_assert((room) && (hash)); 105 GNUNET_assert((room) && (hash));
101 106
@@ -107,8 +112,10 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_H
107} 112}
108 113
109static struct GNUNET_MESSENGER_Contact* 114static struct GNUNET_MESSENGER_Contact*
110handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 115handle_join_message (struct GNUNET_MESSENGER_Room *room,
111 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 116 struct GNUNET_MESSENGER_Contact *sender,
117 const struct GNUNET_MESSENGER_Message *message,
118 const struct GNUNET_HashCode *hash)
112{ 119{
113 if (!sender) 120 if (!sender)
114 { 121 {
@@ -129,8 +136,10 @@ handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
129} 136}
130 137
131static void 138static void
132handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 139handle_leave_message (struct GNUNET_MESSENGER_Room *room,
133 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 140 struct GNUNET_MESSENGER_Contact *sender,
141 const struct GNUNET_MESSENGER_Message *message,
142 const struct GNUNET_HashCode *hash)
134{ 143{
135 if ((!sender) || 144 if ((!sender) ||
136 (GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender))) 145 (GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender)))
@@ -144,8 +153,10 @@ handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGE
144} 153}
145 154
146static void 155static void
147handle_name_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 156handle_name_message (struct GNUNET_MESSENGER_Room *room,
148 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 157 struct GNUNET_MESSENGER_Contact *sender,
158 const struct GNUNET_MESSENGER_Message *message,
159 const struct GNUNET_HashCode *hash)
149{ 160{
150 if (!sender) 161 if (!sender)
151 return; 162 return;
@@ -154,8 +165,10 @@ handle_name_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
154} 165}
155 166
156static void 167static void
157handle_key_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 168handle_key_message (struct GNUNET_MESSENGER_Room *room,
158 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 169 struct GNUNET_MESSENGER_Contact *sender,
170 const struct GNUNET_MESSENGER_Message *message,
171 const struct GNUNET_HashCode *hash)
159{ 172{
160 if (!sender) 173 if (!sender)
161 return; 174 return;
@@ -169,8 +182,10 @@ handle_key_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_
169} 182}
170 183
171static void 184static void
172handle_id_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 185handle_id_message (struct GNUNET_MESSENGER_Room *room,
173 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 186 struct GNUNET_MESSENGER_Contact *sender,
187 const struct GNUNET_MESSENGER_Message *message,
188 const struct GNUNET_HashCode *hash)
174{ 189{
175 if ((!sender) || 190 if ((!sender) ||
176 (GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender)) || 191 (GNUNET_YES != GNUNET_CONTAINER_multishortmap_remove(room->members, &(message->header.sender_id), sender)) ||
@@ -188,8 +203,10 @@ handle_id_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_C
188} 203}
189 204
190static void 205static void
191handle_miss_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 206handle_miss_message (struct GNUNET_MESSENGER_Room *room,
192 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 207 struct GNUNET_MESSENGER_Contact *sender,
208 const struct GNUNET_MESSENGER_Message *message,
209 const struct GNUNET_HashCode *hash)
193{ 210{
194 if ((room->contact_id) && (0 == GNUNET_memcmp(&(message->header.sender_id), room->contact_id))) 211 if ((room->contact_id) && (0 == GNUNET_memcmp(&(message->header.sender_id), room->contact_id)))
195 { 212 {
@@ -201,8 +218,10 @@ handle_miss_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER
201} 218}
202 219
203static void 220static void
204handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 221handle_delete_message (struct GNUNET_MESSENGER_Room *room,
205 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 222 struct GNUNET_MESSENGER_Contact *sender,
223 const struct GNUNET_MESSENGER_Message *message,
224 const struct GNUNET_HashCode *hash)
206{ 225{
207 struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_CONTAINER_multihashmap_get ( 226 struct GNUNET_MESSENGER_RoomMessageEntry *entry = GNUNET_CONTAINER_multihashmap_get (
208 room->messages, &(message->body.deletion.hash) 227 room->messages, &(message->body.deletion.hash)
@@ -217,8 +236,10 @@ handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENG
217} 236}
218 237
219struct GNUNET_MESSENGER_Contact* 238struct GNUNET_MESSENGER_Contact*
220handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, 239handle_room_message (struct GNUNET_MESSENGER_Room *room,
221 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) 240 struct GNUNET_MESSENGER_Contact *sender,
241 const struct GNUNET_MESSENGER_Message *message,
242 const struct GNUNET_HashCode *hash)
222{ 243{
223 if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash)) 244 if (GNUNET_NO != GNUNET_CONTAINER_multihashmap_contains (room->messages, hash))
224 return sender; 245 return sender;
@@ -276,7 +297,9 @@ struct GNUNET_MESSENGER_MemberCall
276}; 297};
277 298
278static int 299static int
279iterate_local_members (void* cls, const struct GNUNET_ShortHashCode *key, void *value) 300iterate_local_members (void* cls,
301 const struct GNUNET_ShortHashCode *key,
302 void *value)
280{ 303{
281 struct GNUNET_MESSENGER_MemberCall *call = cls; 304 struct GNUNET_MESSENGER_MemberCall *call = cls;
282 struct GNUNET_MESSENGER_Contact *contact = value; 305 struct GNUNET_MESSENGER_Contact *contact = value;
@@ -285,7 +308,8 @@ iterate_local_members (void* cls, const struct GNUNET_ShortHashCode *key, void *
285} 308}
286 309
287int 310int
288iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, 311iterate_room_members (struct GNUNET_MESSENGER_Room *room,
312 GNUNET_MESSENGER_MemberCallback callback,
289 void* cls) 313 void* cls)
290{ 314{
291 GNUNET_assert(room); 315 GNUNET_assert(room);
@@ -311,7 +335,9 @@ struct GNUNET_MESSENGER_MemberFind
311}; 335};
312 336
313static int 337static int
314iterate_find_member (void* cls, const struct GNUNET_ShortHashCode *key, void *value) 338iterate_find_member (void* cls,
339 const struct GNUNET_ShortHashCode *key,
340 void *value)
315{ 341{
316 struct GNUNET_MESSENGER_MemberFind *find = cls; 342 struct GNUNET_MESSENGER_MemberFind *find = cls;
317 struct GNUNET_MESSENGER_Contact *contact = value; 343 struct GNUNET_MESSENGER_Contact *contact = value;
@@ -326,7 +352,8 @@ iterate_find_member (void* cls, const struct GNUNET_ShortHashCode *key, void *va
326} 352}
327 353
328int 354int
329find_room_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact) 355find_room_member (const struct GNUNET_MESSENGER_Room *room,
356 const struct GNUNET_MESSENGER_Contact *contact)
330{ 357{
331 GNUNET_assert(room); 358 GNUNET_assert(room);
332 359