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


C++ KviCString::hasData方法代码示例

本文整理汇总了C++中KviCString::hasData方法的典型用法代码示例。如果您正苦于以下问题:C++ KviCString::hasData方法的具体用法?C++ KviCString::hasData怎么用?C++ KviCString::hasData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KviCString的用法示例。


在下文中一共展示了KviCString::hasData方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleIsOn

bool KviStupidNotifyListManager::handleIsOn(KviIrcMessage * msg)
{
	if(m_pConnection->lagMeter())
		m_pConnection->lagMeter()->lagCheckComplete("@notify_naive");

	KviCString nk;
	const char * aux = msg->trailing();
	while(*aux)
	{
		nk = "";
		aux = kvi_extractToken(nk, aux, ' ');
		if(nk.hasData())
		{
			QString nkd = m_pConnection->decodeText(nk.ptr());
			QString nksp = " " + nkd;
			m_szLastIsOnMsg.replace(nksp, "", Qt::CaseInsensitive);
			if(!(m_pConsole->notifyListView()->findEntry(nkd)))
			{
				// not yet notified
				notifyOnLine(nkd);
			}
		}
	}
	// ok...check the users that have left irc now...
	QStringList sl = m_szLastIsOnMsg.isEmpty() ? QStringList() : m_szLastIsOnMsg.split(' ', QString::SkipEmptyParts);

	for(auto & it : sl)
	{
		if(m_pConsole->notifyListView()->findEntry(it))
		{
			// has just left irc
			notifyOffLine(it);
		} // else has never been here...
	}

	if(((unsigned int)m_iNextNickToCheck) >= m_pNickList->count())
	{
		// have to restart
		unsigned int iTimeout = KVI_OPTION_UINT(KviOption_uintNotifyListCheckTimeInSecs);
		if(iTimeout < 5)
		{
			// life first of all.
			// don't allow the user to suicide
			if(_OUTPUT_VERBOSE)
				m_pConsole->output(KVI_OUT_SYSTEMWARNING,
				    __tr2qs("Notify list: Timeout (%d sec) is too short, resetting to something more reasonable (5 sec)"),
				    iTimeout);
			iTimeout = 5;
			KVI_OPTION_UINT(KviOption_uintNotifyListCheckTimeInSecs) = 5;
		}
		m_iRestartTimer = startTimer(iTimeout * 1000);
	}
	else
		sendIsOn();
	return true;
}
开发者ID:un1versal,项目名称:KVIrc,代码行数:56,代码来源:KviNotifyList.cpp

示例2: notifyNickChanged

void RegistrationWizard::notifyNickChanged(const QString &)
{
	bool bYes = !m_pNotifyCheck->isChecked();

	if(!bYes)
	{
		// we need at least one nickname then :)
		KviCString tmp = m_pNotifyNickEdit1->text();
		if(tmp.hasData())
		{
			bYes = true;
		} else {
			tmp = m_pNotifyNickEdit2->text();
			if(tmp.hasData())bYes = true;
		}
	}

	setNextEnabled(m_pPage4,bYes);
}
开发者ID:DINKIN,项目名称:KVIrc,代码行数:19,代码来源:RegistrationWizard.cpp

示例3: writeEntry

void KviConfigurationFile::writeEntry(const QString & szKey,const QList<int> &list)
{
	m_bDirty = true;
	KviConfigurationFileGroup * p_group = getCurrentGroup();
	KviCString szData;
	for(QList<int>::ConstIterator it = list.begin();it != list.end();++it)
	{
		if(szData.hasData())szData.append(',');
		szData.append(KviCString::Format,"%d",*it);
	}
	//qDebug("Writing option list for group %s and key %s: %s",m_szGroup.latin1(),szKey.latin1(),szData.ptr());

	p_group->replace(szKey,new QString(szData.ptr()));
}
开发者ID:tronsha,项目名称:KVIrc,代码行数:14,代码来源:KviConfigurationFile.cpp

