GNUnet 0.22.1
messenger_api_room.h File Reference
Include dependency graph for messenger_api_room.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_RoomSubscription
 
struct  GNUNET_MESSENGER_RoomMessageEntry
 
struct  GNUNET_MESSENGER_Room
 

Typedefs

typedef void(* GNUNET_MESSENGER_RoomLinkDeletion) (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 

Functions

struct GNUNET_MESSENGER_Roomcreate_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
 Creates and allocates a new room for a handle with a given key for the client API. More...
 
void destroy_room (struct GNUNET_MESSENGER_Room *room)
 Destroys a room and frees its memory fully from the client API. More...
 
enum GNUNET_GenericReturnValue is_room_available (const struct GNUNET_MESSENGER_Room *room)
 Checks whether a room is available to send messages. More...
 
struct GNUNET_MESSENGER_Handleget_room_handle (struct GNUNET_MESSENGER_Room *room)
 Returns the messenger handle of the room. More...
 
const struct GNUNET_ShortHashCodeget_room_sender_id (const struct GNUNET_MESSENGER_Room *room)
 Returns the member id of the room's sender. More...
 
void set_room_sender_id (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ShortHashCode *id)
 Sets the member id of the room's sender to a specific id or NULL. More...
 
const struct GNUNET_MESSENGER_Messageget_room_message (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns a message locally stored from a map for a given hash in a room. More...
 
struct GNUNET_MESSENGER_Contactget_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns a messages sender locally stored from a map for a given hash in a room. More...
 
struct GNUNET_MESSENGER_Contactget_room_recipient (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns a messages recipient locally stored from a map for a given hash in a room. More...
 
void delete_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 Deletes a message with a given hash inside a room under a specific delay. More...
 
void callback_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Executes the message callback for a given hash in a room. More...
 
void handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_MessageFlags flags)
 Handles a message with a given hash in a room for the client API to update members and its information. More...
 
void update_room_last_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Updates the last message hash of a room for the client API so that new messages can point to the latest message hash while sending. More...
 
int iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
 Iterates through all members of a given room to forward each of them to a selected callback with a custom closure. More...
 
enum GNUNET_GenericReturnValue find_room_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
 Checks through all members of a given room if a specific contact is found and returns a result depending on that. More...
 
void link_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *other)
 Links a message identified by its hash inside a given room with another message identified by its other hash. More...
 
void link_room_deletion (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay, GNUNET_MESSENGER_RoomLinkDeletion deletion)
 Delete all remaining links to a certain message identified by its hash inside a given room and cause a deletion process to all of the linked messages. More...
 

Typedef Documentation

◆ GNUNET_MESSENGER_RoomLinkDeletion

typedef void(* GNUNET_MESSENGER_RoomLinkDeletion) (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)

Definition at line 87 of file messenger_api_room.h.

Function Documentation

◆ create_room()

struct GNUNET_MESSENGER_Room * create_room ( struct GNUNET_MESSENGER_Handle handle,
const struct GNUNET_HashCode key 
)

Creates and allocates a new room for a handle with a given key for the client API.

Parameters
[in,out]handleHandle
[in]keyKey of room
Returns
New room

Definition at line 41 of file messenger_api_room.c.

43{
44 struct GNUNET_MESSENGER_Room *room;
45
46 GNUNET_assert ((handle) && (key));
47
48 room = GNUNET_new (struct GNUNET_MESSENGER_Room);
49 room->handle = handle;
50
51 GNUNET_memcpy (&(room->key), key, sizeof(*key));
52
53 memset (&(room->last_message), 0, sizeof(room->last_message));
54
55 room->opened = GNUNET_NO;
58
59 room->sender_id = NULL;
60
61 init_list_tunnels (&(room->entries));
62
66
68
69 init_queue_messages (&(room->queue));
70 room->queue_task = NULL;
71
72 room->control = create_message_control (room);
73
74 return room;
75}
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void init_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Initializes list of tunnels peer identities as empty list.
struct GNUNET_MESSENGER_MessageControl * create_message_control(struct GNUNET_MESSENGER_Room *room)
Creates and allocates a new message control for a room of the client API.
void init_queue_messages(struct GNUNET_MESSENGER_QueueMessages *messages)
Initializes queue of messages as empty queue.
struct GNUNET_CONTAINER_MultiHashMap * links
struct GNUNET_CONTAINER_MultiShortmap * subscriptions
struct GNUNET_MESSENGER_Handle * handle
enum GNUNET_GenericReturnValue opened
enum GNUNET_GenericReturnValue wait_for_sync
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_MESSENGER_MessageControl * control
struct GNUNET_SCHEDULER_Task * queue_task
struct GNUNET_CONTAINER_MultiHashMap * messages
enum GNUNET_GenericReturnValue use_handle_name
struct GNUNET_MESSENGER_QueueMessages queue
struct GNUNET_MESSENGER_ListTunnels entries
struct GNUNET_ShortHashCode * sender_id
struct GNUNET_HashCode key
struct GNUNET_HashCode last_message

References GNUNET_MESSENGER_Room::control, create_message_control(), GNUNET_MESSENGER_Room::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_YES, handle, GNUNET_MESSENGER_Room::handle, init_list_tunnels(), init_queue_messages(), key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::last_message, GNUNET_MESSENGER_Room::links, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_Room::opened, GNUNET_MESSENGER_Room::queue, GNUNET_MESSENGER_Room::queue_task, GNUNET_MESSENGER_Room::sender_id, GNUNET_MESSENGER_Room::subscriptions, GNUNET_MESSENGER_Room::use_handle_name, and GNUNET_MESSENGER_Room::wait_for_sync.

Referenced by GNUNET_MESSENGER_enter_room(), and GNUNET_MESSENGER_open_room().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_room()

void destroy_room ( struct GNUNET_MESSENGER_Room room)

Destroys a room and frees its memory fully from the client API.

Parameters
[in,out]roomRoom

Definition at line 134 of file messenger_api_room.c.

135{
136 GNUNET_assert (room);
137
139
140 if (room->queue_task)
142
143 clear_queue_messages (&(room->queue));
144 clear_list_tunnels (&(room->entries));
145
146 if (room->subscriptions)
147 {
150 NULL);
151
153 }
154
155 if (room->messages)
156 {
159
161 }
162
163 if (room->members)
165
166 if (room->links)
167 {
170
172 }
173
174 if (room->sender_id)
175 GNUNET_free (room->sender_id);
176
177 GNUNET_free (room);
178}
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:979
void clear_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Clears the list of tunnels peer identities.
void destroy_message_control(struct GNUNET_MESSENGER_MessageControl *control)
Destroys a message control and frees its memory fully from the client API.
void clear_queue_messages(struct GNUNET_MESSENGER_QueueMessages *messages)
Clears the queue of messages.
static enum GNUNET_GenericReturnValue iterate_destroy_subscription(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_destroy_link(void *cls, const struct GNUNET_HashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_destroy_message(void *cls, const struct GNUNET_HashCode *key, void *value)

References clear_list_tunnels(), clear_queue_messages(), GNUNET_MESSENGER_Room::control, destroy_message_control(), GNUNET_MESSENGER_Room::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), iterate_destroy_link(), iterate_destroy_message(), iterate_destroy_subscription(), GNUNET_MESSENGER_Room::links, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_Room::queue, GNUNET_MESSENGER_Room::queue_task, GNUNET_MESSENGER_RoomSubscription::room, GNUNET_MESSENGER_Room::sender_id, and GNUNET_MESSENGER_Room::subscriptions.

Referenced by close_handle_room(), GNUNET_MESSENGER_enter_room(), GNUNET_MESSENGER_open_room(), and iterate_destroy_room().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_room_available()

enum GNUNET_GenericReturnValue is_room_available ( const struct GNUNET_MESSENGER_Room room)

Checks whether a room is available to send messages.

Parameters
[in]roomRoom
Returns
GNUNET_YES if the room is available, otherwise GNUNET_NO

Definition at line 182 of file messenger_api_room.c.

183{
184 GNUNET_assert (room);
185
186 if (! get_room_sender_id (room))
187 return GNUNET_NO;
188
189 if ((GNUNET_YES == room->opened) || (room->entries.head))
190 return GNUNET_YES;
191 else
192 return GNUNET_NO;
193}
const struct GNUNET_ShortHashCode * get_room_sender_id(const struct GNUNET_MESSENGER_Room *room)
Returns the member id of the room's sender.
struct GNUNET_MESSENGER_ListTunnel * head

References GNUNET_MESSENGER_Room::entries, get_room_sender_id(), GNUNET_assert, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_ListTunnels::head, GNUNET_MESSENGER_Room::opened, and GNUNET_MESSENGER_RoomSubscription::room.

Referenced by dequeue_message_from_room(), dequeue_messages_from_room(), and enqueue_message_to_room().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_room_handle()

struct GNUNET_MESSENGER_Handle * get_room_handle ( struct GNUNET_MESSENGER_Room room)

Returns the messenger handle of the room.

Parameters
[in,out]roomRoom
Returns
Messenger handle or NULL

Definition at line 197 of file messenger_api_room.c.

198{
199 GNUNET_assert (room);
200
201 return room->handle;
202}

References GNUNET_assert, and GNUNET_MESSENGER_Room::handle.

Referenced by process_message_control(), and task_message_control().

Here is the caller graph for this function:

◆ get_room_sender_id()

const struct GNUNET_ShortHashCode * get_room_sender_id ( const struct GNUNET_MESSENGER_Room room)

Returns the member id of the room's sender.

Parameters
[in]roomRoom
Returns
Member id or NULL

Definition at line 206 of file messenger_api_room.c.

207{
208 GNUNET_assert (room);
209
210 return room->sender_id;
211}

References GNUNET_assert, and GNUNET_MESSENGER_Room::sender_id.

Referenced by get_handle_contact(), handle_member_id(), handle_miss_message(), is_room_available(), and send_message_to_room().

Here is the caller graph for this function:

◆ set_room_sender_id()

void set_room_sender_id ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_ShortHashCode id 
)

