mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 22:45:12 +00:00
[ADD/WIP] Congestion, basic ad-hoc commands
Woah, took me a while, eh? Next up, getting forms!
This commit is contained in:
parent
4007232716
commit
408888ef67
9 changed files with 911 additions and 14 deletions
|
|
@ -123,6 +123,14 @@ extern void * ParseeXMPPThread(void *data);
|
|||
* Modifies: NONE */
|
||||
extern XMLElement * ParseeAwaitStanza(char *identifier, int64_t ts);
|
||||
|
||||
/** Returns the amount of unprocessed stanzas in the XMPP thread, which
|
||||
* can be used by admins to guess load.
|
||||
* --------
|
||||
* UB-If: called in the XMPP dispatcher thread itself
|
||||
* Returns: amount of stanzas in the FIFO
|
||||
* Modifies: NONE */
|
||||
extern size_t ParseeCongestion(void);
|
||||
|
||||
/* Finds the room a DM is associated to, from a Matrix user and a Jabber
|
||||
* ID. */
|
||||
extern char * ParseeFindDMRoom(ParseeData *data, char *mxid, char *jid);
|
||||
|
|
|
|||
83
src/include/XMPPCommand.h
Normal file
83
src/include/XMPPCommand.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#ifndef PARSEE_XMPPCOMMAND_H
|
||||
#define PARSEE_XMPPCOMMAND_H
|
||||
|
||||
#include <Cytoplasm/HashMap.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <Parsee.h>
|
||||
#include <XML.h>
|
||||
|
||||
typedef struct XMPPCommandManager XMPPCommandManager;
|
||||
typedef struct XMPPCommand XMPPCommand;
|
||||
typedef struct XMPPOption XMPPOption;
|
||||
typedef void (*XMPPCmdCallback)(XMPPCommandManager *, HashMap *, XMLElement *);
|
||||
|
||||
/** Creates a simple XMPP command manager, which routes commands
|
||||
* with a single-stage form system.
|
||||
* -------------------------------------------
|
||||
* Returns: An opaque command manager[LA:HEAP]
|
||||
* Modifies: NOTHING
|
||||
* See-Also: XMPPFreeManager */
|
||||
extern XMPPCommandManager * XMPPCreateManager(void);
|
||||
|
||||
/** Create a basic command with a node and name description
|
||||
* -----------------------------------------------------
|
||||
* Returns: A command to be used with {XMPPRegisterCommand}[LA:HEAP]
|
||||
* Modifies: NOTHING
|
||||
* See-Also: XMPPRegisterCommand */
|
||||
extern XMPPCommand * XMPPBasicCmd(char *node, char *name, XMPPCmdCallback cb);
|
||||
extern void XMPPAddOption(XMPPCommand *cmd, XMPPOption *opt);
|
||||
extern XMLElement * XMPPFormifyCommand(XMPPCommand *cmd);
|
||||
extern char * XMPPGetCommandNode(XMPPCommand *cmd);
|
||||
extern char * XMPPGetCommandDesc(XMPPCommand *cmd);
|
||||
extern bool XMPPCommandRequiresForm(XMPPCommand *cmd);
|
||||
extern void XMPPExecuteCommand(XMPPCommandManager *m, XMPPCommand *cmd, XMLElement *to, HashMap *arg_table);
|
||||
|
||||
/** Create a basic option.
|
||||
* -----------------------------------------------------
|
||||
* Returns: A form option of the right type[LA:HEAP]
|
||||
* Modifies: NOTHING
|
||||
* See-Also: https://xmpp.org/extensions/xep-0004.html */
|
||||
extern XMPPOption * XMPPCreateText(bool req, char *id, char *def);
|
||||
extern XMPPOption * XMPPCreateBool(bool req, char *id, bool def);
|
||||
extern XMPPOption * XMPPCreateList(bool req, bool single, char *id, char *def);
|
||||
extern XMPPOption * XMPPCreateFixed(char *id, char *text);
|
||||
|
||||
extern void XMPPAddListOption(XMPPOption *list, char *option);
|
||||
extern void XMPPSetDescription(XMPPOption *opt, char *descri);
|
||||
|
||||
extern XMLElement * XMPPOptionToXML(XMPPOption *opt);
|
||||
|
||||
extern void XMPPFreeOption(XMPPOption *opt);
|
||||
extern void XMPPFreeCommand(XMPPCommand *cmd);
|
||||
|
||||
/** Registers a {cmd} to the {m}anager, with no extra metadata or callback.
|
||||
* It also makes {cmd} belong to {m}anager, and therefore does not belong to
|
||||
* its creator anymore.
|
||||
* -----------------------------------------------------
|
||||
* Returns: NOTHING
|
||||
* Modifies: {m}anager
|
||||
* See-Also: XMPPCreateManager, XMPPFreeManager */
|
||||
extern void XMPPRegisterCommand(XMPPCommandManager *m, XMPPCommand *cmd);
|
||||
|
||||
/** Shoves all {m} commands into XML as children of {p}, and a {jid}
|
||||
* -----------------------------------------------------
|
||||
* Returns: NOTHING
|
||||
* Modifies: {p}
|
||||
* See-Also: XMPPCreateManager */
|
||||
extern void XMPPShoveCommandList(XMPPCommandManager *m, char *jid, XMLElement *p);
|
||||
|
||||
/** Destroys all memory related to the command {manager}.
|
||||
* -----------------------------------------------------
|
||||
* Returns: NOTHING
|
||||
* Modifies: {manager}
|
||||
* See-Also: XMPPCreateManager */
|
||||
extern void XMPPFreeManager(XMPPCommandManager *manager);
|
||||
|
||||
/** Manages a command given a IQ stanza and a Parsee data field
|
||||
* -----------------------------------------------------
|
||||
* Returns: Whenever the command was managed properly and completed.
|
||||
* Modifies: {manager}
|
||||
* See-Also: XMPPCreateManager */
|
||||
extern bool XMPPManageCommand(XMPPCommandManager *m, XMLElement *stanza, ParseeData *data);
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue