summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
authorJfreegman <Jfreegman@gmail.com>2014-02-07 19:43:21 -0500
committerJfreegman <Jfreegman@gmail.com>2014-02-07 19:43:21 -0500
commite9f3477d693bf52750395c462788aff161d0430c (patch)
tree379b52e93ef8a275bfb5728ab281417c0974c5c5 /toxcore/Messenger.c
parent9c022832db229e612a0cd5198630b025584297c3 (diff)
added API function to get online friend count
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index c1301767..f0415501 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -665,8 +665,12 @@ static void check_friend_connectionstatus(Messenger *m, int friendnumber, uint8_
665 onion_set_friend_online(m->onion_c, m->friendlist[friendnumber].onion_friendnum, is_online); 665 onion_set_friend_online(m->onion_c, m->friendlist[friendnumber].onion_friendnum, is_online);
666 666
667 if (is_online != was_online) { 667 if (is_online != was_online) {
668 if (was_online) 668 if (was_online) {
669 break_files(m, friendnumber); 669 break_files(m, friendnumber);
670 --m->numonline_friends;
671 } else {
672 ++m->numonline_friends;
673 }
670 674
671 m->friend_connectionstatuschange(m, friendnumber, is_online, m->friend_connectionstatuschange_userdata); 675 m->friend_connectionstatuschange(m, friendnumber, is_online, m->friend_connectionstatuschange_userdata);
672 } 676 }
@@ -2360,6 +2364,12 @@ uint32_t count_friendlist(Messenger *m)
2360 return ret; 2364 return ret;
2361} 2365}
2362 2366
2367/* Return the number of online friends in the instance m. */
2368uint32_t get_num_online_friends(Messenger *m)
2369{
2370 return m->numonline_friends;
2371}
2372
2363/* Copy a list of valid friend IDs into the array out_list. 2373/* Copy a list of valid friend IDs into the array out_list.
2364 * If out_list is NULL, returns 0. 2374 * If out_list is NULL, returns 0.
2365 * Otherwise, returns the number of elements copied. 2375 * Otherwise, returns the number of elements copied.