diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-04-10 18:52:36 +0200 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-04-10 18:52:36 +0200 |
commit | 6e6a4f7f612c14fa0188eab6fc6e2906b717540b (patch) | |
tree | e1d4ccd620a9d6a25c72b4e56b2dd8530aa4f544 | |
parent | 2533114fcc0fbfa3f3ee3c756892fec39fd547a4 (diff) | |
download | messenger-gtk-6e6a4f7f612c14fa0188eab6fc6e2906b717540b.tar.gz messenger-gtk-6e6a4f7f612c14fa0188eab6fc6e2906b717540b.zip |
Updated usage of member user pointers
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | src/contact.c | 23 | ||||
-rw-r--r-- | src/contact.h | 11 | ||||
-rw-r--r-- | src/event.c | 21 |
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) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | void | 62 | void |
63 | contact_set_last_message_to_info(const struct GNUNET_CHAT_Contact *contact, | ||
64 | void *message) | ||
65 | { | ||
66 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | ||
67 | |||
68 | if (!info) | ||
69 | return; | ||
70 | |||
71 | info->last_message = message; | ||
72 | } | ||
73 | |||
74 | void* | ||
75 | contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact) | ||
76 | { | ||
77 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | ||
78 | |||
79 | if (!info) | ||
80 | return NULL; | ||
81 | |||
82 | return info->last_message; | ||
83 | } | ||
84 | |||
85 | void | ||
63 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | 86 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, |
64 | GtkLabel *label) | 87 | GtkLabel *label) |
65 | { | 88 | { |
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021 GNUnet e.V. | 3 | Copyright (C) 2021--2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | typedef struct MESSENGER_ContactInfo | 30 | typedef struct MESSENGER_ContactInfo |
31 | { | 31 | { |
32 | void *last_message; | ||
33 | |||
32 | GList *name_labels; | 34 | GList *name_labels; |
33 | GList *name_avatars; | 35 | GList *name_avatars; |
34 | } MESSENGER_ContactInfo; | 36 | } MESSENGER_ContactInfo; |
@@ -40,6 +42,13 @@ void | |||
40 | contact_destroy_info(struct GNUNET_CHAT_Contact *contact); | 42 | contact_destroy_info(struct GNUNET_CHAT_Contact *contact); |
41 | 43 | ||
42 | void | 44 | void |
45 | contact_set_last_message_to_info(const struct GNUNET_CHAT_Contact *contact, | ||
46 | void *message); | ||
47 | |||
48 | void* | ||
49 | contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact); | ||
50 | |||
51 | void | ||
43 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | 52 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, |
44 | GtkLabel *label); | 53 | GtkLabel *label); |
45 | 54 | ||
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, | |||
412 | msg | 412 | msg |
413 | ); | 413 | ); |
414 | 414 | ||
415 | UI_MESSAGE_Handle *message = (UI_MESSAGE_Handle*) ( | 415 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group(context); |
416 | GNUNET_CHAT_member_get_user_pointer(context, contact) | 416 | |
417 | ); | 417 | UI_MESSAGE_Handle *message = NULL; |
418 | |||
419 | contact_create_info(contact); | ||
420 | |||
421 | if (group) | ||
422 | message = (UI_MESSAGE_Handle*) ( | ||
423 | GNUNET_CHAT_member_get_user_pointer(group, contact) | ||
424 | ); | ||
425 | else | ||
426 | message = (UI_MESSAGE_Handle*) contact_get_last_message_from_info(contact); | ||
418 | 427 | ||
419 | if (message) | 428 | if (message) |
420 | ui_chat_remove_message(handle->chat, app, message); | 429 | ui_chat_remove_message(handle->chat, app, message); |
@@ -422,7 +431,6 @@ event_presence_contact(MESSENGER_Application *app, | |||
422 | message = ui_message_new(app, UI_MESSAGE_STATUS); | 431 | message = ui_message_new(app, UI_MESSAGE_STATUS); |
423 | ui_message_update(message, app, msg); | 432 | ui_message_update(message, app, msg); |
424 | 433 | ||
425 | contact_create_info(contact); | ||
426 | _update_contact_context(contact); | 434 | _update_contact_context(contact); |
427 | 435 | ||
428 | contact_add_name_avatar_to_info(contact, message->sender_avatar); | 436 | contact_add_name_avatar_to_info(contact, message->sender_avatar); |
@@ -453,7 +461,10 @@ event_presence_contact(MESSENGER_Application *app, | |||
453 | 461 | ||
454 | ui_chat_add_message(handle->chat, app, message); | 462 | ui_chat_add_message(handle->chat, app, message); |
455 | 463 | ||
456 | GNUNET_CHAT_member_set_user_pointer(context, contact, message); | 464 | if (group) |
465 | GNUNET_CHAT_member_set_user_pointer(group, contact, message); | ||
466 | else | ||
467 | contact_set_last_message_to_info(contact, message); | ||
457 | 468 | ||
458 | enqueue_chat_entry_update(handle); | 469 | enqueue_chat_entry_update(handle); |
459 | } | 470 | } |