mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-21 07:36:21 +00:00
feat: Add OMEMO trust status indicators to the titlebar
Previously the titlebar only showed [OMEMO], regardless of whether the active session contained untrusted devices. This forced users to manually run /omemo fingerprint to check the security status of their conversation, making it difficult to know at a glance if a session was truly secure. New function `omemo_is_jid_trusted()` to check if all active devices for a JID are trusted. Update chat and MUC titlebar to display [trusted] or [untrusted] tags when an OMEMO session is active. Not sure if MUC makes sense here?
This commit is contained in:
@@ -1155,6 +1155,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_INT(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_INT(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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user