diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger_handle.c')
-rw-r--r-- | src/messenger/gnunet-service-messenger_handle.c | 79 |
1 files changed, 55 insertions, 24 deletions
diff --git a/src/messenger/gnunet-service-messenger_handle.c b/src/messenger/gnunet-service-messenger_handle.c index d7007dbf6..2095f8b29 100644 --- a/src/messenger/gnunet-service-messenger_handle.c +++ b/src/messenger/gnunet-service-messenger_handle.c | |||
@@ -31,7 +31,8 @@ | |||
31 | #include "messenger_api_util.h" | 31 | #include "messenger_api_util.h" |
32 | 32 | ||
33 | struct GNUNET_MESSENGER_SrvHandle* | 33 | struct GNUNET_MESSENGER_SrvHandle* |
34 | create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq) | 34 | create_handle (struct GNUNET_MESSENGER_Service *service, |
35 | struct GNUNET_MQ_Handle *mq) | ||
35 | { | 36 | { |
36 | GNUNET_assert((service) && (mq)); | 37 | GNUNET_assert((service) && (mq)); |
37 | 38 | ||
@@ -49,7 +50,9 @@ create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle | |||
49 | } | 50 | } |
50 | 51 | ||
51 | int | 52 | int |
52 | iterate_free_member_ids (void *cls, const struct GNUNET_HashCode *key, void *value) | 53 | iterate_free_member_ids (void *cls, |
54 | const struct GNUNET_HashCode *key, | ||
55 | void *value) | ||
53 | { | 56 | { |
54 | GNUNET_free(value); | 57 | GNUNET_free(value); |
55 | 58 | ||
@@ -74,7 +77,9 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle) | |||
74 | } | 77 | } |
75 | 78 | ||
76 | void | 79 | void |
77 | get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir) | 80 | get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, |
81 | const char *name, | ||
82 | char **dir) | ||
78 | { | 83 | { |
79 | GNUNET_assert((handle) && (dir)); | 84 | GNUNET_assert((handle) && (dir)); |
80 | 85 | ||
@@ -87,7 +92,8 @@ get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const c | |||
87 | } | 92 | } |
88 | 93 | ||
89 | static int | 94 | static int |
90 | create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 95 | create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, |
96 | const struct GNUNET_HashCode *key) | ||
91 | { | 97 | { |
92 | GNUNET_assert((handle) && (key)); | 98 | GNUNET_assert((handle) && (key)); |
93 | 99 | ||
@@ -112,7 +118,8 @@ create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const | |||
112 | } | 118 | } |
113 | 119 | ||
114 | const struct GNUNET_ShortHashCode* | 120 | const struct GNUNET_ShortHashCode* |
115 | get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 121 | get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, |
122 | const struct GNUNET_HashCode *key) | ||
116 | { | 123 | { |
117 | GNUNET_assert((handle) && (key)); | 124 | GNUNET_assert((handle) && (key)); |
118 | 125 | ||
@@ -120,7 +127,8 @@ get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const str | |||
120 | } | 127 | } |
121 | 128 | ||
122 | int | 129 | int |
123 | change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 130 | change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, |
131 | const struct GNUNET_HashCode *key, | ||
124 | const struct GNUNET_ShortHashCode *unique_id) | 132 | const struct GNUNET_ShortHashCode *unique_id) |
125 | { | 133 | { |
126 | GNUNET_assert((handle) && (key) && (unique_id)); | 134 | GNUNET_assert((handle) && (key) && (unique_id)); |
@@ -165,7 +173,8 @@ send_message_to_client: | |||
165 | } | 173 | } |
166 | 174 | ||
167 | static void | 175 | static void |
168 | change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | 176 | change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, |
177 | const char *name) | ||
169 | { | 178 | { |
170 | GNUNET_assert(handle); | 179 | GNUNET_assert(handle); |
171 | 180 | ||
@@ -192,7 +201,8 @@ change_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | |||
192 | } | 201 | } |
193 | 202 | ||
194 | static void | 203 | static void |
195 | change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego) | 204 | change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, |
205 | const struct GNUNET_MESSENGER_Ego *ego) | ||
196 | { | 206 | { |
197 | GNUNET_assert(handle); | 207 | GNUNET_assert(handle); |
198 | 208 | ||
@@ -222,7 +232,9 @@ struct GNUNET_MESSENGER_MessageHandle | |||
222 | }; | 232 | }; |
223 | 233 | ||
224 | static int | 234 | static int |
225 | iterate_send_message (void *cls, const struct GNUNET_HashCode *key, void *value) | 235 | iterate_send_message (void *cls, |
236 | const struct GNUNET_HashCode *key, | ||
237 | void *value) | ||
226 | { | 238 | { |
227 | struct GNUNET_MESSENGER_MessageHandle *msg_handle = cls; | 239 | struct GNUNET_MESSENGER_MessageHandle *msg_handle = cls; |
228 | 240 | ||
@@ -232,7 +244,8 @@ iterate_send_message (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
232 | } | 244 | } |
233 | 245 | ||
234 | void | 246 | void |
235 | set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego) | 247 | set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, |
248 | const struct GNUNET_MESSENGER_Ego *ego) | ||
236 | { | 249 | { |
237 | GNUNET_assert((handle) && (ego)); | 250 | GNUNET_assert((handle) && (ego)); |
238 | 251 | ||
@@ -271,7 +284,9 @@ get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle) | |||
271 | } | 284 | } |
272 | 285 | ||
273 | static void | 286 | static void |
274 | callback_setup_handle_name (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) | 287 | callback_setup_handle_name (void *cls, |
288 | const char *name, | ||
289 | const struct GNUNET_MESSENGER_Ego *ego) | ||
275 | { | 290 | { |
276 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 291 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
277 | 292 | ||
@@ -285,7 +300,8 @@ callback_setup_handle_name (void *cls, const char *name, const struct GNUNET_MES | |||
285 | } | 300 | } |
286 | 301 | ||
287 | void | 302 | void |
288 | setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | 303 | setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, |
304 | const char *name) | ||
289 | { | 305 | { |
290 | GNUNET_assert(handle); | 306 | GNUNET_assert(handle); |
291 | 307 | ||
@@ -295,7 +311,9 @@ setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | |||
295 | } | 311 | } |
296 | 312 | ||
297 | static void | 313 | static void |
298 | callback_update_handle (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) | 314 | callback_update_handle (void *cls, |
315 | const char *name, | ||
316 | const struct GNUNET_MESSENGER_Ego *ego) | ||
299 | { | 317 | { |
300 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 318 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
301 | 319 | ||
@@ -326,7 +344,9 @@ update_handle (struct GNUNET_MESSENGER_SrvHandle *handle) | |||
326 | } | 344 | } |
327 | 345 | ||
328 | static void | 346 | static void |
329 | callback_set_handle_name (void *cls, const char *name, const struct GNUNET_MESSENGER_Ego *ego) | 347 | callback_set_handle_name (void *cls, |
348 | const char *name, | ||
349 | const struct GNUNET_MESSENGER_Ego *ego) | ||
330 | { | 350 | { |
331 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 351 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
332 | 352 | ||
@@ -383,7 +403,8 @@ callback_set_handle_name (void *cls, const char *name, const struct GNUNET_MESSE | |||
383 | } | 403 | } |
384 | 404 | ||
385 | void | 405 | void |
386 | set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | 406 | set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, |
407 | const char *name) | ||
387 | { | 408 | { |
388 | GNUNET_assert(handle); | 409 | GNUNET_assert(handle); |
389 | 410 | ||
@@ -403,7 +424,8 @@ set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name) | |||
403 | } | 424 | } |
404 | 425 | ||
405 | int | 426 | int |
406 | open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 427 | open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
428 | const struct GNUNET_HashCode *key) | ||
407 | { | 429 | { |
408 | GNUNET_assert((handle) && (key)); | 430 | GNUNET_assert((handle) && (key)); |
409 | 431 | ||
@@ -414,7 +436,8 @@ open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET | |||
414 | } | 436 | } |
415 | 437 | ||
416 | int | 438 | int |
417 | entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, | 439 | entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
440 | const struct GNUNET_PeerIdentity *door, | ||
418 | const struct GNUNET_HashCode *key) | 441 | const struct GNUNET_HashCode *key) |
419 | { | 442 | { |
420 | GNUNET_assert((handle) && (door) && (key)); | 443 | GNUNET_assert((handle) && (door) && (key)); |
@@ -426,7 +449,8 @@ entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE | |||
426 | } | 449 | } |
427 | 450 | ||
428 | int | 451 | int |
429 | close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 452 | close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, |
453 | const struct GNUNET_HashCode *key) | ||
430 | { | 454 | { |
431 | GNUNET_assert((handle) && (key)); | 455 | GNUNET_assert((handle) && (key)); |
432 | 456 | ||
@@ -437,7 +461,8 @@ close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNE | |||
437 | } | 461 | } |
438 | 462 | ||
439 | int | 463 | int |
440 | send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 464 | send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, |
465 | const struct GNUNET_HashCode *key, | ||
441 | const struct GNUNET_MESSENGER_Message *message) | 466 | const struct GNUNET_MESSENGER_Message *message) |
442 | { | 467 | { |
443 | GNUNET_assert((handle) && (key) && (message)); | 468 | GNUNET_assert((handle) && (key) && (message)); |
@@ -475,7 +500,8 @@ get_next_member_session_contect(const struct GNUNET_MESSENGER_MemberSession *ses | |||
475 | } | 500 | } |
476 | 501 | ||
477 | static const struct GNUNET_MESSENGER_MemberSession* | 502 | static const struct GNUNET_MESSENGER_MemberSession* |
478 | get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key) | 503 | get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, |
504 | const struct GNUNET_HashCode *key) | ||
479 | { | 505 | { |
480 | GNUNET_assert((handle) && (key) && (handle->service)); | 506 | GNUNET_assert((handle) && (key) && (handle->service)); |
481 | 507 | ||
@@ -497,9 +523,11 @@ get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, const stru | |||
497 | } | 523 | } |
498 | 524 | ||
499 | void | 525 | void |
500 | notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | 526 | notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, |
527 | const struct GNUNET_HashCode *key, | ||
501 | const struct GNUNET_MESSENGER_MemberSession *session, | 528 | const struct GNUNET_MESSENGER_MemberSession *session, |
502 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) | 529 | const struct GNUNET_MESSENGER_Message *message, |
530 | const struct GNUNET_HashCode *hash) | ||
503 | { | 531 | { |
504 | GNUNET_assert((handle) && (key) && (session) && (message) && (hash)); | 532 | GNUNET_assert((handle) && (key) && (session) && (message) && (hash)); |
505 | 533 | ||
@@ -563,7 +591,8 @@ notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct G | |||
563 | } | 591 | } |
564 | 592 | ||
565 | static int | 593 | static int |
566 | callback_scan_for_rooms (void *cls, const char *filename) | 594 | callback_scan_for_rooms (void *cls, |
595 | const char *filename) | ||
567 | { | 596 | { |
568 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 597 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
569 | 598 | ||
@@ -606,7 +635,9 @@ load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle) | |||
606 | } | 635 | } |
607 | 636 | ||
608 | static int | 637 | static int |
609 | iterate_save_rooms (void *cls, const struct GNUNET_HashCode *key, void *value) | 638 | iterate_save_rooms (void *cls, |
639 | const struct GNUNET_HashCode *key, | ||
640 | void *value) | ||
610 | { | 641 | { |
611 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; | 642 | struct GNUNET_MESSENGER_SrvHandle *handle = cls; |
612 | struct GNUNET_ShortHashCode *member_id = value; | 643 | struct GNUNET_ShortHashCode *member_id = value; |