本文整理汇总了C++中UserPtr::isNMDC方法的典型用法代码示例。如果您正苦于以下问题:C++ UserPtr::isNMDC方法的具体用法?C++ UserPtr::isNMDC怎么用?C++ UserPtr::isNMDC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserPtr
的用法示例。
在下文中一共展示了UserPtr::isNMDC方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPath
string LogManager::getPath(const UserPtr& aUser, ParamMap& params, bool addCache /*false*/) {
if (aUser->isNMDC() || !SETTING(PM_LOG_GROUP_CID)) {
return getPath(PM, params);
}
//is it cached?
auto p = pmPaths.find(aUser->getCID());
if (p != pmPaths.end()) {
//can we still use the same dir?
if (Util::getFilePath(getPath(PM, params)) == Util::getFilePath(p->second))
return p->second;
}
//check the directory
string fileName = getSetting(PM, FILE);
ensureParam("%[userCID]", fileName);
string path = SETTING(LOG_DIRECTORY) + Util::formatParams(fileName, params);
auto files = File::findFiles(Util::getFilePath(path), "*" + aUser->getCID().toBase32() + "*", File::TYPE_FILE);
if (!files.empty()) {
path = files.front();
}
if (addCache)
pmPaths.emplace(aUser->getCID(), path);
return path;
}
示例2: log
void LogManager::log(const UserPtr& aUser, ParamMap& params) {
if (aUser->isNMDC() || !SETTING(PM_LOG_GROUP_CID)) {
log(PM, params);
return;
}
auto path = getPath(aUser, params, true);
log(path, Util::formatParams(getSetting(PM, FORMAT), params));
}
示例3: onPSR
void SearchManager::onPSR(const AdcCommand& cmd, UserPtr from, const string& remoteIp) {
uint16_t udpPort = 0;
uint32_t partialCount = 0;
string tth;
string hubIpPort;
string nick;
PartsInfo partialInfo;
for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) {
const string& str = *i;
if(str.compare(0, 2, "U4") == 0) {
udpPort = static_cast<uint16_t>(Util::toInt(str.substr(2)));
} else if(str.compare(0, 2, "NI") == 0) {
nick = str.substr(2);
} else if(str.compare(0, 2, "HI") == 0) {
hubIpPort = str.substr(2);
} else if(str.compare(0, 2, "TR") == 0) {
tth = str.substr(2);
} else if(str.compare(0, 2, "PC") == 0) {
partialCount = Util::toUInt32(str.substr(2))*2;
} else if(str.compare(0, 2, "PI") == 0) {
StringTokenizer<string> tok(str.substr(2), ',');
for(StringIter i = tok.getTokens().begin(); i != tok.getTokens().end(); ++i) {
partialInfo.push_back((uint16_t)Util::toInt(*i));
}
}
}
string url = ClientManager::getInstance()->findHub(hubIpPort);
if(!from || from == ClientManager::getInstance()->getMe()) {
// for NMDC support
if(nick.empty() || hubIpPort.empty()) {
return;
}
from = ClientManager::getInstance()->findUser(nick, url);
if(!from) {
// Could happen if hub has multiple URLs / IPs
from = ClientManager::getInstance()->findLegacyUser(nick);
if(!from) {
dcdebug("Search result from unknown user");
return;
}
}
}
//ClientManager::getInstance()->setIPUser(from, remoteIp, udpPort);
if(partialInfo.size() != partialCount) {
// what to do now ? just ignore partial search result :-/
return;
}
PartsInfo outPartialInfo;
QueueItem::PartialSource ps(from->isNMDC() ? ClientManager::getInstance()->getClient(url)->getMyIdentity().getNick() : Util::emptyString, hubIpPort, remoteIp, udpPort);
ps.setPartialInfo(partialInfo);
QueueManager::getInstance()->handlePartialResult(from, url, TTHValue(tth), ps, outPartialInfo);
if((udpPort > 0) && !outPartialInfo.empty()) {
try {
AdcCommand cmd = SearchManager::getInstance()->toPSR(false, ps.getMyNick(), hubIpPort, tth, outPartialInfo);
ClientManager::getInstance()->send(cmd, from->getCID());
} catch(...) {
dcdebug("Partial search caught error\n");
}
}
}