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.h147
1 files changed, 0 insertions, 147 deletions
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h
deleted file mode 100644
index 320312f0c..000000000
--- a/src/messenger/messenger_api_room.h
+++ /dev/null
@@ -1,147 +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,
68 const struct GNUNET_HashCode *key);
69
70/**
71 * Destroys a room and frees its memory fully from the client API.
72 *
73 * @param[in/out] room Room
74 */
75void
76destroy_room (struct GNUNET_MESSENGER_Room *room);
77
78/**
79 * Returns a message locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no matching
80 * message is found, NULL gets returned.
81 *
82 * @param[in] room Room
83 * @param[in] hash Hash of message
84 * @return Message or NULL
85 */
86const struct GNUNET_MESSENGER_Message*
87get_room_message (const struct GNUNET_MESSENGER_Room *room,
88 const struct GNUNET_HashCode *hash);
89
90/**
91 * Returns a messages sender locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no
92 * matching message is found, NULL gets returned.
93 *
94 * @param[in] room Room
95 * @param[in] hash Hash of message
96 * @return Contact of sender or NULL
97 */
98struct GNUNET_MESSENGER_Contact*
99get_room_sender (const struct GNUNET_MESSENGER_Room *room,
100 const struct GNUNET_HashCode *hash);
101
102/**
103 * Handles a <i>message</i> with a given <i>hash</i> in a <i>room</i> for the client API to update
104 * members and its information. The function also stores the message in map locally for access afterwards.
105 *
106 * The contact of the message's sender could be updated or even created. It may not be freed or destroyed though!
107 * (The contact may still be in use for old messages...)
108 *
109 * @param[in/out] room Room
110 * @param[in/out] sender Contact of sender
111 * @param[in] message Message
112 * @param[in] hash Hash of message
113 * @return Contact of sender
114 */
115struct GNUNET_MESSENGER_Contact*
116handle_room_message (struct GNUNET_MESSENGER_Room *room,
117 struct GNUNET_MESSENGER_Contact *sender,
118 const struct GNUNET_MESSENGER_Message *message,
119 const struct GNUNET_HashCode *hash);
120
121/**
122 * Iterates through all members of a given <i>room</i> to forward each of them to a selected
123 * <i>callback</i> with a custom closure.
124 *
125 * @param[in/out] room Room
126 * @param[in] callback Function called for each member
127 * @param[in/out] cls Closure
128 * @return Amount of members iterated
129 */
130int
131iterate_room_members (struct GNUNET_MESSENGER_Room *room,
132 GNUNET_MESSENGER_MemberCallback callback,
133 void* cls);
134
135/**
136 * Checks through all members of a given <i>room</i> if a specific <i>contact</i> is found and
137 * returns a result depending on that.
138 *
139 * @param[in] room Room
140 * @param[in] contact
141 * @return #GNUNET_YES if found, otherwise #GNUNET_NO
142 */
143int
144find_room_member (const struct GNUNET_MESSENGER_Room *room,
145 const struct GNUNET_MESSENGER_Contact *contact);
146
147#endif //GNUNET_MESSENGER_API_ROOM_H