mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-26 00:56:22 +00:00
Support legacy delayed delivery (XEP-0091) as well as XEP-0203
This commit is contained in:
32
src/stanza.c
32
src/stanza.c
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <strophe.h>
|
||||
|
||||
#include "common.h"
|
||||
@@ -193,3 +194,34 @@ stanza_create_ping_iq(xmpp_ctx_t *ctx)
|
||||
|
||||
return iq;
|
||||
}
|
||||
|
||||
gboolean
|
||||
stanza_get_delay(xmpp_stanza_t * const stanza, GTimeVal *tv_stamp)
|
||||
{
|
||||
// first check for XEP-0203 delayed delivery
|
||||
xmpp_stanza_t *delay = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_DELAY);
|
||||
if (delay != NULL) {
|
||||
char *xmlns = xmpp_stanza_get_attribute(delay, STANZA_ATTR_XMLNS);
|
||||
if ((xmlns != NULL) && (strcmp(xmlns, "urn:xmpp:delay") == 0)) {
|
||||
char *stamp = xmpp_stanza_get_attribute(delay, STANZA_ATTR_STAMP);
|
||||
if ((stamp != NULL) && (g_time_val_from_iso8601(stamp, tv_stamp))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise check for XEP-0091 legacy delayed delivery
|
||||
// stanp format : CCYYMMDDThh:mm:ss
|
||||
xmpp_stanza_t *x = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_X);
|
||||
if (x != NULL) {
|
||||
char *xmlns = xmpp_stanza_get_attribute(x, STANZA_ATTR_XMLNS);
|
||||
if ((xmlns != NULL) && (strcmp(xmlns, "jabber:x:delay") == 0)) {
|
||||
char *stamp = xmpp_stanza_get_attribute(x, STANZA_ATTR_STAMP);
|
||||
if ((stamp != NULL) && (g_time_val_from_iso8601(stamp, tv_stamp))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user