added API function to get online friend count

This commit is contained in:
Jfreegman 2014-02-07 19:43:21 -05:00
parent 9c022832db
commit e9f3477d69
4 changed files with 25 additions and 1 deletions

View File

@ -665,8 +665,12 @@ static void check_friend_connectionstatus(Messenger *m, int friendnumber, uint8_
onion_set_friend_online(m->onion_c, m->friendlist[friendnumber].onion_friendnum, is_online);
if (is_online != was_online) {
if (was_online)
if (was_online) {
break_files(m, friendnumber);
--m->numonline_friends;
} else {
++m->numonline_friends;
}
m->friend_connectionstatuschange(m, friendnumber, is_online, m->friend_connectionstatuschange_userdata);
}
@ -2360,6 +2364,12 @@ uint32_t count_friendlist(Messenger *m)
return ret;
}
/* Return the number of online friends in the instance m. */
uint32_t get_num_online_friends(Messenger *m)
{
return m->numonline_friends;
}
/* Copy a list of valid friend IDs into the array out_list.
* If out_list is NULL, returns 0.
* Otherwise, returns the number of elements copied.

View File

@ -178,6 +178,7 @@ typedef struct Messenger {
Friend *friendlist;
uint32_t numfriends;
uint32_t numonline_friends;
Group_Chat **chats;
uint32_t numchats;
@ -682,6 +683,9 @@ int messenger_load_encrypted(Messenger *m, uint8_t *data, uint32_t length, uint8
* for copy_friendlist. */
uint32_t count_friendlist(Messenger *m);
/* Return the number of online friends in the instance m. */
uint32_t get_num_online_friends(Messenger *m);
/* Copy a list of valid friend IDs into the array out_list.
* If out_list is NULL, returns 0.
* Otherwise, returns the number of elements copied.

View File

@ -289,6 +289,13 @@ uint32_t tox_count_friendlist(Tox *tox)
return count_friendlist(m);
}
/* Return the number of online friends in the instance m. */
uint32_t tox_get_num_online_friends(Tox *tox)
{
Messenger *m = tox;
return get_num_online_friends(m);
}
/* Copy a list of valid friend IDs into the array out_list.
* If out_list is NULL, returns 0.
* Otherwise, returns the number of elements copied.

View File

@ -284,6 +284,9 @@ void tox_set_sends_receipts(Tox *tox, int friendnumber, int yesno);
* for copy_friendlist. */
uint32_t tox_count_friendlist(Tox *tox);
/* Return the number of online friends in the instance m. */
uint32_t tox_get_num_online_friends(Tox *tox);
/* Copy a list of valid friend IDs into the array out_list.
* If out_list is NULL, returns 0.
* Otherwise, returns the number of elements copied.