1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Start working on MAM RSM to get more pages

Regards https://github.com/profanity-im/profanity/issues/660
This commit is contained in:
Michael Vetter 2020-08-10 15:23:30 +02:00
parent 6a17e9d50e
commit 014e03c72e
2 changed files with 27 additions and 1 deletions

View File

@ -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;
}

View File

@ -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"