summaryrefslogtreecommitdiff
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)
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,
g_hash_table_insert(app->ui.bindings, row, message);
+ GList *list = handle->messages;
+
+ while (list)
+ {
+ UI_MESSAGE_Handle *msg_handle = (UI_MESSAGE_Handle*) list->data;
+
+ if (UI_MESSAGE_SENT == msg_handle->type)
+ {
+ ui_message_refresh(msg_handle);
+ break;
+ }
+
+ list = list->next;
+ }
+
handle->messages = g_list_prepend(handle->messages, message);
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,
return handle;
}
+static int
+_iterate_read_receipts(void *cls,
+ UNUSED const struct GNUNET_CHAT_Message *message,
+ const struct GNUNET_CHAT_Contact *contact,
+ int read_receipt)
+{
+ int *count_read_receipts = (int*) cls;
+
+ if ((GNUNET_YES == read_receipt) &&
+ (GNUNET_NO == GNUNET_CHAT_contact_is_owned(contact)))
+ (*count_read_receipts)++;
+
+ return GNUNET_YES;
+}
+
+void
+ui_message_refresh(UI_MESSAGE_Handle *handle)
+{
+ if ((!(handle->msg)) ||
+ (GNUNET_YES != GNUNET_CHAT_message_is_sent(handle->msg)))
+ return;
+
+ int count = 0;
+ if ((0 < GNUNET_CHAT_message_get_read_receipt(handle->msg, _iterate_read_receipts, &count)) &&
+ (0 < count))
+ gtk_widget_show(GTK_WIDGET(handle->read_receipt_image));
+ else
+ gtk_widget_hide(GTK_WIDGET(handle->read_receipt_image));
+}
+
void
ui_message_update(UI_MESSAGE_Handle *handle,
MESSENGER_Application *app,
@@ -406,6 +436,8 @@ ui_message_update(UI_MESSAGE_Handle *handle,
handle->msg = msg;
+ ui_message_refresh(handle);
+
if (msg)
{
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,
UI_MESSAGE_Type type);
void
+ui_message_refresh(UI_MESSAGE_Handle *handle);
+
+void
ui_message_update(UI_MESSAGE_Handle *handle,
MESSENGER_Application *app,
const struct GNUNET_CHAT_Message *message);