示例4: setContentFromEditor

	void KviVariantTableItem::setContentFromEditor(QWidget * w)
	{
		switch(m_property.type())
		{
			case QVariant::String:
				m_property = QVariant(((QLineEdit *)w)->text());
			break;
			case QVariant::Int:
				m_property = QVariant(((QLineEdit *)w)->text().toInt());
			break;
			case QVariant::UInt:
				m_property = QVariant(((QLineEdit *)w)->text().toUInt());
			break;
			case QVariant::Bool:
				m_property = QVariant(((QComboBox *)w)->currentItem(),1);
			break;
			case QVariant::Color:
				m_property.asColor().setNamedColor(((QLineEdit *)w)->text());
			break;
			case QVariant::Font:
			{
				KviCString txt = ((QComboBox *)w)->currentText();
				if(txt.hasData())
				{
					KviCString fam = txt;
					fam.cutFromFirst(',',true);
					fam.trimmed();
					KviCString psz = txt;
					psz.cutToFirst(',',true);
					psz.trimmed();
					bool bOk;
					unsigned int uSize = psz.toUInt(&bOk);
					if(!bOk)uSize = 12;
					m_property = QVariant(QFont(fam.ptr(),uSize));
				}
			}
			break;
			default:
			break;
		}
	}
开发者ID:netrunner-debian-kde-extras,项目名称:kvirc,代码行数:41,代码来源:canvaswidget.cpp

示例5: hasLeadingChars

	bool hasLeadingChars(KviCString ** pszArray, char c)
	{
		if(!(*pszArray))
			return false; // can't have more leading chars

		bool bGotIt = false;
		while(*pszArray)
		{
			if(*((*pszArray)->ptr()) == c)
			{
				// found at least one such leading char
				bGotIt = true;
			} else {
				// we pretend this line to be empty
				KviCString szTmp = *(*pszArray);
				szTmp.trim();
				if(szTmp.hasData())
					return false;
				*(*pszArray) = ""; // set it to empty also in the main buffer
			}
			pszArray++;
		}
		return bGotIt;
	}
开发者ID:namikaze90,项目名称:KVIrc-old,代码行数:24,代码来源:KviCommandFormatter.cpp

示例6: handleUserhost

bool KviIsOnNotifyListManager::handleUserhost(KviIrcMessage * msg)
{
	if(!m_bExpectingUserhost)
		return false;
	// first check for consistency: all the replies must be on the USERHOST list
	KviPointerList<KviIrcMask> tmplist;
	tmplist.setAutoDelete(true);

	KviCString nk;
	const char * aux = msg->trailing();

	while(*aux)
	{
		nk = "";
		aux = kvi_extractToken(nk, aux, ' ');
		if(nk.hasData())
		{
			// split it in a mask
			KviCString nick;
			KviCString user;
			KviCString host;

			int idx = nk.findFirstIdx('=');
			if(idx != -1)
			{
				nick = nk.left(idx);
				if(nick.lastCharIs('*'))
					nick.cutRight(1);
				nk.cutLeft(idx + 1);
				if(nk.firstCharIs('+') || nk.firstCharIs('-'))
					nk.cutLeft(1);

				idx = nk.findFirstIdx('@');
				if(idx != -1)
				{
					user = nk.left(idx);
					nk.cutLeft(idx + 1);
					host = nk;
				}
				else
				{
					user = "*";
					host = nk;
				}

				bool bGotIt = false;
				QString szNick = m_pConnection->decodeText(nick.ptr());
				QString szUser = m_pConnection->decodeText(user.ptr());
				QString szHost = m_pConnection->decodeText(host.ptr());

				for(QString * s = m_pUserhostList->first(); s && (!bGotIt); s = m_pUserhostList->next())
				{
					if(KviQString::equalCI(*s, szNick))
					{
						KviIrcMask * mk = new KviIrcMask(szNick, szUser, szHost);
						tmplist.append(mk);
						bGotIt = true;
						m_pUserhostList->removeRef(s);
					}
				}

				if(!bGotIt)
				{
					// ops...not my userhost!
					if(_OUTPUT_VERBOSE)
						m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("Notify list: Hey! You've used USERHOST behind my back? (I might be confused now...)"));
					return false;
				}
			}
			else
			{
				if(_OUTPUT_VERBOSE)
					m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("Notify list: Broken USERHOST reply from the server? (%s)"), nk.ptr());
			}
		}
	}

	// Ok...looks to be my usershot (still not sure at 100%, but can't do better)

	if(m_pConnection->lagMeter())
		m_pConnection->lagMeter()->lagCheckComplete("@notify_userhost");

	m_bExpectingUserhost = false;

	for(KviIrcMask * mk = tmplist.first(); mk; mk = tmplist.next())
	{
		if(!doMatchUser(mk->nick(), *mk))
			return true; // have to restart!!!
	}

	if(!(m_pUserhostList->isEmpty()))
	{
		// ops...someone is no longer online ?
		while(QString * s = m_pUserhostList->first())
		{
			if(_OUTPUT_VERBOSE)
				m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Notify list: \r!n\r%Q\r appears to have gone offline before USERHOST reply was received, will recheck in the next loop"), s);
			m_pUserhostList->removeFirst();
		}
	}
