當前位置: 首頁>>代碼示例>>C++>>正文


C++ BOOLSETTING函數代碼示例

本文整理匯總了C++中BOOLSETTING函數的典型用法代碼示例。如果您正苦於以下問題:C++ BOOLSETTING函數的具體用法?C++ BOOLSETTING怎麽用?C++ BOOLSETTING使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BOOLSETTING函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: l

bool IpGuard::check(const string& aIP, string& reason)
{
	Lock l(cs);
	
	if (aIP.empty() || ranges.size() == 0)
		return false;
		
	unsigned int a, b, c, d;
	if (sscanf(aIP.c_str(), "%u.%u.%u.%u", &a, &b, &c, &d) != 4 || a > 255 || b > 255 || c > 255 || d > 255)
		return false;
		
	uint32_t iIP = make_ip(a, b, c, d);
	
	if (iIP == 0)
		return false;
		
	RangeIter find;
	if ((find = range_search(ranges.begin(), ranges.end(), ip(iIP))) != ranges.end())
	{
		reason = find->name;
		return BOOLSETTING(DEFAULT_POLICY);
	}
	
	reason = STRING(IPGUARD_DEFAULT_POLICY);
	return !BOOLSETTING(DEFAULT_POLICY);
}
開發者ID:3F,項目名稱:FlightSDCpp,代碼行數:26,代碼來源:IpGuard.cpp

示例2: checkUser

void UserManager::checkUser(const OnlineUserPtr& user)
{
	if (BOOLSETTING(CHECK_NEW_USERS))
	{
		if (!ClientManager::getInstance()->isMe(user))
		{
			const Client& client = user->getClient();
			if (!client.getExcludeCheck() && client.isOp() &&
			        (client.isActive() || user->getIdentity().isTcpActive()))
			{
				if (!BOOLSETTING(PROT_FAVS) || !FavoriteManager::getInstance()->isNoFavUserOrUserBanUpload(user->getUser()))   // !SMT!-opt
				{
					if (!isInProtectedUserList(user->getIdentity().getNick()))
					{
						try
						{
							QueueManager::getInstance()->addList(HintedUser(user->getUser(), client.getHubUrl()), QueueItem::FLAG_USER_CHECK);
						}
						catch (const Exception& e)
						{
							LogManager::getInstance()->message(e.getError());
						}
					}
				}
			}
		}
	}
}
開發者ID:snarkus,項目名稱:flylinkdc-r5xx,代碼行數:28,代碼來源:UserManager.cpp

示例3: throw

void FinishedManager::on(QueueManagerListener::Finished, const QueueItem* qi, const string&, const Download* d) throw()
{
	bool isFile = !qi->isSet(QueueItem::FLAG_USER_LIST) && !qi->isSet(QueueItem::FLAG_TESTSUR);

	if(isFile && !SETTING(FINISHFILE).empty() && !BOOLSETTING(SOUNDS_DISABLED)) {
		PlaySound(Text::toT(SETTING(FINISHFILE)).c_str(), NULL, SND_FILENAME | SND_ASYNC);
	}
		
	if(isFile || (qi->isSet(QueueItem::FLAG_USER_LIST) && BOOLSETTING(LOG_FILELIST_TRANSFERS))) {
		
		FinishedItemPtr item = new FinishedItem(qi->getTarget(), d->getHintedUser(), qi->getSize(), static_cast<int64_t>(d->getAverageSpeed()), GET_TIME(), qi->getTTH().toBase32());
		{
			Lock l(cs);
			downloads.push_back(item);
		}
			
		fire(FinishedManagerListener::AddedDl(), item);
		//RSX++
		if(qi->isSet(QueueItem::FLAG_CHECK_FILE_LIST))
			return;
		//END
		size_t BUF_SIZE = STRING(FINISHED_DOWNLOAD).size() + MAX_PATH + 128;
		char* buf = new char[BUF_SIZE];
		snprintf(buf, BUF_SIZE, CSTRING(FINISHED_DOWNLOAD), Util::getFileName(qi->getTarget()).c_str(), 
			Util::toString(ClientManager::getInstance()->getNicks(d->getHintedUser())).c_str());

		LogManager::getInstance()->message(buf);
		delete[] buf;
	}
}
開發者ID:BackupTheBerlios,項目名稱:rsxplusplus-svn,代碼行數:30,代碼來源:FinishedManager.cpp

示例4: throw

