#include <AdcCommand.h>
Classes | |
struct | Type |
Public Types | |
enum | Error { ERROR_GENERIC = 0, ERROR_HUB_GENERIC = 10, ERROR_HUB_FULL = 11, ERROR_HUB_DISABLED = 12, ERROR_LOGIN_GENERIC = 20, ERROR_NICK_INVALID = 21, ERROR_NICK_TAKEN = 22, ERROR_BAD_PASSWORD = 23, ERROR_CID_TAKEN = 24, ERROR_COMMAND_ACCESS = 25, ERROR_REGGED_ONLY = 26, ERROR_INVALID_PID = 27, ERROR_BANNED_GENERIC = 30, ERROR_PERM_BANNED = 31, ERROR_TEMP_BANNED = 32, ERROR_PROTOCOL_GENERIC = 40, ERROR_PROTOCOL_UNSUPPORTED = 41, ERROR_CONNECT_FAILED = 42, ERROR_INF_MISSING = 43, ERROR_BAD_STATE = 44, ERROR_FEATURE_MISSING = 45, ERROR_BAD_IP = 46, ERROR_NO_HUB_HASH = 47, ERROR_TRANSFER_GENERIC = 50, ERROR_FILE_NOT_AVAILABLE = 51, ERROR_FILE_PART_NOT_AVAILABLE = 52, ERROR_SLOTS_FULL = 53, ERROR_NO_CLIENT_HASH = 54 } |
enum | Priority { PRIORITY_NORMAL, PRIORITY_LOW, PRIORITY_IGNORE } |
enum | Severity { SEV_SUCCESS = 0, SEV_RECOVERABLE = 1, SEV_FATAL = 2 } |
Public Member Functions | |
AdcCommand (const BufferPtr &buffer_) throw (ParseException) | |
AdcCommand (const std::string &aLine) throw (ParseException) | |
AdcCommand (uint32_t cmd, char aType=TYPE_INFO, uint32_t aFrom=HUB_SID) | |
ADCHPP_DLL | AdcCommand (Severity sev, Error err, const std::string &desc, char aType=TYPE_INFO) |
ADCHPP_DLL | AdcCommand () |
AdcCommand & | addParam (const std::string &name, const std::string &value) |
AdcCommand & | addParam (const std::string ¶m) |
C (RNT, 'R','N','T') | |
C (NAT, 'N','A','T') | |
C (CMD, 'C','M','D') | |
C (SID, 'S','I','D') | |
C (SND, 'S','N','D') | |
C (GFI, 'G','F','I') | |
C (GET, 'G','E','T') | |
C (QUI, 'Q','U','I') | |
C (PAS, 'P','A','S') | |
C (GPA, 'G','P','A') | |
C (RCM, 'R','C','M') | |
C (CTM, 'C','T','M') | |
C (RES, 'R','E','S') | |
C (SCH, 'S','C','H') | |
C (MSG, 'M','S','G') | |
C (INF, 'I','N','F') | |
C (STA, 'S','T','A') | |
C (SUP, 'S','U','P') | |
ADCHPP_DLL bool | delParam (const char *name, size_t start) |
ADCHPP_DLL const BufferPtr & | getBuffer () const |
uint32_t | getCommand () const |
const std::string & | getFeatures () const |
std::string | getFourCC () const |
uint32_t | getFrom () const |
ADCHPP_DLL bool | getParam (const char *name, size_t start, std::string &ret) const |
Return a named parameter where the name is a two-letter code. | |
const std::string & | getParam (size_t n) const |
const StringList & | getParameters () const |
StringList & | getParameters () |
Priority | getPriority () const |
uint32_t | getTo () const |
char | getType () const |
ADCHPP_DLL bool | hasFlag (const char *name, size_t start) const |
bool | operator== (uint32_t aCmd) const |
ADCHPP_DLL void | parse (const char *buf, size_t len) throw (ParseException) |
void | parse (const std::string &str) throw (ParseException) |
void | resetBuffer () |
void | setFrom (uint32_t aFrom) |
void | setPriority (Priority priority_) |
void | setTo (uint32_t aTo) |
ADCHPP_DLL std::string | toString () const |
Static Public Member Functions | |
static void | appendSID (std::string &str, uint32_t aSID) |
static ADCHPP_DLL void | escape (const std::string &s, std::string &out) |
static std::string | fromField (const uint16_t aField) |
static std::string | fromFourCC (uint32_t x) |
static std::string | fromSID (const uint32_t aSID) |
static uint32_t | toCMD (const char *str) |
static uint32_t | toCMD (uint8_t a, uint8_t b, uint8_t c) |
static uint16_t | toField (const char *x) |
static uint32_t | toFourCC (const char *x) |
static uint32_t | toSID (const std::string &aSID) |
Static Public Attributes | |
static const uint32_t | HUB_SID = static_cast<uint32_t>(-1) |
static const uint32_t | INVALID_SID = static_cast<uint32_t>(-2) |
static const char | TYPE_BROADCAST = 'B' |
static const char | TYPE_CLIENT = 'C' |
static const char | TYPE_DIRECT = 'D' |
static const char | TYPE_ECHO = 'E' |
static const char | TYPE_FEATURE = 'F' |
static const char | TYPE_HUB = 'H' |
static const char | TYPE_INFO = 'I' |
static const char | TYPE_UDP = 'U' |
Private Attributes | |
union { | |
uint8_t cmd [4] | |
char cmdChar [4] | |
uint32_t cmdInt | |
}; | |
BufferPtr | buffer |
std::string | features |
uint32_t | from |
StringList | parameters |
Priority | priority |
uint32_t | to |
char | type |
Definition at line 31 of file AdcCommand.h.
Definition at line 38 of file AdcCommand.h.
Definition at line 75 of file AdcCommand.h.
Definition at line 69 of file AdcCommand.h.
adchpp::AdcCommand::AdcCommand | ( | ) |
Definition at line 39 of file AdcCommand.cpp.
adchpp::AdcCommand::AdcCommand | ( | Severity | sev, | |
Error | err, | |||
const std::string & | desc, | |||
char | aType = TYPE_INFO | |||
) | [explicit] |
Definition at line 41 of file AdcCommand.cpp.
References addParam(), and adchpp::Util::toString().
adchpp::AdcCommand::AdcCommand | ( | uint32_t | cmd, | |
char | aType = TYPE_INFO , |
|||
uint32_t | aFrom = HUB_SID | |||
) | [inline, explicit] |
Definition at line 132 of file AdcCommand.h.
adchpp::AdcCommand::AdcCommand | ( | const std::string & | aLine | ) | throw (ParseException) [inline, explicit] |
Definition at line 133 of file AdcCommand.h.
References parse().
adchpp::AdcCommand::AdcCommand | ( | const BufferPtr & | buffer_ | ) | throw (ParseException) [inline, explicit] |
Definition at line 134 of file AdcCommand.h.
References buffer, and parse().
AdcCommand& adchpp::AdcCommand::addParam | ( | const std::string & | name, | |
const std::string & | value | |||
) | [inline] |
Definition at line 150 of file AdcCommand.h.
References addParam().
AdcCommand& adchpp::AdcCommand::addParam | ( | const std::string & | param | ) | [inline] |
Definition at line 145 of file AdcCommand.h.
References parameters.
Referenced by AdcCommand(), addParam(), and adchpp::Entity::getSUP().
static void adchpp::AdcCommand::appendSID | ( | std::string & | str, | |
uint32_t | aSID | |||
) | [inline, static] |
Definition at line 119 of file AdcCommand.h.
Referenced by toString().
adchpp::AdcCommand::C | ( | RNT | , | |
'R' | , | |||
'N' | , | |||
'T' | ||||
) |
adchpp::AdcCommand::C | ( | NAT | , | |
'N' | , | |||
'A' | , | |||
'T' | ||||
) |
adchpp::AdcCommand::C | ( | CMD | , | |
'C' | , | |||
'M' | , | |||
'D' | ||||
) |
adchpp::AdcCommand::C | ( | SID | , | |
'S' | , | |||
'I' | , | |||
'D' | ||||
) |
adchpp::AdcCommand::C | ( | SND | , | |
'S' | , | |||
'N' | , | |||
'D' | ||||
) |
adchpp::AdcCommand::C | ( | GFI | , | |
'G' | , | |||
'F' | , | |||
'I' | ||||
) |
adchpp::AdcCommand::C | ( | GET | , | |
'G' | , | |||
'E' | , | |||
'T' | ||||
) |
adchpp::AdcCommand::C | ( | QUI | , | |
'Q' | , | |||
'U' | , | |||
'I' | ||||
) |
adchpp::AdcCommand::C | ( | PAS | , | |
'P' | , | |||
'A' | , | |||
'S' | ||||
) |
adchpp::AdcCommand::C | ( | GPA | , | |
'G' | , | |||
'P' | , | |||
'A' | ||||
) |
adchpp::AdcCommand::C | ( | RCM | , | |
'R' | , | |||
'C' | , | |||
'M' | ||||
) |
adchpp::AdcCommand::C | ( | CTM | , | |
'C' | , | |||
'T' | , | |||
'M' | ||||
) |
adchpp::AdcCommand::C | ( | RES | , | |
'R' | , | |||
'E' | , | |||
'S' | ||||
) |
adchpp::AdcCommand::C | ( | SCH | , | |
'S' | , | |||
'C' | , | |||
'H' | ||||
) |
adchpp::AdcCommand::C | ( | MSG | , | |
'M' | , | |||
'S' | , | |||
'G' | ||||
) |
adchpp::AdcCommand::C | ( | INF | , | |
'I' | , | |||
'N' | , | |||
'F' | ||||
) |
adchpp::AdcCommand::C | ( | STA | , | |
'S' | , | |||
'T' | , | |||
'A' | ||||
) |
adchpp::AdcCommand::C | ( | SUP | , | |
'S' | , | |||
'U' | , | |||
'P' | ||||
) |
bool adchpp::AdcCommand::delParam | ( | const char * | name, | |
size_t | start | |||
) |
Definition at line 239 of file AdcCommand.cpp.
References getParameters(), resetBuffer(), and toField().
void adchpp::AdcCommand::escape | ( | const std::string & | s, | |
std::string & | out | |||
) | [static] |
Definition at line 46 of file AdcCommand.cpp.
Referenced by toString().
static std::string adchpp::AdcCommand::fromField | ( | const uint16_t | aField | ) | [inline, static] |
Definition at line 125 of file AdcCommand.h.
Referenced by adchpp::Entity::getAllFields().
static std::string adchpp::AdcCommand::fromFourCC | ( | uint32_t | x | ) | [inline, static] |
Definition at line 128 of file AdcCommand.h.
Referenced by adchpp::Entity::getSUP(), and adchpp::Entity::getSupportList().
static std::string adchpp::AdcCommand::fromSID | ( | const uint32_t | aSID | ) | [inline, static] |
Definition at line 118 of file AdcCommand.h.
Referenced by adchpp::ClientManager::enterIdentify(), adchpp::ClientManager::enterNormal(), adchpp::ClientManager::enterVerify(), adchpp::ClientManager::onConnected(), adchpp::ClientManager::onFailed(), adchpp::ClientManager::removeEntity(), adchpp::ClientManager::verifyCID(), adchpp::ClientManager::verifyIp(), and adchpp::ClientManager::verifyNick().
const BufferPtr & adchpp::AdcCommand::getBuffer | ( | ) | const |
Definition at line 186 of file AdcCommand.cpp.
References buffer, and toString().
Referenced by adchpp::Entity::getINF(), adchpp::Entity::getSUP(), and adchpp::Entity::send().
uint32_t adchpp::AdcCommand::getCommand | ( | ) | const [inline] |
Definition at line 138 of file AdcCommand.h.
References cmdInt.
Referenced by adchpp::CommandHandler< ClientManager >::dispatch(), adchpp::PluginManager::CommandDispatch::operator()(), and adchpp::Entity::updateFields().
const std::string& adchpp::AdcCommand::getFeatures | ( | ) | const [inline] |
Definition at line 160 of file AdcCommand.h.
References features.
std::string adchpp::AdcCommand::getFourCC | ( | ) | const [inline] |
Definition at line 140 of file AdcCommand.h.
uint32_t adchpp::AdcCommand::getFrom | ( | ) | const [inline] |
Definition at line 176 of file AdcCommand.h.
References from.
bool adchpp::AdcCommand::getParam | ( | const char * | name, | |
size_t | start, | |||
std::string & | ret | |||
) | const |
Return a named parameter where the name is a two-letter code.
Definition at line 229 of file AdcCommand.cpp.
References getParameters(), and toField().
const std::string& adchpp::AdcCommand::getParam | ( | size_t | n | ) | const [inline] |
Definition at line 154 of file AdcCommand.h.
References adchpp::Util::emptyString, and getParameters().
const StringList& adchpp::AdcCommand::getParameters | ( | ) | const [inline] |
Definition at line 142 of file AdcCommand.h.
References parameters.
StringList& adchpp::AdcCommand::getParameters | ( | ) | [inline] |
Definition at line 141 of file AdcCommand.h.
References parameters.
Referenced by delParam(), getParam(), hasFlag(), adchpp::PluginManager::CommandDispatch::operator()(), toString(), and adchpp::Entity::updateFields().
Priority adchpp::AdcCommand::getPriority | ( | ) | const [inline] |
Definition at line 179 of file AdcCommand.h.
References priority.
uint32_t adchpp::AdcCommand::getTo | ( | ) | const [inline] |
Definition at line 174 of file AdcCommand.h.
References to.
char adchpp::AdcCommand::getType | ( | ) | const [inline] |
Definition at line 139 of file AdcCommand.h.
References type.
bool adchpp::AdcCommand::hasFlag | ( | const char * | name, | |
size_t | start | |||
) | const |
Definition at line 250 of file AdcCommand.cpp.
References getParameters(), and toField().
bool adchpp::AdcCommand::operator== | ( | uint32_t | aCmd | ) | const [inline] |
Definition at line 168 of file AdcCommand.h.
References cmdInt.
void adchpp::AdcCommand::parse | ( | const char * | buf, | |
size_t | len | |||
) | throw (ParseException) |
Definition at line 59 of file AdcCommand.cpp.
References adchpp::Text::validateUtf8().
void adchpp::AdcCommand::parse | ( | const std::string & | str | ) | throw (ParseException) [inline] |
Definition at line 136 of file AdcCommand.h.
References parse().
Referenced by AdcCommand(), and parse().
void adchpp::AdcCommand::resetBuffer | ( | ) | [inline] |
Definition at line 158 of file AdcCommand.h.
References buffer.
Referenced by delParam().
void adchpp::AdcCommand::setFrom | ( | uint32_t | aFrom | ) | [inline] |
Definition at line 177 of file AdcCommand.h.
References from.
void adchpp::AdcCommand::setPriority | ( | Priority | priority_ | ) | [inline] |
Definition at line 180 of file AdcCommand.h.
References priority.
Referenced by adchpp::PluginManager::CommandDispatch::operator()().
void adchpp::AdcCommand::setTo | ( | uint32_t | aTo | ) | [inline] |
Definition at line 175 of file AdcCommand.h.
References to.
static uint32_t adchpp::AdcCommand::toCMD | ( | const char * | str | ) | [inline, static] |
Definition at line 122 of file AdcCommand.h.
References toCMD().
Referenced by toCMD().
static uint32_t adchpp::AdcCommand::toCMD | ( | uint8_t | a, | |
uint8_t | b, | |||
uint8_t | c | |||
) | [inline, static] |
Definition at line 121 of file AdcCommand.h.
static uint16_t adchpp::AdcCommand::toField | ( | const char * | x | ) | [inline, static] |
Definition at line 124 of file AdcCommand.h.
Referenced by delParam(), adchpp::Entity::getField(), getParam(), adchpp::Entity::hasField(), hasFlag(), and adchpp::Entity::setField().
static uint32_t adchpp::AdcCommand::toFourCC | ( | const char * | x | ) | [inline, static] |
Definition at line 127 of file AdcCommand.h.
Referenced by adchpp::ClientManager::ClientManager(), adchpp::Entity::isFiltered(), adchpp::Entity::setField(), adchpp::Entity::updateSupports(), and adchpp::ClientManager::verifySUP().
static uint32_t adchpp::AdcCommand::toSID | ( | const std::string & | aSID | ) | [inline, static] |
Definition at line 117 of file AdcCommand.h.
string adchpp::AdcCommand::toString | ( | ) | const |
Definition at line 193 of file AdcCommand.cpp.
References appendSID(), buffer, cmdChar, escape(), features, from, getParameters(), to, type, TYPE_BROADCAST, TYPE_DIRECT, TYPE_ECHO, and TYPE_FEATURE.
Referenced by adchpp::CommandHandler< ClientManager >::dispatch(), and getBuffer().
union { ... } [private] |
BufferPtr adchpp::AdcCommand::buffer [mutable, private] |
Definition at line 186 of file AdcCommand.h.
Referenced by AdcCommand(), getBuffer(), resetBuffer(), and toString().
uint8_t adchpp::AdcCommand::cmd[4] |
Definition at line 190 of file AdcCommand.h.
Referenced by getFourCC().
char adchpp::AdcCommand::cmdChar[4] |
Definition at line 189 of file AdcCommand.h.
Referenced by toString().
uint32_t adchpp::AdcCommand::cmdInt |
Definition at line 191 of file AdcCommand.h.
Referenced by getCommand(), and operator==().
std::string adchpp::AdcCommand::features [private] |
Definition at line 184 of file AdcCommand.h.
Referenced by getFeatures(), and toString().
uint32_t adchpp::AdcCommand::from [private] |
Definition at line 195 of file AdcCommand.h.
Referenced by getFrom(), setFrom(), and toString().
const uint32_t adchpp::AdcCommand::HUB_SID = static_cast<uint32_t>(-1) [static] |
Definition at line 114 of file AdcCommand.h.
Referenced by adchpp::ClientManager::getEntity(), adchpp::Entity::getINF(), and adchpp::Entity::getSUP().
const uint32_t adchpp::AdcCommand::INVALID_SID = static_cast<uint32_t>(-2) [static] |
Definition at line 115 of file AdcCommand.h.
Referenced by adchpp::ClientManager::getEntity().
StringList adchpp::AdcCommand::parameters [private] |
Definition at line 183 of file AdcCommand.h.
Referenced by addParam(), and getParameters().
Priority adchpp::AdcCommand::priority [private] |
Definition at line 194 of file AdcCommand.h.
Referenced by getPriority(), and setPriority().
uint32_t adchpp::AdcCommand::to [private] |
Definition at line 196 of file AdcCommand.h.
Referenced by getTo(), setTo(), and toString().
char adchpp::AdcCommand::type [private] |
Definition at line 197 of file AdcCommand.h.
Referenced by getFourCC(), getType(), and toString().
const char adchpp::AdcCommand::TYPE_BROADCAST = 'B' [static] |
Definition at line 81 of file AdcCommand.h.
Referenced by adchpp::Entity::getINF(), adchpp::Entity::getSUP(), adchpp::ClientManager::onReceive(), adchpp::ClientManager::send(), and toString().
const char adchpp::AdcCommand::TYPE_CLIENT = 'C' [static] |
Definition at line 82 of file AdcCommand.h.
const char adchpp::AdcCommand::TYPE_DIRECT = 'D' [static] |
Definition at line 83 of file AdcCommand.h.
Referenced by adchpp::ClientManager::onReceive(), adchpp::ClientManager::send(), and toString().
const char adchpp::AdcCommand::TYPE_ECHO = 'E' [static] |
Definition at line 84 of file AdcCommand.h.
Referenced by adchpp::ClientManager::onReceive(), adchpp::ClientManager::send(), and toString().
const char adchpp::AdcCommand::TYPE_FEATURE = 'F' [static] |
Definition at line 85 of file AdcCommand.h.
Referenced by adchpp::ClientManager::onReceive(), adchpp::ClientManager::send(), and toString().
const char adchpp::AdcCommand::TYPE_HUB = 'H' [static] |
Definition at line 87 of file AdcCommand.h.
Referenced by adchpp::ClientManager::onReceive().
const char adchpp::AdcCommand::TYPE_INFO = 'I' [static] |
Definition at line 86 of file AdcCommand.h.
Referenced by adchpp::Entity::getINF(), and adchpp::Entity::getSUP().
const char adchpp::AdcCommand::TYPE_UDP = 'U' [static] |
Definition at line 88 of file AdcCommand.h.