/* bot/context.h
 * ---
 * Implement XMPP connection startup, shutdown, context and user data
 * structures.
 * ---
 */

#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <strophe.h>
#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, bool freeSegment);

/* perform xmpp startup, store in bctx if completed successfully */
int bot_xmpp_startup(struct BotUserInfo user, struct BotXmppCtx * const bctx);

/* teardown and free ctx and connection in bctx */
void bot_xmpp_shutdown(struct BotXmppCtx * const bctx);
