aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-03-19 19:59:53 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-03-20 14:13:57 +0100
commiteec5d26ea19d234de7abe167ab42785620f1bd55 (patch)
tree8882376c104835d564c48c40cdcd27b906df1074
parent69176480c5ff9faad872d2aad68a5780c2f364b5 (diff)
downloadlibgnunetchat-eec5d26ea19d234de7abe167ab42785620f1bd55.tar.gz
libgnunetchat-eec5d26ea19d234de7abe167ab42785620f1bd55.zip
Add sending read receipts
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--include/gnunet_chat_lib.h12
-rw-r--r--src/gnunet_chat_lib.c45
2 files changed, 57 insertions, 0 deletions
diff --git a/include/gnunet_chat_lib.h b/include/gnunet_chat_lib.h
index 6610f59..a434381 100644
--- a/include/gnunet_chat_lib.h
+++ b/include/gnunet_chat_lib.h
@@ -814,6 +814,18 @@ GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context,
814 const char *text); 814 const char *text);
815 815
816/** 816/**
817 * Sends a read receipt depending on a selected <i>message</i> into a given
818 * chat <i>context</i>.
819 *
820 * @param[in,out] context Chat context
821 * @param[in] message Message (optional)
822 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
823 */
824int
825GNUNET_CHAT_context_send_read_receipt (struct GNUNET_CHAT_Context *context,
826 const struct GNUNET_CHAT_Message *message);
827
828/**
817 * Uploads a local file specified via its <i>path</i> using symmetric encryption 829 * Uploads a local file specified via its <i>path</i> using symmetric encryption
818 * and shares the regarding information to download and decrypt it in a given 830 * and shares the regarding information to download and decrypt it in a given
819 * chat <i>context</i>. 831 * chat <i>context</i>.
diff --git a/src/gnunet_chat_lib.c b/src/gnunet_chat_lib.c
index 2632fb5..e11c92d 100644
--- a/src/gnunet_chat_lib.c
+++ b/src/gnunet_chat_lib.c
@@ -925,6 +925,51 @@ GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context,
925} 925}
926 926
927 927
928int
929GNUNET_CHAT_context_send_read_receipt (struct GNUNET_CHAT_Context *context,
930 const struct GNUNET_CHAT_Message *message)
931{
932 if ((!context) || (!(context->room)))
933 return GNUNET_SYSERR;
934
935 char zero = '\0';
936 struct GNUNET_MESSENGER_Message msg;
937 msg.header.kind = GNUNET_MESSENGER_KIND_TEXT;
938 msg.body.text.text = &zero;
939
940 const struct GNUNET_MESSENGER_Contact *receiver = NULL;
941
942 if (!message)
943 goto skip_filter;
944
945 if (GNUNET_CHAT_FLAG_NONE != message->flag)
946 return GNUNET_SYSERR;
947
948 if (message->flags & GNUNET_MESSENGER_FLAG_SENT)
949 return GNUNET_OK;
950
951 if (message->flags & GNUNET_MESSENGER_FLAG_PRIVATE)
952 {
953 receiver = GNUNET_MESSENGER_get_sender(context->room, &(message->hash));
954
955 if (!receiver)
956 return GNUNET_SYSERR;
957 }
958
959 if ((!(message->msg)) ||
960 (GNUNET_MESSENGER_KIND_TEXT != message->msg->header.kind))
961 goto skip_filter;
962
963 if ((!(message->msg->body.text.text)) ||
964 (!(message->msg->body.text.text[0])))
965 return GNUNET_SYSERR;
966
967skip_filter:
968 GNUNET_MESSENGER_send_message(context->room, &msg, receiver);
969 return GNUNET_OK;
970}
971
972
928struct GNUNET_CHAT_File* 973struct GNUNET_CHAT_File*
929GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context, 974GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context,
930 const char *path, 975 const char *path,