aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_handle.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/gnunet-service-messenger_handle.h')
-rw-r--r--src/messenger/gnunet-service-messenger_handle.h252
1 files changed, 0 insertions, 252 deletions
diff --git a/src/messenger/gnunet-service-messenger_handle.h b/src/messenger/gnunet-service-messenger_handle.h
deleted file mode 100644
index 8754716e9..000000000
--- a/src/messenger/gnunet-service-messenger_handle.h
+++ /dev/null
@@ -1,252 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2022 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
43struct 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 */
62struct GNUNET_MESSENGER_SrvHandle*
63create_srv_handle (struct GNUNET_MESSENGER_Service *service,
64 struct GNUNET_MQ_Handle *mq);
65
66/**
67 * Destroys a handle and frees its memory fully.
68 *
69 * @param[in/out] handle Handle
70 */
71void
72destroy_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
73
74/**
75 * Writes the path of the directory for a given <i>handle</i> using a specific <i>name</i> to the parameter
76 * <i>dir</i>. This directory will be used to store data regarding the handle and its messages.
77 *
78 * @param[in] handle Handle
79 * @param[in] name Potential name of the handle
80 * @param[out] dir Path to store data
81 */
82void
83get_srv_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
84 const char *name,
85 char **dir);
86
87/**
88 * Returns the member id of a given <i>handle</i> in a specific <i>room</i>.
89 *
90 * If the handle is not a member of the specific <i>room</i>, NULL gets returned.
91 *
92 * @param[in] handle Handle
93 * @param[in] key Key of a room
94 * @return Member id or NULL
95 */
96const struct GNUNET_ShortHashCode*
97get_srv_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
98 const struct GNUNET_HashCode *key);
99
100/**
101 * Changes the member id of a given <i>handle</i> in a specific <i>room</i> to match a <i>unique_id</i>
102 * and returns GNUNET_OK on success.
103 *
104 * The client connected to the <i>handle</i> will be informed afterwards automatically.
105 *
106 * @param[in/out] handle Handle
107 * @param[in] key Key of a room
108 * @param[in] unique_id Unique member id
109 * @return GNUNET_OK on success, otherwise GNUNET_SYSERR
110 */
111int
112change_srv_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle,
113 const struct GNUNET_HashCode *key,
114 const struct GNUNET_ShortHashCode *unique_id);
115
116/**
117 * Sets the EGO used by a given <i>handle</i>.
118 *
119 * @param[in/out] handle Handle
120 * @param[in] ego EGO key pair
121 */
122void
123set_srv_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
124 const struct GNUNET_MESSENGER_Ego *ego);
125
126/**
127 * Returns the EGO used by a given <i>handle</i>.
128 *
129 * @param[in] handle Handle
130 * @return EGO key pair
131 */
132const struct GNUNET_MESSENGER_Ego*
133get_srv_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle);
134
135/**
136 * Tries to set the name and EGO key of a <i>handle</i> initially by looking up a specific <i>name</i>.
137 *
138 * @param[in/out] handle Handle
139 * @param[in] name Name (optionally: valid EGO name)
140 */
141void
142setup_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
143 const char *name);
144
145/**
146 * Tries to change the key pair of an EGO of a <i>handle</i> under the same name and informs all rooms
147 * about the change automatically.
148 *
149 * @param[in/out] handle Handle
150 */
151void
152update_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
153
154/**
155 * Tries to rename the handle which implies renaming the EGO its using and moving all related data into
156 * the directory fitting to the changed <i>name</i>.
157 *
158 * The client connected to the <i>handle</i> will be informed afterwards automatically.
159 *
160 * @param[in/out] handle Handle
161 * @param[in] name New name
162 */
163void
164set_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
165 const char *name);
166
167/**
168 * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and opens the
169 * room from the handles service.
170 *
171 * @param[in/out] handle Handle
172 * @param[in] key Key of a room
173 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
174 */
175int
176open_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
177 const struct GNUNET_HashCode *key);
178
179/**
180 * Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and enters the room
181 * through a tunnel to a peer identified by a given <i>door</i> (peer identity).
182 *
183 * @param[in/out] handle Handle
184 * @param[in] door Peer identity
185 * @param[in] key Key of a room
186 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
187 */
188int
189entry_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
190 const struct GNUNET_PeerIdentity *door,
191 const struct GNUNET_HashCode *key);
192
193/**
194 * Removes the membership of the room using a specific <i>key</i> and closes it if no other handle
195 * from this service is still a member of it.
196 *
197 * @param[in/out] handle Handle
198 * @param[in] key Key of a room
199 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
200 */
201int
202close_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
203 const struct GNUNET_HashCode *key);
204
205/**
206 * Sends a <i>message</i> from a given <i>handle</i> to the room using a specific <i>key</i>.
207 *
208 * @param[in/out] handle Handle
209 * @param[in] key Key of a room
210 * @param[in] message Message
211 * @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise.
212 */
213int
214send_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
215 const struct GNUNET_HashCode *key,
216 const struct GNUNET_MESSENGER_Message *message);
217
218/**
219 * Notifies the handle that a new message was received or sent.
220 *
221 * @param[in/out] handle Handle
222 * @param[in] room Room of the message
223 * @param[in] session Member session
224 * @param[in] message Message
225 * @param[in] hash Hash of message
226 */
227void
228notify_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
229 struct GNUNET_MESSENGER_SrvRoom *room,
230 const struct GNUNET_MESSENGER_MemberSession *session,
231 const struct GNUNET_MESSENGER_Message *message,
232 const struct GNUNET_HashCode *hash);
233
234/**
235 * Loads member ids and other potential configuration from a given <i>handle</i> which
236 * depends on the given name the <i>handle</i> uses.
237 *
238 * @param[out] handle Handle
239 */
240void
241load_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
242
243/**
244 * Saves member ids and other potential configuration from a given <i>handle</i> which
245 * depends on the given name the <i>handle</i> uses.
246 *
247 * @param[in] handle Handle
248 */
249void
250save_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
251
252#endif //GNUNET_SERVICE_MESSENGER_HANDLE_H