本文整理汇总了C++中KviCString::lastCharIs方法的典型用法代码示例。如果您正苦于以下问题:C++ KviCString::lastCharIs方法的具体用法?C++ KviCString::lastCharIs怎么用?C++ KviCString::lastCharIs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KviCString
的用法示例。
在下文中一共展示了KviCString::lastCharIs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bufferFromBlock
void bufferFromBlock(KviCString & szBuffer)
{
szBuffer.trim();
if((*(szBuffer.ptr()) == '{') && szBuffer.lastCharIs('}'))
{
// leading and trailing { must be stripped
szBuffer.cutLeft(1);
szBuffer.cutRight(1);
}
unindent(szBuffer);
szBuffer.trim();
}
示例2: 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();
}
}
//.........这里部分代码省略.........
示例3: event
bool DccChatWindow::event(QEvent * e)
{
if(e->type() == KVI_THREAD_EVENT)
{
switch(((KviThreadEvent *)e)->id())
{
case KVI_DCC_THREAD_EVENT_ERROR:
{
KviError::Code * pError = ((KviThreadDataEvent<KviError::Code> *)e)->getData();
QString szErr = KviError::getDescription(*pError);
if(!KVS_TRIGGER_EVENT_2_HALTED(KviEvent_OnDCCChatError, this, szErr, m_pDescriptor->idString()))
output(KVI_OUT_DCCERROR, __tr2qs_ctx("ERROR: %Q", "dcc"), &szErr);
KVS_TRIGGER_EVENT_1(KviEvent_OnDCCChatDisconnected, this, m_pDescriptor->idString());
delete pError;
return true;
}
break;
case KVI_DCC_THREAD_EVENT_DATA:
{
KviCString * encoded = ((KviThreadDataEvent<KviCString> *)e)->getData();
KviCString d = KviCString(decodeText(encoded->ptr()));
if(d.firstCharIs(0x01))
{
d.cutLeft(1);
if(d.lastCharIs(0x01))
d.cutRight(1);
if(kvi_strEqualCIN("ACTION", d.ptr(), 6))
d.cutLeft(6);
d.stripLeftWhiteSpace();
output(KVI_OUT_ACTION, "%Q %s", &(m_pDescriptor->szNick), d.ptr());
if(!hasAttention(KviWindow::MainWindowIsVisible))
{
if(KVI_OPTION_BOOL(KviOption_boolFlashDccChatWindowOnNewMessages))
{
demandAttention();
}
if(KVI_OPTION_BOOL(KviOption_boolPopupNotifierOnNewDccChatMessages))
{
QString szMsg = "<b>";
szMsg += m_pDescriptor->szNick;
szMsg += "</b> ";
szMsg += KviQString::toHtmlEscaped(QString(d.ptr()));
//qDebug("KviIrcServerParser_ctcp.cpp:975 debug: %s",szMsg.data());
g_pApp->notifierMessage(this, KVI_OPTION_MSGTYPE(KVI_OUT_ACTION).pixId(), szMsg, KVI_OPTION_UINT(KviOption_uintNotifierAutoHideTime));
}
}
}
else
{
#ifdef COMPILE_CRYPT_SUPPORT
if(KviCryptSessionInfo * cinf = cryptSessionInfo())
{
if(cinf->m_bDoDecrypt)
{
KviCString decryptedStuff;
switch(cinf->m_pEngine->decrypt(d.ptr(), decryptedStuff))
{
case KviCryptEngine::DecryptOkWasEncrypted:
case KviCryptEngine::DecryptOkWasEncoded:
case KviCryptEngine::DecryptOkWasPlainText:
if(!KVS_TRIGGER_EVENT_2_HALTED(KviEvent_OnDCCChatMessage, this, QString(decryptedStuff.ptr()), m_pDescriptor->idString()))
{
g_pMainWindow->firstConsole()->outputPrivmsg(this, KVI_OUT_DCCCHATMSG,
m_pDescriptor->szNick.toUtf8().data(), m_pDescriptor->szUser.toUtf8().data(),
m_pDescriptor->szHost.toUtf8().data(), decryptedStuff.ptr());
}
delete encoded;
return true;
break;
default: // also case KviCryptEngine::DecryptError
{
QString szErr = cinf->m_pEngine->lastError();
output(KVI_OUT_SYSTEMERROR,
__tr2qs_ctx("The following message appears to be encrypted, but the encryption engine failed to decode it: %Q", "dcc"),
&szErr);
}
break;
}
}
}
else
{
#endif
// FIXME!
if(!KVS_TRIGGER_EVENT_2_HALTED(KviEvent_OnDCCChatMessage, this, QString(d.ptr()), m_pDescriptor->idString()))
{
g_pMainWindow->firstConsole()->outputPrivmsg(this, KVI_OUT_DCCCHATMSG,
m_pDescriptor->szNick.toUtf8().data(), m_pDescriptor->szUser.toUtf8().data(),
m_pDescriptor->szHost.toUtf8().data(), d.ptr());
if(!hasAttention(KviWindow::MainWindowIsVisible))
{
if(KVI_OPTION_BOOL(KviOption_boolFlashDccChatWindowOnNewMessages))
{
demandAttention();
}
if(KVI_OPTION_BOOL(KviOption_boolPopupNotifierOnNewDccChatMessages))
{
QString szMsg = KviQString::toHtmlEscaped(QString(d.ptr()));
//.........这里部分代码省略.........
示例4: handleIncomingData
bool DccChatThread::handleIncomingData(KviDccThreadIncomingData * data, bool bCritical)
{
KVI_ASSERT(data->iLen);
KVI_ASSERT(data->buffer);
char * aux = data->buffer;
char * end = data->buffer + data->iLen;
while(aux != end)
{
if((*aux == '\n') || (*aux == '\0'))
{
KviThreadDataEvent<KviCString> * e = new KviThreadDataEvent<KviCString>(KVI_DCC_THREAD_EVENT_DATA);
// The left part is len chars long
int len = aux - data->buffer;
// qDebug("LEN = %d, iLen = %d",len,data->iLen);
//#warning "DO IT BETTER (the \r cutting)"
KviCString * s = new KviCString(data->buffer, len);
if(s->lastCharIs('\r'))
s->cutRight(1);
e->setData(s);
// but we cut also \n (or \0)
++aux;
// so len += 1; --> new data->iLen -= len;
data->iLen -= (len + 1);
// qDebug("iLen now = %d",data->iLen);
KVI_ASSERT(data->iLen >= 0);
if(data->iLen > 0)
{
// memmove the remaining part to the beginning
// aux points after \n or \0
KviMemory::move(data->buffer, aux, data->iLen);
data->buffer = (char *)KviMemory::reallocate(data->buffer, data->iLen);
end = data->buffer + data->iLen;
aux = data->buffer;
}
else
{
// no more data in the buffer
KVI_ASSERT(data->iLen == 0);
KviMemory::free(data->buffer);
data->buffer = end = aux = nullptr;
}
postEvent(parent(), e);
}
else
aux++;
// qDebug("PASSING CHAR %c",*aux);
}
// now aux == end
if(bCritical)
{
// need to flush everything...
if(data->iLen > 0)
{
// in the last part there are no NULL and \n chars
KviThreadDataEvent<KviCString> * e = new KviThreadDataEvent<KviCString>(KVI_DCC_THREAD_EVENT_DATA);
KviCString * s = new KviCString(data->buffer, data->iLen);
if(s->lastCharIs('\r'))
s->cutRight(1);
e->setData(s);
data->iLen = 0;
KviMemory::free(data->buffer);
data->buffer = nullptr;
postEvent(parent(), e);
}
}
return true;
}
示例5: 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);
//.........这里部分代码省略.........