Sets the member id of the room's sender to a specific id or NULL.

Parameters
[in,out]roomRoom
[in]idMember id or NULL

Definition at line 215 of file messenger_api_room.c.

217{
218 GNUNET_assert (room);
219
220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Set member id for room: %s\n",
221 GNUNET_h2s (&(room->key)));
222
223 if (! id)
224 {
225 if (room->sender_id)
226 GNUNET_free (room->sender_id);
227
228 room->sender_id = NULL;
229 return;
230 }
231
232 if (! room->sender_id)
234
235 GNUNET_memcpy (room->sender_id, id, sizeof(struct GNUNET_ShortHashCode));
236}
#define GNUNET_log(kind,...)
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
A 256-bit hashcode.

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_MESSENGER_Room::key, and GNUNET_MESSENGER_Room::sender_id.

Referenced by handle_id_message(), and handle_member_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_room_message()

const struct GNUNET_MESSENGER_Message * get_room_message ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns a message locally stored from a map for a given hash in a room.

If no matching message is found, NULL gets returned.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
Message or NULL

Definition at line 240 of file messenger_api_room.c.

242{
244
245 GNUNET_assert ((room) && (hash));
246
247 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
248
249 if ((! entry) || (GNUNET_YES != entry->completed))
250 return NULL;
251
252 return entry->message;
253}
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
struct GNUNET_MESSENGER_Message * message
enum GNUNET_GenericReturnValue completed

