当前位置: 首页>>代码示例>>C++>>正文


C++ UserPtr::isNMDC方法代码示例

本文整理汇总了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;
}
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:28,代码来源:LogManager.cpp

示例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));
}
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:9,代码来源:LogManager.cpp

示例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");
                }
        }

}
开发者ID:Mezomish,项目名称:leechcraft,代码行数:71,代码来源:SearchManager.cpp


注:本文中的UserPtr::isNMDC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。