diff --git a/src/server_events.c b/src/server_events.c index d7504b64..cf6ecb75 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -309,8 +309,9 @@ handle_incoming_private_message(char *fulljid, char *message) } void -handle_carbon(char *barejid, char *message){ - ui_outgoing_chat_msg(barejid, message, NULL); +handle_carbon(char *barejid, char *message) +{ + ui_outgoing_chat_msg_carbon(barejid, message); } void @@ -842,4 +843,4 @@ handle_muc_occupant_online(const char * const room, const char * const nick, con } occupantswin_occupants(room); } -} \ No newline at end of file +} diff --git a/src/ui/core.c b/src/ui/core.c index aa77e32e..51a44324 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1464,6 +1464,47 @@ ui_outgoing_chat_msg(const char * const barejid, const char * const message, cha ui_switch_win(num); } +void +ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) +{ + PContact contact = roster_get_contact(barejid); + ProfWin *window = (ProfWin*)wins_get_chat(barejid); + int num = 0; + + // create new window + if (window == NULL) { + window = wins_new_chat(barejid); +#ifdef HAVE_LIBOTR + ProfChatWin *chatwin = (ProfChatWin*)window; + if (otr_is_secure(barejid)) { + chatwin->is_otr = TRUE; + } +#endif + num = wins_get_num(window); + + if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) { + _win_show_history(num, barejid); + } + + if (contact != NULL) { + if (strcmp(p_contact_presence(contact), "offline") == 0) { + const char *show = p_contact_presence(contact); + const char *status = p_contact_status(contact); + win_show_status_string(window, barejid, show, status, NULL, "--", "offline"); + } + } + + // use existing window + } else { + num = wins_get_num(window); + } + ProfChatWin *chatwin = (ProfChatWin*)window; + chat_state_active(chatwin->state); + + win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message); + status_bar_active(num); +} + void ui_outgoing_private_msg(const char * const fulljid, const char * const message) { diff --git a/src/ui/ui.h b/src/ui/ui.h index 9c8b9b4d..a2ab5945 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -122,6 +122,7 @@ void ui_disconnected(void); void ui_recipient_gone(const char * const barejid, const char * const resource); void ui_outgoing_chat_msg(const char * const barejid, const char * const message, char *id); +void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message); void ui_outgoing_private_msg(const char * const fulljid, const char * const message); void ui_room_join(const char * const roomjid, gboolean focus); diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c index 802286ba..6b2698a2 100644 --- a/tests/ui/stub_ui.c +++ b/tests/ui/stub_ui.c @@ -202,6 +202,7 @@ void ui_disconnected(void) {} void ui_recipient_gone(const char * const barejid, const char * const resource) {} void ui_outgoing_chat_msg(const char * const barejid, const char * const message, char *id) {} +void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) {} void ui_outgoing_private_msg(const char * const fulljid, const char * const message) {} void ui_room_join(const char * const roomjid, gboolean focus) {}