adchpp::Bot Class Reference

#include <Bot.h>

Inheritance diagram for adchpp::Bot:
Inheritance graph
[legend]
Collaboration diagram for adchpp::Bot:
Collaboration graph
[legend]

List of all members.

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 CIDgetCID () const
ADCHPP_DLL const std::string & getField (const char *name) const
ADCHPP_DLL const BufferPtrgetINF () 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 BufferPtrgetSUP () 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

Detailed Description

Definition at line 30 of file Bot.h.


Member Typedef Documentation

typedef std::map<PluginDataHandle, void*> adchpp::Entity::PluginDataMap [protected, inherited]

Definition at line 141 of file Entity.h.

typedef std::function<void (Bot& bot, const BufferPtr& cmd)> adchpp::Bot::SendHandler

Definition at line 32 of file Bot.h.


Member Enumeration Documentation

enum adchpp::Entity::Flag [inherited]
Enumerator:
FLAG_BOT 
FLAG_REGISTERED 
FLAG_OP 
FLAG_SU 
FLAG_OWNER 
FLAG_HUB 
FLAG_HIDDEN 
MASK_CLIENT_TYPE 
FLAG_PASSWORD 
FLAG_EXT_AWAY 

Extended away, no need to send msg.

FLAG_OK_IP 

Plugins can use these flags to disable various checks.

Bypass ip check

FLAG_GHOST 

This entity is now a ghost being disconnected, totally ignored by ADCH++.

Definition at line 45 of file Entity.h.

enum adchpp::Entity::State [inherited]
Enumerator:
STATE_PROTOCOL 

Initial protocol negotiation (wait for SUP).

STATE_IDENTIFY 

Identify the connecting client (wait for INF).

STATE_VERIFY 

Verify the client (wait for PAS).

STATE_NORMAL 

Normal operation.

STATE_DATA 

Binary data transfer.

Definition at line 32 of file Entity.h.


Constructor & Destructor Documentation

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().

Here is the call graph for this function:


Member Function Documentation

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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]
Parameters:
handle Plugin data handle, as returned by PluginManager::registerPluginData
Returns:
Value stored, NULL if none found

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]
State adchpp::Entity::getState (  )  const [inline, inherited]
const BufferPtr & adchpp::Entity::getSUP (  )  const [inherited]
StringList adchpp::Entity::getSupportList (  )  const [inherited]

Definition at line 105 of file Entity.cpp.

References adchpp::AdcCommand::fromFourCC(), and adchpp::Entity::supports.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

void adchpp::Entity::inject ( AdcCommand cmd  )  [virtual, inherited]

Definition at line 33 of file Entity.cpp.

References adchpp::Singleton< T >::getInstance().

Here is the call graph for this function:

bool adchpp::Entity::isAnySet ( size_t  aFlag  )  const [inline, inherited]

Definition at line 126 of file Entity.h.

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().

Here is the call graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void adchpp::Bot::send ( const BufferPtr cmd  )  [inline, virtual]

Implements adchpp::Entity.

Definition at line 36 of file Bot.h.

void adchpp::Entity::setCID ( const CID cid_  )  [inline, inherited]

Definition at line 120 of file Entity.h.

Referenced by Bot(), and adchpp::ClientManager::verifyCID().

Here is the caller graph for this function:

void adchpp::Entity::setField ( const char *  name,
const std::string &  value 
) [inherited]
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
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().

Here is the caller graph for this function:

void adchpp::Entity::unsetFlag ( size_t  aFlag  )  [inherited]
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend struct BotRemover [friend]

Definition at line 42 of file Bot.h.


Member Data Documentation

CID adchpp::Entity::cid [protected, inherited]

Definition at line 143 of file Entity.h.

Definition at line 45 of file Bot.h.

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().

Definition at line 44 of file Bot.h.

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]

Definition at line 144 of file Entity.h.

State adchpp::Entity::state [protected, inherited]

Definition at line 146 of file Entity.h.

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]
Generated on Sat Nov 27 23:38:29 2010 for adchpp by  doxygen 1.6.3