summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h90
1 files changed, 45 insertions, 45 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 65088ebb..fdff44d1 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 */
85void tox_get_address(Tox *tox, uint8_t *address); 85void 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.
@@ -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 */
103int32_t tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length); 103int32_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 */
114int32_t tox_get_friend_number(Tox *tox, uint8_t *client_id); 114int32_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 */
121int tox_get_client_id(Tox *tox, int32_t friendnumber, uint8_t *client_id); 121int 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 */
136int tox_get_friend_connection_status(Tox *tox, int32_t friendnumber); 136int 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 */
143int tox_friend_exists(Tox *tox, int32_t friendnumber); 143int 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,7 @@ 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 */
159uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length); 159uint32_t tox_send_message(Tox *tox, int32_t friendnumber, const uint8_t *message, uint32_t length);
160uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length); 160uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *message, uint32_t length);
161 161
162/* Send an action to an online friend. 162/* Send an action to an online friend.
163 * 163 *
@@ -173,8 +173,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, 173 * 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. 174 * however we can generate an id for you by calling plain m_sendaction.
175 */ 175 */
176uint32_t tox_send_action(Tox *tox, int32_t friendnumber, uint8_t *action, uint32_t length); 176uint32_t tox_send_action(Tox *tox, int32_t friendnumber, const uint8_t *action, uint32_t length);
177uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length); 177uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, const uint8_t *action, uint32_t length);
178 178
179/* Set our nickname. 179/* Set our nickname.
180 * name must be a string of maximum MAX_NAME_LENGTH length. 180 * name must be a string of maximum MAX_NAME_LENGTH length.
@@ -184,7 +184,7 @@ uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid,
184 * return 0 if success. 184 * return 0 if success.
185 * return -1 if failure. 185 * return -1 if failure.
186 */ 186 */
187int tox_set_name(Tox *tox, uint8_t *name, uint16_t length); 187int tox_set_name(Tox *tox, const uint8_t *name, uint16_t length);
188 188
189/* 189/*
190 * Get your nickname. 190 * Get your nickname.
@@ -194,7 +194,7 @@ int tox_set_name(Tox *tox, uint8_t *name, uint16_t length);
194 * return length of name. 194 * return length of name.
195 * return 0 on error. 195 * return 0 on error.
196 */ 196 */
197uint16_t tox_get_self_name(Tox *tox, uint8_t *name); 197uint16_t tox_get_self_name(const Tox *tox, uint8_t *name);
198 198
199/* Get name of friendnumber and put it in name. 199/* 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. 200 * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
@@ -202,13 +202,13 @@ uint16_t tox_get_self_name(Tox *tox, uint8_t *name);
202 * return length of name if success. 202 * return length of name if success.
203 * return -1 if failure. 203 * return -1 if failure.
204 */ 204 */
205int tox_get_name(Tox *tox, int32_t friendnumber, uint8_t *name); 205int tox_get_name(const Tox *tox, int32_t friendnumber, uint8_t *name);
206 206
207/* returns the length of name on success. 207/* returns the length of name on success.
208 * returns -1 on failure. 208 * returns -1 on failure.
209 */ 209 */
210int tox_get_name_size(Tox *tox, int32_t friendnumber); 210int tox_get_name_size(const Tox *tox, int32_t friendnumber);
211int tox_get_self_name_size(Tox *tox); 211int tox_get_self_name_size(const Tox *tox);
212 212
213/* Set our user status. 213/* Set our user status.
214 * 214 *
@@ -218,14 +218,14 @@ int tox_get_self_name_size(Tox *tox);
218 * returns 0 on success. 218 * returns 0 on success.
219 * returns -1 on failure. 219 * returns -1 on failure.
220 */ 220 */
221int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length); 221int tox_set_status_message(Tox *tox, const uint8_t *status, uint16_t length);
222int tox_set_user_status(Tox *tox, uint8_t userstatus); 222int tox_set_user_status(Tox *tox, uint8_t userstatus);
223 223
224/* returns the length of status message on success. 224/* returns the length of status message on success.
225 * returns -1 on failure. 225 * returns -1 on failure.
226 */ 226 */
227int tox_get_status_message_size(Tox *tox, int32_t friendnumber); 227int tox_get_status_message_size(const Tox *tox, int32_t friendnumber);
228int tox_get_self_status_message_size(Tox *tox); 228int tox_get_self_status_message_size(const Tox *tox);
229 229
230/* Copy friendnumber's status message into buf, truncating if size is over maxlen. 230/* 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. 231 * Get the size you need to allocate from m_get_statusmessage_size.
@@ -234,22 +234,22 @@ int tox_get_self_status_message_size(Tox *tox);
234 * returns the length of the copied data on success 234 * returns the length of the copied data on success
235 * retruns -1 on failure. 235 * retruns -1 on failure.
236 */ 236 */
237int tox_get_status_message(Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen); 237int tox_get_status_message(const Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen);
238int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen); 238int tox_get_self_status_message(const Tox *tox, uint8_t *buf, uint32_t maxlen);
239 239
240/* return one of TOX_USERSTATUS values. 240/* return one of TOX_USERSTATUS values.
241 * Values unknown to your application should be represented as TOX_USERSTATUS_NONE. 241 * Values unknown to your application should be represented as TOX_USERSTATUS_NONE.
242 * As above, the self variant will return our own TOX_USERSTATUS. 242 * As above, the self variant will return our own TOX_USERSTATUS.
243 * If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID. 243 * If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID.
244 */ 244 */
245uint8_t tox_get_user_status(Tox *tox, int32_t friendnumber); 245uint8_t tox_get_user_status(const Tox *tox, int32_t friendnumber);
246uint8_t tox_get_self_user_status(Tox *tox); 246uint8_t tox_get_self_user_status(const Tox *tox);
247 247
248 248
249/* returns timestamp of last time friendnumber was seen online, or 0 if never seen. 249/* returns timestamp of last time friendnumber was seen online, or 0 if never seen.
250 * returns -1 on error. 250 * returns -1 on error.
251 */ 251 */
252uint64_t tox_get_last_online(Tox *tox, int32_t friendnumber); 252uint64_t tox_get_last_online(const Tox *tox, int32_t friendnumber);
253 253
254/* Set our typing status for a friend. 254/* Set our typing status for a friend.
255 * You are responsible for turning it on or off. 255 * You are responsible for turning it on or off.
@@ -264,7 +264,7 @@ int tox_set_user_is_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing);
264 * returns 0 if friend is not typing. 264 * returns 0 if friend is not typing.
265 * returns 1 if friend is typing. 265 * returns 1 if friend is typing.
266 */ 266 */
267uint8_t tox_get_is_typing(Tox *tox, int32_t friendnumber); 267uint8_t tox_get_is_typing(const Tox *tox, int32_t friendnumber);
268 268
269/* Sets whether we send read receipts for friendnumber. 269/* 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). 270 * This function is not lazy, and it will fail if yesno is not (0 or 1).
@@ -274,17 +274,17 @@ void tox_set_sends_receipts(Tox *tox, int32_t friendnumber, int yesno);
274/* Return the number of friends in the instance m. 274/* Return the number of friends in the instance m.
275 * You should use this to determine how much memory to allocate 275 * You should use this to determine how much memory to allocate
276 * for copy_friendlist. */ 276 * for copy_friendlist. */
277uint32_t tox_count_friendlist(Tox *tox); 277uint32_t tox_count_friendlist(const Tox *tox);
278 278
279/* Return the number of online friends in the instance m. */ 279/* Return the number of online friends in the instance m. */
280uint32_t tox_get_num_online_friends(Tox *tox); 280uint32_t tox_get_num_online_friends(const Tox *tox);
281 281
282/* Copy a list of valid friend IDs into the array out_list. 282/* Copy a list of valid friend IDs into the array out_list.
283 * If out_list is NULL, returns 0. 283 * If out_list is NULL, returns 0.
284 * Otherwise, returns the number of elements copied. 284 * Otherwise, returns the number of elements copied.
285 * If the array was too small, the contents 285 * If the array was too small, the contents
286 * of out_list will be truncated to list_size. */ 286 * of out_list will be truncated to list_size. */
287uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size); 287uint32_t tox_get_friendlist(const Tox *tox, int32_t *out_list, uint32_t list_size);
288 288
289/* Set the function that will be executed when a friend request is received. 289/* 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) 290 * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata)
@@ -357,7 +357,7 @@ void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int32_t
357 357
358/* Functions to get/set the nospam part of the id. 358/* Functions to get/set the nospam part of the id.
359 */ 359 */
360uint32_t tox_get_nospam(Tox *tox); 360uint32_t tox_get_nospam(const Tox *tox);
361void tox_set_nospam(Tox *tox, uint32_t nospam); 361void tox_set_nospam(Tox *tox, uint32_t nospam);
362 362
363 363
@@ -417,7 +417,7 @@ int tox_del_groupchat(Tox *tox, int groupnumber);
417 * return length of name if success 417 * return length of name if success
418 * return -1 if failure 418 * return -1 if failure
419 */ 419 */
420int tox_group_peername(Tox *tox, int groupnumber, int peernumber, uint8_t *name); 420int tox_group_peername(const Tox *tox, int groupnumber, int peernumber, uint8_t *name);
421 421
422/* invite friendnumber to groupnumber 422/* invite friendnumber to groupnumber
423 * return 0 on success 423 * return 0 on success
@@ -430,24 +430,24 @@ int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber);
430 * returns group number on success 430 * returns group number on success
431 * returns -1 on failure. 431 * returns -1 on failure.
432 */ 432 */
433int tox_join_groupchat(Tox *tox, int32_t friendnumber, uint8_t *friend_group_public_key); 433int tox_join_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *friend_group_public_key);
434 434
435/* send a group message 435/* send a group message
436 * return 0 on success 436 * return 0 on success
437 * return -1 on failure 437 * return -1 on failure
438 */ 438 */
439int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t length); 439int tox_group_message_send(Tox *tox, int groupnumber, const uint8_t *message, uint32_t length);
440 440
441/* send a group action 441/* send a group action
442 * return 0 on success 442 * return 0 on success
443 * return -1 on failure 443 * return -1 on failure
444 */ 444 */
445int tox_group_action_send(Tox *tox, int groupnumber, uint8_t *action, uint32_t length); 445int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint32_t length);
446 446
447/* Return the number of peers in the group chat on success. 447/* Return the number of peers in the group chat on success.
448 * return -1 on failure 448 * return -1 on failure
449 */ 449 */
450int tox_group_number_peers(Tox *tox, int groupnumber); 450int tox_group_number_peers(const Tox *tox, int groupnumber);
451 451
452/* List all the peers in the group chat. 452/* List all the peers in the group chat.
453 * 453 *
@@ -459,20 +459,20 @@ int tox_group_number_peers(Tox *tox, int groupnumber);
459 * 459 *
460 * return -1 on failure. 460 * return -1 on failure.
461 */ 461 */
462int tox_group_get_names(Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[], 462int tox_group_get_names(const Tox *tox, int groupnumber, uint8_t names[][TOX_MAX_NAME_LENGTH], uint16_t lengths[],
463 uint16_t length); 463 uint16_t length);
464 464
465/* Return the number of chats in the instance m. 465/* Return the number of chats in the instance m.
466 * You should use this to determine how much memory to allocate 466 * You should use this to determine how much memory to allocate
467 * for copy_chatlist. */ 467 * for copy_chatlist. */
468uint32_t tox_count_chatlist(Tox *tox); 468uint32_t tox_count_chatlist(const Tox *tox);
469 469
470/* Copy a list of valid chat IDs into the array out_list. 470/* Copy a list of valid chat IDs into the array out_list.
471 * If out_list is NULL, returns 0. 471 * If out_list is NULL, returns 0.
472 * Otherwise, returns the number of elements copied. 472 * Otherwise, returns the number of elements copied.
473 * If the array was too small, the contents 473 * If the array was too small, the contents
474 * of out_list will be truncated to list_size. */ 474 * of out_list will be truncated to list_size. */
475uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size); 475uint32_t tox_get_chatlist(const Tox *tox, int *out_list, uint32_t list_size);
476 476
477 477
478/****************FILE SENDING FUNCTIONS*****************/ 478/****************FILE SENDING FUNCTIONS*****************/
@@ -551,7 +551,7 @@ void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t,
551 * return file number on success 551 * return file number on success
552 * return -1 on failure 552 * return -1 on failure
553 */ 553 */
554int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length); 554int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, const uint8_t *filename, uint16_t filename_length);
555 555
556/* Send a file control request. 556/* Send a file control request.
557 * 557 *
@@ -562,21 +562,21 @@ int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8
562 * return -1 on failure 562 * return -1 on failure
563 */ 563 */
564int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, 564int 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); 565 const uint8_t *data, uint16_t length);
566 566
567/* Send file data. 567/* Send file data.
568 * 568 *
569 * return 0 on success 569 * return 0 on success
570 * return -1 on failure 570 * return -1 on failure
571 */ 571 */
572int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); 572int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, const uint8_t *data, uint16_t length);
573 573
574/* Returns the recommended/maximum size of the filedata you send with tox_file_send_data() 574/* Returns the recommended/maximum size of the filedata you send with tox_file_send_data()
575 * 575 *
576 * return size on success 576 * return size on success
577 * return -1 on failure (currently will never return -1) 577 * return -1 on failure (currently will never return -1)
578 */ 578 */
579int tox_file_data_size(Tox *tox, int32_t friendnumber); 579int tox_file_data_size(const Tox *tox, int32_t friendnumber);
580 580
581/* Give the number of bytes left to be sent/received. 581/* Give the number of bytes left to be sent/received.
582 * 582 *
@@ -585,7 +585,7 @@ int tox_file_data_size(Tox *tox, int32_t friendnumber);
585 * return number of bytes remaining to be sent/received on success 585 * return number of bytes remaining to be sent/received on success
586 * return 0 on failure 586 * return 0 on failure
587 */ 587 */
588uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); 588uint64_t tox_file_data_remaining(const Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive);
589 589
590/***************END OF FILE SENDING FUNCTIONS******************/ 590/***************END OF FILE SENDING FUNCTIONS******************/
591 591
@@ -606,12 +606,12 @@ uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenum
606 * returns 0 otherwise 606 * returns 0 otherwise
607 */ 607 */
608int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled, 608int tox_bootstrap_from_address(Tox *tox, const char *address, uint8_t ipv6enabled,
609 uint16_t port, uint8_t *public_key); 609 uint16_t port, const uint8_t *public_key);
610 610
611/* return 0 if we are not connected to the DHT. 611/* return 0 if we are not connected to the DHT.
612 * return 1 if we are. 612 * return 1 if we are.
613 */ 613 */
614int tox_isconnected(Tox *tox); 614int tox_isconnected(const Tox *tox);
615 615
616/* 616/*
617 * Run this function at startup. 617 * Run this function at startup.
@@ -645,17 +645,17 @@ void tox_do(Tox *tox);
645/* SAVING AND LOADING FUNCTIONS: */ 645/* SAVING AND LOADING FUNCTIONS: */
646 646
647/* return size of messenger data (for saving). */ 647/* return size of messenger data (for saving). */
648uint32_t tox_size(Tox *tox); 648uint32_t tox_size(const Tox *tox);
649 649
650/* Save the messenger in data (must be allocated memory of size Messenger_size()). */ 650/* Save the messenger in data (must be allocated memory of size Messenger_size()). */
651void tox_save(Tox *tox, uint8_t *data); 651void tox_save(const Tox *tox, uint8_t *data);
652 652
653/* Load the messenger from data of size length. 653/* Load the messenger from data of size length.
654 * 654 *
655 * returns 0 on success 655 * returns 0 on success
656 * returns -1 on failure 656 * returns -1 on failure
657 */ 657 */
658int tox_load(Tox *tox, uint8_t *data, uint32_t length); 658int tox_load(Tox *tox, const uint8_t *data, uint32_t length);
659 659
660#ifdef __cplusplus 660#ifdef __cplusplus
661} 661}