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

Show current presence when logging in

Also show correct presence in title bar upon login
This commit is contained in:
James Booth 2013-01-31 00:40:27 +00:00
parent e6749d669d
commit 06abe13f19
6 changed files with 42 additions and 8 deletions

View File

@ -365,7 +365,7 @@ accounts_get_last_presence(const char * const account_name)
}
jabber_presence_t
account_get_login_presence(const char * const account_name)
accounts_get_login_presence(const char * const account_name)
{
gchar *setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL);
if (setting == NULL || (strcmp(setting, "online") == 0)) {

View File

@ -56,7 +56,7 @@ void accounts_set_server(const char * const account_name, const char * const val
void accounts_set_resource(const char * const account_name, const char * const value);
void accounts_set_last_presence(const char * const account_name, const char * const value);
void accounts_set_login_presence(const char * const account_name, const char * const value);
jabber_presence_t account_get_login_presence(const char * const account_name);
jabber_presence_t accounts_get_login_presence(const char * const account_name);
jabber_presence_t accounts_get_last_presence(const char * const account_name);
#endif

View File

@ -198,11 +198,10 @@ void
prof_handle_login_account_success(char *account_name)
{
ProfAccount *account = accounts_get_account(account_name);
const char *msg = "logged in successfully.";
cons_show("%s %s", account->jid, msg);
title_bar_set_status(PRESENCE_ONLINE);
log_info("%s %s", account->jid, msg);
jabber_presence_t presence = accounts_get_login_presence(account->name);
cons_show_login_success(account);
title_bar_set_status(presence);
log_info("%s logged in successfully", account->jid);
win_current_page_off();
status_bar_print_message(account->jid);
status_bar_refresh();

View File

@ -166,6 +166,7 @@ void cons_show_wins(void);
void cons_show_status(const char * const contact);
void cons_show_info(PContact pcontact);
void cons_show_themes(GSList *themes);
void cons_show_login_success(ProfAccount *account);
// status bar actions
void status_bar_refresh(void);

View File

@ -1083,6 +1083,40 @@ win_show_room_broadcast(const char * const room_jid, const char * const message)
}
}
void
cons_show_login_success(ProfAccount *account)
{
_win_show_time(console->win, '-');
wprintw(console->win, "%s logged in successfully, ", account->jid);
jabber_presence_t presence = accounts_get_login_presence(account->name);
char *presence_str;
switch(presence)
{
case PRESENCE_CHAT:
presence_str = "chat";
break;
case PRESENCE_AWAY:
presence_str = "away";
break;
case PRESENCE_XA:
presence_str = "xa";
break;
case PRESENCE_DND:
presence_str = "dnd";
break;
default:
presence_str = "online";
break;
}
_presence_colour_on(console->win, presence_str);
wprintw(console->win, "%s", presence_str);
_presence_colour_off(console->win, presence_str);
wprintw(console->win, ".\n");
}
void
cons_show_wins(void)
{

View File

@ -149,7 +149,7 @@ _iq_handle_roster_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
item = xmpp_stanza_get_next(item);
}
jabber_presence_t connect_presence = account_get_login_presence(jabber_get_account_name());
jabber_presence_t connect_presence = accounts_get_login_presence(jabber_get_account_name());
presence_update(connect_presence, NULL, 0);
}