summaryrefslogtreecommitdiff
path: root/core/Messenger.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/Messenger.h')
-rw-r--r--core/Messenger.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/core/Messenger.h b/core/Messenger.h
index 8940aadd..f0444b91 100644
--- a/core/Messenger.h
+++ b/core/Messenger.h
@@ -40,6 +40,7 @@ extern "C" {
40 40
41#define PACKET_ID_NICKNAME 48 41#define PACKET_ID_NICKNAME 48
42#define PACKET_ID_USERSTATUS 49 42#define PACKET_ID_USERSTATUS 49
43#define PACKET_ID_RECEIPT 65
43#define PACKET_ID_MESSAGE 64 44#define PACKET_ID_MESSAGE 64
44 45
45/* status definitions */ 46/* status definitions */
@@ -117,9 +118,14 @@ int m_delfriend(int friendnumber);
117int m_friendstatus(int friendnumber); 118int m_friendstatus(int friendnumber);
118 119
119/* send a text chat message to an online friend 120/* send a text chat message to an online friend
120 returns 1 if packet was successfully put into the send queue 121 returns the message id if packet was successfully put into the send queue
121 return 0 if it was not */ 122 return 0 if it was not
122int m_sendmessage(int friendnumber, uint8_t *message, uint32_t length); 123 you will want to retain the return value, it will be passed to your read receipt callback
124 if one is received.
125 m_sendmessage_withid will send a message with the id of your choosing,
126 however we can generate an id for you by calling plain m_sendmessage. */
127uint32_t m_sendmessage(int friendnumber, uint8_t *message, uint32_t length);
128uint32_t m_sendmessage_withid(int friendnumber, uint32_t theid, uint8_t *message, uint32_t length);
123 129
124/* Set our nickname 130/* Set our nickname
125 name must be a string of maximum MAX_NAME_LENGTH length. 131 name must be a string of maximum MAX_NAME_LENGTH length.
@@ -165,6 +171,10 @@ int m_copy_self_userstatus(uint8_t *buf, uint32_t maxlen);
165USERSTATUS_KIND m_get_userstatus_kind(int friendnumber); 171USERSTATUS_KIND m_get_userstatus_kind(int friendnumber);
166USERSTATUS_KIND m_get_self_userstatus_kind(void); 172USERSTATUS_KIND m_get_self_userstatus_kind(void);
167 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).*/
176void m_set_sends_receipts(int friendnumber, int yesno);
177
168/* 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.
169 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) */
170void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t)); 180void m_callback_friendrequest(void (*function)(uint8_t *, uint8_t *, uint16_t));
@@ -183,6 +193,15 @@ void m_callback_namechange(void (*function)(int, uint8_t *, uint16_t));
183 you are not responsible for freeing newstatus */ 193 you are not responsible for freeing newstatus */
184void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t)); 194void m_callback_userstatus(void (*function)(int, USERSTATUS_KIND, uint8_t *, uint16_t));
185 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. */
203void m_callback_read_receipt(void (*function)(int, uint32_t));
204
186/* run this at startup 205/* run this at startup
187 returns 0 if no connection problems 206 returns 0 if no connection problems
188 returns -1 if there are problems */ 207 returns -1 if there are problems */