aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/messenger_api_room.h
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2020-11-01 22:57:28 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-03-06 01:30:37 +0100
commit2925310d67483aca6e055e1ce0593c6463cd6c72 (patch)
tree2cc8aacafc25563cdccde2eee9a90f9ca257d405 /src/messenger/messenger_api_room.h
parent82b864a64679b0a735201724907cdf2b7e4e16c3 (diff)
downloadgnunet-2925310d67483aca6e055e1ce0593c6463cd6c72.tar.gz
gnunet-2925310d67483aca6e055e1ce0593c6463cd6c72.zip
-added core functionality of the messenger service
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> formatting messenger code Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -completed core functionality of messenger service Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -code cleanup and reuse Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> +added structure to memberships of rooms Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented member permission checks and deletion of messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -moved solving requests out of updating last messages (also forward before update) Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -reduced complexity of permisson check and changed load/save of rooms Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added save/load for accessed keys and basement peers of a room Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented save/load for members with their history and session Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -abstracted management of egos and contacts Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fix warning Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -abstracted management of members Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed and adjusted test case Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -separated handling of direct and anonymous contacts Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -messenger added member-sessions which fix multiple edge cases, also additional cleanup Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -updated docs and fixed memory leak Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -changed info messages and added protocol version exchange Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adjusted client api to use contacts from sessions Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added more logging and fixed wrong session usage Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adjusted comm0 test case and removed adding members from checking messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed test-case for peer exchange Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -getting multiple peers connected in test-case with cadet Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed wrong assert and added tunnel version check -simplified handling and forwarding Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed merging last messages and cycling info messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -automated adding sessions and members Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -corrected use of identity keys and signatures Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -adding local joining on entering external room Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed test-case comm0 Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added more test-cases with generic setup Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed multiple simultaneous channels blocking each other Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -making test-cases more precise Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added check of members in test-cases, reduced merge messages Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -unified delayed operations: requests, deletions and merges Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -finished handling of operations Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed member session historystorage, added request permission check and padding for transmission Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -improved padding and removed automatic recursive requests Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -implemented filter for sending messages and added private messages to API level Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -wrong setups fixed with proper ego lookups Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -fixed problem with anonymous ego and changed to discrete-level padding Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added links to replace deleted messages, added local deletion and fixed anonymous id changing Signed-off-by: TheJackiMonster <thejackimonster@gmail.com> -added session completion and removal through completion process Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/messenger/messenger_api_room.h')
-rw-r--r--src/messenger/messenger_api_room.h54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h
index 0038128d8..9455fd43b 100644
--- a/src/messenger/messenger_api_room.h
+++ b/src/messenger/messenger_api_room.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2020 GNUnet e.V. 3 Copyright (C) 2020--2021 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 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 6 under the terms of the GNU Affero General Public License as published
@@ -36,6 +36,11 @@
36#include "messenger_api_contact.h" 36#include "messenger_api_contact.h"
37#include "messenger_api_message.h" 37#include "messenger_api_message.h"
38 38
39struct GNUNET_MESSENGER_RoomMessageEntry {
40 struct GNUNET_MESSENGER_Contact* sender;
41 struct GNUNET_MESSENGER_Message* message;
42};
43
39struct GNUNET_MESSENGER_Room 44struct GNUNET_MESSENGER_Room
40{ 45{
41 struct GNUNET_MESSENGER_Handle *handle; 46 struct GNUNET_MESSENGER_Handle *handle;
@@ -45,17 +50,17 @@ struct GNUNET_MESSENGER_Room
45 50
46 struct GNUNET_ShortHashCode *contact_id; 51 struct GNUNET_ShortHashCode *contact_id;
47 52
48 struct GNUNET_CONTAINER_MultiShortmap *members;
49 struct GNUNET_MESSENGER_ListTunnels entries; 53 struct GNUNET_MESSENGER_ListTunnels entries;
50 54
51 struct GNUNET_CONTAINER_MultiHashMap *messages; 55 struct GNUNET_CONTAINER_MultiHashMap *messages;
56 struct GNUNET_CONTAINER_MultiShortmap *members;
52}; 57};
53 58
54/** 59/**
55 * Creates and allocates a new room for a <i>handle</i> with a given <i>key</i> for the client API. 60 * Creates and allocates a new room for a <i>handle</i> with a given <i>key</i> for the client API.
56 * 61 *
57 * @param handle Handle 62 * @param[in/out] handle Handle
58 * @param key Key of room 63 * @param[in] key Key of room
59 * @return New room 64 * @return New room
60 */ 65 */
61struct GNUNET_MESSENGER_Room* 66struct GNUNET_MESSENGER_Room*
@@ -64,7 +69,7 @@ create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCod
64/** 69/**
65 * Destroys a room and frees its memory fully from the client API. 70 * Destroys a room and frees its memory fully from the client API.
66 * 71 *
67 * @param room Room 72 * @param[in/out] room Room
68 */ 73 */
69void 74void
70destroy_room (struct GNUNET_MESSENGER_Room *room); 75destroy_room (struct GNUNET_MESSENGER_Room *room);
@@ -73,23 +78,48 @@ destroy_room (struct GNUNET_MESSENGER_Room *room);
73 * Returns a message locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no matching 78 * Returns a message locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no matching
74 * message is found, NULL gets returned. 79 * message is found, NULL gets returned.
75 * 80 *
76 * @param room Room 81 * @param[in] room Room
77 * @param hash Hash of message 82 * @param[in] hash Hash of message
78 * @return Message or NULL 83 * @return Message or NULL
79 */ 84 */
80const struct GNUNET_MESSENGER_Message* 85const struct GNUNET_MESSENGER_Message*
81get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); 86get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash);
82 87
83/** 88/**
89 * Returns a messages sender locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no
90 * matching message is found, NULL gets returned.
91 *
92 * @param[in] room Room
93 * @param[in] hash Hash of message
94 * @return Contact of sender or NULL
95 */
96struct GNUNET_MESSENGER_Contact*
97get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash);
98
99/**
84 * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update 100 * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update
85 * members and its information. The function also stores the message in map locally for access afterwards. 101 * members and its information. The function also stores the message in map locally for access afterwards.
86 * 102 *
87 * @param room Room 103 * @param[in/out] room Room
88 * @param message Message 104 * @param[in/out] sender Contact of sender
89 * @param hash Hash of message 105 * @param[in] message Message
106 * @param[in] hash Hash of message
90 */ 107 */
91void 108void
92handle_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, 109handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
93 const struct GNUNET_HashCode *hash); 110 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
111
112/**
113 * Iterates through all members of a given <i>room</i> to forward each of them to a selected
114 * <i>callback</i> with a custom closure.
115 *
116 * @param[in/out] room Room
117 * @param[in] callback Function called for each member
118 * @param[in/out] cls Closure
119 * @return Amount of members iterated
120 */
121int
122iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback,
123 void* cls);
94 124
95#endif //GNUNET_MESSENGER_API_ROOM_H 125#endif //GNUNET_MESSENGER_API_ROOM_H