diff --git a/Makefile.am b/Makefile.am index fe9d4dd3..fce1a1b8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,7 +15,6 @@ core_sources = \ src/xmpp/form.c src/xmpp/form.h \ src/event/server_events.c src/event/server_events.h \ src/event/client_events.c src/event/client_events.h \ - src/event/ui_events.c src/event/ui_events.h \ src/ui/ui.h src/ui/window.c src/ui/window.h src/ui/core.c \ src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \ src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \ @@ -24,6 +23,7 @@ core_sources = \ src/window_list.c src/window_list.h \ src/ui/rosterwin.c src/ui/occupantswin.c \ src/ui/buffer.c src/ui/buffer.h \ + src/ui/chatwin.c \ src/command/command.h src/command/command.c \ src/command/commands.h src/command/commands.c \ src/tools/parser.c \ @@ -74,7 +74,6 @@ unittest_sources = \ src/window_list.c src/window_list.h \ src/event/server_events.c src/event/server_events.h \ src/event/client_events.c src/event/client_events.h \ - src/event/ui_events.c src/event/ui_events.h \ tests/unittests/xmpp/stub_xmpp.c \ tests/unittests/ui/stub_ui.c \ tests/unittests/log/stub_log.c \ diff --git a/src/command/commands.c b/src/command/commands.c index 7aba4672..ae89802b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -71,7 +71,6 @@ #include "ui/ui.h" #include "window_list.h" #include "event/client_events.h" -#include "event/ui_events.h" static void _update_presence(const resource_presence_t presence, const char *const show, gchar **args); @@ -921,7 +920,7 @@ cmd_win(ProfWin *window, const char *const command, gchar **args) if (!focuswin) { cons_show("Window %d does not exist.", num); } else { - ui_ev_focus_win(focuswin); + ui_switch_win(focuswin); } return TRUE; @@ -1506,9 +1505,9 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args) ProfPrivateWin *privwin = wins_get_private(full_jid->str); if (!privwin) { - privwin = ui_ev_new_private_win(full_jid->str); + privwin = ui_new_private_win(full_jid->str); } - ui_ev_focus_win((ProfWin*)privwin); + ui_switch_win((ProfWin*)privwin); if (msg) { cl_ev_send_priv_msg(privwin, msg); @@ -1531,16 +1530,16 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args) ProfChatWin *chatwin = wins_get_chat(barejid); if (!chatwin) { - chatwin = ui_ev_new_chat_win(barejid); + chatwin = chatwin_new(barejid); } - ui_ev_focus_win((ProfWin*)chatwin); + ui_switch_win((ProfWin*)chatwin); if (msg) { cl_ev_send_msg(chatwin, msg); } else { #ifdef PROF_HAVE_LIBOTR if (otr_is_secure(barejid)) { - ui_gone_secure(barejid, otr_is_trusted(barejid)); + chatwin_otr_secured(chatwin, otr_is_trusted(barejid)); } #endif } @@ -2754,7 +2753,7 @@ cmd_form(ProfWin *window, const char *const command, gchar **args) if (!new_current) { new_current = wins_get_console(); } - ui_ev_focus_win(new_current); + ui_switch_win(new_current); wins_close_by_num(num); } @@ -3060,7 +3059,7 @@ cmd_room(ProfWin *window, const char *const command, gchar **args) ProfMucConfWin *confwin = wins_get_muc_conf(mucwin->roomjid); if (confwin) { - ui_ev_focus_win((ProfWin*)confwin); + ui_switch_win((ProfWin*)confwin); } else { iq_request_room_config_form(mucwin->roomjid); } @@ -4695,9 +4694,9 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args) chatwin = wins_get_chat(barejid); if (!chatwin) { - chatwin = ui_ev_new_chat_win(barejid); + chatwin = chatwin_new(barejid); } - ui_ev_focus_win((ProfWin*)chatwin); + ui_switch_win((ProfWin*)chatwin); } else { chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); @@ -4895,9 +4894,9 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args) ProfChatWin *chatwin = wins_get_chat(barejid); if (!chatwin) { - chatwin = ui_ev_new_chat_win(barejid); + chatwin = chatwin_new(barejid); } - ui_ev_focus_win((ProfWin*)chatwin); + ui_switch_win((ProfWin*)chatwin); if (chatwin->pgp_send) { ui_current_print_formatted_line('!', 0, "You must disable PGP encryption before starting an OTR session."); @@ -4921,7 +4920,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ui_gone_secure(barejid, otr_is_trusted(barejid)); + chatwin_otr_secured(chatwin, otr_is_trusted(barejid)); return TRUE; // no recipient, use current chat @@ -4967,7 +4966,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ui_gone_insecure(chatwin->barejid); + chatwin_otr_unsecured(chatwin); otr_end_session(chatwin->barejid); return TRUE; @@ -4984,7 +4983,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ui_trust(chatwin->barejid); + chatwin_otr_trust(chatwin); otr_trust(chatwin->barejid); return TRUE; @@ -5001,7 +5000,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args) return TRUE; } - ui_untrust(chatwin->barejid); + chatwin_otr_untrust(chatwin); otr_untrust(chatwin->barejid); return TRUE; diff --git a/src/event/client_events.c b/src/event/client_events.c index d4ff95e6..f1bc24e7 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -96,14 +96,14 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg) if (chatwin->pgp_send) { char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg); - ui_outgoing_chat_msg(chatwin, plugin_msg, id, PROF_MSG_PGP); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PGP); free(id); } else { gboolean handled = otr_on_message_send(chatwin, plugin_msg); if (!handled) { char *id = message_send_chat(chatwin->barejid, plugin_msg); chat_log_msg_out(chatwin->barejid, plugin_msg); - ui_outgoing_chat_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN); free(id); } } @@ -118,7 +118,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg) if (!handled) { char *id = message_send_chat(chatwin->barejid, plugin_msg); chat_log_msg_out(chatwin->barejid, plugin_msg); - ui_outgoing_chat_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN); free(id); } return; @@ -131,12 +131,12 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg) if (chatwin->pgp_send) { char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg); - ui_outgoing_chat_msg(chatwin, plugin_msg, id, PROF_MSG_PGP); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PGP); free(id); } else { char *id = message_send_chat(chatwin->barejid, plugin_msg); chat_log_msg_out(chatwin->barejid, plugin_msg); - ui_outgoing_chat_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN); free(id); } return; @@ -148,7 +148,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg) #ifndef PROF_HAVE_LIBGPGME char *id = message_send_chat(chatwin->barejid, plugin_msg); chat_log_msg_out(chatwin->barejid, plugin_msg); - ui_outgoing_chat_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_PLAIN); free(id); return; #endif diff --git a/src/event/server_events.c b/src/event/server_events.c index 73dd24f3..42b50807 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -190,7 +190,14 @@ sv_ev_incoming_private_message(const char *const fulljid, char *message) void sv_ev_outgoing_carbon(char *barejid, char *message) { - ui_outgoing_chat_msg_carbon(barejid, message); + ProfChatWin *chatwin = wins_get_chat(barejid); + if (!chatwin) { + chatwin = chatwin_new(barejid); + } + + chat_state_active(chatwin->state); + + chatwin_outgoing_carbon(chatwin, message); } void @@ -204,7 +211,7 @@ sv_ev_incoming_carbon(char *barejid, char *resource, char *message) new_win = TRUE; } - ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN); + chatwin_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN); chat_log_msg_in(barejid, message, NULL); } @@ -214,12 +221,12 @@ _sv_ev_incoming_pgp(ProfChatWin *chatwin, gboolean new_win, char *barejid, char { char *decrypted = p_gpg_decrypt(pgp_message); if (decrypted) { - ui_incoming_msg(chatwin, resource, decrypted, timestamp, new_win, PROF_MSG_PGP); + chatwin_incoming_msg(chatwin, resource, decrypted, timestamp, new_win, PROF_MSG_PGP); chat_log_pgp_msg_in(barejid, decrypted, timestamp); chatwin->pgp_recv = TRUE; p_gpg_free_decrypted(decrypted); } else { - ui_incoming_msg(chatwin, resource, message, timestamp, new_win, PROF_MSG_PLAIN); + chatwin_incoming_msg(chatwin, resource, message, timestamp, new_win, PROF_MSG_PLAIN); chat_log_msg_in(barejid, message, timestamp); chatwin->pgp_recv = FALSE; } @@ -234,10 +241,10 @@ _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, char *barejid, char char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); if (otr_res) { if (decrypted) { - ui_incoming_msg(chatwin, resource, otr_res, timestamp, new_win, PROF_MSG_OTR); + chatwin_incoming_msg(chatwin, resource, otr_res, timestamp, new_win, PROF_MSG_OTR); chatwin->pgp_send = FALSE; } else { - ui_incoming_msg(chatwin, resource, otr_res, timestamp, new_win, PROF_MSG_PLAIN); + chatwin_incoming_msg(chatwin, resource, otr_res, timestamp, new_win, PROF_MSG_PLAIN); } chat_log_otr_msg_in(barejid, otr_res, decrypted, timestamp); otr_free_message(otr_res); @@ -250,7 +257,7 @@ _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, char *barejid, char static void _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message, GDateTime *timestamp) { - ui_incoming_msg(chatwin, resource, message, timestamp, new_win, PROF_MSG_PLAIN); + chatwin_incoming_msg(chatwin, resource, message, timestamp, new_win, PROF_MSG_PLAIN); chat_log_msg_in(barejid, message, timestamp); chatwin->pgp_recv = FALSE; } @@ -325,14 +332,18 @@ sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTim void sv_ev_message_receipt(char *barejid, char *id) { - ui_message_receipt(barejid, id); + ProfChatWin *chatwin = wins_get_chat(barejid); + if (!chatwin) + return; + + chatwin_receipt_received(chatwin, id); } void sv_ev_typing(char *barejid, char *resource) { ui_contact_typing(barejid, resource); - if (ui_chat_win_exists(barejid)) { + if (wins_chat_exists(barejid)) { chat_session_recipient_typing(barejid, resource); } } @@ -340,7 +351,7 @@ sv_ev_typing(char *barejid, char *resource) void sv_ev_paused(char *barejid, char *resource) { - if (ui_chat_win_exists(barejid)) { + if (wins_chat_exists(barejid)) { chat_session_recipient_paused(barejid, resource); } } @@ -348,7 +359,7 @@ sv_ev_paused(char *barejid, char *resource) void sv_ev_inactive(char *barejid, char *resource) { - if (ui_chat_win_exists(barejid)) { + if (wins_chat_exists(barejid)) { chat_session_recipient_inactive(barejid, resource); } } @@ -356,8 +367,22 @@ sv_ev_inactive(char *barejid, char *resource) void sv_ev_gone(const char *const barejid, const char *const resource) { - ui_recipient_gone(barejid, resource); - if (ui_chat_win_exists(barejid)) { + if (barejid && resource) { + gboolean show_message = TRUE; + + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin) { + ChatSession *session = chat_session_get(barejid); + if (session && g_strcmp0(session->resource, resource) != 0) { + show_message = FALSE; + } + if (show_message) { + chatwin_recipient_gone(chatwin); + } + } + } + + if (wins_chat_exists(barejid)) { chat_session_recipient_gone(barejid, resource); } } @@ -365,7 +390,7 @@ sv_ev_gone(const char *const barejid, const char *const resource) void sv_ev_activity(const char *const barejid, const char *const resource, gboolean send_states) { - if (ui_chat_win_exists(barejid)) { + if (wins_chat_exists(barejid)) { chat_session_recipient_active(barejid, resource, send_states); } } diff --git a/src/event/ui_events.c b/src/event/ui_events.c deleted file mode 100644 index a9e71bbd..00000000 --- a/src/event/ui_events.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * ui_events.c - * - * Copyright (C) 2012 - 2015 James Booth - * - * This file is part of Profanity. - * - * Profanity is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Profanity is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Profanity. If not, see . - * - * In addition, as a special exception, the copyright holders give permission to - * link the code of portions of this program with the OpenSSL library under - * certain conditions as described in each individual source file, and - * distribute linked combinations including the two. - * - * You must obey the GNU General Public License in all respects for all of the - * code used other than OpenSSL. If you modify file(s) with this exception, you - * may extend this exception to your version of the file(s), but you are not - * obligated to do so. If you do not wish to do so, delete this exception - * statement from your version. If you delete this exception statement from all - * source files in the program, then also delete it here. - * - */ - -#include "ui/ui.h" -#include "window_list.h" - -void -ui_ev_focus_win(ProfWin *win) -{ - if (!wins_is_current(win)) { - ui_switch_win(win); - } -} - -ProfChatWin* -ui_ev_new_chat_win(const char *const barejid) -{ - return ui_new_chat_win(barejid); -} - -ProfPrivateWin* -ui_ev_new_private_win(const char *const fulljid) -{ - return ui_new_private_win(fulljid); -} diff --git a/src/event/ui_events.h b/src/event/ui_events.h deleted file mode 100644 index 279d1e2a..00000000 --- a/src/event/ui_events.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * ui_events.h - * - * Copyright (C) 2012 - 2015 James Booth - * - * This file is part of Profanity. - * - * Profanity is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Profanity is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Profanity. If not, see . - * - * In addition, as a special exception, the copyright holders give permission to - * link the code of portions of this program with the OpenSSL library under - * certain conditions as described in each individual source file, and - * distribute linked combinations including the two. - * - * You must obey the GNU General Public License in all respects for all of the - * code used other than OpenSSL. If you modify file(s) with this exception, you - * may extend this exception to your version of the file(s), but you are not - * obligated to do so. If you do not wish to do so, delete this exception - * statement from your version. If you delete this exception statement from all - * source files in the program, then also delete it here. - * - */ - -#ifndef UI_EVENTS_H -#define UI_EVENTS_H - -void ui_ev_focus_win(ProfWin *win); -ProfChatWin* ui_ev_new_chat_win(const char *const barejid); -ProfPrivateWin* ui_ev_new_private_win(const char *const fulljid); - -#endif diff --git a/src/otr/otr.c b/src/otr/otr.c index 9ff4a503..68ea3e11 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -42,6 +42,7 @@ #include "otr/otrlib.h" #include "log.h" #include "roster_list.h" +#include "window_list.h" #include "contact.h" #include "ui/ui.h" #include "config/preferences.h" @@ -143,7 +144,12 @@ cb_write_fingerprints(void *opdata) static void cb_gone_secure(void *opdata, ConnContext *context) { - ui_gone_secure(context->username, otr_is_trusted(context->username)); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (!chatwin) { + chatwin = (ProfChatWin*) wins_new_chat(context->username); + } + + chatwin_otr_secured(chatwin, otr_is_trusted(context->username)); } char* @@ -325,7 +331,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message) if (encrypted) { id = message_send_chat_otr(chatwin->barejid, encrypted); chat_log_otr_msg_out(chatwin->barejid, message); - ui_outgoing_chat_msg(chatwin, message, id, PROF_MSG_OTR); + chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_OTR); otr_free_message(encrypted); free(id); return TRUE; @@ -345,7 +351,7 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message) if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) { char *otr_tagged_msg = otr_tag_message(message); id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg); - ui_outgoing_chat_msg(chatwin, message, id, PROF_MSG_PLAIN); + chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_PLAIN); chat_log_msg_out(chatwin->barejid, message); free(otr_tagged_msg); free(id); @@ -567,13 +573,18 @@ otr_smp_secret(const char *const recipient, const char *secret) } // if recipient initiated SMP, send response, else initialise + ProfChatWin *chatwin = wins_get_chat(recipient); if (g_hash_table_contains(smp_initiators, recipient)) { otrl_message_respond_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); - ui_otr_authenticating(recipient); + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_AUTH, NULL); + } g_hash_table_remove(smp_initiators, context->username); } else { otrl_message_initiate_smp(user_state, &ops, NULL, context, (const unsigned char*)secret, strlen(secret)); - ui_otr_authetication_waiting(recipient); + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_AUTH_WAIT, NULL); + } } } @@ -591,7 +602,10 @@ otr_smp_question(const char *const recipient, const char *question, const char * } otrl_message_initiate_smp_q(user_state, &ops, NULL, context, question, (const unsigned char*)answer, strlen(answer)); - ui_otr_authetication_waiting(recipient); + ProfChatWin *chatwin = wins_get_chat(recipient); + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_AUTH_WAIT, NULL); + } } void @@ -733,7 +747,10 @@ otr_decrypt_message(const char *const from, const char *const message, gboolean if (tlv) { if (context) { otrl_context_force_plaintext(context); - ui_gone_insecure(from); + ProfChatWin *chatwin = wins_get_chat(from); + if (chatwin) { + chatwin_otr_unsecured(chatwin); + } } } diff --git a/src/otr/otr.h b/src/otr/otr.h index f966239e..284b69b9 100644 --- a/src/otr/otr.h +++ b/src/otr/otr.h @@ -39,7 +39,7 @@ #include #include "config/accounts.h" -#include "ui/ui.h" +#include "ui/win_types.h" typedef enum { PROF_OTRPOLICY_MANUAL, @@ -47,6 +47,19 @@ typedef enum { PROF_OTRPOLICY_ALWAYS } prof_otrpolicy_t; +typedef enum { + PROF_OTR_SMP_INIT, + PROF_OTR_SMP_INIT_Q, + PROF_OTR_SMP_SENDER_FAIL, + PROF_OTR_SMP_RECEIVER_FAIL, + PROF_OTR_SMP_ABORT, + PROF_OTR_SMP_SUCCESS, + PROF_OTR_SMP_SUCCESS_Q, + PROF_OTR_SMP_FAIL_Q, + PROF_OTR_SMP_AUTH, + PROF_OTR_SMP_AUTH_WAIT +} prof_otr_smp_event_t; + OtrlUserState otr_userstate(void); OtrlMessageAppOps* otr_messageops(void); GHashTable* otr_smpinitators(void); diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index 9bab4eed..f795949d 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -36,6 +36,7 @@ #include #include "ui/ui.h" +#include "window_list.h" #include "otr/otr.h" #include "otr/otrlib.h" @@ -140,7 +141,10 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext if (nextMsg != OTRL_SMP_EXPECT1) { otrl_message_abort_smp(user_state, ops, NULL, context); } else { - ui_smp_recipient_initiated(context->username); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT, NULL); + } g_hash_table_insert(smp_initiators, strdup(context->username), strdup(context->username)); } } @@ -149,10 +153,13 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext if (nextMsg != OTRL_SMP_EXPECT1) { otrl_message_abort_smp(user_state, ops, NULL, context); } else { - char *question = (char *)tlv->data; - char *eoq = memchr(question, '\0', tlv->len); - if (eoq) { - ui_smp_recipient_initiated_q(context->username, question); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (chatwin) { + char *question = (char *)tlv->data; + char *eoq = memchr(question, '\0', tlv->len); + if (eoq) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT_Q, question); + } } } } @@ -170,19 +177,22 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext otrl_message_abort_smp(user_state, ops, NULL, context); } else { context->smstate->nextExpected = OTRL_SMP_EXPECT1; - if (context->smstate->received_question == 0) { - if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) { - ui_smp_successful(context->username); - ui_trust(context->username); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (chatwin) { + if (context->smstate->received_question == 0) { + if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS, NULL); + chatwin_otr_trust(chatwin); + } else { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SENDER_FAIL, NULL); + chatwin_otr_untrust(chatwin); + } } else { - ui_smp_unsuccessful_sender(context->username); - ui_untrust(context->username); - } - } else { - if (context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) { - ui_smp_answer_success(context->username); - } else { - ui_smp_answer_failure(context->username); + if (context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS_Q, NULL); + } else { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_FAIL_Q, NULL); + } } } } @@ -193,20 +203,26 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext otrl_message_abort_smp(user_state, ops, NULL, context); } else { context->smstate->nextExpected = OTRL_SMP_EXPECT1; - if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) { - ui_smp_successful(context->username); - ui_trust(context->username); - } else { - ui_smp_unsuccessful_receiver(context->username); - ui_untrust(context->username); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (chatwin) { + if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS, NULL); + chatwin_otr_trust(chatwin); + } else { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_RECEIVER_FAIL, NULL); + chatwin_otr_untrust(chatwin); + } } } } tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT); if (tlv) { context->smstate->nextExpected = OTRL_SMP_EXPECT1; - ui_smp_aborted(context->username); - ui_untrust(context->username); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_ABORT, NULL); + chatwin_otr_untrust(chatwin); + } otr_untrust(context->username); } } diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c index 8ed17fcf..548d2232 100644 --- a/src/otr/otrlibv4.c +++ b/src/otr/otrlibv4.c @@ -37,6 +37,7 @@ #include #include "ui/ui.h" +#include "window_list.h" #include "log.h" #include "otr/otr.h" #include "otr/otrlib.h" @@ -176,36 +177,46 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, OtrlMessageAppOps *ops = otr_messageops(); GHashTable *smp_initiators = otr_smpinitators(); + ProfChatWin *chatwin = wins_get_chat(context->username); + switch(smp_event) { case OTRL_SMPEVENT_ASK_FOR_SECRET: - ui_smp_recipient_initiated(context->username); + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT, NULL); + } g_hash_table_insert(smp_initiators, strdup(context->username), strdup(context->username)); break; case OTRL_SMPEVENT_ASK_FOR_ANSWER: - ui_smp_recipient_initiated_q(context->username, question); + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_INIT_Q, question); + } break; case OTRL_SMPEVENT_SUCCESS: - if (context->smstate->received_question == 0) { - ui_smp_successful(context->username); - ui_trust(context->username); - } else { - ui_smp_answer_success(context->username); + if (chatwin) { + if (context->smstate->received_question == 0) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS, NULL); + chatwin_otr_trust(chatwin); + } else { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SUCCESS_Q, NULL); + } } break; case OTRL_SMPEVENT_FAILURE: - if (context->smstate->received_question == 0) { - if (nextMsg == OTRL_SMP_EXPECT3) { - ui_smp_unsuccessful_sender(context->username); - } else if (nextMsg == OTRL_SMP_EXPECT4) { - ui_smp_unsuccessful_receiver(context->username); + if (chatwin) { + if (context->smstate->received_question == 0) { + if (nextMsg == OTRL_SMP_EXPECT3) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_SENDER_FAIL, NULL); + } else if (nextMsg == OTRL_SMP_EXPECT4) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_RECEIVER_FAIL, NULL); + } + chatwin_otr_untrust(chatwin); + } else { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_FAIL_Q, NULL); } - ui_untrust(context->username); - } else { - ui_smp_answer_failure(context->username); } break; @@ -218,8 +229,10 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, break; case OTRL_SMPEVENT_ABORT: - ui_smp_aborted(context->username); - ui_untrust(context->username); + if (chatwin) { + chatwin_otr_smp_event(chatwin, PROF_OTR_SMP_ABORT, NULL); + chatwin_otr_untrust(chatwin); + } break; case OTRL_SMPEVENT_IN_PROGRESS: diff --git a/src/plugins/api.c b/src/plugins/api.c index e94a22a2..e7a36561 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -44,7 +44,6 @@ #include "ui/ui.h" #include "config/theme.h" #include "command/command.h" -#include "event/ui_events.h" #include "window_list.h" #include "common.h" @@ -190,7 +189,7 @@ void api_win_focus(const char *tag) { ProfPluginWin *pluginwin = wins_get_plugin(tag); - ui_ev_focus_win((ProfWin*)pluginwin); + ui_switch_win((ProfWin*)pluginwin); } void diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c new file mode 100644 index 00000000..dab5c669 --- /dev/null +++ b/src/ui/chatwin.c @@ -0,0 +1,368 @@ +/* + * chatwin.c + * + * Copyright (C) 2012 - 2015 James Booth + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see . + * + * In addition, as a special exception, the copyright holders give permission to + * link the code of portions of this program with the OpenSSL library under + * certain conditions as described in each individual source file, and + * distribute linked combinations including the two. + * + * You must obey the GNU General Public License in all respects for all of the + * code used other than OpenSSL. If you modify file(s) with this exception, you + * may extend this exception to your version of the file(s), but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. If you delete this exception statement from all + * source files in the program, then also delete it here. + * + */ + +#include +#include +#include + +#include "chat_session.h" +#include "window_list.h" +#include "roster_list.h" +#include "log.h" +#include "config/preferences.h" +#include "ui/ui.h" +#include "ui/window.h" +#include "ui/titlebar.h" +#include "plugins/plugins.h" + +static void _chatwin_history(ProfChatWin *chatwin, const char *const contact); + +ProfChatWin* +chatwin_new(const char *const barejid) +{ + ProfWin *window = wins_new_chat(barejid); + ProfChatWin *chatwin = (ProfChatWin *)window; + + if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) { + _chatwin_history(chatwin, barejid); + } + + // if the contact is offline, show a message + PContact contact = roster_get_contact(barejid); + if (contact) { + 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 chatwin; +} + +void +chatwin_receipt_received(ProfChatWin *chatwin, const char *const id) +{ + assert(chatwin != NULL); + + ProfWin *win = (ProfWin*) chatwin; + win_mark_received(win, id); +} + +void +chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) +{ + assert(chatwin != NULL); + + chatwin->is_otr = TRUE; + chatwin->otr_is_trusted = trusted; + + ProfWin *window = (ProfWin*) chatwin; + if (trusted) { + win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); + } else { + win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); + } + + if (wins_is_current(window)) { + title_bar_switch(); + } else { + int num = wins_get_num(window); + status_bar_new(num); + + int ui_index = num; + if (ui_index == 10) { + ui_index = 0; + } + cons_show("%s started an OTR session (%d).", chatwin->barejid, ui_index); + cons_alert(); + } +} + +void +chatwin_otr_unsecured(ProfChatWin *chatwin) +{ + assert(chatwin != NULL); + + chatwin->is_otr = FALSE; + chatwin->otr_is_trusted = FALSE; + + ProfWin *window = (ProfWin*)chatwin; + win_print(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended."); + if (wins_is_current(window)) { + title_bar_switch(); + } +} + +void +chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data) +{ + assert(chatwin != NULL); + + switch (event) { + case PROF_OTR_SMP_INIT: + win_vprintln_ch((ProfWin*)chatwin, '!', + "%s wants to authenticate your identity, use '/otr secret '.", chatwin->barejid); + break; + case PROF_OTR_SMP_INIT_Q: + win_vprintln_ch((ProfWin*)chatwin, '!', + "%s wants to authenticate your identity with the following question:", chatwin->barejid); + win_vprintln_ch((ProfWin*)chatwin, '!', " %s", (char*)data); + win_vprintln_ch((ProfWin*)chatwin, '!', "use '/otr answer '."); + break; + case PROF_OTR_SMP_SENDER_FAIL: + win_vprintln_ch((ProfWin*)chatwin, '!', + "Authentication failed, the secret you entered does not match the secret entered by %s.", + chatwin->barejid); + break; + case PROF_OTR_SMP_RECEIVER_FAIL: + win_vprintln_ch((ProfWin*)chatwin, '!', + "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); + break; + case PROF_OTR_SMP_ABORT: + win_vprintln_ch((ProfWin*)chatwin, '!', "SMP session aborted."); + break; + case PROF_OTR_SMP_SUCCESS: + win_vprintln_ch((ProfWin*)chatwin, '!', "Authentication successful."); + break; + case PROF_OTR_SMP_SUCCESS_Q: + win_vprintln_ch((ProfWin*)chatwin, '!', "%s successfully authenticated you.", chatwin->barejid); + break; + case PROF_OTR_SMP_FAIL_Q: + win_vprintln_ch((ProfWin*)chatwin, '!', "%s failed to authenticate you.", chatwin->barejid); + break; + case PROF_OTR_SMP_AUTH: + win_vprintln_ch((ProfWin*)chatwin, '!', "Authenticating %s...", chatwin->barejid); + break; + case PROF_OTR_SMP_AUTH_WAIT: + win_vprintln_ch((ProfWin*)chatwin, '!', "Awaiting authentication from %s...", chatwin->barejid); + break; + default: + break; + } +} + +void +chatwin_otr_trust(ProfChatWin *chatwin) +{ + assert(chatwin != NULL); + + chatwin->is_otr = TRUE; + chatwin->otr_is_trusted = TRUE; + + ProfWin *window = (ProfWin*)chatwin; + win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted."); + if (wins_is_current(window)) { + title_bar_switch(); + } +} + +void +chatwin_otr_untrust(ProfChatWin *chatwin) +{ + assert(chatwin != NULL); + + chatwin->is_otr = TRUE; + chatwin->otr_is_trusted = FALSE; + + ProfWin *window = (ProfWin*)chatwin; + win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted."); + if (wins_is_current(window)) { + title_bar_switch(); + } +} + +void +chatwin_recipient_gone(ProfChatWin *chatwin) +{ + assert(chatwin != NULL); + + const char *display_usr = NULL; + PContact contact = roster_get_contact(chatwin->barejid); + if (contact) { + if (p_contact_name(contact)) { + display_usr = p_contact_name(contact); + } else { + display_usr = chatwin->barejid; + } + } else { + display_usr = chatwin->barejid; + } + + win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr); +} + +void +chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const char *const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode) +{ + assert(chatwin != NULL); + + char *plugin_message = plugins_pre_chat_message_display(chatwin->barejid, message); + + ProfWin *window = (ProfWin*)chatwin; + int num = wins_get_num(window); + + char *display_name = roster_get_msg_display_name(chatwin->barejid, resource); + + // currently viewing chat window with sender + if (wins_is_current(window)) { + win_print_incoming_message(window, timestamp, display_name, plugin_message, enc_mode); + title_bar_set_typing(FALSE); + status_bar_active(num); + + // not currently viewing chat window with sender + } else { + status_bar_new(num); + cons_show_incoming_message(display_name, num); + + if (prefs_get_boolean(PREF_FLASH)) { + flash(); + } + + chatwin->unread++; + if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) { + _chatwin_history(chatwin, chatwin->barejid); + } + + // show users status first, when receiving message via delayed delivery + if (timestamp && win_created) { + PContact pcontact = roster_get_contact(chatwin->barejid); + if (pcontact) { + win_show_contact(window, pcontact); + } + } + + win_print_incoming_message(window, timestamp, display_name, plugin_message, enc_mode); + } + + if (prefs_get_boolean(PREF_BEEP)) { + beep(); + } + + if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) { + notify_message(window, display_name, plugin_message); + } + + free(display_name); + + plugins_post_chat_message_display(chatwin->barejid, plugin_message); + + free(plugin_message); +} + +void +chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode) +{ + assert(chatwin != NULL); + + char enc_char = '-'; + if (enc_mode == PROF_MSG_OTR) { + enc_char = prefs_get_otr_char(); + } else if (enc_mode == PROF_MSG_PGP) { + enc_char = prefs_get_pgp_char(); + } + + if (prefs_get_boolean(PREF_RECEIPTS_REQUEST) && id) { + win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id); + } else { + win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); + } +} + +void +chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message) +{ + assert(chatwin != NULL); + + win_print((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); + int num = wins_get_num((ProfWin*)chatwin); + status_bar_active(num); +} + +void +chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity) +{ + assert(chatwin != NULL); + + const char *show = string_from_resource_presence(resource->presence); + PContact contact = roster_get_contact(chatwin->barejid); + char *display_str = p_contact_create_display_string(contact, resource->name); + + win_show_status_string((ProfWin*)chatwin, display_str, show, resource->status, last_activity, "++", "online"); + + free(display_str); +} + +void +chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) +{ + assert(chatwin != NULL); + + PContact contact = roster_get_contact(chatwin->barejid); + char *display_str = p_contact_create_display_string(contact, resource); + + win_show_status_string((ProfWin*)chatwin, display_str, "offline", status, NULL, "--", "offline"); + + free(display_str); +} + +static void +_chatwin_history(ProfChatWin *chatwin, const char *const contact) +{ + if (!chatwin->history_shown) { + Jid *jid = jid_create(jabber_get_fulljid()); + GSList *history = chat_log_get_previous(jid->barejid, contact); + jid_destroy(jid); + GSList *curr = history; + while (curr) { + char *line = curr->data; + // entry + if (line[2] == ':') { + char hh[3]; memcpy(hh, &line[0], 2); hh[2] = '\0'; int ihh = atoi(hh); + char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); + char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); + GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); + win_print((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); + g_date_time_unref(timestamp); + // header + } else { + win_print((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", curr->data); + } + curr = g_slist_next(curr); + } + chatwin->history_shown = TRUE; + + g_slist_free_full(history, free); + } +} diff --git a/src/ui/core.c b/src/ui/core.c index 61f3bd68..931d610c 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -75,7 +75,6 @@ #include "window_list.h" #include "xmpp/xmpp.h" #include "plugins/plugins.h" -#include "event/ui_events.h" static char *win_title; @@ -88,8 +87,6 @@ static Display *display; static GTimer *ui_idle_time; -//static void _win_handle_switch(const wint_t ch); -static void _win_show_history(ProfChatWin *chatwin, const char *const contact); static void _ui_draw_term_title(void); void @@ -301,13 +298,6 @@ ui_handle_stanza(const char *const msg) } } -gboolean -ui_chat_win_exists(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - return (chatwin != NULL); -} - void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) { @@ -333,11 +323,17 @@ ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) // show in chat win if "all" if (g_strcmp0(show_chat_win, "all") == 0) { - ui_chat_win_contact_online(contact, resource, last_activity); + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin) { + chatwin_contact_online(chatwin, resource, last_activity); + } // show in char win if "online" and presence online } else if (g_strcmp0(show_chat_win, "online") == 0 && resource->presence == RESOURCE_ONLINE) { - ui_chat_win_contact_online(contact, resource, last_activity); + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin) { + chatwin_contact_online(chatwin, resource, last_activity); + } } free(show_console); @@ -394,71 +390,6 @@ ui_get_chat_recipients(void) return recipients; } -void -ui_message_receipt(const char *const barejid, const char *const id) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - ProfWin *win = (ProfWin*) chatwin; - win_mark_received(win, id); - } -} - -void -ui_incoming_msg(ProfChatWin *chatwin, const char *const resource, const char *const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode) -{ - char *plugin_message = plugins_pre_chat_message_display(chatwin->barejid, message); - - ProfWin *window = (ProfWin*)chatwin; - int num = wins_get_num(window); - - char *display_name = roster_get_msg_display_name(chatwin->barejid, resource); - - // currently viewing chat window with sender - if (wins_is_current(window)) { - win_print_incoming_message(window, timestamp, display_name, plugin_message, enc_mode); - title_bar_set_typing(FALSE); - status_bar_active(num); - - // not currently viewing chat window with sender - } else { - status_bar_new(num); - cons_show_incoming_message(display_name, num); - - if (prefs_get_boolean(PREF_FLASH)) { - flash(); - } - - chatwin->unread++; - if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) { - _win_show_history(chatwin, chatwin->barejid); - } - - // show users status first, when receiving message via delayed delivery - if (timestamp && win_created) { - PContact pcontact = roster_get_contact(chatwin->barejid); - if (pcontact) { - win_show_contact(window, pcontact); - } - } - - win_print_incoming_message(window, timestamp, display_name, plugin_message, enc_mode); - } - - if (prefs_get_boolean(PREF_BEEP)) { - beep(); - } - - if (prefs_get_boolean(PREF_NOTIFY_MESSAGE)) { - notify_message(window, display_name, plugin_message); - } - - free(display_name); - - plugins_post_chat_message_display(chatwin->barejid, plugin_message); - free(plugin_message); -} - void ui_incoming_private_msg(const char *const fulljid, const char *const message, GDateTime *timestamp) { @@ -624,6 +555,17 @@ ui_handle_recipient_error(const char *const recipient, const char *const err_msg } } +void +ui_handle_otr_error(const char *const barejid, const char *const message) +{ + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin) { + win_print((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message); + } else { + cons_show_error("%s - %s", barejid, message); + } +} + void ui_handle_error(const char *const err_msg) { @@ -830,6 +772,10 @@ ui_switch_win(ProfWin *window) { assert(window != NULL); + if (wins_is_current(window)) { + return; + } + ProfWin *old_current = wins_get_current(); if (old_current->type == WIN_MUC_CONFIG) { ProfMucConfWin *confwin = (ProfMucConfWin*)old_current; @@ -853,193 +799,6 @@ ui_switch_win(ProfWin *window) status_bar_active(i); } -void -ui_gone_secure(const char *const barejid, gboolean trusted) -{ - ProfWin *window = NULL; - - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - window = (ProfWin*)chatwin; - } else { - window = wins_new_chat(barejid); - chatwin = (ProfChatWin*)window; - } - - chatwin->is_otr = TRUE; - chatwin->otr_is_trusted = trusted; - if (trusted) { - win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); - } else { - win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); - } - - if (wins_is_current(window)) { - title_bar_switch(); - } else { - int num = wins_get_num(window); - status_bar_new(num); - - int ui_index = num; - if (ui_index == 10) { - ui_index = 0; - } - cons_show("%s started an OTR session (%d).", barejid, ui_index); - cons_alert(); - } -} - -void -ui_gone_insecure(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - chatwin->is_otr = FALSE; - chatwin->otr_is_trusted = FALSE; - - ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended."); - if (wins_is_current(window)) { - title_bar_switch(); - } - } -} - -void -ui_smp_recipient_initiated(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s wants to authenticate your identity, use '/otr secret '.", barejid); - } -} - -void -ui_smp_recipient_initiated_q(const char *const barejid, const char *question) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s wants to authenticate your identity with the following question:", barejid); - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", " %s", question); - win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "use '/otr answer '."); - } -} - -void -ui_smp_unsuccessful_sender(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authentication failed, the secret you entered does not match the secret entered by %s.", barejid); - } -} - -void -ui_smp_unsuccessful_receiver(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authentication failed, the secret entered by %s does not match yours.", barejid); - } -} - -void -ui_smp_aborted(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "SMP session aborted."); - } -} - -void -ui_smp_successful(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authentication successful."); - } -} - -void -ui_smp_answer_success(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s successfully authenticated you.", barejid); - } -} - -void -ui_smp_answer_failure(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s failed to authenticate you.", barejid); - } -} - -void -ui_otr_authenticating(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authenticating %s...", barejid); - } -} - -void -ui_otr_authetication_waiting(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Awaiting authentication from %s...", barejid); - } -} - -void -ui_handle_otr_error(const char *const barejid, const char *const message) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_print((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message); - } else { - cons_show_error("%s - %s", barejid, message); - } -} - -void -ui_trust(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - chatwin->is_otr = TRUE; - chatwin->otr_is_trusted = TRUE; - - ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted."); - if (wins_is_current(window)) { - title_bar_switch(); - } - } -} - -void -ui_untrust(const char *const barejid) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - chatwin->is_otr = TRUE; - chatwin->otr_is_trusted = FALSE; - - ProfWin *window = (ProfWin*)chatwin; - win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted."); - if (wins_is_current(window)) { - title_bar_switch(); - } - } -} - void ui_close_win(int index) { @@ -1177,40 +936,6 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag win_vprint(window, '-', 0, NULL, 0, 0, "", "*%s %s", barejid, message); } -void -ui_recipient_gone(const char *const barejid, const char *const resource) -{ - if (barejid == NULL) - return; - if (resource == NULL) - return; - - gboolean show_message = TRUE; - - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - ChatSession *session = chat_session_get(barejid); - if (session && g_strcmp0(session->resource, resource) != 0) { - show_message = FALSE; - } - if (show_message) { - const char * display_usr = NULL; - PContact contact = roster_get_contact(barejid); - if (contact) { - if (p_contact_name(contact)) { - display_usr = p_contact_name(contact); - } else { - display_usr = barejid; - } - } else { - display_usr = barejid; - } - - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr); - } - } -} - ProfPrivateWin* ui_new_private_win(const char *const fulljid) { @@ -1222,7 +947,7 @@ void ui_create_xmlconsole_win(void) { ProfWin *window = wins_new_xmlconsole(); - ui_ev_focus_win(window); + ui_switch_win(window); } void @@ -1230,68 +955,10 @@ ui_open_xmlconsole_win(void) { ProfXMLWin *xmlwin = wins_get_xmlconsole(); if (xmlwin) { - ui_ev_focus_win((ProfWin*)xmlwin); + ui_switch_win((ProfWin*)xmlwin); } } -ProfChatWin* -ui_new_chat_win(const char *const barejid) -{ - ProfWin *window = wins_new_chat(barejid); - ProfChatWin *chatwin = (ProfChatWin *)window; - - if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) { - _win_show_history(chatwin, barejid); - } - - // if the contact is offline, show a message - PContact contact = roster_get_contact(barejid); - if (contact) { - 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 chatwin; -} - -void -ui_outgoing_chat_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode) -{ - char enc_char = '-'; - if (enc_mode == PROF_MSG_OTR) { - enc_char = prefs_get_otr_char(); - } else if (enc_mode == PROF_MSG_PGP) { - enc_char = prefs_get_pgp_char(); - } - - if (prefs_get_boolean(PREF_RECEIPTS_REQUEST) && id) { - win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id); - } else { - win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); - } -} - -void -ui_outgoing_chat_msg_carbon(const char *const barejid, const char *const message) -{ - ProfChatWin *chatwin = wins_get_chat(barejid); - - // create new window - if (!chatwin) { - chatwin = ui_new_chat_win(barejid); - } - - chat_state_active(chatwin->state); - - win_print((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); - - int num = wins_get_num((ProfWin*)chatwin); - status_bar_active(num); -} - void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char *const message) { @@ -1322,7 +989,7 @@ ui_room_join(const char *const roomjid, gboolean focus) if (focus) { - ui_ev_focus_win(window); + ui_switch_win(window); } else { int num = wins_get_num(window); status_bar_active(num); @@ -1336,7 +1003,7 @@ void ui_switch_to_room(const char *const roomjid) { ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - ui_ev_focus_win(window); + ui_switch_win(window); } void @@ -2108,38 +1775,6 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) return inp_get_password(); } -void -ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) -{ - const char *show = string_from_resource_presence(resource->presence); - char *display_str = p_contact_create_display_string(contact, resource->name); - const char *barejid = p_contact_barejid(contact); - - ProfWin *window = (ProfWin*)wins_get_chat(barejid); - if (window) { - win_show_status_string(window, display_str, show, resource->status, - last_activity, "++", "online"); - - } - - free(display_str); -} - -void -ui_chat_win_contact_offline(PContact contact, char *resource, char *status) -{ - char *display_str = p_contact_create_display_string(contact, resource); - const char *barejid = p_contact_barejid(contact); - - ProfWin *window = (ProfWin*)wins_get_chat(barejid); - if (window) { - win_show_status_string(window, display_str, "offline", status, NULL, "--", - "offline"); - } - - free(display_str); -} - void ui_contact_offline(char *barejid, char *resource, char *status) { @@ -2161,11 +1796,17 @@ ui_contact_offline(char *barejid, char *resource, char *status) // show in chat win if "all" if (g_strcmp0(show_chat_win, "all") == 0) { - ui_chat_win_contact_offline(contact, resource, status); + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin) { + chatwin_contact_offline(chatwin, resource, status); + } // show in char win if "online" and presence online } else if (g_strcmp0(show_chat_win, "online") == 0) { - ui_chat_win_contact_offline(contact, resource, status); + ProfChatWin *chatwin = wins_get_chat(barejid); + if (chatwin) { + chatwin_contact_offline(chatwin, resource, status); + } } } } @@ -2547,7 +2188,7 @@ ui_handle_room_configuration(const char *const roomjid, DataForm *form) ProfMucConfWin *confwin = (ProfMucConfWin*)window; assert(confwin->memcheck == PROFCONFWIN_MEMCHECK); - ui_ev_focus_win(window); + ui_switch_win(window); ui_show_form(confwin); win_print(window, '-', 0, NULL, 0, 0, "", ""); @@ -2599,11 +2240,11 @@ ui_handle_room_config_submit_result(const char *const roomjid) } if (muc_window) { - ui_ev_focus_win((ProfWin*)muc_window); + ui_switch_win((ProfWin*)muc_window); win_print(muc_window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room configuration successful"); } else { ProfWin *console = wins_get_console(); - ui_ev_focus_win(console); + ui_switch_win(console); cons_show("Room configuration successful: %s", roomjid); } } else { @@ -2868,36 +2509,6 @@ ui_show_software_version(const char *const jid, const char *const presence, } } -static void -_win_show_history(ProfChatWin *chatwin, const char *const contact) -{ - if (!chatwin->history_shown) { - Jid *jid = jid_create(jabber_get_fulljid()); - GSList *history = chat_log_get_previous(jid->barejid, contact); - jid_destroy(jid); - GSList *curr = history; - while (curr) { - char *line = curr->data; - // entry - if (line[2] == ':') { - char hh[3]; memcpy(hh, &line[0], 2); hh[2] = '\0'; int ihh = atoi(hh); - char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); - char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); - GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); - win_print((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); - g_date_time_unref(timestamp); - // header - } else { - win_print((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", curr->data); - } - curr = g_slist_next(curr); - } - chatwin->history_shown = TRUE; - - g_slist_free_full(history, free); - } -} - void ui_status_bar_inactive(const int win) { diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 1c196d81..de2bce51 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -64,7 +64,6 @@ #include "ui/inputwin.h" #include "ui/window.h" #include "window_list.h" -#include "event/ui_events.h" #include "xmpp/xmpp.h" static WINDOW *inp_win; @@ -466,7 +465,7 @@ _go_to_win(int i) { ProfWin *window = wins_get_by_num(i); if (window) { - ui_ev_focus_win(window); + ui_switch_win(window); } } @@ -545,7 +544,7 @@ _inp_rl_altleft_handler(int count, int key) { ProfWin *window = wins_get_previous(); if (window) { - ui_ev_focus_win(window); + ui_switch_win(window); } return 0; } @@ -555,7 +554,7 @@ _inp_rl_altright_handler(int count, int key) { ProfWin *window = wins_get_next(); if (window) { - ui_ev_focus_win(window); + ui_switch_win(window); } return 0; } diff --git a/src/ui/ui.h b/src/ui/ui.h index e55d785f..acbcdcd9 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -38,6 +38,7 @@ #include "command/commands.h" #include "ui/win_types.h" #include "muc.h" +#include "otr/otr.h" #define NO_ME 1 #define NO_DATE 2 @@ -62,30 +63,25 @@ GSList* ui_get_chat_recipients(void); void ui_switch_win(ProfWin *window); void ui_sigwinch_handler(int sig); -void ui_gone_secure(const char *const barejid, gboolean trusted); -void ui_gone_insecure(const char *const barejid); -void ui_trust(const char *const barejid); -void ui_untrust(const char *const barejid); -void ui_smp_recipient_initiated(const char *const barejid); -void ui_smp_recipient_initiated_q(const char *const barejid, const char *question); - -void ui_smp_successful(const char *const barejid); -void ui_smp_unsuccessful_sender(const char *const barejid); -void ui_smp_unsuccessful_receiver(const char *const barejid); -void ui_smp_aborted(const char *const barejid); - -void ui_smp_answer_success(const char *const barejid); -void ui_smp_answer_failure(const char *const barejid); - -void ui_otr_authenticating(const char *const barejid); -void ui_otr_authetication_waiting(const char *const recipient); +ProfChatWin* chatwin_new(const char *const barejid); +void chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const char *const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode); +void chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted); +void chatwin_otr_unsecured(ProfChatWin *chatwin); +void chatwin_otr_trust(ProfChatWin *chatwin); +void chatwin_otr_untrust(ProfChatWin *chatwin); +void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data); +void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id); +void chatwin_recipient_gone(ProfChatWin *chatwin); +void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode); +void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message); +void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity); +void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status); void ui_handle_otr_error(const char *const barejid, const char *const message); unsigned long ui_get_idle_time(void); void ui_reset_idle_time(void); ProfPrivateWin* ui_new_private_win(const char *const fulljid); -ProfChatWin* ui_new_chat_win(const char *const barejid); void ui_print_system_msg_from_recipient(const char *const barejid, const char *message); gint ui_unread(void); void ui_close_connected_win(int index); @@ -110,15 +106,10 @@ void ui_handle_stanza(const char *const msg); // ui events void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity); void ui_contact_typing(const char *const barejid, const char *const resource); -void ui_incoming_msg(ProfChatWin *chatwin, const char *const resource, const char *const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode); void ui_incoming_private_msg(const char *const fulljid, const char *const message, GDateTime *timestamp); -void ui_message_receipt(const char *const barejid, const char *const id); void ui_disconnected(void); -void ui_recipient_gone(const char *const barejid, const char *const resource); -void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode); -void ui_outgoing_chat_msg_carbon(const char *const barejid, const char *const message); void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char *const message); void ui_room_join(const char *const roomjid, gboolean focus); @@ -179,8 +170,6 @@ void ui_contact_already_in_group(const char *const contact, const char *const gr void ui_contact_not_in_group(const char *const contact, const char *const group); void ui_group_added(const char *const contact, const char *const group); void ui_group_removed(const char *const contact, const char *const group); -void ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); -void ui_chat_win_contact_offline(PContact contact, char *resource, char *status); void ui_contact_offline(char *barejid, char *resource, char *status); void ui_handle_recipient_not_found(const char *const recipient, const char *const err_msg); void ui_handle_recipient_error(const char *const recipient, const char *const err_msg); @@ -210,7 +199,6 @@ void ui_show_lines(ProfWin *window, const gchar** lines); void ui_redraw_all_room_rosters(void); void ui_show_all_room_rosters(void); void ui_hide_all_room_rosters(void); -gboolean ui_chat_win_exists(const char *const barejid); void ui_handle_software_version_error(const char *const roomjid, const char *const message); void ui_show_software_version(const char *const jid, const char *const presence, const char *const name, const char *const version, const char *const os); @@ -374,6 +362,7 @@ void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *o void win_show_contact(ProfWin *window, PContact contact); void win_show_info(ProfWin *window, PContact contact); void win_println(ProfWin *window, int pad, const char *const message); +void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...); // desktop notifier actions void notifier_initialise(void); diff --git a/src/ui/window.c b/src/ui/window.c index 6188a837..3f6382da 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -982,6 +982,18 @@ win_println(ProfWin *window, int pad, const char *const message) win_print(window, '-', pad, NULL, 0, 0, "", message); } +void +win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) +{ + va_list arg; + va_start(arg, message); + GString *fmt_msg = g_string_new(NULL); + g_string_vprintf(fmt_msg, message, arg); + win_print(window, ch, 0, NULL, 0, 0, "", fmt_msg->str); + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + void win_newline(ProfWin *window) { diff --git a/src/window_list.c b/src/window_list.c index f82bd4a9..f20399e1 100644 --- a/src/window_list.c +++ b/src/window_list.c @@ -46,7 +46,6 @@ #include "ui/ui.h" #include "ui/statusbar.h" #include "window_list.h" -#include "event/ui_events.h" static GHashTable *windows; static int current; @@ -69,6 +68,13 @@ wins_get_console(void) return g_hash_table_lookup(windows, GINT_TO_POINTER(1)); } +gboolean +wins_chat_exists(const char *const barejid) +{ + ProfChatWin *chatwin = wins_get_chat(barejid); + return (chatwin != NULL); +} + ProfChatWin* wins_get_chat(const char *const barejid) { @@ -562,7 +568,7 @@ wins_swap(int source_win, int target_win) } if (wins_get_current_num() == source_win) { wins_set_current_by_num(target_win); - ui_ev_focus_win(console); + ui_switch_win(console); } return TRUE; @@ -583,7 +589,7 @@ wins_swap(int source_win, int target_win) status_bar_active(source_win); } if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) { - ui_ev_focus_win(console); + ui_switch_win(console); } return TRUE; } @@ -643,7 +649,7 @@ wins_tidy(void) windows = new_windows; current = 1; ProfWin *console = wins_get_console(); - ui_ev_focus_win(console); + ui_switch_win(console); g_list_free(keys); return TRUE; } else { diff --git a/src/window_list.h b/src/window_list.h index ed1f4b4e..56c21cae 100644 --- a/src/window_list.h +++ b/src/window_list.h @@ -46,6 +46,8 @@ ProfWin* wins_new_muc_config(const char *const roomjid, DataForm *form); ProfWin* wins_new_private(const char *const fulljid); ProfWin* wins_new_plugin(const char *const tag); +gboolean wins_chat_exists(const char *const barejid); + ProfWin* wins_get_console(void); ProfChatWin* wins_get_chat(const char *const barejid); ProfMucWin* wins_get_muc(const char *const roomjid); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 7c7c6ab3..4761cc96 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -66,23 +66,12 @@ GSList* ui_get_chat_recipients(void) void ui_switch_win(ProfWin *win) {} -void ui_gone_secure(const char * const barejid, gboolean trusted) {} -void ui_gone_insecure(const char * const barejid) {} -void ui_trust(const char * const barejid) {} -void ui_untrust(const char * const barejid) {} -void ui_smp_recipient_initiated(const char * const barejid) {} -void ui_smp_recipient_initiated_q(const char * const barejid, const char *question) {} +void chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) {} +void chatwin_otr_unsecured(ProfChatWin *chatwin) {} +void chatwin_otr_trust(ProfChatWin *chatwin) {} +void chatwin_otr_untrust(ProfChatWin *chatwin) {} +void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data) {} -void ui_smp_successful(const char * const barejid) {} -void ui_smp_unsuccessful_sender(const char * const barejid) {} -void ui_smp_unsuccessful_receiver(const char * const barejid) {} -void ui_smp_aborted(const char * const barejid) {} - -void ui_smp_answer_success(const char * const barejid) {} -void ui_smp_answer_failure(const char * const barejid) {} - -void ui_otr_authenticating(const char * const barejid) {} -void ui_otr_authetication_waiting(const char * const recipient) {} void ui_sigwinch_handler(int sig) {} unsigned long ui_get_idle_time(void) @@ -96,7 +85,7 @@ ProfPrivateWin* ui_new_private_win(const char * const fulljid) return NULL; } -ProfChatWin* ui_new_chat_win(const char * const barejid) +ProfChatWin* chatwin_new(const char * const barejid) { return NULL; } @@ -184,16 +173,16 @@ void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activi } void ui_contact_typing(const char * const barejid, const char * const resource) {} -void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode) {} -void ui_message_receipt(const char * const barejid, const char * const id) {} +void chatwin_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode) {} +void chatwin_receipt_received(ProfChatWin *chatwin, const char * const id) {} void ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp) {} void ui_disconnected(void) {} -void ui_recipient_gone(const char * const barejid, const char * const resource) {} +void chatwin_recipient_gone(ProfChatWin *chatwin) {} -void ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) {} -void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) {} +void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) {} +void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message) {} void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char * const message) {} void ui_room_join(const char * const roomjid, gboolean focus) {} @@ -254,12 +243,8 @@ void ui_contact_already_in_group(const char * const contact, const char * const void ui_contact_not_in_group(const char * const contact, const char * const group) {} void ui_group_added(const char * const contact, const char * const group) {} void ui_group_removed(const char * const contact, const char * const group) {} -void ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) {} -void ui_chat_win_contact_offline(PContact contact, char *resource, char *status) {} -gboolean ui_chat_win_exists(const char * const barejid) -{ - return TRUE; -} +void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity) {} +void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) {} void ui_contact_offline(char *barejid, char *resource, char *status) {} @@ -562,6 +547,7 @@ void win_show_occupant_info(ProfWin *window, const char * const room, Occupant * void win_show_contact(ProfWin *window, PContact contact) {} void win_show_info(ProfWin *window, PContact contact) {} void win_println(ProfWin *window, int pad, const char * const message) {} +void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) {} // desktop notifier actions void notifier_uninit(void) {}