void IpGuard::check(uint32_t aIP, Socket* socket /*= NULL*/) throw(SocketException)
{
	Lock l(cs);
	
	if (aIP == 0 || ranges.size() == 0)
		return;
		
	RangeIter find;
	if ((find = range_search(ranges.begin(), ranges.end(), ip(htonl(aIP)))) != ranges.end())
	{
		if (BOOLSETTING(DEFAULT_POLICY))
		{
			if (socket != NULL)
				socket->disconnect();
			throw SocketException(STRING(IPGUARD) + ": " + find->name + " (" + inet_ntoa(*(in_addr*)&aIP) + ")");
		}
		
		return;
	}
	
	if (!BOOLSETTING(DEFAULT_POLICY))
	{
		if (socket != NULL)
			socket->disconnect();
		throw SocketException(STRING(IPGUARD) + ": " + STRING(IPGUARD_DEFAULT_POLICY) + " (" + inet_ntoa(*(in_addr*)&aIP) + ")");
	}
}
開發者ID:3F,項目名稱:FlightSDCpp,代碼行數:27,代碼來源:IpGuard.cpp

示例5: if

bool Client::allowChatMessagefromUser(const ChatMessage& message, const string& p_nick)
{
	if (!message.m_from)
	{
		if (!p_nick.empty() && UserManager::isInIgnoreList(p_nick)) // http://code.google.com/p/flylinkdc/issues/detail?id=1432
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else if (isMe(message.m_from))
	{
		return true;
	}
	else if (message.thirdPerson && BOOLSETTING(NSL_IGNORE_ME))
	{
		return false;
	}
	if (BOOLSETTING(SUPPRESS_MAIN_CHAT) && !isOp())
	{
		return false;
	}
	else if (UserManager::isInIgnoreList(message.m_from->getIdentity().getNick())) // !SMT!-S
	{
		return false;
	}
	else
	{
		return true;
	}
}
開發者ID:snarkus,項目名稱:flylinkdc-r5xx,代碼行數:34,代碼來源:Client.cpp

示例6: dcassert

/** Download finished! */
void DownloadManager::endData(UserConnection* aSource) {
    dcassert(aSource->getState() == UserConnection::STATE_RUNNING);
    Download* d = aSource->getDownload();
    dcassert(d != NULL);

    if(d->getType() == Transfer::TYPE_TREE) {
        d->getFile()->flush();

        int64_t bl = 1024;
        while(bl * (int64_t)d->getTigerTree().getLeaves().size() < d->getTigerTree().getFileSize())
            bl *= 2;
        d->getTigerTree().setBlockSize(bl);
        d->getTigerTree().calcRoot();

        if(!(d->getTTH() == d->getTigerTree().getRoot())) {
            // This tree is for a different file, remove from queue...
            removeDownload(d);
            fire(DownloadManagerListener::Failed(), d, _("Full tree does not match TTH root"));

            QueueManager::getInstance()->removeSource(d->getPath(), aSource->getUser(), QueueItem::Source::FLAG_BAD_TREE, false);

            QueueManager::getInstance()->putDownload(d, false);

            checkDownloads(aSource);
            return;
        }
        d->setTreeValid(true);
    } else {
        // First, finish writing the file (flushing the buffers and closing the file...)
        try {
            d->getFile()->flush();
                } catch(const Exception& e) {
                        d->resetPos();
            failDownload(aSource, e.getError());
            return;
        }

        aSource->setSpeed(d->getAverageSpeed());
        aSource->updateChunkSize(d->getTigerTree().getBlockSize(), d->getSize(), GET_TICK() - d->getStart());

        dcdebug("Download finished: %s, size " I64_FMT ", downloaded " I64_FMT "\n", d->getPath().c_str(),
                static_cast<long long int>(d->getSize()), static_cast<long long int>(d->getPos()));

        if(BOOLSETTING(LOG_DOWNLOADS) && (BOOLSETTING(LOG_FILELIST_TRANSFERS) || d->getType() == Transfer::TYPE_FILE)) {
            logDownload(aSource, d);
        }
    }

    removeDownload(d);
    fire(DownloadManagerListener::Complete(), d);

    QueueManager::getInstance()->putDownload(d, true);
    checkDownloads(aSource);
}
開發者ID:pk2010,項目名稱:eiskaltdcpp,代碼行數:55,代碼來源:DownloadManager.cpp

示例7: CFlyTimerAdapter

SpyFrame::SpyFrame() : CFlyTimerAdapter(m_hWnd), CFlyTaskAdapter(m_hWnd), m_total(0), m_current(0),
	m_ignoreTTH(BOOLSETTING(SPY_FRAME_IGNORE_TTH_SEARCHES)),
	m_showNick(BOOLSETTING(SHOW_SEEKERS_IN_SPY_FRAME)),
	m_LogFile(BOOLSETTING(LOG_SEEKERS_IN_SPY_FRAME)),
	m_ignoreTTHContainer(WC_BUTTON, this, SPYFRAME_IGNORETTH_MESSAGE_MAP),
	m_ShowNickContainer(WC_BUTTON, this, SPYFRAME_SHOW_NICK),
	m_SpyLogFileContainer(WC_BUTTON, this, SPYFRAME_LOG_FILE),
	m_log(nullptr), m_needsUpdateTime(true), m_needsResort(false) //[+]IRainman refactoring SpyFrame
{
	memzero(m_perSecond, sizeof(m_perSecond));
	ClientManager::getInstance()->addListener(this);
	SettingsManager::getInstance()->addListener(this);
}
開發者ID:craxycat,項目名稱:flylinkdc-r5xx,代碼行數:13,代碼來源:SpyFrame.cpp

示例8: l

void DownloadManager::on(TimerManagerListener::Second, uint64_t aTick) noexcept {
    typedef vector<pair<string, UserPtr> > TargetList;
    TargetList dropTargets;

    {
        Lock l(cs);

        DownloadList tickList;
        // Tick each ongoing download
        for(DownloadList::iterator i = downloads.begin(); i != downloads.end(); ++i) {
            if((*i)->getPos() > 0) {
                tickList.push_back(*i);
                (*i)->tick();
            }
        }

        if(tickList.size() > 0)
            fire(DownloadManagerListener::Tick(), tickList);


        // Automatically remove or disconnect slow sources
        if((uint32_t)(aTick / 1000) % SETTING(AUTODROP_INTERVAL) == 0) {
            for(DownloadList::iterator i = downloads.begin(); i != downloads.end(); ++i) {
                Download* d = *i;
                uint64_t timeElapsed = aTick - d->getStart();
                uint64_t timeInactive = aTick - d->getUserConnection().getLastActivity();
                uint64_t bytesDownloaded = d->getPos();
                bool timeElapsedOk = timeElapsed >= (uint32_t)SETTING(AUTODROP_ELAPSED) * 1000;
                bool timeInactiveOk = timeInactive <= (uint32_t)SETTING(AUTODROP_INACTIVITY) * 1000;
                bool speedTooLow = timeElapsedOk && timeInactiveOk && bytesDownloaded > 0 ?
                    bytesDownloaded / timeElapsed * 1000 < (uint32_t)SETTING(AUTODROP_SPEED) : false;
                bool isUserList = d->getType() == Transfer::TYPE_FULL_LIST;
                bool onlineSourcesOk = isUserList ?
                    true : QueueManager::getInstance()->countOnlineSources(d->getPath()) >= SETTING(AUTODROP_MINSOURCES);
                bool filesizeOk = !isUserList && d->getSize() >= ((int64_t)SETTING(AUTODROP_FILESIZE)) * 1024;
                bool dropIt = (isUserList && BOOLSETTING(AUTODROP_FILELISTS)) ||
                    (filesizeOk && BOOLSETTING(AUTODROP_ALL));
                if(speedTooLow && onlineSourcesOk && dropIt) {
                    if(BOOLSETTING(AUTODROP_DISCONNECT) && isUserList) {
                        d->getUserConnection().disconnect();
                    } else {
                        dropTargets.push_back(make_pair(d->getPath(), d->getUser()));
                    }
                }
            }
        }
    }
    for(TargetList::iterator i = dropTargets.begin(); i != dropTargets.end(); ++i) {
        QueueManager::getInstance()->removeSource(i->first, i->second, QueueItem::Source::FLAG_SLOW_SOURCE);
    }
}
開發者ID:pk2010,項目名稱:eiskaltdcpp,代碼行數:51,代碼來源:DownloadManager.cpp

示例9: getMyIdentity

string Client::getLocalIp() const
{
	// [!] IRainman fix:
	// [!] If possible, always return the hub that IP, which he identified with us when you connect.
	// [!] This saves the user from a variety of configuration problems.
	const string& myUserIp = getMyIdentity().getIpAsString(); // [!] opt, and fix done: [4] https://www.box.net/shared/c497f50da28f3dfcc60a
	if (!myUserIp.empty())
	{
		return myUserIp; // [!] Best case - the server detected it.
	}
	// Favorite hub Ip
	if (!getFavIp().empty())
	{
		return Socket::resolve(getFavIp());
	}
	const auto& settingIp = SETTING(EXTERNAL_IP);
	if (!BOOLSETTING(NO_IP_OVERRIDE) && !settingIp.empty() &&
	        SETTING(INCOMING_CONNECTIONS) != SettingsManager::INCOMING_DIRECT)   // !SMT!-F
	{
		return Socket::resolve(settingIp);
	}
	
	{
#ifdef FLYLINKDC_USE_CS_CLIENT_SOCKET
		FastLock lock(csSock); // [+] brain-ripper
#endif
		if (m_client_sock)
		{
			return m_client_sock->getLocalIp();
		}
	}
	return Util::getLocalOrBindIp(false);
	// [~] IRainman fix.
}
開發者ID:snarkus,項目名稱:flylinkdc-r5xx,代碼行數:34,代碼來源:Client.cpp

示例10: write

	/*
	 * Limits a traffic and writes a packet to the network
	 * We must handle this a little bit differently than downloads, because of that stupidity in OpenSSL
	 */		
	int ThrottleManager::write(Socket* sock, void* buffer, size_t& len)
	{
		size_t ups = UploadManager::getInstance()->getUploadCount();
		if(!BOOLSETTING(THROTTLE_ENABLE) || upLimit == 0 || ups == 0)
			return sock->write(buffer, len);
		
		boost::unique_lock<boost::mutex> lock(upMutex);
		
		if(upTokens > 0)
		{
			size_t slice = getUploadLimit() / ups;
			len = min(slice, min(len, upTokens));
			upTokens -= len;

			// next code can't be in critical section, so we must unlock here
			lock.unlock();

			// write to socket			
			int sent = sock->write(buffer, len);

			// give a chance to other transfers to get a token
			boost::thread::yield();
			return sent;
		}
		
		// no tokens, wait for them
		upCond.timed_wait(lock, boost::posix_time::millisec(CONDWAIT_TIMEOUT));
		return 0;	// from BufferedSocket: -1 = failed, 0 = retry
	}
開發者ID:strogo,項目名稱:StrongDC,代碼行數:33,代碼來源:ThrottleManager.cpp

示例11: read

	/*
	 * Limits a traffic and reads a packet from the network
	 */
	int ThrottleManager::read(Socket* sock, void* buffer, size_t len)
	{
		size_t downs = DownloadManager::getInstance()->getDownloadCount();
		if(!BOOLSETTING(THROTTLE_ENABLE) || downLimit == 0 || downs == 0)
			return sock->read(buffer, len);

		boost::unique_lock<boost::mutex> lock(downMutex);


		if(downTokens > 0)
		{
			size_t slice = getDownloadLimit() / downs;
			size_t readSize = min(slice, min(len, downTokens));
				
			// read from socket
			readSize = sock->read(buffer, readSize);
				
			if(readSize > 0)
				downTokens -= readSize;

			// next code can't be in critical section, so we must unlock here
			lock.unlock();

			// give a chance to other transfers to get a token
			boost::thread::yield();
			return readSize;
		}

		// no tokens, wait for them
		downCond.timed_wait(lock, boost::posix_time::millisec(CONDWAIT_TIMEOUT));
		return -1;	// from BufferedSocket: -1 = retry, 0 = connection close
	}
開發者ID:strogo,項目名稱:StrongDC,代碼行數:35,代碼來源:ThrottleManager.cpp

示例12: BOOLSETTING

LRESULT EmoticonsDlg::onEmoticonClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND hWndCtl, BOOL& /*bHandled*/)
{
	WinUtil::GetWindowText(result, hWndCtl);
	// pro ucely testovani emoticon packu...
	if (WinUtil::isShift() && WinUtil::isCtrl())
	{
		const CAGEmotion::Array& Emoticons = CAGEmotionSetup::g_pEmotionsSetup->getEmoticonsArray();
		result.clear();
		string lastEmotionPath, lastAnimEmotionPath;
		int l_count_emotion = 0;
		bool bUseAnimation = BOOLSETTING(SMILE_SELECT_WND_ANIM_SMILES);
		
		for (auto pEmotion = Emoticons.cbegin();
		        pEmotion != Emoticons.cend() && l_count_emotion < CAGEmotionSetup::g_pEmotionsSetup->m_CountSelEmotions;
		        ++pEmotion, ++l_count_emotion)
		{
			if (bUseAnimation)
			{
				if (lastEmotionPath != (*pEmotion)->getEmotionBmpPath() || lastAnimEmotionPath != (*pEmotion)->getEmotionGifPath())
					result += (*pEmotion)->getEmotionText() + _T(' ');
					
				lastEmotionPath = (*pEmotion)->getEmotionBmpPath();
				lastAnimEmotionPath = (*pEmotion)->getEmotionGifPath();
			}
			else
			{
				if (lastEmotionPath != (*pEmotion)->getEmotionBmpPath())
					result += (*pEmotion)->getEmotionText() + _T(' ');
				lastEmotionPath = (*pEmotion)->getEmotionBmpPath();
			}
		}
	}
	PostMessage(WM_CLOSE);
	return 0;
}
開發者ID:craxycat,項目名稱:flylinkdc-r5xx,代碼行數:35,代碼來源:EmoticonsDlg.cpp

