mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 19:55:10 +00:00
[MOD/WIP] Try doing fallbacks
This commit is contained in:
parent
fe77906cde
commit
cc85859cca
5 changed files with 56 additions and 2 deletions
|
|
@ -19,7 +19,7 @@ static HttpServer *server = NULL;
|
||||||
static pthread_t xmpp_thr;
|
static pthread_t xmpp_thr;
|
||||||
static XMPPComponent *jabber = NULL;
|
static XMPPComponent *jabber = NULL;
|
||||||
|
|
||||||
|
extern int ParseeFindDatastart(char *data);
|
||||||
int
|
int
|
||||||
Main(void)
|
Main(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
#include <Cytoplasm/Log.h>
|
#include <Cytoplasm/Log.h>
|
||||||
#include <Cytoplasm/Str.h>
|
#include <Cytoplasm/Str.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Routes.h>
|
#include <Routes.h>
|
||||||
|
|
||||||
ParseeData *
|
ParseeData *
|
||||||
|
|
@ -99,3 +101,34 @@ ParseeCleanup(void *datp)
|
||||||
DbListFree(chats);
|
DbListFree(chats);
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
int
|
||||||
|
ParseeFindDatastart(char *data)
|
||||||
|
{
|
||||||
|
char *startline;
|
||||||
|
bool found = false;
|
||||||
|
if (!data)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
startline = data;
|
||||||
|
while (startline)
|
||||||
|
{
|
||||||
|
char *endline = strchr(startline, '\n');
|
||||||
|
|
||||||
|
if (*startline != '>')
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
startline = endline ? endline + 1 : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) (startline - data);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <Cytoplasm/Str.h>
|
#include <Cytoplasm/Str.h>
|
||||||
#include <Cytoplasm/Log.h>
|
#include <Cytoplasm/Log.h>
|
||||||
|
|
||||||
|
#include <Parsee.h>
|
||||||
#include <XML.h>
|
#include <XML.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -52,11 +53,27 @@ XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, ch
|
||||||
|
|
||||||
if (rst && rse)
|
if (rst && rse)
|
||||||
{
|
{
|
||||||
|
int off = ParseeFindDatastart(msg);
|
||||||
|
char *ostr = StrInt(off);
|
||||||
XMLElement *reply = XMLCreateTag("reply");
|
XMLElement *reply = XMLCreateTag("reply");
|
||||||
|
XMLElement *fallback = XMLCreateTag("fallback");
|
||||||
|
XMLElement *fall_body = XMLCreateTag("body");
|
||||||
|
|
||||||
XMLAddAttr(reply, "to", rse);
|
XMLAddAttr(reply, "to", rse);
|
||||||
XMLAddAttr(reply, "id", rst);
|
XMLAddAttr(reply, "id", rst);
|
||||||
XMLAddAttr(reply, "xmlns", "urn:xmpp:reply:0");
|
XMLAddAttr(reply, "xmlns", "urn:xmpp:reply:0");
|
||||||
|
|
||||||
|
XMLAddAttr(fallback, "xmlns", "urn:xmpp:feature-fallback:0");
|
||||||
|
XMLAddAttr(fallback, "for", "urn:xmpp:reply:0");
|
||||||
|
|
||||||
|
XMLAddAttr(fall_body, "start", "0");
|
||||||
|
XMLAddAttr(fall_body, "end", ostr);
|
||||||
|
XMLAddChild(fallback, fall_body);
|
||||||
|
|
||||||
XMLAddChild(message, reply);
|
XMLAddChild(message, reply);
|
||||||
|
XMLAddChild(message, fallback);
|
||||||
|
|
||||||
|
Free(ostr);
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLAddChild(message, body);
|
XMLAddChild(message, body);
|
||||||
|
|
|
||||||
|
|
@ -160,4 +160,7 @@ extern bool ParseeInitialiseSignals(HttpServer *, pthread_t, XMPPComponent *);
|
||||||
|
|
||||||
/* Job used to cleanup Parsee data that isn't necessary anymore. */
|
/* Job used to cleanup Parsee data that isn't necessary anymore. */
|
||||||
extern void ParseeCleanup(void *data);
|
extern void ParseeCleanup(void *data);
|
||||||
|
|
||||||
|
/* Finds the offset of the first line without a '>' at its start. */
|
||||||
|
extern int ParseeFindDatastart(char *data);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -60,4 +60,5 @@ extern void XMPPFreeMUCInfo(MUCInfo info);
|
||||||
|
|
||||||
/* Checks if a stanza has an x-parsee element */
|
/* Checks if a stanza has an x-parsee element */
|
||||||
extern bool XMPPIsParseeStanza(XMLElement *);
|
extern bool XMPPIsParseeStanza(XMLElement *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue