about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/chatwin.c4
-rw-r--r--src/ui/console.c24
-rw-r--r--src/ui/mucwin.c53
-rw-r--r--src/ui/titlebar.c30
-rw-r--r--src/ui/ui.h7
-rw-r--r--src/ui/win_types.h3
-rw-r--r--src/ui/window.c5
-rw-r--r--src/ui/window_list.c1
8 files changed, 114 insertions, 13 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 98431a60..5064b194 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -305,6 +305,8 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
         enc_char = prefs_get_otr_char();
     } else if (enc_mode == PROF_MSG_PGP) {
         enc_char = prefs_get_pgp_char();
+    } else if (enc_mode == PROF_MSG_OMEMO) {
+        enc_char = prefs_get_omemo_char();
     }
 
     if (request_receipt && id) {
@@ -322,6 +324,8 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en
     char enc_char = '-';
     if (enc_mode == PROF_MSG_PGP) {
         enc_char = prefs_get_pgp_char();
+    } else if (enc_mode == PROF_MSG_OMEMO) {
+        enc_char = prefs_get_omemo_char();
     }
 
     ProfWin *window = (ProfWin*)chatwin;
diff --git a/src/ui/console.c b/src/ui/console.c
index e5c12158..260658c8 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1999,6 +1999,28 @@ cons_show_pgp_prefs(void)
 }
 
 void
+cons_show_omemo_prefs(void)
+{
+    cons_show("OMEMO preferences:");
+    cons_show("");
+
+    char *log_value = prefs_get_string(PREF_OMEMO_LOG);
+    if (strcmp(log_value, "on") == 0) {
+        cons_show("OMEMO logging (/omemo log)   : ON");
+    } else if (strcmp(log_value, "off") == 0) {
+        cons_show("OMEMO logging (/omemo log)   : OFF");
+    } else {
+        cons_show("OMEMO logging (/omemo log)   : Redacted");
+    }
+    prefs_free_string(log_value);
+
+    char ch = prefs_get_omemo_char();
+    cons_show("OMEMO char (/omemo char)     : %c", ch);
+
+    cons_alert();
+}
+
+void
 cons_show_themes(GSList *themes)
 {
     cons_show("");
@@ -2072,6 +2094,8 @@ cons_prefs(void)
     cons_show("");
     cons_show_pgp_prefs();
     cons_show("");
+    cons_show_omemo_prefs();
+    cons_show("");
 
     cons_alert();
 }
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index 0f9f4f2b..0122950a 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -478,29 +478,60 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge
 }
 
 void
-mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message, GSList *mentions, GList *triggers)
+mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode)
 {
     assert(mucwin != NULL);
 
+    g_hash_table_insert(mucwin->sent_messages, strdup(id), NULL);
+
     ProfWin *window = (ProfWin*)mucwin;
     char *mynick = muc_nick(mucwin->roomjid);
 
     char ch = '-';
     if (mucwin->message_char) {
         ch = mucwin->message_char[0];
+    } else if (enc_mode == PROF_MSG_OTR) {
+        ch = prefs_get_otr_char();
+    } else if (enc_mode == PROF_MSG_PGP) {
+        ch = prefs_get_pgp_char();
+    } else if (enc_mode == PROF_MSG_OMEMO) {
+        ch = prefs_get_omemo_char();
     }
 
-    if (g_strcmp0(nick, mynick) != 0) {
-        if (g_slist_length(mentions) > 0) {
-            _mucwin_print_mention(window, message, nick, mynick, mentions, &ch);
-        } else if (triggers) {
-            win_print_them(window, THEME_ROOMTRIGGER, ch, nick);
-            _mucwin_print_triggers(window, message, triggers);
-        } else {
-            win_println_them_message(window, ch, nick, "%s", message);
-        }
+    win_println_me_message(window, ch, mynick, "%s", message);
+}
+
+void
+mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, const char *const id, GSList *mentions, GList *triggers, prof_enc_t enc_mode)
+{
+    assert(mucwin != NULL);
+
+    if (g_hash_table_remove(mucwin->sent_messages, id)) {
+        /* Ignore reflection messages */
+        return;
+    }
+
+    ProfWin *window = (ProfWin*)mucwin;
+    char *mynick = muc_nick(mucwin->roomjid);
+
+    char ch = '-';
+    if (mucwin->message_char) {
+        ch = mucwin->message_char[0];
+    } else if (enc_mode == PROF_MSG_OTR) {
+        ch = prefs_get_otr_char();
+    } else if (enc_mode == PROF_MSG_PGP) {
+        ch = prefs_get_pgp_char();
+    } else if (enc_mode == PROF_MSG_OMEMO) {
+        ch = prefs_get_omemo_char();
+    }
+
+    if (g_slist_length(mentions) > 0) {
+        _mucwin_print_mention(window, message, nick, mynick, mentions, &ch);
+    } else if (triggers) {
+        win_print_them(window, THEME_ROOMTRIGGER, ch, nick);
+        _mucwin_print_triggers(window, message, triggers);
     } else {
-        win_println_me_message(window, ch, mynick, "%s", message);
+        win_println_them_message(window, ch, nick, "%s", message);
     }
 }
 
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index f519fdd2..e1758d81 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -321,6 +321,21 @@ _show_muc_privacy(ProfMucWin *mucwin)
     int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
     int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED);
 
