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