diff options
Diffstat (limited to 'src/messenger/messenger_api_room.h')
-rw-r--r-- | src/messenger/messenger_api_room.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h new file mode 100644 index 000000000..0038128d8 --- /dev/null +++ b/src/messenger/messenger_api_room.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2020 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 | */ | ||
20 | /** | ||
21 | * @author Tobias Frisch | ||
22 | * @file src/messenger/messenger_api_room.h | ||
23 | * @brief messenger api: client implementation of GNUnet MESSENGER service | ||
24 | */ | ||
25 | |||
26 | #ifndef GNUNET_MESSENGER_API_ROOM_H | ||
27 | #define GNUNET_MESSENGER_API_ROOM_H | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_container_lib.h" | ||
31 | #include "gnunet_crypto_lib.h" | ||
32 | |||
33 | #include "gnunet_messenger_service.h" | ||
34 | |||
35 | #include "messenger_api_list_tunnels.h" | ||
36 | #include "messenger_api_contact.h" | ||
37 | #include "messenger_api_message.h" | ||
38 | |||
39 | struct GNUNET_MESSENGER_Room | ||
40 | { | ||
41 | struct GNUNET_MESSENGER_Handle *handle; | ||
42 | struct GNUNET_HashCode key; | ||
43 | |||
44 | int opened; | ||
45 | |||
46 | struct GNUNET_ShortHashCode *contact_id; | ||
47 | |||
48 | struct GNUNET_CONTAINER_MultiShortmap *members; | ||
49 | struct GNUNET_MESSENGER_ListTunnels entries; | ||
50 | |||
51 | struct GNUNET_CONTAINER_MultiHashMap *messages; | ||
52 | }; | ||
53 | |||
54 | /** | ||
55 | * Creates and allocates a new room for a <i>handle</i> with a given <i>key</i> for the client API. | ||
56 | * | ||
57 | * @param handle Handle | ||
58 | * @param key Key of room | ||
59 | * @return New room | ||
60 | */ | ||
61 | struct GNUNET_MESSENGER_Room* | ||
62 | create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key); | ||
63 | |||
64 | /** | ||
65 | * Destroys a room and frees its memory fully from the client API. | ||
66 | * | ||
67 | * @param room Room | ||
68 | */ | ||
69 | void | ||
70 | destroy_room (struct GNUNET_MESSENGER_Room *room); | ||
71 | |||
72 | /** | ||
73 | * 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. | ||
75 | * | ||
76 | * @param room Room | ||
77 | * @param hash Hash of message | ||
78 | * @return Message or NULL | ||
79 | */ | ||
80 | const struct GNUNET_MESSENGER_Message* | ||
81 | get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash); | ||
82 | |||
83 | /** | ||
84 | * 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. | ||
86 | * | ||
87 | * @param room Room | ||
88 | * @param message Message | ||
89 | * @param hash Hash of message | ||
90 | */ | ||
91 | void | ||
92 | handle_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, | ||
93 | const struct GNUNET_HashCode *hash); | ||
94 | |||
95 | #endif //GNUNET_MESSENGER_API_ROOM_H | ||