mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Save last activity to account on disconnect
This commit is contained in:
parent
4257ecb1c5
commit
b484411ea8
@ -777,6 +777,7 @@ cmd_disconnect(ProfWin *window, const char * const command, gchar **args)
|
|||||||
if (jabber_get_connection_status() == JABBER_CONNECTED) {
|
if (jabber_get_connection_status() == JABBER_CONNECTED) {
|
||||||
char *jid = strdup(jabber_get_fulljid());
|
char *jid = strdup(jabber_get_fulljid());
|
||||||
cons_show("%s logged out successfully.", jid);
|
cons_show("%s logged out successfully.", jid);
|
||||||
|
accounts_set_last_activity(jabber_get_account_name());
|
||||||
jabber_disconnect();
|
jabber_disconnect();
|
||||||
roster_clear();
|
roster_clear();
|
||||||
muc_invites_clear();
|
muc_invites_clear();
|
||||||
|
@ -761,6 +761,23 @@ accounts_set_last_presence(const char * const account_name, const char * const v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
accounts_set_last_activity(const char * const account_name)
|
||||||
|
{
|
||||||
|
if (accounts_account_exists(account_name)) {
|
||||||
|
GDateTime *nowdt = g_date_time_new_now_utc();
|
||||||
|
GTimeVal nowtv;
|
||||||
|
gboolean res = g_date_time_to_timeval(nowdt, &nowtv);
|
||||||
|
g_date_time_unref(nowdt);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
char *timestr = g_time_val_to_iso8601(&nowtv);
|
||||||
|
g_key_file_set_string(accounts, account_name, "last.activity", timestr);
|
||||||
|
_save_accounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
accounts_set_login_presence(const char * const account_name, const char * const value)
|
accounts_set_login_presence(const char * const account_name, const char * const value)
|
||||||
{
|
{
|
||||||
|
@ -66,6 +66,7 @@ void accounts_set_muc_service(const char * const account_name, const char * cons
|
|||||||
void accounts_set_muc_nick(const char * const account_name, const char * const value);
|
void accounts_set_muc_nick(const char * const account_name, const char * const value);
|
||||||
void accounts_set_otr_policy(const char * const account_name, const char * const value);
|
void accounts_set_otr_policy(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_last_presence(const char * const account_name, const char * const value);
|
||||||
|
void accounts_set_last_activity(const char * const account_name);
|
||||||
void accounts_set_login_presence(const char * const account_name, const char * const value);
|
void accounts_set_login_presence(const char * const account_name, const char * const value);
|
||||||
resource_presence_t accounts_get_login_presence(const char * const account_name);
|
resource_presence_t accounts_get_login_presence(const char * const account_name);
|
||||||
resource_presence_t accounts_get_last_presence(const char * const account_name);
|
resource_presence_t accounts_get_last_presence(const char * const account_name);
|
||||||
|
@ -200,6 +200,7 @@ jabber_disconnect(void)
|
|||||||
// if connected, send end stream and wait for response
|
// if connected, send end stream and wait for response
|
||||||
if (jabber_conn.conn_status == JABBER_CONNECTED) {
|
if (jabber_conn.conn_status == JABBER_CONNECTED) {
|
||||||
log_info("Closing connection");
|
log_info("Closing connection");
|
||||||
|
accounts_set_last_activity(jabber_get_account_name());
|
||||||
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
jabber_conn.conn_status = JABBER_DISCONNECTING;
|
||||||
xmpp_disconnect(jabber_conn.conn);
|
xmpp_disconnect(jabber_conn.conn);
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ void accounts_set_otr_policy(const char * const account_name, const char * const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void accounts_set_last_presence(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_last_activity(const char * const account_name) {}
|
||||||
void accounts_set_pgp_keyid(const char * const account_name, const char * const value) {}
|
void accounts_set_pgp_keyid(const char * const account_name, const char * const value) {}
|
||||||
|
|
||||||
void accounts_set_login_presence(const char * const account_name, const char * const value)
|
void accounts_set_login_presence(const char * const account_name, const char * const value)
|
||||||
|
@ -22,6 +22,7 @@ void clears_chat_sessions(void **state)
|
|||||||
chat_session_recipient_active("mike@server.org", "work", FALSE);
|
chat_session_recipient_active("mike@server.org", "work", FALSE);
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
will_return(jabber_get_account_name, "someaccount");
|
||||||
will_return(jabber_get_fulljid, "myjid@myserver.com");
|
will_return(jabber_get_fulljid, "myjid@myserver.com");
|
||||||
expect_any_cons_show();
|
expect_any_cons_show();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user