From 100db7c36cc40ff740a51d51c2c7887c4d2e138d Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 25 Sep 2015 22:55:44 +0100 Subject: Set status to what it was before autoaway --- src/profanity.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/profanity.c') diff --git a/src/profanity.c b/src/profanity.c index 1e542420..edc3cf76 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -78,6 +78,8 @@ static void _create_directories(void); static void _connect_default(const char * const account); static gboolean idle = FALSE; +resource_presence_t autoaway_pre_presence; + static gboolean cont = TRUE; void @@ -174,8 +176,10 @@ _check_autoaway() unsigned long idle_ms = ui_get_idle_time(); char *pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE); + if (!idle) { resource_presence_t current_presence = accounts_get_last_presence(jabber_get_account_name()); + autoaway_pre_presence = current_presence; if ((current_presence == RESOURCE_ONLINE) || (current_presence == RESOURCE_CHAT)) { if (idle_ms >= prefs_time) { idle = TRUE; @@ -202,11 +206,11 @@ _check_autoaway() // handle check if (prefs_get_boolean(PREF_AUTOAWAY_CHECK)) { if (strcmp(pref_autoaway_mode, "away") == 0) { - cl_ev_presence_send(RESOURCE_ONLINE, NULL, 0); - ui_end_auto_away(); + cl_ev_presence_send(autoaway_pre_presence, NULL, 0); + ui_end_auto_away(autoaway_pre_presence); } else if (strcmp(pref_autoaway_mode, "idle") == 0) { - cl_ev_presence_send(RESOURCE_ONLINE, NULL, 0); - ui_titlebar_presence(CONTACT_ONLINE); + cl_ev_presence_send(autoaway_pre_presence, NULL, 0); + ui_titlebar_presence(contact_presence_from_resource_presence(autoaway_pre_presence)); } } } -- cgit 1.4.1-2-gfad0