diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger_room.h')
-rw-r--r-- | src/messenger/gnunet-service-messenger_room.h | 265 |
1 files changed, 113 insertions, 152 deletions
diff --git a/src/messenger/gnunet-service-messenger_room.h b/src/messenger/gnunet-service-messenger_room.h index 36c9e8cf5..a40961177 100644 --- a/src/messenger/gnunet-service-messenger_room.h +++ b/src/messenger/gnunet-service-messenger_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 |
@@ -33,33 +33,29 @@ | |||
33 | #include "gnunet_identity_service.h" | 33 | #include "gnunet_identity_service.h" |
34 | #include "gnunet_mq_lib.h" | 34 | #include "gnunet_mq_lib.h" |
35 | 35 | ||
36 | #include "gnunet-service-messenger_contact.h" | ||
37 | |||
38 | #include "gnunet_messenger_service.h" | 36 | #include "gnunet_messenger_service.h" |
39 | #include "gnunet-service-messenger_basement.h" | 37 | #include "gnunet-service-messenger_basement.h" |
40 | #include "gnunet-service-messenger_handle.h" | 38 | #include "gnunet-service-messenger_handle.h" |
41 | #include "gnunet-service-messenger_tunnel.h" | ||
42 | |||
43 | #include "gnunet-service-messenger_list_messages.h" | 39 | #include "gnunet-service-messenger_list_messages.h" |
40 | |||
44 | #include "messenger_api_list_tunnels.h" | 41 | #include "messenger_api_list_tunnels.h" |
45 | 42 | ||
43 | #include "gnunet-service-messenger_member_store.h" | ||
46 | #include "gnunet-service-messenger_message_store.h" | 44 | #include "gnunet-service-messenger_message_store.h" |
45 | #include "gnunet-service-messenger_operation_store.h" | ||
47 | #include "messenger_api_ego.h" | 46 | #include "messenger_api_ego.h" |
48 | 47 | ||
49 | enum GNUNET_MESSENGER_MemberAccess | 48 | #define GNUNET_MESSENGER_IDLE_DELAY GNUNET_TIME_relative_multiply \ |
50 | { | 49 | (GNUNET_TIME_relative_get_second_ (), 5) |
51 | GNUNET_MESSENGER_MEMBER_ALLOWED = 1, | ||
52 | GNUNET_MESSENGER_MEMBER_BLOCKED = 1, | ||
53 | 50 | ||
54 | GNUNET_MESSENGER_MEMBER_UNKNOWN = 0 | 51 | #define GNUNET_MESSENGER_REQUEST_DELAY GNUNET_TIME_relative_multiply \ |
55 | }; | 52 | (GNUNET_TIME_relative_get_minute_ (), 5) |
56 | 53 | ||
57 | struct GNUNET_MESSENGER_MemberInfo | 54 | #define GNUNET_MESSENGER_MERGE_DELAY GNUNET_TIME_relative_multiply \ |
58 | { | 55 | (GNUNET_TIME_relative_get_second_ (), 30) |
59 | enum GNUNET_MESSENGER_MemberAccess access; | ||
60 | 56 | ||
61 | struct GNUNET_MESSENGER_ListMessages session_messages; | 57 | struct GNUNET_MESSENGER_SrvTunnel; |
62 | }; | 58 | struct GNUNET_MESSENGER_MemberSession; |
63 | 59 | ||
64 | struct GNUNET_MESSENGER_SrvRoom | 60 | struct GNUNET_MESSENGER_SrvRoom |
65 | { | 61 | { |
@@ -70,11 +66,10 @@ struct GNUNET_MESSENGER_SrvRoom | |||
70 | struct GNUNET_HashCode key; | 66 | struct GNUNET_HashCode key; |
71 | 67 | ||
72 | struct GNUNET_CONTAINER_MultiPeerMap *tunnels; | 68 | struct GNUNET_CONTAINER_MultiPeerMap *tunnels; |
73 | struct GNUNET_CONTAINER_MultiShortmap *members; | ||
74 | struct GNUNET_CONTAINER_MultiShortmap *member_infos; | ||
75 | 69 | ||
76 | struct GNUNET_MESSENGER_MessageStore store; | 70 | struct GNUNET_MESSENGER_MemberStore member_store; |
77 | struct GNUNET_CONTAINER_MultiHashMap *requested; | 71 | struct GNUNET_MESSENGER_MessageStore message_store; |
72 | struct GNUNET_MESSENGER_OperationStore operation_store; | ||
78 | 73 | ||
79 | struct GNUNET_MESSENGER_ListTunnels basement; | 74 | struct GNUNET_MESSENGER_ListTunnels basement; |
80 | struct GNUNET_MESSENGER_ListMessages last_messages; | 75 | struct GNUNET_MESSENGER_ListMessages last_messages; |
@@ -83,15 +78,13 @@ struct GNUNET_MESSENGER_SrvRoom | |||
83 | 78 | ||
84 | struct GNUNET_MESSENGER_ListMessages handling; | 79 | struct GNUNET_MESSENGER_ListMessages handling; |
85 | struct GNUNET_SCHEDULER_Task *idle; | 80 | struct GNUNET_SCHEDULER_Task *idle; |
86 | |||
87 | int strict_access; | ||
88 | }; | 81 | }; |
89 | 82 | ||
90 | /** | 83 | /** |
91 | * Creates and allocates a new room for a <i>handle</i> with a given <i>key</i>. | 84 | * Creates and allocates a new room for a <i>handle</i> with a given <i>key</i>. |
92 | * | 85 | * |
93 | * @param handle Handle | 86 | * @param[in/out] handle Handle |
94 | * @param key Key of room | 87 | * @param[in] key Key of room |
95 | * @return New room | 88 | * @return New room |
96 | */ | 89 | */ |
97 | struct GNUNET_MESSENGER_SrvRoom* | 90 | struct GNUNET_MESSENGER_SrvRoom* |
@@ -100,58 +93,42 @@ create_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_Hash | |||
100 | /** | 93 | /** |
101 | * Destroys a room and frees its memory fully. | 94 | * Destroys a room and frees its memory fully. |
102 | * | 95 | * |
103 | * @param room Room | 96 | * @param[in/out] room Room |
104 | */ | 97 | */ |
105 | void | 98 | void |
106 | destroy_room (struct GNUNET_MESSENGER_SrvRoom *room); | 99 | destroy_room (struct GNUNET_MESSENGER_SrvRoom *room); |
107 | 100 | ||
108 | /** | 101 | /** |
109 | * Returns the contact of a member in a <i>room</i> identified by a given <i>id</i>. If the <i>room</i> | 102 | * Returns the used member store of a given <i>room</i>. |
110 | * does not contain a member with the given <i>id</i>, NULL gets returned. | ||
111 | * | ||
112 | * @param room Room | ||
113 | * @param id Member id | ||
114 | * @return Contact or NULL | ||
115 | */ | ||
116 | struct GNUNET_MESSENGER_SrvContact* | ||
117 | get_room_contact (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id); | ||
118 | |||
119 | /** | ||
120 | * Adds a contact from the service to a <i>room</i> under a specific <i>id</i> with a given public key. | ||
121 | * | 103 | * |
122 | * @param room Room | 104 | * @param[in/out] room Room |
123 | * @param id Member id | 105 | * @return Member store |
124 | * @param pubkey Public key of EGO | ||
125 | */ | 106 | */ |
126 | void | 107 | struct GNUNET_MESSENGER_MemberStore* |
127 | add_room_contact (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id, | 108 | get_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room); |
128 | const struct GNUNET_IDENTITY_PublicKey *pubkey); | ||
129 | 109 | ||
130 | /** | 110 | /** |
131 | * Returns the member information of a member in a <i>room</i> identified by a given <i>id</i>. If the <i>room</i> | 111 | * Returns the used message store of a given <i>room</i>. |
132 | * does not contain a member with the given <i>id</i>, NULL gets returned. | ||
133 | * | 112 | * |
134 | * @param room Room | 113 | * @param[in/out] room Room |
135 | * @param id Member id | 114 | * @return Message store |
136 | * @return Member information or NULL | ||
137 | */ | 115 | */ |
138 | struct GNUNET_MESSENGER_MemberInfo* | 116 | struct GNUNET_MESSENGER_MessageStore* |
139 | get_room_member_info (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *id); | 117 | get_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room); |
140 | 118 | ||
141 | /** | 119 | /** |
142 | * Tries to generate and allocate a new unique member id checking all current members for possible | 120 | * Returns the used operation store of a given <i>room</i>. |
143 | * duplicates. If the function fails, NULL gets returned. | ||
144 | * | 121 | * |
145 | * @param room Room | 122 | * @param[in/out] room Room |
146 | * @return New member id or NULL | 123 | * @return Operation store |
147 | */ | 124 | */ |
148 | struct GNUNET_ShortHashCode* | 125 | struct GNUNET_MESSENGER_OperationStore* |
149 | generate_room_member_id (const struct GNUNET_MESSENGER_SrvRoom *room); | 126 | get_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room); |
150 | 127 | ||
151 | /** | 128 | /** |
152 | * Returns the member id of the member representing the handle currently hosting this <i>room</i>. | 129 | * Returns the member id of the member representing the handle currently hosting this <i>room</i>. |
153 | * | 130 | * |
154 | * @param room Room | 131 | * @param[in] room Room |
155 | * @return Host member id or NULL | 132 | * @return Host member id or NULL |
156 | */ | 133 | */ |
157 | const struct GNUNET_ShortHashCode* | 134 | const struct GNUNET_ShortHashCode* |
@@ -160,8 +137,8 @@ get_room_host_id (const struct GNUNET_MESSENGER_SrvRoom *room); | |||
160 | /** | 137 | /** |
161 | * Changes the member id of the member representing the handle currently hosting this <i>room</i>. | 138 | * Changes the member id of the member representing the handle currently hosting this <i>room</i>. |
162 | * | 139 | * |
163 | * @param room Room | 140 | * @param[in/out] room Room |
164 | * @param unique_id Unique member id | 141 | * @param[in] unique_id Unique member id |
165 | */ | 142 | */ |
166 | void | 143 | void |
167 | change_room_host_id (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *unique_id); | 144 | change_room_host_id (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *unique_id); |
@@ -172,11 +149,11 @@ change_room_host_id (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ | |||
172 | * | 149 | * |
173 | * Calling this method should result in joining a room and sending a peer message as well for this peer. | 150 | * Calling this method should result in joining a room and sending a peer message as well for this peer. |
174 | * | 151 | * |
175 | * If the function returns GNUNET_YES the port for this room is guranteed to be open for incoming connections. | 152 | * If the function returns #GNUNET_YES the port for this room is guranteed to be open for incoming connections. |
176 | * | 153 | * |
177 | * @param room Room | 154 | * @param[in/out] room Room |
178 | * @param handle Handle | 155 | * @param[in/out] handle Handle |
179 | * @return GNUNET_YES on success, GNUNET_NO on failure. | 156 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. |
180 | */ | 157 | */ |
181 | int | 158 | int |
182 | open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle); | 159 | open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle); |
@@ -186,45 +163,34 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHan | |||
186 | * a peer identity of a hosting peer. During the connection the handle will join the room as a member, waiting for | 163 | * a peer identity of a hosting peer. During the connection the handle will join the room as a member, waiting for |
187 | * an info message from the selected host. | 164 | * an info message from the selected host. |
188 | * | 165 | * |
189 | * @param room Room | 166 | * @param[in/out] room Room |
190 | * @param handle Handle | 167 | * @param[in/out] handle Handle |
191 | * @param door Peer identity | 168 | * @param[in] door Peer identity |
192 | * @return GNUNET_YES on success, GNUNET_NO on failure. | 169 | * @return #GNUNET_YES on success, #GNUNET_NO on failure. |
193 | */ | 170 | */ |
194 | int | 171 | int |
195 | entry_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 172 | enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, |
196 | const struct GNUNET_PeerIdentity *door); | 173 | const struct GNUNET_PeerIdentity *door); |
197 | 174 | ||
198 | /** | 175 | /** |
199 | * Returns a tunnel granting a direct connection to a specific member in a <i>room</i>. The member gets identified | ||
200 | * by an <i>id</i>. If no tunnel has been linked to the selected id, NULL gets returned. | ||
201 | * | ||
202 | * @param room Room | ||
203 | * @param contact_id Member id | ||
204 | * @return Tunnel to the member or NULL | ||
205 | */ | ||
206 | struct GNUNET_MESSENGER_SrvTunnel* | ||
207 | find_room_tunnel_to (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *contact_id); | ||
208 | |||
209 | /** | ||
210 | * Packs a <i>message</i> depending on the selected <i>mode</i> into a newly allocated envelope. It will set the | 176 | * Packs a <i>message</i> depending on the selected <i>mode</i> into a newly allocated envelope. It will set the |
211 | * timestamp of the message, the sender id and the previous messages hash automatically before packing. The message | 177 | * timestamp of the message, the sender id and the previous messages hash automatically before packing. The message |
212 | * will be signed by the handles EGO. | 178 | * will be signed by the handles EGO. |
213 | * | 179 | * |
214 | * If the optional <i>hash</i> parameter is a valid pointer, its value will be overriden by the signed messages hash. | 180 | * If the optional <i>hash</i> parameter is a valid pointer, its value will be overriden by the signed messages hash. |
215 | * | 181 | * |
216 | * If <i>mode</i> is set to GNUNET_MESSENGER_PACK_MODE_ENVELOPE, the function returns a valid envelope to send | 182 | * If <i>mode</i> is set to #GNUNET_MESSENGER_PACK_MODE_ENVELOPE, the function returns a valid envelope to send |
217 | * through a message queue, otherwise NULL. | 183 | * through a message queue, otherwise NULL. |
218 | * | 184 | * |
219 | * @param room Room | 185 | * @param[in] room Room |
220 | * @param handle Handle | 186 | * @param[in] handle Handle |
221 | * @param message Message | 187 | * @param[in/out] message Message |
222 | * @param[out] hash Hash of message | 188 | * @param[out] hash Hash of message |
223 | * @param mode Packing mode | 189 | * @param[in] mode Packing mode |
224 | * @return New envelope or NULL | 190 | * @return New envelope or NULL |
225 | */ | 191 | */ |
226 | struct GNUNET_MQ_Envelope* | 192 | struct GNUNET_MQ_Envelope* |
227 | pack_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 193 | pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, |
228 | struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode); | 194 | struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode); |
229 | 195 | ||
230 | /** | 196 | /** |
@@ -234,59 +200,69 @@ pack_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGE | |||
234 | * The function handles packing the message automatically and will call linked message-events locally even if | 200 | * The function handles packing the message automatically and will call linked message-events locally even if |
235 | * the message won't be sent to another peer. | 201 | * the message won't be sent to another peer. |
236 | * | 202 | * |
237 | * @param room Room | 203 | * The function returns #GNUNET_YES on success, #GNUNET_NO if message is null and |
238 | * @param handle Handle | 204 | * #GNUNET_SYSERR if the message was known already. |
239 | * @param message Message | 205 | * |
240 | * @param[out] hash Hash of message | 206 | * @param[in/out] room Room |
207 | * @param[in/out] handle Handle | ||
208 | * @param[in/out] message Message | ||
209 | * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise. | ||
241 | */ | 210 | */ |
242 | void | 211 | int |
243 | send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 212 | send_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, |
244 | struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash); | 213 | struct GNUNET_MESSENGER_Message *message); |
245 | 214 | ||
246 | /** | 215 | /** |
247 | * Sends a <i>message</i> from a given <i>handle</i> into a <i>room</i> excluding one specific <i>tunnel</i>. | 216 | * Forwards a <i>message</i> with a given <i>hash</i> to a specific <i>tunnel</i> inside of a <i>room</i>. |
248 | * The <i>hash</i> parameter will be updated with the hash-value resulting from the sent message. | ||
249 | * | ||
250 | * The function handles packing the message automatically and will call linked message-events locally even if | ||
251 | * the message won't be sent to another peer. | ||
252 | * | 217 | * |
253 | * @param room Room | 218 | * @param[in/out] room Room |
254 | * @param handle Handle | 219 | * @param[in/out] tunnel Tunnel |
255 | * @param message Message | 220 | * @param[in/out] message Message |
256 | * @param[out] hash Hash of message | 221 | * @param[in] hash Hash of message |
257 | * @param tunnel Tunnel | ||
258 | */ | 222 | */ |
259 | void | 223 | void |
260 | send_room_message_ext (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, | 224 | forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, |
261 | struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, | 225 | struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); |
262 | struct GNUNET_MESSENGER_SrvTunnel *tunnel); | ||
263 | 226 | ||
264 | /** | 227 | /** |
265 | * Forwards a <i>message</i> with a given <i>hash</i> to a specific <i>tunnel</i> inside of a <i>room</i>. | 228 | * Checks the current state of opening a given <i>room</i> from this peer and re-publishes it |
229 | * if necessary to a selected <i>tunnel</i> or to all connected tunnels if necessary or if the | ||
230 | * selected tunnel is NULL. | ||
266 | * | 231 | * |
267 | * @param room Room | 232 | * @param[in/out] room Room |
268 | * @param tunnel Tunnel | 233 | * @param[in/out] tunnel Tunnel |
269 | * @param message Message | ||
270 | * @param hash Hash of message | ||
271 | */ | 234 | */ |
272 | void | 235 | void |
273 | forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, | 236 | check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel); |
274 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | ||
275 | 237 | ||
276 | /** | 238 | /** |
277 | * Reduces all current forks inside of the message history of a <i>room</i> to one remaining last message | 239 | * Reduces all current forks inside of the message history of a <i>room</i> to one remaining last message |
278 | * by merging them down. All merge messages will be sent from a given <i>handle</i>. | 240 | * by merging them down. All merge messages will be sent from a given <i>handle</i>. |
279 | * | 241 | * |
280 | * @param room Room | 242 | * @param[in/out] room Room |
281 | * @param handle Handle | 243 | * @param[in/out] handle Handle |
282 | */ | 244 | */ |
283 | void | 245 | void |
284 | merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle); | 246 | merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle); |
285 | 247 | ||
286 | /** | 248 | /** |
249 | * Deletes a message from the <i>room</i> with a given <i>hash</i> in a specific <i>delay</i> if | ||
250 | * the provided member by its session is permitted to do so. | ||
251 | * | ||
252 | * @param[in/out] room Room | ||
253 | * @param[in/out] session Member session | ||
254 | * @param[in] hash Hash of message | ||
255 | * @param[in] delay Delay of deletion | ||
256 | * @return #GNUNET_YES on success, #GNUNET_NO if permission gets denied, #GNUNET_SYSERR on operation failure | ||
257 | */ | ||
258 | int | ||
259 | delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, | ||
260 | const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay); | ||
261 | |||
262 | /** | ||
287 | * Returns the CADET handle from a rooms service. | 263 | * Returns the CADET handle from a rooms service. |
288 | * | 264 | * |
289 | * @param room Room | 265 | * @param[in/out] room Room |
290 | * @return CADET handle | 266 | * @return CADET handle |
291 | */ | 267 | */ |
292 | struct GNUNET_CADET_Handle* | 268 | struct GNUNET_CADET_Handle* |
@@ -295,26 +271,26 @@ get_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room); | |||
295 | /** | 271 | /** |
296 | * Returns the shared secret you need to access a <i>room</i>. | 272 | * Returns the shared secret you need to access a <i>room</i>. |
297 | * | 273 | * |
298 | * @param room Room | 274 | * @param[in] room Room |
299 | * @return Shared secret | 275 | * @return Shared secret |
300 | */ | 276 | */ |
301 | struct GNUNET_HashCode* | 277 | const struct GNUNET_HashCode* |
302 | get_room_key (struct GNUNET_MESSENGER_SrvRoom *room); | 278 | get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room); |
303 | 279 | ||
304 | /** | 280 | /** |
305 | * Returns a tunnel inside of a <i>room</i> leading towards a given <i>peer</i> if such a tunnel exists, | 281 | * Returns a tunnel inside of a <i>room</i> leading towards a given <i>peer</i> if such a tunnel exists, |
306 | * otherwise NULL. | 282 | * otherwise NULL. |
307 | * | 283 | * |
308 | * @param room Room | 284 | * @param[in] room Room |
309 | * @param peer Peer identity | 285 | * @param[in] peer Peer identity |
310 | * @return Tunnel or NULL | 286 | * @return Tunnel or NULL |
311 | */ | 287 | */ |
312 | const struct GNUNET_MESSENGER_SrvTunnel* | 288 | const struct GNUNET_MESSENGER_SrvTunnel* |
313 | get_room_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *peer); | 289 | get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *peer); |
314 | 290 | ||
315 | /** | 291 | /** |
316 | * Returns a message from a <i>room</i> identified by a given <i>hash</i>. If no matching message is | 292 | * Returns a message from a <i>room</i> identified by a given <i>hash</i>. If no matching message is |
317 | * found and <i>request</i> is set to GNUNET_YES, the <i>handle</i> will request the missing message | 293 | * found and <i>request</i> is set to #GNUNET_YES, the <i>handle</i> will request the missing message |
318 | * automatically. | 294 | * automatically. |
319 | * | 295 | * |
320 | * The function uses the optimized check for a message via its hash from the message store. | 296 | * The function uses the optimized check for a message via its hash from the message store. |
@@ -323,10 +299,10 @@ get_room_tunnel (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_Peer | |||
323 | * If a message is missing independent of the following request, NULL gets returned instead of the | 299 | * If a message is missing independent of the following request, NULL gets returned instead of the |
324 | * matching message. | 300 | * matching message. |
325 | * | 301 | * |
326 | * @param room Room | 302 | * @param[in/out] room Room |
327 | * @param handle Handle | 303 | * @param[in/out] handle Handle |
328 | * @param hash Hash of message | 304 | * @param[in] hash Hash of message |
329 | * @param request Flag to request a message | 305 | * @param[in] request Flag to request a message |
330 | * @return Message or NULL | 306 | * @return Message or NULL |
331 | */ | 307 | */ |
332 | const struct GNUNET_MESSENGER_Message* | 308 | const struct GNUNET_MESSENGER_Message* |
@@ -334,45 +310,30 @@ get_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER | |||
334 | const struct GNUNET_HashCode *hash, int request); | 310 | const struct GNUNET_HashCode *hash, int request); |
335 | 311 | ||
336 | /** | 312 | /** |
337 | * Updates the last messages of a <i>room</i> by replacing them if the previous hash of a given <i>message</i> | 313 | * Rebuilds the decentralized structure for a <i>room</i> by ensuring all required connections are made |
338 | * matches with one of the latest messages. | 314 | * depending on the amount of peers and this peers index in the list of them. |
339 | * | ||
340 | * @param room Room | ||
341 | * @param message Message | ||
342 | * @param hash Hash of message | ||
343 | */ | ||
344 | void | ||
345 | update_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, | ||
346 | const struct GNUNET_HashCode *hash); | ||
347 | |||
348 | /** | ||
349 | * Changes an id of a current member from an old id to a new one and adds optionally the <i>hash</i> of an | ||
350 | * id message to the members information. | ||
351 | * | 315 | * |
352 | * @param room Room | 316 | * @param[in/out] room Room |
353 | * @param old_id Old member id | ||
354 | * @param new_id New member id | ||
355 | * @param hash Hash of id message | ||
356 | */ | 317 | */ |
357 | void | 318 | void |
358 | switch_room_member_id (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *old_id, | 319 | rebuild_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room); |
359 | const struct GNUNET_ShortHashCode *new_id, const struct GNUNET_HashCode *hash); | ||
360 | 320 | ||
361 | /** | 321 | /** |
362 | * Rebuilds the decentralized structure for a <i>room</i> by ensuring all required connections are made | 322 | * Loads the local configuration for a given <i>room</i> of a service which contains the last messages hash |
363 | * depending on the amount of peers and this peers index in the list of them. | 323 | * and the ruleset for general access of new members. |
364 | * | 324 | * |
365 | * @param room Room | 325 | * @param[out] room Room |
366 | */ | 326 | */ |
367 | void | 327 | void |
368 | rebuild_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room); | 328 | load_room (struct GNUNET_MESSENGER_SrvRoom *room); |
369 | 329 | ||
370 | /** | 330 | /** |
371 | * Handles all queued up messages of a room to handle in correct order. | 331 | * Saves the configuration for a given <i>room</i> of a service which contains the last messages hash |
332 | * and the ruleset for general access of new members locally. | ||
372 | * | 333 | * |
373 | * @param room Room | 334 | * @param[in] room Room |
374 | */ | 335 | */ |
375 | void | 336 | void |
376 | handle_room_messages (struct GNUNET_MESSENGER_SrvRoom *room); | 337 | save_room (struct GNUNET_MESSENGER_SrvRoom *room); |
377 | 338 | ||
378 | #endif //GNUNET_SERVICE_MESSENGER_ROOM_H | 339 | #endif //GNUNET_SERVICE_MESSENGER_ROOM_H |