fix: add missing omemo_is_jid_trusted(), auto_gerror macro, and titlebar variable declarations
Some checks failed
CI Code / Check coding style (pull_request) Failing after 12s
CI Code / Check spelling (pull_request) Successful in 23s
CI Code / Linux (debian) (pull_request) Failing after 5m42s
CI Code / Linux (ubuntu) (pull_request) Failing after 6m3s
CI Code / Code Coverage (pull_request) Successful in 7m2s
CI Code / Linux (arch) (pull_request) Failing after 8m20s

Fixes build errors from cherry-picked upstream patches:
- Add omemo_is_jid_trusted() function (from upstream trust indicator feature)
- Add auto_gerror/PROF_GERROR_MESSAGE macros (needed by /changes command)
- Add trusted_attrs/untrusted_attrs declarations in _show_muc_privacy()
- Remove stale 'error' reference in omemo_receive_message()
This commit is contained in:
2026-03-31 20:13:43 +03:00
parent 7bb8f2efb3
commit 48b36a0269
7 changed files with 69 additions and 5 deletions

View File

@@ -1266,11 +1266,6 @@ cmd_sub(ProfWin* window, const char* const command, gchar** args)
auto_jid Jid* jidp = jid_create(jid);
if (!jidp) {
cons_bad_cmd_usage(command);
return TRUE;
}
if (jidp == NULL) {
cons_show("Malformed JID: %s", jid);
return TRUE;
}

View File

@@ -105,6 +105,15 @@ auto_free_guchar(guchar** ptr)
g_free(*ptr);
}
void
auto_free_gerror(GError** err)
{
if (err == NULL || *err == NULL) {
return;
}
g_error_free(*err);
}
/**
* Frees the memory allocated for a gchar** string array.
*

View File

@@ -104,6 +104,10 @@ void auto_free_guchar(guchar** str);
*/
#define auto_guchar __attribute__((__cleanup__(auto_free_guchar)))
void auto_free_gerror(GError** err);
#define auto_gerror __attribute__((__cleanup__(auto_free_gerror)))
#define PROF_GERROR_MESSAGE(err) ((err) ? (err)->message : "unknown")
#define auto_gfd __attribute__((__cleanup__(auto_close_gfd)))
void auto_close_gfd(gint* fd);

View File

@@ -1136,6 +1136,53 @@ omemo_is_trusted_identity(const char* const jid, const char* const fingerprint)
return trusted;
}
gboolean
omemo_is_jid_trusted(const char* const jid)
{
if (!omemo_loaded()) {
return FALSE;
}
GList* device_list = g_hash_table_lookup(omemo_ctx.device_list, jid);
if (!device_list) {
return FALSE;
}
GList* device_id_iter;
for (device_id_iter = device_list; device_id_iter != NULL; device_id_iter = device_id_iter->next) {
uint32_t device_id = GPOINTER_TO_UINT(device_id_iter->data);
if (device_id == omemo_ctx.device_id && equals_our_barejid(jid)) {
continue;
}
GHashTable* known_identities = g_hash_table_lookup(omemo_ctx.known_devices, jid);
if (!known_identities) {
return FALSE;
}
gboolean found = FALSE;
GList* fp_list = g_hash_table_get_keys(known_identities);
GList* fp_iter;
for (fp_iter = fp_list; fp_iter != NULL; fp_iter = fp_iter->next) {
if (device_id == GPOINTER_TO_UINT(g_hash_table_lookup(known_identities, fp_iter->data))) {
if (!omemo_is_trusted_identity(jid, fp_iter->data)) {
g_list_free(fp_list);
return FALSE;
}
found = TRUE;
break;
}
}
g_list_free(fp_list);
if (!found) {
return FALSE;
}
}
return TRUE;
}
static char*
_omemo_fingerprint(ec_public_key* identity, gboolean formatted)
{

View File

@@ -85,6 +85,7 @@ void omemo_trust(const char* const jid, const char* const fingerprint);
void omemo_untrust(const char* const jid, const char* const fingerprint);
GList* omemo_known_device_identities(const char* const jid);
gboolean omemo_is_trusted_identity(const char* const jid, const char* const fingerprint);
gboolean omemo_is_jid_trusted(const char* const jid);
char* omemo_fingerprint_autocomplete(const char* const search_str, gboolean previous, void* context);
void omemo_fingerprint_autocomplete_reset(void);
gboolean omemo_automatic_start(const char* const recipient);

View File

@@ -438,6 +438,8 @@ _show_muc_privacy(ProfMucWin* mucwin)
{
int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED);
int trusted_attrs = theme_attrs(THEME_TITLE_TRUSTED);
int untrusted_attrs = theme_attrs(THEME_TITLE_UNTRUSTED);
if (mucwin->is_omemo) {
wprintw(win, " ");

View File

@@ -42,6 +42,12 @@ omemo_is_trusted_identity(const char* const jid, const char* const fingerprint)
return TRUE;
}
gboolean
omemo_is_jid_trusted(const char* const jid)
{
return TRUE;
}
GList*
omemo_known_device_identities(const char* const jid)
{