aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/messenger_api_room.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/messenger_api_room.h')
-rw-r--r--src/messenger/messenger_api_room.h140
1 files changed, 0 insertions, 140 deletions
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h
deleted file mode 100644
index 634052272..000000000
--- a/src/messenger/messenger_api_room.h
+++ /dev/null
@@ -1,140 +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/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
39struct GNUNET_MESSENGER_RoomMessageEntry {
40 struct GNUNET_MESSENGER_Contact* sender;
41 struct GNUNET_MESSENGER_Message* message;
42};
43
44struct GNUNET_MESSENGER_Room
45{
46 struct GNUNET_MESSENGER_Handle *handle;
47 struct GNUNET_HashCode key;
48
49 int opened;
50
51 struct GNUNET_ShortHashCode *contact_id;
52
53 struct GNUNET_MESSENGER_ListTunnels entries;
54
55 struct GNUNET_CONTAINER_MultiHashMap *messages;
56 struct GNUNET_CONTAINER_MultiShortmap *members;
57};
58
59/**
60 * Creates and allocates a new room for a <i>handle</i> with a given <i>key</i> for the client API.
61 *
62 * @param[in/out] handle Handle
63 * @param[in] key Key of room
64 * @return New room
65 */
66struct GNUNET_MESSENGER_Room*
67create_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key);
68
69/**
70 * Destroys a room and frees its memory fully from the client API.
71 *
72 * @param[in/out] room Room
73 */
74void
75destroy_room (struct GNUNET_MESSENGER_Room *room);
76
77/**
78 * Returns a message locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no matching
79 * message is found, NULL gets returned.
80 *
81 * @param[in] room Room
82 * @param[in] hash Hash of message
83 * @return Message or NULL
84 */
85const struct GNUNET_MESSENGER_Message*
86get_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash);
87
88/**
89 * Returns a messages sender locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no
90 * matching message is found, NULL gets returned.
91 *
92 * @param[in] room Room
93 * @param[in] hash Hash of message
94 * @return Contact of sender or NULL
95 */
96struct GNUNET_MESSENGER_Contact*
97get_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash);
98
99/**
100 * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update
101 * members and its information. The function also stores the message in map locally for access afterwards.
102 *
103 * The contact of the message's sender could be updated or even created. It may not be freed or destroyed though!
104 * (The contact may still be in use for old messages...)
105 *
106 * @param[in/out] room Room
107 * @param[in/out] sender Contact of sender
108 * @param[in] message Message
109 * @param[in] hash Hash of message
110 * @return Contact of sender
111 */
112struct GNUNET_MESSENGER_Contact*
113handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender,
114 const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash);
115
116/**
117 * Iterates through all members of a given <i>room</i> to forward each of them to a selected
118 * <i>callback</i> with a custom closure.
119 *
120 * @param[in/out] room Room
121 * @param[in] callback Function called for each member
122 * @param[in/out] cls Closure
123 * @return Amount of members iterated
124 */
125int
126iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback,
127 void* cls);
128
129/**
130 * Checks through all members of a given <i>room</i> if a specific <i>contact</i> is found and
131 * returns a result depending on that.
132 *
133 * @param[in] room Room
134 * @param[in] contact
135 * @return #GNUNET_YES if found, otherwise #GNUNET_NO
136 */
137int
138find_room_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact);
139
140#endif //GNUNET_MESSENGER_API_ROOM_H