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 static void
_fix_legacy_accounts(const char * const account_name) _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_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_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_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 #endif

View File

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