diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-03-19 19:59:53 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-03-19 19:59:53 +0100 |
commit | 7fd77866e389b1838e86a71f030042901186350c (patch) | |
tree | ab5ebada54ae2c5983816110124f3bc551c4798a | |
parent | a2567049c4088ec78a770ff4b460a96ceb3943b2 (diff) | |
download | libgnunetchat-7fd77866e389b1838e86a71f030042901186350c.tar.gz libgnunetchat-7fd77866e389b1838e86a71f030042901186350c.zip |
Add sending read receipts
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | include/gnunet_chat_lib.h | 12 | ||||
-rw-r--r-- | src/gnunet_chat_lib.c | 45 |
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 | */ | ||
824 | int | ||
825 | GNUNET_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 b8213e7..6f53819 100644 --- a/src/gnunet_chat_lib.c +++ b/src/gnunet_chat_lib.c | |||
@@ -941,6 +941,51 @@ GNUNET_CHAT_context_send_text (struct GNUNET_CHAT_Context *context, | |||
941 | } | 941 | } |
942 | 942 | ||
943 | 943 | ||
944 | int | ||
945 | GNUNET_CHAT_context_send_read_receipt (struct GNUNET_CHAT_Context *context, | ||
946 | const struct GNUNET_CHAT_Message *message) | ||
947 | { | ||
948 | if ((!context) || (!(context->room))) | ||
949 | return GNUNET_SYSERR; | ||
950 | |||
951 | char zero = '\0'; | ||
952 | struct GNUNET_MESSENGER_Message msg; | ||
953 | msg.header.kind = GNUNET_MESSENGER_KIND_TEXT; | ||
954 | msg.body.text.text = &zero; | ||
955 | |||
956 | const struct GNUNET_MESSENGER_Contact *receiver = NULL; | ||
957 | |||
958 | if (!message) | ||
959 | goto skip_filter; | ||
960 | |||
961 | if (GNUNET_CHAT_FLAG_NONE != message->flag) | ||
962 | return GNUNET_SYSERR; | ||
963 | |||
964 | if (message->flags & GNUNET_MESSENGER_FLAG_SENT) | ||
965 | return GNUNET_OK; | ||
966 | |||
967 | if (message->flags & GNUNET_MESSENGER_FLAG_PRIVATE) | ||
968 | { | ||
969 | receiver = GNUNET_MESSENGER_get_sender(context->room, &(message->hash)); | ||
970 | |||
971 | if (!receiver) | ||
972 | return GNUNET_SYSERR; | ||
973 | } | ||
974 | |||
975 | if ((!(message->msg)) || | ||
976 | (GNUNET_MESSENGER_KIND_TEXT != message->msg->header.kind)) | ||
977 | goto skip_filter; | ||
978 | |||
979 | if ((!(message->msg->body.text.text)) || | ||
980 | (!(message->msg->body.text.text[0]))) | ||
981 | return GNUNET_SYSERR; | ||
982 | |||
983 | skip_filter: | ||
984 | GNUNET_MESSENGER_send_message(context->room, &msg, receiver); | ||
985 | return GNUNET_OK; | ||
986 | } | ||
987 | |||
988 | |||
944 | struct GNUNET_CHAT_File* | 989 | struct GNUNET_CHAT_File* |
945 | GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context, | 990 | GNUNET_CHAT_context_send_file (struct GNUNET_CHAT_Context *context, |
946 | const char *path, | 991 | const char *path, |