diff options
Diffstat (limited to 'src/messenger/messenger_api_room.h')
-rw-r--r-- | src/messenger/messenger_api_room.h | 54 |
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 | ||
39 | struct GNUNET_MESSENGER_RoomMessageEntry { | ||
40 | struct GNUNET_MESSENGER_Contact* sender; | ||
41 | struct GNUNET_MESSENGER_Message* message; | ||
42 | }; | ||
43 | |||
39 | struct GNUNET_MESSENGER_Room | 44 | struct 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 | */ |
61 | struct GNUNET_MESSENGER_Room* | 66 | struct 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 | */ |
69 | void | 74 | void |
70 | destroy_room (struct GNUNET_MESSENGER_Room *room); | 75 | destroy_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 | */ |
80 | const struct GNUNET_MESSENGER_Message* | 85 | const struct GNUNET_MESSENGER_Message* |
81 | get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); | 86 | get_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 | */ | ||
96 | struct GNUNET_MESSENGER_Contact* | ||
97 | get_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 | */ |
91 | void | 108 | void |
92 | handle_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, | 109 | handle_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 | */ | ||
121 | int | ||
122 | iterate_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 |