aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-02-18 21:53:37 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-02-18 21:53:37 +0100
commit42066201e5b2476463ebc2de1480b027fbe4489f (patch)
tree1324531f5fd3a6600fbf914f5e4a8197bf894d0c
parent65a85c59ca226fbf65ada003c57f0d77e61ef073 (diff)
downloadmessenger-gtk-42066201e5b2476463ebc2de1480b027fbe4489f.tar.gz
messenger-gtk-42066201e5b2476463ebc2de1480b027fbe4489f.zip
Added read receipt status update
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/ui/chat.c15
-rw-r--r--src/ui/message.c32
-rw-r--r--src/ui/message.h3
3 files changed, 50 insertions, 0 deletions
diff --git a/src/ui/chat.c b/src/ui/chat.c
index 4fe4735..455e3c4 100644
--- a/src/ui/chat.c
+++ b/src/ui/chat.c
@@ -877,6 +877,21 @@ ui_chat_add_message(UI_CHAT_Handle *handle,
877 877
878 g_hash_table_insert(app->ui.bindings, row, message); 878 g_hash_table_insert(app->ui.bindings, row, message);
879 879
880 GList *list = handle->messages;
881
882 while (list)
883 {
884 UI_MESSAGE_Handle *msg_handle = (UI_MESSAGE_Handle*) list->data;
885
886 if (UI_MESSAGE_SENT == msg_handle->type)
887 {
888 ui_message_refresh(msg_handle);
889 break;
890 }
891
892 list = list->next;
893 }
894
880 handle->messages = g_list_prepend(handle->messages, message); 895 handle->messages = g_list_prepend(handle->messages, message);
881 896
882 gtk_list_box_invalidate_sort(handle->messages_listbox); 897 gtk_list_box_invalidate_sort(handle->messages_listbox);
diff --git a/src/ui/message.c b/src/ui/message.c
index 4dbddf1..4920d76 100644
--- a/src/ui/message.c
+++ b/src/ui/message.c
@@ -397,6 +397,36 @@ ui_message_new(MESSENGER_Application *app,
397 return handle; 397 return handle;
398} 398}
399 399
400static int
401_iterate_read_receipts(void *cls,
402 UNUSED const struct GNUNET_CHAT_Message *message,
403 const struct GNUNET_CHAT_Contact *contact,
404 int read_receipt)
405{
406 int *count_read_receipts = (int*) cls;
407
408 if ((GNUNET_YES == read_receipt) &&
409 (GNUNET_NO == GNUNET_CHAT_contact_is_owned(contact)))
410 (*count_read_receipts)++;
411
412 return GNUNET_YES;
413}
414
415void
416ui_message_refresh(UI_MESSAGE_Handle *handle)
417{
418 if ((!(handle->msg)) ||
419 (GNUNET_YES != GNUNET_CHAT_message_is_sent(handle->msg)))
420 return;
421
422 int count = 0;
423 if ((0 < GNUNET_CHAT_message_get_read_receipt(handle->msg, _iterate_read_receipts, &count)) &&
424 (0 < count))
425 gtk_widget_show(GTK_WIDGET(handle->read_receipt_image));
426 else
427 gtk_widget_hide(GTK_WIDGET(handle->read_receipt_image));
428}
429
400void 430void
401ui_message_update(UI_MESSAGE_Handle *handle, 431ui_message_update(UI_MESSAGE_Handle *handle,
402 MESSENGER_Application *app, 432 MESSENGER_Application *app,
@@ -406,6 +436,8 @@ ui_message_update(UI_MESSAGE_Handle *handle,
406 436
407 handle->msg = msg; 437 handle->msg = msg;
408 438
439 ui_message_refresh(handle);
440
409 if (msg) 441 if (msg)
410 { 442 {
411 file = GNUNET_CHAT_message_get_file(msg); 443 file = GNUNET_CHAT_message_get_file(msg);
diff --git a/src/ui/message.h b/src/ui/message.h
index 87c7003..ec4e772 100644
--- a/src/ui/message.h
+++ b/src/ui/message.h
@@ -89,6 +89,9 @@ ui_message_new(MESSENGER_Application *app,
89 UI_MESSAGE_Type type); 89 UI_MESSAGE_Type type);
90 90
91void 91void
92ui_message_refresh(UI_MESSAGE_Handle *handle);
93
94void
92ui_message_update(UI_MESSAGE_Handle *handle, 95ui_message_update(UI_MESSAGE_Handle *handle,
93 MESSENGER_Application *app, 96 MESSENGER_Application *app,
94 const struct GNUNET_CHAT_Message *message); 97 const struct GNUNET_CHAT_Message *message);