//.........这里部分代码省略.........
开发者ID:un1versal,项目名称:KVIrc,代码行数:101,代码来源:KviNotifyList.cpp

示例7: processHeader

bool KviHttpRequest::processHeader(KviCString &szHeader)
{
	int idx = szHeader.findFirstIdx("\r\n");
	KviCString szResponse;
	if(idx != -1)
	{
		szResponse = szHeader.left(idx);
		szHeader.cutLeft(idx + 2);
	} else {
		szResponse = szHeader;
		szHeader = "";
	}

	szResponse.trim();

	bool bValid = false;

	unsigned int uStatus = 0;

	// check the response value
	if(kvi_strEqualCSN(szResponse.ptr(),"HTTP",4))
	{
		KviCString szR = szResponse;
		szR.cutToFirst(' ');
		szR.trim();
		int idx = szR.findFirstIdx(' ');
		KviCString szNumber;
		if(idx != -1)szNumber = szR.left(idx);
		else szNumber = szR;
		bool bOk;
		uStatus = szNumber.toUInt(&bOk);
		if(bOk)bValid = true;
	}

	QString szUniResponse = QString::fromUtf8(szResponse.ptr());

	if(!bValid)
	{
		// the response is invalid ?
		resetInternalStatus();
		m_szLastError = __tr2qs("Invalid HTTP response: %1").arg(szUniResponse);
		emit terminated(false);
		return false;
	}

	emit status(__tr2qs("Received HTTP response: %1").arg(szUniResponse));

	KviPointerList<KviCString> hlist;
	hlist.setAutoDelete(true);

	idx = szHeader.findFirstIdx("\r\n");
	while(idx != -1)
	{
		if(idx > 0)
		{
			hlist.append(new KviCString(szHeader.ptr(),idx));
			szHeader.cutLeft(idx + 2);
		}
		idx = szHeader.findFirstIdx("\r\n");
	}
	if(szHeader.hasData())hlist.append(new KviCString(szHeader));

	KviPointerHashTable<const char *,KviCString> hdr(11,false,true);
	hdr.setAutoDelete(true);

	for(KviCString * s = hlist.first();s;s = hlist.next())
	{
		idx = s->findFirstIdx(":");
		if(idx != -1)
		{
			KviCString szName = s->left(idx);
			s->cutLeft(idx + 1);
			s->trim();
			hdr.replace(szName.ptr(),new KviCString(*s));
			//qDebug("FOUND HEADER (%s)=(%s)",szName.ptr(),s->ptr());
		}
	}

	KviCString * size = hdr.find("Content-length");
	if(size)
	{
		bool bOk;
		m_uTotalSize = size->toUInt(&bOk);
		if(!bOk)m_uTotalSize = 0;
	}

	KviCString * contentEncoding = hdr.find("Content-encoding");
	if(contentEncoding)
	{
		m_bGzip = contentEncoding->equalsCI("gzip");
	}

	KviCString * transferEncoding = hdr.find("Transfer-Encoding");
	if(transferEncoding)
	{
		if(kvi_strEqualCI(transferEncoding->ptr(),"chunked"))
		{
			// be prepared to handle the chunked transfer encoding as required by HTTP/1.1
			m_bChunkedTransferEncoding = true;
			m_uRemainingChunkSize = 0;
//.........这里部分代码省略.........
开发者ID:kartagis,项目名称:KVIrc,代码行数:101,代码来源:KviHttpRequest.cpp

示例8: connectionInProgress

void DccChatWindow::connectionInProgress()
{
	if(m_pDescriptor->bActive)
	{
		output(KVI_OUT_DCCMSG, __tr2qs_ctx("Contacting host %Q on port %Q", "dcc"), &(m_pDescriptor->szIp), &(m_pDescriptor->szPort));
	}
	else
	{
		output(KVI_OUT_DCCMSG, __tr2qs_ctx("Listening on interface %Q port %Q", "dcc"), &(m_pMarshal->localIp()), &(m_pMarshal->localPort()));

		if(m_pDescriptor->bSendRequest)
		{
			KviCString ip;
			if(!m_pDescriptor->szFakeIp.isEmpty())
			{
				ip = m_pDescriptor->szFakeIp;
			}
			else
			{
				ip = m_pDescriptor->szListenIp;

				if(KVI_OPTION_BOOL(KviOption_boolDccGuessIpFromServerWhenLocalIsUnroutable))
				{
					if(!kvi_isRoutableIpString(ip.ptr()))
					{
						// try to get the IP that the IRC server can see
						if(m_pDescriptor->console())
						{
							KviCString tmp = m_pDescriptor->console()->connection() ? m_pDescriptor->console()->connection()->userInfo()->hostIp().toUtf8().data() : "";
							if(tmp.hasData())
							{
								ip = tmp;
								output(KVI_OUT_DCCMSG, __tr2qs_ctx("The local IP address is private, determining from IRC server: %s", "dcc"), ip.ptr());
							}
							else
							{
								output(KVI_OUT_DCCMSG, __tr2qs_ctx("The local IP address is private, but unable to determine it from the IRC server", "dcc"));
							}
						}
						else
						{
							output(KVI_OUT_DCCMSG, __tr2qs_ctx("The local IP address is private, but have no IRC server to determine it from", "dcc"));
						}
					}
				}
			}

			QString port = !m_pDescriptor->szFakePort.isEmpty() ? m_pDescriptor->szFakePort : QString(m_pMarshal->localPort());

			//FIXME: #warning "OPTION FOR SENDING 127.0.0.1 and so on (not an unsigned number)"
			struct in_addr a;
			if(KviNetUtils::stringIpToBinaryIp(ip.ptr(), &a))
				ip.setNum(htonl(a.s_addr));

			QString szReq = QString("PRIVMSG %1 :%2DCC %3 chat %4 %5").arg(m_pDescriptor->szNick, QChar(0x01), m_pDescriptor->szType, ip.ptr(), port);

			if(m_pDescriptor->isZeroPortRequest())
			{
				szReq.append(" ");
				szReq += m_pDescriptor->zeroPortRequestTag();
			}
			szReq.append((char)(0x01));

			m_pDescriptor->console()->connection()->sendData(m_pDescriptor->console()->connection()->encodeText(szReq).data());
			output(KVI_OUT_DCCMSG, __tr2qs_ctx("Sent DCC %Q request to %Q, waiting for the remote client to connect...", "dcc"),
			    &(m_pDescriptor->szType), &(m_pDescriptor->szNick));
			//qDebug(m_pDescriptor->szNick);
		}
		else
			output(KVI_OUT_DCCMSG, __tr2qs_ctx("DCC %Q request not sent, awaiting manual connection", "dcc"), &(m_pDescriptor->szType));
	}
	KVS_TRIGGER_EVENT_1(KviEvent_OnDCCChatConnectionInProgress, this, m_pDescriptor->idString());
}
开发者ID:Cizzle,项目名称:KVIrc,代码行数:73,代码来源:DccChatWindow.cpp

示例9: handleUserhost

bool KviIsOnNotifyListManager::handleUserhost(KviIrcMessage * msg)
{
	if(!m_bExpectingUserhost)
		return false;
	// first check for consistency: all the replies must be on the USERHOST list

	std::map<std::size_t, std::unique_ptr<KviIrcMask>> tmplist;

	KviCString nk;
	const char * aux = msg->trailing();

	while(*aux)
	{
		nk = "";
		aux = kvi_extractToken(nk, aux, ' ');
		if(nk.hasData())
		{
			// split it in a mask
			KviCString nick;
			KviCString user;
			KviCString host;

			int idx = nk.findFirstIdx('=');
			if(idx != -1)
			{
				nick = nk.left(idx);
				if(nick.lastCharIs('*'))
					nick.cutRight(1);
				nk.cutLeft(idx + 1);
				if(nk.firstCharIs('+') || nk.firstCharIs('-'))
					nk.cutLeft(1);

				idx = nk.findFirstIdx('@');
				if(idx != -1)
				{
					user = nk.left(idx);
					nk.cutLeft(idx + 1);
					host = nk;
				}
				else
				{
					user = "*";
					host = nk;
				}

				bool bGotIt = false;
				QString szNick = m_pConnection->decodeText(nick.ptr());
				QString szUser = m_pConnection->decodeText(user.ptr());
				QString szHost = m_pConnection->decodeText(host.ptr());

				std::size_t i = 0;
				for(const auto & s : m_UserhostList)
				{
					if(KviQString::equalCI(s, szNick))
					{
						tmplist.emplace(i, std::make_unique<KviIrcMask>(szNick, szUser, szHost));
						bGotIt = true;
						break;
					}
				}

				if(!bGotIt)
				{
					// oops... not my userhost!
					if(_OUTPUT_VERBOSE)
						m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("Notify list: Hey! You've used USERHOST behind my back? (I might be confused now...)"));
					return false;
				}
			}
			else
			{
				if(_OUTPUT_VERBOSE)
					m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("Notify list: Broken USERHOST reply from the server? (%s)"), nk.ptr());
			}
		}
	}

	// Ok... looks to be my usershot (still not sure at 100%, but can't do better)

	if(m_pConnection->lagMeter())
		m_pConnection->lagMeter()->lagCheckComplete("@notify_userhost");

	m_bExpectingUserhost = false;

	for(auto & pair : tmplist)
	{
		KviIrcMask * mk = pair.second.get();

		if(!doMatchUser(mk->nick(), *mk))
			return true; // have to restart!!!
	}

	for(auto i = tmplist.rbegin(); i != tmplist.rend(); ++i)
		m_UserhostList.erase(m_UserhostList.begin() + i->first);

	for(const auto & s : m_UserhostList)
	{
		// oops... someone is no longer online ?
		if(_OUTPUT_VERBOSE)
			m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Notify list: \r!n\r%Q\r appears to have gone offline before USERHOST reply was received, will recheck in the next loop"), &s);
//.........这里部分代码省略.........
开发者ID:AndrioCelos,项目名称:KVIrc,代码行数:101,代码来源:KviNotifyList.cpp

示例10: load


//.........这里部分代码省略.........
		KviMemory::free(pcBuffer);
		f.close();
		return false;
	}

	// Check for broken *.mo files
	if(uSize < (24 + (sizeof(GnuMoStringDescriptor) * iStringsNum)))
	{
		qDebug("KviLocale: Broken translation file %s (too small for all descriptors)",szCatalogueFile.toUtf8().data());
		KviMemory::free(pcBuffer);
		f.close();
		return false;
	}

	GnuMoStringDescriptor * pOrigDescriptor  = (GnuMoStringDescriptor *)(pcBuffer + KVI_SWAP_IF_NEEDED(bMustSwap,hdr.orig_tab_offset));
	GnuMoStringDescriptor * pTransDescriptor = (GnuMoStringDescriptor *)(pcBuffer + KVI_SWAP_IF_NEEDED(bMustSwap,hdr.trans_tab_offset));

	// Check again for broken *.mo files
	int iExpectedFileSize = KVI_SWAP_IF_NEEDED(bMustSwap,pTransDescriptor[iStringsNum - 1].offset) +
			KVI_SWAP_IF_NEEDED(bMustSwap,pTransDescriptor[iStringsNum - 1].length);

	if(uSize < (unsigned int)iExpectedFileSize)
	{
		qDebug("KviLocale: Broken translation file %s (too small for all the message strings)",szCatalogueFile.toUtf8().data());
		KviMemory::free(pcBuffer);
		f.close();
		return false;
	}

	// Ok...we can run now

	int iDictSize = kvi_getFirstBiggerPrime(iStringsNum);
	if(m_pMessages)
		delete m_pMessages;
	m_pMessages = new KviPointerHashTable<const char *,KviTranslationEntry>(iDictSize,true,false); // dictSize, case sensitive, don't copy keys
	m_pMessages->setAutoDelete(true);

	KviCString szHeader;

	for(int i = 0; i < iStringsNum; i++)
	{
		// FIXME: "Check for NULL inside strings here ?"
		//qDebug("original seems to be at %u and %u byttes long",KVI_SWAP_IF_NEEDED(bMustSwap,pOrigDescriptor[i].offset),
		//	KVI_SWAP_IF_NEEDED(bMustSwap,pOrigDescriptor[i].length));
		//qDebug("translated seems to be at %u and %u byttes long",KVI_SWAP_IF_NEEDED(bMustSwap,pTransDescriptor[i].offset),
		//	KVI_SWAP_IF_NEEDED(bMustSwap,pTransDescriptor[i].length));

		KviTranslationEntry * e = new KviTranslationEntry(
			(char *)(pcBuffer + KVI_SWAP_IF_NEEDED(bMustSwap,pOrigDescriptor[i].offset)),
			KVI_SWAP_IF_NEEDED(bMustSwap,pOrigDescriptor[i].length),
			(char *)(pcBuffer + KVI_SWAP_IF_NEEDED(bMustSwap,pTransDescriptor[i].offset)),
			KVI_SWAP_IF_NEEDED(bMustSwap,pTransDescriptor[i].length));

		// In some (or all?) *.mo files the first string
		// is zero bytes long and the translated one contains
		// information about the translation
		if(e->m_szKey.len() == 0)
		{
			szHeader = e->m_szEncodedTranslation;
			delete e;
			continue;
		}

		m_pMessages->insert(e->m_szKey.ptr(),e);
	}

	KviMemory::free(pcBuffer);
	f.close();

	m_pTextCodec = 0;

	// find out the text encoding, if possible
	if(szHeader.hasData())
	{
		// find "charset=*\n"
		int iIdx = szHeader.findFirstIdx("charset=");
		if(iIdx != -1)
		{
			szHeader.cutLeft(iIdx + 8);
			szHeader.cutFromFirst('\n');
			szHeader.trim();
			m_pTextCodec = KviLocale::instance()->codecForName(szHeader.ptr());
			if(!m_pTextCodec)
			{
				qDebug("Can't find the codec for charset=%s",szHeader.ptr());
				qDebug("Falling back to codecForLocale()");
				m_pTextCodec = QTextCodec::codecForLocale();
			}
		}
	}

	if(!m_pTextCodec)
	{
		qDebug("The message catalogue does not have a \"charset\" header");
		qDebug("Assuming utf8"); // FIXME: or codecForLocale() ?
		m_pTextCodec = QTextCodec::codecForName("UTF-8");
	}

	return true;
}
开发者ID:namikaze90,项目名称:KVIrc-old,代码行数:101,代码来源:KviMessageCatalogue.cpp


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