mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Moved new chat win events to client events module
This commit is contained in:
parent
53f2a4a35c
commit
88739d5c59
@ -738,7 +738,7 @@ gboolean
|
|||||||
cmd_win(gchar **args, struct cmd_help_t help)
|
cmd_win(gchar **args, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
int num = atoi(args[0]);
|
int num = atoi(args[0]);
|
||||||
gboolean switched = ui_switch_win(num);
|
gboolean switched = ui_switch_win_num(num);
|
||||||
if (switched == FALSE) {
|
if (switched == FALSE) {
|
||||||
cons_show("Window %d does not exist.", num);
|
cons_show("Window %d does not exist.", num);
|
||||||
}
|
}
|
||||||
@ -1347,7 +1347,13 @@ cmd_msg(gchar **args, struct cmd_help_t help)
|
|||||||
client_send_msg(barejid, msg);
|
client_send_msg(barejid, msg);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
ui_new_chat_win(barejid);
|
ProfWin *window = (ProfWin*)wins_get_chat(barejid);
|
||||||
|
if (window) {
|
||||||
|
client_focus_win(window);
|
||||||
|
} else {
|
||||||
|
client_new_chat_win(barejid);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
if (otr_is_secure(barejid)) {
|
if (otr_is_secure(barejid)) {
|
||||||
ui_gone_secure(barejid, otr_is_trusted(barejid));
|
ui_gone_secure(barejid, otr_is_trusted(barejid));
|
||||||
@ -2467,7 +2473,7 @@ cmd_form(gchar **args, struct cmd_help_t help)
|
|||||||
current = wins_get_console();
|
current = wins_get_console();
|
||||||
}
|
}
|
||||||
int num = wins_get_num(current);
|
int num = wins_get_num(current);
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2775,7 +2781,7 @@ cmd_room(gchar **args, struct cmd_help_t help)
|
|||||||
|
|
||||||
if (confwin != NULL) {
|
if (confwin != NULL) {
|
||||||
num = wins_get_num(window);
|
num = wins_get_num(window);
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
} else {
|
} else {
|
||||||
iq_request_room_config_form(mucwin->roomjid);
|
iq_request_room_config_form(mucwin->roomjid);
|
||||||
}
|
}
|
||||||
@ -4180,7 +4186,12 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
|||||||
barejid = contact;
|
barejid = contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_new_chat_win(barejid);
|
ProfWin *window = (ProfWin*)wins_get_chat(barejid);
|
||||||
|
if (window) {
|
||||||
|
client_focus_win(window);
|
||||||
|
} else {
|
||||||
|
client_new_chat_win(barejid);
|
||||||
|
}
|
||||||
|
|
||||||
if (ui_current_win_is_otr()) {
|
if (ui_current_win_is_otr()) {
|
||||||
ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
|
ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
|
||||||
|
@ -96,4 +96,17 @@ client_send_priv_msg(const char * const fulljid, const char * const msg)
|
|||||||
{
|
{
|
||||||
message_send_private(fulljid, msg);
|
message_send_private(fulljid, msg);
|
||||||
ui_outgoing_private_msg(fulljid, msg);
|
ui_outgoing_private_msg(fulljid, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_focus_win(ProfWin *win)
|
||||||
|
{
|
||||||
|
ui_switch_win(win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_new_chat_win(const char * const barejid)
|
||||||
|
{
|
||||||
|
ProfWin *win = ui_new_chat_win(barejid);
|
||||||
|
ui_switch_win(win);
|
||||||
}
|
}
|
@ -39,4 +39,7 @@ void client_send_msg(const char * const barejid, const char * const msg);
|
|||||||
void client_send_muc_msg(const char * const roomjid, const char * const msg);
|
void client_send_muc_msg(const char * const roomjid, const char * const msg);
|
||||||
void client_send_priv_msg(const char * const fulljid, const char * const msg);
|
void client_send_priv_msg(const char * const fulljid, const char * const msg);
|
||||||
|
|
||||||
|
void client_focus_win(ProfWin *win);
|
||||||
|
void client_new_chat_win(const char * const barejid);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -878,7 +878,14 @@ ui_win_has_unsaved_form(int num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ui_switch_win(const int i)
|
ui_switch_win(ProfWin *win)
|
||||||
|
{
|
||||||
|
int num = wins_get_num(win);
|
||||||
|
return ui_switch_win_num(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ui_switch_win_num(const int i)
|
||||||
{
|
{
|
||||||
if (ui_win_exists(i)) {
|
if (ui_win_exists(i)) {
|
||||||
ProfWin *old_current = wins_get_current();
|
ProfWin *old_current = wins_get_current();
|
||||||
@ -1358,6 +1365,30 @@ ui_recipient_gone(const char * const barejid, const char * const resource)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProfWin*
|
||||||
|
ui_new_chat_win(const char * const barejid)
|
||||||
|
{
|
||||||
|
ProfWin* window = wins_new_chat(barejid);
|
||||||
|
|
||||||
|
int num = wins_get_num(window);
|
||||||
|
|
||||||
|
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
||||||
|
_win_show_history(num, barejid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the contact is offline, show a message
|
||||||
|
PContact contact = roster_get_contact(barejid);
|
||||||
|
if (contact != NULL) {
|
||||||
|
if (strcmp(p_contact_presence(contact), "offline") == 0) {
|
||||||
|
const char * const show = p_contact_presence(contact);
|
||||||
|
const char * const status = p_contact_status(contact);
|
||||||
|
win_show_status_string(window, barejid, show, status, NULL, "--", "offline");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_new_private_win(const char * const fulljid)
|
ui_new_private_win(const char * const fulljid)
|
||||||
{
|
{
|
||||||
@ -1372,39 +1403,7 @@ ui_new_private_win(const char * const fulljid)
|
|||||||
num = wins_get_num(window);
|
num = wins_get_num(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ui_new_chat_win(const char * const barejid)
|
|
||||||
{
|
|
||||||
ProfWin *window = (ProfWin*)wins_get_chat(barejid);
|
|
||||||
int num = 0;
|
|
||||||
|
|
||||||
// create new window
|
|
||||||
if (window == NULL) {
|
|
||||||
window = wins_new_chat(barejid);
|
|
||||||
|
|
||||||
num = wins_get_num(window);
|
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
|
||||||
_win_show_history(num, barejid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the contact is offline, show a message
|
|
||||||
PContact contact = roster_get_contact(barejid);
|
|
||||||
if (contact != NULL) {
|
|
||||||
if (strcmp(p_contact_presence(contact), "offline") == 0) {
|
|
||||||
const char * const show = p_contact_presence(contact);
|
|
||||||
const char * const status = p_contact_status(contact);
|
|
||||||
win_show_status_string(window, barejid, show, status, NULL, "--", "offline");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
num = wins_get_num(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_switch_win(num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1412,7 +1411,7 @@ ui_create_xmlconsole_win(void)
|
|||||||
{
|
{
|
||||||
ProfWin *window = wins_new_xmlconsole();
|
ProfWin *window = wins_new_xmlconsole();
|
||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1421,7 +1420,7 @@ ui_open_xmlconsole_win(void)
|
|||||||
ProfXMLWin *xmlwin = wins_get_xmlconsole();
|
ProfXMLWin *xmlwin = wins_get_xmlconsole();
|
||||||
if (xmlwin != NULL) {
|
if (xmlwin != NULL) {
|
||||||
int num = wins_get_num((ProfWin*)xmlwin);
|
int num = wins_get_num((ProfWin*)xmlwin);
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1467,7 +1466,7 @@ ui_outgoing_chat_msg(const char * const barejid, const char * const message, cha
|
|||||||
} else {
|
} else {
|
||||||
win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message);
|
win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message);
|
||||||
}
|
}
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1528,7 +1527,7 @@ ui_outgoing_private_msg(const char * const fulljid, const char * const message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message);
|
win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message);
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1559,7 +1558,7 @@ ui_room_join(const char * const roomjid, gboolean focus)
|
|||||||
num = wins_get_num(window);
|
num = wins_get_num(window);
|
||||||
|
|
||||||
if (focus) {
|
if (focus) {
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
} else {
|
} else {
|
||||||
status_bar_active(num);
|
status_bar_active(num);
|
||||||
ProfWin *console = wins_get_console();
|
ProfWin *console = wins_get_console();
|
||||||
@ -1573,8 +1572,7 @@ ui_switch_to_room(const char * const roomjid)
|
|||||||
{
|
{
|
||||||
ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
|
ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
|
||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
num = wins_get_num(window);
|
ui_switch_win_num(num);
|
||||||
ui_switch_win(num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -2747,7 +2745,7 @@ ui_handle_room_configuration(const char * const roomjid, DataForm *form)
|
|||||||
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
|
assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
|
||||||
|
|
||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
|
|
||||||
ui_show_form(confwin);
|
ui_show_form(confwin);
|
||||||
|
|
||||||
@ -2804,10 +2802,10 @@ ui_handle_room_config_submit_result(const char * const roomjid)
|
|||||||
|
|
||||||
if (muc_window) {
|
if (muc_window) {
|
||||||
int num = wins_get_num(muc_window);
|
int num = wins_get_num(muc_window);
|
||||||
ui_switch_win(num);
|
ui_switch_win_num(num);
|
||||||
win_print(muc_window, '!', NULL, 0, THEME_ROOMINFO, "", "Room configuration successful");
|
win_print(muc_window, '!', NULL, 0, THEME_ROOMINFO, "", "Room configuration successful");
|
||||||
} else {
|
} else {
|
||||||
ui_switch_win(1);
|
ui_switch_win_num(1);
|
||||||
cons_show("Room configuration successful: %s", roomjid);
|
cons_show("Room configuration successful: %s", roomjid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -452,70 +452,70 @@ _inp_rl_tab_handler(int count, int key)
|
|||||||
static int
|
static int
|
||||||
_inp_rl_win1_handler(int count, int key)
|
_inp_rl_win1_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(1);
|
ui_switch_win_num(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win2_handler(int count, int key)
|
_inp_rl_win2_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(2);
|
ui_switch_win_num(2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win3_handler(int count, int key)
|
_inp_rl_win3_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(3);
|
ui_switch_win_num(3);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win4_handler(int count, int key)
|
_inp_rl_win4_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(4);
|
ui_switch_win_num(4);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win5_handler(int count, int key)
|
_inp_rl_win5_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(5);
|
ui_switch_win_num(5);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win6_handler(int count, int key)
|
_inp_rl_win6_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(6);
|
ui_switch_win_num(6);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win7_handler(int count, int key)
|
_inp_rl_win7_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(7);
|
ui_switch_win_num(7);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win8_handler(int count, int key)
|
_inp_rl_win8_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(8);
|
ui_switch_win_num(8);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win9_handler(int count, int key)
|
_inp_rl_win9_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(9);
|
ui_switch_win_num(9);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_inp_rl_win0_handler(int count, int key)
|
_inp_rl_win0_handler(int count, int key)
|
||||||
{
|
{
|
||||||
ui_switch_win(0);
|
ui_switch_win_num(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,8 @@ void ui_close(void);
|
|||||||
void ui_redraw(void);
|
void ui_redraw(void);
|
||||||
void ui_resize(void);
|
void ui_resize(void);
|
||||||
GSList* ui_get_chat_recipients(void);
|
GSList* ui_get_chat_recipients(void);
|
||||||
gboolean ui_switch_win(const int i);
|
gboolean ui_switch_win_num(const int i);
|
||||||
|
gboolean ui_switch_win(ProfWin *win);
|
||||||
void ui_next_win(void);
|
void ui_next_win(void);
|
||||||
void ui_previous_win(void);
|
void ui_previous_win(void);
|
||||||
void ui_sigwinch_handler(int sig);
|
void ui_sigwinch_handler(int sig);
|
||||||
@ -86,8 +87,8 @@ void ui_handle_otr_error(const char * const barejid, const char * const message)
|
|||||||
|
|
||||||
unsigned long ui_get_idle_time(void);
|
unsigned long ui_get_idle_time(void);
|
||||||
void ui_reset_idle_time(void);
|
void ui_reset_idle_time(void);
|
||||||
void ui_new_chat_win(const char * const barejid);
|
|
||||||
void ui_new_private_win(const char * const fulljid);
|
void ui_new_private_win(const char * const fulljid);
|
||||||
|
ProfWin* ui_new_chat_win(const char * const barejid);
|
||||||
void ui_print_system_msg_from_recipient(const char * const barejid, const char *message);
|
void ui_print_system_msg_from_recipient(const char * const barejid, const char *message);
|
||||||
gint ui_unread(void);
|
gint ui_unread(void);
|
||||||
void ui_close_connected_win(int index);
|
void ui_close_connected_win(int index);
|
||||||
|
@ -660,7 +660,7 @@ wins_swap(int source_win, int target_win)
|
|||||||
}
|
}
|
||||||
if (wins_get_current_num() == source_win) {
|
if (wins_get_current_num() == source_win) {
|
||||||
wins_set_current_by_num(target_win);
|
wins_set_current_by_num(target_win);
|
||||||
ui_switch_win(1);
|
ui_switch_win_num(1);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -681,7 +681,7 @@ wins_swap(int source_win, int target_win)
|
|||||||
status_bar_active(source_win);
|
status_bar_active(source_win);
|
||||||
}
|
}
|
||||||
if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
|
if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
|
||||||
ui_switch_win(1);
|
ui_switch_win_num(1);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -740,7 +740,7 @@ wins_tidy(void)
|
|||||||
|
|
||||||
windows = new_windows;
|
windows = new_windows;
|
||||||
current = 1;
|
current = 1;
|
||||||
ui_switch_win(1);
|
ui_switch_win_num(1);
|
||||||
g_list_free(keys);
|
g_list_free(keys);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,8 +15,8 @@ void cmd_win_shows_message_when_win_doesnt_exist(void **state)
|
|||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
gchar *args[] = { "3", NULL };
|
gchar *args[] = { "3", NULL };
|
||||||
|
|
||||||
expect_value(ui_switch_win, i, 3);
|
expect_value(ui_switch_win_num, i, 3);
|
||||||
will_return(ui_switch_win, FALSE);
|
will_return(ui_switch_win_num, FALSE);
|
||||||
|
|
||||||
expect_cons_show("Window 3 does not exist.");
|
expect_cons_show("Window 3 does not exist.");
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ void cmd_win_switches_to_given_win_when_exists(void **state)
|
|||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
gchar *args[] = { "12", NULL };
|
gchar *args[] = { "12", NULL };
|
||||||
|
|
||||||
expect_value(ui_switch_win, i, 12);
|
expect_value(ui_switch_win_num, i, 12);
|
||||||
will_return(ui_switch_win, TRUE);
|
will_return(ui_switch_win_num, TRUE);
|
||||||
|
|
||||||
gboolean result = cmd_win(args, *help);
|
gboolean result = cmd_win(args, *help);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
@ -64,7 +64,12 @@ GSList* ui_get_chat_recipients(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean ui_switch_win(const int i)
|
gboolean ui_switch_win(ProfWin *win)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean ui_switch_win_num(const int i)
|
||||||
{
|
{
|
||||||
check_expected(i);
|
check_expected(i);
|
||||||
return (gboolean)mock();
|
return (gboolean)mock();
|
||||||
@ -99,8 +104,12 @@ unsigned long ui_get_idle_time(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ui_reset_idle_time(void) {}
|
void ui_reset_idle_time(void) {}
|
||||||
void ui_new_chat_win(const char * const barejid) {}
|
|
||||||
void ui_new_private_win(const char * const fulljid) {}
|
void ui_new_private_win(const char * const fulljid) {}
|
||||||
|
ProfWin* ui_new_chat_win(const char * const barejid)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void ui_print_system_msg_from_recipient(const char * const barejid, const char *message) {}
|
void ui_print_system_msg_from_recipient(const char * const barejid, const char *message) {}
|
||||||
gint ui_unread(void)
|
gint ui_unread(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user