summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/Messenger.h')
-rw-r--r--toxcore/Messenger.h163
1 files changed, 85 insertions, 78 deletions
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index e6851800..8474bbe7 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -198,28 +198,28 @@ typedef struct Messenger {
198 198
199 uint64_t last_LANdiscovery; 199 uint64_t last_LANdiscovery;
200 200
201 void (*friend_message)(struct Messenger *m, int, uint8_t *, uint16_t, void *); 201 void (*friend_message)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
202 void *friend_message_userdata; 202 void *friend_message_userdata;
203 void (*friend_action)(struct Messenger *m, int, uint8_t *, uint16_t, void *); 203 void (*friend_action)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
204 void *friend_action_userdata; 204 void *friend_action_userdata;
205 void (*friend_namechange)(struct Messenger *m, int, uint8_t *, uint16_t, void *); 205 void (*friend_namechange)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
206 void *friend_namechange_userdata; 206 void *friend_namechange_userdata;
207 void (*friend_statusmessagechange)(struct Messenger *m, int, uint8_t *, uint16_t, void *); 207 void (*friend_statusmessagechange)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
208 void *friend_statusmessagechange_userdata; 208 void *friend_statusmessagechange_userdata;
209 void (*friend_userstatuschange)(struct Messenger *m, int, USERSTATUS, void *); 209 void (*friend_userstatuschange)(struct Messenger *m, int32_t, USERSTATUS, void *);
210 void *friend_userstatuschange_userdata; 210 void *friend_userstatuschange_userdata;
211 void (*friend_typingchange)(struct Messenger *m, int, int, void *); 211 void (*friend_typingchange)(struct Messenger *m, int32_t, int, void *);
212 void *friend_typingchange_userdata; 212 void *friend_typingchange_userdata;
213 void (*read_receipt)(struct Messenger *m, int, uint32_t, void *); 213 void (*read_receipt)(struct Messenger *m, int32_t, uint32_t, void *);
214 void *read_receipt_userdata; 214 void *read_receipt_userdata;
215 void (*friend_statuschange)(struct Messenger *m, int, uint8_t, void *); 215 void (*friend_statuschange)(struct Messenger *m, int32_t, uint8_t, void *);
216 void *friend_statuschange_userdata; 216 void *friend_statuschange_userdata;
217 void (*friend_connectionstatuschange)(struct Messenger *m, int, uint8_t, void *); 217 void (*friend_connectionstatuschange)(struct Messenger *m, int32_t, uint8_t, void *);
218 void *friend_connectionstatuschange_userdata; 218 void *friend_connectionstatuschange_userdata;
219 void (*friend_connectionstatuschange_internal)(struct Messenger *m, int, uint8_t, void *); 219 void (*friend_connectionstatuschange_internal)(struct Messenger *m, int32_t, uint8_t, void *);
220 void *friend_connectionstatuschange_internal_userdata; 220 void *friend_connectionstatuschange_internal_userdata;
221 221
222 void (*group_invite)(struct Messenger *m, int, uint8_t *, void *); 222 void (*group_invite)(struct Messenger *m, int32_t, uint8_t *, void *);
223 void *group_invite_userdata; 223 void *group_invite_userdata;
224 void (*group_message)(struct Messenger *m, int, int, uint8_t *, uint16_t, void *); 224 void (*group_message)(struct Messenger *m, int, int, uint8_t *, uint16_t, void *);
225 void *group_message_userdata; 225 void *group_message_userdata;
@@ -228,14 +228,14 @@ typedef struct Messenger {
228 void (*group_namelistchange)(struct Messenger *m, int, int, uint8_t, void *); 228 void (*group_namelistchange)(struct Messenger *m, int, int, uint8_t, void *);
229 void *group_namelistchange_userdata; 229 void *group_namelistchange_userdata;
230 230
231 void (*file_sendrequest)(struct Messenger *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, void *); 231 void (*file_sendrequest)(struct Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *, uint16_t, void *);
232 void *file_sendrequest_userdata; 232 void *file_sendrequest_userdata;
233 void (*file_filecontrol)(struct Messenger *m, int, uint8_t, uint8_t, uint8_t, uint8_t *, uint16_t, void *); 233 void (*file_filecontrol)(struct Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *, uint16_t, void *);
234 void *file_filecontrol_userdata; 234 void *file_filecontrol_userdata;
235 void (*file_filedata)(struct Messenger *m, int, uint8_t, uint8_t *, uint16_t length, void *); 235 void (*file_filedata)(struct Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length, void *);
236 void *file_filedata_userdata; 236 void *file_filedata_userdata;
237 237
238 void (*msi_packet)(struct Messenger *m, int, uint8_t *, uint16_t, void *); 238 void (*msi_packet)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
239 void *msi_packet_userdata; 239 void *msi_packet_userdata;
240 240
241} Messenger; 241} Messenger;
@@ -262,19 +262,19 @@ void getaddress(Messenger *m, uint8_t *address);
262 * (the nospam for that friend was set to the new one). 262 * (the nospam for that friend was set to the new one).
263 * return -8 if increasing the friend list size fails. 263 * return -8 if increasing the friend list size fails.
264 */ 264 */
265int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length); 265int32_t m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length);
266 266
267 267
268/* Add a friend without sending a friendrequest. 268/* Add a friend without sending a friendrequest.
269 * return the friend number if success. 269 * return the friend number if success.
270 * return -1 if failure. 270 * return -1 if failure.
271 */ 271 */
272int m_addfriend_norequest(Messenger *m, uint8_t *client_id); 272int32_t m_addfriend_norequest(Messenger *m, uint8_t *client_id);
273 273
274/* return the friend id associated to that client id. 274/* return the friend number associated to that client id.
275 * return -1 if no such friend. 275 * return -1 if no such friend.
276 */ 276 */
277int getfriend_id(Messenger *m, uint8_t *client_id); 277int32_t getfriend_id(Messenger *m, uint8_t *client_id);
278 278
279/* Copies the public key associated to that friend id into client_id buffer. 279/* Copies the public key associated to that friend id into client_id buffer.
280 * Make sure that client_id is of size CLIENT_ID_SIZE. 280 * Make sure that client_id is of size CLIENT_ID_SIZE.
@@ -282,10 +282,14 @@ int getfriend_id(Messenger *m, uint8_t *client_id);
282 * return 0 if success 282 * return 0 if success
283 * return -1 if failure 283 * return -1 if failure
284 */ 284 */
285int getclient_id(Messenger *m, int friend_id, uint8_t *client_id); 285int getclient_id(Messenger *m, int32_t friendnumber, uint8_t *client_id);
286 286
287/* Remove a friend. */ 287/* Remove a friend.
288int m_delfriend(Messenger *m, int friendnumber); 288 *
289 * return 0 if success
290 * return -1 if failure
291 */
292int m_delfriend(Messenger *m, int32_t friendnumber);
289 293
290/* Checks friend's connecting status. 294/* Checks friend's connecting status.
291 * 295 *
@@ -293,14 +297,14 @@ int m_delfriend(Messenger *m, int friendnumber);
293 * return 0 if friend is not connected to us (Offline). 297 * return 0 if friend is not connected to us (Offline).
294 * return -1 on failure. 298 * return -1 on failure.
295 */ 299 */
296int m_get_friend_connectionstatus(Messenger *m, int friendnumber); 300int m_get_friend_connectionstatus(Messenger *m, int32_t friendnumber);
297 301
298/* Checks if there exists a friend with given friendnumber. 302/* Checks if there exists a friend with given friendnumber.
299 * 303 *
300 * return 1 if friend exists. 304 * return 1 if friend exists.
301 * return 0 if friend doesn't exist. 305 * return 0 if friend doesn't exist.
302 */ 306 */
303int m_friend_exists(Messenger *m, int friendnumber); 307int m_friend_exists(Messenger *m, int32_t friendnumber);
304 308
305/* Send a text chat message to an online friend. 309/* Send a text chat message to an online friend.
306 * 310 *
@@ -312,8 +316,8 @@ int m_friend_exists(Messenger *m, int friendnumber);
312 * m_sendmessage_withid will send a message with the id of your choosing, 316 * m_sendmessage_withid will send a message with the id of your choosing,
313 * however we can generate an id for you by calling plain m_sendmessage. 317 * however we can generate an id for you by calling plain m_sendmessage.
314 */ 318 */
315uint32_t m_sendmessage(Messenger *m, int friendnumber, uint8_t *message, uint32_t length); 319uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, uint8_t *message, uint32_t length);
316uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length); 320uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length);
317 321
318/* Send an action to an online friend. 322/* Send an action to an online friend.
319 * 323 *
@@ -325,8 +329,8 @@ uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, ui
325 * m_sendaction_withid will send an action message with the id of your choosing, 329 * m_sendaction_withid will send an action message with the id of your choosing,
326 * however we can generate an id for you by calling plain m_sendaction. 330 * however we can generate an id for you by calling plain m_sendaction.
327 */ 331 */
328uint32_t m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length); 332uint32_t m_sendaction(Messenger *m, int32_t friendnumber, uint8_t *action, uint32_t length);
329uint32_t m_sendaction_withid(Messenger *m, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length); 333uint32_t m_sendaction_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length);
330 334
331/* Set the name and name_length of a friend. 335/* Set the name and name_length of a friend.
332 * name must be a string of maximum MAX_NAME_LENGTH length. 336 * name must be a string of maximum MAX_NAME_LENGTH length.
@@ -336,7 +340,7 @@ uint32_t m_sendaction_withid(Messenger *m, int friendnumber, uint32_t theid, uin
336 * return 0 if success. 340 * return 0 if success.
337 * return -1 if failure. 341 * return -1 if failure.
338 */ 342 */
339int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length); 343int setfriendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length);
340 344
341/* Set our nickname. 345/* Set our nickname.
342 * name must be a string of maximum MAX_NAME_LENGTH length. 346 * name must be a string of maximum MAX_NAME_LENGTH length.
@@ -351,13 +355,12 @@ int setname(Messenger *m, uint8_t *name, uint16_t length);
351/* 355/*
352 * Get your nickname. 356 * Get your nickname.
353 * m - The messanger context to use. 357 * m - The messanger context to use.
354 * name - Pointer to a string for the name. 358 * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes.
355 * nlen - The length of the string buffer.
356 * 359 *
357 * return length of the name. 360 * return length of the name.
358 * return 0 on error. 361 * return 0 on error.
359 */ 362 */
360uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen); 363uint16_t getself_name(Messenger *m, uint8_t *name);
361 364
362/* Get name of friendnumber and put it in name. 365/* Get name of friendnumber and put it in name.
363 * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes. 366 * name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
@@ -365,12 +368,12 @@ uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen);
365 * return length of name if success. 368 * return length of name if success.
366 * return -1 if failure. 369 * return -1 if failure.
367 */ 370 */
368int getname(Messenger *m, int friendnumber, uint8_t *name); 371int getname(Messenger *m, int32_t friendnumber, uint8_t *name);
369 372
370/* returns valid ip port of connected friend on success 373/* returns valid ip port of connected friend on success
371 * returns zeroed out IP_Port on failure 374 * returns zeroed out IP_Port on failure
372 */ 375 */
373IP_Port get_friend_ipport(Messenger *m, int friendnumber); 376IP_Port get_friend_ipport(Messenger *m, int32_t friendnumber);
374 377
375/* Set our user status. 378/* Set our user status.
376 * You are responsible for freeing status after. 379 * You are responsible for freeing status after.
@@ -384,7 +387,7 @@ int m_set_userstatus(Messenger *m, USERSTATUS status);
384/* return the length of friendnumber's status message, including null. 387/* return the length of friendnumber's status message, including null.
385 * Pass it into malloc. 388 * Pass it into malloc.
386 */ 389 */
387int m_get_statusmessage_size(Messenger *m, int friendnumber); 390int m_get_statusmessage_size(Messenger *m, int32_t friendnumber);
388 391
389/* Copy friendnumber's status message into buf, truncating if size is over maxlen. 392/* Copy friendnumber's status message into buf, truncating if size is over maxlen.
390 * Get the size you need to allocate from m_get_statusmessage_size. 393 * Get the size you need to allocate from m_get_statusmessage_size.
@@ -393,7 +396,7 @@ int m_get_statusmessage_size(Messenger *m, int friendnumber);
393 * returns the length of the copied data on success 396 * returns the length of the copied data on success
394 * retruns -1 on failure. 397 * retruns -1 on failure.
395 */ 398 */
396int m_copy_statusmessage(Messenger *m, int friendnumber, uint8_t *buf, uint32_t maxlen); 399int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint32_t maxlen);
397int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen); 400int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen);
398 401
399/* return one of USERSTATUS values. 402/* return one of USERSTATUS values.
@@ -401,7 +404,7 @@ int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen);
401 * As above, the self variant will return our own USERSTATUS. 404 * As above, the self variant will return our own USERSTATUS.
402 * If friendnumber is invalid, this shall return USERSTATUS_INVALID. 405 * If friendnumber is invalid, this shall return USERSTATUS_INVALID.
403 */ 406 */
404USERSTATUS m_get_userstatus(Messenger *m, int friendnumber); 407USERSTATUS m_get_userstatus(Messenger *m, int32_t friendnumber);
405USERSTATUS m_get_self_userstatus(Messenger *m); 408USERSTATUS m_get_self_userstatus(Messenger *m);
406 409
407/* Set our typing status for a friend. 410/* Set our typing status for a friend.
@@ -410,19 +413,19 @@ USERSTATUS m_get_self_userstatus(Messenger *m);
410 * returns 0 on success. 413 * returns 0 on success.
411 * returns -1 on failure. 414 * returns -1 on failure.
412 */ 415 */
413int m_set_usertyping(Messenger *m, int friendnumber, uint8_t is_typing); 416int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing);
414 417
415/* Get the typing status of a friend. 418/* Get the typing status of a friend.
416 * 419 *
417 * returns 0 if friend is not typing. 420 * returns 0 if friend is not typing.
418 * returns 1 if friend is typing. 421 * returns 1 if friend is typing.
419 */ 422 */
420int m_get_istyping(Messenger *m, int friendnumber); 423int m_get_istyping(Messenger *m, int32_t friendnumber);
421 424
422/* Sets whether we send read receipts for friendnumber. 425/* Sets whether we send read receipts for friendnumber.
423 * This function is not lazy, and it will fail if yesno is not (0 or 1). 426 * This function is not lazy, and it will fail if yesno is not (0 or 1).
424 */ 427 */
425void m_set_sends_receipts(Messenger *m, int friendnumber, int yesno); 428void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno);
426 429
427/* Set the function that will be executed when a friend request is received. 430/* Set the function that will be executed when a friend request is received.
428 * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) 431 * Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length)
@@ -430,43 +433,44 @@ void m_set_sends_receipts(Messenger *m, int friendnumber, int yesno);
430void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata); 433void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata);
431 434
432/* Set the function that will be executed when a message from a friend is received. 435/* Set the function that will be executed when a message from a friend is received.
433 * Function format is: function(int friendnumber, uint8_t * message, uint32_t length) 436 * Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length)
434 */ 437 */
435void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), 438void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
436 void *userdata); 439 void *userdata);
437 440
438/* Set the function that will be executed when an action from a friend is received. 441/* Set the function that will be executed when an action from a friend is received.
439 * Function format is: function(int friendnumber, uint8_t * action, uint32_t length) 442 * Function format is: function(int32_t friendnumber, uint8_t * action, uint32_t length)
440 */ 443 */
441void m_callback_action(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), void *userdata); 444void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
445 void *userdata);
442 446
443/* Set the callback for name changes. 447/* Set the callback for name changes.
444 * Function(int friendnumber, uint8_t *newname, uint16_t length) 448 * Function(int32_t friendnumber, uint8_t *newname, uint16_t length)
445 * You are not responsible for freeing newname. 449 * You are not responsible for freeing newname.
446 */ 450 */
447void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), 451void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
448 void *userdata); 452 void *userdata);
449 453
450/* Set the callback for status message changes. 454/* Set the callback for status message changes.
451 * Function(int friendnumber, uint8_t *newstatus, uint16_t length) 455 * Function(int32_t friendnumber, uint8_t *newstatus, uint16_t length)
452 * 456 *
453 * You are not responsible for freeing newstatus 457 * You are not responsible for freeing newstatus
454 */ 458 */
455void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), 459void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
456 void *userdata); 460 void *userdata);
457 461
458/* Set the callback for status type changes. 462/* Set the callback for status type changes.
459 * Function(int friendnumber, USERSTATUS kind) 463 * Function(int32_t friendnumber, USERSTATUS kind)
460 */ 464 */
461void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int, USERSTATUS, void *), void *userdata); 465void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, USERSTATUS, void *), void *userdata);
462 466
463/* Set the callback for typing changes. 467/* Set the callback for typing changes.
464 * Function(int friendnumber, int is_typing) 468 * Function(int32_t friendnumber, int is_typing)
465 */ 469 */
466void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int, int, void *), void *userdata); 470void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int32_t, int, void *), void *userdata);
467 471
468/* Set the callback for read receipts. 472/* Set the callback for read receipts.
469 * Function(int friendnumber, uint32_t receipt) 473 * Function(int32_t friendnumber, uint32_t receipt)
470 * 474 *
471 * If you are keeping a record of returns from m_sendmessage, 475 * If you are keeping a record of returns from m_sendmessage,
472 * receipt might be one of those values, meaning the message 476 * receipt might be one of those values, meaning the message
@@ -474,10 +478,10 @@ void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int, in
474 * Since core doesn't track ids for you, receipt may not correspond to any message. 478 * Since core doesn't track ids for you, receipt may not correspond to any message.
475 * In that case, you should discard it. 479 * In that case, you should discard it.
476 */ 480 */
477void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, uint32_t, void *), void *userdata); 481void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int32_t, uint32_t, void *), void *userdata);
478 482
479/* Set the callback for connection status changes. 483/* Set the callback for connection status changes.
480 * function(int friendnumber, uint8_t status) 484 * function(int32_t friendnumber, uint8_t status)
481 * 485 *
482 * Status: 486 * Status:
483 * 0 -- friend went offline after being previously online. 487 * 0 -- friend went offline after being previously online.
@@ -487,18 +491,19 @@ void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, u
487 * being previously online" part. 491 * being previously online" part.
488 * It's assumed that when adding friends, their connection status is offline. 492 * It's assumed that when adding friends, their connection status is offline.
489 */ 493 */
490void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void *), void *userdata); 494void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *),
495 void *userdata);
491/* Same as previous but for internal A/V core usage only */ 496/* Same as previous but for internal A/V core usage only */
492void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void *), 497void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *),
493 void *userdata); 498 void *userdata);
494 499
495/**********GROUP CHATS************/ 500/**********GROUP CHATS************/
496 501
497/* Set the callback for group invites. 502/* Set the callback for group invites.
498 * 503 *
499 * Function(Messenger *m, int friendnumber, uint8_t *group_public_key, void *userdata) 504 * Function(Messenger *m, int32_t friendnumber, uint8_t *group_public_key, void *userdata)
500 */ 505 */
501void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, void *), void *userdata); 506void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, void *), void *userdata);
502 507
503/* Set the callback for group messages. 508/* Set the callback for group messages.
504 * 509 *
@@ -548,14 +553,14 @@ int m_group_peername(Messenger *m, int groupnumber, int peernumber, uint8_t *nam
548 * return 0 on success 553 * return 0 on success
549 * return -1 on failure 554 * return -1 on failure
550 */ 555 */
551int invite_friend(Messenger *m, int friendnumber, int groupnumber); 556int invite_friend(Messenger *m, int32_t friendnumber, int groupnumber);
552 557
553/* Join a group (you need to have been invited first.) 558/* Join a group (you need to have been invited first.)
554 * 559 *
555 * returns group number on success 560 * returns group number on success
556 * returns -1 on failure. 561 * returns -1 on failure.
557 */ 562 */
558int join_groupchat(Messenger *m, int friendnumber, uint8_t *friend_group_public_key); 563int join_groupchat(Messenger *m, int32_t friendnumber, uint8_t *friend_group_public_key);
559 564
560/* send a group message 565/* send a group message
561 * return 0 on success 566 * return 0 on success
@@ -589,25 +594,27 @@ int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES],
589 594
590/* Set the callback for file send requests. 595/* Set the callback for file send requests.
591 * 596 *
592 * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) 597 * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
593 */ 598 */
594void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, 599void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *,
600 uint16_t,
595 void *), void *userdata); 601 void *), void *userdata);
596 602
597/* Set the callback for file control requests. 603/* Set the callback for file control requests.
598 * 604 *
599 * Function(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata) 605 * Function(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
600 * 606 *
601 */ 607 */
602void callback_file_control(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint8_t, uint8_t, uint8_t *, 608void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
603 uint16_t, void *), void *userdata); 609 uint16_t, void *), void *userdata);
604 610
605/* Set the callback for file data. 611/* Set the callback for file data.
606 * 612 *
607 * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata) 613 * Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
608 * 614 *
609 */ 615 */
610void callback_file_data(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint8_t *, uint16_t length, void *), 616void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length,
617 void *),
611 void *userdata); 618 void *userdata);
612 619
613/* Send a file send request. 620/* Send a file send request.
@@ -615,7 +622,7 @@ void callback_file_data(Messenger *m, void (*function)(Messenger *m, int, uint8_
615 * return 1 on success 622 * return 1 on success
616 * return 0 on failure 623 * return 0 on failure
617 */ 624 */
618int file_sendrequest(Messenger *m, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, 625int file_sendrequest(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename,
619 uint16_t filename_length); 626 uint16_t filename_length);
620 627
621/* Send a file send request. 628/* Send a file send request.
@@ -623,7 +630,7 @@ int file_sendrequest(Messenger *m, int friendnumber, uint8_t filenumber, uint64_
623 * return file number on success 630 * return file number on success
624 * return -1 on failure 631 * return -1 on failure
625 */ 632 */
626int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length); 633int new_filesender(Messenger *m, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length);
627 634
628/* Send a file control request. 635/* Send a file control request.
629 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file. 636 * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file.
@@ -631,7 +638,7 @@ int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *f
631 * return 1 on success 638 * return 1 on success
632 * return 0 on failure 639 * return 0 on failure
633 */ 640 */
634int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, 641int file_control(Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
635 uint8_t *data, uint16_t length); 642 uint8_t *data, uint16_t length);
636 643
637/* Send file data. 644/* Send file data.
@@ -639,7 +646,7 @@ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t f
639 * return 1 on success 646 * return 1 on success
640 * return 0 on failure 647 * return 0 on failure
641 */ 648 */
642int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); 649int file_data(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
643 650
644/* Give the number of bytes left to be sent/received. 651/* Give the number of bytes left to be sent/received.
645 * 652 *
@@ -648,15 +655,15 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data,
648 * return number of bytes remaining to be sent/received on success 655 * return number of bytes remaining to be sent/received on success
649 * return 0 on failure 656 * return 0 on failure
650 */ 657 */
651uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t send_receive); 658uint64_t file_dataremaining(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive);
652 659
653/*************** A/V related ******************/ 660/*************** A/V related ******************/
654 661
655/* Set the callback for msi packets. 662/* Set the callback for msi packets.
656 * 663 *
657 * Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata) 664 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
658 */ 665 */
659void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), 666void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
660 void *userdata); 667 void *userdata);
661 668
662/* Send an msi packet. 669/* Send an msi packet.
@@ -664,7 +671,7 @@ void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int, uin
664 * return 1 on success 671 * return 1 on success
665 * return 0 on failure 672 * return 0 on failure
666 */ 673 */
667int m_msi_packet(Messenger *m, int friendnumber, uint8_t *data, uint16_t length); 674int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length);
668 675
669/**********************************************/ 676/**********************************************/
670 677
@@ -673,7 +680,7 @@ int m_msi_packet(Messenger *m, int friendnumber, uint8_t *data, uint16_t length)
673 * return -1 on failure. 680 * return -1 on failure.
674 * return 0 on success. 681 * return 0 on success.
675 */ 682 */
676int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t byte, packet_handler_callback cb, 683int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, packet_handler_callback cb,
677 void *object); 684 void *object);
678 685
679/* High level function to send custom user packets. 686/* High level function to send custom user packets.
@@ -681,7 +688,7 @@ int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t b
681 * return -1 on failure. 688 * return -1 on failure.
682 * return number of bytes sent on success. 689 * return number of bytes sent on success.
683 */ 690 */
684int send_custom_user_packet(Messenger *m, int friendnumber, uint8_t *data, uint32_t length); 691int send_custom_user_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length);
685 692
686/**********************************************/ 693/**********************************************/
687/* Run this at startup. 694/* Run this at startup.
@@ -747,7 +754,7 @@ uint32_t get_num_online_friends(Messenger *m);
747 * Otherwise, returns the number of elements copied. 754 * Otherwise, returns the number of elements copied.
748 * If the array was too small, the contents 755 * If the array was too small, the contents
749 * of out_list will be truncated to list_size. */ 756 * of out_list will be truncated to list_size. */
750uint32_t copy_friendlist(Messenger *m, int *out_list, uint32_t list_size); 757uint32_t copy_friendlist(Messenger *m, int32_t *out_list, uint32_t list_size);
751 758
752/* Allocate and return a list of valid friend id's. List must be freed by the 759/* Allocate and return a list of valid friend id's. List must be freed by the
753 * caller. 760 * caller.