mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
wip: add rsm after we get the first couple of mam messages
This commit is contained in:
parent
69e35e86b2
commit
db65255a5a
@ -2556,11 +2556,12 @@ iq_mam_request(ProfChatWin* win)
|
|||||||
g_date_time_unref(now);
|
g_date_time_unref(now);
|
||||||
gchar* datestr = g_date_time_format(timestamp, "%FT%TZ");
|
gchar* datestr = g_date_time_format(timestamp, "%FT%TZ");
|
||||||
xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, win->barejid, datestr);
|
xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, win->barejid, datestr);
|
||||||
|
|
||||||
|
iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, NULL, g_strdup(datestr));
|
||||||
|
|
||||||
g_free(datestr);
|
g_free(datestr);
|
||||||
g_date_time_unref(timestamp);
|
g_date_time_unref(timestamp);
|
||||||
|
|
||||||
iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, NULL, NULL);
|
|
||||||
|
|
||||||
iq_send_stanza(iq);
|
iq_send_stanza(iq);
|
||||||
xmpp_stanza_release(iq);
|
xmpp_stanza_release(iq);
|
||||||
|
|
||||||
@ -2573,7 +2574,12 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
|||||||
const char* type = xmpp_stanza_get_type(stanza);
|
const char* type = xmpp_stanza_get_type(stanza);
|
||||||
if (g_strcmp0(type, "error") == 0) {
|
if (g_strcmp0(type, "error") == 0) {
|
||||||
//TODO
|
//TODO
|
||||||
//char* error_message = stanza_get_error_message(stanza);
|
/*
|
||||||
|
char* error_message = stanza_get_error_message(stanza);
|
||||||
|
cons_show_error("Server error: %s", error_message);
|
||||||
|
log_debug("Error: %s", error_message);
|
||||||
|
free(error_message);
|
||||||
|
*/
|
||||||
} else if (g_strcmp0(type, "result") == 0) {
|
} 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);
|
xmpp_stanza_t* fin = stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_FIN, STANZA_NS_MAM2);
|
||||||
if (fin) {
|
if (fin) {
|
||||||
@ -2582,6 +2588,15 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
|||||||
xmpp_stanza_t* last = xmpp_stanza_get_child_by_name(set, STANZA_NAME_LAST);
|
xmpp_stanza_t* last = xmpp_stanza_get_child_by_name(set, STANZA_NAME_LAST);
|
||||||
char* lastid = xmpp_stanza_get_text(last);
|
char* lastid = xmpp_stanza_get_text(last);
|
||||||
lastid = lastid;
|
lastid = lastid;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
iq_send_stanza(iq);
|
||||||
|
xmpp_stanza_release(iq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2615,7 +2615,7 @@ stanza_attach_correction(xmpp_ctx_t* ctx, xmpp_stanza_t* stanza, const char* con
|
|||||||
}
|
}
|
||||||
|
|
||||||
xmpp_stanza_t*
|
xmpp_stanza_t*
|
||||||
stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate)
|
stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate, const char *const lastid)
|
||||||
{
|
{
|
||||||
char* id = connection_create_stanza_id();
|
char* id = connection_create_stanza_id();
|
||||||
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
|
xmpp_stanza_t* iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
|
||||||
@ -2674,6 +2674,23 @@ stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const s
|
|||||||
|
|
||||||
xmpp_stanza_add_child(field_start, value_start);
|
xmpp_stanza_add_child(field_start, value_start);
|
||||||
|
|
||||||
|
// 4.3.2 set/rsm
|
||||||
|
xmpp_stanza_t *after, *after_text, *set;
|
||||||
|
if (lastid) {
|
||||||
|
set = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_name(set, STANZA_TYPE_SET);
|
||||||
|
xmpp_stanza_set_ns(set, STANZA_NS_RSM);
|
||||||
|
|
||||||
|
after = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_name(after, STANZA_NAME_AFTER);
|
||||||
|
|
||||||
|
after_text = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_text(after_text, lastid);
|
||||||
|
|
||||||
|
xmpp_stanza_add_child(after, after_text);
|
||||||
|
xmpp_stanza_add_child(set, after);
|
||||||
|
}
|
||||||
|
|
||||||
// add and release
|
// add and release
|
||||||
xmpp_stanza_add_child(iq, query);
|
xmpp_stanza_add_child(iq, query);
|
||||||
xmpp_stanza_add_child(query, x);
|
xmpp_stanza_add_child(query, x);
|
||||||
@ -2681,6 +2698,14 @@ stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const s
|
|||||||
xmpp_stanza_add_child(x, field_with);
|
xmpp_stanza_add_child(x, field_with);
|
||||||
xmpp_stanza_add_child(x, field_start);
|
xmpp_stanza_add_child(x, field_start);
|
||||||
|
|
||||||
|
if (lastid) {
|
||||||
|
xmpp_stanza_add_child(query, after);
|
||||||
|
|
||||||
|
xmpp_stanza_release(after_text);
|
||||||
|
xmpp_stanza_release(after);
|
||||||
|
xmpp_stanza_release(set);
|
||||||
|
}
|
||||||
|
|
||||||
xmpp_stanza_release(mam_text);
|
xmpp_stanza_release(mam_text);
|
||||||
xmpp_stanza_release(with_text);
|
xmpp_stanza_release(with_text);
|
||||||
xmpp_stanza_release(date_text);
|
xmpp_stanza_release(date_text);
|
||||||
|
@ -115,6 +115,7 @@
|
|||||||
#define STANZA_NAME_MINIMIZE "minimize"
|
#define STANZA_NAME_MINIMIZE "minimize"
|
||||||
#define STANZA_NAME_FIN "fin"
|
#define STANZA_NAME_FIN "fin"
|
||||||
#define STANZA_NAME_LAST "last"
|
#define STANZA_NAME_LAST "last"
|
||||||
|
#define STANZA_NAME_AFTER "after"
|
||||||
|
|
||||||
// error conditions
|
// error conditions
|
||||||
#define STANZA_NAME_BAD_REQUEST "bad-request"
|
#define STANZA_NAME_BAD_REQUEST "bad-request"
|
||||||
@ -380,6 +381,6 @@ void stanza_free_caps(XMPPCaps* caps);
|
|||||||
|
|
||||||
xmpp_stanza_t* stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_id, const char* const item_id, const char* const jid);
|
xmpp_stanza_t* stanza_create_avatar_retrieve_data_request(xmpp_ctx_t* ctx, const char* stanza_id, const char* const item_id, const char* const jid);
|
||||||
|
|
||||||
xmpp_stanza_t* stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate);
|
xmpp_stanza_t* stanza_create_mam_iq(xmpp_ctx_t* ctx, const char* const jid, const char* const startdate, const char *const lastid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user