Show encryption for historical messages

Refactor getting char, introduce get_show_char() to follow DRY principle.

In theory, performance might be negatively affected after this change.

Ideally get_show_char should be optimized in the future.
This commit is contained in:
John Hernandez
2023-11-03 11:27:30 +01:00
parent 0b957d6207
commit 7af0e9b1e1
4 changed files with 35 additions and 38 deletions

View File

@@ -518,16 +518,8 @@ mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* c
auto_char char* ch;
if (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 {
ch = strdup("-");
ch = get_show_char(enc_mode);
}
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;
if (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 {
ch = strdup("-");
ch = get_show_char(message->enc);
}
win_insert_last_read_position_marker((ProfWin*)mucwin, mucwin->roomjid);