about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-04-12 00:37:20 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-04-12 00:42:02 +0200
commit51518497e5bb11aa795ef2267512786eb16467df (patch)
tree63e5c886fca95107969ccaee06179ab43998d418 /src/ui
parent98200ebd43e90d8662fee5e014bbe3dc1709a6d7 (diff)
downloadprofani-tty-51518497e5bb11aa795ef2267512786eb16467df.tar.gz
Add hidden MAM setting and trigger MAM retrievel when opening new window
Only when we start the conversation.
Not yet when we get messaged and a new window is opened.
Need to have sorting of messages in the window buffer then, I guess.
Also MAM IQ should only be send one time in such a case.

If MAM is enabled history from sql backend will not be shown.

`mam` in profrc enables experimental MAM.
Can change soon again. Don't rely on stuff in this stage ;)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/chatwin.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 1c04432c..22992ecd 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -57,7 +57,7 @@
 #include "omemo/omemo.h"
 #endif
 
-/*static void _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid);*/
+static void _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid);
 static void _chatwin_set_last_message(ProfChatWin *chatwin, const char *const id, const char *const message);
 
 ProfChatWin*
@@ -66,8 +66,8 @@ chatwin_new(const char *const barejid)
     ProfWin *window = wins_new_chat(barejid);
     ProfChatWin *chatwin = (ProfChatWin *)window;
 
-    if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
-        //_chatwin_history(chatwin, barejid);
+    if (!prefs_get_boolean(PREF_MAM) && prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
+        _chatwin_history(chatwin, barejid);
     }
 
     // if the contact is offline, show a message
@@ -87,7 +87,9 @@ chatwin_new(const char *const barejid)
     }
 #endif
 
-    iq_mam_request(chatwin);
+    if (prefs_get_boolean(PREF_MAM)) {
+        iq_mam_request(chatwin);
+    }
     return chatwin;
 }
 
@@ -285,8 +287,13 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr
 
         chatwin->unread++;
 
-        if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
-//            _chatwin_history(chatwin, chatwin->barejid);
+        //TODO: so far we don't ask for MAM when incoming message occurs.
+        //Need to figure out:
+        //1) only send IQ once
+        //2) sort incoming messages on timestamp
+        //for now if experimental MAM is enabled we dont show no history from sql either
+        if (!prefs_get_boolean(PREF_MAM) && prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
+            _chatwin_history(chatwin, chatwin->barejid);
         }
 
         // show users status first, when receiving message via delayed delivery
@@ -485,7 +492,6 @@ chatwin_unset_outgoing_char(ProfChatWin *chatwin)
     }
 }
 
-/*
 static void
 _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid)
 {
@@ -503,7 +509,6 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid)
         g_slist_free_full(history, (GDestroyNotify)message_free);
     }
 }
-*/
 
 static void
 _chatwin_set_last_message(ProfChatWin *chatwin, const char *const id, const char *const message)