diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/event/client_events.c | 12 | ||||
-rw-r--r-- | src/event/server_events.c | 30 | ||||
-rw-r--r-- | src/otr/otr.c | 4 | ||||
-rw-r--r-- | src/ui/core.c | 23 | ||||
-rw-r--r-- | src/ui/ui.h | 4 | ||||
-rw-r--r-- | src/ui/window.c | 11 | ||||
-rw-r--r-- | src/ui/window.h | 2 |
7 files changed, 55 insertions, 31 deletions
diff --git a/src/event/client_events.c b/src/event/client_events.c index 2bf48234..f8df6bf4 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -97,13 +97,13 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg) if (!handled) { char *id = message_send_chat(chatwin->barejid, msg); chat_log_msg_out(chatwin->barejid, msg); - ui_outgoing_chat_msg(chatwin, msg, id); + ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE); free(id); } } else { // enc_mode = PROF_ENC_PGP char *id = message_send_chat_pgp(chatwin->barejid, msg); chat_log_pgp_msg_out(chatwin->barejid, msg); - ui_outgoing_chat_msg(chatwin, msg, id); + ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_PGP); free(id); } return; @@ -117,7 +117,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg) if (!handled) { char *id = message_send_chat(chatwin->barejid, msg); chat_log_msg_out(chatwin->barejid, msg); - ui_outgoing_chat_msg(chatwin, msg, id); + ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE); free(id); } return; @@ -131,12 +131,12 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg) if (enc_mode == PROF_ENC_NONE) { char *id = message_send_chat(chatwin->barejid, msg); chat_log_msg_out(chatwin->barejid, msg); - ui_outgoing_chat_msg(chatwin, msg, id); + ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE); free(id); } else if (enc_mode == PROF_ENC_PGP) { char *id = message_send_chat_pgp(chatwin->barejid, msg); chat_log_pgp_msg_out(chatwin->barejid, msg); - ui_outgoing_chat_msg(chatwin, msg, id); + ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_PGP); free(id); } return; @@ -148,7 +148,7 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char * const msg) #ifndef HAVE_LIBGPGME char *id = message_send_chat(chatwin->barejid, msg); chat_log_msg_out(chatwin->barejid, msg); - ui_outgoing_chat_msg(chatwin, msg, id); + ui_outgoing_chat_msg(chatwin, msg, id, PROF_ENC_NONE; free(id); return; #endif diff --git a/src/event/server_events.c b/src/event/server_events.c index 0755aae5..283fc264 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -187,7 +187,7 @@ sv_ev_incoming_carbon(char *barejid, char *resource, char *message) new_win = TRUE; } - ui_incoming_msg(chatwin, resource, message, NULL, new_win); + ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE); chat_log_msg_in(barejid, message); } @@ -215,12 +215,12 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m if (enc_mode == PROF_ENC_NONE) { win_println((ProfWin*)chatwin, 0, "PGP encryption enabled."); } - ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); + ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win, PROF_ENC_PGP); chat_log_pgp_msg_in(barejid, decrypted); chatwin->enc_mode = PROF_ENC_PGP; p_gpg_free_decrypted(decrypted); } else { - ui_incoming_msg(chatwin, resource, message, NULL, new_win); + ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } @@ -228,14 +228,18 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m } else { if (enc_mode == PROF_ENC_PGP) { win_println((ProfWin*)chatwin, 0, "PGP encryption disabled."); - ui_incoming_msg(chatwin, resource, message, NULL, new_win); + ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } else { gboolean decrypted = FALSE; char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); if (otr_res) { - ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win); + if (decrypted && g_strrstr(message, otr_res) == NULL) { + ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_OTR); + } else { + ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_NONE); + } chat_log_otr_msg_in(barejid, otr_res, decrypted); otr_free_message(otr_res); } @@ -251,7 +255,11 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m gboolean decrypted = FALSE; char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); if (otr_res) { - ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win); + if (decrypted && g_strrstr(message, otr_res) == NULL) { + ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_OTR); + } else { + ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win, PROF_ENC_NONE); + } chat_log_otr_msg_in(barejid, otr_res, decrypted); otr_free_message(otr_res); } @@ -265,17 +273,17 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m if (enc_message) { char *decrypted = p_gpg_decrypt(enc_message); if (decrypted) { - ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); + ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win, PROF_ENC_PGP); chat_log_pgp_msg_in(barejid, decrypted); chatwin->enc_mode = PROF_ENC_PGP; p_gpg_free_decrypted(decrypted); } else { - ui_incoming_msg(chatwin, resource, message, NULL, new_win); + ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } } else { - ui_incoming_msg(chatwin, resource, message, NULL, new_win); + ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } @@ -286,7 +294,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m // OTR unsupported, PGP unsupported #ifndef HAVE_LIBOTR #ifndef HAVE_LIBGPGME - ui_incoming_msg(chatwin, resource, message, NULL, new_win); + ui_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_ENC_NONE); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; return; @@ -311,7 +319,7 @@ sv_ev_delayed_message(char *barejid, char *message, GDateTime *timestamp) new_win = TRUE; } - ui_incoming_msg(chatwin, NULL, message, timestamp, new_win); + ui_incoming_msg(chatwin, NULL, message, timestamp, new_win, PROF_ENC_NONE); chat_log_msg_in_delayed(barejid, message, timestamp); } diff --git a/src/otr/otr.c b/src/otr/otr.c index 53433642..7953733d 100644 --- a/src/otr/otr.c +++ b/src/otr/otr.c @@ -325,7 +325,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); + ui_outgoing_chat_msg(chatwin, message, id, PROF_ENC_OTR); otr_free_message(encrypted); free(id); return TRUE; @@ -345,7 +345,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); + ui_outgoing_chat_msg(chatwin, message, id, PROF_ENC_NONE); chat_log_msg_out(chatwin->barejid, message); free(otr_tagged_msg); free(id); diff --git a/src/ui/core.c b/src/ui/core.c index f947577b..f416a448 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -412,7 +412,7 @@ ui_message_receipt(const char * const barejid, const char * const id) } void -ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created) +ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode) { ProfWin *window = (ProfWin*)chatwin; int num = wins_get_num(window); @@ -421,7 +421,7 @@ ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * // currently viewing chat window with sender if (wins_is_current(window)) { - win_print_incoming_message(window, timestamp, display_name, message); + win_print_incoming_message(window, timestamp, display_name, message, enc_mode); title_bar_set_typing(FALSE); status_bar_active(num); @@ -447,7 +447,7 @@ ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * } } - win_print_incoming_message(window, timestamp, display_name, message); + win_print_incoming_message(window, timestamp, display_name, message, enc_mode); } if (prefs_get_boolean(PREF_BEEP)) { @@ -478,7 +478,7 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message, // currently viewing chat window with sender if (wins_is_current(window)) { - win_print_incoming_message(window, timestamp, display_from, message); + win_print_incoming_message(window, timestamp, display_from, message, PROF_ENC_NONE); title_bar_set_typing(FALSE); status_bar_active(num); @@ -487,7 +487,7 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message, privatewin->unread++; status_bar_new(num); cons_show_incoming_message(display_from, num); - win_print_incoming_message(window, timestamp, display_from, message); + win_print_incoming_message(window, timestamp, display_from, message, PROF_ENC_NONE); if (prefs_get_boolean(PREF_FLASH)) { flash(); @@ -1287,12 +1287,19 @@ ui_new_chat_win(const char * const barejid) } void -ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id) +ui_outgoing_chat_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) { + char enc_char = '-'; + if (enc_mode == PROF_ENC_OTR) { + enc_char = 'O'; + } else if (enc_mode == PROF_ENC_PGP) { + enc_char = 'P'; + } + if (prefs_get_boolean(PREF_RECEIPTS_REQUEST) && id) { - win_print_with_receipt((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message, id); + win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id); } else { - win_print((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); + win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); } } diff --git a/src/ui/ui.h b/src/ui/ui.h index cfda6384..bd38cbe8 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -102,14 +102,14 @@ 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); +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); +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); diff --git a/src/ui/window.c b/src/ui/window.c index ef675c09..808ad825 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -877,11 +877,20 @@ win_show_status_string(ProfWin *window, const char * const from, void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, - const char * const from, const char * const message) + const char * const from, const char * const message, prof_enc_t enc_mode) { + char enc_char = '-'; + switch (window->type) { case WIN_CHAT: + if (enc_mode == PROF_ENC_OTR) { + enc_char = 'O'; + } else if (enc_mode == PROF_ENC_PGP) { + enc_char = 'P'; + } + win_print(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); + break; case WIN_PRIVATE: win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); break; diff --git a/src/ui/window.h b/src/ui/window.h index 64989e4c..603f1cc3 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -60,7 +60,7 @@ void win_show_status_string(ProfWin *window, const char * const from, GDateTime *last_activity, const char * const pre, const char * const default_show); void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, - const char * const from, const char * const message); + const char * const from, const char * const message, prof_enc_t enc_mode); void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, char *id); void win_newline(ProfWin *window); |