messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit ecbc6b5d98276c18f319e827fd1bce6b61420909
parent 1ef0dc0013ce7df914f7416a8936c014cbd4fb6d
Author: Jacki <jacki@thejackimonster.de>
Date:   Wed,  3 Jan 2024 16:40:40 +0100

Fix contact info updates

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

Diffstat:
Msrc/chat/messenger.c | 27++++++++++++++-------------
Msrc/contact.c | 8++++----
Msrc/contact.h | 6+++---
Msrc/event.c | 26+++++++++++++-------------
4 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/src/chat/messenger.c b/src/chat/messenger.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2022 GNUnet e.V. + Copyright (C) 2021--2024 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 @@ -26,6 +26,7 @@ #include "../contact.h" #include "../event.h" +#include <gnunet/gnunet_chat_lib.h> int _chat_messenger_destroy_contacts(UNUSED void *cls, @@ -113,10 +114,10 @@ _chat_messenger_message(void *cls, case GNUNET_CHAT_KIND_UPDATE: { application_call_message_event( - app, - event_update_chats, - context, - message + app, + event_update_chats, + context, + message ); break; } @@ -147,10 +148,10 @@ _chat_messenger_message(void *cls, case GNUNET_CHAT_KIND_INVITATION: { application_call_message_event( - app, - event_invitation, - context, - message + app, + event_invitation, + context, + message ); break; } @@ -159,10 +160,10 @@ _chat_messenger_message(void *cls, case GNUNET_CHAT_KIND_WHISPER: { application_call_message_event( - app, - event_receive_message, - context, - message + app, + event_receive_message, + context, + message ); break; } diff --git a/src/contact.c b/src/contact.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2022 GNUnet e.V. + Copyright (C) 2021--2024 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 @@ -86,7 +86,7 @@ contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact) void contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, - GtkLabel *label) + GtkLabel *label) { MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); @@ -102,12 +102,12 @@ contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, void contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, - HdyAvatar *avatar) + HdyAvatar *avatar) { MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); if ((!info) || (!avatar)) - return; + return; const char *name = GNUNET_CHAT_contact_get_name(contact); diff --git a/src/contact.h b/src/contact.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021--2022 GNUnet e.V. + Copyright (C) 2021--2024 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 @@ -83,7 +83,7 @@ contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact); */ void contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, - GtkLabel *label); + GtkLabel *label); /** * Adds a HdyAvatar to the list of avatars @@ -94,7 +94,7 @@ contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, */ void contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, - HdyAvatar *avatar); + HdyAvatar *avatar); /** * Updates the connected UI elements for a given diff --git a/src/event.c b/src/event.c @@ -395,14 +395,11 @@ _update_contact_context(struct GNUNET_CHAT_Contact *contact) void event_presence_contact(MESSENGER_Application *app, - struct GNUNET_CHAT_Context *context, - const struct GNUNET_CHAT_Message *msg) + struct GNUNET_CHAT_Context *context, + const struct GNUNET_CHAT_Message *msg) { UI_CHAT_ENTRY_Handle *handle = GNUNET_CHAT_context_get_user_pointer(context); - if (!handle) - return; - struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( msg ); @@ -410,19 +407,18 @@ event_presence_contact(MESSENGER_Application *app, if (!contact) return; - const enum GNUNET_CHAT_MessageKind kind = GNUNET_CHAT_message_get_kind( - msg - ); + contact_create_info(contact); + + if (!handle) + return; struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group(context); UI_MESSAGE_Handle *message = NULL; - contact_create_info(contact); - if (group) message = (UI_MESSAGE_Handle*) ( - GNUNET_CHAT_member_get_user_pointer(group, contact) + GNUNET_CHAT_member_get_user_pointer(group, contact) ); else message = (UI_MESSAGE_Handle*) contact_get_last_message_from_info(contact); @@ -438,6 +434,10 @@ event_presence_contact(MESSENGER_Application *app, contact_add_name_avatar_to_info(contact, message->sender_avatar); contact_add_name_label_to_info(contact, message->sender_label); + const enum GNUNET_CHAT_MessageKind kind = GNUNET_CHAT_message_get_kind( + msg + ); + const char *text = ( GNUNET_CHAT_KIND_JOIN == kind? _("joined the chat") : _("left the chat") ); @@ -473,8 +473,8 @@ event_presence_contact(MESSENGER_Application *app, void event_update_contacts(UNUSED MESSENGER_Application *app, - struct GNUNET_CHAT_Context *context, - const struct GNUNET_CHAT_Message *msg) + struct GNUNET_CHAT_Context *context, + const struct GNUNET_CHAT_Message *msg) { struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( msg