libgnunetchat

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

commit 61d6c29d3ec85d30fee2e5bfda39fedae589f24b
parent 4b1cb90926d99819fe4c0c29366e9ba12ec2adce
Author: Jacki <jacki@thejackimonster.de>
Date:   Sun, 11 Jan 2026 07:15:04 +0100

Store duplicate of warning for async internal messages

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Msrc/gnunet_chat_handle.c | 3++-
Msrc/gnunet_chat_message.c | 17++++++++++++++---
Msrc/gnunet_chat_message.h | 8++++++--
3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/gnunet_chat_handle.c b/src/gnunet_chat_handle.c @@ -870,7 +870,8 @@ handle_send_internal_message (struct GNUNET_CHAT_Handle *handle, internal->chat = handle; internal->msg = message_create_internally( - account, context, flag, warning + account, context, flag, warning, + GNUNET_YES != feedback? GNUNET_YES : GNUNET_NO ); if (!(internal->msg)) diff --git a/src/gnunet_chat_message.c b/src/gnunet_chat_message.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2024 GNUnet e.V. + Copyright (C) 2021--2026 GNUnet e.V. GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -45,6 +45,8 @@ message_create_from_msg (struct GNUNET_CHAT_Context *context, message->flags = flags; message->flag = GNUNET_CHAT_FLAG_NONE; + message->warning_buffer = NULL; + message->msg = msg; message->user_pointer = NULL; @@ -55,7 +57,8 @@ struct GNUNET_CHAT_Message* message_create_internally (struct GNUNET_CHAT_Account *account, struct GNUNET_CHAT_Context *context, enum GNUNET_CHAT_MessageFlag flag, - const char *warning) + const char *warning, + enum GNUNET_GenericReturnValue async_warning) { struct GNUNET_CHAT_Message *message = GNUNET_new(struct GNUNET_CHAT_Message); @@ -67,7 +70,12 @@ message_create_internally (struct GNUNET_CHAT_Account *account, message->flags = GNUNET_MESSENGER_FLAG_PRIVATE; message->flag = flag; - message->warning = warning; + if (GNUNET_YES == async_warning) + message->warning_buffer = warning? GNUNET_strdup(warning) : NULL; + else + message->warning_buffer = NULL; + + message->warning = GNUNET_YES == async_warning? message->warning_buffer : warning; message->user_pointer = NULL; return message; @@ -116,5 +124,8 @@ message_destroy (struct GNUNET_CHAT_Message* message) if (message->task) GNUNET_SCHEDULER_cancel(message->task); + if (message->warning_buffer) + GNUNET_free(message->warning_buffer); + GNUNET_free(message); } diff --git a/src/gnunet_chat_message.h b/src/gnunet_chat_message.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2024 GNUnet e.V. + Copyright (C) 2021--2026 GNUnet e.V. GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -62,6 +62,8 @@ struct GNUNET_CHAT_Message struct GNUNET_CHAT_Context *context; struct GNUNET_SCHEDULER_Task *task; + char *warning_buffer; + union { const struct GNUNET_MESSENGER_Message *msg; const char *warning; @@ -101,13 +103,15 @@ message_create_from_msg (struct GNUNET_CHAT_Context *context, * @param[in,out] context Chat context or NULL * @param[in] flag Chat message flag * @param[in] warning Warning text + * @param[in] async_warning Async flag to buffer warning text * @return New internal chat message */ struct GNUNET_CHAT_Message* message_create_internally (struct GNUNET_CHAT_Account *account, struct GNUNET_CHAT_Context *context, enum GNUNET_CHAT_MessageFlag flag, - const char *warning); + const char *warning, + enum GNUNET_GenericReturnValue async_warning); /** * Returns whether a chat <i>message</i> contains an actual