/* 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;
} BotXmppCtx;
void bot_free_user_data(const BotUserInfo user, GString *filename, bool freeSegment);
/* sets the given avatar file (base64 encoded) */
int bot_xmpp_set_avatar(BotXmppCtx * const bctx, const GString *avatarFile);
/* perform xmpp startup, store in bctx if completed successfully */
int bot_xmpp_startup(const BotUserInfo user, GString * const avatarFile);
/* 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);