#ifndef IRC_CLIENT_H
#define IRC_CLIENT_H
/**
* @file
*
* Defines the high-level, full-featured IRC 'client' state, which essentially manipulates a set of irc_net's.
*
* XXX: rename to something else
*/
#include "irc_net.h"
#include <sys/queue.h>
/**
* Defaults for irc_client operation, mostly add_net
*/
struct irc_client_defaults {
/** Default nickname/username/etc to use */
struct irc_conn_register_info register_info;
/** Default service (port) to use for non-SSL connections */
const char *service;
/** Default service (port) to use for SSL connections */
const char *service_ssl;
};
/**
* High-level IRC client state, this just means a set of named irc_net's and some common behaviour.
*/
struct irc_client {
/** Default parameters */
struct irc_client_defaults defaults;
/** Our set of configured IRC networks */
TAILQ_HEAD(irc_client_networks, irc_net) networks;
/** Are we in the process of quitting all networks? */
bool quitting;
/** Have we quit all networks? */
bool quit;
};
/**
* Construct a new irc_client
*/
err_t irc_client_create (struct irc_client **client_ptr, error_t *err);
/**
* Destroy the irc_client, also destroying all networks
*/
void irc_client_destroy (struct irc_client *client);
/**
* Set the default parameters to use for e.g. add_net.
*
* The irc_client_defaults struct itself is copied, but not its contents.
*
* @param client the IRC client
* @param defaults the defaults to use, not copied
*/
void irc_client_set_defaults (struct irc_client *client, const struct irc_client_defaults *defaults);
/**
* Add a new IRC network, using any default values set using irc_client_set_defaults() to replace NULL values in the
* given \a net_info.
*
* Use of raw_socket is not supported.
*
* @param client the irc_client state
* @param net_ptr used to return the new irc_net if not NULL
* @param net_info info required to identify and connect to the network
* @param err returned error info
*/
err_t irc_client_add_net (struct irc_client *client, struct irc_net **net_ptr, const struct irc_net_info *net_info, error_t *err);
/**
* Get a pre-existing IRC network by name
*/
struct irc_net* irc_client_get_net (struct irc_client *client, const char *network);
/**
* Get an irc_chan by network/channel name
*/
struct irc_chan* irc_client_get_chan (struct irc_client *client, const char *network, const char *channel);
/**
* Quit cleanly from all our IRC networks.
*
* XXX: currently no way to indicate once we've quit all of them
*/
err_t irc_client_quit (struct irc_client *client, const char *message);
#endif