GNUnet 0.21.2
messenger_api_room.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2024 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
26#include "messenger_api_room.h"
27
28#include "gnunet_common.h"
30
36
37#include <string.h>
38
41 const struct GNUNET_HashCode *key)
42{
43 GNUNET_assert ((handle) && (key));
44
45 struct GNUNET_MESSENGER_Room *room = GNUNET_new (struct
47
48 room->handle = handle;
49 GNUNET_memcpy (&(room->key), key, sizeof(*key));
50
51 memset (&(room->last_message), 0, sizeof(room->last_message));
52
53 room->opened = GNUNET_NO;
56
57 room->sender_id = NULL;
58
59 init_list_tunnels (&(room->entries));
60
64
66
67 init_queue_messages (&(room->queue));
68 room->queue_task = NULL;
69
70 room->control = create_message_control (room);
71
72 return room;
73}
74
75
78 const struct GNUNET_HashCode *key,
79 void *value)
80{
82
83 destroy_message (entry->message);
84 GNUNET_free (entry);
85
86 return GNUNET_YES;
87}
88
89
92 const struct GNUNET_HashCode *key,
93 void *value)
94{
95 struct GNUNET_HashCode *hash = value;
96 GNUNET_free (hash);
97 return GNUNET_YES;
98}
99
100
103 const struct GNUNET_ShortHashCode *key,
104 void *value)
105{
106 struct GNUNET_MESSENGER_RoomSubscription *subscription = value;
107
108 if (subscription->task)
109 GNUNET_SCHEDULER_cancel (subscription->task);
110
111 if (subscription->message)
112 destroy_message (subscription->message);
113
114 GNUNET_free (subscription);
115 return GNUNET_YES;
116}
117
118
119void
121{
123
125
126 if (room->queue_task)
128
131
132 if (room->subscriptions)
133 {
136 NULL);
137
139 }
140
141 if (room->messages)
142 {
145
147 }
148
149 if (room->members)
151
152 if (room->links)
153 {
156
158 }
159
160 if (room->sender_id)
162
164}
165
166
169{
171
172 if (! get_room_sender_id (room))
173 return GNUNET_NO;
174
175 if ((GNUNET_YES == room->opened) || (room->entries.head))
176 return GNUNET_YES;
177 else
178 return GNUNET_NO;
179}
180
181
184{
185 GNUNET_assert (room);
186
187 return room->handle;
188}
189
190
191const struct GNUNET_ShortHashCode*
193{
194 GNUNET_assert (room);
195
196 return room->sender_id;
197}
198
199
200void
202 const struct GNUNET_ShortHashCode *id)
203{
204 GNUNET_assert (room);
205
206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Set member id for room: %s\n",
207 GNUNET_h2s (&(room->key)));
208
209 if (! id)
210 {
211 if (room->sender_id)
212 GNUNET_free (room->sender_id);
213
214 room->sender_id = NULL;
215 return;
216 }
217
218 if (! room->sender_id)
220
221 GNUNET_memcpy (room->sender_id, id, sizeof(struct GNUNET_ShortHashCode));
222}
223
224
225const struct GNUNET_MESSENGER_Message*
227 const struct GNUNET_HashCode *hash)
228{
229 GNUNET_assert ((room) && (hash));
230
233 room->messages, hash);
234
235 if ((! entry) || (GNUNET_YES != entry->completed))
236 return NULL;
237
238 return entry->message;
239}
240
241
244 const struct GNUNET_HashCode *hash)
245{
246 GNUNET_assert ((room) && (hash));
247
250 room->messages, hash);
251
252 if ((! entry) || (GNUNET_YES != entry->completed))
253 return NULL;
254
255 return entry->sender;
256}
257
258
261 const struct GNUNET_HashCode *hash)
262{
263 GNUNET_assert ((room) && (hash));
264
267 room->messages, hash);
268
269 if ((! entry) || (GNUNET_YES != entry->completed))
270 return NULL;
271
272 return entry->recipient;
273}
274
275
276void
278 const struct GNUNET_HashCode *hash)
279{
280 GNUNET_assert ((room) && (hash));
281
282 struct GNUNET_MESSENGER_Handle *handle = room->handle;
283
284 if (! handle)
285 return;
286
288 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
289
290 if (! entry)
291 return;
292
293 if (handle->msg_callback)
294 handle->msg_callback (handle->msg_cls, room,
295 entry->sender,
296 entry->recipient,
297 entry->message,
298 hash,
299 entry->flags);
300
303}
304
305
306static void
308 const struct GNUNET_HashCode *hash,
310
311
312void
314 const struct GNUNET_HashCode *hash,
316{
317 GNUNET_assert ((room) && (hash) && (entry));
318
319 if (! entry->sender)
320 {
322 room->handle);
324
325 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
326 &context);
327
328 entry->sender = get_store_contact (store, &context,
329 &(entry->message->body.join.key));
330 }
331
333 room->members, &(entry->message->header.sender_id), entry->sender)) &&
335 &(entry->message->header
336 .sender_id),
337 entry->sender,
339
341}
342
343
344static void
346 const struct GNUNET_HashCode *hash,
348{
349 GNUNET_assert ((room) && (hash) && (entry));
350
351 if ((! entry->sender) ||
353 &(entry->message->
354 header.sender_id),
355 entry->sender)))
356 return;
357
358 if (GNUNET_YES == decrease_contact_rc (entry->sender))
360 "A contact does not share any room with you anymore!\n");
361}
362
363
364static void
366 const struct GNUNET_HashCode *hash,
368{
369 GNUNET_assert ((room) && (hash) && (entry));
370
372 {
374 "Set rule for using handle name in room: %s\n",
375 GNUNET_h2s (&(room->key)));
376
377 const char *handle_name = get_handle_name (room->handle);
378
379 if ((handle_name) && (0 == strcmp (handle_name,
380 entry->message->body.name.name)))
382 }
383
384 if (! entry->sender)
385 return;
386
387 set_contact_name (entry->sender, entry->message->body.name.name);
388}
389
390
391static void
393 const struct GNUNET_HashCode *hash,
395{
396 GNUNET_assert ((room) && (hash) && (entry));
397
398 if (! entry->sender)
399 return;
400
402 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
403 &context);
404
406 room->handle);
407
408 update_store_contact (store, entry->sender, &context, &context,
409 &(entry->message->body.key.key));
410}
411
412
413static void
415 const struct GNUNET_HashCode *hash,
417{
418 GNUNET_assert ((room) && (hash) && (entry));
419
421 set_room_sender_id (room, &(entry->message->body.id.id));
422
423 if ((! entry->sender) ||
425 &(entry->message->
426 header.sender_id),
427 entry->sender)) ||
429 &(entry->message->body.
430 id.id),
431 entry->sender,
433
434 return;
435
436 struct GNUNET_HashCode context, next_context;
437 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
438 &context);
439 get_context_from_member (&(room->key), &(entry->message->body.id.id),
440 &next_context);
441
443 room->handle);
444
445 update_store_contact (store, entry->sender, &context, &next_context,
446 get_contact_key (entry->sender));
447}
448
449
450static void
452 const struct GNUNET_HashCode *hash,
454{
455 GNUNET_assert ((room) && (hash) && (entry));
456
457 if (0 == (GNUNET_MESSENGER_FLAG_SENT & entry->flags))
458 return;
459
461 &(room->entries), &(entry->message->body.miss.peer), NULL);
462
463 if (match)
464 remove_from_list_tunnels (&(room->entries), match);
465}
466
467
468static void
470 const struct GNUNET_HashCode *hash,
472{
473 GNUNET_assert ((room) && (hash) && (entry));
474
475 struct GNUNET_MESSENGER_Message *private_message = copy_message (
476 entry->message);
477
478 if (! private_message)
479 return;
480
481 if (GNUNET_YES != decrypt_message (private_message,
482 get_handle_key (room->handle)))
483 {
484 destroy_message (private_message);
485 private_message = NULL;
486 }
487
488 if (! private_message)
489 return;
490
491 destroy_message (entry->message);
492
493 entry->recipient = get_handle_contact (room->handle, &(room->key));
494
495 entry->message = private_message;
497
498 if ((entry->sender) && (entry->recipient))
499 handle_message (room, hash, entry);
500}
501
502
503extern void
505 const struct GNUNET_HashCode *hash,
506 const struct GNUNET_TIME_Relative delay);
507
508
509static void
511 const struct GNUNET_HashCode *hash,
513{
514 GNUNET_assert ((room) && (hash) && (entry));
515
516 const struct GNUNET_HashCode *target_hash =
517 &(entry->message->body.deletion.hash);
518
519 if (get_handle_contact (room->handle, &(room->key)) == entry->sender)
520 {
521 struct GNUNET_TIME_Relative delay;
523
525
528
530 action);
531
532 link_room_deletion (room, target_hash, delay, delete_message_in_room);
533 }
534
535 struct GNUNET_MESSENGER_RoomMessageEntry *target =
536 GNUNET_CONTAINER_multihashmap_get (room->messages, target_hash);
537
538 if (! target)
539 return;
540
541 if (((target->sender != entry->sender) &&
542 (get_handle_contact (room->handle, &(room->key)) != entry->sender)))
543 return;
544
546 callback_room_message (room, target_hash);
547
549 target_hash,
550 target))
551 {
552 destroy_message (target->message);
553 GNUNET_free (target);
554 }
555}
556
557
558static void
560 const struct GNUNET_HashCode *hash,
562{
563 GNUNET_assert ((room) && (hash) && (entry));
564
565 if (get_handle_contact (room->handle, &(room->key)) != entry->sender)
566 return;
567
568 const struct GNUNET_HashCode *original_hash =
569 &(entry->message->body.transcript.hash);
571 room->handle);
572
573 struct GNUNET_MESSENGER_RoomMessageEntry *original =
574 GNUNET_CONTAINER_multihashmap_get (room->messages, original_hash);
575 struct GNUNET_MESSENGER_Message *original_message;
576
577 if (original)
578 goto read_transcript;
579
581
582 if (! original)
583 return;
584
585 original->sender = NULL;
586 original->recipient = NULL;
587
588 original->message = NULL;
590 original->completed = GNUNET_NO;
591
593 original_hash,
594 original,
596 {
597 GNUNET_free (original);
598 return;
599 }
600
601read_transcript:
602 original_message = copy_message (entry->message);
603
604 if (! original_message)
605 return;
606
607 if (GNUNET_YES != read_transcript_message (original_message))
608 {
609 destroy_message (original_message);
610 return;
611 }
612
613 original->recipient = get_store_contact (store,
614 NULL,
615 &(entry->message->body.transcript.key
616 ));
617
618 if (original->message)
619 {
622
623 copy_message_header (original_message, &(original->message->header));
624 destroy_message (original->message);
625 }
626
627 original->message = original_message;
628
629 link_room_message (room, hash, original_hash);
630 link_room_message (room, original_hash, hash);
631
632 if ((original->sender) && (original->recipient))
633 {
635 handle_message (room, original_hash, original);
636 }
637}
638
639
640static void
642 const struct GNUNET_HashCode *hash,
644{
645 GNUNET_assert ((room) && (hash) && (entry));
646
647 switch (entry->message->header.kind)
648 {
650 handle_join_message (room, hash, entry);
651 break;
653 handle_leave_message (room, hash, entry);
654 break;
656 handle_name_message (room, hash, entry);
657 break;
659 handle_key_message (room, hash, entry);
660 break;
662 handle_id_message (room, hash, entry);
663 break;
665 handle_miss_message (room, hash, entry);
666 break;
668 handle_private_message (room, hash, entry);
669 break;
671 handle_delete_message (room, hash, entry);
672 break;
674 handle_transcript_message (room, hash, entry);
675 break;
676 default:
677 break;
678 }
679
681 callback_room_message (room, hash);
682}
683
684
685void
687 struct GNUNET_MESSENGER_Contact *sender,
688 const struct GNUNET_MESSENGER_Message *message,
689 const struct GNUNET_HashCode *hash,
691{
692 GNUNET_assert ((room) && (message) && (hash));
693
695 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
696
697 if (entry)
698 goto update_entry;
699
701
702 if (! entry)
703 return;
704
705 entry->sender = NULL;
706 entry->recipient = NULL;
707
708 entry->message = NULL;
710 entry->completed = GNUNET_NO;
711
713 entry,
715 {
716 GNUNET_free (entry);
717 return;
718 }
719
720update_entry:
721 entry->sender = sender;
722 entry->flags = flags;
723
724 if (entry->message)
725 {
728
730 }
731 else
732 entry->message = copy_message (message);
733
734 entry->completed = GNUNET_YES;
735
736 handle_message (room, hash, entry);
737}
738
739
740void
742 const struct GNUNET_HashCode *hash)
743{
744 GNUNET_assert ((room) && (hash));
745
746 GNUNET_memcpy (&(room->last_message), hash, sizeof(room->last_message));
747}
748
749
751{
754 void *cls;
755};
756
759 const struct GNUNET_ShortHashCode *key,
760 void *value)
761{
763 struct GNUNET_MESSENGER_Contact *contact = value;
764
765 return call->callback (call->cls, call->room, contact);
766}
767
768
769int
772 void *cls)
773{
774 GNUNET_assert (room);
775
776 if (! callback)
777 return GNUNET_CONTAINER_multishortmap_iterate (room->members, NULL, NULL);
778
780
781 call.room = room;
782 call.callback = callback;
783 call.cls = cls;
784
786
789 &call);
790}
791
792
794{
797};
798
801 const struct GNUNET_ShortHashCode *key,
802 void *value)
803{
804 struct GNUNET_MESSENGER_MemberFind *find = cls;
805 struct GNUNET_MESSENGER_Contact *contact = value;
806
807 if (contact == find->contact)
808 {
809 find->result = GNUNET_YES;
810 return GNUNET_NO;
811 }
812
813 return GNUNET_YES;
814}
815
816
819 const struct GNUNET_MESSENGER_Contact *contact)
820{
821 GNUNET_assert (room);
822
823 struct GNUNET_MESSENGER_MemberFind find;
824
825 find.contact = contact;
826 find.result = GNUNET_NO;
827
829 &find);
830
831 return find.result;
832}
833
834
837 const struct GNUNET_HashCode *key,
838 void *value)
839{
840 const struct GNUNET_HashCode **result = cls;
841 struct GNUNET_HashCode *hash = value;
842
843 if (0 == GNUNET_CRYPTO_hash_cmp (hash, *result))
844 {
845 *result = NULL;
846 return GNUNET_NO;
847 }
848
849 return GNUNET_YES;
850}
851
852
853void
855 const struct GNUNET_HashCode *hash,
856 const struct GNUNET_HashCode *other)
857{
858 GNUNET_assert ((room) && (hash) && (other));
859
860 const struct GNUNET_HashCode **result = &other;
863
864 if (! *result)
865 return;
866
867 struct GNUNET_HashCode *value = GNUNET_memdup (other, sizeof(struct
869 ;
870 if (! value)
871 return;
872
875
877}
878
879
881{
885};
886
887
890 const struct GNUNET_HashCode *key,
891 void *value)
892{
893 struct GNUNET_HashCode **linked = cls;
894 struct GNUNET_HashCode *hash = value;
895
896 if (0 != GNUNET_CRYPTO_hash_cmp (*linked, hash))
897 return GNUNET_YES;
898
899 *linked = hash;
900 return GNUNET_NO;
901}
902
903
906 const struct GNUNET_HashCode *key,
907 void *value)
908{
910 struct GNUNET_HashCode *hash = value;
911
912 struct GNUNET_HashCode key_value;
913 GNUNET_memcpy (&key_value, key, sizeof (key_value));
914
915 struct GNUNET_HashCode *linked = &key_value;
916
918 clear_linked_hash, &linked);
919
920 if ((linked != &key_value) &&
922 hash, linked)))
923 GNUNET_free (linked);
924
925 if (info->deletion)
926 info->deletion (info->room, hash, info->delay);
927
928 GNUNET_free (hash);
929 return GNUNET_YES;
930}
931
932
933void
935 const struct GNUNET_HashCode *hash,
936 const struct GNUNET_TIME_Relative delay,
938{
939 GNUNET_assert ((room) && (hash));
940
942 info.room = room;
943 info.delay = delay;
944 info.deletion = deletion;
945
949}
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
struct GNUNET_HashCode key
The key used in the DHT.
static pa_context * context
Pulseaudio context.
static char * value
Value of the record to add/remove.
static int result
Global testing status.
#define info
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:221
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
int GNUNET_CONTAINER_multishortmap_contains_value(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Check if the map contains the given value under the given key.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling.
enum GNUNET_GenericReturnValue(* GNUNET_MESSENGER_MemberCallback)(void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
Method called for each member in a room during iteration.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_TRANSCRIPT
The transcript kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
@ GNUNET_MESSENGER_FLAG_SENT
The sent flag.
@ GNUNET_MESSENGER_FLAG_UPDATE
The update flag.
@ GNUNET_MESSENGER_FLAG_NONE
The none flag.
@ GNUNET_MESSENGER_FLAG_DELETE
The delete flag.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:628
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:450
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:421
enum GNUNET_GenericReturnValue decrease_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Decreases the reference counter if possible (can not underflow!) of a given contact and returns GNUNE...
const struct GNUNET_CRYPTO_PublicKey * get_contact_key(const struct GNUNET_MESSENGER_Contact *contact)
Returns the public key of a given contact.
void set_contact_name(struct GNUNET_MESSENGER_Contact *contact, const char *name)
Changes the current name of a given contact by copying it from the parameter name.
void increase_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Increases the reference counter of a given contact which is zero as default.
void get_context_from_member(const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id, struct GNUNET_HashCode *context)
Calculates the context hash of a member in a room and returns it.
void update_store_contact(struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context, const struct GNUNET_CRYPTO_PublicKey *pubkey)
Moves a contact from the store to another location matching a given public key and member context.
struct GNUNET_MESSENGER_Contact * get_store_contact(struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, const struct GNUNET_CRYPTO_PublicKey *pubkey)
Returns a contact using a specific public key.
struct GNUNET_MESSENGER_ContactStore * get_handle_contact_store(struct GNUNET_MESSENGER_Handle *handle)
Returns the used contact store of a given handle.
struct GNUNET_MESSENGER_Contact * get_handle_contact(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Returns the contact of a given handle in a room identified by a given key.
const char * get_handle_name(const struct GNUNET_MESSENGER_Handle *handle)
Returns the current name of a given handle or NULL if no valid name was assigned yet.
const struct GNUNET_CRYPTO_PrivateKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the private key of a given handle.
void init_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Initializes list of tunnels peer identities as empty list.
struct GNUNET_MESSENGER_ListTunnel * find_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index)
Searches linearly through the list of tunnels peer identities for matching a specific peer identity a...
void clear_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Clears the list of tunnels peer identities.
struct GNUNET_MESSENGER_ListTunnel * remove_from_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element)
Removes a specific element from the list of tunnels peer identities and returns the next element in t...
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
enum GNUNET_GenericReturnValue decrypt_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PrivateKey *key)
Decrypts a private message using a given private key and replaces its body and kind with the inner en...
void copy_message_header(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_MessageHeader *header)
Copy message header details from another message to a given message.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
enum GNUNET_GenericReturnValue read_transcript_message(struct GNUNET_MESSENGER_Message *message)
Read the original message from a transcript message and replaces its body and kind with the inner enc...
struct GNUNET_MESSENGER_MessageControl * create_message_control(struct GNUNET_MESSENGER_Room *room)
Creates and allocates a new message control for a room of the client API.
void destroy_message_control(struct GNUNET_MESSENGER_MessageControl *control)
Destroys a message control and frees its memory fully from the client API.
void init_queue_messages(struct GNUNET_MESSENGER_QueueMessages *messages)
Initializes queue of messages as empty queue.
void clear_queue_messages(struct GNUNET_MESSENGER_QueueMessages *messages)
Clears the queue of messages.
static void handle_name_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
enum GNUNET_GenericReturnValue find_room_member(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
Checks through all members of a given room if a specific contact is found and returns a result depend...
static enum GNUNET_GenericReturnValue delete_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
static void handle_id_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
struct GNUNET_MESSENGER_Contact * get_room_sender(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a messages sender locally stored from a map for a given hash in a room.
void set_room_sender_id(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ShortHashCode *id)
Sets the member id of the room's sender to a specific id or NULL.
void handle_room_message(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
Handles a message with a given hash in a room for the client API to update members and its informatio...
void link_room_deletion(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay, GNUNET_MESSENGER_RoomLinkDeletion deletion)
Delete all remaining links to a certain message identified by its hash inside a given room and cause ...
const struct GNUNET_MESSENGER_Message * get_room_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a message locally stored from a map for a given hash in a room.
static enum GNUNET_GenericReturnValue iterate_destroy_subscription(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
void update_room_last_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Updates the last message hash of a room for the client API so that new messages can point to the late...
static void handle_private_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static enum GNUNET_GenericReturnValue iterate_find_member(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
enum GNUNET_GenericReturnValue is_room_available(const struct GNUNET_MESSENGER_Room *room)
Checks whether a room is available to send messages.
void callback_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Executes the message callback for a given hash in a room.
void delete_message_in_room(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
static void handle_leave_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_miss_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_transcript_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static enum GNUNET_GenericReturnValue iterate_destroy_link(void *cls, const struct GNUNET_HashCode *key, void *value)
static void handle_key_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_delete_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static enum GNUNET_GenericReturnValue iterate_destroy_message(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_MESSENGER_Handle * get_room_handle(struct GNUNET_MESSENGER_Room *room)
Returns the messenger handle of the room.
const struct GNUNET_ShortHashCode * get_room_sender_id(const struct GNUNET_MESSENGER_Room *room)
Returns the member id of the room's sender.
static enum GNUNET_GenericReturnValue clear_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_local_members(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
void link_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *other)
Links a message identified by its hash inside a given room with another message identified by its oth...
void handle_join_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
int iterate_room_members(struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
Iterates through all members of a given room to forward each of them to a selected callback with a cu...
void destroy_room(struct GNUNET_MESSENGER_Room *room)
Destroys a room and frees its memory fully from the client API.
static enum GNUNET_GenericReturnValue find_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_MESSENGER_Contact * get_room_recipient(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a messages recipient locally stored from a map for a given hash in a room.
struct GNUNET_MESSENGER_Room * create_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Creates and allocates a new room for a handle with a given key for the client API.
void(* GNUNET_MESSENGER_RoomLinkDeletion)(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
A 512-bit hashcode.
struct GNUNET_MESSENGER_ListTunnel * head
GNUNET_MESSENGER_MemberCallback callback
struct GNUNET_MESSENGER_Room * room
const struct GNUNET_MESSENGER_Contact * contact
enum GNUNET_GenericReturnValue result
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_MESSENGER_MessageName name
struct GNUNET_MESSENGER_MessageTranscript transcript
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_MESSENGER_MessageDelete deletion
struct GNUNET_HashCode hash
The hash of the message to delete.
struct GNUNET_TIME_RelativeNBO delay
The delay of the delete operation to get processed.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.
struct GNUNET_CRYPTO_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_CRYPTO_PublicKey key
The new public key which replaces the current senders public key.
struct GNUNET_PeerIdentity peer
The peer identity of a disconnected door to a room.
char * name
The new name which replaces the current senders name.
struct GNUNET_HashCode hash
The hash of the original message.
struct GNUNET_CRYPTO_PublicKey key
The key from the recipient of the original message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_Room * room
GNUNET_MESSENGER_RoomLinkDeletion deletion
struct GNUNET_MESSENGER_Contact * recipient
enum GNUNET_MESSENGER_MessageFlags flags
struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_Contact * sender
enum GNUNET_GenericReturnValue completed
struct GNUNET_SCHEDULER_Task * task
struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_Room * room
struct GNUNET_CONTAINER_MultiHashMap * links
struct GNUNET_CONTAINER_MultiShortmap * subscriptions
struct GNUNET_MESSENGER_Handle * handle
enum GNUNET_GenericReturnValue opened
enum GNUNET_GenericReturnValue wait_for_sync
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_MESSENGER_MessageControl * control
struct GNUNET_SCHEDULER_Task * queue_task
struct GNUNET_CONTAINER_MultiHashMap * messages
enum GNUNET_GenericReturnValue use_handle_name
struct GNUNET_MESSENGER_QueueMessages queue
struct GNUNET_MESSENGER_ListTunnels entries
struct GNUNET_ShortHashCode * sender_id
struct GNUNET_HashCode key
struct GNUNET_HashCode last_message
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.