mirror of
https://github.com/profanity-im/profanity.git
synced 2024-06-23 21:45:30 +00:00
Merge pull request #1910 from H3rnand3zzz/fix/show-char-dry-and-db
Show encryption for historical messages
This commit is contained in:
commit
83fdd9b8d6
|
@ -433,16 +433,8 @@ chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id,
|
||||||
auto_char char* enc_char;
|
auto_char char* enc_char;
|
||||||
if (chatwin->outgoing_char) {
|
if (chatwin->outgoing_char) {
|
||||||
enc_char = chatwin->outgoing_char;
|
enc_char = chatwin->outgoing_char;
|
||||||
} else if (enc_mode == PROF_MSG_ENC_OTR) {
|
|
||||||
enc_char = prefs_get_otr_char();
|
|
||||||
} else if (enc_mode == PROF_MSG_ENC_PGP) {
|
|
||||||
enc_char = prefs_get_pgp_char();
|
|
||||||
} else if (enc_mode == PROF_MSG_ENC_OMEMO) {
|
|
||||||
enc_char = prefs_get_omemo_char();
|
|
||||||
} else if (enc_mode == PROF_MSG_ENC_OX) {
|
|
||||||
enc_char = prefs_get_ox_char();
|
|
||||||
} else {
|
} else {
|
||||||
enc_char = strdup("-");
|
enc_char = get_show_char(enc_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request_receipt && id) {
|
if (request_receipt && id) {
|
||||||
|
|
|
@ -518,16 +518,8 @@ mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* c
|
||||||
auto_char char* ch;
|
auto_char char* ch;
|
||||||
if (mucwin->message_char) {
|
if (mucwin->message_char) {
|
||||||
ch = strdup(mucwin->message_char);
|
ch = strdup(mucwin->message_char);
|
||||||
} else if (enc_mode == PROF_MSG_ENC_OTR) {
|
|
||||||
ch = prefs_get_otr_char();
|
|
||||||
} else if (enc_mode == PROF_MSG_ENC_PGP) {
|
|
||||||
ch = prefs_get_pgp_char();
|
|
||||||
} else if (enc_mode == PROF_MSG_ENC_OMEMO) {
|
|
||||||
ch = prefs_get_omemo_char();
|
|
||||||
} else if (enc_mode == PROF_MSG_ENC_OX) {
|
|
||||||
ch = prefs_get_omemo_char();
|
|
||||||
} else {
|
} else {
|
||||||
ch = strdup("-");
|
ch = get_show_char(enc_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
win_print_outgoing_muc_msg(window, ch, mynick, id, replace_id, message);
|
win_print_outgoing_muc_msg(window, ch, mynick, id, replace_id, message);
|
||||||
|
@ -566,14 +558,8 @@ mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList
|
||||||
auto_char char* ch;
|
auto_char char* ch;
|
||||||
if (mucwin->message_char) {
|
if (mucwin->message_char) {
|
||||||
ch = strdup(mucwin->message_char);
|
ch = strdup(mucwin->message_char);
|
||||||
} else if (message->enc == PROF_MSG_ENC_OTR) {
|
|
||||||
ch = prefs_get_otr_char();
|
|
||||||
} else if (message->enc == PROF_MSG_ENC_PGP) {
|
|
||||||
ch = prefs_get_pgp_char();
|
|
||||||
} else if (message->enc == PROF_MSG_ENC_OMEMO) {
|
|
||||||
ch = prefs_get_omemo_char();
|
|
||||||
} else {
|
} else {
|
||||||
ch = strdup("-");
|
ch = get_show_char(message->enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
win_insert_last_read_position_marker((ProfWin*)mucwin, mucwin->roomjid);
|
win_insert_last_read_position_marker((ProfWin*)mucwin, mucwin->roomjid);
|
||||||
|
|
|
@ -1394,16 +1394,8 @@ win_print_incoming(ProfWin* window, const char* const display_name_from, ProfMes
|
||||||
|
|
||||||
if (chatwin->incoming_char) {
|
if (chatwin->incoming_char) {
|
||||||
enc_char = strdup(chatwin->incoming_char);
|
enc_char = strdup(chatwin->incoming_char);
|
||||||
} else if (message->enc == PROF_MSG_ENC_OTR) {
|
|
||||||
enc_char = prefs_get_otr_char();
|
|
||||||
} else if (message->enc == PROF_MSG_ENC_PGP) {
|
|
||||||
enc_char = prefs_get_pgp_char();
|
|
||||||
} else if (message->enc == PROF_MSG_ENC_OX) { // XEP-0373: OpenPGP for XMPP
|
|
||||||
enc_char = prefs_get_ox_char();
|
|
||||||
} else if (message->enc == PROF_MSG_ENC_OMEMO) {
|
|
||||||
enc_char = prefs_get_omemo_char();
|
|
||||||
} else {
|
} else {
|
||||||
enc_char = strdup("-");
|
enc_char = get_show_char(message->enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) {
|
if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) {
|
||||||
|
@ -1492,10 +1484,12 @@ win_print_history(ProfWin* window, const ProfMessage* const message)
|
||||||
flags = NO_ME;
|
flags = NO_ME;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_append(window->layout->buffer, "-", 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, NULL, message->plain, NULL, NULL);
|
auto_char char* ch = get_show_char(message->enc);
|
||||||
|
|
||||||
|
buffer_append(window->layout->buffer, ch, 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, NULL, message->plain, NULL, NULL);
|
||||||
wins_add_urls_ac(window, message, FALSE);
|
wins_add_urls_ac(window, message, FALSE);
|
||||||
wins_add_quotes_ac(window, message->plain, FALSE);
|
wins_add_quotes_ac(window, message->plain, FALSE);
|
||||||
_win_print_internal(window, "-", 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, message->plain, NULL);
|
_win_print_internal(window, ch, 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, message->plain, NULL);
|
||||||
|
|
||||||
inp_nonblocking(TRUE);
|
inp_nonblocking(TRUE);
|
||||||
g_date_time_unref(message->timestamp);
|
g_date_time_unref(message->timestamp);
|
||||||
|
@ -1518,10 +1512,12 @@ win_print_old_history(ProfWin* window, const ProfMessage* const message)
|
||||||
flags = NO_ME;
|
flags = NO_ME;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_prepend(window->layout->buffer, "-", 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, NULL, message->plain, NULL, NULL);
|
auto_char char* ch = get_show_char(message->enc);
|
||||||
|
|
||||||
|
buffer_prepend(window->layout->buffer, ch, 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, NULL, message->plain, NULL, NULL);
|
||||||
wins_add_urls_ac(window, message, TRUE);
|
wins_add_urls_ac(window, message, TRUE);
|
||||||
wins_add_quotes_ac(window, message->plain, TRUE);
|
wins_add_quotes_ac(window, message->plain, TRUE);
|
||||||
_win_print_internal(window, "-", 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, message->plain, NULL);
|
_win_print_internal(window, ch, 0, message->timestamp, flags, THEME_TEXT_HISTORY, display_name, message->plain, NULL);
|
||||||
|
|
||||||
inp_nonblocking(TRUE);
|
inp_nonblocking(TRUE);
|
||||||
g_date_time_unref(message->timestamp);
|
g_date_time_unref(message->timestamp);
|
||||||
|
@ -2239,3 +2235,24 @@ win_quote_autocomplete(ProfWin* window, const char* const input, gboolean previo
|
||||||
|
|
||||||
return g_strdup_printf("> %s\n", quoted_result);
|
return g_strdup_printf("> %s\n", quoted_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Derive encryption char from encryption mode. Output needs to be freed by caller.
|
||||||
|
char*
|
||||||
|
get_show_char(prof_enc_t encryption_mode)
|
||||||
|
{
|
||||||
|
char* enc_char;
|
||||||
|
|
||||||
|
if (encryption_mode == PROF_MSG_ENC_OTR) {
|
||||||
|
enc_char = prefs_get_otr_char();
|
||||||
|
} else if (encryption_mode == PROF_MSG_ENC_PGP) {
|
||||||
|
enc_char = prefs_get_pgp_char();
|
||||||
|
} else if (encryption_mode == PROF_MSG_ENC_OMEMO) {
|
||||||
|
enc_char = prefs_get_omemo_char();
|
||||||
|
} else if (encryption_mode == PROF_MSG_ENC_OX) {
|
||||||
|
enc_char = prefs_get_ox_char();
|
||||||
|
} else {
|
||||||
|
enc_char = strdup("-");
|
||||||
|
}
|
||||||
|
|
||||||
|
return enc_char;
|
||||||
|
}
|
||||||
|
|
|
@ -98,4 +98,6 @@ void win_remove_entry_message(ProfWin* window, const char* const id);
|
||||||
|
|
||||||
char* win_quote_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
char* win_quote_autocomplete(ProfWin* window, const char* const input, gboolean previous);
|
||||||
|
|
||||||
|
char* get_show_char(prof_enc_t encryption_mode);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user