mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 23:05:10 +00:00
[ADD] No-fly, forms
This commit is contained in:
parent
a880769c48
commit
df394172ec
11 changed files with 338 additions and 52 deletions
|
|
@ -108,14 +108,58 @@ XMPPCommandRequiresForm(XMPPCommand *cmd)
|
|||
return cmd ? !!cmd->options : false;
|
||||
}
|
||||
void
|
||||
XMPPExecuteCommand(XMPPCommandManager *m, XMPPCommand *cmd, char *from, XMLElement *to, HashMap *arg_table)
|
||||
XMPPExecuteCommand(XMPPCommandManager *m, XMPPCommand *cmd, char *from, XMLElement *to, XMLElement *form)
|
||||
{
|
||||
if (!m || !cmd || !from || !to)
|
||||
{
|
||||
return;
|
||||
}
|
||||
cmd->callback(m, from, arg_table, to);
|
||||
|
||||
/* TODO Free arg_table's strings */
|
||||
HashMapFree(arg_table);
|
||||
cmd->callback(m, from, form, to);
|
||||
}
|
||||
|
||||
void
|
||||
XMPPShoveOptions(XMPPCommand *cmd, XMLElement *form)
|
||||
{
|
||||
size_t i;
|
||||
if (!cmd || !form)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ArraySize(cmd->options); i++)
|
||||
{
|
||||
XMPPOption *opt = ArrayGet(cmd->options, i);
|
||||
XMLElement *xml = XMPPOptionToXML(opt);
|
||||
|
||||
XMLAddChild(form, xml);
|
||||
}
|
||||
}
|
||||
bool
|
||||
XMPPVerifyForm(XMPPCommand *cmd, XMLElement *form)
|
||||
{
|
||||
size_t i;
|
||||
if (!cmd || !form)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < ArraySize(cmd->options); i++)
|
||||
{
|
||||
XMPPOption *opt = ArrayGet(cmd->options, i);
|
||||
if (XMPPIsOptionRequired(opt))
|
||||
{
|
||||
/* Check in the form for a field with the right var */
|
||||
char *var = XMPPOptionVar(opt);
|
||||
XMLElement *field = XMLookForTKV(form, "field", "var", var);
|
||||
|
||||
if (!field)
|
||||
{
|
||||
/* Required field not found; die. */
|
||||
return false;
|
||||
}
|
||||
/* TODO */
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue