Typing and status functions implemented.

This commit is contained in:
irungentoo 2015-02-19 16:54:49 -05:00
parent 308cf5da6d
commit c037aefe9d
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
3 changed files with 42 additions and 2 deletions

View File

@ -806,7 +806,7 @@ int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing)
return 0; return 0;
} }
uint8_t m_get_istyping(const Messenger *m, int32_t friendnumber) int m_get_istyping(const Messenger *m, int32_t friendnumber)
{ {
if (friend_not_valid(m, friendnumber)) if (friend_not_valid(m, friendnumber))
return -1; return -1;

View File

@ -616,7 +616,7 @@ int m_set_usertyping(Messenger *m, int32_t friendnumber, uint8_t is_typing);
* returns 0 if friend is not typing. * returns 0 if friend is not typing.
* returns 1 if friend is typing. * returns 1 if friend is typing.
*/ */
uint8_t m_get_istyping(const Messenger *m, int32_t friendnumber); int m_get_istyping(const Messenger *m, int32_t friendnumber);
/* Sets whether we send read receipts for 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). * This function is not lazy, and it will fail if yesno is not (0 or 1).

View File

@ -646,3 +646,43 @@ void tox_callback_friend_status_message(Tox *tox, tox_friend_status_message_cb *
Messenger *m = tox; Messenger *m = tox;
m_callback_statusmessage(m, function, user_data); m_callback_statusmessage(m, function, user_data);
} }
TOX_STATUS tox_friend_get_status(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error)
{
const Messenger *m = tox;
int ret = m_get_userstatus(m, friend_number);
if (ret == USERSTATUS_INVALID) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND);
return TOX_STATUS_INVALID;
}
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK);
return ret;
}
void tox_callback_friend_status(Tox *tox, tox_friend_status_cb *function, void *user_data)
{
Messenger *m = tox;
m_callback_userstatus(m, function, user_data);
}
bool tox_friend_get_typing(Tox const *tox, uint32_t friend_number, TOX_ERR_FRIEND_QUERY *error)
{
const Messenger *m = tox;
int ret = m_get_istyping(m, friend_number);
if (ret == -1) {
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_FRIEND_NOT_FOUND);
return 0;
}
SET_ERROR_PARAMETER(error, TOX_ERR_FRIEND_QUERY_OK);
return !!ret;
}
void tox_callback_friend_typing(Tox *tox, tox_friend_typing_cb *function, void *user_data)
{
Messenger *m = tox;
m_callback_typingchange(m, function, user_data);
}