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