From 8a397263ddab0762f7ce7f0ce19a2eb19c54b48a Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 8 Nov 2015 22:01:51 +0000 Subject: [PATCH 1/2] ui_incoming_private_msg takes ProfPrivateWin, added asserts --- src/event/server_events.c | 24 +++++++++++++++++------- src/ui/privwin.c | 13 ++++++------- src/ui/ui.h | 2 +- tests/unittests/ui/stub_ui.c | 2 +- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/event/server_events.c b/src/event/server_events.c index a56a54b0..baedd154 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -184,7 +184,23 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, void sv_ev_incoming_private_message(const char *const fulljid, char *message) { - ui_incoming_private_msg(fulljid, message, NULL); + ProfPrivateWin *privatewin = wins_get_private(fulljid); + if (privatewin == NULL) { + ProfWin *window = wins_new_private(fulljid); + privatewin = (ProfPrivateWin*)window; + } + ui_incoming_private_msg(privatewin, message, NULL); +} + +void +sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTime *timestamp) +{ + ProfPrivateWin *privatewin = wins_get_private(fulljid); + if (privatewin == NULL) { + ProfWin *window = wins_new_private(fulljid); + privatewin = (ProfPrivateWin*)window; + } + ui_incoming_private_msg(privatewin, message, timestamp); } void @@ -319,12 +335,6 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m #endif } -void -sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTime *timestamp) -{ - ui_incoming_private_msg(fulljid, message, timestamp); -} - void sv_ev_message_receipt(char *barejid, char *id) { diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 487492b9..5b896d85 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -32,6 +32,7 @@ * */ +#include #include #include "ui/win_types.h" @@ -41,18 +42,14 @@ #include "config/preferences.h" void -ui_incoming_private_msg(const char *const fulljid, const char *const message, GDateTime *timestamp) +ui_incoming_private_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp) { - ProfPrivateWin *privatewin = wins_get_private(fulljid); - if (privatewin == NULL) { - ProfWin *window = wins_new_private(fulljid); - privatewin = (ProfPrivateWin*)window; - } + assert(privatewin != NULL); ProfWin *window = (ProfWin*) privatewin; int num = wins_get_num(window); - char *display_from = get_nick_from_full_jid(fulljid); + char *display_from = get_nick_from_full_jid(privatewin->fulljid); // currently viewing chat window with sender if (wins_is_current(window)) { @@ -86,5 +83,7 @@ ui_incoming_private_msg(const char *const fulljid, const char *const message, GD void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char *const message) { + assert(privwin != NULL); + win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); } diff --git a/src/ui/ui.h b/src/ui/ui.h index 751e65ca..5fba3982 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -83,7 +83,7 @@ char* ui_get_line(void); char* ui_ask_pgp_passphrase(const char *hint, int prev_fail); 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_private_msg(const char *const fulljid, const char *const message, GDateTime *timestamp); +void ui_incoming_private_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp); void ui_disconnected(void); void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char *const message); void ui_room_join(const char *const roomjid, gboolean focus); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 23520009..d3f74d29 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -159,7 +159,7 @@ void ui_contact_typing(const char * const barejid, const char * const resource) 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_incoming_private_msg(ProfPrivateWin *privatewin, const char * const message, GDateTime *timestamp) {} void ui_disconnected(void) {} void chatwin_recipient_gone(ProfChatWin *chatwin) {} From 60215cdf9df7d5072db45afe445239f685e06d91 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 8 Nov 2015 22:08:29 +0000 Subject: [PATCH 2/2] Renamed MUC private window functions --- src/event/client_events.c | 2 +- src/event/server_events.c | 4 ++-- src/ui/privwin.c | 4 ++-- src/ui/ui.h | 18 +++++++++++------- tests/unittests/ui/stub_ui.c | 4 ++-- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/event/client_events.c b/src/event/client_events.c index f1872202..88776fd5 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -164,5 +164,5 @@ void cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg) { message_send_private(privwin->fulljid, msg); - ui_outgoing_private_msg(privwin, msg); + privwin_outgoing_msg(privwin, msg); } diff --git a/src/event/server_events.c b/src/event/server_events.c index baedd154..3622b327 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -189,7 +189,7 @@ sv_ev_incoming_private_message(const char *const fulljid, char *message) ProfWin *window = wins_new_private(fulljid); privatewin = (ProfPrivateWin*)window; } - ui_incoming_private_msg(privatewin, message, NULL); + privwin_incoming_msg(privatewin, message, NULL); } void @@ -200,7 +200,7 @@ sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTim ProfWin *window = wins_new_private(fulljid); privatewin = (ProfPrivateWin*)window; } - ui_incoming_private_msg(privatewin, message, timestamp); + privwin_incoming_msg(privatewin, message, timestamp); } void diff --git a/src/ui/privwin.c b/src/ui/privwin.c index 5b896d85..af7ad0de 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -42,7 +42,7 @@ #include "config/preferences.h" void -ui_incoming_private_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp) +privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp) { assert(privatewin != NULL); @@ -81,7 +81,7 @@ ui_incoming_private_msg(ProfPrivateWin *privatewin, const char *const message, G } void -ui_outgoing_private_msg(ProfPrivateWin *privwin, const char *const message) +privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) { assert(privwin != NULL); diff --git a/src/ui/ui.h b/src/ui/ui.h index 5fba3982..b967ea8b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -83,9 +83,7 @@ char* ui_get_line(void); char* ui_ask_pgp_passphrase(const char *hint, int prev_fail); 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_private_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp); void ui_disconnected(void); -void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char *const message); void ui_room_join(const char *const roomjid, gboolean focus); void ui_switch_to_room(const char *const roomjid); void ui_room_destroy(const char *const roomjid); @@ -107,14 +105,9 @@ void ui_handle_recipient_error(const char *const recipient, const char *const er void ui_handle_error(const char *const err_msg); void ui_clear_win_title(void); void ui_goodbye_title(void); -void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form); void ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message); void ui_handle_room_config_submit_result(const char *const roomjid); void ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message); -void mucconfwin_show_form(ProfMucConfWin *confwin); -void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag); -void mucconfwin_form_help(ProfMucConfWin *confwin); -void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag); void ui_show_lines(ProfWin *window, const gchar** lines); void ui_redraw_all_room_rosters(void); void ui_show_all_room_rosters(void); @@ -195,6 +188,17 @@ void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const ch void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks); void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error); +// MUC private chat window +void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDateTime *timestamp); +void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message); + +// MUC room config window +void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form); +void mucconfwin_show_form(ProfMucConfWin *confwin); +void mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag); +void mucconfwin_form_help(ProfMucConfWin *confwin); +void mucconfwin_field_help(ProfMucConfWin *confwin, char *tag); + // xml console void xmlwin_show(ProfXMLWin *xmlwin, const char *const msg); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index d3f74d29..6ebf4803 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -159,14 +159,14 @@ void ui_contact_typing(const char * const barejid, const char * const resource) 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(ProfPrivateWin *privatewin, const char * const message, GDateTime *timestamp) {} +void privwin_incoming_msg(ProfPrivateWin *privatewin, const char * const message, GDateTime *timestamp) {} void ui_disconnected(void) {} 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 ui_outgoing_private_msg(ProfPrivateWin *privwin, const char * const message) {} +void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {} void ui_room_join(const char * const roomjid, gboolean focus) {} void ui_switch_to_room(const char * const roomjid) {}