mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-08 19:34:14 -04:00
Merge branch 'master' into inp-utf8
This commit is contained in:
commit
78bfd8da40
@ -75,28 +75,26 @@ 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);
|
|
||||||
GTimer *timer = g_timer_new();
|
|
||||||
gboolean cmd_result = 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;
|
||||||
while(cmd_result == TRUE) {
|
while(cmd_result == TRUE) {
|
||||||
wint_t ch = ERR;
|
wint_t ch = ERR;
|
||||||
size = 0;
|
size = 0;
|
||||||
@ -107,18 +105,12 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
|
|||||||
_handle_idle_time();
|
_handle_idle_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
gdouble elapsed = g_timer_elapsed(timer, NULL);
|
|
||||||
|
|
||||||
gint remind_period = prefs_get_notify_remind();
|
|
||||||
if (remind_period > 0 && elapsed >= remind_period) {
|
|
||||||
notify_remind();
|
|
||||||
g_timer_start(timer);
|
|
||||||
}
|
|
||||||
|
|
||||||
ch = ui_get_char(inp, &size);
|
ch = ui_get_char(inp, &size);
|
||||||
|
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
otr_poll();
|
otr_poll();
|
||||||
#endif
|
#endif
|
||||||
|
notify_remind();
|
||||||
jabber_process_events();
|
jabber_process_events();
|
||||||
ui_update();
|
ui_update();
|
||||||
}
|
}
|
||||||
@ -126,8 +118,6 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
|
|||||||
inp[size++] = '\0';
|
inp[size++] = '\0';
|
||||||
cmd_result = process_input(inp);
|
cmd_result = process_input(inp);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_timer_destroy(timer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -205,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) {
|
||||||
@ -224,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,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
|
||||||
@ -284,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
|
||||||
|
@ -102,6 +102,7 @@ ui_init(void)
|
|||||||
status_bar_active(1);
|
status_bar_active(1);
|
||||||
create_input_window();
|
create_input_window();
|
||||||
wins_init();
|
wins_init();
|
||||||
|
notifier_initialise();
|
||||||
cons_about();
|
cons_about();
|
||||||
#ifdef HAVE_LIBXSS
|
#ifdef HAVE_LIBXSS
|
||||||
display = XOpenDisplay(0);
|
display = XOpenDisplay(0);
|
||||||
|
@ -48,10 +48,19 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "muc.h"
|
#include "muc.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
#include "config/preferences.h"
|
||||||
|
|
||||||
static void _notify(const char * const message, int timeout,
|
static void _notify(const char * const message, int timeout,
|
||||||
const char * const category);
|
const char * const category);
|
||||||
|
|
||||||
|
static GTimer *remind_timer;
|
||||||
|
|
||||||
|
void
|
||||||
|
notifier_initialise(void)
|
||||||
|
{
|
||||||
|
remind_timer = g_timer_new();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
notifier_uninit(void)
|
notifier_uninit(void)
|
||||||
{
|
{
|
||||||
@ -60,6 +69,7 @@ notifier_uninit(void)
|
|||||||
notify_uninit();
|
notify_uninit();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
g_timer_destroy(remind_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -128,46 +138,52 @@ notify_subscription(const char * const from)
|
|||||||
void
|
void
|
||||||
notify_remind(void)
|
notify_remind(void)
|
||||||
{
|
{
|
||||||
gint unread = ui_unread();
|
gdouble elapsed = g_timer_elapsed(remind_timer, NULL);
|
||||||
gint open = muc_invites_count();
|
gint remind_period = prefs_get_notify_remind();
|
||||||
gint subs = presence_sub_request_count();
|
if (remind_period > 0 && elapsed >= remind_period) {
|
||||||
|
gint unread = ui_unread();
|
||||||
|
gint open = muc_invites_count();
|
||||||
|
gint subs = presence_sub_request_count();
|
||||||
|
|
||||||
GString *text = g_string_new("");
|
GString *text = g_string_new("");
|
||||||
|
|
||||||
if (unread > 0) {
|
|
||||||
if (unread == 1) {
|
|
||||||
g_string_append(text, "1 unread message");
|
|
||||||
} else {
|
|
||||||
g_string_append_printf(text, "%d unread messages", unread);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (open > 0) {
|
|
||||||
if (unread > 0) {
|
if (unread > 0) {
|
||||||
g_string_append(text, "\n");
|
if (unread == 1) {
|
||||||
}
|
g_string_append(text, "1 unread message");
|
||||||
if (open == 1) {
|
} else {
|
||||||
g_string_append(text, "1 room invite");
|
g_string_append_printf(text, "%d unread messages", unread);
|
||||||
} else {
|
}
|
||||||
g_string_append_printf(text, "%d room invites", open);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (subs > 0) {
|
|
||||||
if ((unread > 0) || (open > 0)) {
|
|
||||||
g_string_append(text, "\n");
|
|
||||||
}
|
|
||||||
if (subs == 1) {
|
|
||||||
g_string_append(text, "1 subscription request");
|
|
||||||
} else {
|
|
||||||
g_string_append_printf(text, "%d subscription requests", subs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((unread > 0) || (open > 0) || (subs > 0)) {
|
}
|
||||||
_notify(text->str, 5000, "Incoming message");
|
if (open > 0) {
|
||||||
}
|
if (unread > 0) {
|
||||||
|
g_string_append(text, "\n");
|
||||||
|
}
|
||||||
|
if (open == 1) {
|
||||||
|
g_string_append(text, "1 room invite");
|
||||||
|
} else {
|
||||||
|
g_string_append_printf(text, "%d room invites", open);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (subs > 0) {
|
||||||
|
if ((unread > 0) || (open > 0)) {
|
||||||
|
g_string_append(text, "\n");
|
||||||
|
}
|
||||||
|
if (subs == 1) {
|
||||||
|
g_string_append(text, "1 subscription request");
|
||||||
|
} else {
|
||||||
|
g_string_append_printf(text, "%d subscription requests", subs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_string_free(text, TRUE);
|
if ((unread > 0) || (open > 0) || (subs > 0)) {
|
||||||
|
_notify(text->str, 5000, "Incoming message");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_string_free(text, TRUE);
|
||||||
|
|
||||||
|
g_timer_start(remind_timer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -329,6 +329,7 @@ void rosterwin_roster(void);
|
|||||||
void occupantswin_occupants(const char * const room);
|
void occupantswin_occupants(const char * const room);
|
||||||
|
|
||||||
// desktop notifier actions
|
// desktop notifier actions
|
||||||
|
void notifier_initialise(void);
|
||||||
void notifier_uninit(void);
|
void notifier_uninit(void);
|
||||||
|
|
||||||
void notify_typing(const char * const handle);
|
void notify_typing(const char * const handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user