aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/gnunet-service-messenger_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/gnunet-service-messenger_service.h')
-rw-r--r--src/messenger/gnunet-service-messenger_service.h212
1 files changed, 0 insertions, 212 deletions
diff --git a/src/messenger/gnunet-service-messenger_service.h b/src/messenger/gnunet-service-messenger_service.h
deleted file mode 100644
index d364a93c0..000000000
--- a/src/messenger/gnunet-service-messenger_service.h
+++ /dev/null
@@ -1,212 +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_service.h
23 * @brief GNUnet MESSENGER service
24 */
25
26#ifndef GNUNET_SERVICE_MESSENGER_SERVICE_H
27#define GNUNET_SERVICE_MESSENGER_SERVICE_H
28
29#include "platform.h"
30#include "gnunet_configuration_lib.h"
31#include "gnunet_crypto_lib.h"
32#include "gnunet_container_lib.h"
33#include "gnunet_disk_lib.h"
34#include "gnunet_identity_service.h"
35
36#include "gnunet-service-messenger_ego_store.h"
37#include "gnunet-service-messenger_list_handles.h"
38
39#include "messenger_api_contact_store.h"
40#include "gnunet-service-messenger_room.h"
41
42#include "gnunet-service-messenger_member_session.h"
43
44struct GNUNET_MESSENGER_Service
45{
46 const struct GNUNET_CONFIGURATION_Handle *config;
47 struct GNUNET_SERVICE_Handle *service;
48
49 struct GNUNET_SCHEDULER_Task *shutdown;
50
51 char *dir;
52
53 struct GNUNET_CADET_Handle *cadet;
54
55 struct GNUNET_MESSENGER_EgoStore ego_store;
56 struct GNUNET_MESSENGER_ContactStore contact_store;
57
58 struct GNUNET_MESSENGER_ListHandles handles;
59
60 struct GNUNET_CONTAINER_MultiHashMap *rooms;
61};
62
63/**
64 * Creates and allocates a new service using a given <i>config</i> and a GNUnet service handle.
65 *
66 * @param[in] config Configuration
67 * @param[in/out] service_handle GNUnet service handle
68 * @return New service
69 */
70struct GNUNET_MESSENGER_Service*
71create_service (const struct GNUNET_CONFIGURATION_Handle *config,
72 struct GNUNET_SERVICE_Handle *service_handle);
73
74/**
75 * Destroys a <i>service</i> and frees its memory fully.
76 *
77 * @param[in/out] service Service
78 */
79void
80destroy_service (struct GNUNET_MESSENGER_Service *service);
81
82/**
83 * Returns the used EGO-store of a given <i>service</i>.
84 *
85 * @param[in/out] service Service
86 * @return EGO-store
87 */
88struct GNUNET_MESSENGER_EgoStore*
89get_service_ego_store (struct GNUNET_MESSENGER_Service *service);
90
91/**
92 * Returns the used contact store of a given <i>service</i>.
93 *
94 * @param[in/out] service Service
95 * @return Contact store
96 */
97struct GNUNET_MESSENGER_ContactStore*
98get_service_contact_store (struct GNUNET_MESSENGER_Service *service);
99
100/**
101 * Creates and adds a new handle to a <i>service</i> using a given message queue.
102 *
103 * @param[in/out] service Service
104 * @param[in/out] mq Message queue
105 * @return New handle
106 */
107struct GNUNET_MESSENGER_SrvHandle*
108add_service_handle (struct GNUNET_MESSENGER_Service *service,
109 struct GNUNET_MQ_Handle *mq);
110
111/**
112 * Removes a <i>handle</i> from a <i>service</i> and destroys it.
113 *
114 * @param[in/out] service Service
115 * @param[in/out] handle Handle
116 */
117void
118remove_service_handle (struct GNUNET_MESSENGER_Service *service,
119 struct GNUNET_MESSENGER_SrvHandle *handle);
120
121/**
122 * Tries to write the peer identity of the peer running a <i>service</i> on to the <i>peer</i>
123 * parameter. The functions returns #GNUNET_OK on success, otherwise #GNUNET_SYSERR.
124 *
125 * @param[in] service Service
126 * @param[out] peer Peer identity
127 * @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR
128 */
129int
130get_service_peer_identity (const struct GNUNET_MESSENGER_Service *service,
131 struct GNUNET_PeerIdentity *peer);
132
133/**
134 * Returns the room identified by a given <i>key</i> for a <i>service</i>. If the service doesn't know any room
135 * using the given key, NULL gets returned.
136 *
137 * @param[in] service Service
138 * @param[in] key Key of room
139 * @return Room or NULL
140 */
141struct GNUNET_MESSENGER_SrvRoom*
142get_service_room (const struct GNUNET_MESSENGER_Service *service,
143 const struct GNUNET_HashCode *key);
144
145/**
146 * Tries to open a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will be
147 * created if necessary. If the function is successful, it returns #GNUNET_YES, otherwise #GNUNET_NO.
148 *
149 * @param[in/out] service Service
150 * @param[in/out] handle Handle
151 * @param[in] key Key of room
152 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
153 */
154int
155open_service_room (struct GNUNET_MESSENGER_Service *service,
156 struct GNUNET_MESSENGER_SrvHandle *handle,
157 const struct GNUNET_HashCode *key);
158
159/**
160 * Tries to enter a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will
161 * be created if necessary. If the function is successful, it returns #GNUNET_YES, otherwise #GNUNET_NO.
162 *
163 * The room will be entered through the peer identitied by the peer identity provided as <i>door</i> parameter and
164 * a new connection will be made.
165 *
166 * @param[in/out] service Service
167 * @param[in/out] handle Handle
168 * @param[in] door Peer identity
169 * @param[in] key Key of room
170 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
171 */
172int
173entry_service_room (struct GNUNET_MESSENGER_Service *service,
174 struct GNUNET_MESSENGER_SrvHandle *handle,
175 const struct GNUNET_PeerIdentity *door,
176 const struct GNUNET_HashCode *key);
177
178/**
179 * Tries to close a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will
180 * be created if necessary. If the function is successful, it returns #GNUNET_YES, otherwise #GNUNET_NO.
181 *
182 * If the specific handle is currently the host of the room for this service, a new handle which is a member will
183 * take its place. Otherwise the room will be destroyed for this service.
184 *
185 * @param[in/out] service Service
186 * @param[in/out] handle Handle
187 * @param[in] key Key of room
188 * @return #GNUNET_YES on success, otherwise #GNUNET_NO
189 */
190int
191close_service_room (struct GNUNET_MESSENGER_Service *service,
192 struct GNUNET_MESSENGER_SrvHandle *handle,
193 const struct GNUNET_HashCode *key);
194
195/**
196 * Sends a received or sent <i>message</i> with a given <i>hash</i> to each handle of a <i>service</i> which
197 * is currently member of a specific <i>room</i> for handling it in the client API.
198 *
199 * @param[in/out] service Service
200 * @param[in/out] room Room
201 * @param[in] session Member session
202 * @param[in] message Message
203 * @param[in] hash Hash of message
204 */
205void
206handle_service_message (struct GNUNET_MESSENGER_Service *service,
207 struct GNUNET_MESSENGER_SrvRoom *room,
208 const struct GNUNET_MESSENGER_MemberSession *session,
209 const struct GNUNET_MESSENGER_Message *message,
210 const struct GNUNET_HashCode *hash);
211
212#endif //GNUNET_SERVICE_MESSENGER_SERVICE_H