1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Set status to what it was before autoaway

This commit is contained in:
James Booth 2015-09-25 22:55:44 +01:00
parent 22ba3db0b2
commit 100db7c36c
4 changed files with 13 additions and 10 deletions

View File

@ -78,6 +78,8 @@ static void _create_directories(void);
static void _connect_default(const char * const account); static void _connect_default(const char * const account);
static gboolean idle = FALSE; static gboolean idle = FALSE;
resource_presence_t autoaway_pre_presence;
static gboolean cont = TRUE; static gboolean cont = TRUE;
void void
@ -174,8 +176,10 @@ _check_autoaway()
unsigned long idle_ms = ui_get_idle_time(); unsigned long idle_ms = ui_get_idle_time();
char *pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE); char *pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE);
if (!idle) { if (!idle) {
resource_presence_t current_presence = accounts_get_last_presence(jabber_get_account_name()); 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 ((current_presence == RESOURCE_ONLINE) || (current_presence == RESOURCE_CHAT)) {
if (idle_ms >= prefs_time) { if (idle_ms >= prefs_time) {
idle = TRUE; idle = TRUE;
@ -202,11 +206,11 @@ _check_autoaway()
// handle check // handle check
if (prefs_get_boolean(PREF_AUTOAWAY_CHECK)) { if (prefs_get_boolean(PREF_AUTOAWAY_CHECK)) {
if (strcmp(pref_autoaway_mode, "away") == 0) { if (strcmp(pref_autoaway_mode, "away") == 0) {
cl_ev_presence_send(RESOURCE_ONLINE, NULL, 0); cl_ev_presence_send(autoaway_pre_presence, NULL, 0);
ui_end_auto_away(); ui_end_auto_away(autoaway_pre_presence);
} else if (strcmp(pref_autoaway_mode, "idle") == 0) { } else if (strcmp(pref_autoaway_mode, "idle") == 0) {
cl_ev_presence_send(RESOURCE_ONLINE, NULL, 0); cl_ev_presence_send(autoaway_pre_presence, NULL, 0);
ui_titlebar_presence(CONTACT_ONLINE); ui_titlebar_presence(contact_presence_from_resource_presence(autoaway_pre_presence));
} }
} }
} }

View File

@ -574,12 +574,11 @@ ui_auto_away(void)
} }
void void
ui_end_auto_away(void) ui_end_auto_away(resource_presence_t presence)
{ {
int pri = int pri = accounts_get_priority_for_presence_type(jabber_get_account_name(), presence);
accounts_get_priority_for_presence_type(jabber_get_account_name(), RESOURCE_ONLINE);
cons_show("No longer idle, status set to online (priority %d).", pri); cons_show("No longer idle, status set to online (priority %d).", pri);
title_bar_set_presence(CONTACT_ONLINE); title_bar_set_presence(contact_presence_from_resource_presence(presence));
} }
void void

View File

@ -226,7 +226,7 @@ void ui_subwin_page_down(void);
void ui_clear_win(ProfWin *window); void ui_clear_win(ProfWin *window);
void ui_auto_away(void); void ui_auto_away(void);
void ui_end_auto_away(void); void ui_end_auto_away(resource_presence_t presence);
void ui_titlebar_presence(contact_presence_t presence); void ui_titlebar_presence(contact_presence_t presence);
void ui_handle_login_account_success(ProfAccount *account); void ui_handle_login_account_success(ProfAccount *account);
void ui_update_presence(const resource_presence_t resource_presence, void ui_update_presence(const resource_presence_t resource_presence,

View File

@ -316,7 +316,7 @@ gboolean ui_swap_wins(int source_win, int target_win)
} }
void ui_auto_away(void) {} void ui_auto_away(void) {}
void ui_end_auto_away(void) {} void ui_end_auto_away(resource_presence_t presence) {}
void ui_titlebar_presence(contact_presence_t presence) {} void ui_titlebar_presence(contact_presence_t presence) {}
void ui_handle_login_account_success(ProfAccount *account) {} void ui_handle_login_account_success(ProfAccount *account) {}
void ui_update_presence(const resource_presence_t resource_presence, void ui_update_presence(const resource_presence_t resource_presence,