libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit fc3e6095465c119e9b58777ccb385ae91181eafe
parent 2d86ca47e55589718307872999b8cb362b818ba0
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Fri, 18 Feb 2022 00:55:52 +0100

Added message target for deletions

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
Minclude/gnunet_chat_lib.h | 11+++++++++++
Msrc/gnunet_chat_lib.c | 24+++++++++++++++++++-----
2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/include/gnunet_chat_lib.h b/include/gnunet_chat_lib.h @@ -876,6 +876,17 @@ struct GNUNET_CHAT_Invitation* GNUNET_CHAT_message_get_invitation (const struct GNUNET_CHAT_Message *message); /** + * Returns the target message of an operation represented by a given + * <i>message</i> if its kind is #GNUNET_CHAT_KIND_DELETION, otherwise it + * returns NULL. + * + * @param[in] message Message + * @return The target of message or NULL + */ +const struct GNUNET_CHAT_Message* +GNUNET_CHAT_message_get_target (const struct GNUNET_CHAT_Message *message); + +/** * Deletes a given <i>message</i> with a specific relative <i>delay</i>. * * @param[in] message Message diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c @@ -1080,6 +1080,25 @@ GNUNET_CHAT_message_get_invitation (const struct GNUNET_CHAT_Message *message) } +const struct GNUNET_CHAT_Message* +GNUNET_CHAT_message_get_target (const struct GNUNET_CHAT_Message *message) +{ + if ((!message) || (!(message->msg)) || (!(message->context))) + return NULL; + + struct GNUNET_CHAT_Message *target; + + if (GNUNET_MESSENGER_KIND_DELETE == message->msg->header.kind) + target = GNUNET_CONTAINER_multihashmap_get( + message->context->messages, &(message->msg->body.deletion.hash) + ); + else + target = NULL; + + return target; +} + + int GNUNET_CHAT_message_delete (const struct GNUNET_CHAT_Message *message, struct GNUNET_TIME_Relative delay) @@ -1360,8 +1379,6 @@ GNUNET_CHAT_file_is_unindexing (const struct GNUNET_CHAT_File *file) } - - int GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file, GNUNET_CHAT_FileUnindexCallback callback, @@ -1404,8 +1421,6 @@ GNUNET_CHAT_file_unindex (struct GNUNET_CHAT_File *file, } - - void GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation) { @@ -1420,4 +1435,3 @@ GNUNET_CHAT_invitation_accept (struct GNUNET_CHAT_Invitation *invitation) &door, &(invitation->key) ); } -