diff options
author | James Booth <boothj5@gmail.com> | 2015-08-26 00:42:56 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-08-26 00:42:56 +0100 |
commit | f998ab8f3b71922ad20646dc4598cd61d2e7bc36 (patch) | |
tree | 0cc088b975dc06d3b516f5f136c1dad2b9222157 /src/ui | |
parent | 4b0ee89fa3dca49604532c0185cf48cf601ac08a (diff) | |
download | profani-tty-f998ab8f3b71922ad20646dc4598cd61d2e7bc36.tar.gz |
Display special char for encrypted messages
Diffstat (limited to 'src/ui')
-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 |
4 files changed, 28 insertions, 12 deletions
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); |