Parsee/src/include/XMPP.h
LDA 8472ada953 [ADD/MOD] Help/stats and two-way modification
More on the Reverse Ideology!
2024-06-29 19:10:28 +02:00

73 lines
2.3 KiB
C

#ifndef PARSEE_XMPP_H
#define PARSEE_XMPP_H
#include <Cytoplasm/Stream.h>
#include <pthread.h>
#include <XML.h>
typedef struct XMPPComponent {
/* A lock for all write operations */
pthread_mutex_t write_lock;
char *host;
Stream *stream;
} XMPPComponent;
/* Initialises a raw component stream to host, with an optional port.
* If said port is 0, then it is set to the default Prosody port */
extern XMPPComponent * XMPPInitialiseCompStream(char *host, int port);
/* Authenticates a component stream with a given shared secret,
* with a stream ID from the server. This should be called right
* after XMPPInitialiseCompStream. */
extern bool XMPPAuthenticateCompStream(XMPPComponent *comp, char *shared);
/* Makes a user join a MUC */
extern void XMPPJoinMUC(XMPPComponent *comp, char *fr, char *muc);
/* TODO: XMPP stuff, I don't fucking know, I'm not a Jabbernerd. */
extern void XMPPSendPlain(XMPPComponent *comp, char *fr, char *to, char *msg, char *type, char *rst, char *rse, char *event_id, char *oob, char *id);
/* Closes a raw component stream. */
extern void XMPPEndCompStream(XMPPComponent *stream);
/* Sends a loopback stanza (a "killstanza"), used to kill an XMPP listener
* thread. */
extern void XMPPKillThread(XMPPComponent *jabber, char *killer);
/* Checks if a stanza is a "killstanza". */
extern bool XMPPIsKiller(XMLElement *);
typedef struct MUCInfo {
bool exists;
XMPPComponent *jabber;
XMLElement *iq_reply;
} MUCInfo;
/* Queries a MUC's existence, and if $[out] is set, stores information
* pertaining the MUC itself from an <iq> query, to be freed by
* XMPPFreeMUCInfo */
extern bool XMPPQueryMUC(XMPPComponent *jabber, char *muc, MUCInfo *out);
/* Retrieves the MUC's name from an IQ reply */
extern char * XMPPGetMUCName(MUCInfo info);
extern void XMPPFreeMUCInfo(MUCInfo info);
/* Checks if a stanza has an x-parsee element */
extern bool XMPPIsParseeStanza(XMLElement *);
/* Returns the stanza ID of a stanza, if existent */
extern char * XMPPGetStanzaID(XMLElement *);
/* Returns the origin ID of a stanza, if existent */
extern char * XMPPGetOriginID(XMLElement *);
/* Returns the origin ID of the replaced stanza, if the current one
* is a replacement notice */
extern char * XMPPGetReplacedID(XMLElement *);
#endif