mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Restore last status string when connecting
This commit is contained in:
parent
aae252e1b5
commit
0fc3343d75
@ -844,8 +844,6 @@ accounts_set_last_status(const char* const account_name, const char* const value
|
|||||||
if (accounts_account_exists(account_name)) {
|
if (accounts_account_exists(account_name)) {
|
||||||
if (value) {
|
if (value) {
|
||||||
g_key_file_set_string(accounts, account_name, "presence.laststatus", value);
|
g_key_file_set_string(accounts, account_name, "presence.laststatus", value);
|
||||||
} else {
|
|
||||||
g_key_file_remove_key(accounts, account_name, "presence.laststatus", NULL);
|
|
||||||
}
|
}
|
||||||
_save_accounts();
|
_save_accounts();
|
||||||
}
|
}
|
||||||
@ -952,6 +950,17 @@ accounts_get_login_presence(const char* const account_name)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
accounts_get_login_status(const char* const account_name)
|
||||||
|
{
|
||||||
|
gchar* setting = g_key_file_get_string(accounts, account_name, "presence.login", NULL);
|
||||||
|
gchar* status = NULL;
|
||||||
|
if (g_strcmp0(setting, "last") == 0) {
|
||||||
|
status = accounts_get_last_status(account_name);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_save_accounts(void)
|
_save_accounts(void)
|
||||||
{
|
{
|
||||||
|
@ -76,6 +76,7 @@ void accounts_set_login_presence(const char* const account_name, const char* con
|
|||||||
resource_presence_t accounts_get_login_presence(const char* const account_name);
|
resource_presence_t accounts_get_login_presence(const char* const account_name);
|
||||||
char* accounts_get_last_status(const char* const account_name);
|
char* accounts_get_last_status(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);
|
||||||
|
char* accounts_get_login_status(const char* const account_name);
|
||||||
void accounts_set_priority_online(const char* const account_name, const gint value);
|
void accounts_set_priority_online(const char* const account_name, const gint value);
|
||||||
void accounts_set_priority_chat(const char* const account_name, const gint value);
|
void accounts_set_priority_chat(const char* const account_name, const gint value);
|
||||||
void accounts_set_priority_away(const char* const account_name, const gint value);
|
void accounts_set_priority_away(const char* const account_name, const gint value);
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "config/accounts.h"
|
||||||
#include "profanity.h"
|
#include "profanity.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
@ -166,6 +167,7 @@ sv_ev_roster_received(void)
|
|||||||
// send initial presence
|
// send initial presence
|
||||||
resource_presence_t conn_presence = accounts_get_login_presence(account_name);
|
resource_presence_t conn_presence = accounts_get_login_presence(account_name);
|
||||||
char* last_activity_str = accounts_get_last_activity(account_name);
|
char* last_activity_str = accounts_get_last_activity(account_name);
|
||||||
|
char* status_message = accounts_get_login_status(account_name);
|
||||||
if (prefs_get_boolean(PREF_LASTACTIVITY) && last_activity_str) {
|
if (prefs_get_boolean(PREF_LASTACTIVITY) && last_activity_str) {
|
||||||
|
|
||||||
GTimeVal lasttv;
|
GTimeVal lasttv;
|
||||||
@ -177,17 +179,17 @@ sv_ev_roster_received(void)
|
|||||||
GTimeSpan diff_micros = g_date_time_difference(nowdt, lastdt);
|
GTimeSpan diff_micros = g_date_time_difference(nowdt, lastdt);
|
||||||
int diff_secs = (diff_micros / 1000) / 1000;
|
int diff_secs = (diff_micros / 1000) / 1000;
|
||||||
|
|
||||||
connection_set_presence_msg(NULL);
|
connection_set_presence_msg(status_message);
|
||||||
cl_ev_presence_send(conn_presence, diff_secs);
|
cl_ev_presence_send(conn_presence, diff_secs);
|
||||||
|
|
||||||
g_date_time_unref(lastdt);
|
g_date_time_unref(lastdt);
|
||||||
} else {
|
} else {
|
||||||
connection_set_presence_msg(NULL);
|
connection_set_presence_msg(status_message);
|
||||||
cl_ev_presence_send(conn_presence, 0);
|
cl_ev_presence_send(conn_presence, 0);
|
||||||
}
|
}
|
||||||
g_date_time_unref(nowdt);
|
g_date_time_unref(nowdt);
|
||||||
} else {
|
} else {
|
||||||
connection_set_presence_msg(NULL);
|
connection_set_presence_msg(status_message);
|
||||||
cl_ev_presence_send(conn_presence, 0);
|
cl_ev_presence_send(conn_presence, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +213,12 @@ accounts_get_last_presence(const char* const account_name)
|
|||||||
return mock_type(resource_presence_t);
|
return mock_type(resource_presence_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
accounts_get_login_status(const char* const account_name)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
accounts_set_priority_online(const char* const account_name, const gint value)
|
accounts_set_priority_online(const char* const account_name, const gint value)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user