messenger api: client implementation of GNUnet MESSENGER service More...
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_MemberCall |
struct | GNUNET_MESSENGER_MemberFind |
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... | |
static int | iterate_destroy_message (void *cls, const struct GNUNET_HashCode *key, void *value) |
void | destroy_room (struct GNUNET_MESSENGER_Room *room) |
Destroys a room and frees its memory fully from the client API. 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... | |
static struct GNUNET_MESSENGER_Contact * | handle_join_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
static void | handle_leave_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
static void | handle_name_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
static void | handle_key_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
static void | handle_id_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
static void | handle_miss_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
static void | handle_delete_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
struct GNUNET_MESSENGER_Contact * | handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash) |
Handles a message with a given hash in a room for the client API to update members and its information. More... | |
static int | iterate_local_members (void *cls, const struct GNUNET_ShortHashCode *key, void *value) |
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... | |
static int | iterate_find_member (void *cls, const struct GNUNET_ShortHashCode *key, void *value) |
int | 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... | |
messenger api: client implementation of GNUnet MESSENGER service
Definition in file messenger_api_room.c.
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 32 of file messenger_api_room.c.
References GNUNET_MESSENGER_Room::contact_id, GNUNET_MESSENGER_Room::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_memcpy, GNUNET_new, GNUNET_NO, handle, GNUNET_MESSENGER_Room::handle, init_list_tunnels(), key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_Room::opened.
Referenced by GNUNET_MESSENGER_enter_room(), and GNUNET_MESSENGER_open_room().
|
static |
Definition at line 54 of file messenger_api_room.c.
References destroy_message(), GNUNET_free, GNUNET_YES, GNUNET_MESSENGER_RoomMessageEntry::message, and value.
Referenced by destroy_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 67 of file messenger_api_room.c.
References clear_list_tunnels(), GNUNET_MESSENGER_Room::contact_id, GNUNET_MESSENGER_Room::entries, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_free, iterate_destroy_message(), GNUNET_MESSENGER_Room::members, and GNUNET_MESSENGER_Room::messages.
Referenced by close_handle_room(), GNUNET_MESSENGER_enter_room(), GNUNET_MESSENGER_open_room(), and iterate_destroy_room().
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 90 of file messenger_api_room.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_RoomMessageEntry::message, and GNUNET_MESSENGER_Room::messages.
Referenced by GNUNET_MESSENGER_get_message(), and handle_recv_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 103 of file messenger_api_room.c.
References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_RoomMessageEntry::sender.
Referenced by GNUNET_MESSENGER_get_sender().
|
static |
Definition at line 116 of file messenger_api_room.c.
References GNUNET_MESSENGER_Message::body, context, get_context_from_member(), get_handle_contact_store(), get_store_contact(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_contains_value(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, increase_contact_rc(), GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::members, and GNUNET_MESSENGER_MessageHeader::sender_id.
Referenced by handle_room_message().
|
static |
Definition at line 140 of file messenger_api_room.c.
References context, decrease_contact_rc(), get_context_from_member(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::members, and GNUNET_MESSENGER_MessageHeader::sender_id.
Referenced by handle_room_message().
|
static |
Definition at line 157 of file messenger_api_room.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, and set_contact_name().
Referenced by handle_room_message().
|
static |
Definition at line 169 of file messenger_api_room.c.
References GNUNET_MESSENGER_Message::body, context, get_context_from_member(), get_handle_contact_store(), GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_MessageHeader::sender_id, and update_store_contact().
Referenced by handle_room_message().
|
static |
Definition at line 186 of file messenger_api_room.c.
References GNUNET_MESSENGER_Message::body, context, get_contact_key(), get_context_from_member(), get_handle_contact_store(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_MessageHeader::sender_id, and update_store_contact().
Referenced by handle_room_message().
|
static |
Definition at line 207 of file messenger_api_room.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_Room::contact_id, GNUNET_MESSENGER_Room::entries, find_list_tunnels(), GNUNET_memcmp, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageMiss::peer, remove_from_list_tunnels(), and GNUNET_MESSENGER_MessageHeader::sender_id.
Referenced by handle_room_message().
|
static |
Definition at line 222 of file messenger_api_room.c.
References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageBody::deletion, destroy_message(), get_handle_contact(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_RoomMessageEntry::sender.
Referenced by handle_room_message().
struct GNUNET_MESSENGER_Contact* handle_room_message | ( | struct GNUNET_MESSENGER_Room * | room, |
struct GNUNET_MESSENGER_Contact * | sender, | ||
const struct GNUNET_MESSENGER_Message * | message, | ||
const struct GNUNET_HashCode * | hash | ||
) |
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 |
Definition at line 240 of file messenger_api_room.c.
References copy_message(), destroy_message(), GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_free, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_new, GNUNET_NO, GNUNET_OK, handle_delete_message(), handle_id_message(), handle_join_message(), handle_key_message(), handle_leave_message(), handle_miss_message(), handle_name_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_RoomMessageEntry::sender.
Referenced by handle_recv_message().
|
static |
Definition at line 301 of file messenger_api_room.c.
References call, GNUNET_MESSENGER_MemberCall::cls, and value.
Referenced by 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.
[in,out] | room | Room |
[in] | callback | Function called for each member |
[in,out] | cls | Closure |
Definition at line 312 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().
|
static |
Definition at line 339 of file messenger_api_room.c.
References GNUNET_MESSENGER_MemberFind::contact, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_MemberFind::result, and value.
Referenced by find_room_member().
int 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 356 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().