mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 13:45:10 +00:00
Negociating stanza sizes seems to be real trouble. Also this code is now `-fanalyzer'-safe! Also kills the last GNUMakefile present. It wasn't even used...
68 lines
1.2 KiB
C
68 lines
1.2 KiB
C
#include <FileInfo.h>
|
|
|
|
#include <Cytoplasm/Memory.h>
|
|
#include <Cytoplasm/Str.h>
|
|
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
static int
|
|
GetField(XMLElement *elem)
|
|
{
|
|
XMLElement *child;
|
|
if (!elem || ArraySize(elem->children) != 1)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
child = ArrayGet(elem->children, 0);
|
|
|
|
return strtol(child->data, NULL, 10);
|
|
}
|
|
|
|
FileInfo *
|
|
FileInfoFromXMPP(XMLElement *stanza)
|
|
{
|
|
FileInfo *info;
|
|
XMLElement *reference, *sims, *file;
|
|
|
|
if (!stanza)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
reference = XMLookForTKV(stanza,
|
|
"reference", "xmlns", "urn:xmpp:reference:0"
|
|
);
|
|
sims = XMLookForTKV(reference,
|
|
"media-sharing", "xmlns", "urn:xmpp:sims:1"
|
|
);
|
|
file = XMLookForTKV(sims,
|
|
"file", "xmlns", "urn:xmpp:jingle:apps:file-transfer:5"
|
|
);
|
|
/* TODO: We'll definitely need MIME types to do things like
|
|
* WebXDC */
|
|
if (!file)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
info = Malloc(sizeof(*info));
|
|
|
|
|
|
info->width = GetField(XMLookForUnique(file, "width"));
|
|
info->height = GetField(XMLookForUnique(file, "height"));
|
|
info->size = GetField(XMLookForUnique(file, "size"));
|
|
return info;
|
|
}
|
|
|
|
void
|
|
FileInfoFree(FileInfo *info)
|
|
{
|
|
if (!info)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Free(info);
|
|
}
|