References GNUNET_MESSENGER_RoomMessageEntry::completed, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_YES, GNUNET_MESSENGER_RoomMessageEntry::message, and GNUNET_MESSENGER_Room::messages.

Referenced by GNUNET_MESSENGER_get_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_room_sender()

struct GNUNET_MESSENGER_Contact * get_room_sender ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns a messages sender locally stored from a map for a given hash in a room.

If no matching message is found, NULL gets returned.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
Contact of sender or NULL

Definition at line 257 of file messenger_api_room.c.

259{
261
262 GNUNET_assert ((room) && (hash));
263
264 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
265
266 if ((! entry) || (GNUNET_YES != entry->completed))
267 return NULL;
268
269 return entry->sender;
270}
struct GNUNET_MESSENGER_Contact * sender

References GNUNET_MESSENGER_RoomMessageEntry::completed, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_YES, GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by GNUNET_MESSENGER_get_sender().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_room_recipient()

struct GNUNET_MESSENGER_Contact * get_room_recipient ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns a messages recipient locally stored from a map for a given hash in a room.

If no matching message is found or the message has not been privately received, NULL gets returned.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
Contact of recipient or NULL

Definition at line 274 of file messenger_api_room.c.

276{
278
279 GNUNET_assert ((room) && (hash));
280
281 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
282
283 if ((! entry) || (GNUNET_YES != entry->completed))
284 return NULL;
285
286 return entry->recipient;
287}
struct GNUNET_MESSENGER_Contact * recipient

