summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-04-10 18:52:36 +0200
committerTheJackiMonster <thejackimonster@gmail.com>2022-04-10 18:52:36 +0200
commit6e6a4f7f612c14fa0188eab6fc6e2906b717540b (patch)
treee1d4ccd620a9d6a25c72b4e56b2dd8530aa4f544
parent2533114fcc0fbfa3f3ee3c756892fec39fd547a4 (diff)
Updated usage of member user pointers
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/contact.c23
-rw-r--r--src/contact.h11
-rw-r--r--src/event.c21
3 files changed, 49 insertions, 6 deletions
diff --git a/src/contact.c b/src/contact.c
index 0ebe9c6..9c590a3 100644
--- 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
index 15c7c9f..8a6dd4c 100644
--- 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
index 59c47d6..80deb25 100644
--- 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);
}