mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 20:26:21 +00:00
Added idle and activity handlers
This commit is contained in:
@@ -99,6 +99,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
|
||||
void
|
||||
prof_handle_idle(void)
|
||||
{
|
||||
cons_debug("IDLE");
|
||||
jabber_conn_status_t status = jabber_get_connection_status();
|
||||
if (status == JABBER_CONNECTED) {
|
||||
GSList *recipients = ui_get_chat_recipients();
|
||||
@@ -120,6 +121,7 @@ prof_handle_idle(void)
|
||||
void
|
||||
prof_handle_activity(void)
|
||||
{
|
||||
cons_debug("ACTIVITY");
|
||||
win_type_t win_type = ui_current_win_type();
|
||||
jabber_conn_status_t status = jabber_get_connection_status();
|
||||
|
||||
|
||||
@@ -142,16 +142,6 @@ offset_to_col(char *str, int offset)
|
||||
return col;
|
||||
}
|
||||
|
||||
void
|
||||
inp_write(char *line, int offset)
|
||||
{
|
||||
int col = offset_to_col(line, offset);
|
||||
werase(inp_win);
|
||||
waddstr(inp_win, line);
|
||||
wmove(inp_win, 0, col);
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
void
|
||||
inp_non_block(gint block_timeout)
|
||||
{
|
||||
@@ -164,6 +154,16 @@ inp_block(void)
|
||||
wtimeout(inp_win, -1);
|
||||
}
|
||||
|
||||
void
|
||||
inp_write(char *line, int offset)
|
||||
{
|
||||
int col = offset_to_col(line, offset);
|
||||
werase(inp_win);
|
||||
waddstr(inp_win, line);
|
||||
wmove(inp_win, 0, col);
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
gboolean
|
||||
inp_readline(void)
|
||||
{
|
||||
@@ -177,7 +177,12 @@ inp_readline(void)
|
||||
|
||||
if (FD_ISSET(fileno(rl_instream), &fds)) {
|
||||
rl_callback_read_char();
|
||||
if (rl_line_buffer && rl_line_buffer[0] != '/') {
|
||||
prof_handle_activity();
|
||||
}
|
||||
inp_write(rl_line_buffer, rl_point);
|
||||
} else {
|
||||
prof_handle_idle();
|
||||
}
|
||||
|
||||
p_rl_timeout.tv_sec = 0;
|
||||
|
||||
Reference in New Issue
Block a user