+    if (mucwin->is_omemo) {
+        wprintw(win, " ");
+        wattron(win, bracket_attrs);
+        wprintw(win, "[");
+        wattroff(win, bracket_attrs);
+        wattron(win, encrypted_attrs);
+        wprintw(win, "OMEMO");
+        wattroff(win, encrypted_attrs);
+        wattron(win, bracket_attrs);
+        wprintw(win, "]");
+        wattroff(win, bracket_attrs);
+
+        return;
+    }
+
     if (mucwin->enctext) {
         wprintw(win, " ");
         wattron(win, bracket_attrs);
@@ -421,6 +436,21 @@ _show_privacy(ProfChatWin *chatwin)
         return;
     }
 
+    if (chatwin->is_omemo) {
+        wprintw(win, " ");
+        wattron(win, bracket_attrs);
+        wprintw(win, "[");
+        wattroff(win, bracket_attrs);
+        wattron(win, encrypted_attrs);
+        wprintw(win, "OMEMO");
+        wattroff(win, encrypted_attrs);
+        wattron(win, bracket_attrs);
+        wprintw(win, "]");
+        wattroff(win, bracket_attrs);
+
+        return;
+    }
+
     if (prefs_get_boolean(PREF_ENC_WARN)) {
         wprintw(win, " ");
         wattron(win, bracket_attrs);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index ad5a1216..b94fe475 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -56,7 +56,8 @@
 typedef enum {
     PROF_MSG_PLAIN,
     PROF_MSG_OTR,
-    PROF_MSG_PGP
+    PROF_MSG_PGP,
+    PROF_MSG_OMEMO
 } prof_enc_t;
 
 // core UI
@@ -161,7 +162,8 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char
     const char *const role, const char *const affiliation, const char *const actor, const char *const reason);
 void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence);
 void mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, const char *const message);
-void mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message, GSList *mentions, GList *triggers);
+void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode);
+void mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, const char *const id, GSList *mentions, GList *triggers, prof_enc_t enc_mode);
 void mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject);
 void mucwin_requires_config(ProfMucWin *mucwin);
 void mucwin_info(ProfMucWin *mucwin);
@@ -250,6 +252,7 @@ void cons_show_presence_prefs(void);
 void cons_show_connection_prefs(void);
 void cons_show_otr_prefs(void);
 void cons_show_pgp_prefs(void);
+void cons_show_omemo_prefs(void);
 void cons_show_account(ProfAccount *account);
 void cons_debug(const char *const msg, ...);
 void cons_show_error(const char *const cmd, ...);
diff --git a/src/ui/win_types.h b/src/ui/win_types.h
index 92618a36..e1e64bf9 100644
--- a/src/ui/win_types.h
+++ b/src/ui/win_types.h
@@ -152,6 +152,7 @@ typedef struct prof_chat_win_t {
     gboolean otr_is_trusted;
     gboolean pgp_send;
     gboolean pgp_recv;
+    gboolean is_omemo;
     char *resource_override;
     gboolean history_shown;
     unsigned long memcheck;
@@ -167,9 +168,11 @@ typedef struct prof_muc_win_t {
     gboolean unread_mentions;
     gboolean unread_triggers;
     gboolean showjid;
+    gboolean is_omemo;
     unsigned long memcheck;
     char *enctext;
     char *message_char;
+    GHashTable *sent_messages;
 } ProfMucWin;
 
 typedef struct prof_conf_win_t ProfConfWin;
diff --git a/src/ui/window.c b/src/ui/window.c
index cc2c2062..12b6c15b 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -143,6 +143,7 @@ win_create_chat(const char *const barejid)
     new_win->otr_is_trusted = FALSE;
     new_win->pgp_recv = FALSE;
     new_win->pgp_send = FALSE;
+    new_win->is_omemo = FALSE;
     new_win->history_shown = FALSE;
     new_win->unread = 0;
     new_win->state = chat_state_new();
@@ -196,6 +197,8 @@ win_create_muc(const char *const roomjid)
     }
     new_win->enctext = NULL;
     new_win->message_char = NULL;
+    new_win->is_omemo = FALSE;
+    new_win->sent_messages = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
 
     new_win->memcheck = PROFMUCWIN_MEMCHECK;
 
@@ -1057,6 +1060,8 @@ win_print_incoming(ProfWin *window, GDateTime *timestamp,
                 enc_char = prefs_get_otr_char();
             } else if (enc_mode == PROF_MSG_PGP) {
                 enc_char = prefs_get_pgp_char();
+            } else if (enc_mode == PROF_MSG_OMEMO) {
+                enc_char = prefs_get_omemo_char();
             }
             _win_printf(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message);
             break;
diff --git a/src/ui/window_list.c b/src/ui/window_list.c
index 5ce68d63..43230b57 100644
--- a/src/ui/window_list.c
+++ b/src/ui/window_list.c
@@ -561,6 +561,7 @@ wins_close_by_num(int i)
                 ProfMucWin *mucwin = (ProfMucWin*)window;
                 autocomplete_remove(wins_ac, mucwin->roomjid);
                 autocomplete_remove(wins_close_ac, mucwin->roomjid);
+                g_hash_table_remove_all(mucwin->sent_messages);
                 break;
             }
             case WIN_PRIVATE: