mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:43:01 +01:00
fix auto-away bugs
Manually set aways no longer unaway when they shouldn't, and busy status is no longer overridden
This commit is contained in:
parent
442d9e22b4
commit
090d3339a0
@ -66,6 +66,9 @@ static char mplex_data [BUFFER_SIZE];
|
|||||||
|
|
||||||
static char buffer [BUFFER_SIZE];
|
static char buffer [BUFFER_SIZE];
|
||||||
|
|
||||||
|
/* Differentiates between mplex auto-away and manual-away */
|
||||||
|
static bool auto_away_active = false;
|
||||||
|
|
||||||
static mplex_status mplex = MPLEX_NONE;
|
static mplex_status mplex = MPLEX_NONE;
|
||||||
static TOX_USERSTATUS prev_status = TOX_USERSTATUS_NONE;
|
static TOX_USERSTATUS prev_status = TOX_USERSTATUS_NONE;
|
||||||
static char prev_note [TOX_MAX_STATUSMESSAGE_LENGTH] = "";
|
static char prev_note [TOX_MAX_STATUSMESSAGE_LENGTH] = "";
|
||||||
@ -75,8 +78,8 @@ static char prev_note [TOX_MAX_STATUSMESSAGE_LENGTH] = "";
|
|||||||
- auto-away POSIX timer, which runs from a separate thread
|
- auto-away POSIX timer, which runs from a separate thread
|
||||||
after init, should be accessed only by cmd_status()
|
after init, should be accessed only by cmd_status()
|
||||||
*/
|
*/
|
||||||
pthread_mutex_t status_lock;
|
static pthread_mutex_t status_lock;
|
||||||
pthread_t mplex_tid;
|
static pthread_t mplex_tid;
|
||||||
|
|
||||||
void lock_status ()
|
void lock_status ()
|
||||||
{
|
{
|
||||||
@ -311,27 +314,28 @@ static int mplex_is_detached ()
|
|||||||
|
|
||||||
static void mplex_timer_handler (Tox *m)
|
static void mplex_timer_handler (Tox *m)
|
||||||
{
|
{
|
||||||
int detached;
|
|
||||||
TOX_USERSTATUS current_status, new_status;
|
TOX_USERSTATUS current_status, new_status;
|
||||||
const char *new_note;
|
const char *new_note;
|
||||||
|
|
||||||
if (mplex == MPLEX_NONE)
|
if (mplex == MPLEX_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
detached = mplex_is_detached ();
|
int detached = mplex_is_detached ();
|
||||||
|
|
||||||
pthread_mutex_lock (&Winthread.lock);
|
pthread_mutex_lock (&Winthread.lock);
|
||||||
current_status = tox_get_self_user_status (m);
|
current_status = tox_get_self_user_status (m);
|
||||||
pthread_mutex_unlock (&Winthread.lock);
|
pthread_mutex_unlock (&Winthread.lock);
|
||||||
|
|
||||||
if (current_status == TOX_USERSTATUS_AWAY && !detached)
|
if (auto_away_active && current_status == TOX_USERSTATUS_AWAY && !detached)
|
||||||
{
|
{
|
||||||
|
auto_away_active = false;
|
||||||
new_status = prev_status;
|
new_status = prev_status;
|
||||||
new_note = prev_note;
|
new_note = prev_note;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (current_status != TOX_USERSTATUS_AWAY && detached)
|
if (current_status == TOX_USERSTATUS_NONE && detached)
|
||||||
{
|
{
|
||||||
|
auto_away_active = true;
|
||||||
prev_status = current_status;
|
prev_status = current_status;
|
||||||
new_status = TOX_USERSTATUS_AWAY;
|
new_status = TOX_USERSTATUS_AWAY;
|
||||||
pthread_mutex_lock (&Winthread.lock);
|
pthread_mutex_lock (&Winthread.lock);
|
||||||
@ -384,4 +388,3 @@ int init_mplex_away_timer (Tox *m)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user