mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-14 00:25:11 +00:00
59 lines
1.9 KiB
C
59 lines
1.9 KiB
C
#ifndef PARSEE_MATRIX_H
|
|
#define PARSEE_MATRIX_H
|
|
|
|
#include <Cytoplasm/Json.h>
|
|
#include <Cytoplasm/Uri.h>
|
|
|
|
#include "FileInfo.h"
|
|
|
|
/* A simple representation of everything. It is not as complex as
|
|
* Telodendria's CommonID parser, simply because Parsee does not
|
|
* need such complexity. */
|
|
typedef struct UserID {
|
|
/* We're being extra leinent. */
|
|
char localpart[256];
|
|
char server[256];
|
|
} UserID;
|
|
|
|
/** Parses a Matrix user ID, with no attention to detail.
|
|
* -----------
|
|
* Returns: a valid user ID[HEAP] | NULL
|
|
* Thrasher: Free */
|
|
extern UserID * MatrixParseID(char *user);
|
|
|
|
/** Attempts to parse a Matrix ID from a matrix.to URL.
|
|
* -------------------------------------------------
|
|
* Returns: a valid user ID[HEAP] | NULL
|
|
* Thrasher: Free */
|
|
extern UserID * MatrixParseIDFromMTO(Uri *uri);
|
|
|
|
/* Creates an error message JSON, with the specified code and message. */
|
|
extern HashMap * MatrixCreateError(char *err, char *msg);
|
|
|
|
/* Creates the content for a notice message. */
|
|
extern HashMap * MatrixCreateNotice(char *body);
|
|
|
|
/* Creates the content for a normal message. */
|
|
extern HashMap * MatrixCreateMessage(char *body);
|
|
|
|
extern HashMap * MatrixCreateReact(char *event, char *body);
|
|
|
|
/* Creates the content for a replace message. */
|
|
extern HashMap * MatrixCreateReplace(char *event, char *body);
|
|
|
|
/* Creates the content for a media file. */
|
|
extern HashMap * MatrixCreateMedia(char *mxc, char *body, char *mime, FileInfo *info);
|
|
|
|
/* Creates the content for a m.room.name state event */
|
|
extern HashMap * MatrixCreateNameState(char *name);
|
|
|
|
/* Creates a join membership with a specific nickname */
|
|
extern HashMap * MatrixCreateNickChange(char *nick);
|
|
|
|
/* Modifies a hashmap to create a reply event */
|
|
extern void MatrixSetReply(HashMap *e, char *event);
|
|
|
|
/* Get the event ID of the reply if existent */
|
|
extern char * MatrixGetReply(HashMap *event);
|
|
extern char * MatrixGetEdit(HashMap *event);
|
|
#endif
|