void ConnectionManager::on(AdcCommand::SUP, UserConnection* aSource, const AdcCommand& cmd) throw() { if(aSource->getState() != UserConnection::STATE_SUPNICK) { // Already got this once, ignore...@todo fix support updates dcdebug("CM::onMyNick %p sent nick twice\n", (void*)aSource); return; } bool baseOk = false; for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) { if(i->compare(0, 2, "AD") == 0) { string feat = i->substr(2); if(feat == UserConnection::FEATURE_ADC_BASE) { baseOk = true; // ADC clients must support all these... aSource->setFlag(UserConnection::FLAG_SUPPORTS_ADCGET); aSource->setFlag(UserConnection::FLAG_SUPPORTS_MINISLOTS); aSource->setFlag(UserConnection::FLAG_SUPPORTS_TTHF); aSource->setFlag(UserConnection::FLAG_SUPPORTS_TTHL); // For compatibility with older clients... aSource->setFlag(UserConnection::FLAG_SUPPORTS_XML_BZLIST); } else if(feat == UserConnection::FEATURE_ZLIB_GET) { aSource->setFlag(UserConnection::FLAG_SUPPORTS_ZLIB_GET); } else if(feat == UserConnection::FEATURE_ADC_BZIP) { aSource->setFlag(UserConnection::FLAG_SUPPORTS_XML_BZLIST); } } } if(!baseOk) { aSource->send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Invalid SUP")); aSource->disconnect(); return; } if(aSource->isSet(UserConnection::FLAG_INCOMING)) { StringList defFeatures = adcFeatures; if(BOOLSETTING(COMPRESS_TRANSFERS)) { defFeatures.push_back("AD" + UserConnection::FEATURE_ZLIB_GET); } aSource->sup(defFeatures); aSource->inf(false); } else { aSource->inf(true); } aSource->setState(UserConnection::STATE_INF); }
void AdcHub::handle(Command::INF, Command& c) throw() { if(c.getFrom().isZero() || c.getParameters().empty()) return; User::Ptr u = ClientManager::getInstance()->getUser(c.getFrom(), this, true); int op = 0; int reg = 0; int norm = 0; string ve; int sl = 0; for(StringIterC i = c.getParameters().begin(); i != c.getParameters().end(); ++i) { if(i->length() < 2) continue; if(i->compare(0, 2, "NI") == 0) { u->setNick(i->substr(2)); } else if(i->compare(0, 2, "HU") == 0) { hub = u; } else if(i->compare(0, 2, "DE") == 0) { u->setDescription(i->substr(2)); } else if(i->compare(0, 2, "I4") == 0) { u->setIp(i->substr(2)); } else if(i->compare(0, 2, "SS") == 0) { u->setBytesShared(i->substr(2)); } else if(i->compare(0, 2, "VE") == 0) { ve = i->substr(2); } else if(i->compare(0, 2, "EM") == 0) { u->setEmail(i->substr(2)); } else if(i->compare(0, 2, "OP") == 0) { if(i->length() == 2) { u->unsetFlag(User::OP); } else { u->setFlag(User::OP); } } else if(i->compare(0, 2, "HO") == 0) { op = Util::toInt(i->substr(2)); } else if(i->compare(0, 2, "HR") == 0) { reg = Util::toInt(i->substr(2)); } else if(i->compare(0, 2, "HN") == 0) { norm = Util::toInt(i->substr(2)); } else if(i->compare(0, 2, "SL") == 0) { sl = Util::toInt(i->substr(2)); } else if(i->compare(0, 2, "BO") == 0) { if(i->length() == 2) { u->unsetFlag(User::BOT); } else { u->setFlag(User::BOT); } } else if(i->compare(0, 2, "HI") == 0) { if(i->length() == 2) { u->unsetFlag(User::HIDDEN); } else { u->setFlag(User::HIDDEN); } } else if(i->compare(0, 2, "HU") == 0) { if(i->length() == 2) { u->unsetFlag(User::HUB); } else { u->setFlag(User::HUB); } } } if(!ve.empty()) { if(ve.find(' ') != string::npos) { ve.insert(ve.find(' ') + 1, "V:"); } u->setTag("<" + ve + ",M:" + string(u->getIp().empty() ? "P" : "A") + ",H:" + Util::toString(norm) + "/" + Util::toString(reg) + "/" + Util::toString(op) + ",S:" + Util::toString(sl) + ">" ); } if(u == getMe()) state = STATE_NORMAL; fire(ClientListener::UserUpdated(), this, u); }