mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 19:45:11 +00:00
[ADD/WIP] Push all the Janet changes
This is still unstable(and I still need to design/document the exposed API)! Do(n't) go and use it!
This commit is contained in:
parent
960599d983
commit
ca87972b3a
50 changed files with 3550 additions and 92 deletions
81
src/include/Extension.h
Normal file
81
src/include/Extension.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#ifndef PARSEE_EXTENSION_H
|
||||
#define PARSEE_EXTENSION_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <Cytoplasm/Json.h>
|
||||
|
||||
#include <XML.h>
|
||||
|
||||
typedef struct ParseeData ParseeData;
|
||||
|
||||
typedef struct Extensions Extensions;
|
||||
typedef struct Extension Extension;
|
||||
|
||||
typedef enum StanzaType {
|
||||
STANZA_RAW = 0,
|
||||
STANZA_MESSAGE = 1,
|
||||
STANZA_IQ = 2,
|
||||
STANZA_PRESENCE = 3,
|
||||
|
||||
STANZA_TYPE_COUNT
|
||||
} StanzaType;
|
||||
|
||||
/** Verifies if extensions are enabled with the Parsee binary.
|
||||
* Functions here <strong>WILL</strong> fail if this function
|
||||
* returns false!
|
||||
* -------------------
|
||||
* Returns: true IFF extensions are enabled */
|
||||
extern bool ExtensionEnabled(void);
|
||||
|
||||
/* Creates an extension context. */
|
||||
extern Extensions * ExtensionCreateContext(struct ParseeData *data);
|
||||
|
||||
/** Destroys the entire extension context, and all of its extensions.
|
||||
* -------------------------------------
|
||||
* Returns: NOTHING
|
||||
* Thrashes: ctx */
|
||||
extern void ExtensionDestroyContext(Extensions *ctx);
|
||||
|
||||
/** Loads a basic extension from a simple Janet file.
|
||||
* ----------------------------
|
||||
* Returns: An extension handle[ctx] | NULL */
|
||||
extern Extension * ExtensionLoadBasic(Extensions *ctx, char *id, char *file);
|
||||
|
||||
/** Reloads an extension from an ID.
|
||||
* ---------------------------
|
||||
* Returns: NOTHING */
|
||||
extern void ExtensionReload(Extensions *ctx, char *id);
|
||||
|
||||
/** Loads extensions from a directory. The directory's Janet files are loaded
|
||||
* (with the part before the .janet extension denoting the identifier).
|
||||
* -----------------------------------
|
||||
* Returns: NOTHING */
|
||||
extern void ExtensionLoadDir(Extensions *ctx, char *dir);
|
||||
|
||||
/** Broadcasts a stanza received to all extensions(by calling the
|
||||
* on-stanza function).
|
||||
* -----------------------------------------
|
||||
* Returns: NOTHING
|
||||
* Modifies: the extensions */
|
||||
extern bool ExtensionPushStanza(Extensions *ctx, XMLElement *stanza, StanzaType t);
|
||||
|
||||
/** Broadcasts a Matrix event to all extensions, akin to ExtensionPushStanza.
|
||||
* -----------
|
||||
* Returns: NOTHING
|
||||
* Modifies: the extensions */
|
||||
extern bool ExtensionPushEvent(Extensions *ctx, HashMap *obj);
|
||||
|
||||
/** Calls "on-xmpp-cmd" on extensions' Janet side, with no arguments.
|
||||
* ----------
|
||||
* Returns: NOTHING
|
||||
* Modifies: the extensions */
|
||||
extern void ExtensionRequestCommands(Extensions *ctx);
|
||||
|
||||
extern void
|
||||
ExtensionShoveCommands(Extensions *ctx, char *jid, XMLElement *query, XMLElement *stanza);
|
||||
|
||||
extern void
|
||||
ExtensionManageCommands(Extensions *ctx, XMLElement *stanza);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue