#ifndef IRC_USER_H
#define IRC_USER_H
/**
* @file
*
* Minimal state for tracking per-user state for an irc_net. Mainly, the purpose of this module is to support the
* irc_chan::users implementation, such that when a user's nickname is changed, one does not need to modify all
* irc_chan lists, but rather, just replace the nickname field here.
*
* XXX: should this tie in to irc_net to register its own NICK/QUIT handlers?
*/
#include "irc_net.h"
#include "error.h"
/**
* Basic per-network user info. The lifetime of an irc_user struct is strictly for the duration between the user
* JOIN'ing onto the first irc_chan we are on (or us JOIN'ing onto it while they are on it), and them PART'ing the
* last channel we see them on, or QUIT'ing.
*/
struct irc_user {
/** The user's nickname */
char *nickname;
/** Refcount for irc_chan.users lists */
size_t refcount;
/** Our entry in the irc_net list */
LIST_ENTRY(irc_user) net_users;
};
/**
* Create a new irc_user with the given nickname. The nickname is copied for storage.
*
* XXX: this is a private function for use by irc_net
*/
err_t irc_user_create (struct irc_user **user_ptr, struct irc_net *net, const char *nickname);
/**
* Rename the irc_user with a new nickname
*/
err_t irc_user_rename (struct irc_user *user, const char *new_nickname);
/**
* Destroy an irc_user, releasing memory
*/
void irc_user_destroy (struct irc_user *user);
#endif