diff options
author | Jacki <jacki@thejackimonster.de> | 2024-01-03 16:40:40 +0100 |
---|---|---|
committer | Jacki <jacki@thejackimonster.de> | 2024-01-03 16:40:40 +0100 |
commit | ecbc6b5d98276c18f319e827fd1bce6b61420909 (patch) | |
tree | a8776a3ba1c0dcb696cf4bb88446d3547890a151 /src | |
parent | 1ef0dc0013ce7df914f7416a8936c014cbd4fb6d (diff) | |
download | messenger-gtk-ecbc6b5d98276c18f319e827fd1bce6b61420909.tar.gz messenger-gtk-ecbc6b5d98276c18f319e827fd1bce6b61420909.zip |
Fix contact info updates
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/chat/messenger.c | 27 | ||||
-rw-r--r-- | src/contact.c | 8 | ||||
-rw-r--r-- | src/contact.h | 6 | ||||
-rw-r--r-- | src/event.c | 26 |
4 files changed, 34 insertions, 33 deletions
diff --git a/src/chat/messenger.c b/src/chat/messenger.c index 0015f25..b330efd 100644 --- a/src/chat/messenger.c +++ b/src/chat/messenger.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 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 |
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include "../contact.h" | 27 | #include "../contact.h" |
28 | #include "../event.h" | 28 | #include "../event.h" |
29 | #include <gnunet/gnunet_chat_lib.h> | ||
29 | 30 | ||
30 | int | 31 | int |
31 | _chat_messenger_destroy_contacts(UNUSED void *cls, | 32 | _chat_messenger_destroy_contacts(UNUSED void *cls, |
@@ -113,10 +114,10 @@ _chat_messenger_message(void *cls, | |||
113 | case GNUNET_CHAT_KIND_UPDATE: | 114 | case GNUNET_CHAT_KIND_UPDATE: |
114 | { | 115 | { |
115 | application_call_message_event( | 116 | application_call_message_event( |
116 | app, | 117 | app, |
117 | event_update_chats, | 118 | event_update_chats, |
118 | context, | 119 | context, |
119 | message | 120 | message |
120 | ); | 121 | ); |
121 | break; | 122 | break; |
122 | } | 123 | } |
@@ -147,10 +148,10 @@ _chat_messenger_message(void *cls, | |||
147 | case GNUNET_CHAT_KIND_INVITATION: | 148 | case GNUNET_CHAT_KIND_INVITATION: |
148 | { | 149 | { |
149 | application_call_message_event( | 150 | application_call_message_event( |
150 | app, | 151 | app, |
151 | event_invitation, | 152 | event_invitation, |
152 | context, | 153 | context, |
153 | message | 154 | message |
154 | ); | 155 | ); |
155 | break; | 156 | break; |
156 | } | 157 | } |
@@ -159,10 +160,10 @@ _chat_messenger_message(void *cls, | |||
159 | case GNUNET_CHAT_KIND_WHISPER: | 160 | case GNUNET_CHAT_KIND_WHISPER: |
160 | { | 161 | { |
161 | application_call_message_event( | 162 | application_call_message_event( |
162 | app, | 163 | app, |
163 | event_receive_message, | 164 | event_receive_message, |
164 | context, | 165 | context, |
165 | message | 166 | message |
166 | ); | 167 | ); |
167 | break; | 168 | break; |
168 | } | 169 | } |
diff --git a/src/contact.c b/src/contact.c index d23b6b7..55a3ede 100644 --- a/src/contact.c +++ b/src/contact.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2021--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 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 |
@@ -86,7 +86,7 @@ contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact) | |||
86 | 86 | ||
87 | void | 87 | void |
88 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | 88 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, |
89 | GtkLabel *label) | 89 | GtkLabel *label) |
90 | { | 90 | { |
91 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | 91 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); |
92 | 92 | ||
@@ -102,12 +102,12 @@ contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | |||
102 | 102 | ||
103 | void | 103 | void |
104 | contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, | 104 | contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, |
105 | HdyAvatar *avatar) | 105 | HdyAvatar *avatar) |
106 | { | 106 | { |
107 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); | 107 | MESSENGER_ContactInfo* info = GNUNET_CHAT_contact_get_user_pointer(contact); |
108 | 108 | ||
109 | if ((!info) || (!avatar)) | 109 | if ((!info) || (!avatar)) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | const char *name = GNUNET_CHAT_contact_get_name(contact); | 112 | const char *name = GNUNET_CHAT_contact_get_name(contact); |
113 | 113 | ||
diff --git a/src/contact.h b/src/contact.h index 61d41e7..a923444 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--2022 GNUnet e.V. | 3 | Copyright (C) 2021--2024 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 |
@@ -83,7 +83,7 @@ contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact); | |||
83 | */ | 83 | */ |
84 | void | 84 | void |
85 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | 85 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, |
86 | GtkLabel *label); | 86 | GtkLabel *label); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Adds a HdyAvatar to the list of avatars | 89 | * Adds a HdyAvatar to the list of avatars |
@@ -94,7 +94,7 @@ contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | |||
94 | */ | 94 | */ |
95 | void | 95 | void |
96 | contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, | 96 | contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, |
97 | HdyAvatar *avatar); | 97 | HdyAvatar *avatar); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Updates the connected UI elements for a given | 100 | * Updates the connected UI elements for a given |
diff --git a/src/event.c b/src/event.c index 8f3ba23..fcaab5b 100644 --- a/src/event.c +++ b/src/event.c | |||
@@ -395,14 +395,11 @@ _update_contact_context(struct GNUNET_CHAT_Contact *contact) | |||
395 | 395 | ||
396 | void | 396 | void |
397 | event_presence_contact(MESSENGER_Application *app, | 397 | event_presence_contact(MESSENGER_Application *app, |
398 | struct GNUNET_CHAT_Context *context, | 398 | struct GNUNET_CHAT_Context *context, |
399 | const struct GNUNET_CHAT_Message *msg) | 399 | const struct GNUNET_CHAT_Message *msg) |
400 | { | 400 | { |
401 | UI_CHAT_ENTRY_Handle *handle = GNUNET_CHAT_context_get_user_pointer(context); | 401 | UI_CHAT_ENTRY_Handle *handle = GNUNET_CHAT_context_get_user_pointer(context); |
402 | 402 | ||
403 | if (!handle) | ||
404 | return; | ||
405 | |||
406 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 403 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
407 | msg | 404 | msg |
408 | ); | 405 | ); |
@@ -410,19 +407,18 @@ event_presence_contact(MESSENGER_Application *app, | |||
410 | if (!contact) | 407 | if (!contact) |
411 | return; | 408 | return; |
412 | 409 | ||
413 | const enum GNUNET_CHAT_MessageKind kind = GNUNET_CHAT_message_get_kind( | 410 | contact_create_info(contact); |
414 | msg | 411 | |
415 | ); | 412 | if (!handle) |
413 | return; | ||
416 | 414 | ||
417 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group(context); | 415 | struct GNUNET_CHAT_Group *group = GNUNET_CHAT_context_get_group(context); |
418 | 416 | ||
419 | UI_MESSAGE_Handle *message = NULL; | 417 | UI_MESSAGE_Handle *message = NULL; |
420 | 418 | ||
421 | contact_create_info(contact); | ||
422 | |||
423 | if (group) | 419 | if (group) |
424 | message = (UI_MESSAGE_Handle*) ( | 420 | message = (UI_MESSAGE_Handle*) ( |
425 | GNUNET_CHAT_member_get_user_pointer(group, contact) | 421 | GNUNET_CHAT_member_get_user_pointer(group, contact) |
426 | ); | 422 | ); |
427 | else | 423 | else |
428 | message = (UI_MESSAGE_Handle*) contact_get_last_message_from_info(contact); | 424 | message = (UI_MESSAGE_Handle*) contact_get_last_message_from_info(contact); |
@@ -438,6 +434,10 @@ event_presence_contact(MESSENGER_Application *app, | |||
438 | contact_add_name_avatar_to_info(contact, message->sender_avatar); | 434 | contact_add_name_avatar_to_info(contact, message->sender_avatar); |
439 | contact_add_name_label_to_info(contact, message->sender_label); | 435 | contact_add_name_label_to_info(contact, message->sender_label); |
440 | 436 | ||
437 | const enum GNUNET_CHAT_MessageKind kind = GNUNET_CHAT_message_get_kind( | ||
438 | msg | ||
439 | ); | ||
440 | |||
441 | const char *text = ( | 441 | const char *text = ( |
442 | GNUNET_CHAT_KIND_JOIN == kind? _("joined the chat") : _("left the chat") | 442 | GNUNET_CHAT_KIND_JOIN == kind? _("joined the chat") : _("left the chat") |
443 | ); | 443 | ); |
@@ -473,8 +473,8 @@ event_presence_contact(MESSENGER_Application *app, | |||
473 | 473 | ||
474 | void | 474 | void |
475 | event_update_contacts(UNUSED MESSENGER_Application *app, | 475 | event_update_contacts(UNUSED MESSENGER_Application *app, |
476 | struct GNUNET_CHAT_Context *context, | 476 | struct GNUNET_CHAT_Context *context, |
477 | const struct GNUNET_CHAT_Message *msg) | 477 | const struct GNUNET_CHAT_Message *msg) |
478 | { | 478 | { |
479 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( | 479 | struct GNUNET_CHAT_Contact *contact = GNUNET_CHAT_message_get_sender( |
480 | msg | 480 | msg |