示例13: setAutoReconnect

void Client::connect() {
	if(socket)
		BufferedSocket::putSocket(socket);

	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	reloadSettings(true);
	setRegistered(false);
	setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
	setHubIdentity(Identity());

	try {
		socket = BufferedSocket::getSocket(separator);
		socket->addListener(this);
		socket->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
	} catch(const Exception& e) {
		if(socket) {
			BufferedSocket::putSocket(socket);
			socket = 0;
		}
		fire(ClientListener::Failed(), this, e.getError());
	}
	updateActivity();
	state = STATE_CONNECTING;
}
開發者ID:BackupTheBerlios,項目名稱:ldcpp-svn,代碼行數:25,代碼來源:Client.cpp

示例14: rc

LRESULT OMenu::onDrawItem(HWND /*hWnd*/, UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	bHandled = FALSE;
	if (wParam == NULL) {
		DRAWITEMSTRUCT dis = *(DRAWITEMSTRUCT*)lParam;
		if (dis.CtlType == ODT_MENU) {
			OMenuItem* mi = (OMenuItem*)dis.itemData;
			if (mi) {
				bHandled = TRUE;
				CRect rc(dis.rcItem);
				//rc.top += 2;
				rc.bottom -= 2;

				CDC dc;
				dc.Attach(dis.hDC);

				if (BOOLSETTING(MENUBAR_TWO_COLORS))
					OperaColors::FloodFill(dc, rc.left, rc.top, rc.right, rc.bottom, SETTING(MENUBAR_LEFT_COLOR), SETTING(MENUBAR_RIGHT_COLOR), BOOLSETTING(MENUBAR_BUMPED));
				else
					dc.FillSolidRect(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SETTING(MENUBAR_LEFT_COLOR));

				dc.SetBkMode(TRANSPARENT);
				dc.SetTextColor(OperaColors::TextFromBackground(SETTING(MENUBAR_LEFT_COLOR)));
				HFONT oldFont = dc.SelectFont(WinUtil::boldFont);
				tstring buf = mi->text;
				dc.DrawText(buf.c_str(), _tcslen(buf.c_str()), rc, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);
				dc.SelectFont(oldFont);

				dc.Detach();
				return TRUE;
			}
		}
	}
	return S_OK;
}
開發者ID:inetra,項目名稱:peers1,代碼行數:34,代碼來源:OMenu.cpp

示例15: cmd

AdcCommand Download::getCommand(bool zlib) {
    AdcCommand cmd(AdcCommand::CMD_GET);

    cmd.addParam(Transfer::names[getType()]);

    if(getType() == TYPE_PARTIAL_LIST) {
        cmd.addParam(Util::toAdcFile(getPath()));
    } else if(getType() == TYPE_FULL_LIST) {
        if(isSet(Download::FLAG_XML_BZ_LIST)) {
            cmd.addParam(USER_LIST_NAME_BZ);
        } else {
            cmd.addParam(USER_LIST_NAME);
        }
    } else {
        cmd.addParam("TTH/" + getTTH().toBase32());
    }

    cmd.addParam(Util::toString(getStartPos()));
    cmd.addParam(Util::toString(getSize()));

    if(zlib && BOOLSETTING(COMPRESS_TRANSFERS)) {
        cmd.addParam("ZL1");
    }

    return cmd;
}
開發者ID:bhaavanmerchant,項目名稱:eiskaltdcpp,代碼行數:26,代碼來源:Download.cpp


注:本文中的BOOLSETTING函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。