References GNUNET_MESSENGER_RoomMessageEntry::completed, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_YES, GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_RoomMessageEntry::recipient.

Referenced by GNUNET_MESSENGER_get_recipient().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_room_message()

void delete_room_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay 
)

Deletes a message with a given hash inside a room under a specific delay.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]delayDelay of deletion

Definition at line 291 of file messenger_api_room.c.

294{
295 struct GNUNET_MESSENGER_Message *message;
296
297 GNUNET_assert ((room) && (hash));
298
299 message = create_message_delete (hash, delay);
300
301 if (! message)
302 {
304 "Sending deletion aborted: Message creation failed!\n");
305 return;
306 }
307
308 enqueue_message_to_room (room, message, NULL);
309}
@ GNUNET_ERROR_TYPE_WARNING
void enqueue_message_to_room(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript)
struct GNUNET_MESSENGER_Message * create_message_delete(const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Creates and allocates a new delete message containing the hash of a message to delete after a specifi...

References create_message_delete(), enqueue_message_to_room(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.

Referenced by GNUNET_MESSENGER_delete_message(), and handle_delete_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_room_message()

void callback_room_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Executes the message callback for a given hash in a room.

Parameters
[in,out]roomRoom
[in]hashHash of message

Definition at line 313 of file messenger_api_room.c.

315{
318
319 GNUNET_assert ((room) && (hash));
320
321 handle = room->handle;
322 if (! handle)
323 return;
324
325 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
326 if (! entry)
327 return;
328
329 if (handle->msg_callback)
330 handle->msg_callback (handle->msg_cls, room,
331 entry->sender,
332 entry->recipient,
333 entry->message,
334 hash,
335 entry->flags);
336
339}
@ GNUNET_MESSENGER_FLAG_UPDATE
The update flag.
enum GNUNET_MESSENGER_MessageFlags flags

References GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_FLAG_UPDATE, handle, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_RoomMessageEntry::recipient, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_delete_message(), handle_message(), and handle_message_control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_room_message()

void handle_room_message ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Contact sender,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash,
enum GNUNET_MESSENGER_MessageFlags  flags 
)

Handles a message with a given hash in a room for the client API to update members and its information.

The function also stores the message in map locally for access afterwards.

The contact of the message's sender could be updated or even created. It may not be freed or destroyed though! (The contact may still be in use for old messages...)

Parameters
[in,out]roomRoom
[in,out]senderContact of sender
[in]messageMessage
[in]hashHash of message
[in]flagsFlags of message

Definition at line 726 of file messenger_api_room.c.

731{
733
734 GNUNET_assert ((room) && (message) && (hash));
735
736 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
737
738 if (entry)
739 goto update_entry;
740
742
743 if (! entry)
744 return;
745
746 entry->sender = NULL;
747 entry->recipient = NULL;
748
749 entry->message = NULL;
751 entry->completed = GNUNET_NO;
752
754 entry,
756 {
757 GNUNET_free (entry);
758 return;
759 }
760
761update_entry:
762 entry->sender = sender;
763 entry->flags = flags;
764
765 if (entry->message)
766 {
769
771 }
772 else
773 entry->message = copy_message (message);
774
775 entry->completed = GNUNET_YES;
776
777 handle_message (room, hash, entry);
778}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_OK
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
@ GNUNET_MESSENGER_FLAG_NONE
The none flag.
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
void copy_message_header(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_MessageHeader *header)
Copy message header details from another message to a given message.
static void handle_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_MESSENGER_MessageHeader header
Header.

References GNUNET_MESSENGER_RoomMessageEntry::completed, copy_message(), copy_message_header(), GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_free, GNUNET_MESSENGER_FLAG_NONE, GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_RoomMessageEntry::recipient, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_message_control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_room_last_message()

void update_room_last_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Updates the last message hash of a room for the client API so that new messages can point to the latest message hash while sending.

Parameters
[in,out]roomRoom
[in]hashHash of message

Definition at line 782 of file messenger_api_room.c.

784{
785 GNUNET_assert ((room) && (hash));
786
787 GNUNET_memcpy (&(room->last_message), hash, sizeof(room->last_message));
788}

References GNUNET_assert, GNUNET_memcpy, and GNUNET_MESSENGER_Room::last_message.

Referenced by handle_message_control(), handle_room_close(), handle_room_entry(), handle_room_open(), handle_room_sync(), and send_message_to_room().

Here is the caller graph for this function:

◆ iterate_room_members()

int iterate_room_members ( struct GNUNET_MESSENGER_Room room,
GNUNET_MESSENGER_MemberCallback  callback,
void *  cls 
)

Iterates through all members of a given room to forward each of them to a selected callback with a custom closure.

Parameters
[in,out]roomRoom
[in]callbackFunction called for each member
[in,out]clsClosure
Returns
Amount of members iterated

Definition at line 816 of file messenger_api_room.c.

819{
821
823
824 if (! callback)
826
827 call.room = room;
828 call.callback = callback;
829 call.cls = cls;
830
832
835 &call);
836}
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).
static enum GNUNET_GenericReturnValue iterate_local_members(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
GNUNET_MESSENGER_MemberCallback callback
struct GNUNET_MESSENGER_Room * room

References call, GNUNET_MESSENGER_MemberCall::callback, GNUNET_MESSENGER_MemberCall::cls, GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), iterate_local_members(), GNUNET_MESSENGER_Room::members, and GNUNET_MESSENGER_MemberCall::room.

