#include <Bot.h>
Public Types | |
enum | Flag { FLAG_BOT = 0x01, FLAG_REGISTERED = 0x02, FLAG_OP = 0x04, FLAG_SU = 0x08, FLAG_OWNER = 0x10, FLAG_HUB = 0x20, FLAG_HIDDEN = 0x40, MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_SU | FLAG_OWNER | FLAG_HUB | FLAG_HIDDEN, FLAG_PASSWORD = 0x100, FLAG_EXT_AWAY = 0x200, FLAG_OK_IP = 0x400, FLAG_GHOST = 0x800 } |
typedef std::function< void(Bot &bot, const BufferPtr &cmd)> | SendHandler |
enum | State { STATE_PROTOCOL, STATE_IDENTIFY, STATE_VERIFY, STATE_NORMAL, STATE_DATA } |
Public Member Functions | |
ADCHPP_DLL bool | addSupports (uint32_t feature) |
ADCHPP_DLL | Bot (uint32_t sid, const SendHandler &handler_) |
ADCHPP_DLL void | clearPluginData (const PluginDataHandle &handle) throw () |
Clear any data referenced by the handle, calling the registered delete function. | |
virtual ADCHPP_DLL void | disconnect (Util::Reason reason) throw () |
ADCHPP_DLL bool | getAllFields (AdcCommand &cmd) const throw () |
Add any flags that have been updated to the AdcCommand (type etc is not set). | |
const CID & | getCID () const |
ADCHPP_DLL const std::string & | getField (const char *name) const |
ADCHPP_DLL const BufferPtr & | getINF () const |
virtual ADCHPP_DLL time_t | getOverflow () const |
The time that this entity's write buffer size exceeded the maximum buffer size, 0 if no overflow. | |
ADCHPP_DLL void * | getPluginData (const PluginDataHandle &handle) const throw () |
virtual ADCHPP_DLL size_t | getQueuedBytes () const |
The number of bytes in the write buffer. | |
uint32_t | getSID () const |
State | getState () const |
ADCHPP_DLL const BufferPtr & | getSUP () const |
ADCHPP_DLL StringList | getSupportList () const |
ADCHPP_DLL bool | hasField (const char *name) const |
ADCHPP_DLL bool | hasSupport (uint32_t feature) const |
virtual ADCHPP_DLL void | inject (AdcCommand &cmd) |
bool | isAnySet (size_t aFlag) const |
ADCHPP_DLL bool | isFiltered (const std::string &features) const |
bool | isSet (size_t aFlag) const |
ADCHPP_DLL bool | removeSupports (uint32_t feature) |
void | send (const AdcCommand &cmd) |
virtual void | send (const BufferPtr &cmd) |
void | setCID (const CID &cid_) |
ADCHPP_DLL void | setField (const char *name, const std::string &value) |
ADCHPP_DLL void | setFlag (size_t aFlag) |
ADCHPP_DLL void | setPluginData (const PluginDataHandle &handle, void *data) throw () |
Set PSD (plugin specific data). | |
void | setState (State state_) |
ADCHPP_DLL void | unsetFlag (size_t aFlag) |
ADCHPP_DLL void | updateFields (const AdcCommand &cmd) |
ADCHPP_DLL void | updateSupports (const AdcCommand &cmd) throw () |
Protected Types | |
typedef std::map < PluginDataHandle, void * > | PluginDataMap |
Protected Attributes | |
CID | cid |
FieldMap | fields |
INF fields. | |
std::vector< uint32_t > | filters |
INF SU. | |
Flags | flags |
BufferPtr | INF |
Latest INF cached. | |
PluginDataMap | pluginData |
Plugin data, see PluginManager::registerPluginData. | |
uint32_t | sid |
State | state |
BufferPtr | SUP |
Latest SUP cached. | |
std::vector< uint32_t > | supports |
SUP items. | |
Private Member Functions | |
void | die () |
Private Attributes | |
bool | disconnecting |
SendHandler | handler |
Friends | |
struct | BotRemover |
Definition at line 30 of file Bot.h.
typedef std::map<PluginDataHandle, void*> adchpp::Entity::PluginDataMap [protected, inherited] |
typedef std::function<void (Bot& bot, const BufferPtr& cmd)> adchpp::Bot::SendHandler |
enum adchpp::Entity::Flag [inherited] |
enum adchpp::Entity::State [inherited] |
adchpp::Bot::Bot | ( | uint32_t | sid, | |
const SendHandler & | handler_ | |||
) |
Definition at line 37 of file Bot.cpp.
References adchpp::Entity::FLAG_BOT, adchpp::CID::generate(), adchpp::Entity::setCID(), and adchpp::Entity::setFlag().
bool adchpp::Entity::addSupports | ( | uint32_t | feature | ) | [inherited] |
Definition at line 93 of file Entity.cpp.
References adchpp::Entity::SUP, and adchpp::Entity::supports.
Referenced by adchpp::ClientManager::ClientManager().
void adchpp::Entity::clearPluginData | ( | const PluginDataHandle & | handle | ) | throw () [inherited] |
Clear any data referenced by the handle, calling the registered delete function.
Definition at line 186 of file Entity.cpp.
void adchpp::Bot::die | ( | ) | [private] |
Definition at line 53 of file Bot.cpp.
References adchpp::Singleton< T >::getInstance().
void adchpp::Bot::disconnect | ( | Util::Reason | reason | ) | throw () [virtual] |
Implements adchpp::Entity.
Definition at line 44 of file Bot.cpp.
References adchpp::SocketManager::addJob(), and adchpp::Singleton< SocketManager >::getInstance().
bool adchpp::Entity::getAllFields | ( | AdcCommand & | cmd | ) | const throw () [inherited] |
Add any flags that have been updated to the AdcCommand (type etc is not set).
Definition at line 69 of file Entity.cpp.
References adchpp::AdcCommand::fromField().
Referenced by adchpp::Entity::getINF().
const CID& adchpp::Entity::getCID | ( | ) | const [inline, inherited] |
Definition at line 119 of file Entity.h.
Referenced by adchpp::ClientManager::regBot(), adchpp::ClientManager::removeEntity(), and adchpp::ClientManager::verifyCID().
const std::string & adchpp::Entity::getField | ( | const char * | name | ) | const [inherited] |
Definition at line 37 of file Entity.cpp.
References adchpp::Util::emptyString, adchpp::Entity::fields, and adchpp::AdcCommand::toField().
Referenced by adchpp::ClientManager::regBot(), adchpp::ClientManager::removeEntity(), and adchpp::ClientManager::verifyNick().
const BufferPtr & adchpp::Entity::getINF | ( | ) | const [inherited] |
Definition at line 84 of file Entity.cpp.
References adchpp::Entity::getAllFields(), adchpp::AdcCommand::getBuffer(), adchpp::Entity::getSID(), adchpp::AdcCommand::HUB_SID, adchpp::Entity::INF, adchpp::AdcCommand::TYPE_BROADCAST, and adchpp::AdcCommand::TYPE_INFO.
Referenced by adchpp::ClientManager::enterNormal().
time_t adchpp::Entity::getOverflow | ( | ) | const [virtual, inherited] |
The time that this entity's write buffer size exceeded the maximum buffer size, 0 if no overflow.
Reimplemented in adchpp::Client.
Definition at line 214 of file Entity.cpp.
void * adchpp::Entity::getPluginData | ( | const PluginDataHandle & | handle | ) | const throw () [inherited] |
handle | Plugin data handle, as returned by PluginManager::registerPluginData |
Definition at line 181 of file Entity.cpp.
size_t adchpp::Entity::getQueuedBytes | ( | ) | const [virtual, inherited] |
The number of bytes in the write buffer.
Reimplemented in adchpp::Client.
Definition at line 210 of file Entity.cpp.
uint32_t adchpp::Entity::getSID | ( | ) | const [inline, inherited] |
Definition at line 91 of file Entity.h.
Referenced by adchpp::ClientManager::enterIdentify(), adchpp::ClientManager::enterNormal(), adchpp::ClientManager::enterVerify(), adchpp::Entity::getINF(), adchpp::Entity::getSUP(), adchpp::ClientManager::onConnected(), adchpp::ClientManager::onFailed(), adchpp::ClientManager::removeEntity(), adchpp::ClientManager::verifyCID(), adchpp::ClientManager::verifyIp(), and adchpp::ClientManager::verifyNick().
State adchpp::Entity::getState | ( | ) | const [inline, inherited] |
Definition at line 122 of file Entity.h.
Referenced by adchpp::ClientManager::enterIdentify(), adchpp::ClientManager::enterNormal(), adchpp::ClientManager::enterVerify(), adchpp::ClientManager::handle(), adchpp::ClientManager::handleDefault(), adchpp::ClientManager::onConnected(), adchpp::PluginManager::CommandDispatch::operator()(), adchpp::ClientManager::removeEntity(), adchpp::ClientManager::setState(), adchpp::ClientManager::verifyCID(), and adchpp::ClientManager::verifyIp().
const BufferPtr & adchpp::Entity::getSUP | ( | ) | const [inherited] |
Definition at line 127 of file Entity.cpp.
References adchpp::AdcCommand::addParam(), adchpp::AdcCommand::fromFourCC(), adchpp::AdcCommand::getBuffer(), adchpp::Entity::getSID(), adchpp::AdcCommand::HUB_SID, adchpp::Entity::SUP, adchpp::Entity::supports, adchpp::AdcCommand::TYPE_BROADCAST, and adchpp::AdcCommand::TYPE_INFO.
StringList adchpp::Entity::getSupportList | ( | ) | const [inherited] |
Definition at line 105 of file Entity.cpp.
References adchpp::AdcCommand::fromFourCC(), and adchpp::Entity::supports.
bool adchpp::Entity::hasField | ( | const char * | name | ) | const [inherited] |
Definition at line 42 of file Entity.cpp.
References adchpp::Entity::fields, and adchpp::AdcCommand::toField().
Referenced by adchpp::ClientManager::verifyIp().
bool adchpp::Entity::hasSupport | ( | uint32_t | feature | ) | const [inherited] |
Definition at line 138 of file Entity.cpp.
References adchpp::Entity::supports.
Referenced by adchpp::ClientManager::verifySUP().
void adchpp::Entity::inject | ( | AdcCommand & | cmd | ) | [virtual, inherited] |
Definition at line 33 of file Entity.cpp.
References adchpp::Singleton< T >::getInstance().
bool adchpp::Entity::isAnySet | ( | size_t | aFlag | ) | const [inline, inherited] |
bool adchpp::Entity::isFiltered | ( | const std::string & | features | ) | const [inherited] |
Definition at line 157 of file Entity.cpp.
References adchpp::Entity::filters, and adchpp::AdcCommand::toFourCC().
bool adchpp::Entity::isSet | ( | size_t | aFlag | ) | const [inline, inherited] |
Definition at line 125 of file Entity.h.
Referenced by adchpp::ClientManager::removeEntity(), and adchpp::ClientManager::verifyIp().
bool adchpp::Entity::removeSupports | ( | uint32_t | feature | ) | [inherited] |
Definition at line 114 of file Entity.cpp.
References adchpp::Entity::SUP, and adchpp::Entity::supports.
void adchpp::Entity::send | ( | const AdcCommand & | cmd | ) | [inline, inherited] |
Definition at line 71 of file Entity.h.
References adchpp::AdcCommand::getBuffer(), and adchpp::Entity::send().
Referenced by adchpp::ClientManager::maybeSend(), adchpp::Entity::send(), adchpp::ClientManager::verifyCID(), and adchpp::ClientManager::verifyOverflow().
virtual void adchpp::Bot::send | ( | const BufferPtr & | cmd | ) | [inline, virtual] |
Implements adchpp::Entity.
void adchpp::Entity::setCID | ( | const CID & | cid_ | ) | [inline, inherited] |
Definition at line 120 of file Entity.h.
Referenced by Bot(), and adchpp::ClientManager::verifyCID().
void adchpp::Entity::setField | ( | const char * | name, | |
const std::string & | value | |||
) | [inherited] |
Definition at line 46 of file Entity.cpp.
References adchpp::Entity::fields, adchpp::Entity::filters, adchpp::Entity::INF, adchpp::AdcCommand::toField(), and adchpp::AdcCommand::toFourCC().
Referenced by adchpp::Hub::Hub(), adchpp::Entity::setFlag(), adchpp::Entity::unsetFlag(), adchpp::Entity::updateFields(), and adchpp::ClientManager::verifyIp().
void adchpp::Entity::setFlag | ( | size_t | aFlag | ) | [inherited] |
Definition at line 196 of file Entity.cpp.
References adchpp::Entity::flags, adchpp::Flags::getFlags(), adchpp::Entity::MASK_CLIENT_TYPE, adchpp::Entity::setField(), adchpp::Flags::setFlag(), and adchpp::Util::toString().
Referenced by Bot(), adchpp::Hub::Hub(), and adchpp::ClientManager::verifyCID().
void adchpp::Entity::setPluginData | ( | const PluginDataHandle & | handle, | |
void * | data | |||
) | throw () [inherited] |
Set PSD (plugin specific data).
This allows a plugin to store arbitrary per-client data, and retrieve it later on. The life cycle of the data follows that of the client unless explicitly removed. Any data referenced by the plugin will have its delete function called when the Entity is deleted.
id | Id as retrieved from PluginManager::getPluginId() | |
data | Data to store, this can be pretty much anything |
Definition at line 176 of file Entity.cpp.
void adchpp::Entity::setState | ( | State | state_ | ) | [inline, inherited] |
Definition at line 123 of file Entity.h.
Referenced by adchpp::ClientManager::setState().
void adchpp::Entity::unsetFlag | ( | size_t | aFlag | ) | [inherited] |
Definition at line 203 of file Entity.cpp.
References adchpp::Entity::flags, adchpp::Flags::getFlags(), adchpp::Entity::MASK_CLIENT_TYPE, adchpp::Entity::setField(), adchpp::Flags::setFlag(), and adchpp::Util::toString().
void adchpp::Entity::updateFields | ( | const AdcCommand & | cmd | ) | [inherited] |
Definition at line 75 of file Entity.cpp.
References dcassert, adchpp::AdcCommand::getCommand(), adchpp::AdcCommand::getParameters(), and adchpp::Entity::setField().
Referenced by adchpp::ClientManager::verifyINF().
void adchpp::Entity::updateSupports | ( | const AdcCommand & | cmd | ) | throw () [inherited] |
Definition at line 142 of file Entity.cpp.
References adchpp::AdcCommand::toFourCC().
Referenced by adchpp::ClientManager::verifySUP().
friend struct BotRemover [friend] |
CID adchpp::Entity::cid [protected, inherited] |
bool adchpp::Bot::disconnecting [private] |
FieldMap adchpp::Entity::fields [protected, inherited] |
INF fields.
Definition at line 155 of file Entity.h.
Referenced by adchpp::Entity::getField(), adchpp::Entity::hasField(), and adchpp::Entity::setField().
std::vector<uint32_t> adchpp::Entity::filters [protected, inherited] |
INF SU.
Definition at line 152 of file Entity.h.
Referenced by adchpp::Entity::isFiltered(), and adchpp::Entity::setField().
Flags adchpp::Entity::flags [protected, inherited] |
Definition at line 145 of file Entity.h.
Referenced by adchpp::Entity::setFlag(), and adchpp::Entity::unsetFlag().
SendHandler adchpp::Bot::handler [private] |
BufferPtr adchpp::Entity::INF [mutable, protected, inherited] |
Latest INF cached.
Definition at line 161 of file Entity.h.
Referenced by adchpp::Entity::getINF(), and adchpp::Entity::setField().
PluginDataMap adchpp::Entity::pluginData [protected, inherited] |
Plugin data, see PluginManager::registerPluginData.
Definition at line 158 of file Entity.h.
Referenced by adchpp::Entity::~Entity().
uint32_t adchpp::Entity::sid [protected, inherited] |
State adchpp::Entity::state [protected, inherited] |
BufferPtr adchpp::Entity::SUP [mutable, protected, inherited] |
Latest SUP cached.
Definition at line 164 of file Entity.h.
Referenced by adchpp::Entity::addSupports(), adchpp::Entity::getSUP(), and adchpp::Entity::removeSupports().
std::vector<uint32_t> adchpp::Entity::supports [protected, inherited] |
SUP items.
Definition at line 149 of file Entity.h.
Referenced by adchpp::Entity::addSupports(), adchpp::Entity::getSUP(), adchpp::Entity::getSupportList(), adchpp::Entity::hasSupport(), and adchpp::Entity::removeSupports().