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

Set last presence for account

This commit is contained in:
James Booth 2013-01-27 22:27:30 +00:00
parent dba48f18b5
commit a9c629dd9e
3 changed files with 29 additions and 1 deletions

View File

@ -300,6 +300,24 @@ 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)
{
if (accounts_account_exists(account_name)) {
g_key_file_set_string(accounts, account_name, "presence.last", value);
_save_accounts();
}
}
void
accounts_set_login_presence(const char * const account_name, const char * const value)
{
if (accounts_account_exists(account_name)) {
g_key_file_set_string(accounts, account_name, "presence.login", value);
_save_accounts();
}
}
static void
_fix_legacy_accounts(const char * const account_name)
{

View File

@ -50,5 +50,7 @@ gboolean accounts_account_exists(const char * const account_name);
void accounts_set_jid(const char * const account_name, const char * const value);
void accounts_set_server(const char * const account_name, const char * const value);
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);
#endif

View File

@ -402,7 +402,7 @@ jabber_update_presence(jabber_presence_t status, const char * const msg,
int idle)
{
int pri;
char *show;
char *show, *last;
// don't send presence when disconnected
if (jabber_conn.conn_status != JABBER_CONNECTED)
@ -419,18 +419,23 @@ jabber_update_presence(jabber_presence_t status, const char * const msg,
{
case PRESENCE_AWAY:
show = STANZA_TEXT_AWAY;
last = STANZA_TEXT_AWAY;
break;
case PRESENCE_DND:
show = STANZA_TEXT_DND;
last = STANZA_TEXT_DND;
break;
case PRESENCE_CHAT:
show = STANZA_TEXT_CHAT;
last = STANZA_TEXT_CHAT;
break;
case PRESENCE_XA:
show = STANZA_TEXT_XA;
last = STANZA_TEXT_XA;
break;
default: // PRESENCE_ONLINE
show = NULL;
last = STANZA_TEXT_ONLINE;
break;
}
@ -496,6 +501,9 @@ jabber_update_presence(jabber_presence_t status, const char * const msg,
xmpp_stanza_release(presence);
FREE_SET_NULL(sha1);
// set last presence for account
accounts_set_last_presence(saved_account.name, last);
}
void