Referenced by GNUNET_MESSENGER_iterate_members().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_room_member()

enum GNUNET_GenericReturnValue find_room_member ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_MESSENGER_Contact contact 
)

Checks through all members of a given room if a specific contact is found and returns a result depending on that.

Parameters
[in]roomRoom
[in]contact
Returns
GNUNET_YES if found, otherwise GNUNET_NO

Definition at line 869 of file messenger_api_room.c.

871{
872 struct GNUNET_MESSENGER_MemberFind find;
873
874 GNUNET_assert (room);
875
876 find.contact = contact;
877 find.result = GNUNET_NO;
878
880 &find);
881
882 return find.result;
883}
static enum GNUNET_GenericReturnValue iterate_find_member(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
const struct GNUNET_MESSENGER_Contact * contact

References GNUNET_MESSENGER_MemberFind::contact, GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_NO, iterate_find_member(), GNUNET_MESSENGER_Room::members, and GNUNET_MESSENGER_MemberFind::result.

Referenced by iterate_find_room().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_room_message()

void link_room_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_HashCode other 
)

Links a message identified by its hash inside a given room with another message identified by its other hash.

Linked messages will be deleted automatically, if any linked message to it gets deleted.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]otherHash of other message

Definition at line 910 of file messenger_api_room.c.

913{
914 const struct GNUNET_HashCode **result;
915 struct GNUNET_HashCode *value;
916
917 GNUNET_assert ((room) && (hash) && (other));
918
919 result = &other;
922
923 if (! *result)
924 return;
925
926 value = GNUNET_memdup (other, sizeof(struct GNUNET_HashCode));
927 if (! value)
928 return;
929
932
934}
static char * value
Value of the record to add/remove.
static int result
Global testing status.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
static enum GNUNET_GenericReturnValue find_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
A 512-bit hashcode.

References find_linked_hash(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_free, GNUNET_memdup, GNUNET_OK, GNUNET_MESSENGER_Room::links, result, and value.

Referenced by dequeue_message_from_room(), and handle_transcript_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ link_room_deletion()

void link_room_deletion ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay,
GNUNET_MESSENGER_RoomLinkDeletion  deletion 
)

Delete all remaining links to a certain message identified by its hash inside a given room and cause a deletion process to all of the linked messages.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]delayDelay for linked deletion
[in]deletionFunction called for each linked deletion

Definition at line 1001 of file messenger_api_room.c.

1005{
1007
1008 GNUNET_assert ((room) && (hash));
1009
1010 info.room = room;
1011 info.delay = delay;
1012 info.deletion = deletion;
1013
1017}
#define info
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
static enum GNUNET_GenericReturnValue delete_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_MESSENGER_Room * room
GNUNET_MESSENGER_RoomLinkDeletion deletion

References GNUNET_MESSENGER_RoomLinkDeletionInfo::delay, delete_linked_hash(), GNUNET_MESSENGER_RoomLinkDeletionInfo::deletion, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_remove_all(), info, GNUNET_MESSENGER_Room::links, and GNUNET_MESSENGER_RoomLinkDeletionInfo::room.

Referenced by handle_delete_message().

Here is the call graph for this function:
Here is the caller graph for this function: