mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 18:25:10 +00:00
[MOD] Add width/height information when possible
This commit is contained in:
parent
09d38993bb
commit
d989331716
5 changed files with 103 additions and 3 deletions
66
src/FileInfo.c
Normal file
66
src/FileInfo.c
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#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"
|
||||
);
|
||||
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue