about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-08-10 15:23:30 +0200
committerMichael Vetter <jubalh@iodoru.org>2021-01-28 14:44:35 +0100
commit014e03c72e691ff701dccc8c46fb74873419afbe (patch)
treed9189b75c55889e64aebd8defd519d553f4f01cf /src/xmpp
parent6a17e9d50ebeb7217a21a3147088fb3822f95459 (diff)
downloadprofani-tty-014e03c72e691ff701dccc8c46fb74873419afbe.tar.gz
Start working on MAM RSM to get more pages
Regards https://github.com/profanity-im/profanity/issues/660
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/iq.c25
-rw-r--r--src/xmpp/stanza.h3
2 files changed, 27 insertions, 1 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index d1797a72..56659c1a 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -142,6 +142,7 @@ static int _auto_pong_id_handler(xmpp_stanza_t* const stanza, void* const userda
 static int _room_list_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
 static int _command_list_result_handler(xmpp_stanza_t* const stanza, void* const userdata);
 static int _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata);
+static int _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
 
 static void _iq_free_room_data(ProfRoomInfoData* roominfo);
 static void _iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set);
@@ -2559,7 +2560,7 @@ iq_mam_request(ProfChatWin* win)
     g_free(datestr);
     g_date_time_unref(timestamp);
 
-    //    iq_id_handler_add(id, _http_upload_response_id_handler, NULL, upload);
+    iq_id_handler_add(id, _mam_rsm_id_handler, NULL, NULL);
     free(id);
 
     iq_send_stanza(iq);
@@ -2567,3 +2568,25 @@ iq_mam_request(ProfChatWin* win)
 
     return;
 }
+
+static int
+_mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
+{
+    const char* type = xmpp_stanza_get_type(stanza);
+    if (g_strcmp0(type, "error") == 0) {
+        //TODO
+        //char* error_message = stanza_get_error_message(stanza);
+    } else if (g_strcmp0(type, "result") == 0) {
+        xmpp_stanza_t* fin = stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_FIN, STANZA_NS_MAM2);
+        if (fin) {
+            xmpp_stanza_t* set = stanza_get_child_by_name_and_ns(fin, STANZA_TYPE_SET, STANZA_NS_RSM);
+            if (set) {
+                xmpp_stanza_t* last =  xmpp_stanza_get_child_by_name(set, STANZA_NAME_LAST);
+                char* lastid = xmpp_stanza_get_text(last);
+                lastid = lastid;
+            }
+        }
+    }
+
+    return 0;
+}
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 95cdc29b..f57a6d22 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -113,6 +113,8 @@
 #define STANZA_NAME_STANZA_ID        "stanza-id"
 #define STANZA_NAME_RESULT           "result"
 #define STANZA_NAME_MINIMIZE         "minimize"
+#define STANZA_NAME_FIN              "fin"
+#define STANZA_NAME_LAST             "last"
 
 // error conditions
 #define STANZA_NAME_BAD_REQUEST             "bad-request"
@@ -220,6 +222,7 @@
 #define STANZA_NS_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0"
 #define STANZA_NS_MAM2                    "urn:xmpp:mam:2"
 #define STANZA_NS_EXT_GAJIM_BOOKMARKS     "xmpp:gajim.org/bookmarks"
+#define STANZA_NS_RSM                     "http://jabber.org/protocol/rsm"
 
 #define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"
 
n259' href='#n259'>259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303