diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index da326b88..81a347be 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -562,7 +562,7 @@ int m_set_statusmessage(Messenger *m, uint8_t *status, uint16_t length) return 0; } -int m_set_userstatus(Messenger *m, USERSTATUS status) +int m_set_userstatus(Messenger *m, uint8_t status) { if (status >= USERSTATUS_INVALID) { return -1; @@ -616,12 +616,12 @@ 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, int32_t friendnumber) +uint8_t m_get_userstatus(Messenger *m, int32_t friendnumber) { if (friend_not_valid(m, friendnumber)) return USERSTATUS_INVALID; - USERSTATUS status = m->friendlist[friendnumber].userstatus; + uint8_t status = m->friendlist[friendnumber].userstatus; if (status >= USERSTATUS_INVALID) { status = USERSTATUS_NONE; @@ -630,7 +630,7 @@ USERSTATUS m_get_userstatus(Messenger *m, int32_t friendnumber) return status; } -USERSTATUS m_get_self_userstatus(Messenger *m) +uint8_t m_get_self_userstatus(Messenger *m) { return m->userstatus; } @@ -663,10 +663,9 @@ static int send_statusmessage(Messenger *m, int32_t friendnumber, uint8_t *statu return write_cryptpacket_id(m, friendnumber, PACKET_ID_STATUSMESSAGE, status, length); } -static int send_userstatus(Messenger *m, int32_t friendnumber, USERSTATUS status) +static int send_userstatus(Messenger *m, int32_t friendnumber, uint8_t status) { - uint8_t stat = status; - return write_cryptpacket_id(m, friendnumber, PACKET_ID_USERSTATUS, &stat, sizeof(stat)); + return write_cryptpacket_id(m, friendnumber, PACKET_ID_USERSTATUS, &status, sizeof(status)); } static int send_user_istyping(Messenger *m, int32_t friendnumber, uint8_t is_typing) @@ -698,7 +697,7 @@ static int set_friend_statusmessage(Messenger *m, int32_t friendnumber, uint8_t return 0; } -static void set_friend_userstatus(Messenger *m, int32_t friendnumber, USERSTATUS status) +static void set_friend_userstatus(Messenger *m, int32_t friendnumber, uint8_t status) { m->friendlist[friendnumber].userstatus = status; } @@ -756,7 +755,7 @@ void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32 m->friend_statuschange_userdata = userdata; } -void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, USERSTATUS, void *), void *userdata) +void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata) { m->friend_userstatuschange = function; m->friend_userstatuschange_userdata = userdata; diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 88e5e19d..213f8586 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -206,7 +206,7 @@ typedef struct Messenger { void *friend_namechange_userdata; void (*friend_statusmessagechange)(struct Messenger *m, int32_t, uint8_t *, uint16_t, void *); void *friend_statusmessagechange_userdata; - void (*friend_userstatuschange)(struct Messenger *m, int32_t, USERSTATUS, void *); + void (*friend_userstatuschange)(struct Messenger *m, int32_t, uint8_t, void *); void *friend_userstatuschange_userdata; void (*friend_typingchange)(struct Messenger *m, int32_t, int, void *); void *friend_typingchange_userdata; @@ -388,7 +388,7 @@ IP_Port get_friend_ipport(Messenger *m, int32_t friendnumber); * returns -1 on failure. */ int m_set_statusmessage(Messenger *m, uint8_t *status, uint16_t length); -int m_set_userstatus(Messenger *m, USERSTATUS status); +int m_set_userstatus(Messenger *m, uint8_t status); /* return the length of friendnumber's status message, including null on success. * return -1 on failure. @@ -411,8 +411,8 @@ 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, int32_t friendnumber); -USERSTATUS m_get_self_userstatus(Messenger *m); +uint8_t m_get_userstatus(Messenger *m, int32_t friendnumber); +uint8_t m_get_self_userstatus(Messenger *m); /* Set our typing status for a friend. * You are responsible for turning it on or off. @@ -469,7 +469,7 @@ void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int32 /* Set the callback for status type changes. * Function(int32_t friendnumber, USERSTATUS kind) */ -void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, USERSTATUS, void *), void *userdata); +void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int32_t, uint8_t, void *), void *userdata); /* Set the callback for typing changes. * Function(int32_t friendnumber, int is_typing) diff --git a/toxcore/tox.c b/toxcore/tox.c index 0b430a90..d3e596ba 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -236,7 +236,7 @@ int tox_set_status_message(Tox *tox, uint8_t *status, uint16_t length) return m_set_statusmessage(m, status, length); } -int tox_set_user_status(Tox *tox, TOX_USERSTATUS status) +int tox_set_user_status(Tox *tox, uint8_t status) { Messenger *m = tox; return m_set_userstatus(m, status); @@ -278,16 +278,16 @@ 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, int32_t friendnumber) +uint8_t tox_get_user_status(Tox *tox, int32_t friendnumber) { Messenger *m = tox; - return (TOX_USERSTATUS)m_get_userstatus(m, friendnumber); + return m_get_userstatus(m, friendnumber); } -TOX_USERSTATUS tox_get_self_user_status(Tox *tox) +uint8_t tox_get_self_user_status(Tox *tox) { Messenger *m = tox; - return (TOX_USERSTATUS)m_get_self_userstatus(m); + return m_get_self_userstatus(m); } /* Set our typing status for a friend. @@ -405,7 +405,7 @@ void tox_callback_status_message(Tox *tox, void (*function)(Messenger *tox, int3 /* Set the callback for status type changes. * function(int32_t friendnumber, USERSTATUS kind) */ -void tox_callback_user_status(Tox *tox, void (*function)(Messenger *tox, int32_t, TOX_USERSTATUS, void *), +void tox_callback_user_status(Tox *tox, void (*function)(Messenger *tox, int32_t, uint8_t, void *), void *userdata) { Messenger *m = tox; diff --git a/toxcore/tox.h b/toxcore/tox.h index 8fb03af3..5b619cd0 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -236,7 +236,7 @@ int tox_get_self_name_size(Tox *tox); * 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 userstatus); +int tox_set_user_status(Tox *tox, uint8_t userstatus); /* returns the length of status message on success. * returns -1 on failure. @@ -259,8 +259,8 @@ int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen); * 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, int32_t friendnumber); -TOX_USERSTATUS tox_get_self_user_status(Tox *tox); +uint8_t tox_get_user_status(Tox *tox, int32_t friendnumber); +uint8_t tox_get_self_user_status(Tox *tox); /* Set our typing status for a friend. * You are responsible for turning it on or off. @@ -298,48 +298,48 @@ uint32_t tox_get_num_online_friends(Tox *tox); 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) + * Function format is function(Tox *tox, uint8_t * public_key, uint8_t * data, uint16_t length, void *userdata) */ void tox_callback_friend_request(Tox *tox, 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(Tox *tox, int friendnumber, uint8_t * message, uint32_t length, void *userdata) */ void tox_callback_friend_message(Tox *tox, void (*function)(Tox *tox, int, 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(int32_t friendnumber, uint8_t * action, uint32_t length) + * Function format is: function(Tox *tox, int32_t friendnumber, uint8_t * action, uint32_t length, 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(int32_t friendnumber, uint8_t *newname, uint16_t length) + * function(Tox *tox, int32_t friendnumber, uint8_t *newname, uint16_t length, void *userdata) * You are not responsible for freeing newname */ 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(int32_t friendnumber, uint8_t *newstatus, uint16_t length) + * function(Tox *tox, int32_t friendnumber, uint8_t *newstatus, uint16_t length, void *userdata) * You are not responsible for freeing newstatus. */ 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(int32_t friendnumber, USERSTATUS kind) + * function(Tox *tox, int32_t friendnumber, uint8_t TOX_USERSTATUS, void *userdata) */ -void tox_callback_user_status(Tox *tox, void (*function)(Tox *tox, int32_t, TOX_USERSTATUS, void *), void *userdata); +void tox_callback_user_status(Tox *tox, void (*function)(Tox *tox, int32_t, uint8_t, void *), void *userdata); /* Set the callback for typing changes. - * function (int32_t friendnumber, int is_typing) + * function (Tox *tox, int32_t friendnumber, int is_typing, 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(int32_t friendnumber, uint32_t receipt) + * function(Tox *tox, int32_t friendnumber, uint32_t receipt, void *userdata) * * If you are keeping a record of returns from m_sendmessage; * receipt might be one of those values, meaning the message @@ -350,7 +350,7 @@ void tox_callback_typing_change(Tox *tox, void (*function)(Tox *tox, int32_t, in 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(int32_t friendnumber, uint8_t status) + * function(Tox *tox, int32_t friendnumber, uint8_t status, void *userdata) * * Status: * 0 -- friend went offline after being previously online