mirror of
https://github.com/profanity-im/profanity.git
synced 2025-07-26 12:14:28 -04:00
Merge branch 'master' into plugins
Conflicts: src/profanity.c src/server_events.c
This commit is contained in:
commit
5929d8450c
@ -82,6 +82,7 @@ tests_sources = \
|
||||
tests/test_server_events.c \
|
||||
tests/test_muc.c \
|
||||
tests/test_cmd_roster.c \
|
||||
tests/test_cmd_win.c \
|
||||
tests/testsuite.c
|
||||
|
||||
main_source = src/main.c
|
||||
|
@ -63,7 +63,7 @@ static char * _account_autocomplete(char *input, int *size);
|
||||
static char * _who_autocomplete(char *input, int *size);
|
||||
static char * _roster_autocomplete(char *input, int *size);
|
||||
static char * _group_autocomplete(char *input, int *size);
|
||||
//static char * _bookmark_autocomplete(char *input, int *size);
|
||||
static char * _bookmark_autocomplete(char *input, int *size);
|
||||
static char * _otr_autocomplete(char *input, int *size);
|
||||
static char * _connect_autocomplete(char *input, int *size);
|
||||
static char * _statuses_autocomplete(char *input, int *size);
|
||||
@ -297,7 +297,7 @@ static struct cmd_t command_defs[] =
|
||||
"Example : /rooms conference.jabber.org",
|
||||
"Example : /rooms (if logged in as me@server.org, is equivalent to /rooms conference.server.org)",
|
||||
NULL } } },
|
||||
/*
|
||||
|
||||
{ "/bookmark",
|
||||
cmd_bookmark, parse_args, 0, 4, NULL,
|
||||
{ "/bookmark [add|list|remove] [room@server] [autojoin on|off] [nick nickname]",
|
||||
@ -306,7 +306,7 @@ static struct cmd_t command_defs[] =
|
||||
"---------------------------------------------------------------------------",
|
||||
"Manage bookmarks.",
|
||||
NULL } } },
|
||||
*/
|
||||
|
||||
{ "/disco",
|
||||
cmd_disco, parse_args, 1, 2, NULL,
|
||||
{ "/disco command entity", "Service discovery.",
|
||||
@ -871,7 +871,7 @@ static Autocomplete close_ac;
|
||||
static Autocomplete wins_ac;
|
||||
static Autocomplete roster_ac;
|
||||
static Autocomplete group_ac;
|
||||
//static Autocomplete bookmark_ac;
|
||||
static Autocomplete bookmark_ac;
|
||||
static Autocomplete otr_ac;
|
||||
static Autocomplete otr_log_ac;
|
||||
static Autocomplete connect_property_ac;
|
||||
@ -1042,12 +1042,12 @@ cmd_init(void)
|
||||
autocomplete_add(who_ac, "available");
|
||||
autocomplete_add(who_ac, "unavailable");
|
||||
autocomplete_add(who_ac, "any");
|
||||
/*
|
||||
|
||||
bookmark_ac = autocomplete_new();
|
||||
autocomplete_add(bookmark_ac, "add");
|
||||
autocomplete_add(bookmark_ac, "list");
|
||||
autocomplete_add(bookmark_ac, "remove");
|
||||
*/
|
||||
|
||||
otr_ac = autocomplete_new();
|
||||
autocomplete_add(otr_ac, "gen");
|
||||
autocomplete_add(otr_ac, "start");
|
||||
@ -1117,7 +1117,7 @@ cmd_uninit(void)
|
||||
autocomplete_free(wins_ac);
|
||||
autocomplete_free(roster_ac);
|
||||
autocomplete_free(group_ac);
|
||||
// autocomplete_free(bookmark_ac);
|
||||
autocomplete_free(bookmark_ac);
|
||||
autocomplete_free(otr_ac);
|
||||
autocomplete_free(otr_log_ac);
|
||||
autocomplete_free(connect_property_ac);
|
||||
@ -1240,7 +1240,7 @@ cmd_reset_autocomplete()
|
||||
autocomplete_reset(wins_ac);
|
||||
autocomplete_reset(roster_ac);
|
||||
autocomplete_reset(group_ac);
|
||||
// autocomplete_reset(bookmark_ac);
|
||||
autocomplete_reset(bookmark_ac);
|
||||
autocomplete_reset(otr_ac);
|
||||
autocomplete_reset(otr_log_ac);
|
||||
autocomplete_reset(connect_property_ac);
|
||||
@ -1249,7 +1249,7 @@ cmd_reset_autocomplete()
|
||||
autocomplete_reset(alias_ac);
|
||||
autocomplete_reset(aliases_ac);
|
||||
autocomplete_reset(join_property_ac);
|
||||
// bookmark_autocomplete_reset();
|
||||
bookmark_autocomplete_reset();
|
||||
}
|
||||
|
||||
// Command execution
|
||||
@ -1529,8 +1529,7 @@ _cmd_complete_parameters(char *input, int *size)
|
||||
autocompleter acs[] = { _who_autocomplete, _sub_autocomplete, _notify_autocomplete,
|
||||
_autoaway_autocomplete, _titlebar_autocomplete, _theme_autocomplete,
|
||||
_account_autocomplete, _roster_autocomplete, _group_autocomplete,
|
||||
// _bookmark_autocomplete, _autoconnect_autocomplete, _otr_autocomplete,
|
||||
_autoconnect_autocomplete, _otr_autocomplete,
|
||||
_bookmark_autocomplete, _autoconnect_autocomplete, _otr_autocomplete,
|
||||
_connect_autocomplete, _statuses_autocomplete, _alias_autocomplete,
|
||||
_join_autocomplete };
|
||||
|
||||
@ -1602,7 +1601,7 @@ _group_autocomplete(char *input, int *size)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
|
||||
static char *
|
||||
_bookmark_autocomplete(char *input, int *size)
|
||||
{
|
||||
@ -1630,7 +1629,6 @@ _bookmark_autocomplete(char *input, int *size)
|
||||
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
static char *
|
||||
_notify_autocomplete(char *input, int *size)
|
||||
|
@ -531,12 +531,10 @@ gboolean
|
||||
cmd_win(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
int num = atoi(args[0]);
|
||||
if (ui_win_exists(num)) {
|
||||
ui_switch_win(num);
|
||||
} else {
|
||||
gboolean switched = ui_switch_win(num);
|
||||
if (switched == FALSE) {
|
||||
cons_show("Window %d does not exist.", num);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -2668,7 +2666,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
||||
} else if (strcmp(args[0], "warn") == 0) {
|
||||
gboolean result = _cmd_set_boolean_preference(args[1], help,
|
||||
"OTR warning message", PREF_OTR_WARN);
|
||||
ui_current_refresh();
|
||||
ui_current_update_virtual();
|
||||
return result;
|
||||
} else if (strcmp(args[0], "libver") == 0) {
|
||||
char *version = otr_libotr_version();
|
||||
|
@ -234,7 +234,7 @@ _otr_keygen(ProfAccount *account)
|
||||
cons_show("Generating private key, this may take some time.");
|
||||
cons_show("Moving the mouse randomly around the screen may speed up the process!");
|
||||
ui_current_page_off();
|
||||
ui_refresh();
|
||||
ui_update_screen();
|
||||
err = otrl_privkey_generate(user_state, keysfilename->str, account->jid, "xmpp");
|
||||
if (!err == GPG_ERR_NO_ERROR) {
|
||||
g_string_free(basedir, TRUE);
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include "profanity.h"
|
||||
|
||||
#include "chat_session.h"
|
||||
#include "config/accounts.h"
|
||||
#include "config/preferences.h"
|
||||
@ -72,7 +71,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
|
||||
char inp[INP_WIN_MAX];
|
||||
int size = 0;
|
||||
|
||||
ui_refresh();
|
||||
ui_update_screen();
|
||||
plugins_on_start();
|
||||
|
||||
if (account_name != NULL) {
|
||||
@ -106,7 +105,7 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
|
||||
plugins_run_timed();
|
||||
|
||||
ui_handle_special_keys(&ch, inp, size);
|
||||
ui_refresh();
|
||||
ui_update_screen();
|
||||
jabber_process_events();
|
||||
|
||||
ch = inp_get_char(inp, &size);
|
||||
|
@ -99,7 +99,7 @@ handle_login_account_success(char *account_name)
|
||||
log_info("%s logged in successfully", account->jid);
|
||||
ui_current_page_off();
|
||||
status_bar_print_message(account->jid);
|
||||
status_bar_refresh();
|
||||
status_bar_update_virtual();
|
||||
|
||||
account_free(account);
|
||||
}
|
||||
@ -199,7 +199,6 @@ handle_room_message(const char * const room_jid, const char * const nick,
|
||||
}
|
||||
|
||||
ui_room_message(room_jid, nick, new_message);
|
||||
ui_current_page_off();
|
||||
|
||||
if (prefs_get_boolean(PREF_GRLOG)) {
|
||||
Jid *jid = jid_create(jabber_get_fulljid());
|
||||
@ -246,7 +245,6 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
}
|
||||
|
||||
ui_incoming_msg(from, plugin_message, NULL, priv);
|
||||
ui_current_page_off();
|
||||
|
||||
if (prefs_get_boolean(PREF_CHLOG) && !priv) {
|
||||
Jid *from_jid = jid_create(from);
|
||||
@ -277,7 +275,6 @@ handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
}
|
||||
|
||||
ui_incoming_msg(from, plugin_message, NULL, priv);
|
||||
ui_current_page_off();
|
||||
|
||||
if (prefs_get_boolean(PREF_CHLOG) && !priv) {
|
||||
Jid *from_jid = jid_create(from);
|
||||
@ -309,7 +306,6 @@ handle_delayed_message(char *from, char *message, GTimeVal tv_stamp,
|
||||
}
|
||||
|
||||
ui_incoming_msg(from, new_message, &tv_stamp, priv);
|
||||
ui_current_page_off();
|
||||
|
||||
if (prefs_get_boolean(PREF_CHLOG) && !priv) {
|
||||
Jid *from_jid = jid_create(from);
|
||||
|
@ -52,7 +52,7 @@ _cons_show_time(void)
|
||||
{
|
||||
ProfWin *console = wins_get_console();
|
||||
win_print_time(console, '-');
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -60,7 +60,7 @@ _cons_show_word(const char * const word)
|
||||
{
|
||||
ProfWin *console = wins_get_console();
|
||||
wprintw(console->win, "%s", word);
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -77,11 +77,11 @@ _cons_debug(const char * const msg, ...)
|
||||
g_string_free(fmt_msg, TRUE);
|
||||
va_end(arg);
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
|
||||
ui_current_page_off();
|
||||
ui_refresh();
|
||||
ui_update_screen();
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ _cons_show(const char * const msg, ...)
|
||||
wprintw(console->win, "%s\n", fmt_msg->str);
|
||||
g_string_free(fmt_msg, TRUE);
|
||||
va_end(arg);
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -115,7 +115,7 @@ _cons_show_error(const char * const msg, ...)
|
||||
g_string_free(fmt_msg, TRUE);
|
||||
va_end(arg);
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ _cons_show_typing(const char * const barejid)
|
||||
|
||||
win_vprint_line(console, '-', COLOUR_TYPING, "!! %s is typing a message...", display_usr);
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ _cons_show_incoming_message(const char * const short_from, const int win_index)
|
||||
wprintw(console->win, "<< incoming from %s (%d)\n", short_from, ui_index);
|
||||
wattroff(console->win, COLOUR_INCOMING);
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ _cons_about(void)
|
||||
|
||||
pnoutrefresh(console->win, 0, 0, 1, 0, rows-3, cols-1);
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ _cons_check_version(gboolean not_available_msg)
|
||||
}
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
}
|
||||
@ -254,7 +254,7 @@ _cons_show_login_success(ProfAccount *account)
|
||||
wprintw(console->win, " (priority %d)",
|
||||
accounts_get_priority_for_presence_type(account->name, presence));
|
||||
wprintw(console->win, ".\n");
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ _cons_show_wins(void)
|
||||
}
|
||||
|
||||
cons_show("");
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ _cons_show_room_invites(GSList *invites)
|
||||
}
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -426,7 +426,7 @@ _cons_show_info(PContact pcontact)
|
||||
ordered_resources = g_list_next(ordered_resources);
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -501,7 +501,7 @@ _cons_show_caps(const char * const contact, Resource *resource)
|
||||
}
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -528,7 +528,7 @@ _cons_show_software_version(const char * const jid, const char * const presence
|
||||
cons_show("OS : %s", os);
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -592,7 +592,7 @@ _cons_show_room_list(GSList *rooms, const char * const conference_node)
|
||||
cons_show("No chat rooms at %s", conference_node);
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -622,7 +622,7 @@ _cons_show_bookmarks(const GList *list)
|
||||
list = g_list_next(list);
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -664,7 +664,7 @@ _cons_show_disco_info(const char *jid, GSList *identities, GSList *features)
|
||||
features = g_slist_next(features);
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
}
|
||||
@ -690,7 +690,7 @@ _cons_show_disco_items(GSList *items, const char * const jid)
|
||||
cons_show("");
|
||||
cons_show("No service discovery items for %s", jid);
|
||||
}
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -705,7 +705,7 @@ _cons_show_status(const char * const barejid)
|
||||
} else {
|
||||
cons_show("No such contact \"%s\" in roster.", barejid);
|
||||
}
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -742,7 +742,7 @@ _cons_show_room_invite(const char * const invitor, const char * const room,
|
||||
|
||||
free(display_from);
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -772,7 +772,7 @@ _cons_show_account_list(gchar **accounts)
|
||||
cons_show("");
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -898,7 +898,7 @@ _cons_show_account(ProfAccount *account)
|
||||
}
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1034,7 +1034,7 @@ _cons_show_ui_prefs(void)
|
||||
cons_titlebar_setting();
|
||||
cons_otrwarn_setting();
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1078,7 +1078,7 @@ _cons_show_desktop_prefs(void)
|
||||
cons_show("");
|
||||
cons_notify_setting();
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1142,7 +1142,7 @@ _cons_show_chat_prefs(void)
|
||||
cons_gone_setting();
|
||||
cons_history_setting();
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1194,7 +1194,7 @@ _cons_show_log_prefs(void)
|
||||
cons_grlog_setting();
|
||||
cons_otr_log_setting();
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1230,7 +1230,7 @@ _cons_show_presence_prefs(void)
|
||||
cons_show("");
|
||||
cons_autoaway_setting();
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1276,7 +1276,7 @@ _cons_show_connection_prefs(void)
|
||||
cons_autoping_setting();
|
||||
cons_autoconnect_setting();
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1295,7 +1295,7 @@ _cons_show_themes(GSList *themes)
|
||||
}
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1316,7 +1316,7 @@ _cons_prefs(void)
|
||||
cons_show_connection_prefs();
|
||||
cons_show("");
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1339,7 +1339,7 @@ _cons_help(void)
|
||||
cons_show("/help [command] - Detailed help on a specific command.");
|
||||
cons_show("");
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1361,7 +1361,7 @@ _cons_navigation_help(void)
|
||||
cons_show("PAGE UP, PAGE DOWN : Page the main window.");
|
||||
cons_show("");
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1377,7 +1377,7 @@ _cons_show_roster_group(const char * const group, GSList *list)
|
||||
}
|
||||
|
||||
_show_roster_contacts(list, FALSE);
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1388,7 +1388,7 @@ _cons_show_roster(GSList *list)
|
||||
cons_show("Roster:");
|
||||
|
||||
_show_roster_contacts(list, TRUE);
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
@ -1407,7 +1407,7 @@ _cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_
|
||||
if (wins_is_current(console)) {
|
||||
ui_current_page_off();
|
||||
}
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1423,7 +1423,7 @@ _cons_show_contact_offline(PContact contact, char *resource, char *status)
|
||||
if (wins_is_current(console)) {
|
||||
ui_current_page_off();
|
||||
}
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1441,7 +1441,7 @@ _cons_show_contacts(GSList *list)
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
|
||||
wins_refresh_console();
|
||||
wins_update_virtual_console();
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
|
124
src/ui/core.c
124
src/ui/core.c
@ -95,15 +95,15 @@ _ui_init(void)
|
||||
display = XOpenDisplay(0);
|
||||
#endif
|
||||
ui_idle_time = g_timer_new();
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_refresh(void)
|
||||
_ui_update_screen(void)
|
||||
{
|
||||
_ui_draw_win_title();
|
||||
title_bar_refresh();
|
||||
status_bar_refresh();
|
||||
title_bar_update_virtual();
|
||||
status_bar_update_virtual();
|
||||
inp_put_back();
|
||||
doupdate();
|
||||
}
|
||||
@ -149,7 +149,7 @@ _ui_resize(const int ch, const char * const input, const int size)
|
||||
status_bar_resize();
|
||||
wins_resize_all();
|
||||
inp_win_resize(input, size);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -188,7 +188,7 @@ _ui_contact_typing(const char * const barejid)
|
||||
// have chat window but not currently in it
|
||||
} else if (!wins_is_current(window)) {
|
||||
cons_show_typing(barejid);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
// in chat window with user
|
||||
} else {
|
||||
@ -196,7 +196,7 @@ _ui_contact_typing(const char * const barejid)
|
||||
|
||||
int num = wins_get_num(window);
|
||||
status_bar_active(num);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ _ui_incoming_msg(const char * const from, const char * const message,
|
||||
win_print_incoming_message(window, tv_stamp, display_from, new_message);
|
||||
title_bar_set_typing(FALSE);
|
||||
status_bar_active(num);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
// not currently viewing chat window with sender
|
||||
} else {
|
||||
@ -300,6 +300,12 @@ _ui_incoming_msg(const char * const from, const char * const message,
|
||||
notify_message(display_from, ui_index);
|
||||
|
||||
free(display_from);
|
||||
|
||||
ProfWin *current = wins_get_current();
|
||||
if (!current->paged) {
|
||||
win_move_to_end(current);
|
||||
win_update_virtual(current);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -370,7 +376,7 @@ _ui_handle_recipient_not_found(const char * const recipient, const char * const
|
||||
win_print_line(win, '!', COLOUR_ERROR, msg->str);
|
||||
}
|
||||
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
g_string_free(msg, TRUE);
|
||||
}
|
||||
@ -390,7 +396,7 @@ _ui_handle_recipient_error(const char * const recipient, const char * const err_
|
||||
win_print_line(win, '!', COLOUR_ERROR, msg->str);
|
||||
}
|
||||
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
g_string_free(msg, TRUE);
|
||||
}
|
||||
@ -403,7 +409,7 @@ _ui_handle_error(const char * const err_msg)
|
||||
|
||||
cons_show_error(msg->str);
|
||||
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
g_string_free(msg, TRUE);
|
||||
}
|
||||
@ -414,7 +420,7 @@ _ui_disconnected(void)
|
||||
wins_lost_connection();
|
||||
title_bar_set_presence(CONTACT_OFFLINE);
|
||||
status_bar_clear_message();
|
||||
status_bar_refresh();
|
||||
status_bar_update_virtual();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -528,12 +534,12 @@ _get_recipient_string(ProfWin *window)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
_ui_switch_win(const int i)
|
||||
{
|
||||
ui_current_page_off();
|
||||
ProfWin *new_current = wins_get_by_num(i);
|
||||
if (new_current != NULL) {
|
||||
if (ui_win_exists(i)) {
|
||||
ui_current_page_off();
|
||||
ProfWin *new_current = wins_get_by_num(i);
|
||||
wins_set_current_by_num(i);
|
||||
ui_current_page_off();
|
||||
|
||||
@ -550,12 +556,15 @@ _ui_switch_win(const int i)
|
||||
status_bar_current(i);
|
||||
status_bar_active(i);
|
||||
}
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_current_refresh(void)
|
||||
_ui_current_update_virtual(void)
|
||||
{
|
||||
ui_switch_win(wins_get_current_num());
|
||||
}
|
||||
@ -582,7 +591,7 @@ _ui_next_win(void)
|
||||
status_bar_current(i);
|
||||
status_bar_active(i);
|
||||
}
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -602,7 +611,7 @@ _ui_gone_secure(const char * const recipient, gboolean trusted)
|
||||
GString *recipient_str = _get_recipient_string(window);
|
||||
title_bar_set_recipient(recipient_str->str);
|
||||
g_string_free(recipient_str, TRUE);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -620,7 +629,7 @@ _ui_gone_insecure(const char * const recipient)
|
||||
GString *recipient_str = _get_recipient_string(window);
|
||||
title_bar_set_recipient(recipient_str->str);
|
||||
g_string_free(recipient_str, TRUE);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -638,7 +647,7 @@ _ui_trust(const char * const recipient)
|
||||
GString *recipient_str = _get_recipient_string(window);
|
||||
title_bar_set_recipient(recipient_str->str);
|
||||
g_string_free(recipient_str, TRUE);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -656,7 +665,7 @@ _ui_untrust(const char * const recipient)
|
||||
GString *recipient_str = _get_recipient_string(window);
|
||||
title_bar_set_recipient(recipient_str->str);
|
||||
g_string_free(recipient_str, TRUE);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -683,7 +692,7 @@ _ui_previous_win(void)
|
||||
status_bar_current(i);
|
||||
status_bar_active(i);
|
||||
}
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -711,7 +720,7 @@ _ui_close_win(int index)
|
||||
status_bar_current(1);
|
||||
status_bar_active(1);
|
||||
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -830,7 +839,7 @@ _ui_current_print_line(const char * const msg, ...)
|
||||
win_print_line(current, '-', 0, fmt_msg->str);
|
||||
va_end(arg);
|
||||
g_string_free(fmt_msg, TRUE);
|
||||
win_refresh(current);
|
||||
win_update_virtual(current);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -844,7 +853,7 @@ _ui_current_print_formatted_line(const char show_char, int attrs, const char * c
|
||||
win_print_line(current, show_char, attrs, fmt_msg->str);
|
||||
va_end(arg);
|
||||
g_string_free(fmt_msg, TRUE);
|
||||
win_refresh(current);
|
||||
win_update_virtual(current);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -852,15 +861,15 @@ _ui_current_error_line(const char * const msg)
|
||||
{
|
||||
ProfWin *current = wins_get_current();
|
||||
win_print_line(current, '-', COLOUR_ERROR, msg);
|
||||
win_refresh(current);
|
||||
win_update_virtual(current);
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_current_page_off(void)
|
||||
{
|
||||
ProfWin *current = wins_get_current();
|
||||
win_page_off(current);
|
||||
win_refresh(current);
|
||||
win_move_to_end(current);
|
||||
win_update_virtual(current);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -894,7 +903,7 @@ _ui_print_system_msg_from_recipient(const char * const from, const char *message
|
||||
|
||||
// this is the current window
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -916,7 +925,7 @@ _ui_recipient_gone(const char * const barejid)
|
||||
if (window != NULL) {
|
||||
win_vprint_line(window, '!', COLOUR_GONE, "<- %s has left the conversation.", display_usr);
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1153,7 +1162,7 @@ _ui_room_roster(const char * const room, GList *roster, const char * const prese
|
||||
}
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1168,7 +1177,7 @@ _ui_room_member_offline(const char * const room, const char * const nick)
|
||||
wattroff(window->win, COLOUR_OFFLINE);
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1184,7 +1193,7 @@ _ui_room_member_online(const char * const room, const char * const nick,
|
||||
wattroff(window->win, COLOUR_ONLINE);
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1199,7 +1208,7 @@ _ui_room_member_presence(const char * const room, const char * const nick,
|
||||
}
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1215,7 +1224,7 @@ _ui_room_member_nick_change(const char * const room,
|
||||
wattroff(window->win, COLOUR_THEM);
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1230,7 +1239,7 @@ _ui_room_nick_change(const char * const room, const char * const nick)
|
||||
wattroff(window->win, COLOUR_ME);
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1256,7 +1265,7 @@ _ui_room_history(const char * const room_jid, const char * const nick,
|
||||
}
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1296,14 +1305,14 @@ _ui_room_message(const char * const room_jid, const char * const nick,
|
||||
// currently in groupchat window
|
||||
if (wins_is_current(window)) {
|
||||
status_bar_active(num);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
// not currenlty on groupchat window
|
||||
} else {
|
||||
status_bar_new(num);
|
||||
cons_show_incoming_message(nick, num);
|
||||
if (wins_get_current_num() == 0) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
|
||||
if (strcmp(nick, muc_get_room_nick(room_jid)) != 0) {
|
||||
@ -1330,6 +1339,12 @@ _ui_room_message(const char * const room_jid, const char * const nick,
|
||||
jid_destroy(jidp);
|
||||
}
|
||||
}
|
||||
|
||||
ProfWin *current = wins_get_current();
|
||||
if (!current->paged) {
|
||||
win_move_to_end(current);
|
||||
win_update_virtual(current);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1347,7 +1362,7 @@ _ui_room_subject(const char * const room_jid, const char * const subject)
|
||||
// currently in groupchat window
|
||||
if (wins_is_current(window)) {
|
||||
status_bar_active(num);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
// not currenlty on groupchat window
|
||||
} else {
|
||||
@ -1370,7 +1385,7 @@ _ui_room_broadcast(const char * const room_jid, const char * const message)
|
||||
// currently in groupchat window
|
||||
if (wins_is_current(window)) {
|
||||
status_bar_active(num);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
// not currenlty on groupchat window
|
||||
} else {
|
||||
@ -1443,7 +1458,7 @@ _ui_ask_password(void)
|
||||
{
|
||||
char *passwd = malloc(sizeof(char) * (MAX_PASSWORD_SIZE + 1));
|
||||
status_bar_get_password();
|
||||
status_bar_refresh();
|
||||
status_bar_update_virtual();
|
||||
inp_block();
|
||||
inp_get_password(passwd);
|
||||
inp_non_block();
|
||||
@ -1464,7 +1479,7 @@ _ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *las
|
||||
last_activity, "++", "online");
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
ui_current_page_off();
|
||||
}
|
||||
}
|
||||
@ -1484,7 +1499,7 @@ _ui_chat_win_contact_offline(PContact contact, char *resource, char *status)
|
||||
"offline");
|
||||
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
ui_current_page_off();
|
||||
}
|
||||
}
|
||||
@ -1625,7 +1640,7 @@ _win_handle_page(const wint_t * const ch)
|
||||
*page_start = y - page_space;
|
||||
|
||||
current->paged = 1;
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
} else if (mouse_event.bstate & BUTTON4_PRESSED) { // mouse wheel up
|
||||
*page_start -= 4;
|
||||
|
||||
@ -1634,7 +1649,7 @@ _win_handle_page(const wint_t * const ch)
|
||||
*page_start = 0;
|
||||
|
||||
current->paged = 1;
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1649,7 +1664,7 @@ _win_handle_page(const wint_t * const ch)
|
||||
*page_start = 0;
|
||||
|
||||
current->paged = 1;
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
|
||||
// page down
|
||||
} else if (*ch == KEY_NPAGE) {
|
||||
@ -1664,7 +1679,12 @@ _win_handle_page(const wint_t * const ch)
|
||||
*page_start = y - page_space;
|
||||
|
||||
current->paged = 1;
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
|
||||
// switch off page if last line visible
|
||||
if ((y-1) - *page_start == page_space) {
|
||||
current->paged = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1691,7 +1711,7 @@ void
|
||||
ui_init_module(void)
|
||||
{
|
||||
ui_init = _ui_init;
|
||||
ui_refresh = _ui_refresh;
|
||||
ui_update_screen = _ui_update_screen;
|
||||
ui_get_idle_time = _ui_get_idle_time;
|
||||
ui_reset_idle_time = _ui_reset_idle_time;
|
||||
ui_close = _ui_close;
|
||||
@ -1766,5 +1786,5 @@ ui_init_module(void)
|
||||
ui_handle_recipient_not_found = _ui_handle_recipient_not_found;
|
||||
ui_handle_recipient_error = _ui_handle_recipient_error;
|
||||
ui_handle_error = _ui_handle_error;
|
||||
ui_current_refresh = _ui_current_refresh;
|
||||
ui_current_update_virtual = _ui_current_update_virtual;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "ui/windows.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
|
||||
#define _inp_win_refresh() pnoutrefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1)
|
||||
#define _inp_win_update_virtual() pnoutrefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1)
|
||||
|
||||
static WINDOW *inp_win;
|
||||
static int pad_start = 0;
|
||||
@ -71,7 +71,7 @@ _create_input_window(void)
|
||||
wbkgd(inp_win, COLOUR_INPUT_TEXT);
|
||||
keypad(inp_win, TRUE);
|
||||
wmove(inp_win, 0, 0);
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -89,7 +89,7 @@ _inp_win_resize(const char * const input, const int size)
|
||||
}
|
||||
}
|
||||
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -165,7 +165,7 @@ _inp_get_char(char *input, int *size)
|
||||
|
||||
if (inp_x - pad_start > cols-3) {
|
||||
pad_start++;
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
// otherwise just append
|
||||
@ -189,7 +189,7 @@ _inp_get_char(char *input, int *size)
|
||||
getmaxyx(stdscr, rows, cols);
|
||||
if (display_size - pad_start > cols-2) {
|
||||
pad_start++;
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -207,7 +207,7 @@ static void
|
||||
_inp_get_password(char *passwd)
|
||||
{
|
||||
_clear_input();
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
doupdate();
|
||||
noecho();
|
||||
mvwgetnstr(inp_win, 0, 1, passwd, MAX_PASSWORD_SIZE);
|
||||
@ -219,7 +219,7 @@ _inp_get_password(char *passwd)
|
||||
static void
|
||||
_inp_put_back(void)
|
||||
{
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -240,7 +240,7 @@ _inp_win_reset(void)
|
||||
{
|
||||
_clear_input();
|
||||
pad_start = 0;
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -316,7 +316,7 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
||||
pad_start = 0;
|
||||
}
|
||||
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
return 1;
|
||||
|
||||
@ -358,7 +358,7 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
||||
// if gone off screen to right, jump right (half a screen worth)
|
||||
if (inp_x > pad_start + cols) {
|
||||
pad_start = pad_start + (cols / 2);
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -444,7 +444,7 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
||||
// current position off screen to left
|
||||
if (inp_x - 1 < pad_start) {
|
||||
pad_start--;
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -459,7 +459,7 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
||||
// current position off screen to right
|
||||
if ((inp_x + 1 - pad_start) >= cols) {
|
||||
pad_start++;
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -494,7 +494,7 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
||||
}
|
||||
wmove(inp_win, 0, 0);
|
||||
pad_start = 0;
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
return 1;
|
||||
|
||||
case KEY_END:
|
||||
@ -562,7 +562,7 @@ _handle_backspace(int display_size, int inp_x, int *size, char *input)
|
||||
pad_start = 0;
|
||||
}
|
||||
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ _handle_alt_key(char *input, int *size, int key)
|
||||
pad_start = 0;
|
||||
}
|
||||
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -691,7 +691,7 @@ _go_to_end(int display_size)
|
||||
wmove(inp_win, 0, display_size);
|
||||
if (display_size > cols-2) {
|
||||
pad_start = display_size - cols + 1;
|
||||
_inp_win_refresh();
|
||||
_inp_win_update_virtual();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ _create_status_bar(void)
|
||||
}
|
||||
|
||||
static void
|
||||
_status_bar_refresh(void)
|
||||
_status_bar_update_virtual(void)
|
||||
{
|
||||
GDateTime *now_time = g_date_time_new_now_local();
|
||||
GTimeSpan elapsed = g_date_time_difference(now_time, last_time);
|
||||
@ -426,7 +426,7 @@ void
|
||||
statusbar_init_module(void)
|
||||
{
|
||||
create_status_bar = _create_status_bar;
|
||||
status_bar_refresh = _status_bar_refresh;
|
||||
status_bar_update_virtual = _status_bar_update_virtual;
|
||||
status_bar_resize = _status_bar_resize;
|
||||
status_bar_set_all_inactive = _status_bar_set_all_inactive;
|
||||
status_bar_current = _status_bar_current;
|
||||
|
@ -82,7 +82,7 @@ _title_bar_resize(void)
|
||||
}
|
||||
|
||||
static void
|
||||
_title_bar_refresh(void)
|
||||
_title_bar_update_virtual(void)
|
||||
{
|
||||
if (current_recipient != NULL) {
|
||||
|
||||
@ -264,7 +264,7 @@ titlebar_init_module(void)
|
||||
create_title_bar = _create_title_bar;
|
||||
title_bar_console = _title_bar_console;
|
||||
title_bar_resize = _title_bar_resize;
|
||||
title_bar_refresh = _title_bar_refresh;
|
||||
title_bar_update_virtual = _title_bar_update_virtual;
|
||||
title_bar_set_presence = _title_bar_set_presence;
|
||||
title_bar_set_recipient = _title_bar_set_recipient;
|
||||
title_bar_set_typing = _title_bar_set_typing;
|
||||
|
10
src/ui/ui.h
10
src/ui/ui.h
@ -51,14 +51,14 @@ void titlebar_init_module(void);
|
||||
// ui startup and control
|
||||
void (*ui_init)(void);
|
||||
void (*ui_load_colours)(void);
|
||||
void (*ui_refresh)(void);
|
||||
void (*ui_update_screen)(void);
|
||||
void (*ui_close)(void);
|
||||
void (*ui_resize)(const int ch, const char * const input,
|
||||
const int size);
|
||||
GSList* (*ui_get_recipients)(void);
|
||||
void (*ui_handle_special_keys)(const wint_t * const ch, const char * const inp,
|
||||
const int size);
|
||||
void (*ui_switch_win)(const int i);
|
||||
gboolean (*ui_switch_win)(const int i);
|
||||
void (*ui_next_win)(void);
|
||||
void (*ui_previous_win)(void);
|
||||
void (*ui_gone_secure)(const char * const recipient, gboolean trusted);
|
||||
@ -86,7 +86,7 @@ void (*ui_current_print_line)(const char * const msg, ...);
|
||||
void (*ui_current_print_formatted_line)(const char show_char, int attrs, const char * const msg, ...);
|
||||
void (*ui_current_error_line)(const char * const msg);
|
||||
void (*ui_current_page_off)(void);
|
||||
void (*ui_current_refresh)(void);
|
||||
void (*ui_current_update_virtual)(void);
|
||||
|
||||
win_type_t (*ui_win_type)(int index);
|
||||
char * (*ui_recipient)(int index);
|
||||
@ -153,7 +153,7 @@ void (*create_status_bar)(void);
|
||||
void (*create_input_window)(void);
|
||||
|
||||
// title bar actions
|
||||
void (*title_bar_refresh)(void);
|
||||
void (*title_bar_update_virtual)(void);
|
||||
void (*title_bar_resize)(void);
|
||||
void (*title_bar_console)(void);
|
||||
void (*title_bar_set_presence)(contact_presence_t presence);
|
||||
@ -233,7 +233,7 @@ void (*cons_show_contact_online)(PContact contact, Resource *resource, GDateTime
|
||||
void (*cons_show_contact_offline)(PContact contact, char *resource, char *status);
|
||||
|
||||
// status bar actions
|
||||
void (*status_bar_refresh)(void);
|
||||
void (*status_bar_update_virtual)(void);
|
||||
void (*status_bar_resize)(void);
|
||||
void (*status_bar_clear)(void);
|
||||
void (*status_bar_clear_message)(void);
|
||||
|
@ -106,7 +106,7 @@ win_vprint_line(ProfWin *window, const char show_char, int attrs,
|
||||
}
|
||||
|
||||
void
|
||||
win_refresh(ProfWin *window)
|
||||
win_update_virtual(ProfWin *window)
|
||||
{
|
||||
int rows, cols;
|
||||
getmaxyx(stdscr, rows, cols);
|
||||
@ -114,7 +114,7 @@ win_refresh(ProfWin *window)
|
||||
}
|
||||
|
||||
void
|
||||
win_page_off(ProfWin *window)
|
||||
win_move_to_end(ProfWin *window)
|
||||
{
|
||||
window->paged = 0;
|
||||
|
||||
|
@ -63,8 +63,8 @@ void win_vprint_line(ProfWin *self, const char show_char, int attrs,
|
||||
const char * const msg, ...);
|
||||
void win_print_line(ProfWin *self, const char show_char, int attrs,
|
||||
const char * const msg);
|
||||
void win_refresh(ProfWin *window);
|
||||
void win_page_off(ProfWin *window);
|
||||
void win_update_virtual(ProfWin *window);
|
||||
void win_move_to_end(ProfWin *window);
|
||||
void win_print_time(ProfWin *window, char show_char);
|
||||
void win_presence_colour_on(ProfWin *window, const char * const presence);
|
||||
void win_presence_colour_off(ProfWin *window, const char * const presence);
|
||||
|
@ -197,7 +197,7 @@ wins_close_by_num(int i)
|
||||
if (i != 1) {
|
||||
if (i == current) {
|
||||
current = 1;
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
g_hash_table_remove(windows, GINT_TO_POINTER(i));
|
||||
status_bar_inactive(i);
|
||||
@ -205,10 +205,10 @@ wins_close_by_num(int i)
|
||||
}
|
||||
|
||||
void
|
||||
wins_refresh_current(void)
|
||||
wins_update_virtual_current(void)
|
||||
{
|
||||
ProfWin *window = wins_get_current();
|
||||
win_refresh(window);
|
||||
win_update_virtual(window);
|
||||
}
|
||||
|
||||
void
|
||||
@ -216,7 +216,7 @@ wins_clear_current(void)
|
||||
{
|
||||
ProfWin *window = wins_get_current();
|
||||
werase(window->win);
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -283,10 +283,10 @@ wins_resize_all(void)
|
||||
}
|
||||
|
||||
void
|
||||
wins_refresh_console(void)
|
||||
wins_update_virtual_console(void)
|
||||
{
|
||||
if (current == 0) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ wins_lost_connection(void)
|
||||
|
||||
// if current win, set current_win_dirty
|
||||
if (wins_is_current(window)) {
|
||||
wins_refresh_current();
|
||||
wins_update_virtual_current();
|
||||
}
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
|
@ -37,8 +37,8 @@ int wins_get_num(ProfWin *window);
|
||||
int wins_get_current_num(void);
|
||||
void wins_close_current(void);
|
||||
void wins_close_by_num(int i);
|
||||
void wins_refresh_current(void);
|
||||
void wins_refresh_console(void);
|
||||
void wins_update_virtual_current(void);
|
||||
void wins_update_virtual_console(void);
|
||||
void wins_clear_current(void);
|
||||
gboolean wins_is_current(ProfWin *window);
|
||||
ProfWin * wins_new(const char * const from, win_type_t type);
|
||||
|
@ -439,7 +439,7 @@ _connection_handler(xmpp_conn_t * const conn,
|
||||
iq_add_handlers();
|
||||
|
||||
roster_request();
|
||||
// bookmark_request();
|
||||
bookmark_request();
|
||||
jabber_conn.conn_status = JABBER_CONNECTED;
|
||||
|
||||
if (prefs_get_reconnect() != 0) {
|
||||
|
@ -36,8 +36,9 @@
|
||||
|
||||
static int _field_compare(FormField *f1, FormField *f2);
|
||||
|
||||
#if 0
|
||||
xmpp_stanza_t *
|
||||
stanza_create_storage_bookmarks(xmpp_ctx_t *ctx)
|
||||
stanza_create_pubsub_bookmarks(xmpp_ctx_t *ctx)
|
||||
{
|
||||
xmpp_stanza_t *iq, *pubsub, *items;
|
||||
|
||||
@ -62,8 +63,8 @@ stanza_create_storage_bookmarks(xmpp_ctx_t *ctx)
|
||||
|
||||
return iq;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
xmpp_stanza_t *
|
||||
stanza_create_storage_bookmarks(xmpp_ctx_t *ctx)
|
||||
{
|
||||
@ -91,7 +92,6 @@ stanza_create_storage_bookmarks(xmpp_ctx_t *ctx)
|
||||
|
||||
return iq;
|
||||
}
|
||||
#endif
|
||||
|
||||
xmpp_stanza_t *
|
||||
stanza_create_chat_state(xmpp_ctx_t *ctx, const char * const recipient,
|
||||
|
@ -179,7 +179,7 @@ void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state)
|
||||
void cmd_otr_warn_shows_usage_when_no_args(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
stub_ui_current_refresh();
|
||||
stub_ui_current_update_virtual();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "Some usage";
|
||||
gchar *args[] = { "warn", NULL };
|
||||
@ -195,7 +195,7 @@ void cmd_otr_warn_shows_usage_when_no_args(void **state)
|
||||
void cmd_otr_warn_shows_usage_when_invalid_arg(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
stub_ui_current_refresh();
|
||||
stub_ui_current_update_virtual();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "Some usage";
|
||||
gchar *args[] = { "warn", "badarg", NULL };
|
||||
@ -211,7 +211,7 @@ void cmd_otr_warn_shows_usage_when_invalid_arg(void **state)
|
||||
void cmd_otr_warn_on_enables_unencrypted_warning(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
stub_ui_current_refresh();
|
||||
stub_ui_current_update_virtual();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "warn", "on", NULL };
|
||||
|
||||
@ -230,7 +230,7 @@ void cmd_otr_warn_on_enables_unencrypted_warning(void **state)
|
||||
void cmd_otr_warn_off_disables_unencrypted_warning(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
stub_ui_current_refresh();
|
||||
stub_ui_current_update_virtual();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "warn", "off", NULL };
|
||||
|
||||
|
39
tests/test_cmd_win.c
Normal file
39
tests/test_cmd_win.c
Normal file
@ -0,0 +1,39 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "ui/ui.h"
|
||||
#include "ui/mock_ui.h"
|
||||
|
||||
#include "command/commands.h"
|
||||
|
||||
void cmd_win_shows_message_when_win_doesnt_exist(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "3", NULL };
|
||||
|
||||
ui_switch_win_expect_and_return(3, FALSE);
|
||||
expect_cons_show("Window 3 does not exist.");
|
||||
|
||||
gboolean result = cmd_win(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_win_switches_to_given_win_when_exists(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
gchar *args[] = { "12", NULL };
|
||||
|
||||
ui_switch_win_expect_and_return(12, TRUE);
|
||||
|
||||
gboolean result = cmd_win(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
2
tests/test_cmd_win.h
Normal file
2
tests/test_cmd_win.h
Normal file
@ -0,0 +1,2 @@
|
||||
void cmd_win_shows_message_when_win_doesnt_exist(void **state);
|
||||
void cmd_win_switches_to_given_win_when_exists(void **state);
|
@ -30,6 +30,7 @@
|
||||
#include "test_cmd_join.h"
|
||||
#include "test_muc.h"
|
||||
#include "test_cmd_roster.h"
|
||||
#include "test_cmd_win.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
const UnitTest all_tests[] = {
|
||||
@ -518,6 +519,9 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_roster_clearnick_shows_message_when_no_jid),
|
||||
unit_test(cmd_roster_clearnick_shows_message_when_no_contact_exists),
|
||||
unit_test(cmd_roster_clearnick_sends_name_change_request_with_empty_nick),
|
||||
|
||||
unit_test(cmd_win_shows_message_when_win_doesnt_exist),
|
||||
unit_test(cmd_win_switches_to_given_win_when_exists),
|
||||
};
|
||||
|
||||
return run_tests(all_tests);
|
||||
|
@ -133,7 +133,7 @@ void _stub_ui_handle_recipient_not_found(const char * const recipient, const cha
|
||||
}
|
||||
|
||||
static
|
||||
void _stub_ui_current_refresh(void)
|
||||
void _stub_ui_current_update_virtual(void)
|
||||
{
|
||||
}
|
||||
|
||||
@ -177,13 +177,19 @@ void _mock_cons_show_roster(GSList *list)
|
||||
check_expected(list);
|
||||
}
|
||||
|
||||
static
|
||||
gboolean _mock_ui_switch_win(const int i)
|
||||
{
|
||||
check_expected(i);
|
||||
return (gboolean)mock();
|
||||
}
|
||||
|
||||
// bind mocks and stubs
|
||||
|
||||
void
|
||||
mock_cons_show(void)
|
||||
{
|
||||
cons_show = _mock_cons_show;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@ -265,9 +271,9 @@ stub_ui_handle_recipient_error(void)
|
||||
}
|
||||
|
||||
void
|
||||
stub_ui_current_refresh(void)
|
||||
stub_ui_current_update_virtual(void)
|
||||
{
|
||||
ui_current_refresh = _stub_ui_current_refresh;
|
||||
ui_current_update_virtual = _stub_ui_current_update_virtual;
|
||||
}
|
||||
|
||||
void
|
||||
@ -438,3 +444,11 @@ cons_show_roster_expect(GSList *list)
|
||||
{
|
||||
expect_any(_mock_cons_show_roster, list);
|
||||
}
|
||||
|
||||
void
|
||||
ui_switch_win_expect_and_return(int given_i, gboolean result)
|
||||
{
|
||||
ui_switch_win = _mock_ui_switch_win;
|
||||
expect_value(_mock_ui_switch_win, i, given_i);
|
||||
will_return(_mock_ui_switch_win, result);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ void mock_current_win_type(win_type_t type);
|
||||
void mock_ui_current_recipient(void);
|
||||
void ui_current_recipient_returns(char *jid);
|
||||
|
||||
void stub_ui_current_refresh(void);
|
||||
void stub_ui_current_update_virtual(void);
|
||||
|
||||
void mock_ui_current_print_formatted_line(void);
|
||||
void ui_current_print_formatted_line_expect(char show_char, int attrs, char *message);
|
||||
@ -64,4 +64,6 @@ void ui_room_join_expect(char *room);
|
||||
void mock_cons_show_roster(void);
|
||||
void cons_show_roster_expect(GSList *list);
|
||||
|
||||
void ui_switch_win_expect_and_return(int given_i, gboolean result);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user