diff options
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r-- | toxcore/tox.h | 118 |
1 files changed, 60 insertions, 58 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h index afa502f5..d931b9be 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -82,7 +82,7 @@ typedef struct Tox Tox; | |||
82 | /* return TOX_FRIEND_ADDRESS_SIZE byte address to give to others. | 82 | /* return TOX_FRIEND_ADDRESS_SIZE byte address to give to others. |
83 | * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] | 83 | * format: [client_id (32 bytes)][nospam number (4 bytes)][checksum (2 bytes)] |
84 | */ | 84 | */ |
85 | void tox_get_address(Tox *tox, uint8_t *address); | 85 | void tox_get_address(const Tox *tox, uint8_t *address); |
86 | 86 | ||
87 | /* Add a friend. | 87 | /* Add a friend. |
88 | * Set the data that will be sent along with friend request. | 88 | * Set the data that will be sent along with friend request. |
@@ -90,7 +90,7 @@ void tox_get_address(Tox *tox, uint8_t *address); | |||
90 | * data is the data and length is the length. | 90 | * data is the data and length is the length. |
91 | * | 91 | * |
92 | * return the friend number if success. | 92 | * return the friend number if success. |
93 | * return TOX_FA_TOOLONG if message length is too long. | 93 | * return TOX_FAERR_TOOLONG if message length is too long. |
94 | * return TOX_FAERR_NOMESSAGE if no message (message length must be >= 1 byte). | 94 | * return TOX_FAERR_NOMESSAGE if no message (message length must be >= 1 byte). |
95 | * return TOX_FAERR_OWNKEY if user's own key. | 95 | * return TOX_FAERR_OWNKEY if user's own key. |
96 | * return TOX_FAERR_ALREADYSENT if friend request already sent or already a friend. | 96 | * return TOX_FAERR_ALREADYSENT if friend request already sent or already a friend. |
@@ -100,7 +100,7 @@ void tox_get_address(Tox *tox, uint8_t *address); | |||
100 | * (the nospam for that friend was set to the new one). | 100 | * (the nospam for that friend was set to the new one). |
101 | * return TOX_FAERR_NOMEM if increasing the friend list size fails. | 101 | * return TOX_FAERR_NOMEM if increasing the friend list size fails. |
102 | */ | 102 | */ |
103 | int32_t tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length); | 103 | int32_t tox_add_friend(Tox *tox, const uint8_t *address, const uint8_t *data, uint16_t length); |
104 | 104 | ||
105 | 105 | ||
106 | /* Add a friend without sending a friendrequest. | 106 | /* Add a friend without sending a friendrequest. |
@@ -111,14 +111,14 @@ int32_t tox_add_friend_norequest(Tox *tox, const uint8_t *client_id); | |||
111 | 111 | ||
112 | /* return the friend number associated to that client id. | 112 | /* return the friend number associated to that client id. |
113 | return -1 if no such friend */ | 113 | return -1 if no such friend */ |
114 | int32_t tox_get_friend_number(Tox *tox, uint8_t *client_id); | 114 | int32_t tox_get_friend_number(const Tox *tox, const uint8_t *client_id); |
115 | 115 | ||
116 | /* Copies the public key associated to that friend id into client_id buffer. | 116 | /* Copies the public key associated to that friend id into client_id buffer. |
117 | * Make sure that client_id is of size CLIENT_ID_SIZE. | 117 | * Make sure that client_id is of size CLIENT_ID_SIZE. |
118 | * return 0 if success. | 118 | * return 0 if success. |
119 | * return -1 if failure. | 119 | * return -1 if failure. |
120 | */ | 120 | */ |
121 | int tox_get_client_id(Tox *tox, int32_t friendnumber, uint8_t *client_id); | 121 | int tox_get_client_id(const Tox *tox, int32_t friendnumber, uint8_t *client_id); |
122 | 122 | ||
123 | /* Remove a friend. | 123 | /* Remove a friend. |
124 | * | 124 | * |
@@ -133,14 +133,14 @@ int tox_del_friend(Tox *tox, int32_t friendnumber); | |||
133 | * return 0 if friend is not connected to us (Offline). | 133 | * return 0 if friend is not connected to us (Offline). |
134 | * return -1 on failure. | 134 | * return -1 on failure. |
135 | */ | 135 | */ |
136 | int tox_get_friend_connection_status(Tox *tox, int32_t friendnumber); | 136 | int tox_get_friend_connection_status(const Tox *tox, int32_t friendnumber); |
137 | 137 | ||
138 | /* Checks if there exists a friend with given friendnumber. | 138 | /* Checks if there exists a friend with given friendnumber. |
139 | * | 139 | * |
140 | * return 1 if friend exists. | 140 | * return 1 if friend exists. |
141 | * return 0 if friend doesn't exist. | 141 | * return 0 if friend doesn't exist. |
142 | */ | 142 | */ |
143 | int tox_friend_exists(Tox *tox, int32_t friendnumber); | 143 | int tox_friend_exists(const Tox *tox, int32_t friendnumber); |
144 | 144 | ||
145 | /* Send a text chat message to an online friend. | 145 | /* Send a text chat message to an online friend. |
146 | * | 146 | * |
@@ -157,7 +157,8 @@ int tox_friend_exists(Tox *tox, int32_t friendnumber); | |||
157 | * however we can generate an id for you by calling plain m_sendmessage. | 157 | * however we can generate an id for you by calling plain m_sendmessage. |
158 | */ | 158 | */ |
159 | uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length); | 159 | uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length); |
160 | uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length); | 160 | uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *message, |
161 | uint32_t length); | ||
161 | 162 | ||
162 | /* Send an action to an online friend. | 163 | /* Send an action to an online friend. |
163 | * | 164 | * |
@@ -173,8 +174,8 @@ uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, | |||
173 | * m_sendaction_withid will send an action message with the id of your choosing, | 174 | * m_sendaction_withid will send an action message with the id of your choosing, |
174 | * however we can generate an id for you by calling plain m_sendaction. | 175 | * however we can generate an id for you by calling plain m_sendaction. |
175 | */ | 176 | */ |
176 | uint32_t tox_send_action(Tox *tox, int32_t friendnumber, uint8_t *action, uint32_t length); | 177 | uint32_t tox_send_action(Tox *tox, int32_t friendnumber, const uint8_t *action, uint32_t length); |
177 | uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length); | 178 | uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *action, uint32_t length); |
178 | 179 | ||
179 | /* Set our nickname. | 180 | /* Set our nickname. |
180 | * name must be a string of maximum MAX_NAME_LENGTH length. | 181 | * name must be a string of maximum MAX_NAME_LENGTH length. |
@@ -184,7 +185,7 @@ uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, | |||
184 | * return 0 if success. | 185 | * return 0 if success. |
185 | * return -1 if failure. | 186 | * return -1 if failure. |
186 | */ | 187 | */ |
187 | int tox_set_name(Tox *tox, uint8_t *name, uint16_t length); | 188 | int tox_set_name(Tox *tox, const uint8_t *name, uint16_t length); |
188 | 189 | ||
189 | /* | 190 | /* |
190 | * Get your nickname. | 191 | * Get your nickname. |
@@ -194,7 +195,7 @@ int tox_set_name(Tox *tox, uint8_t *name, uint16_t length); | |||
194 | * return length of name. | 195 | * return length of name. |
195 | * return 0 on error. | 196 | * return 0 on error. |
196 | */ | 197 | */ |
197 | uint16_t tox_get_self_name(Tox *tox, uint8_t *name); | 198 | uint16_t tox_get_self_name(const Tox *tox, uint8_t *name); |
198 | 199 | ||
199 | /* Get name of friendnumber and put it in name. | 200 | /* Get name of friendnumber and put it in name. |
200 | * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. | 201 | * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. |
@@ -202,13 +203,13 @@ uint16_t tox_get_self_name(Tox *tox, uint8_t *name); | |||
202 | * return length of name if success. | 203 | * return length of name if success. |
203 | * return -1 if failure. | 204 | * return -1 if failure. |
204 | */ | 205 | */ |
205 | int tox_get_name(Tox *tox, int32_t friendnumber, uint8_t *name); | 206 | int tox_get_name(const Tox *tox, int32_t friendnumber, uint8_t *name); |
206 | 207 | ||
207 | /* returns the length of name on success. | 208 | /* returns the length of name on success. |
208 | * returns -1 on failure. | 209 | * returns -1 on failure. |
209 | */ | 210 | */ |
210 | int tox_get_name_size(Tox *tox, int32_t friendnumber); | 211 | int tox_get_name_size(const Tox *tox, int32_t friendnumber); |
211 | int tox_get_self_name_size(Tox *tox); | 212 | int tox_get_self_name_size(const Tox *tox); |
212 | 213 | ||
213 | /* Set our user status. | 214 | /* Set our user status. |
214 | * | 215 | * |
@@ -218,14 +219,14 @@ int tox_get_self_name_size(Tox *tox); | |||
218 | * returns 0 on success. | 219 | * returns 0 on success. |
219 | * returns -1 on failure. | 220 | * returns -1 on failure. |
220 | */ | 221 | */ |
221 | int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length); | 222 | int tox_set_status_message(Tox *tox, const uint8_t *status, uint16_t length); |
222 | int tox_set_user_status(Tox *tox, uint8_t userstatus); | 223 | int tox_set_user_status(Tox *tox, uint8_t userstatus); |
223 | 224 | ||
224 | /* returns the length of status message on success. | 225 | /* returns the length of status message on success. |
225 | * returns -1 on failure. | 226 | * returns -1 on failure. |
226 | */ | 227 | */ |
227 | int tox_get_status_message_size(Tox *tox, int32_t friendnumber); | 228 | int tox_get_status_message_size(const Tox *tox, int32_t friendnumber); |
228 | int tox_get_self_status_message_size(Tox *tox); | 229 | int tox_get_self_status_message_size(const Tox *tox); |
229 | 230 | ||
230 | /* Copy friendnumber's status message into buf, truncating if size is over maxlen. | 231 | /* Copy friendnumber's status message into buf, truncating if size is over maxlen. |
231 | * Get the size you need to allocate from m_get_statusmessage_size. | 232 | * Get the size you need to allocate from m_get_statusmessage_size. |
@@ -234,22 +235,22 @@ int tox_get_self_status_message_size(Tox *tox); | |||
234 | * returns the length of the copied data on success | 235 | * returns the length of the copied data on success |
235 | * retruns -1 on failure. | 236 | * retruns -1 on failure. |
236 | */ | 237 | */ |
237 | int tox_get_status_message(Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen); | 238 | int tox_get_status_message(const Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen); |
238 | int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen); | 239 | int tox_get_self_status_message(const Tox *tox, uint8_t *buf, uint32_t maxlen); |
239 | 240 | ||
240 | /* return one of TOX_USERSTATUS values. | 241 | /* return one of TOX_USERSTATUS values. |
241 | * Values unknown to your application should be represented as TOX_USERSTATUS_NONE. | 242 | * Values unknown to your application should be represented as TOX_USERSTATUS_NONE. |
242 | * As above, the self variant will return our own TOX_USERSTATUS. | 243 | * As above, the self variant will return our own TOX_USERSTATUS. |
243 | * If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID. | 244 | * If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID. |
244 | */ | 245 | */ |
245 | uint8_t tox_get_user_status(Tox *tox, int32_t friendnumber); | 246 | uint8_t tox_get_user_status(const Tox *tox, int32_t friendnumber); |
246 | uint8_t tox_get_self_user_status(Tox *tox); | 247 | uint8_t tox_get_self_user_status(const Tox *tox); |
247 | 248 | ||
248 | 249 | ||
249 | /* returns timestamp of last time friendnumber was seen online, or 0 if never seen. | 250 | /* returns timestamp of last time friendnumber was seen online, or 0 if never seen. |
250 | * returns -1 on error. | 251 | * returns -1 on error. |
251 | */ | 252 | */ |
252 | uint64_t tox_get_last_online(Tox *tox, int32_t friendnumber); | 253 | uint64_t tox_get_last_online(const Tox *tox, int32_t friendnumber); |
253 | 254 | ||
254 | /* Set our typing status for a friend. | 255 | /* Set our typing status for a friend. |
255 | * You are responsible for turning it on or off. | 256 | * You are responsible for turning it on or off. |
@@ -264,7 +265,7 @@ int tox_set_user_is_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing); | |||
264 | * returns 0 if friend is not typing. | 265 | * returns 0 if friend is not typing. |
265 | * returns 1 if friend is typing. | 266 | * returns 1 if friend is typing. |
266 | */ | 267 | */ |
267 | uint8_t tox_get_is_typing(Tox *tox, int32_t friendnumber); | 268 | uint8_t tox_get_is_typing(const Tox *tox, int32_t friendnumber); |
268 | 269 | ||
269 | /* Sets whether we send read receipts for friendnumber. | 270 | /* Sets whether we send read receipts for friendnumber. |
270 | * This function is not lazy, and it will fail if yesno is not (0 or 1). | 271 | * This function is not lazy, and it will fail if yesno is not (0 or 1). |
@@ -274,17 +275,17 @@ void tox_set_sends_receipts(Tox *tox, int32_t friendnumber, int yesno); | |||
274 | /* Return the number of friends in the instance m. | 275 | /* Return the number of friends in the instance m. |
275 | * You should use this to determine how much memory to allocate | 276 | * You should use this to determine how much memory to allocate |
276 | * for copy_friendlist. */ | 277 | * for copy_friendlist. */ |
277 | uint32_t tox_count_friendlist(Tox *tox); | 278 | uint32_t tox_count_friendlist(const Tox *tox); |
278 | 279 | ||
279 | /* Return the number of online friends in the instance m. */ | 280 | /* Return the number of online friends in the instance m. */ |
280 | uint32_t tox_get_num_online_friends(Tox *tox); | 281 | uint32_t tox_get_num_online_friends(const Tox *tox); |
281 | 282 | ||
282 | /* Copy a list of valid friend IDs into the array out_list. | 283 | /* Copy a list of valid friend IDs into the array out_list. |
283 | * If out_list is NULL, returns 0. | 284 | * If out_list is NULL, returns 0. |
284 | * Otherwise, returns the number of elements copied. | 285 | * Otherwise, returns the number of elements copied. |
285 | * If the array was too small, the contents | 286 | * If the array was too small, the contents |
286 | * of out_list will be truncated to list_size. */ | 287 | * of out_list will be truncated to list_size. */ |
287 | uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size); | 288 | uint32_t tox_get_friendlist(const Tox *tox, int32_t *out_list, uint32_t list_size); |
288 | 289 | ||
289 | /* Set the function that will be executed when a friend request is received. | 290 | /* Set the function that will be executed when a friend request is received. |
290 | * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) | 291 | * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) |
@@ -295,27 +296,27 @@ void tox_callback_friend_request(Tox *tox, void (*function)(Tox *tox, const uint | |||
295 | /* Set the function that will be executed when a message from a friend is received. | 296 | /* Set the function that will be executed when a message from a friend is received. |
296 | * Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * message, uint32_t length, void *userdata) | 297 | * Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * message, uint32_t length, void *userdata) |
297 | */ | 298 | */ |
298 | void tox_callback_friend_message(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *), | 299 | void tox_callback_friend_message(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *), |
299 | void *userdata); | 300 | void *userdata); |
300 | 301 | ||
301 | /* Set the function that will be executed when an action from a friend is received. | 302 | /* Set the function that will be executed when an action from a friend is received. |
302 | * Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * action, uint32_t length, void *userdata) | 303 | * Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * action, uint32_t length, void *userdata) |
303 | */ | 304 | */ |
304 | void tox_callback_friend_action(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *), | 305 | void tox_callback_friend_action(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *), |
305 | void *userdata); | 306 | void *userdata); |
306 | 307 | ||
307 | /* Set the callback for name changes. | 308 | /* Set the callback for name changes. |
308 | * function(Tox *tox, int32_t friendnumber, uint8_t *newname, uint16_t length, void *userdata) | 309 | * function(Tox *tox, int32_t friendnumber, uint8_t *newname, uint16_t length, void *userdata) |
309 | * You are not responsible for freeing newname | 310 | * You are not responsible for freeing newname |
310 | */ | 311 | */ |
311 | void tox_callback_name_change(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *), | 312 | void tox_callback_name_change(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *), |
312 | void *userdata); | 313 | void *userdata); |
313 | 314 | ||
314 | /* Set the callback for status message changes. | 315 | /* Set the callback for status message changes. |
315 | * function(Tox *tox, int32_t friendnumber, uint8_t *newstatus, uint16_t length, void *userdata) | 316 | * function(Tox *tox, int32_t friendnumber, uint8_t *newstatus, uint16_t length, void *userdata) |
316 | * You are not responsible for freeing newstatus. | 317 | * You are not responsible for freeing newstatus. |
317 | */ | 318 | */ |
318 | void tox_callback_status_message(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *), | 319 | void tox_callback_status_message(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, uint16_t, void *), |
319 | void *userdata); | 320 | void *userdata); |
320 | 321 | ||
321 | /* Set the callback for status type changes. | 322 | /* Set the callback for status type changes. |
@@ -357,7 +358,7 @@ void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int32_t | |||
357 | 358 | ||
358 | /* Functions to get/set the nospam part of the id. | 359 | /* Functions to get/set the nospam part of the id. |
359 | */ | 360 | */ |
360 | uint32_t tox_get_nospam(Tox *tox); | 361 | uint32_t tox_get_nospam(const Tox *tox); |
361 | void tox_set_nospam(Tox *tox, uint32_t nospam); | 362 | void tox_set_nospam(Tox *tox, uint32_t nospam); |
362 | 363 | ||
363 | 364 | ||
@@ -367,20 +368,20 @@ void tox_set_nospam(Tox *tox, uint32_t nospam); | |||
367 | * | 368 | * |
368 | * Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata) | 369 | * Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata) |
369 | */ | 370 | */ |
370 | void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, void *), void *userdata); | 371 | void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int32_t, const uint8_t *, void *), void *userdata); |
371 | 372 | ||
372 | /* Set the callback for group messages. | 373 | /* Set the callback for group messages. |
373 | * | 374 | * |
374 | * Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata) | 375 | * Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata) |
375 | */ | 376 | */ |
376 | void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t *, uint16_t, void *), | 377 | void tox_callback_group_message(Tox *tox, void (*function)(Tox *tox, int, int, const uint8_t *, uint16_t, void *), |
377 | void *userdata); | 378 | void *userdata); |
378 | 379 | ||
379 | /* Set the callback for group actions. | 380 | /* Set the callback for group actions. |
380 | * | 381 | * |
381 | * Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * action, uint16_t length, void *userdata) | 382 | * Function(Tox *tox, int groupnumber, int friendgroupnumber, uint8_t * action, uint16_t length, void *userdata) |
382 | */ | 383 | */ |
383 | void tox_callback_group_action(Tox *tox, void (*function)(Tox *tox, int, int, uint8_t *, uint16_t, void *), | 384 | void tox_callback_group_action(Tox *tox, void (*function)(Tox *tox, int, int, const uint8_t *, uint16_t, void *), |
384 | void *userdata); | 385 | void *userdata); |
385 | 386 | ||
386 | /* Set callback function for peer name list changes. | 387 | /* Set callback function for peer name list changes. |
@@ -417,7 +418,7 @@ int tox_del_groupchat(Tox *tox, int groupnumber); | |||
417 | * return length of name if success | 418 | * return length of name if success |
418 | * return -1 if failure | 419 | * return -1 if failure |
419 | */ | 420 | */ |
420 | int tox_group_peername(Tox *tox, int groupnumber, int peernumber, uint8_t *name); | 421 | int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, uint8_t *name); |
421 | 422 | ||
422 | /* invite friendnumber to groupnumber | 423 | /* invite friendnumber to groupnumber |
423 | * return 0 on success | 424 | * return 0 on success |
@@ -430,24 +431,24 @@ int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber); | |||
430 | * returns group number on success | 431 | * returns group number on success |
431 | * returns -1 on failure. | 432 | * returns -1 on failure. |
432 | */ | 433 | */ |
433 | int tox_join_groupchat(Tox *tox, int32_t friendnumber, uint8_t *friend_group_public_key); | 434 | int tox_join_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *friend_group_public_key); |
434 | 435 | ||
435 | /* send a group message | 436 | /* send a group message |
436 | * return 0 on success | 437 | * return 0 on success |
437 | * return -1 on failure | 438 | * return -1 on failure |
438 | */ | 439 | */ |
439 | int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t length); | 440 | int tox_group_message_send(Tox *tox, int groupnumber, const uint8_t *message, uint32_t length); |
440 | 441 | ||
441 | /* send a group action | 442 | /* send a group action |
442 | * return 0 on success | 443 | * return 0 on success |
443 | * return -1 on failure | 444 | * return -1 on failure |
444 | */ | 445 | */ |
445 | int tox_group_action_send(Tox *tox, int groupnumber, uint8_t *action, uint32_t length); | 446 | int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint32_t length); |
446 | 447 | ||
447 | /* Return the number of peers in the group chat on success. | 448 | /* Return the number of peers in the group chat on success. |
448 | * return -1 on failure | 449 | * return -1 on failure |
449 | */ | 450 | */ |
450 | int tox_group_number_peers(Tox *tox, int groupnumber); | 451 | int tox_group_number_peers(const Tox *tox, int groupnumber); |
451 | 452 | ||
452 | /* List all the peers in the group chat. | 453 | /* List all the peers in the group chat. |
453 | * | 454 | * |
@@ -459,20 +460,20 @@ int tox_group_number_peers(Tox *tox, int groupnumber); | |||
459 | * | 460 | * |
460 | * return -1 on failure. | 461 | * return -1 on failure. |
461 | */ | 462 | */ |
462 | int tox_group_get_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[], | 463 | int tox_group_get_names(const Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[], |
463 | uint16_t length); | 464 | uint16_t length); |
464 | 465 | ||
465 | /* Return the number of chats in the instance m. | 466 | /* Return the number of chats in the instance m. |
466 | * You should use this to determine how much memory to allocate | 467 | * You should use this to determine how much memory to allocate |
467 | * for copy_chatlist. */ | 468 | * for copy_chatlist. */ |
468 | uint32_t tox_count_chatlist(Tox *tox); | 469 | uint32_t tox_count_chatlist(const Tox *tox); |
469 | 470 | ||
470 | /* Copy a list of valid chat IDs into the array out_list. | 471 | /* Copy a list of valid chat IDs into the array out_list. |
471 | * If out_list is NULL, returns 0. | 472 | * If out_list is NULL, returns 0. |
472 | * Otherwise, returns the number of elements copied. | 473 | * Otherwise, returns the number of elements copied. |
473 | * If the array was too small, the contents | 474 | * If the array was too small, the contents |
474 | * of out_list will be truncated to list_size. */ | 475 | * of out_list will be truncated to list_size. */ |
475 | uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size); | 476 | uint32_t tox_get_chatlist(const Tox *tox, int *out_list, uint32_t list_size); |
476 | 477 | ||
477 | 478 | ||
478 | /****************FILE SENDING FUNCTIONS*****************/ | 479 | /****************FILE SENDING FUNCTIONS*****************/ |
@@ -523,8 +524,8 @@ enum { | |||
523 | * | 524 | * |
524 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) | 525 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) |
525 | */ | 526 | */ |
526 | void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint64_t, uint8_t *, uint16_t, | 527 | void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint64_t, const uint8_t *, |
527 | void *), void *userdata); | 528 | uint16_t, void *), void *userdata); |
528 | 529 | ||
529 | /* Set the callback for file control requests. | 530 | /* Set the callback for file control requests. |
530 | * | 531 | * |
@@ -534,7 +535,7 @@ void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int32_t, | |||
534 | * Function(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata) | 535 | * Function(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata) |
535 | * | 536 | * |
536 | */ | 537 | */ |
537 | void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *, | 538 | void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t, uint8_t, const uint8_t *, |
538 | uint16_t, void *), void *userdata); | 539 | uint16_t, void *), void *userdata); |
539 | 540 | ||
540 | /* Set the callback for file data. | 541 | /* Set the callback for file data. |
@@ -542,8 +543,8 @@ void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int32_t, uint8 | |||
542 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata) | 543 | * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata) |
543 | * | 544 | * |
544 | */ | 545 | */ |
545 | void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t *, uint16_t length, void *), | 546 | void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, const uint8_t *, uint16_t length, |
546 | void *userdata); | 547 | void *), void *userdata); |
547 | 548 | ||
548 | 549 | ||
549 | /* Send a file send request. | 550 | /* Send a file send request. |
@@ -551,7 +552,8 @@ void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, | |||
551 | * return file number on success | 552 | * return file number on success |
552 | * return -1 on failure | 553 | * return -1 on failure |
553 | */ | 554 | */ |
554 | int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length); | 555 | int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, const uint8_t *filename, |
556 | uint16_t filename_length); | ||
555 | 557 | ||
556 | /* Send a file control request. | 558 | /* Send a file control request. |
557 | * | 559 | * |
@@ -562,21 +564,21 @@ int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8 | |||
562 | * return -1 on failure | 564 | * return -1 on failure |
563 | */ | 565 | */ |
564 | int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, | 566 | int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, |
565 | uint8_t *data, uint16_t length); | 567 | const uint8_t *data, uint16_t length); |
566 | 568 | ||
567 | /* Send file data. | 569 | /* Send file data. |
568 | * | 570 | * |
569 | * return 0 on success | 571 | * return 0 on success |
570 | * return -1 on failure | 572 | * return -1 on failure |
571 | */ | 573 | */ |
572 | int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); | 574 | int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length); |
573 | 575 | ||
574 | /* Returns the recommended/maximum size of the filedata you send with tox_file_send_data() | 576 | /* Returns the recommended/maximum size of the filedata you send with tox_file_send_data() |
575 | * | 577 | * |
576 | * return size on success | 578 | * return size on success |
577 | * return -1 on failure (currently will never return -1) | 579 | * return -1 on failure (currently will never return -1) |
578 | */ | 580 | */ |
579 | int tox_file_data_size(Tox *tox, int32_t friendnumber); | 581 | int tox_file_data_size(const Tox *tox, int32_t friendnumber); |
580 | 582 | ||
581 | /* Give the number of bytes left to be sent/received. | 583 | /* Give the number of bytes left to be sent/received. |
582 | * | 584 | * |
@@ -585,7 +587,7 @@ int tox_file_data_size(Tox *tox, int32_t friendnumber); | |||
585 | * return number of bytes remaining to be sent/received on success | 587 | * return number of bytes remaining to be sent/received on success |
586 | * return 0 on failure | 588 | * return 0 on failure |
587 | */ | 589 | */ |
588 | uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); | 590 | uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); |
589 | 591 | ||
590 | /***************END OF FILE SENDING FUNCTIONS******************/ | 592 | /***************END OF FILE SENDING FUNCTIONS******************/ |
591 | 593 | ||
@@ -606,12 +608,12 @@ uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenum | |||
606 | * returns 0 otherwise | 608 | * returns 0 otherwise |
607 | */ | 609 | */ |
608 | int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled, | 610 | int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled, |
609 | uint16_t port, uint8_t *public_key); | 611 | uint16_t port, const uint8_t *public_key); |
610 | 612 | ||
611 | /* return 0 if we are not connected to the DHT. | 613 | /* return 0 if we are not connected to the DHT. |
612 | * return 1 if we are. | 614 | * return 1 if we are. |
613 | */ | 615 | */ |
614 | int tox_isconnected(Tox *tox); | 616 | int tox_isconnected(const Tox *tox); |
615 | 617 | ||
616 | /* | 618 | /* |
617 | * Run this function at startup. | 619 | * Run this function at startup. |
@@ -645,17 +647,17 @@ void tox_do(Tox *tox); | |||
645 | /* SAVING AND LOADING FUNCTIONS: */ | 647 | /* SAVING AND LOADING FUNCTIONS: */ |
646 | 648 | ||
647 | /* return size of messenger data (for saving). */ | 649 | /* return size of messenger data (for saving). */ |
648 | uint32_t tox_size(Tox *tox); | 650 | uint32_t tox_size(const Tox *tox); |
649 | 651 | ||
650 | /* Save the messenger in data (must be allocated memory of size Messenger_size()). */ | 652 | /* Save the messenger in data (must be allocated memory of size Messenger_size()). */ |
651 | void tox_save(Tox *tox, uint8_t *data); | 653 | void tox_save(const Tox *tox, uint8_t *data); |
652 | 654 | ||
653 | /* Load the messenger from data of size length. | 655 | /* Load the messenger from data of size length. |
654 | * | 656 | * |
655 | * returns 0 on success | 657 | * returns 0 on success |
656 | * returns -1 on failure | 658 | * returns -1 on failure |
657 | */ | 659 | */ |
658 | int tox_load(Tox *tox, uint8_t *data, uint32_t length); | 660 | int tox_load(Tox *tox, const uint8_t *data, uint32_t length); |
659 | 661 | ||
660 | #ifdef __cplusplus | 662 | #ifdef __cplusplus |
661 | } | 663 | } |