refactor: address PR #105 review feedback
Some checks failed
CI Code / Check spelling (pull_request) Successful in 21s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Linux (arch) (pull_request) Failing after 2m52s
CI Code / Code Coverage (pull_request) Successful in 2m56s
CI Code / Linux (debian) (pull_request) Successful in 6m48s
CI Code / Linux (ubuntu) (pull_request) Successful in 7m11s
Some checks failed
CI Code / Check spelling (pull_request) Successful in 21s
CI Code / Check coding style (pull_request) Successful in 35s
CI Code / Linux (arch) (pull_request) Failing after 2m52s
CI Code / Code Coverage (pull_request) Successful in 2m56s
CI Code / Linux (debian) (pull_request) Successful in 6m48s
CI Code / Linux (ubuntu) (pull_request) Successful in 7m11s
Apply fixes, refactors and test additions requested by reviewer on PR #105. Fixes: - database: warn and notify user on duplicate archive_id instead of silently debug-logging it (R05). - database: add missing '[' in "[DB Migration]" log prefix (R06). - xmpp/resource: NULL-out name/status after g_free to avoid double-free via roster_list.c cleanup path (R09, R23). - common: widen strtoi_range internal storage from int to long so that values in (INT_MAX, LONG_MAX] are rejected as out-of-range instead of being silently truncated on 64-bit platforms (R25). Refactors: - xmpp/message: extract _receive_omemo helper, removing three copies of the OMEMO receive block in groupchat / MUC-PM / chat handlers (R04). - omemo: flatten deeply nested device-list processing via guard-clause continues (R11). - tools/autocomplete: merge two nested ifs into a single && condition (R13). - ui/titlebar: extract _show_trust_indicator and inline _wprintw_withattr wrapper, collapsing three near-identical trust-indicator blocks (R22). - config/tlscerts: drop _checked_g_strdup wrapper; g_strdup is NULL-safe per glib documentation (R19). - ui/inputwin: use auto_gchar for spellcheck word instead of manual g_free (R20). - tools/editor: drop outdated "Deprecated synchronous" comment that no longer matches the callback-based implementation (R28). Tests: - tests/command/cmd_ac: rename segfaults_when_empty -> no_segfault_when_empty; expand cycling coverage to three files plus backward SHIFT-TAB traversal (R16, R17). - tests/common: add strtoi_range overflow/underflow and strtol-parsing consistency tests (R25). - tests/xmpp/jid: add test for '@' inside resourcepart per RFC 6122 section 2.4 (R26). Misc: - xmpp/omemo: change omemo_error_to_string return type from char* to gchar* for glib consistency (R01). - subprojects/libstrophe: point wrap-git at our fork at git.jabber.space/devs/libstrophe-gh (R24). - RELEASE_GUIDE: drop "Updating website" section referring to an upstream site that is not ours (R18).
This commit is contained in:
@@ -417,9 +417,8 @@ _inp_write(char* line, int offset)
|
||||
end += next_ch_len;
|
||||
}
|
||||
|
||||
char* word = g_strndup(&line[start], end - start);
|
||||
auto_gchar gchar* word = g_strndup(&line[start], end - start);
|
||||
gboolean misspelled = spellcheck_is_misspelled(word);
|
||||
g_free(word);
|
||||
|
||||
if (misspelled) {
|
||||
wattron(inp_win, theme_attrs(THEME_INPUT_MISSPELLED));
|
||||
|
||||
@@ -45,6 +45,24 @@ static void _show_privacy(ProfChatWin* chatwin);
|
||||
static void _show_muc_privacy(ProfMucWin* mucwin);
|
||||
static void _show_scrolled(ProfWin* current);
|
||||
static void _show_attention(ProfWin* current, gboolean attention);
|
||||
static void _show_trust_indicator(gboolean trusted, int bracket_attrs, int trusted_attrs, int untrusted_attrs);
|
||||
|
||||
static inline void
|
||||
_wprintw_withattr(WINDOW* w, const char* text, int attrs)
|
||||
{
|
||||
wattron(w, attrs);
|
||||
wprintw(w, "%s", text);
|
||||
wattroff(w, attrs);
|
||||
}
|
||||
|
||||
static void
|
||||
_show_trust_indicator(gboolean trusted, int bracket_attrs, int trusted_attrs, int untrusted_attrs)
|
||||
{
|
||||
wprintw(win, " ");
|
||||
_wprintw_withattr(win, "[", bracket_attrs);
|
||||
_wprintw_withattr(win, trusted ? "trusted" : "untrusted", trusted ? trusted_attrs : untrusted_attrs);
|
||||
_wprintw_withattr(win, "]", bracket_attrs);
|
||||
}
|
||||
|
||||
void
|
||||
create_title_bar(void)
|
||||
@@ -433,29 +451,7 @@ _show_muc_privacy(ProfMucWin* mucwin)
|
||||
wattroff(win, bracket_attrs);
|
||||
|
||||
#ifdef HAVE_OMEMO
|
||||
if (mucwin->omemo_trusted) {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, trusted_attrs);
|
||||
wprintw(win, "trusted");
|
||||
wattroff(win, trusted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
} else {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, untrusted_attrs);
|
||||
wprintw(win, "untrusted");
|
||||
wattroff(win, untrusted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
}
|
||||
_show_trust_indicator(mucwin->omemo_trusted, bracket_attrs, trusted_attrs, untrusted_attrs);
|
||||
#endif
|
||||
|
||||
return;
|
||||
@@ -524,29 +520,7 @@ _show_privacy(ProfChatWin* chatwin)
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
if (chatwin->otr_is_trusted) {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, trusted_attrs);
|
||||
wprintw(win, "trusted");
|
||||
wattroff(win, trusted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
} else {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, untrusted_attrs);
|
||||
wprintw(win, "untrusted");
|
||||
wattroff(win, untrusted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
}
|
||||
_show_trust_indicator(chatwin->otr_is_trusted, bracket_attrs, trusted_attrs, untrusted_attrs);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -588,29 +562,7 @@ _show_privacy(ProfChatWin* chatwin)
|
||||
wattroff(win, bracket_attrs);
|
||||
|
||||
#ifdef HAVE_OMEMO
|
||||
if (chatwin->omemo_trusted) {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, trusted_attrs);
|
||||
wprintw(win, "trusted");
|
||||
wattroff(win, trusted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
} else {
|
||||
wprintw(win, " ");
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "[");
|
||||
wattroff(win, bracket_attrs);
|
||||
wattron(win, untrusted_attrs);
|
||||
wprintw(win, "untrusted");
|
||||
wattroff(win, untrusted_attrs);
|
||||
wattron(win, bracket_attrs);
|
||||
wprintw(win, "]");
|
||||
wattroff(win, bracket_attrs);
|
||||
}
|
||||
_show_trust_indicator(chatwin->omemo_trusted, bracket_attrs, trusted_attrs, untrusted_attrs);
|
||||
#endif
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user