mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Tidy profanity.c
This commit is contained in:
parent
0007e3569e
commit
3b69ad7b61
@ -75,26 +75,25 @@ void
|
|||||||
prof_run(const int disable_tls, char *log_level, char *account_name)
|
prof_run(const int disable_tls, char *log_level, char *account_name)
|
||||||
{
|
{
|
||||||
_init(disable_tls, log_level);
|
_init(disable_tls, log_level);
|
||||||
log_info("Starting main event loop");
|
|
||||||
ui_input_nonblocking(TRUE);
|
|
||||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
|
||||||
|
|
||||||
char inp[INP_WIN_MAX];
|
char inp[INP_WIN_MAX];
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT);
|
char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT);
|
||||||
if (account_name != NULL) {
|
if (account_name != NULL) {
|
||||||
char *cmd = "/connect";
|
snprintf(inp, sizeof(inp), "%s %s", "/connect", account_name);
|
||||||
snprintf(inp, sizeof(inp), "%s %s", cmd, account_name);
|
|
||||||
process_input(inp);
|
process_input(inp);
|
||||||
} else if (pref_connect_account != NULL) {
|
} else if (pref_connect_account != NULL) {
|
||||||
char *cmd = "/connect";
|
snprintf(inp, sizeof(inp), "%s %s", "/connect", pref_connect_account);
|
||||||
snprintf(inp, sizeof(inp), "%s %s", cmd, pref_connect_account);
|
|
||||||
process_input(inp);
|
process_input(inp);
|
||||||
}
|
}
|
||||||
prefs_free_string(pref_connect_account);
|
prefs_free_string(pref_connect_account);
|
||||||
|
|
||||||
ui_update();
|
ui_update();
|
||||||
|
|
||||||
|
log_info("Starting main event loop");
|
||||||
|
|
||||||
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
gboolean cmd_result = TRUE;
|
gboolean cmd_result = TRUE;
|
||||||
while(cmd_result == TRUE) {
|
while(cmd_result == TRUE) {
|
||||||
wint_t ch = ERR;
|
wint_t ch = ERR;
|
||||||
@ -196,15 +195,15 @@ static void
|
|||||||
_handle_idle_time()
|
_handle_idle_time()
|
||||||
{
|
{
|
||||||
gint prefs_time = prefs_get_autoaway_time() * 60000;
|
gint prefs_time = prefs_get_autoaway_time() * 60000;
|
||||||
resource_presence_t current_presence = accounts_get_last_presence(jabber_get_account_name());
|
|
||||||
unsigned long idle_ms = ui_get_idle_time();
|
unsigned long idle_ms = ui_get_idle_time();
|
||||||
char *pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE);
|
char *pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE);
|
||||||
char *pref_autoaway_message = prefs_get_string(PREF_AUTOAWAY_MESSAGE);
|
|
||||||
|
|
||||||
if (!idle) {
|
if (!idle) {
|
||||||
|
resource_presence_t current_presence = accounts_get_last_presence(jabber_get_account_name());
|
||||||
if ((current_presence == RESOURCE_ONLINE) || (current_presence == RESOURCE_CHAT)) {
|
if ((current_presence == RESOURCE_ONLINE) || (current_presence == RESOURCE_CHAT)) {
|
||||||
if (idle_ms >= prefs_time) {
|
if (idle_ms >= prefs_time) {
|
||||||
idle = TRUE;
|
idle = TRUE;
|
||||||
|
char *pref_autoaway_message = prefs_get_string(PREF_AUTOAWAY_MESSAGE);
|
||||||
|
|
||||||
// handle away mode
|
// handle away mode
|
||||||
if (strcmp(pref_autoaway_mode, "away") == 0) {
|
if (strcmp(pref_autoaway_mode, "away") == 0) {
|
||||||
@ -215,6 +214,8 @@ _handle_idle_time()
|
|||||||
} else if (strcmp(pref_autoaway_mode, "idle") == 0) {
|
} else if (strcmp(pref_autoaway_mode, "idle") == 0) {
|
||||||
presence_update(RESOURCE_ONLINE, pref_autoaway_message, idle_ms / 1000);
|
presence_update(RESOURCE_ONLINE, pref_autoaway_message, idle_ms / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prefs_free_string(pref_autoaway_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,8 +235,8 @@ _handle_idle_time()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs_free_string(pref_autoaway_mode);
|
prefs_free_string(pref_autoaway_mode);
|
||||||
prefs_free_string(pref_autoaway_message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -275,6 +276,7 @@ _init(const int disable_tls, char *log_level)
|
|||||||
otr_init();
|
otr_init();
|
||||||
#endif
|
#endif
|
||||||
atexit(_shutdown);
|
atexit(_shutdown);
|
||||||
|
ui_input_nonblocking(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user