mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Some api changes.
This commit is contained in:
parent
388b1229b9
commit
554afe11d7
|
@ -1243,7 +1243,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
new_lines("[i] change username with /n");
|
||||
uint8_t name[TOX_MAX_NAME_LENGTH + 1];
|
||||
uint16_t namelen = tox_get_self_name(m, name, sizeof(name));
|
||||
uint16_t namelen = tox_get_self_name(m, name);
|
||||
name[namelen] = 0;
|
||||
|
||||
if (namelen > 0) {
|
||||
|
|
|
@ -34,16 +34,16 @@
|
|||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
|
||||
|
||||
static void set_friend_status(Messenger *m, int friendnumber, uint8_t status);
|
||||
static int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length);
|
||||
static void set_friend_status(Messenger *m, int32_t friendnumber, uint8_t status);
|
||||
static int write_cryptpacket_id(Messenger *m, int32_t friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length);
|
||||
|
||||
// friend_not_valid determines if the friendnumber passed is valid in the Messenger object
|
||||
static uint8_t friend_not_valid(Messenger *m, int friendnumber)
|
||||
static uint8_t friend_not_valid(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
return (unsigned int)friendnumber >= m->numfriends;
|
||||
}
|
||||
|
||||
static int add_online_friend(Messenger *m, int friendnumber)
|
||||
static int add_online_friend(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -74,7 +74,7 @@ static int add_online_friend(Messenger *m, int friendnumber)
|
|||
}
|
||||
|
||||
|
||||
static int remove_online_friend(Messenger *m, int friendnumber)
|
||||
static int remove_online_friend(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
uint32_t i;
|
||||
Online_Friend *temp;
|
||||
|
@ -132,7 +132,7 @@ int realloc_friendlist(Messenger *m, uint32_t num)
|
|||
/* return the friend id associated to that public key.
|
||||
* return -1 if no such friend.
|
||||
*/
|
||||
int getfriend_id(Messenger *m, uint8_t *client_id)
|
||||
int32_t getfriend_id(Messenger *m, uint8_t *client_id)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
@ -151,13 +151,13 @@ int getfriend_id(Messenger *m, uint8_t *client_id)
|
|||
* return 0 if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int getclient_id(Messenger *m, int friend_id, uint8_t *client_id)
|
||||
int getclient_id(Messenger *m, int32_t friendnumber, uint8_t *client_id)
|
||||
{
|
||||
if (friend_not_valid(m, friend_id))
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
||||
if (m->friendlist[friend_id].status > 0) {
|
||||
memcpy(client_id, m->friendlist[friend_id].client_id, CLIENT_ID_SIZE);
|
||||
if (m->friendlist[friendnumber].status > 0) {
|
||||
memcpy(client_id, m->friendlist[friendnumber].client_id, CLIENT_ID_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ void getaddress(Messenger *m, uint8_t *address)
|
|||
* (the nospam for that friend was set to the new one).
|
||||
* return FAERR_NOMEM if increasing the friend list size fails.
|
||||
*/
|
||||
int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length)
|
||||
int32_t m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (length >= (MAX_DATA_SIZE - crypto_box_PUBLICKEYBYTES
|
||||
- crypto_box_NONCEBYTES - crypto_box_BOXZEROBYTES
|
||||
|
@ -231,7 +231,7 @@ int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length)
|
|||
if (id_equal(client_id, m->net_crypto->self_public_key))
|
||||
return FAERR_OWNKEY;
|
||||
|
||||
int friend_id = getfriend_id(m, client_id);
|
||||
int32_t friend_id = getfriend_id(m, client_id);
|
||||
|
||||
if (friend_id != -1) {
|
||||
uint32_t nospam;
|
||||
|
@ -250,7 +250,7 @@ int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length)
|
|||
|
||||
memset(&(m->friendlist[m->numfriends]), 0, sizeof(Friend));
|
||||
|
||||
int onion_friendnum = onion_addfriend(m->onion_c, client_id);
|
||||
int32_t onion_friendnum = onion_addfriend(m->onion_c, client_id);
|
||||
|
||||
if (onion_friendnum == -1)
|
||||
return FAERR_UNKNOWN;
|
||||
|
@ -285,7 +285,7 @@ int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length)
|
|||
return FAERR_UNKNOWN;
|
||||
}
|
||||
|
||||
int m_addfriend_norequest(Messenger *m, uint8_t *client_id)
|
||||
int32_t m_addfriend_norequest(Messenger *m, uint8_t *client_id)
|
||||
{
|
||||
if (getfriend_id(m, client_id) != -1)
|
||||
return -1;
|
||||
|
@ -299,7 +299,7 @@ int m_addfriend_norequest(Messenger *m, uint8_t *client_id)
|
|||
|
||||
memset(&(m->friendlist[m->numfriends]), 0, sizeof(Friend));
|
||||
|
||||
int onion_friendnum = onion_addfriend(m->onion_c, client_id);
|
||||
int32_t onion_friendnum = onion_addfriend(m->onion_c, client_id);
|
||||
|
||||
if (onion_friendnum == -1)
|
||||
return FAERR_UNKNOWN;
|
||||
|
@ -335,7 +335,7 @@ int m_addfriend_norequest(Messenger *m, uint8_t *client_id)
|
|||
* return 0 if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int m_delfriend(Messenger *m, int friendnumber)
|
||||
int m_delfriend(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -362,7 +362,7 @@ int m_delfriend(Messenger *m, int friendnumber)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int m_get_friend_connectionstatus(Messenger *m, int friendnumber)
|
||||
int m_get_friend_connectionstatus(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -370,7 +370,7 @@ int m_get_friend_connectionstatus(Messenger *m, int friendnumber)
|
|||
return m->friendlist[friendnumber].status == FRIEND_ONLINE;
|
||||
}
|
||||
|
||||
int m_friend_exists(Messenger *m, int friendnumber)
|
||||
int m_friend_exists(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return 0;
|
||||
|
@ -383,7 +383,7 @@ int m_friend_exists(Messenger *m, int friendnumber)
|
|||
* return the message id if packet was successfully put into the send queue.
|
||||
* return 0 if it was not.
|
||||
*/
|
||||
uint32_t m_sendmessage(Messenger *m, int friendnumber, uint8_t *message, uint32_t length)
|
||||
uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, uint8_t *message, uint32_t length)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return 0;
|
||||
|
@ -400,7 +400,7 @@ uint32_t m_sendmessage(Messenger *m, int friendnumber, uint8_t *message, uint32_
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length)
|
||||
uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length)
|
||||
{
|
||||
if (length >= (MAX_DATA_SIZE - sizeof(theid)))
|
||||
return 0;
|
||||
|
@ -417,7 +417,7 @@ uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, ui
|
|||
* return the message id if packet was successfully put into the send queue.
|
||||
* return 0 if it was not.
|
||||
*/
|
||||
uint32_t m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length)
|
||||
uint32_t m_sendaction(Messenger *m, int32_t friendnumber, uint8_t *action, uint32_t length)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return 0;
|
||||
|
@ -434,7 +434,7 @@ uint32_t m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32_t m_sendaction_withid(Messenger *m, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length)
|
||||
uint32_t m_sendaction_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length)
|
||||
{
|
||||
if (length >= (MAX_DATA_SIZE - sizeof(theid)))
|
||||
return 0;
|
||||
|
@ -449,7 +449,7 @@ uint32_t m_sendaction_withid(Messenger *m, int friendnumber, uint32_t theid, uin
|
|||
/* Send a name packet to friendnumber.
|
||||
* length is the length with the NULL terminator.
|
||||
*/
|
||||
static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length)
|
||||
static int m_sendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length)
|
||||
{
|
||||
if (length > MAX_NAME_LENGTH || length == 0)
|
||||
return 0;
|
||||
|
@ -462,7 +462,7 @@ static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t le
|
|||
* return 0 if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length)
|
||||
int setfriendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -507,18 +507,15 @@ int setname(Messenger *m, uint8_t *name, uint16_t length)
|
|||
*
|
||||
* return the length of the name.
|
||||
*/
|
||||
uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen)
|
||||
uint16_t getself_name(Messenger *m, uint8_t *name)
|
||||
{
|
||||
uint16_t len;
|
||||
|
||||
if (name == NULL || nlen == 0) {
|
||||
if (name == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = MIN(nlen, m->name_length);
|
||||
memcpy(name, m->name, len);
|
||||
memcpy(name, m->name, m->name_length);
|
||||
|
||||
return len;
|
||||
return m->name_length;
|
||||
}
|
||||
|
||||
/* Get name of friendnumber and put it in name.
|
||||
|
@ -527,7 +524,7 @@ uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen)
|
|||
* return length of name if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int getname(Messenger *m, int friendnumber, uint8_t *name)
|
||||
int getname(Messenger *m, int32_t friendnumber, uint8_t *name)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -570,7 +567,7 @@ int m_set_userstatus(Messenger *m, USERSTATUS status)
|
|||
/* return the size of friendnumber's user status.
|
||||
* Guaranteed to be at most MAX_STATUSMESSAGE_LENGTH.
|
||||
*/
|
||||
int m_get_statusmessage_size(Messenger *m, int friendnumber)
|
||||
int m_get_statusmessage_size(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -581,7 +578,7 @@ int m_get_statusmessage_size(Messenger *m, int friendnumber)
|
|||
/* Copy the user status of friendnumber into buf, truncating if needed to maxlen
|
||||
* bytes, use m_get_statusmessage_size to find out how much you need to allocate.
|
||||
*/
|
||||
int m_copy_statusmessage(Messenger *m, int friendnumber, uint8_t *buf, uint32_t maxlen)
|
||||
int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint32_t maxlen)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -598,7 +595,7 @@ int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen)
|
|||
return MIN(maxlen, m->statusmessage_length);
|
||||
}
|
||||
|
||||
USERSTATUS m_get_userstatus(Messenger *m, int friendnumber)
|
||||
USERSTATUS m_get_userstatus(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return USERSTATUS_INVALID;
|
||||
|
@ -617,7 +614,7 @@ USERSTATUS m_get_self_userstatus(Messenger *m)
|
|||
return m->userstatus;
|
||||
}
|
||||
|
||||
int m_set_usertyping(Messenger *m, int friendnumber, uint8_t is_typing)
|
||||
int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing)
|
||||
{
|
||||
if (is_typing != 0 && is_typing != 1) {
|
||||
return -1;
|
||||
|
@ -632,7 +629,7 @@ int m_set_usertyping(Messenger *m, int friendnumber, uint8_t is_typing)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int m_get_istyping(Messenger *m, int friendnumber)
|
||||
int m_get_istyping(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -640,24 +637,24 @@ int m_get_istyping(Messenger *m, int friendnumber)
|
|||
return m->friendlist[friendnumber].is_typing;
|
||||
}
|
||||
|
||||
static int send_statusmessage(Messenger *m, int friendnumber, uint8_t *status, uint16_t length)
|
||||
static int send_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *status, uint16_t length)
|
||||
{
|
||||
return write_cryptpacket_id(m, friendnumber, PACKET_ID_STATUSMESSAGE, status, length);
|
||||
}
|
||||
|
||||
static int send_userstatus(Messenger *m, int friendnumber, USERSTATUS status)
|
||||
static int send_userstatus(Messenger *m, int32_t friendnumber, USERSTATUS status)
|
||||
{
|
||||
uint8_t stat = status;
|
||||
return write_cryptpacket_id(m, friendnumber, PACKET_ID_USERSTATUS, &stat, sizeof(stat));
|
||||
}
|
||||
|
||||
static int send_user_istyping(Messenger *m, int friendnumber, uint8_t is_typing)
|
||||
static int send_user_istyping(Messenger *m, int32_t friendnumber, uint8_t is_typing)
|
||||
{
|
||||
uint8_t typing = is_typing;
|
||||
return write_cryptpacket_id(m, friendnumber, PACKET_ID_TYPING, &typing, sizeof(typing));
|
||||
}
|
||||
|
||||
static int send_ping(Messenger *m, int friendnumber)
|
||||
static int send_ping(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
int ret = write_cryptpacket_id(m, friendnumber, PACKET_ID_PING, 0, 0);
|
||||
|
||||
|
@ -667,7 +664,7 @@ static int send_ping(Messenger *m, int friendnumber)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int set_friend_statusmessage(Messenger *m, int friendnumber, uint8_t *status, uint16_t length)
|
||||
static int set_friend_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *status, uint16_t length)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -680,18 +677,18 @@ static int set_friend_statusmessage(Messenger *m, int friendnumber, uint8_t *sta
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void set_friend_userstatus(Messenger *m, int friendnumber, USERSTATUS status)
|
||||
static void set_friend_userstatus(Messenger *m, int32_t friendnumber, USERSTATUS status)
|
||||
{
|
||||
m->friendlist[friendnumber].userstatus = status;
|
||||
}
|
||||
|
||||
static void set_friend_typing(Messenger *m, int friendnumber, uint8_t is_typing)
|
||||
static void set_friend_typing(Messenger *m, int32_t friendnumber, uint8_t is_typing)
|
||||
{
|
||||
m->friendlist[friendnumber].is_typing = is_typing;
|
||||
}
|
||||
|
||||
/* Sets whether we send read receipts for friendnumber. */
|
||||
void m_set_sends_receipts(Messenger *m, int friendnumber, int yesno)
|
||||
void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno)
|
||||
{
|
||||
if (yesno != 0 && yesno != 1)
|
||||
return;
|
||||
|
@ -710,66 +707,67 @@ void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t
|
|||
}
|
||||
|
||||
/* Set the function that will be executed when a message from a friend is received. */
|
||||
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *),
|
||||
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
m->friend_message = function;
|
||||
m->friend_message_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), void *userdata)
|
||||
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
m->friend_action = function;
|
||||
m->friend_action_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *),
|
||||
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
m->friend_namechange = function;
|
||||
m->friend_namechange_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *),
|
||||
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
m->friend_statusmessagechange = function;
|
||||
m->friend_statuschange_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int, USERSTATUS, void *), void *userdata)
|
||||
void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, USERSTATUS, void *), void *userdata)
|
||||
{
|
||||
m->friend_userstatuschange = function;
|
||||
m->friend_userstatuschange_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int, int, void *), void *userdata)
|
||||
void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int32_t, int, void *), void *userdata)
|
||||
{
|
||||
m->friend_typingchange = function;
|
||||
m->friend_typingchange_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, uint32_t, void *), void *userdata)
|
||||
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int32_t, uint32_t, void *), void *userdata)
|
||||
{
|
||||
m->read_receipt = function;
|
||||
m->read_receipt_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void *), void *userdata)
|
||||
void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata)
|
||||
{
|
||||
m->friend_connectionstatuschange = function;
|
||||
m->friend_connectionstatuschange_userdata = userdata;
|
||||
}
|
||||
|
||||
void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void *),
|
||||
void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
m->friend_connectionstatuschange_internal = function;
|
||||
m->friend_connectionstatuschange_internal_userdata = userdata;
|
||||
}
|
||||
|
||||
static void break_files(Messenger *m, int friendnumber);
|
||||
static void check_friend_connectionstatus(Messenger *m, int friendnumber, uint8_t status)
|
||||
static void break_files(Messenger *m, int32_t friendnumber);
|
||||
static void check_friend_connectionstatus(Messenger *m, int32_t friendnumber, uint8_t status)
|
||||
{
|
||||
if (status == NOFRIEND)
|
||||
return;
|
||||
|
@ -796,13 +794,13 @@ static void check_friend_connectionstatus(Messenger *m, int friendnumber, uint8_
|
|||
}
|
||||
}
|
||||
|
||||
void set_friend_status(Messenger *m, int friendnumber, uint8_t status)
|
||||
void set_friend_status(Messenger *m, int32_t friendnumber, uint8_t status)
|
||||
{
|
||||
check_friend_connectionstatus(m, friendnumber, status);
|
||||
m->friendlist[friendnumber].status = status;
|
||||
}
|
||||
|
||||
int write_cryptpacket_id(Messenger *m, int friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length)
|
||||
int write_cryptpacket_id(Messenger *m, int32_t friendnumber, uint8_t packet_id, uint8_t *data, uint32_t length)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return 0;
|
||||
|
@ -842,7 +840,7 @@ static uint8_t groupnumber_not_valid(Messenger *m, int groupnumber)
|
|||
/* returns valid ip port of connected friend on success
|
||||
* returns zeroed out IP_Port on failure
|
||||
*/
|
||||
IP_Port get_friend_ipport(Messenger *m, int friendnumber)
|
||||
IP_Port get_friend_ipport(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
IP_Port zero;
|
||||
memset(&zero, 0, sizeof(zero));
|
||||
|
@ -876,9 +874,9 @@ static int group_num(Messenger *m, uint8_t *group_public_key)
|
|||
|
||||
/* Set the callback for group invites.
|
||||
*
|
||||
* Function(Messenger *m, int friendnumber, uint8_t *group_public_key, void *userdata)
|
||||
* Function(Messenger *m, int32_t friendnumber, uint8_t *group_public_key, void *userdata)
|
||||
*/
|
||||
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, void *), void *userdata)
|
||||
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, void *), void *userdata)
|
||||
{
|
||||
m->group_invite = function;
|
||||
m->group_invite_userdata = userdata;
|
||||
|
@ -1081,7 +1079,7 @@ int m_group_peername(Messenger *m, int groupnumber, int peernumber, uint8_t *nam
|
|||
|
||||
/* Store the fact that we invited a specific friend.
|
||||
*/
|
||||
static void group_store_friendinvite(Messenger *m, int friendnumber, int groupnumber)
|
||||
static void group_store_friendinvite(Messenger *m, int32_t friendnumber, int groupnumber)
|
||||
{
|
||||
/* Add 1 to the groupchat number because 0 (default value in invited_groups) is a valid groupchat number */
|
||||
m->friendlist[friendnumber].invited_groups[m->friendlist[friendnumber].invited_groups_num % MAX_INVITED_GROUPS] =
|
||||
|
@ -1092,7 +1090,7 @@ static void group_store_friendinvite(Messenger *m, int friendnumber, int groupnu
|
|||
/* return 1 if that friend was invited to the group
|
||||
* return 0 if the friend was not or error.
|
||||
*/
|
||||
static uint8_t group_invited(Messenger *m, int friendnumber, int groupnumber)
|
||||
static uint8_t group_invited(Messenger *m, int32_t friendnumber, int groupnumber)
|
||||
{
|
||||
|
||||
uint32_t i;
|
||||
|
@ -1114,7 +1112,7 @@ static uint8_t group_invited(Messenger *m, int friendnumber, int groupnumber)
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int invite_friend(Messenger *m, int friendnumber, int groupnumber)
|
||||
int invite_friend(Messenger *m, int32_t friendnumber, int groupnumber)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber) || (unsigned int)groupnumber >= m->numchats)
|
||||
return -1;
|
||||
|
@ -1140,7 +1138,7 @@ int invite_friend(Messenger *m, int friendnumber, int groupnumber)
|
|||
* returns group number on success
|
||||
* returns -1 on failure.
|
||||
*/
|
||||
int join_groupchat(Messenger *m, int friendnumber, uint8_t *friend_group_public_key)
|
||||
int join_groupchat(Messenger *m, int32_t friendnumber, uint8_t *friend_group_public_key)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -1257,9 +1255,10 @@ static void do_allgroupchats(Messenger *m)
|
|||
|
||||
/* Set the callback for file send requests.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
||||
*/
|
||||
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint64_t, uint8_t *, uint16_t,
|
||||
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *,
|
||||
uint16_t,
|
||||
void *), void *userdata)
|
||||
{
|
||||
m->file_sendrequest = function;
|
||||
|
@ -1268,10 +1267,10 @@ void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int,
|
|||
|
||||
/* Set the callback for file control requests.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint8_t, uint8_t, uint8_t *,
|
||||
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
|
||||
uint16_t,
|
||||
void *), void *userdata)
|
||||
{
|
||||
|
@ -1281,10 +1280,11 @@ void callback_file_control(Messenger *m, void (*function)(Messenger *m, int, uin
|
|||
|
||||
/* Set the callback for file data.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
*
|
||||
*/
|
||||
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint8_t *, uint16_t length, void *),
|
||||
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length,
|
||||
void *),
|
||||
void *userdata)
|
||||
{
|
||||
m->file_filedata = function;
|
||||
|
@ -1298,7 +1298,7 @@ void callback_file_data(Messenger *m, void (*function)(Messenger *m, int, uint8_
|
|||
* return 1 on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
int file_sendrequest(Messenger *m, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename,
|
||||
int file_sendrequest(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename,
|
||||
uint16_t filename_length)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
|
@ -1321,7 +1321,7 @@ int file_sendrequest(Messenger *m, int friendnumber, uint8_t filenumber, uint64_
|
|||
* return file number on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length)
|
||||
int new_filesender(Messenger *m, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return -1;
|
||||
|
@ -1351,7 +1351,7 @@ int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *f
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
||||
int file_control(Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
||||
uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (length > MAX_DATA_SIZE - 3)
|
||||
|
@ -1439,7 +1439,7 @@ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t f
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length)
|
||||
int file_data(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length)
|
||||
{
|
||||
if (length > MAX_DATA_SIZE - 1)
|
||||
return -1;
|
||||
|
@ -1474,7 +1474,7 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data,
|
|||
* return number of bytes remaining to be sent/received on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t send_receive)
|
||||
uint64_t file_dataremaining(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
return 0;
|
||||
|
@ -1497,7 +1497,7 @@ uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber,
|
|||
/* Run this when the friend disconnects.
|
||||
* Sets all current file transfers to broken.
|
||||
*/
|
||||
static void break_files(Messenger *m, int friendnumber)
|
||||
static void break_files(Messenger *m, int32_t friendnumber)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
@ -1510,7 +1510,7 @@ static void break_files(Messenger *m, int friendnumber)
|
|||
}
|
||||
}
|
||||
|
||||
static int handle_filecontrol(Messenger *m, int friendnumber, uint8_t receive_send, uint8_t filenumber,
|
||||
static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
|
||||
uint8_t message_id, uint8_t *data,
|
||||
uint16_t length)
|
||||
{
|
||||
|
@ -1600,7 +1600,7 @@ static int handle_filecontrol(Messenger *m, int friendnumber, uint8_t receive_se
|
|||
*
|
||||
* Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
*/
|
||||
void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *),
|
||||
void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
m->msi_packet = function;
|
||||
|
@ -1612,12 +1612,12 @@ void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int, uin
|
|||
* return 1 on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
int m_msi_packet(Messenger *m, int friendnumber, uint8_t *data, uint16_t length)
|
||||
int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length)
|
||||
{
|
||||
return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length);
|
||||
}
|
||||
|
||||
static int friendnum_from_ip_port(Messenger *m, IP_Port ip_port)
|
||||
static int32_t friendnum_from_ip_port(Messenger *m, IP_Port ip_port)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
@ -1632,7 +1632,7 @@ static int friendnum_from_ip_port(Messenger *m, IP_Port ip_port)
|
|||
static int handle_custom_user_packet(void *object, IP_Port source, uint8_t *packet, uint32_t length)
|
||||
{
|
||||
Messenger *m = object;
|
||||
int friend_num = friendnum_from_ip_port(m, source);
|
||||
int32_t friend_num = friendnum_from_ip_port(m, source);
|
||||
|
||||
if (friend_num == -1)
|
||||
return 1;
|
||||
|
@ -1645,7 +1645,7 @@ static int handle_custom_user_packet(void *object, IP_Port source, uint8_t *pack
|
|||
}
|
||||
|
||||
|
||||
int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t byte, packet_handler_callback cb,
|
||||
int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, packet_handler_callback cb,
|
||||
void *object)
|
||||
{
|
||||
if (friend_not_valid(m, friendnumber))
|
||||
|
@ -1660,7 +1660,7 @@ int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t b
|
|||
return 0;
|
||||
}
|
||||
|
||||
int send_custom_user_packet(Messenger *m, int friendnumber, uint8_t *data, uint32_t length)
|
||||
int send_custom_user_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length)
|
||||
{
|
||||
IP_Port ip_port = get_friend_ipport(m, friendnumber);
|
||||
|
||||
|
@ -2573,7 +2573,7 @@ uint32_t get_num_online_friends(Messenger *m)
|
|||
* Otherwise, returns the number of elements copied.
|
||||
* If the array was too small, the contents
|
||||
* of out_list will be truncated to list_size. */
|
||||
uint32_t copy_friendlist(Messenger *m, int *out_list, uint32_t list_size)
|
||||
uint32_t copy_friendlist(Messenger *m, int32_t *out_list, uint32_t list_size)
|
||||
{
|
||||
if (!out_list)
|
||||
return 0;
|
||||
|
@ -2605,7 +2605,7 @@ uint32_t copy_friendlist(Messenger *m, int *out_list, uint32_t list_size)
|
|||
* retun 0 if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int get_friendlist(Messenger *m, int **out_list, uint32_t *out_list_length)
|
||||
int get_friendlist(Messenger *m, int32_t **out_list, uint32_t *out_list_length)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
@ -2616,7 +2616,7 @@ int get_friendlist(Messenger *m, int **out_list, uint32_t *out_list_length)
|
|||
return 0;
|
||||
}
|
||||
|
||||
*out_list = malloc(m->numfriends * sizeof(int));
|
||||
*out_list = malloc(m->numfriends * sizeof(int32_t));
|
||||
|
||||
if (*out_list == NULL) {
|
||||
return -1;
|
||||
|
|
|
@ -198,28 +198,28 @@ typedef struct Messenger {
|
|||
|
||||
uint64_t last_LANdiscovery;
|
||||
|
||||
void (*friend_message)(struct Messenger *m, int, uint8_t *, uint16_t, void *);
|
||||
void (*friend_message)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
|
||||
void *friend_message_userdata;
|
||||
void (*friend_action)(struct Messenger *m, int, uint8_t *, uint16_t, void *);
|
||||
void (*friend_action)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
|
||||
void *friend_action_userdata;
|
||||
void (*friend_namechange)(struct Messenger *m, int, uint8_t *, uint16_t, void *);
|
||||
void (*friend_namechange)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
|
||||
void *friend_namechange_userdata;
|
||||
void (*friend_statusmessagechange)(struct Messenger *m, int, uint8_t *, uint16_t, void *);
|
||||
void (*friend_statusmessagechange)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
|
||||
void *friend_statusmessagechange_userdata;
|
||||
void (*friend_userstatuschange)(struct Messenger *m, int, USERSTATUS, void *);
|
||||
void (*friend_userstatuschange)(struct Messenger *m, int32_t, USERSTATUS, void *);
|
||||
void *friend_userstatuschange_userdata;
|
||||
void (*friend_typingchange)(struct Messenger *m, int, int, void *);
|
||||
void (*friend_typingchange)(struct Messenger *m, int32_t, int, void *);
|
||||
void *friend_typingchange_userdata;
|
||||
void (*read_receipt)(struct Messenger *m, int, uint32_t, void *);
|
||||
void (*read_receipt)(struct Messenger *m, int32_t, uint32_t, void *);
|
||||
void *read_receipt_userdata;
|
||||
void (*friend_statuschange)(struct Messenger *m, int, uint8_t, void *);
|
||||
void (*friend_statuschange)(struct Messenger *m, int32_t, uint8_t, void *);
|
||||
void *friend_statuschange_userdata;
|
||||
void (*friend_connectionstatuschange)(struct Messenger *m, int, uint8_t, void *);
|
||||
void (*friend_connectionstatuschange)(struct Messenger *m, int32_t, uint8_t, void *);
|
||||
void *friend_connectionstatuschange_userdata;
|
||||
void (*friend_connectionstatuschange_internal)(struct Messenger *m, int, uint8_t, void *);
|
||||
void (*friend_connectionstatuschange_internal)(struct Messenger *m, int32_t, uint8_t, void *);
|
||||
void *friend_connectionstatuschange_internal_userdata;
|
||||
|
||||
void (*group_invite)(struct Messenger *m, int, uint8_t *, void *);
|
||||
void (*group_invite)(struct Messenger *m, int32_t, uint8_t *, void *);
|
||||
void *group_invite_userdata;
|
||||
void (*group_message)(struct Messenger *m, int, int, uint8_t *, uint16_t, void *);
|
||||
void *group_message_userdata;
|
||||
|
@ -228,14 +228,14 @@ typedef struct Messenger {
|
|||
void (*group_namelistchange)(struct Messenger *m, int, int, uint8_t, void *);
|
||||
void *group_namelistchange_userdata;
|
||||
|
||||
void (*file_sendrequest)(struct Messenger *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, void *);
|
||||
void (*file_sendrequest)(struct Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *, uint16_t, void *);
|
||||
void *file_sendrequest_userdata;
|
||||
void (*file_filecontrol)(struct Messenger *m, int, uint8_t, uint8_t, uint8_t, uint8_t *, uint16_t, void *);
|
||||
void (*file_filecontrol)(struct Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *, uint16_t, void *);
|
||||
void *file_filecontrol_userdata;
|
||||
void (*file_filedata)(struct Messenger *m, int, uint8_t, uint8_t *, uint16_t length, void *);
|
||||
void (*file_filedata)(struct Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length, void *);
|
||||
void *file_filedata_userdata;
|
||||
|
||||
void (*msi_packet)(struct Messenger *m, int, uint8_t *, uint16_t, void *);
|
||||
void (*msi_packet)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *);
|
||||
void *msi_packet_userdata;
|
||||
|
||||
} Messenger;
|
||||
|
@ -262,19 +262,19 @@ void getaddress(Messenger *m, uint8_t *address);
|
|||
* (the nospam for that friend was set to the new one).
|
||||
* return -8 if increasing the friend list size fails.
|
||||
*/
|
||||
int m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length);
|
||||
int32_t m_addfriend(Messenger *m, uint8_t *address, uint8_t *data, uint16_t length);
|
||||
|
||||
|
||||
/* Add a friend without sending a friendrequest.
|
||||
* return the friend number if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int m_addfriend_norequest(Messenger *m, uint8_t *client_id);
|
||||
int32_t m_addfriend_norequest(Messenger *m, uint8_t *client_id);
|
||||
|
||||
/* return the friend id associated to that client id.
|
||||
/* return the friend number associated to that client id.
|
||||
* return -1 if no such friend.
|
||||
*/
|
||||
int getfriend_id(Messenger *m, uint8_t *client_id);
|
||||
int32_t getfriend_id(Messenger *m, uint8_t *client_id);
|
||||
|
||||
/* Copies the public key associated to that friend id into client_id buffer.
|
||||
* Make sure that client_id is of size CLIENT_ID_SIZE.
|
||||
|
@ -282,10 +282,14 @@ int getfriend_id(Messenger *m, uint8_t *client_id);
|
|||
* return 0 if success
|
||||
* return -1 if failure
|
||||
*/
|
||||
int getclient_id(Messenger *m, int friend_id, uint8_t *client_id);
|
||||
int getclient_id(Messenger *m, int32_t friendnumber, uint8_t *client_id);
|
||||
|
||||
/* Remove a friend. */
|
||||
int m_delfriend(Messenger *m, int friendnumber);
|
||||
/* Remove a friend.
|
||||
*
|
||||
* return 0 if success
|
||||
* return -1 if failure
|
||||
*/
|
||||
int m_delfriend(Messenger *m, int32_t friendnumber);
|
||||
|
||||
/* Checks friend's connecting status.
|
||||
*
|
||||
|
@ -293,14 +297,14 @@ int m_delfriend(Messenger *m, int friendnumber);
|
|||
* return 0 if friend is not connected to us (Offline).
|
||||
* return -1 on failure.
|
||||
*/
|
||||
int m_get_friend_connectionstatus(Messenger *m, int friendnumber);
|
||||
int m_get_friend_connectionstatus(Messenger *m, int32_t friendnumber);
|
||||
|
||||
/* Checks if there exists a friend with given friendnumber.
|
||||
*
|
||||
* return 1 if friend exists.
|
||||
* return 0 if friend doesn't exist.
|
||||
*/
|
||||
int m_friend_exists(Messenger *m, int friendnumber);
|
||||
int m_friend_exists(Messenger *m, int32_t friendnumber);
|
||||
|
||||
/* Send a text chat message to an online friend.
|
||||
*
|
||||
|
@ -312,8 +316,8 @@ int m_friend_exists(Messenger *m, int friendnumber);
|
|||
* m_sendmessage_withid will send a message with the id of your choosing,
|
||||
* however we can generate an id for you by calling plain m_sendmessage.
|
||||
*/
|
||||
uint32_t m_sendmessage(Messenger *m, int friendnumber, uint8_t *message, uint32_t length);
|
||||
uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length);
|
||||
uint32_t m_sendmessage(Messenger *m, int32_t friendnumber, uint8_t *message, uint32_t length);
|
||||
uint32_t m_sendmessage_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length);
|
||||
|
||||
/* Send an action to an online friend.
|
||||
*
|
||||
|
@ -325,8 +329,8 @@ uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, ui
|
|||
* m_sendaction_withid will send an action message with the id of your choosing,
|
||||
* however we can generate an id for you by calling plain m_sendaction.
|
||||
*/
|
||||
uint32_t m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length);
|
||||
uint32_t m_sendaction_withid(Messenger *m, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length);
|
||||
uint32_t m_sendaction(Messenger *m, int32_t friendnumber, uint8_t *action, uint32_t length);
|
||||
uint32_t m_sendaction_withid(Messenger *m, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length);
|
||||
|
||||
/* Set the name and name_length of a friend.
|
||||
* 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
|
|||
* return 0 if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length);
|
||||
int setfriendname(Messenger *m, int32_t friendnumber, uint8_t *name, uint16_t length);
|
||||
|
||||
/* Set our nickname.
|
||||
* 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);
|
|||
/*
|
||||
* Get your nickname.
|
||||
* m - The messanger context to use.
|
||||
* name - Pointer to a string for the name.
|
||||
* nlen - The length of the string buffer.
|
||||
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH bytes.
|
||||
*
|
||||
* return length of the name.
|
||||
* return 0 on error.
|
||||
*/
|
||||
uint16_t getself_name(Messenger *m, uint8_t *name, uint16_t nlen);
|
||||
uint16_t getself_name(Messenger *m, uint8_t *name);
|
||||
|
||||
/* Get name of friendnumber and put it in name.
|
||||
* 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);
|
|||
* return length of name if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int getname(Messenger *m, int friendnumber, uint8_t *name);
|
||||
int getname(Messenger *m, int32_t friendnumber, uint8_t *name);
|
||||
|
||||
/* returns valid ip port of connected friend on success
|
||||
* returns zeroed out IP_Port on failure
|
||||
*/
|
||||
IP_Port get_friend_ipport(Messenger *m, int friendnumber);
|
||||
IP_Port get_friend_ipport(Messenger *m, int32_t friendnumber);
|
||||
|
||||
/* Set our user status.
|
||||
* You are responsible for freeing status after.
|
||||
|
@ -384,7 +387,7 @@ int m_set_userstatus(Messenger *m, USERSTATUS status);
|
|||
/* return the length of friendnumber's status message, including null.
|
||||
* Pass it into malloc.
|
||||
*/
|
||||
int m_get_statusmessage_size(Messenger *m, int friendnumber);
|
||||
int m_get_statusmessage_size(Messenger *m, int32_t friendnumber);
|
||||
|
||||
/* Copy friendnumber's status message into buf, truncating if size is over maxlen.
|
||||
* 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);
|
|||
* returns the length of the copied data on success
|
||||
* retruns -1 on failure.
|
||||
*/
|
||||
int m_copy_statusmessage(Messenger *m, int friendnumber, uint8_t *buf, uint32_t maxlen);
|
||||
int m_copy_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *buf, uint32_t maxlen);
|
||||
int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen);
|
||||
|
||||
/* return one of USERSTATUS values.
|
||||
|
@ -401,7 +404,7 @@ int m_copy_self_statusmessage(Messenger *m, uint8_t *buf, uint32_t maxlen);
|
|||
* As above, the self variant will return our own USERSTATUS.
|
||||
* If friendnumber is invalid, this shall return USERSTATUS_INVALID.
|
||||
*/
|
||||
USERSTATUS m_get_userstatus(Messenger *m, int friendnumber);
|
||||
USERSTATUS m_get_userstatus(Messenger *m, int32_t friendnumber);
|
||||
USERSTATUS m_get_self_userstatus(Messenger *m);
|
||||
|
||||
/* Set our typing status for a friend.
|
||||
|
@ -410,19 +413,19 @@ USERSTATUS m_get_self_userstatus(Messenger *m);
|
|||
* returns 0 on success.
|
||||
* returns -1 on failure.
|
||||
*/
|
||||
int m_set_usertyping(Messenger *m, int friendnumber, uint8_t is_typing);
|
||||
int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing);
|
||||
|
||||
/* Get the typing status of a friend.
|
||||
*
|
||||
* returns 0 if friend is not typing.
|
||||
* returns 1 if friend is typing.
|
||||
*/
|
||||
int m_get_istyping(Messenger *m, int friendnumber);
|
||||
int m_get_istyping(Messenger *m, int32_t friendnumber);
|
||||
|
||||
/* Sets whether we send read receipts for friendnumber.
|
||||
* This function is not lazy, and it will fail if yesno is not (0 or 1).
|
||||
*/
|
||||
void m_set_sends_receipts(Messenger *m, int friendnumber, int yesno);
|
||||
void m_set_sends_receipts(Messenger *m, int32_t friendnumber, int yesno);
|
||||
|
||||
/* Set the function that will be executed when a friend request is received.
|
||||
* 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);
|
|||
void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), void *userdata);
|
||||
|
||||
/* Set the function that will be executed when a message from a friend is received.
|
||||
* Function format is: function(int friendnumber, uint8_t * message, uint32_t length)
|
||||
* Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length)
|
||||
*/
|
||||
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *),
|
||||
void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/* Set the function that will be executed when an action from a friend is received.
|
||||
* Function format is: function(int friendnumber, uint8_t * action, uint32_t length)
|
||||
* Function format is: function(int32_t friendnumber, uint8_t * action, uint32_t length)
|
||||
*/
|
||||
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *), void *userdata);
|
||||
void m_callback_action(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/* Set the callback for name changes.
|
||||
* Function(int friendnumber, uint8_t *newname, uint16_t length)
|
||||
* Function(int32_t friendnumber, uint8_t *newname, uint16_t length)
|
||||
* You are not responsible for freeing newname.
|
||||
*/
|
||||
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *),
|
||||
void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/* Set the callback for status message changes.
|
||||
* Function(int friendnumber, uint8_t *newstatus, uint16_t length)
|
||||
* Function(int32_t friendnumber, uint8_t *newstatus, uint16_t length)
|
||||
*
|
||||
* You are not responsible for freeing newstatus
|
||||
*/
|
||||
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *),
|
||||
void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/* Set the callback for status type changes.
|
||||
* Function(int friendnumber, USERSTATUS kind)
|
||||
* Function(int32_t friendnumber, USERSTATUS kind)
|
||||
*/
|
||||
void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int, USERSTATUS, void *), void *userdata);
|
||||
void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, USERSTATUS, void *), void *userdata);
|
||||
|
||||
/* Set the callback for typing changes.
|
||||
* Function(int friendnumber, int is_typing)
|
||||
* Function(int32_t friendnumber, int is_typing)
|
||||
*/
|
||||
void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int, int, void *), void *userdata);
|
||||
void m_callback_typingchange(Messenger *m, void(*function)(Messenger *m, int32_t, int, void *), void *userdata);
|
||||
|
||||
/* Set the callback for read receipts.
|
||||
* Function(int friendnumber, uint32_t receipt)
|
||||
* Function(int32_t friendnumber, uint32_t receipt)
|
||||
*
|
||||
* If you are keeping a record of returns from m_sendmessage,
|
||||
* 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
|
|||
* Since core doesn't track ids for you, receipt may not correspond to any message.
|
||||
* In that case, you should discard it.
|
||||
*/
|
||||
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, uint32_t, void *), void *userdata);
|
||||
void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int32_t, uint32_t, void *), void *userdata);
|
||||
|
||||
/* Set the callback for connection status changes.
|
||||
* function(int friendnumber, uint8_t status)
|
||||
* function(int32_t friendnumber, uint8_t status)
|
||||
*
|
||||
* Status:
|
||||
* 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
|
|||
* being previously online" part.
|
||||
* It's assumed that when adding friends, their connection status is offline.
|
||||
*/
|
||||
void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void *), void *userdata);
|
||||
void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *),
|
||||
void *userdata);
|
||||
/* Same as previous but for internal A/V core usage only */
|
||||
void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void *),
|
||||
void m_callback_connectionstatus_internal_av(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/**********GROUP CHATS************/
|
||||
|
||||
/* Set the callback for group invites.
|
||||
*
|
||||
* Function(Messenger *m, int friendnumber, uint8_t *group_public_key, void *userdata)
|
||||
* Function(Messenger *m, int32_t friendnumber, uint8_t *group_public_key, void *userdata)
|
||||
*/
|
||||
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, void *), void *userdata);
|
||||
void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, void *), void *userdata);
|
||||
|
||||
/* Set the callback for group messages.
|
||||
*
|
||||
|
@ -548,14 +553,14 @@ int m_group_peername(Messenger *m, int groupnumber, int peernumber, uint8_t *nam
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int invite_friend(Messenger *m, int friendnumber, int groupnumber);
|
||||
int invite_friend(Messenger *m, int32_t friendnumber, int groupnumber);
|
||||
|
||||
/* Join a group (you need to have been invited first.)
|
||||
*
|
||||
* returns group number on success
|
||||
* returns -1 on failure.
|
||||
*/
|
||||
int join_groupchat(Messenger *m, int friendnumber, uint8_t *friend_group_public_key);
|
||||
int join_groupchat(Messenger *m, int32_t friendnumber, uint8_t *friend_group_public_key);
|
||||
|
||||
/* send a group message
|
||||
* return 0 on success
|
||||
|
@ -589,25 +594,27 @@ int group_names(Messenger *m, int groupnumber, uint8_t names[][MAX_NICK_BYTES],
|
|||
|
||||
/* Set the callback for file send requests.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
||||
*/
|
||||
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint64_t, uint8_t *, uint16_t,
|
||||
void callback_file_sendrequest(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint64_t, uint8_t *,
|
||||
uint16_t,
|
||||
void *), void *userdata);
|
||||
|
||||
/* Set the callback for file control requests.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint8_t, uint8_t, uint8_t *,
|
||||
void callback_file_control(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
|
||||
uint16_t, void *), void *userdata);
|
||||
|
||||
/* Set the callback for file data.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
*
|
||||
*/
|
||||
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int, uint8_t, uint8_t *, uint16_t length, void *),
|
||||
void callback_file_data(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, uint8_t *, uint16_t length,
|
||||
void *),
|
||||
void *userdata);
|
||||
|
||||
/* Send a file send request.
|
||||
|
@ -615,7 +622,7 @@ void callback_file_data(Messenger *m, void (*function)(Messenger *m, int, uint8_
|
|||
* return 1 on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
int file_sendrequest(Messenger *m, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename,
|
||||
int file_sendrequest(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename,
|
||||
uint16_t filename_length);
|
||||
|
||||
/* Send a file send request.
|
||||
|
@ -623,7 +630,7 @@ int file_sendrequest(Messenger *m, int friendnumber, uint8_t filenumber, uint64_
|
|||
* return file number on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int new_filesender(Messenger *m, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length);
|
||||
int new_filesender(Messenger *m, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length);
|
||||
|
||||
/* Send a file control request.
|
||||
* 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
|
|||
* return 1 on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
||||
int file_control(Messenger *m, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
||||
uint8_t *data, uint16_t length);
|
||||
|
||||
/* Send file data.
|
||||
|
@ -639,7 +646,7 @@ int file_control(Messenger *m, int friendnumber, uint8_t send_receive, uint8_t f
|
|||
* return 1 on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
|
||||
int file_data(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
|
||||
|
||||
/* Give the number of bytes left to be sent/received.
|
||||
*
|
||||
|
@ -648,15 +655,15 @@ int file_data(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t *data,
|
|||
* return number of bytes remaining to be sent/received on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
uint64_t file_dataremaining(Messenger *m, int friendnumber, uint8_t filenumber, uint8_t send_receive);
|
||||
uint64_t file_dataremaining(Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive);
|
||||
|
||||
/*************** A/V related ******************/
|
||||
|
||||
/* Set the callback for msi packets.
|
||||
*
|
||||
* Function(Messenger *m, int friendnumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
* Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
*/
|
||||
void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void *),
|
||||
void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/* Send an msi packet.
|
||||
|
@ -664,7 +671,7 @@ void m_callback_msi_packet(Messenger *m, void (*function)(Messenger *m, int, uin
|
|||
* return 1 on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
int m_msi_packet(Messenger *m, int friendnumber, uint8_t *data, uint16_t length);
|
||||
int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length);
|
||||
|
||||
/**********************************************/
|
||||
|
||||
|
@ -673,7 +680,7 @@ int m_msi_packet(Messenger *m, int friendnumber, uint8_t *data, uint16_t length)
|
|||
* return -1 on failure.
|
||||
* return 0 on success.
|
||||
*/
|
||||
int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t byte, packet_handler_callback cb,
|
||||
int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, packet_handler_callback cb,
|
||||
void *object);
|
||||
|
||||
/* High level function to send custom user packets.
|
||||
|
@ -681,7 +688,7 @@ int custom_user_packet_registerhandler(Messenger *m, int friendnumber, uint8_t b
|
|||
* return -1 on failure.
|
||||
* return number of bytes sent on success.
|
||||
*/
|
||||
int send_custom_user_packet(Messenger *m, int friendnumber, uint8_t *data, uint32_t length);
|
||||
int send_custom_user_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length);
|
||||
|
||||
/**********************************************/
|
||||
/* Run this at startup.
|
||||
|
@ -747,7 +754,7 @@ uint32_t get_num_online_friends(Messenger *m);
|
|||
* Otherwise, returns the number of elements copied.
|
||||
* If the array was too small, the contents
|
||||
* of out_list will be truncated to list_size. */
|
||||
uint32_t copy_friendlist(Messenger *m, int *out_list, uint32_t list_size);
|
||||
uint32_t copy_friendlist(Messenger *m, int32_t *out_list, uint32_t list_size);
|
||||
|
||||
/* Allocate and return a list of valid friend id's. List must be freed by the
|
||||
* caller.
|
||||
|
|
115
toxcore/tox.c
115
toxcore/tox.c
|
@ -60,7 +60,7 @@ void tox_get_address(Tox *tox, uint8_t *address)
|
|||
* (the nospam for that friend was set to the new one).
|
||||
* return FAERR_NOMEM if increasing the friend list size fails.
|
||||
*/
|
||||
int tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length)
|
||||
int32_t tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_addfriend(m, address, data, length);
|
||||
|
@ -71,16 +71,16 @@ int tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length)
|
|||
* return the friend number if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int tox_add_friend_norequest(Tox *tox, uint8_t *client_id)
|
||||
int32_t tox_add_friend_norequest(Tox *tox, uint8_t *client_id)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_addfriend_norequest(m, client_id);
|
||||
}
|
||||
|
||||
/* return the friend id associated to that client id.
|
||||
/* return the friend number associated to that client id.
|
||||
* return -1 if no such friend.
|
||||
*/
|
||||
int tox_get_friend_id(Tox *tox, uint8_t *client_id)
|
||||
int32_t tox_get_friend_number(Tox *tox, uint8_t *client_id)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return getfriend_id(m, client_id);
|
||||
|
@ -92,14 +92,14 @@ int tox_get_friend_id(Tox *tox, uint8_t *client_id)
|
|||
* return 0 if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int tox_get_client_id(Tox *tox, int friend_id, uint8_t *client_id)
|
||||
int tox_get_client_id(Tox *tox, int32_t friendnumber, uint8_t *client_id)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return getclient_id(m, friend_id, client_id);
|
||||
return getclient_id(m, friendnumber, client_id);
|
||||
}
|
||||
|
||||
/* Remove a friend. */
|
||||
int tox_del_friend(Tox *tox, int friendnumber)
|
||||
int tox_del_friend(Tox *tox, int32_t friendnumber)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_delfriend(m, friendnumber);
|
||||
|
@ -111,7 +111,7 @@ int tox_del_friend(Tox *tox, int friendnumber)
|
|||
* return 0 if friend is not connected to us (Offline).
|
||||
* return -1 on failure.
|
||||
*/
|
||||
int tox_get_friend_connection_status(Tox *tox, int friendnumber)
|
||||
int tox_get_friend_connection_status(Tox *tox, int32_t friendnumber)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_get_friend_connectionstatus(m, friendnumber);
|
||||
|
@ -122,7 +122,7 @@ int tox_get_friend_connection_status(Tox *tox, int friendnumber)
|
|||
* return 1 if friend exists.
|
||||
* return 0 if friend doesn't exist.
|
||||
*/
|
||||
int tox_friend_exists(Tox *tox, int friendnumber)
|
||||
int tox_friend_exists(Tox *tox, int32_t friendnumber)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_friend_exists(m, friendnumber);
|
||||
|
@ -137,13 +137,13 @@ int tox_friend_exists(Tox *tox, int friendnumber)
|
|||
* m_sendmessage_withid will send a message with the id of your choosing,
|
||||
* however we can generate an id for you by calling plain m_sendmessage.
|
||||
*/
|
||||
uint32_t tox_send_message(Tox *tox, int friendnumber, uint8_t *message, uint32_t length)
|
||||
uint32_t tox_send_message(Tox *tox, int32_t friendnumber, uint8_t *message, uint32_t length)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_sendmessage(m, friendnumber, message, length);
|
||||
}
|
||||
|
||||
uint32_t tox_send_message_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length)
|
||||
uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_sendmessage_withid(m, friendnumber, theid, message, length);
|
||||
|
@ -159,13 +159,13 @@ uint32_t tox_send_message_withid(Tox *tox, int friendnumber, uint32_t theid, uin
|
|||
* m_sendaction_withid will send an action message with the id of your choosing,
|
||||
* however we can generate an id for you by calling plain m_sendaction.
|
||||
*/
|
||||
uint32_t tox_send_action(Tox *tox, int friendnumber, uint8_t *action, uint32_t length)
|
||||
uint32_t tox_send_action(Tox *tox, int32_t friendnumber, uint8_t *action, uint32_t length)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_sendaction(m, friendnumber, action, length);
|
||||
}
|
||||
|
||||
uint32_t tox_send_action_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length)
|
||||
uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_sendaction_withid(m, friendnumber, theid, action, length);
|
||||
|
@ -187,16 +187,15 @@ int tox_set_name(Tox *tox, uint8_t *name, uint16_t length)
|
|||
|
||||
/* Get your nickname.
|
||||
* m - The messanger context to use.
|
||||
* name - Pointer to a string for the name.
|
||||
* nlen - The length of the string buffer.
|
||||
* name - Pointer to a string for the name. (must be at least MAX_NAME_LENGTH)
|
||||
*
|
||||
* return length of the name.
|
||||
* return 0 on error.
|
||||
*/
|
||||
uint16_t tox_get_self_name(Tox *tox, uint8_t *name, uint16_t nlen)
|
||||
uint16_t tox_get_self_name(Tox *tox, uint8_t *name)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return getself_name(m, name, nlen);
|
||||
return getself_name(m, name);
|
||||
}
|
||||
|
||||
/* Get name of friendnumber and put it in name.
|
||||
|
@ -205,7 +204,7 @@ uint16_t tox_get_self_name(Tox *tox, uint8_t *name, uint16_t nlen)
|
|||
* return length of name (with the NULL terminator) if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int tox_get_name(Tox *tox, int friendnumber, uint8_t *name)
|
||||
int tox_get_name(Tox *tox, int32_t friendnumber, uint8_t *name)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return getname(m, friendnumber, name);
|
||||
|
@ -225,13 +224,13 @@ int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length)
|
|||
int tox_set_user_status(Tox *tox, TOX_USERSTATUS status)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_set_userstatus(m, (USERSTATUS)status);
|
||||
return m_set_userstatus(m, status);
|
||||
}
|
||||
|
||||
/* return the length of friendnumber's status message, including null.
|
||||
* Pass it into malloc.
|
||||
*/
|
||||
int tox_get_status_message_size(Tox *tox, int friendnumber)
|
||||
int tox_get_status_message_size(Tox *tox, int32_t friendnumber)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_get_statusmessage_size(m, friendnumber);
|
||||
|
@ -241,7 +240,7 @@ int tox_get_status_message_size(Tox *tox, int friendnumber)
|
|||
* Get the size you need to allocate from m_get_statusmessage_size.
|
||||
* The self variant will copy our own status message.
|
||||
*/
|
||||
int tox_get_status_message(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen)
|
||||
int tox_get_status_message(Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_copy_statusmessage(m, friendnumber, buf, maxlen);
|
||||
|
@ -258,7 +257,7 @@ int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen)
|
|||
* As above, the self variant will return our own USERSTATUS.
|
||||
* If friendnumber is invalid, this shall return USERSTATUS_INVALID.
|
||||
*/
|
||||
TOX_USERSTATUS tox_get_user_status(Tox *tox, int friendnumber)
|
||||
TOX_USERSTATUS tox_get_user_status(Tox *tox, int32_t friendnumber)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return (TOX_USERSTATUS)m_get_userstatus(m, friendnumber);
|
||||
|
@ -276,7 +275,7 @@ TOX_USERSTATUS tox_get_self_user_status(Tox *tox)
|
|||
* returns 0 on success.
|
||||
* returns -1 on failure.
|
||||
*/
|
||||
int tox_set_user_is_typing(Tox *tox, int friendnumber, uint8_t is_typing)
|
||||
int tox_set_user_is_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_set_usertyping(m, friendnumber, is_typing);
|
||||
|
@ -287,7 +286,7 @@ int tox_set_user_is_typing(Tox *tox, int friendnumber, uint8_t is_typing)
|
|||
* returns 0 if friend is not typing.
|
||||
* returns 1 if friend is typing.
|
||||
*/
|
||||
int tox_get_is_typing(Tox *tox, int friendnumber)
|
||||
int tox_get_is_typing(Tox *tox, int32_t friendnumber)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return m_get_istyping(m, friendnumber);
|
||||
|
@ -297,7 +296,7 @@ int tox_get_is_typing(Tox *tox, int friendnumber)
|
|||
/* Sets whether we send read receipts for friendnumber.
|
||||
* This function is not lazy, and it will fail if yesno is not (0 or 1).
|
||||
*/
|
||||
void tox_set_sends_receipts(Tox *tox, int friendnumber, int yesno)
|
||||
void tox_set_sends_receipts(Tox *tox, int32_t friendnumber, int yesno)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
m_set_sends_receipts(m, friendnumber, yesno);
|
||||
|
@ -324,7 +323,7 @@ uint32_t tox_get_num_online_friends(Tox *tox)
|
|||
* Otherwise, returns the number of elements copied.
|
||||
* If the array was too small, the contents
|
||||
* of out_list will be truncated to list_size. */
|
||||
uint32_t tox_get_friendlist(Tox *tox, int *out_list, uint32_t list_size)
|
||||
uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return copy_friendlist(m, out_list, list_size);
|
||||
|
@ -341,9 +340,9 @@ void tox_callback_friend_request(Tox *tox, void (*function)(uint8_t *, uint8_t *
|
|||
|
||||
|
||||
/* Set the function that will be executed when a message from a friend is received.
|
||||
* Function format is: function(int friendnumber, uint8_t * message, uint32_t length)
|
||||
* Function format is: function(int32_t friendnumber, uint8_t * message, uint32_t length)
|
||||
*/
|
||||
void tox_callback_friend_message(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *),
|
||||
void tox_callback_friend_message(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
|
@ -351,9 +350,9 @@ void tox_callback_friend_message(Tox *tox, void (*function)(Messenger *tox, int,
|
|||
}
|
||||
|
||||
/* Set the function that will be executed when an action from a friend is received.
|
||||
* function format is: function(int friendnumber, uint8_t * action, uint32_t length)
|
||||
* function format is: function(int32_t friendnumber, uint8_t * action, uint32_t length)
|
||||
*/
|
||||
void tox_callback_friend_action(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *),
|
||||
void tox_callback_friend_action(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
|
@ -361,10 +360,10 @@ void tox_callback_friend_action(Tox *tox, void (*function)(Messenger *tox, int,
|
|||
}
|
||||
|
||||
/* Set the callback for name changes.
|
||||
* function(int friendnumber, uint8_t *newname, uint16_t length)
|
||||
* function(int32_t friendnumber, uint8_t *newname, uint16_t length)
|
||||
* You are not responsible for freeing newname.
|
||||
*/
|
||||
void tox_callback_name_change(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *),
|
||||
void tox_callback_name_change(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
|
@ -372,10 +371,10 @@ void tox_callback_name_change(Tox *tox, void (*function)(Messenger *tox, int, ui
|
|||
}
|
||||
|
||||
/* Set the callback for status message changes.
|
||||
* function(int friendnumber, uint8_t *newstatus, uint16_t length)
|
||||
* function(int32_t friendnumber, uint8_t *newstatus, uint16_t length)
|
||||
* You are not responsible for freeing newstatus.
|
||||
*/
|
||||
void tox_callback_status_message(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *),
|
||||
void tox_callback_status_message(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
|
@ -383,25 +382,26 @@ void tox_callback_status_message(Tox *tox, void (*function)(Messenger *tox, int,
|
|||
}
|
||||
|
||||
/* Set the callback for status type changes.
|
||||
* function(int friendnumber, USERSTATUS kind)
|
||||
* function(int32_t friendnumber, USERSTATUS kind)
|
||||
*/
|
||||
void tox_callback_user_status(Tox *tox, void (*function)(Messenger *tox, int, TOX_USERSTATUS, void *), void *userdata)
|
||||
void tox_callback_user_status(Tox *tox, void (*function)(Messenger *tox, int32_t, TOX_USERSTATUS, void *),
|
||||
void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
m_callback_userstatus(m, function, userdata);
|
||||
}
|
||||
|
||||
/* Set the callback for typing changes.
|
||||
* function (int friendnumber, int is_typing)
|
||||
* function (int32_t friendnumber, int is_typing)
|
||||
*/
|
||||
void tox_callback_typing_change(Tox *tox, void (*function)(Messenger *tox, int, int, void *), void *userdata)
|
||||
void tox_callback_typing_change(Tox *tox, void (*function)(Messenger *tox, int32_t, int, void *), void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
m_callback_typingchange(m, function, userdata);
|
||||
}
|
||||
|
||||
/* Set the callback for read receipts.
|
||||
* function(int friendnumber, uint32_t receipt)
|
||||
* function(int32_t friendnumber, uint32_t receipt)
|
||||
*
|
||||
* If you are keeping a record of returns from m_sendmessage;
|
||||
* receipt might be one of those values, meaning the message
|
||||
|
@ -409,14 +409,14 @@ void tox_callback_typing_change(Tox *tox, void (*function)(Messenger *tox, int,
|
|||
* Since core doesn't track ids for you, receipt may not correspond to any message.
|
||||
* in that case, you should discard it.
|
||||
*/
|
||||
void tox_callback_read_receipt(Tox *tox, void (*function)(Messenger *tox, int, uint32_t, void *), void *userdata)
|
||||
void tox_callback_read_receipt(Tox *tox, void (*function)(Messenger *tox, int32_t, uint32_t, void *), void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
m_callback_read_receipt(m, function, userdata);
|
||||
}
|
||||
|
||||
/* Set the callback for connection status changes.
|
||||
* function(int friendnumber, uint8_t status)
|
||||
* function(int32_t friendnumber, uint8_t status)
|
||||
*
|
||||
* Status:
|
||||
* 0 -- friend went offline after being previously online
|
||||
|
@ -426,7 +426,8 @@ void tox_callback_read_receipt(Tox *tox, void (*function)(Messenger *tox, int, u
|
|||
* being previously online" part. It's assumed that when adding friends,
|
||||
* their connection status is offline.
|
||||
*/
|
||||
void tox_callback_connection_status(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, void *), void *userdata)
|
||||
void tox_callback_connection_status(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, void *),
|
||||
void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
m_callback_connectionstatus(m, function, userdata);
|
||||
|
@ -436,9 +437,9 @@ void tox_callback_connection_status(Tox *tox, void (*function)(Messenger *tox, i
|
|||
|
||||
/* Set the callback for group invites.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t *group_public_key, void *userdata)
|
||||
*/
|
||||
void tox_callback_group_invite(Tox *tox, void (*function)(Messenger *tox, int, uint8_t *, void *), void *userdata)
|
||||
void tox_callback_group_invite(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t *, void *), void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
m_callback_group_invite(m, function, userdata);
|
||||
|
@ -513,7 +514,7 @@ int tox_group_peername(Tox *tox, int groupnumber, int peernumber, uint8_t *name)
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int tox_invite_friend(Tox *tox, int friendnumber, int groupnumber)
|
||||
int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return invite_friend(m, friendnumber, groupnumber);
|
||||
|
@ -523,7 +524,7 @@ int tox_invite_friend(Tox *tox, int friendnumber, int groupnumber)
|
|||
* returns group number on success
|
||||
* returns -1 on failure.
|
||||
*/
|
||||
int tox_join_groupchat(Tox *tox, int friendnumber, uint8_t *friend_group_public_key)
|
||||
int tox_join_groupchat(Tox *tox, int32_t friendnumber, uint8_t *friend_group_public_key)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return join_groupchat(m, friendnumber, friend_group_public_key);
|
||||
|
@ -598,9 +599,9 @@ uint32_t tox_get_chatlist(Tox *tox, int *out_list, uint32_t list_size)
|
|||
|
||||
/* Set the callback for file send requests.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
||||
*/
|
||||
void tox_callback_file_send_request(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, uint64_t, uint8_t *,
|
||||
void tox_callback_file_send_request(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, uint64_t, uint8_t *,
|
||||
uint16_t,
|
||||
void *), void *userdata)
|
||||
{
|
||||
|
@ -609,10 +610,10 @@ void tox_callback_file_send_request(Tox *tox, void (*function)(Messenger *tox, i
|
|||
}
|
||||
/* Set the callback for file control requests.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
void tox_callback_file_control(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, uint8_t, uint8_t, uint8_t *,
|
||||
void tox_callback_file_control(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
|
||||
uint16_t, void *), void *userdata)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
|
@ -620,10 +621,10 @@ void tox_callback_file_control(Tox *tox, void (*function)(Messenger *tox, int, u
|
|||
}
|
||||
/* Set the callback for file data.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
*
|
||||
*/
|
||||
void tox_callback_file_data(Tox *tox, void (*function)(Messenger *tox, int, uint8_t, uint8_t *, uint16_t length,
|
||||
void tox_callback_file_data(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, uint8_t *, uint16_t length,
|
||||
void *),
|
||||
void *userdata)
|
||||
|
||||
|
@ -636,7 +637,7 @@ void tox_callback_file_data(Tox *tox, void (*function)(Messenger *tox, int, uint
|
|||
* return file number on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int tox_new_file_sender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length)
|
||||
int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return new_filesender(m, friendnumber, filesize, filename, filename_length);
|
||||
|
@ -647,7 +648,7 @@ int tox_new_file_sender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int tox_file_send_control(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
||||
int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
||||
uint8_t *data, uint16_t length)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
|
@ -658,7 +659,7 @@ int tox_file_send_control(Tox *tox, int friendnumber, uint8_t send_receive, uint
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int tox_file_send_data(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length)
|
||||
int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return file_data(m, friendnumber, filenumber, data, length);
|
||||
|
@ -669,7 +670,7 @@ int tox_file_send_data(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *
|
|||
* return size on success
|
||||
* return -1 on failure (currently will never return -1)
|
||||
*/
|
||||
int tox_file_data_size(Tox *tox, int friendnumber)
|
||||
int tox_file_data_size(Tox *tox, int32_t friendnumber)
|
||||
{
|
||||
return MAX_DATA_SIZE - crypto_box_MACBYTES - 3;
|
||||
}
|
||||
|
@ -681,7 +682,7 @@ int tox_file_data_size(Tox *tox, int friendnumber)
|
|||
* return number of bytes remaining to be sent/received on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
uint64_t tox_file_data_remaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive)
|
||||
uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive)
|
||||
{
|
||||
Messenger *m = tox;
|
||||
return file_dataremaining(m, friendnumber, filenumber, send_receive);
|
||||
|
|
197
toxcore/tox.h
197
toxcore/tox.h
|
@ -36,8 +36,6 @@
|
|||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/* sa_family_t is the sockaddr_in / sockaddr_in6 family field */
|
||||
typedef short sa_family_t;
|
||||
|
||||
#ifndef true
|
||||
#define true 1
|
||||
|
@ -58,7 +56,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#define TOX_MAX_NAME_LENGTH 128
|
||||
#define TOX_MAX_STATUSMESSAGE_LENGTH 128
|
||||
#define TOX_MAX_STATUSMESSAGE_LENGTH 1007
|
||||
#define TOX_CLIENT_ID_SIZE 32
|
||||
|
||||
#define TOX_FRIEND_ADDRESS_SIZE (TOX_CLIENT_ID_SIZE + sizeof(uint32_t) + sizeof(uint16_t))
|
||||
|
@ -67,37 +65,8 @@ extern "C" {
|
|||
#define TOX_PORTRANGE_TO 33545
|
||||
#define TOX_PORT_DEFAULT TOX_PORTRANGE_FROM
|
||||
|
||||
typedef union {
|
||||
uint8_t c[4];
|
||||
uint16_t s[2];
|
||||
uint32_t i;
|
||||
} tox_IP4;
|
||||
|
||||
typedef union {
|
||||
uint8_t uint8[16];
|
||||
uint16_t uint16[8];
|
||||
uint32_t uint32[4];
|
||||
struct in6_addr in6_addr;
|
||||
} tox_IP6;
|
||||
|
||||
typedef struct {
|
||||
sa_family_t family;
|
||||
union {
|
||||
tox_IP4 ip4;
|
||||
tox_IP6 ip6;
|
||||
};
|
||||
} tox_IP;
|
||||
|
||||
/* will replace IP_Port as soon as the complete infrastructure is in place
|
||||
* removed the unused union and padding also */
|
||||
typedef struct {
|
||||
tox_IP ip;
|
||||
uint16_t port;
|
||||
} tox_IP_Port;
|
||||
|
||||
#define TOX_ENABLE_IPV6_DEFAULT 1
|
||||
|
||||
|
||||
/* Errors for m_addfriend
|
||||
* FAERR - Friend Add Error
|
||||
*/
|
||||
|
@ -132,6 +101,8 @@ typedef struct Tox Tox;
|
|||
*
|
||||
* The length when passing those strings to the core includes that NULL character.
|
||||
*
|
||||
* The length of all strings returned by the core include the NULL character.
|
||||
*
|
||||
* If you send non NULL terminated strings Tox will force NULL terminates them when it receives them.
|
||||
*/
|
||||
|
||||
|
@ -156,28 +127,32 @@ void tox_get_address(Tox *tox, uint8_t *address);
|
|||
* (the nospam for that friend was set to the new one).
|
||||
* return TOX_FAERR_NOMEM if increasing the friend list size fails.
|
||||
*/
|
||||
int tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length);
|
||||
int32_t tox_add_friend(Tox *tox, uint8_t *address, uint8_t *data, uint16_t length);
|
||||
|
||||
|
||||
/* Add a friend without sending a friendrequest.
|
||||
* return the friend number if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int tox_add_friend_norequest(Tox *tox, uint8_t *client_id);
|
||||
int32_t tox_add_friend_norequest(Tox *tox, uint8_t *client_id);
|
||||
|
||||
/* return the friend id associated to that client id.
|
||||
/* return the friend number associated to that client id.
|
||||
return -1 if no such friend */
|
||||
int tox_get_friend_id(Tox *tox, uint8_t *client_id);
|
||||
int32_t tox_get_friend_number(Tox *tox, uint8_t *client_id);
|
||||
|
||||
/* Copies the public key associated to that friend id into client_id buffer.
|
||||
* Make sure that client_id is of size CLIENT_ID_SIZE.
|
||||
* return 0 if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int tox_get_client_id(Tox *tox, int friend_id, uint8_t *client_id);
|
||||
int tox_get_client_id(Tox *tox, int32_t friendnumber, uint8_t *client_id);
|
||||
|
||||
/* Remove a friend. */
|
||||
int tox_del_friend(Tox *tox, int friendnumber);
|
||||
/* Remove a friend.
|
||||
*
|
||||
* return 0 if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int tox_del_friend(Tox *tox, int32_t friendnumber);
|
||||
|
||||
/* Checks friend's connecting status.
|
||||
*
|
||||
|
@ -185,14 +160,14 @@ int tox_del_friend(Tox *tox, int friendnumber);
|
|||
* return 0 if friend is not connected to us (Offline).
|
||||
* return -1 on failure.
|
||||
*/
|
||||
int tox_get_friend_connection_status(Tox *tox, int friendnumber);
|
||||
int tox_get_friend_connection_status(Tox *tox, int32_t friendnumber);
|
||||
|
||||
/* Checks if there exists a friend with given friendnumber.
|
||||
*
|
||||
* return 1 if friend exists.
|
||||
* return 0 if friend doesn't exist.
|
||||
*/
|
||||
int tox_friend_exists(Tox *tox, int friendnumber);
|
||||
int tox_friend_exists(Tox *tox, int32_t friendnumber);
|
||||
|
||||
/* Send a text chat message to an online friend.
|
||||
*
|
||||
|
@ -204,8 +179,8 @@ int tox_friend_exists(Tox *tox, int friendnumber);
|
|||
* m_sendmessage_withid will send a message with the id of your choosing,
|
||||
* however we can generate an id for you by calling plain m_sendmessage.
|
||||
*/
|
||||
uint32_t tox_send_message(Tox *tox, int friendnumber, uint8_t *message, uint32_t length);
|
||||
uint32_t tox_send_message_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *message, uint32_t length);
|
||||
uint32_t tox_send_message(Tox *tox, int32_t friendnumber, uint8_t *message, uint32_t length);
|
||||
uint32_t tox_send_message_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *message, uint32_t length);
|
||||
|
||||
/* Send an action to an online friend.
|
||||
*
|
||||
|
@ -217,8 +192,8 @@ uint32_t tox_send_message_withid(Tox *tox, int friendnumber, uint32_t theid, uin
|
|||
* m_sendaction_withid will send an action message with the id of your choosing,
|
||||
* however we can generate an id for you by calling plain m_sendaction.
|
||||
*/
|
||||
uint32_t tox_send_action(Tox *tox, int friendnumber, uint8_t *action, uint32_t length);
|
||||
uint32_t tox_send_action_withid(Tox *tox, int friendnumber, uint32_t theid, uint8_t *action, uint32_t length);
|
||||
uint32_t tox_send_action(Tox *tox, int32_t friendnumber, uint8_t *action, uint32_t length);
|
||||
uint32_t tox_send_action_withid(Tox *tox, int32_t friendnumber, uint32_t theid, uint8_t *action, uint32_t length);
|
||||
|
||||
/* Set our nickname.
|
||||
* name must be a string of maximum MAX_NAME_LENGTH length.
|
||||
|
@ -233,35 +208,36 @@ int tox_set_name(Tox *tox, uint8_t *name, uint16_t length);
|
|||
/*
|
||||
* Get your nickname.
|
||||
* m - The messanger context to use.
|
||||
* name - Pointer to a string for the name.
|
||||
* nlen - The length of the string buffer.
|
||||
* name - needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
||||
*
|
||||
* return length of name.
|
||||
* return 0 on error.
|
||||
*/
|
||||
uint16_t tox_get_self_name(Tox *tox, uint8_t *name, uint16_t nlen);
|
||||
uint16_t tox_get_self_name(Tox *tox, uint8_t *name);
|
||||
|
||||
/* Get name of friendnumber and put it in name.
|
||||
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
|
||||
*
|
||||
* return length of name (with the NULL terminator) if success.
|
||||
* return length of name if success.
|
||||
* return -1 if failure.
|
||||
*/
|
||||
int tox_get_name(Tox *tox, int friendnumber, uint8_t *name);
|
||||
int tox_get_name(Tox *tox, int32_t friendnumber, uint8_t *name);
|
||||
|
||||
/* Set our user status.
|
||||
* You are responsible for freeing status after.
|
||||
*
|
||||
* userstatus must be one of TOX_USERSTATUS values.
|
||||
*
|
||||
* returns 0 on success.
|
||||
* returns -1 on failure.
|
||||
*/
|
||||
int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length);
|
||||
int tox_set_user_status(Tox *tox, TOX_USERSTATUS status);
|
||||
int tox_set_user_status(Tox *tox, TOX_USERSTATUS userstatus);
|
||||
|
||||
/* return the length of friendnumber's status message, including null.
|
||||
/* return the length of friendnumber's status message.
|
||||
* Pass it into malloc
|
||||
*/
|
||||
int tox_get_status_message_size(Tox *tox, int friendnumber);
|
||||
int tox_get_status_message_size(Tox *tox, int32_t friendnumber);
|
||||
|
||||
/* Copy friendnumber's status message into buf, truncating if size is over maxlen.
|
||||
* Get the size you need to allocate from m_get_statusmessage_size.
|
||||
|
@ -270,15 +246,15 @@ int tox_get_status_message_size(Tox *tox, int friendnumber);
|
|||
* returns the length of the copied data on success
|
||||
* retruns -1 on failure.
|
||||
*/
|
||||
int tox_get_status_message(Tox *tox, int friendnumber, uint8_t *buf, uint32_t maxlen);
|
||||
int tox_get_status_message(Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen);
|
||||
int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen);
|
||||
|
||||
/* return one of USERSTATUS values.
|
||||
* Values unknown to your application should be represented as USERSTATUS_NONE.
|
||||
* As above, the self variant will return our own USERSTATUS.
|
||||
* If friendnumber is invalid, this shall return USERSTATUS_INVALID.
|
||||
/* return one of TOX_USERSTATUS values.
|
||||
* Values unknown to your application should be represented as TOX_USERSTATUS_NONE.
|
||||
* As above, the self variant will return our own TOX_USERSTATUS.
|
||||
* If friendnumber is invalid, this shall return TOX_USERSTATUS_INVALID.
|
||||
*/
|
||||
TOX_USERSTATUS tox_get_user_status(Tox *tox, int friendnumber);
|
||||
TOX_USERSTATUS tox_get_user_status(Tox *tox, int32_t friendnumber);
|
||||
TOX_USERSTATUS tox_get_self_user_status(Tox *tox);
|
||||
|
||||
/* Set our typing status for a friend.
|
||||
|
@ -287,19 +263,19 @@ TOX_USERSTATUS tox_get_self_user_status(Tox *tox);
|
|||
* returns 0 on success.
|
||||
* returns -1 on failure.
|
||||
*/
|
||||
int tox_set_user_is_typing(Tox *tox, int friendnumber, uint8_t is_typing);
|
||||
int tox_set_user_is_typing(Tox *tox, int32_t friendnumber, uint8_t is_typing);
|
||||
|
||||
/* Get the typing status of a friend.
|
||||
*
|
||||
* returns 0 if friend is not typing.
|
||||
* returns 1 if friend is typing.
|
||||
*/
|
||||
int tox_get_is_typing(Tox *tox, int friendnumber);
|
||||
int tox_get_is_typing(Tox *tox, int32_t friendnumber);
|
||||
|
||||
/* Sets whether we send read receipts for friendnumber.
|
||||
* This function is not lazy, and it will fail if yesno is not (0 or 1).
|
||||
*/
|
||||
void tox_set_sends_receipts(Tox *tox, int friendnumber, int yesno);
|
||||
void tox_set_sends_receipts(Tox *tox, int32_t friendnumber, int yesno);
|
||||
|
||||
/* Return the number of friends in the instance m.
|
||||
* You should use this to determine how much memory to allocate
|
||||
|
@ -314,7 +290,7 @@ uint32_t tox_get_num_online_friends(Tox *tox);
|
|||
* Otherwise, returns the number of elements copied.
|
||||
* If the array was too small, the contents
|
||||
* of out_list will be truncated to list_size. */
|
||||
uint32_t tox_get_friendlist(Tox *tox, int *out_list, uint32_t list_size);
|
||||
uint32_t tox_get_friendlist(Tox *tox, int32_t *out_list, uint32_t list_size);
|
||||
|
||||
/* Set the function that will be executed when a friend request is received.
|
||||
* Function format is function(uint8_t * public_key, uint8_t * data, uint16_t length)
|
||||
|
@ -328,36 +304,37 @@ void tox_callback_friend_message(Tox *tox, void (*function)(Tox *tox, int, uint8
|
|||
void *userdata);
|
||||
|
||||
/* Set the function that will be executed when an action from a friend is received.
|
||||
* Function format is: function(int friendnumber, uint8_t * action, uint32_t length)
|
||||
* Function format is: function(int32_t friendnumber, uint8_t * action, uint32_t length)
|
||||
*/
|
||||
void tox_callback_friend_action(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *), void *userdata);
|
||||
void tox_callback_friend_action(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/* Set the callback for name changes.
|
||||
* function(int friendnumber, uint8_t *newname, uint16_t length)
|
||||
* function(int32_t friendnumber, uint8_t *newname, uint16_t length)
|
||||
* You are not responsible for freeing newname
|
||||
*/
|
||||
void tox_callback_name_change(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *),
|
||||
void tox_callback_name_change(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/* Set the callback for status message changes.
|
||||
* function(int friendnumber, uint8_t *newstatus, uint16_t length)
|
||||
* function(int32_t friendnumber, uint8_t *newstatus, uint16_t length)
|
||||
* You are not responsible for freeing newstatus.
|
||||
*/
|
||||
void tox_callback_status_message(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, uint16_t, void *),
|
||||
void tox_callback_status_message(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, uint16_t, void *),
|
||||
void *userdata);
|
||||
|
||||
/* Set the callback for status type changes.
|
||||
* function(int friendnumber, USERSTATUS kind)
|
||||
* function(int32_t friendnumber, USERSTATUS kind)
|
||||
*/
|
||||
void tox_callback_user_status(Tox *tox, void (*function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata);
|
||||
void tox_callback_user_status(Tox *tox, void (*function)(Tox *tox, int32_t, TOX_USERSTATUS, void *), void *userdata);
|
||||
|
||||
/* Set the callback for typing changes.
|
||||
* function (int friendnumber, int is_typing)
|
||||
* function (int32_t friendnumber, int is_typing)
|
||||
*/
|
||||
void tox_callback_typing_change(Tox *tox, void (*function)(Tox *tox, int, int, void *), void *userdata);
|
||||
void tox_callback_typing_change(Tox *tox, void (*function)(Tox *tox, int32_t, int, void *), void *userdata);
|
||||
|
||||
/* Set the callback for read receipts.
|
||||
* function(int friendnumber, uint32_t receipt)
|
||||
* function(int32_t friendnumber, uint32_t receipt)
|
||||
*
|
||||
* If you are keeping a record of returns from m_sendmessage;
|
||||
* receipt might be one of those values, meaning the message
|
||||
|
@ -365,10 +342,10 @@ void tox_callback_typing_change(Tox *tox, void (*function)(Tox *tox, int, int, v
|
|||
* Since core doesn't track ids for you, receipt may not correspond to any message.
|
||||
* In that case, you should discard it.
|
||||
*/
|
||||
void tox_callback_read_receipt(Tox *tox, void (*function)(Tox *tox, int, uint32_t, void *), void *userdata);
|
||||
void tox_callback_read_receipt(Tox *tox, void (*function)(Tox *tox, int32_t, uint32_t, void *), void *userdata);
|
||||
|
||||
/* Set the callback for connection status changes.
|
||||
* function(int friendnumber, uint8_t status)
|
||||
* function(int32_t friendnumber, uint8_t status)
|
||||
*
|
||||
* Status:
|
||||
* 0 -- friend went offline after being previously online
|
||||
|
@ -378,7 +355,7 @@ void tox_callback_read_receipt(Tox *tox, void (*function)(Tox *tox, int, uint32_
|
|||
* being previously online" part. it's assumed that when adding friends,
|
||||
* their connection status is offline.
|
||||
*/
|
||||
void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int, uint8_t, void *), void *userdata);
|
||||
void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t, void *), void *userdata);
|
||||
|
||||
/**********GROUP CHAT FUNCTIONS: WARNING WILL BREAK A LOT************/
|
||||
|
||||
|
@ -386,7 +363,7 @@ void tox_callback_connection_status(Tox *tox, void (*function)(Tox *tox, int, ui
|
|||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata)
|
||||
*/
|
||||
void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int, uint8_t *, void *), void *userdata);
|
||||
void tox_callback_group_invite(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t *, void *), void *userdata);
|
||||
|
||||
/* Set the callback for group messages.
|
||||
*
|
||||
|
@ -442,14 +419,14 @@ int tox_group_peername(Tox *tox, int groupnumber, int peernumber, uint8_t *name)
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int tox_invite_friend(Tox *tox, int friendnumber, int groupnumber);
|
||||
int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber);
|
||||
|
||||
/* Join a group (you need to have been invited first.)
|
||||
*
|
||||
* returns group number on success
|
||||
* returns -1 on failure.
|
||||
*/
|
||||
int tox_join_groupchat(Tox *tox, int friendnumber, uint8_t *friend_group_public_key);
|
||||
int tox_join_groupchat(Tox *tox, int32_t friendnumber, uint8_t *friend_group_public_key);
|
||||
|
||||
/* send a group message
|
||||
* return 0 on success
|
||||
|
@ -528,9 +505,9 @@ enum {
|
|||
};
|
||||
/* Set the callback for file send requests.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata)
|
||||
*/
|
||||
void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint64_t, uint8_t *, uint16_t,
|
||||
void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint64_t, uint8_t *, uint16_t,
|
||||
void *), void *userdata);
|
||||
|
||||
/* Set the callback for file control requests.
|
||||
|
@ -538,18 +515,18 @@ void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int, uint
|
|||
* receive_send is 1 if the message is for a slot on which we are currently sending a file and 0 if the message
|
||||
* is for a slot on which we are receiving the file
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t receive_send, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata)
|
||||
* 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)
|
||||
*
|
||||
*/
|
||||
void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint8_t, uint8_t, uint8_t *,
|
||||
void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t, uint8_t, uint8_t *,
|
||||
uint16_t, void *), void *userdata);
|
||||
|
||||
/* Set the callback for file data.
|
||||
*
|
||||
* Function(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
* Function(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata)
|
||||
*
|
||||
*/
|
||||
void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint8_t *, uint16_t length, void *),
|
||||
void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int32_t, uint8_t, uint8_t *, uint16_t length, void *),
|
||||
void *userdata);
|
||||
|
||||
|
||||
|
@ -558,7 +535,7 @@ void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int, uint8_t, uin
|
|||
* return file number on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int tox_new_file_sender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length);
|
||||
int tox_new_file_sender(Tox *tox, int32_t friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length);
|
||||
|
||||
/* Send a file control request.
|
||||
*
|
||||
|
@ -568,7 +545,7 @@ int tox_new_file_sender(Tox *tox, int friendnumber, uint64_t filesize, uint8_t *
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int tox_file_send_control(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
||||
int tox_file_send_control(Tox *tox, int32_t friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id,
|
||||
uint8_t *data, uint16_t length);
|
||||
|
||||
/* Send file data.
|
||||
|
@ -576,14 +553,14 @@ int tox_file_send_control(Tox *tox, int friendnumber, uint8_t send_receive, uint
|
|||
* return 0 on success
|
||||
* return -1 on failure
|
||||
*/
|
||||
int tox_file_send_data(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
|
||||
int tox_file_send_data(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
|
||||
|
||||
/* Returns the recommended/maximum size of the filedata you send with tox_file_send_data()
|
||||
*
|
||||
* return size on success
|
||||
* return -1 on failure (currently will never return -1)
|
||||
*/
|
||||
int tox_file_data_size(Tox *tox, int friendnumber);
|
||||
int tox_file_data_size(Tox *tox, int32_t friendnumber);
|
||||
|
||||
/* Give the number of bytes left to be sent/received.
|
||||
*
|
||||
|
@ -592,19 +569,51 @@ int tox_file_data_size(Tox *tox, int friendnumber);
|
|||
* return number of bytes remaining to be sent/received on success
|
||||
* return 0 on failure
|
||||
*/
|
||||
uint64_t tox_file_data_remaining(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive);
|
||||
uint64_t tox_file_data_remaining(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive);
|
||||
|
||||
/***************END OF FILE SENDING FUNCTIONS******************/
|
||||
|
||||
/* WARNING: DEPRECATED, DO NOT USE. */
|
||||
typedef union {
|
||||
uint8_t c[4];
|
||||
uint16_t s[2];
|
||||
uint32_t i;
|
||||
} tox_IP4;
|
||||
|
||||
/*
|
||||
* Use these two functions to bootstrap the client.
|
||||
*/
|
||||
typedef union {
|
||||
uint8_t uint8[16];
|
||||
uint16_t uint16[8];
|
||||
uint32_t uint32[4];
|
||||
struct in6_addr in6_addr;
|
||||
} tox_IP6;
|
||||
|
||||
typedef struct {
|
||||
uint8_t family;
|
||||
/* Not used for anything right now. */
|
||||
uint8_t padding[3];
|
||||
union {
|
||||
tox_IP4 ip4;
|
||||
tox_IP6 ip6;
|
||||
};
|
||||
} tox_IP;
|
||||
|
||||
/* will replace IP_Port as soon as the complete infrastructure is in place
|
||||
* removed the unused union and padding also */
|
||||
typedef struct {
|
||||
tox_IP ip;
|
||||
uint16_t port;
|
||||
} tox_IP_Port;
|
||||
/* WARNING: DEPRECATED, DO NOT USE. */
|
||||
/* Sends a "get nodes" request to the given node with ip, port and public_key
|
||||
* to setup connections
|
||||
*/
|
||||
void tox_bootstrap_from_ip(Tox *tox, tox_IP_Port ip_port, uint8_t *public_key);
|
||||
|
||||
|
||||
/*
|
||||
* Use this function to bootstrap the client.
|
||||
*/
|
||||
|
||||
/* Resolves address into an IP address. If successful, sends a "get nodes"
|
||||
* request to the given node with ip, port (in network byte order, HINT: use htons())
|
||||
* and public_key to setup connections
|
||||
|
|
Loading…
Reference in New Issue
Block a user