diff options
Diffstat (limited to 'core/Messenger.h')
-rw-r--r-- | core/Messenger.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/core/Messenger.h b/core/Messenger.h index aef652ff..d2fa8945 100644 --- a/core/Messenger.h +++ b/core/Messenger.h | |||
@@ -41,6 +41,7 @@ extern "C" { | |||
41 | #define PACKET_ID_NICKNAME 48 | 41 | #define PACKET_ID_NICKNAME 48 |
42 | #define PACKET_ID_STATUSMESSAGE 49 | 42 | #define PACKET_ID_STATUSMESSAGE 49 |
43 | #define PACKET_ID_USERSTATUS 50 | 43 | #define PACKET_ID_USERSTATUS 50 |
44 | #define PACKET_ID_RECEIPT 65 | ||
44 | #define PACKET_ID_MESSAGE 64 | 45 | #define PACKET_ID_MESSAGE 64 |
45 | 46 | ||
46 | /* status definitions */ | 47 | /* status definitions */ |
@@ -112,9 +113,14 @@ int m_delfriend(int friendnumber); | |||
112 | int m_friendstatus(int friendnumber); | 113 | int m_friendstatus(int friendnumber); |
113 | 114 | ||
114 | /* send a text chat message to an online friend | 115 | /* send a text chat message to an online friend |
115 | returns 1 if packet was successfully put into the send queue | 116 | returns the message id if packet was successfully put into the send queue |
116 | return 0 if it was not */ | 117 | return 0 if it was not |
117 | int m_sendmessage(int friendnumber, uint8_t *message, uint32_t length); | 118 | you will want to retain the return value, it will be passed to your read receipt callback |
119 | if one is received. | ||
120 | m_sendmessage_withid will send a message with the id of your choosing, | ||
121 | however we can generate an id for you by calling plain m_sendmessage. */ | ||
122 | uint32_t m_sendmessage(int friendnumber, uint8_t *message, uint32_t length); | ||
123 | uint32_t m_sendmessage_withid(int friendnumber, uint32_t theid, uint8_t *message, uint32_t length); | ||
118 | 124 | ||
119 | /* Set our nickname | 125 | /* Set our nickname |
120 | name must be a string of maximum MAX_NAME_LENGTH length. | 126 | name must be a string of maximum MAX_NAME_LENGTH length. |
@@ -160,6 +166,10 @@ int m_copy_self_statusmessage(uint8_t *buf, uint32_t maxlen); | |||
160 | USERSTATUS m_get_userstatus(int friendnumber); | 166 | USERSTATUS m_get_userstatus(int friendnumber); |
161 | USERSTATUS m_get_self_userstatus(void); | 167 | USERSTATUS m_get_self_userstatus(void); |
162 | 168 | ||
169 | /* Sets whether we send read receipts for friendnumber. | ||
170 | * This function is not lazy, and it will fail if yesno is not (0 or 1).*/ | ||
171 | void m_set_sends_receipts(int friendnumber, int yesno); | ||
172 | |||
163 | /* set the function that will be executed when a friend request is received. | 173 | /* set the function that will be executed when a friend request is received. |
164 | function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ | 174 | function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ |
165 | void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)); | 175 | void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)); |
@@ -178,6 +188,15 @@ void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t)); | |||
178 | you are not responsible for freeing newstatus */ | 188 | you are not responsible for freeing newstatus */ |
179 | void m_callback_statusmessage(void (*function)(int, uint8_t *, uint16_t)); | 189 | void m_callback_statusmessage(void (*function)(int, uint8_t *, uint16_t)); |
180 | 190 | ||
191 | /* set the callback for read receipts | ||
192 | function(int friendnumber, uint32_t receipt) | ||
193 | if you are keeping a record of returns from m_sendmessage, | ||
194 | receipt might be one of those values, and that means the message | ||
195 | has been received on the other side. since core doesn't | ||
196 | track ids for you, receipt may not correspond to any message | ||
197 | in that case, you should discard it. */ | ||
198 | void m_callback_read_receipt(void (*function)(int, uint32_t)); | ||
199 | |||
181 | /* run this at startup | 200 | /* run this at startup |
182 | returns 0 if no connection problems | 201 | returns 0 if no connection problems |
183 | returns -1 if there are problems */ | 202 | returns -1 if there are problems */ |