messenger-gtk

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

commit 6e6a4f7f612c14fa0188eab6fc6e2906b717540b
parent 2533114fcc0fbfa3f3ee3c756892fec39fd547a4
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Sun, 10 Apr 2022 18:52:36 +0200

Updated usage of member user pointers

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

Diffstat:
Msrc/contact.c | 23+++++++++++++++++++++++
Msrc/contact.h | 11++++++++++-
Msrc/event.c | 21++++++++++++++++-----
3 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/src/contact.c b/src/contact.c @@ -60,6 +60,29 @@ contact_destroy_info(struct GNUNET_CHAT_Contact *contact) } void +contact_set_last_message_to_info(const struct GNUNET_CHAT_Contact *contact, + void *message) +{ + MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); + + if (!info) + return; + + info->last_message = message; +} + +void* +contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact) +{ + MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); + + if (!info) + return NULL; + + return info->last_message; +} + +void contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, GtkLabel *label) { diff --git a/src/contact.h b/src/contact.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021 GNUnet e.V. + Copyright (C) 2021--2022 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 @@ -29,6 +29,8 @@ typedef struct MESSENGER_ContactInfo { + void *last_message; + GList *name_labels; GList *name_avatars; } MESSENGER_ContactInfo; @@ -40,6 +42,13 @@ void contact_destroy_info(struct GNUNET_CHAT_Contact *contact); void +contact_set_last_message_to_info(const struct GNUNET_CHAT_Contact *contact, + void *message); + +void* +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); diff --git a/src/event.c b/src/event.c @@ -412,9 +412,18 @@ event_presence_contact(MESSENGER_Application *app, msg ); - UI_MESSAGE_Handle *message = (UI_MESSAGE_Handle*) ( - GNUNET_CHAT_member_get_user_pointer(context, contact) - ); + 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) + ); + else + message = (UI_MESSAGE_Handle*) contact_get_last_message_from_info(contact); if (message) ui_chat_remove_message(handle->chat, app, message); @@ -422,7 +431,6 @@ event_presence_contact(MESSENGER_Application *app, message = ui_message_new(app, UI_MESSAGE_STATUS); ui_message_update(message, app, msg); - contact_create_info(contact); _update_contact_context(contact); contact_add_name_avatar_to_info(contact, message->sender_avatar); @@ -453,7 +461,10 @@ event_presence_contact(MESSENGER_Application *app, ui_chat_add_message(handle->chat, app, message); - GNUNET_CHAT_member_set_user_pointer(context, contact, message); + if (group) + GNUNET_CHAT_member_set_user_pointer(group, contact, message); + else + contact_set_last_message_to_info(contact, message); enqueue_chat_entry_update(handle); }