ircd/client_state.hpp
#ifndef CLIENT_STATE_HPP_
#define CLIENT_STATE_HPP_
#include "client.hpp"
#include "channel.hpp"
#include <string>
#include <map>
#include <set>
class ClientState {
private:
static std::map<std::string, Client*> nicks; ///< all currently active #nick
Client* const client;
public:
ClientState(Client*);
~ClientState();
bool has_pass; ///< server password ok
bool is_oper; ///< oper granted
bool nickserv_reg; ///< nickserv: nick registered
bool nickserv_ident; ///< nickserv: registered nick identified
const char* nick; // these might be NULL
const char* user; // could need '~'-prefixing
const char* real;
const char* away;
std::set<Channel*> channels; ///< list of joined channels
static bool is_nick(const char*); ///< valid nickname?
static Client* nick_find(const char*); ///< check for existing nick
bool nick_set(const char*); ///< sets/replaces #nick, false if already in use or invalid.
bool user_set(const char*, const char*); ///< sets username/realname (once), false if already set or #user invalid (#real unchecked).
bool away_set(const char*); ///< sets #away message (NULL if not away)
const char* prefix_get(bool details, bool reveal, const char* nick=NULL) const; ///< returns irc message prefix nick[!user@host] (from static buffer)
const char* mode_get() const; ///< returns mode char, e.g. 'o' for oper
const char* state_get() const; ///< returns status char, e.g. '@' for oper
};
#endif