/* bot/context.h
* ---
* Implement XMPP connection startup, shutdown, context and user data
* structures.
* ---
*/
#pragma once
#include "handlers.h"
typedef struct BotUserInfo {
GString* jid;
GString* pass;
} BotUserInfo;
typedef struct BotXmppCtx {
pthread_mutex_t lock;
xmpp_log_t* log;
xmpp_ctx_t* ctx;
xmpp_conn_t* conn;
GString* avatarBase64;
GString* avatarFile;
} BotXmppCtx;
void bot_free_user_data(const BotUserInfo user, GString *filename, bool freeSegment);
/* sets the given avatar file (base64 encoded). Accepts the avatar SHA1 hash as hexadecimal */
char * bot_xmpp_set_avatar_pubsub(BotXmppCtx * const bctx, bool setData, char * const hexHash);
/* perform xmpp startup, store in bctx if completed successfully */
int bot_xmpp_startup(const BotUserInfo user, GString * const avatarFile, GString * const avatarBase64);
/* teardown and free ctx and connection in bctx */
void bot_xmpp_shutdown();
/* static-lifetime context for signal handling */
BotXmppCtx *bot_get_ctx();
void bot_set_ctx(BotXmppCtx * const bctx);