/* bot/context.h
* ---
* Implement XMPP connection startup, shutdown, context and user data
* structures.
* ---
*/
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <glib.h>
#include <strophe.h>
#include <openssl/sha.h> /* For SHA1 */
#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) */
GString *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, struct BotXmppCtx * const bctx);
/* teardown and free ctx and connection in bctx */
void bot_xmpp_shutdown(struct BotXmppCtx * const bctx);