diff options
author | Michael Vetter <jubalh@iodoru.org> | 2021-01-28 14:41:19 +0100 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2021-01-28 14:44:53 +0100 |
commit | d3303517f7bf3cea504f360518db6ea223036fac (patch) | |
tree | 24a804b6fb0a95d0af533aadfb4ce75fc0139ec7 | |
parent | 6e1e01dbb8476899efdd3d4a169f821c8e388ad5 (diff) | |
download | profani-tty-d3303517f7bf3cea504f360518db6ea223036fac.tar.gz |
MAM: Request more pages via RSM
Send another request with same jid and last id we got.
-rw-r--r-- | src/xmpp/iq.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index e7648251..cc58db58 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -108,6 +108,12 @@ typedef struct command_config_data_t char* command; } CommandConfigData; +typedef struct mam_rsm_userdata +{ + char* barejid; + char* datestr; +} MamRsmUserdata; + static int _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const userdata); static void _error_handler(xmpp_stanza_t* const stanza); @@ -2557,7 +2563,11 @@ iq_mam_request(ProfChatWin* win) gchar* datestr = g_date_time_format(timestamp, "%FT%TZ"); xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, win->barejid, datestr, NULL); - iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, NULL, g_strdup(datestr)); + MamRsmUserdata* data = malloc(sizeof(MamRsmUserdata)); + data->datestr = strdup(datestr); + data->barejid = strdup(win->barejid); + + iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, NULL, data); g_free(datestr); g_date_time_unref(timestamp); @@ -2585,15 +2595,21 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata) if (fin) { xmpp_stanza_t* set = xmpp_stanza_get_child_by_name_and_ns(fin, STANZA_TYPE_SET, STANZA_NS_RSM); if (set) { + char *lastid = NULL; xmpp_stanza_t* last = xmpp_stanza_get_child_by_name(set, STANZA_NAME_LAST); - char* lastid = xmpp_stanza_get_text(last); - lastid = lastid; + if (last) { + lastid = xmpp_stanza_get_text(last); + } // 4.3.2. send same stanza with set,max stanza xmpp_ctx_t* const ctx = connection_get_ctx(); - gchar *datestr = (gchar*)userdata; - //TODO give barejid or get from stanza - xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, NULL, datestr, lastid); + + MamRsmUserdata* data = (MamRsmUserdata*)userdata; + xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, data->barejid, data->datestr, lastid); + free(data->barejid); + free(data->datestr); + free(data); + free(lastid); iq_send_stanza(iq); xmpp_stanza_release(iq); |