#include "gnunet_common.h"
#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_messenger_service.h"
#include "messenger_api_handle.h"
#include "messenger_api_list_tunnels.h"
#include "messenger_api_contact.h"
#include "messenger_api_message_control.h"
#include "messenger_api_queue_messages.h"
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_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. 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_Handle * | get_room_handle (struct GNUNET_MESSENGER_Room *room) |
Returns the messenger handle of the room. More... | |
const struct GNUNET_ShortHashCode * | get_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_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. More... | |
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. More... | |
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. 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 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.
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.
[in,out] | handle | Handle |
[in] | key | Key of room |
Definition at line 41 of file messenger_api_room.c.
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().
void destroy_room | ( | struct GNUNET_MESSENGER_Room * | room | ) |
Destroys a room and frees its memory fully from the client API.
[in,out] | room | Room |
Definition at line 134 of file messenger_api_room.c.
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().
enum GNUNET_GenericReturnValue is_room_available | ( | const struct GNUNET_MESSENGER_Room * | room | ) |
Checks whether a room is available to send messages.
[in] | room | Room |
Definition at line 182 of file messenger_api_room.c.
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().
struct GNUNET_MESSENGER_Handle * get_room_handle | ( | struct GNUNET_MESSENGER_Room * | room | ) |
Returns the messenger handle of the room.
[in,out] | room | Room |
Definition at line 197 of file messenger_api_room.c.
References GNUNET_assert, and GNUNET_MESSENGER_Room::handle.
Referenced by process_message_control(), and task_message_control().
const struct GNUNET_ShortHashCode * get_room_sender_id | ( | const struct GNUNET_MESSENGER_Room * | room | ) |
Returns the member id of the room's sender.
[in] | room | Room |
Definition at line 206 of file messenger_api_room.c.
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().
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.
[in,out] | room | Room |
[in] | id | Member id or NULL |
Definition at line 215 of file messenger_api_room.c.
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().
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.
[in] | room | Room |
[in] | hash | Hash of message |
Definition at line 240 of file messenger_api_room.c.
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().
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.
[in] | room | Room |
[in] | hash | Hash of message |
Definition at line 257 of file messenger_api_room.c.
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().
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.
[in] | room | Room |
[in] | hash | Hash of message |
Definition at line 274 of file messenger_api_room.c.
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().
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.
[in,out] | room | Room |
[in] | hash | Hash of message |
[in] | delay | Delay of deletion |
Definition at line 291 of file messenger_api_room.c.
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().
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.
[in,out] | room | Room |
[in] | hash | Hash of message |
Definition at line 313 of file messenger_api_room.c.
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().
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...)
[in,out] | room | Room |
[in,out] | sender | Contact of sender |
[in] | message | Message |
[in] | hash | Hash of message |
[in] | flags | Flags of message |
Definition at line 726 of file messenger_api_room.c.
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().
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.
[in,out] | room | Room |
[in] | hash | Hash of message |
Definition at line 782 of file messenger_api_room.c.
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().
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.
[in,out] | room | Room |
[in] | callback | Function called for each member |
[in,out] | cls | Closure |
Definition at line 816 of file messenger_api_room.c.
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().
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.
[in] | room | Room |
[in] | contact |
Definition at line 869 of file messenger_api_room.c.
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().
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.
[in,out] | room | Room |
[in] | hash | Hash of message |
[in] | other | Hash of other message |
Definition at line 910 of file messenger_api_room.c.
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().
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.
[in,out] | room | Room |
[in] | hash | Hash of message |
[in] | delay | Delay for linked deletion |
[in] | deletion | Function called for each linked deletion |
Definition at line 1001 of file messenger_api_room.c.
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().