diff options
Diffstat (limited to 'src/messenger/gnunet-service-messenger_handle.h')
-rw-r--r-- | src/messenger/gnunet-service-messenger_handle.h | 238 |
1 files changed, 0 insertions, 238 deletions
diff --git a/src/messenger/gnunet-service-messenger_handle.h b/src/messenger/gnunet-service-messenger_handle.h deleted file mode 100644 index d8ff3aaa8..000000000 --- a/src/messenger/gnunet-service-messenger_handle.h +++ /dev/null | |||
@@ -1,238 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2020--2021 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/gnunet-service-messenger_handle.h | ||
23 | * @brief GNUnet MESSENGER service | ||
24 | */ | ||
25 | |||
26 | #ifndef GNUNET_SERVICE_MESSENGER_HANDLE_H | ||
27 | #define GNUNET_SERVICE_MESSENGER_HANDLE_H | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_cadet_service.h" | ||
31 | #include "gnunet_container_lib.h" | ||
32 | #include "gnunet_crypto_lib.h" | ||
33 | #include "gnunet_identity_service.h" | ||
34 | #include "gnunet_peer_lib.h" | ||
35 | #include "gnunet_mq_lib.h" | ||
36 | |||
37 | #include "gnunet-service-messenger_service.h" | ||
38 | #include "gnunet-service-messenger_member_session.h" | ||
39 | |||
40 | #include "messenger_api_ego.h" | ||
41 | #include "messenger_api_message.h" | ||
42 | |||
43 | struct GNUNET_MESSENGER_SrvHandle | ||
44 | { | ||
45 | struct GNUNET_MESSENGER_Service *service; | ||
46 | struct GNUNET_MQ_Handle *mq; | ||
47 | |||
48 | char *name; | ||
49 | |||
50 | const struct GNUNET_MESSENGER_Ego *ego; | ||
51 | |||
52 | struct GNUNET_CONTAINER_MultiHashMap *member_ids; | ||
53 | }; | ||
54 | |||
55 | /** | ||
56 | * Creates and allocates a new handle related to a <i>service</i> and using a given <i>mq</i> (message queue). | ||
57 | * | ||
58 | * @param[in/out] service MESSENGER Service | ||
59 | * @param[in/out] mq Message queue | ||
60 | * @return New handle | ||
61 | */ | ||
62 | struct GNUNET_MESSENGER_SrvHandle* | ||
63 | create_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq); | ||
64 | |||
65 | /** | ||
66 | * Destroys a handle and frees its memory fully. | ||
67 | * | ||
68 | * @param[in/out] handle Handle | ||
69 | */ | ||
70 | void | ||
71 | destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle); | ||
72 | |||
73 | /** | ||
74 | * Writes the path of the directory for a given <i>handle</i> using a specific <i>name</i> to the parameter | ||
75 | * <i>dir</i>. This directory will be used to store data regarding the handle and its messages. | ||
76 | * | ||
77 | * @param[in] handle Handle | ||
78 | * @param[in] name Potential name of the handle | ||
79 | * @param[out] dir Path to store data | ||
80 | */ | ||
81 | void | ||
82 | get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir); | ||
83 | |||
84 | /** | ||
85 | * Returns the member id of a given <i>handle</i> in a specific <i>room</i>. | ||
86 | * | ||
87 | * If the handle is not a member of the specific <i>room</i>, NULL gets returned. | ||
88 | * | ||
89 | * @param[in] handle Handle | ||
90 | * @param[in] key Key of a room | ||
91 | * @return Member id or NULL | ||
92 | */ | ||
93 | const struct GNUNET_ShortHashCode* | ||
94 | get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); | ||
95 | |||
96 | /** | ||
97 | * Changes the member id of a given <i>handle</i> in a specific <i>room</i> to match a <i>unique_id</i> | ||
98 | * and returns GNUNET_OK on success. | ||
99 | * | ||
100 | * The client connected to the <i>handle</i> will be informed afterwards automatically. | ||
101 | * | ||
102 | * @param[in/out] handle Handle | ||
103 | * @param[in] key Key of a room | ||
104 | * @param[in] unique_id Unique member id | ||
105 | * @return GNUNET_OK on success, otherwise GNUNET_SYSERR | ||
106 | */ | ||
107 | int | ||
108 | change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | ||
109 | const struct GNUNET_ShortHashCode *unique_id); | ||
110 | |||
111 | /** | ||
112 | * Sets the EGO used by a given <i>handle</i>. | ||
113 | * | ||
114 | * @param[in/out] handle Handle | ||
115 | * @param[in] ego EGO key pair | ||
116 | */ | ||
117 | void | ||
118 | set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Ego *ego); | ||
119 | |||
120 | /** | ||
121 | * Returns the EGO used by a given <i>handle</i>. | ||
122 | * | ||
123 | * @param[in] handle Handle | ||
124 | * @return EGO key pair | ||
125 | */ | ||
126 | const struct GNUNET_MESSENGER_Ego* | ||
127 | get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle); | ||
128 | |||
129 | /** | ||
130 | * Tries to set the name and EGO key of a <i>handle</i> initially by looking up a specific <i>name</i>. | ||
131 | * | ||
132 | * @param[in/out] handle Handle | ||
133 | * @param[in] name Name (optionally: valid EGO name) | ||
134 | */ | ||
135 | void | ||
136 | setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); | ||
137 | |||
138 | /** | ||
139 | * Tries to change the key pair of an EGO of a <i>handle</i> under the same name and informs all rooms | ||
140 | * about the change automatically. | ||
141 | * | ||
142 | * @param[in/out] handle Handle | ||
143 | */ | ||
144 | void | ||
145 | update_handle (struct GNUNET_MESSENGER_SrvHandle *handle); | ||
146 | |||
147 | /** | ||
148 | * Tries to rename the handle which implies renaming the EGO its using and moving all related data into | ||
149 | * the directory fitting to the changed <i>name</i>. | ||
150 | * | ||
151 | * The client connected to the <i>handle</i> will be informed afterwards automatically. | ||
152 | * | ||
153 | * @param[in/out] handle Handle | ||
154 | * @param[in] name New name | ||
155 | */ | ||
156 | void | ||
157 | set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle, const char *name); | ||
158 | |||
159 | /** | ||
160 | * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and opens the | ||
161 | * room from the handles service. | ||
162 | * | ||
163 | * @param[in/out] handle Handle | ||
164 | * @param[in] key Key of a room | ||
165 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | ||
166 | */ | ||
167 | int | ||
168 | open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); | ||
169 | |||
170 | /** | ||
171 | * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and enters the room | ||
172 | * through a tunnel to a peer identified by a given <i>door</i> (peer identity). | ||
173 | * | ||
174 | * @param[in/out] handle Handle | ||
175 | * @param[in] door Peer identity | ||
176 | * @param[in] key Key of a room | ||
177 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | ||
178 | */ | ||
179 | int | ||
180 | entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, | ||
181 | const struct GNUNET_HashCode *key); | ||
182 | |||
183 | /** | ||
184 | * Removes the membership of the room using a specific <i>key</i> and closes it if no other handle | ||
185 | * from this service is still a member of it. | ||
186 | * | ||
187 | * @param[in/out] handle Handle | ||
188 | * @param[in] key Key of a room | ||
189 | * @return #GNUNET_YES on success, otherwise #GNUNET_NO | ||
190 | */ | ||
191 | int | ||
192 | close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key); | ||
193 | |||
194 | /** | ||
195 | * Sends a <i>message</i> from a given <i>handle</i> to the room using a specific <i>key</i>. | ||
196 | * | ||
197 | * @param[in/out] handle Handle | ||
198 | * @param[in] key Key of a room | ||
199 | * @param[in] message Message | ||
200 | * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise. | ||
201 | */ | ||
202 | int | ||
203 | send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | ||
204 | const struct GNUNET_MESSENGER_Message *message); | ||
205 | |||
206 | /** | ||
207 | * Notifies the handle that a new message was received or sent. | ||
208 | * | ||
209 | * @param[in/out] handle Handle | ||
210 | * @param[in] key Key of room | ||
211 | * @param[in] session Member session | ||
212 | * @param[in] message Message | ||
213 | * @param[in] hash Hash of message | ||
214 | */ | ||
215 | void | ||
216 | notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, | ||
217 | const struct GNUNET_MESSENGER_MemberSession *session, | ||
218 | const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash); | ||
219 | |||
220 | /** | ||
221 | * Loads member ids and other potential configuration from a given <i>handle</i> which | ||
222 | * depends on the given name the <i>handle</i> uses. | ||
223 | * | ||
224 | * @param[out] handle Handle | ||
225 | */ | ||
226 | void | ||
227 | load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle); | ||
228 | |||
229 | /** | ||
230 | * Saves member ids and other potential configuration from a given <i>handle</i> which | ||
231 | * depends on the given name the <i>handle</i> uses. | ||
232 | * | ||
233 | * @param[in] handle Handle | ||
234 | */ | ||
235 | void | ||
236 | save_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle); | ||
237 | |||
238 | #endif //GNUNET_SERVICE_MESSENGER_HANDLE_H | ||