/* bot/context.h
* ---
* Implement XMPP connection startup, shutdown, context and user data
* structures.
* ---
*/
#pragma once
#include "handlers.h"
struct BotUserInfo {
GString* jid;
GString* pass;
};
struct BotXmppCtx {
xmpp_log_t* log;
xmpp_ctx_t* ctx;
xmpp_conn_t* conn;
};
void bot_free_user_data(struct BotUserInfo user, GString *filename, bool freeSegment);
/* sets the given avatar file (base64 encoded) */
int bot_xmpp_set_avatar(struct BotXmppCtx * const bctx, const GString *avatarFile);
/* perform xmpp startup, store in bctx if completed successfully */
int bot_xmpp_startup(struct BotUserInfo user, GString *avatarFile);
/* teardown and free ctx and connection in bctx */
void bot_xmpp_shutdown();
/* send a reminder when SIGALARM is triggered */
void bot_reminder_alarm_func(int s);
/* global context for signal handling */
extern struct BotXmppCtx *g_bctx;
struct BotXmppCtx *bot_get_ctx();
void bot_set_ctx(struct BotXmppCtx *bctx);