diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/Messenger.c | 15 | ||||
-rw-r--r-- | core/Messenger.h | 11 |
2 files changed, 25 insertions, 1 deletions
diff --git a/core/Messenger.c b/core/Messenger.c index a4195d58..353ce603 100644 --- a/core/Messenger.c +++ b/core/Messenger.c | |||
@@ -205,7 +205,10 @@ uint32_t m_sendmessage(int friendnumber, uint8_t *message, uint32_t length) | |||
205 | { | 205 | { |
206 | if (friendnumber < 0 || friendnumber >= numfriends) | 206 | if (friendnumber < 0 || friendnumber >= numfriends) |
207 | return 0; | 207 | return 0; |
208 | return m_sendmessage_withid(friendnumber, friendlist[friendnumber].message_id++, message, length); | 208 | uint32_t msgid = ++friendlist[friendnumber].message_id; |
209 | if (msgid == 0) | ||
210 | msgid = 1; /* otherwise, false error */ | ||
211 | return m_sendmessage_withid(friendnumber, msgid, message, length); | ||
209 | } | 212 | } |
210 | 213 | ||
211 | uint32_t m_sendmessage_withid(int friendnumber, uint32_t theid, uint8_t *message, uint32_t length) | 214 | uint32_t m_sendmessage_withid(int friendnumber, uint32_t theid, uint8_t *message, uint32_t length) |
@@ -391,6 +394,16 @@ static void set_friend_userstatus_kind(int friendnumber, USERSTATUS_KIND k) | |||
391 | friendlist[friendnumber].userstatus_kind = k; | 394 | friendlist[friendnumber].userstatus_kind = k; |
392 | } | 395 | } |
393 | 396 | ||
397 | /* Sets whether we send read receipts for friendnumber. */ | ||
398 | void m_set_sends_receipts(int friendnumber, int yesno) | ||
399 | { | ||
400 | if (yesno < 0 || yesno > 1) | ||
401 | return; | ||
402 | if (friendnumber >= numfriends || friendnumber < 0) | ||
403 | return; | ||
404 | friendlist[friendnumber].receives_read_receipts = yesno; | ||
405 | } | ||
406 | |||
394 | /* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); | 407 | /* static void (*friend_request)(uint8_t *, uint8_t *, uint16_t); |
395 | static uint8_t friend_request_isset = 0; */ | 408 | static uint8_t friend_request_isset = 0; */ |
396 | /* set the function that will be executed when a friend request is received. */ | 409 | /* set the function that will be executed when a friend request is received. */ |
diff --git a/core/Messenger.h b/core/Messenger.h index 0e4eabe0..f0444b91 100644 --- a/core/Messenger.h +++ b/core/Messenger.h | |||
@@ -171,6 +171,10 @@ int m_copy_self_userstatus(uint8_t *buf, uint32_t maxlen); | |||
171 | USERSTATUS_KIND m_get_userstatus_kind(int friendnumber); | 171 | USERSTATUS_KIND m_get_userstatus_kind(int friendnumber); |
172 | USERSTATUS_KIND m_get_self_userstatus_kind(void); | 172 | USERSTATUS_KIND m_get_self_userstatus_kind(void); |
173 | 173 | ||
174 | /* Sets whether we send read receipts for friendnumber. | ||
175 | * This function is not lazy, and it will fail if yesno is not (0 or 1).*/ | ||
176 | void m_set_sends_receipts(int friendnumber, int yesno); | ||
177 | |||
174 | /* set the function that will be executed when a friend request is received. | 178 | /* set the function that will be executed when a friend request is received. |
175 | function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ | 179 | function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ |
176 | void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)); | 180 | void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)); |
@@ -189,6 +193,13 @@ void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t)); | |||
189 | you are not responsible for freeing newstatus */ | 193 | you are not responsible for freeing newstatus */ |
190 | void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t)); | 194 | void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t)); |
191 | 195 | ||
196 | /* set the callback for read receipts | ||
197 | function(int friendnumber, uint32_t receipt) | ||
198 | if you are keeping a record of returns from m_sendmessage, | ||
199 | receipt might be one of those values, and that means the message | ||
200 | has been received on the other side. since core doesn't | ||
201 | track ids for you, receipt may not correspond to any message | ||
202 | in that case, you should discard it. */ | ||
192 | void m_callback_read_receipt(void (*function)(int, uint32_t)); | 203 | void m_callback_read_receipt(void (*function)(int, uint32_t)); |
193 | 204 | ||
194 | /* run this at startup | 205 | /* run this at startup |