#ifndef PARSEE_EXTENSION_H #define PARSEE_EXTENSION_H #include #include #include 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 WILL 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