mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 22:55:11 +00:00
[ADD/WIP] On-the-fly forms
Still WIP-tier, also I need to make a way to index a multi-option list like a regular array with the forms thing, the current one-at-a-time idea is not great...
This commit is contained in:
parent
91d373addb
commit
0cb19a15d8
4 changed files with 146 additions and 6 deletions
|
|
@ -11,6 +11,7 @@ typedef struct XMPPCommandManager XMPPCommandManager;
|
|||
typedef struct XMPPCommand XMPPCommand;
|
||||
typedef struct XMPPOption XMPPOption;
|
||||
typedef void (*XMPPCmdCallback)(XMPPCommandManager *, char *, XMLElement *, XMLElement *);
|
||||
typedef void (*XMPPOptionWriter)(XMPPCommandManager *, XMPPCommand *, char *);
|
||||
|
||||
/** Creates a simple XMPP command manager, which routes commands
|
||||
* with a single-stage form system, with a {cookie}
|
||||
|
|
@ -27,8 +28,9 @@ extern void * XMPPGetManagerCookie(XMPPCommandManager *manager);
|
|||
* Modifies: NOTHING
|
||||
* See-Also: XMPPRegisterCommand */
|
||||
extern XMPPCommand * XMPPBasicCmd(char *node, char *name, XMPPCmdCallback cb);
|
||||
extern void XMPPCmdOptionsCreator(XMPPCommand *cmd, XMPPOptionWriter writer);
|
||||
extern void XMPPAddOption(XMPPCommand *cmd, XMPPOption *opt);
|
||||
extern XMLElement * XMPPFormifyCommand(XMPPCommand *cmd);
|
||||
extern XMLElement * XMPPFormifyCommand(XMPPCommandManager *m, XMPPCommand *cmd, char *from);
|
||||
extern char * XMPPGetCommandNode(XMPPCommand *cmd);
|
||||
extern char * XMPPGetCommandDesc(XMPPCommand *cmd);
|
||||
extern void XMPPSetFormInstruction(XMPPCommand *cmd, char *instruction);
|
||||
|
|
@ -91,6 +93,7 @@ extern bool XMPPManageCommand(XMPPCommandManager *m, XMLElement *stanza, ParseeD
|
|||
|
||||
|
||||
/* --------------------------------- COMMANDS --------------------------------- */
|
||||
/* Please edit stc/XMPPThread.c (you can just force-save) for these to apply! */
|
||||
#define XMPPCOMMANDS \
|
||||
XMPP_COMMAND(StatusCallback, "stats", "Get Parsee statistics", {}) \
|
||||
XMPP_COMMAND(CleanCallback, "clean", "Cleanup temporary Parsee data", {}) \
|
||||
|
|
@ -104,6 +107,11 @@ extern bool XMPPManageCommand(XMPPCommandManager *m, XMLElement *stanza, ParseeD
|
|||
XMPPSetFormTitle(cmd, "Admin addition form"); \
|
||||
XMPPSetFormInstruction(cmd, "Select a glob pattern to add as an admin"); \
|
||||
}) \
|
||||
XMPP_COMMAND(DelAdminCallback, "del-admin", "Removes a glob from admin rights", { \
|
||||
XMPPCmdOptionsCreator(cmd, FormDelAdminCallback); \
|
||||
XMPPSetFormTitle(cmd, "Admin removal form"); \
|
||||
XMPPSetFormInstruction(cmd, "Select a glob pattern to remove as an admin"); \
|
||||
}) \
|
||||
XMPP_COMMAND(AddNoflyCallback, "add-nofly", "Adds user to nofly", { \
|
||||
XMPPOption *entity = XMPPCreateText(true, "entity", ""); \
|
||||
XMPPOption *reason = XMPPCreateText(false, "reason", "Not behaving"); \
|
||||
|
|
@ -118,7 +126,11 @@ extern bool XMPPManageCommand(XMPPCommandManager *m, XMLElement *stanza, ParseeD
|
|||
|
||||
#define XMPP_COMMAND(f,n,t,s) \
|
||||
extern void \
|
||||
f(XMPPCommandManager *, char *, XMLElement *, XMLElement *);
|
||||
f(XMPPCommandManager *, char *, XMLElement *, XMLElement *); \
|
||||
/* This symbol might not exist. We do, however, not care, as
|
||||
* it is not always done. */ \
|
||||
extern void \
|
||||
Form##f(XMPPCommandManager *, XMPPCommand *, char *); \
|
||||
|
||||
XMPPCOMMANDS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue