messenger api: client implementation of GNUnet MESSENGER service More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_messenger_service.h"
#include "messenger_api_list_tunnels.h"
#include "messenger_api_contact.h"
#include "messenger_api_message.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_MESSENGER_RoomMessageEntry |
struct | GNUNET_MESSENGER_Room |
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... | |
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 * | 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... | |
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... | |
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.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 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().
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().
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().
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().
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().