Merge pull request #2113 from profanity-im/omemo-noise
Reduce OMEMO noise
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
#include "plugins/plugins.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/avatar.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
@@ -8456,6 +8457,7 @@ cmd_omemo_start(ProfWin* window, const char* const command, gchar** args)
|
||||
win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Initiating OMEMO session with %s...", chatwin->barejid);
|
||||
omemo_start_session(chatwin->barejid);
|
||||
chatwin->is_omemo = TRUE;
|
||||
win_clear_warned_jids((ProfWin*)chatwin);
|
||||
} else if (window->type == WIN_MUC) {
|
||||
ProfMucWin* mucwin = (ProfMucWin*)window;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
@@ -8471,6 +8473,7 @@ cmd_omemo_start(ProfWin* window, const char* const command, gchar** args)
|
||||
win_println((ProfWin*)mucwin, THEME_DEFAULT, "!", "Initiating OMEMO session in %s...", mucwin->roomjid);
|
||||
omemo_start_muc_sessions(mucwin->roomjid);
|
||||
mucwin->is_omemo = TRUE;
|
||||
win_clear_warned_jids((ProfWin*)mucwin);
|
||||
} else {
|
||||
win_println(window, THEME_DEFAULT, "!", "MUC must be non-anonymous (i.e. be configured to present real jid to anyone) and members-only in order to support OMEMO.");
|
||||
}
|
||||
@@ -8589,6 +8592,7 @@ cmd_omemo_end(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
chatwin->is_omemo = FALSE;
|
||||
accounts_add_omemo_state(session_get_account_name(), chatwin->barejid, FALSE);
|
||||
win_clear_warned_jids((ProfWin*)chatwin);
|
||||
} else if (window->type == WIN_MUC) {
|
||||
ProfMucWin* mucwin = (ProfMucWin*)window;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
@@ -8600,6 +8604,7 @@ cmd_omemo_end(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
mucwin->is_omemo = FALSE;
|
||||
accounts_add_omemo_state(session_get_account_name(), mucwin->roomjid, FALSE);
|
||||
win_clear_warned_jids((ProfWin*)mucwin);
|
||||
} else {
|
||||
win_println(window, THEME_DEFAULT, "-", "You must be in a regular chat window to start an OMEMO session.");
|
||||
return TRUE;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "omemo/omemo.h"
|
||||
#include "omemo/store.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/connection.h"
|
||||
#include "xmpp/muc.h"
|
||||
@@ -514,18 +515,21 @@ omemo_set_device_list(const char* const from, GList* device_list)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
if (equals_our_barejid(jid->barejid)) {
|
||||
if (dev_id != omemo_ctx.device_id) {
|
||||
cons_show("New OMEMO device (ID: %u) added to your account.", dev_id);
|
||||
}
|
||||
} else {
|
||||
ProfChatWin* chatwin = wins_get_chat(jid->barejid);
|
||||
if (chatwin) {
|
||||
win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "New OMEMO device (ID: %u) found for %s.", dev_id, jid->barejid);
|
||||
auto_gchar gchar* dev_id_str = g_strdup_printf("%u", dev_id);
|
||||
if (!g_key_file_has_key(omemo_ctx.knowndevices.keyfile, jid->barejid, dev_id_str, NULL)) {
|
||||
if (equals_our_barejid(jid->barejid)) {
|
||||
if (dev_id != omemo_ctx.device_id) {
|
||||
cons_show("New OMEMO device (ID: %u) added to your account.", dev_id);
|
||||
}
|
||||
} else {
|
||||
ProfMucWin* mucwin = wins_get_muc(jid->barejid);
|
||||
if (mucwin) {
|
||||
win_println((ProfWin*)mucwin, THEME_DEFAULT, "!", "New OMEMO device (ID: %u) found for %s.", dev_id, jid->barejid);
|
||||
ProfChatWin* chatwin = wins_get_chat(jid->barejid);
|
||||
if (chatwin) {
|
||||
win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "New OMEMO device (ID: %u) found for %s.", dev_id, jid->barejid);
|
||||
} else {
|
||||
ProfMucWin* mucwin = wins_get_muc(jid->barejid);
|
||||
if (mucwin) {
|
||||
win_println((ProfWin*)mucwin, THEME_DEFAULT, "!", "New OMEMO device (ID: %u) found for %s.", dev_id, jid->barejid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -728,17 +732,6 @@ omemo_start_device_session(const char* const jid, uint32_t device_id,
|
||||
}
|
||||
} else {
|
||||
log_debug("[OMEMO] session with %s device %d exists", jid, device_id);
|
||||
if (omemo_ctx.notifying) {
|
||||
ProfChatWin* chatwin = wins_get_chat(jid);
|
||||
if (chatwin) {
|
||||
win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "OMEMO session with %s (device %u) already exists.", jid, device_id);
|
||||
} else {
|
||||
ProfMucWin* mucwin = wins_get_muc(jid);
|
||||
if (mucwin) {
|
||||
win_println((ProfWin*)mucwin, THEME_DEFAULT, "!", "OMEMO session with %s (device %u) already exists.", jid, device_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
@@ -822,7 +815,11 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
||||
recipient_device_id = g_hash_table_lookup(omemo_ctx.device_list, recipients_iter->data);
|
||||
if (!recipient_device_id) {
|
||||
log_warning("[OMEMO][SEND] cannot find device ids for %s", recipients_iter->data);
|
||||
win_println(win, THEME_ERROR, "!", "Can't find a OMEMO device id for %s.\n", recipients_iter->data);
|
||||
|
||||
if (win_warn_needed(win, "omemo_no_device", recipients_iter->data)) {
|
||||
win_println(win, THEME_ERROR, "!", "Can't find a OMEMO device id for %s.", recipients_iter->data);
|
||||
win_warn_sent(win, "omemo_no_device", recipients_iter->data);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ typedef struct prof_win_t
|
||||
ProfLayout* layout;
|
||||
Autocomplete urls_ac;
|
||||
Autocomplete quotes_ac;
|
||||
GHashTable* warned_jids;
|
||||
} ProfWin;
|
||||
|
||||
typedef struct prof_console_win_t
|
||||
|
||||
@@ -557,6 +557,10 @@ win_free(ProfWin* window)
|
||||
}
|
||||
free(window->layout);
|
||||
|
||||
if (window->warned_jids) {
|
||||
g_hash_table_destroy(window->warned_jids);
|
||||
}
|
||||
|
||||
switch (window->type) {
|
||||
case WIN_CHAT:
|
||||
{
|
||||
@@ -609,6 +613,44 @@ win_free(ProfWin* window)
|
||||
free(window);
|
||||
}
|
||||
|
||||
gboolean
|
||||
win_warn_needed(ProfWin* window, const char* const type, const char* const jid)
|
||||
{
|
||||
if (!window || !type || !jid) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!window->warned_jids) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
auto_gchar gchar* key = g_strdup_printf("%s:%s", type, jid);
|
||||
return !g_hash_table_contains(window->warned_jids, key);
|
||||
}
|
||||
|
||||
void
|
||||
win_warn_sent(ProfWin* window, const char* const type, const char* const jid)
|
||||
{
|
||||
if (!window || !type || !jid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!window->warned_jids) {
|
||||
window->warned_jids = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
|
||||
}
|
||||
|
||||
gchar* key = g_strdup_printf("%s:%s", type, jid);
|
||||
g_hash_table_insert(window->warned_jids, key, GINT_TO_POINTER(1));
|
||||
}
|
||||
|
||||
void
|
||||
win_clear_warned_jids(ProfWin* window)
|
||||
{
|
||||
if (window && window->warned_jids) {
|
||||
g_hash_table_remove_all(window->warned_jids);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
win_page_up(ProfWin* window, int scroll_size)
|
||||
{
|
||||
|
||||
@@ -59,6 +59,10 @@ void win_update_entry_message(ProfWin* window, const char* const id, const char*
|
||||
|
||||
gboolean win_has_active_subwin(ProfWin* window);
|
||||
|
||||
gboolean win_warn_needed(ProfWin* window, const char* const type, const char* const jid);
|
||||
void win_warn_sent(ProfWin* window, const char* const type, const char* const jid);
|
||||
void win_clear_warned_jids(ProfWin* window);
|
||||
|
||||
void win_page_up(ProfWin* window, int scroll_size);
|
||||
void win_page_down(ProfWin* window, int scroll_size);
|
||||
void win_sub_page_down(ProfWin* window);
|
||||
|
||||
@@ -1318,6 +1318,22 @@ win_refresh_with_subwin(ProfWin* window)
|
||||
{
|
||||
}
|
||||
|
||||
gboolean
|
||||
win_warn_needed(ProfWin* window, const char* const type, const char* const jid)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
win_warn_sent(ProfWin* window, const char* const type, const char* const jid)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
win_clear_warned_jids(ProfWin* window)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
win_println(ProfWin* window, theme_item_t theme, const char* ch, const char* const message, ...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user