diff options
Diffstat (limited to 'src/service/messenger/messenger_api_room.h')
-rw-r--r-- | src/service/messenger/messenger_api_room.h | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/src/service/messenger/messenger_api_room.h b/src/service/messenger/messenger_api_room.h index d5ffc5c4b..2504a51dd 100644 --- a/src/service/messenger/messenger_api_room.h +++ b/src/service/messenger/messenger_api_room.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2020--2021 GNUnet e.V. | 3 | Copyright (C) 2020--2023 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 6 | under the terms of the GNU Affero General Public License as published |
@@ -34,10 +34,12 @@ | |||
34 | #include "messenger_api_list_tunnels.h" | 34 | #include "messenger_api_list_tunnels.h" |
35 | #include "messenger_api_contact.h" | 35 | #include "messenger_api_contact.h" |
36 | #include "messenger_api_message.h" | 36 | #include "messenger_api_message.h" |
37 | #include "messenger_api_queue_messages.h" | ||
37 | 38 | ||
38 | struct GNUNET_MESSENGER_RoomMessageEntry { | 39 | struct GNUNET_MESSENGER_RoomMessageEntry |
39 | struct GNUNET_MESSENGER_Contact* sender; | 40 | { |
40 | struct GNUNET_MESSENGER_Message* message; | 41 | struct GNUNET_MESSENGER_Contact *sender; |
42 | struct GNUNET_MESSENGER_Message *message; | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | struct GNUNET_MESSENGER_Room | 45 | struct GNUNET_MESSENGER_Room |
@@ -45,14 +47,20 @@ struct GNUNET_MESSENGER_Room | |||
45 | struct GNUNET_MESSENGER_Handle *handle; | 47 | struct GNUNET_MESSENGER_Handle *handle; |
46 | struct GNUNET_HashCode key; | 48 | struct GNUNET_HashCode key; |
47 | 49 | ||
48 | int opened; | 50 | struct GNUNET_HashCode last_message; |
51 | |||
52 | enum GNUNET_GenericReturnValue opened; | ||
53 | enum GNUNET_GenericReturnValue use_handle_name; | ||
54 | enum GNUNET_GenericReturnValue wait_for_sync; | ||
49 | 55 | ||
50 | struct GNUNET_ShortHashCode *contact_id; | 56 | struct GNUNET_ShortHashCode *sender_id; |
51 | 57 | ||
52 | struct GNUNET_MESSENGER_ListTunnels entries; | 58 | struct GNUNET_MESSENGER_ListTunnels entries; |
53 | 59 | ||
54 | struct GNUNET_CONTAINER_MultiHashMap *messages; | 60 | struct GNUNET_CONTAINER_MultiHashMap *messages; |
55 | struct GNUNET_CONTAINER_MultiShortmap *members; | 61 | struct GNUNET_CONTAINER_MultiShortmap *members; |
62 | |||
63 | struct GNUNET_MESSENGER_QueueMessages queue; | ||
56 | }; | 64 | }; |
57 | 65 | ||
58 | /** | 66 | /** |
@@ -75,6 +83,34 @@ void | |||
75 | destroy_room (struct GNUNET_MESSENGER_Room *room); | 83 | destroy_room (struct GNUNET_MESSENGER_Room *room); |
76 | 84 | ||
77 | /** | 85 | /** |
86 | * Checks whether a room is available to send messages. | ||
87 | * | ||
88 | * @param[in] room Room | ||
89 | * @return GNUNET_YES if the room is available, otherwise GNUNET_NO | ||
90 | */ | ||
91 | enum GNUNET_GenericReturnValue | ||
92 | is_room_available (const struct GNUNET_MESSENGER_Room *room); | ||
93 | |||
94 | /** | ||
95 | * Returns the member id of the <i>room</i>'s sender. | ||
96 | * | ||
97 | * @param[in] room Room | ||
98 | * @return Member id or NULL | ||
99 | */ | ||
100 | const struct GNUNET_ShortHashCode* | ||
101 | get_room_sender_id (const struct GNUNET_MESSENGER_Room *room); | ||
102 | |||
103 | /** | ||
104 | * Sets the member id of the <i>room</i>'s sender to a specific <i>id</i> or NULL. | ||
105 | * | ||
106 | * @param[in,out] room Room | ||
107 | * @param[in] id Member id or NULL | ||
108 | */ | ||
109 | void | ||
110 | set_room_sender_id (struct GNUNET_MESSENGER_Room *room, | ||
111 | const struct GNUNET_ShortHashCode *id); | ||
112 | |||
113 | /** | ||
78 | * Returns a message locally stored from a map for a given <i>hash</i> in a <i>room</i>. If no matching | 114 | * 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. | 115 | * message is found, NULL gets returned. |
80 | * | 116 | * |
@@ -109,13 +145,15 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room, | |||
109 | * @param[in,out] sender Contact of sender | 145 | * @param[in,out] sender Contact of sender |
110 | * @param[in] message Message | 146 | * @param[in] message Message |
111 | * @param[in] hash Hash of message | 147 | * @param[in] hash Hash of message |
148 | * @param[in] flags Flags of message | ||
112 | * @return Contact of sender | 149 | * @return Contact of sender |
113 | */ | 150 | */ |
114 | struct GNUNET_MESSENGER_Contact* | 151 | struct GNUNET_MESSENGER_Contact* |
115 | handle_room_message (struct GNUNET_MESSENGER_Room *room, | 152 | handle_room_message (struct GNUNET_MESSENGER_Room *room, |
116 | struct GNUNET_MESSENGER_Contact *sender, | 153 | struct GNUNET_MESSENGER_Contact *sender, |
117 | const struct GNUNET_MESSENGER_Message *message, | 154 | const struct GNUNET_MESSENGER_Message *message, |
118 | const struct GNUNET_HashCode *hash); | 155 | const struct GNUNET_HashCode *hash, |
156 | enum GNUNET_MESSENGER_MessageFlags flags); | ||
119 | 157 | ||
120 | /** | 158 | /** |
121 | * Iterates through all members of a given <i>room</i> to forward each of them to a selected | 159 | * Iterates through all members of a given <i>room</i> to forward each of them to a selected |
@@ -129,7 +167,7 @@ handle_room_message (struct GNUNET_MESSENGER_Room *room, | |||
129 | int | 167 | int |
130 | iterate_room_members (struct GNUNET_MESSENGER_Room *room, | 168 | iterate_room_members (struct GNUNET_MESSENGER_Room *room, |
131 | GNUNET_MESSENGER_MemberCallback callback, | 169 | GNUNET_MESSENGER_MemberCallback callback, |
132 | void* cls); | 170 | void *cls); |
133 | 171 | ||
134 | /** | 172 | /** |
135 | * Checks through all members of a given <i>room</i> if a specific <i>contact</i> is found and | 173 | * Checks through all members of a given <i>room</i> if a specific <i>contact</i> is found and |