本文整理汇总了C++中KviIrcMask::nick方法的典型用法代码示例。如果您正苦于以下问题:C++ KviIrcMask::nick方法的具体用法?C++ KviIrcMask::nick怎么用?C++ KviIrcMask::nick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KviIrcMask
的用法示例。
在下文中一共展示了KviIrcMask::nick方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doMatchUser
bool KviIsOnNotifyListManager::doMatchUser(const QString & notifyString, const KviIrcMask & mask)
{
const auto i = m_pRegUserDict.find(notifyString);
if(i != m_pRegUserDict.end())
{
const QString & nam = i->second;
// ok... find the user
if(KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(nam))
{
// ok... match the user
if(u->matchesFixed(mask))
{
// new user online
if(!(m_pConsole->notifyListView()->findEntry(mask.nick())))
{
notifyOnLine(mask.nick(), mask.user(), mask.host());
} // else already online, and matching... all ok
}
else
{
// not matched.... has he been online before ?
if(m_pConsole->notifyListView()->findEntry(mask.nick()))
{
// has been online just a sec ago, but now the mask does not match
// either reguserdb has changed, or the user went offline and another one got his nick
// in the meantime... (ugly situation anyway)
notifyOffLine(mask.nick(), mask.user(), mask.host(), __tr2qs("registration mask changed, or nickname is being used by someone else"));
}
else
{
// has never been online
if(_OUTPUT_VERBOSE)
m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Notify list: \r!n\r%Q\r appears to be online, but the mask [%[email protected]\r!h\r%Q\r] does not match (registration mask does not match, or nickname is being used by someone else)"), &(mask.nick()), &(mask.user()), &(mask.host()));
}
}
}
else
{
// oops... unexpected inconsistency.... reguser db modified ?
m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("Notify list: Unexpected inconsistency, registered user DB modified? (restarting)"));
stop();
start();
return false; // critical... exit from the call stack
}
}
else
{
// oops... unexpected inconsistency
m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("Notify list: Unexpected inconsistency, expected \r!n\r%Q\r in the registered user DB"), ¬ifyString);
}
return true;
}
示例2: notifyCheckClicked
void RegisteredUserEntryDialog::notifyCheckClicked(bool bChecked)
{
m_pNotifyNick->setEnabled(bChecked);
m_pNotifyLabel->setEnabled(bChecked);
if(bChecked && m_pNotifyNick->text().isEmpty())
{
QString szMask;
if(m_pUser)
{
for(KviIrcMask * m = m_pUser->maskList()->first();m;m = m_pUser->maskList()->next())
{
QString tmp = m->nick();
if((tmp.indexOf('*') == -1) && (tmp.indexOf('?') == -1) && (!tmp.isEmpty()))
{
if(!szMask.isEmpty())szMask.append(' ');
szMask.append(tmp);
}
}
// if the nickname list is still empty, build a dummy nick to notify
if(szMask.isEmpty())
{
szMask = m_pUser->name();
szMask.replace(" ","");
szMask.replace("'","");
szMask.replace("&","");
szMask.replace(",","");
}
m_pNotifyNick->setText(szMask);
}
}
}
示例3: itemPressed
void RegisteredUsersDialog::itemPressed(QTreeWidgetItem * it, int c)
{
if(!it)
return;
RegisteredUsersDialogItemBase * b = (RegisteredUsersDialogItemBase *)it;
if(b->type() == RegisteredUsersDialogItemBase::User)
{
RegisteredUsersDialogItem * i = (RegisteredUsersDialogItem *)it;
QRect r = m_pListView->visualItemRect(i);
int daw = m_pListView->columnWidth(0);
QPoint ppp = m_pListView->mapFromGlobal(QCursor::pos());
if((c == 1) && (ppp.x() < (r.height() + 5 + daw)))
{
// notify list toggle
if(i->user()->getProperty("notify").isEmpty())
{
// try to find the nicknames to be notified
QString szMask;
for(KviIrcMask * m = i->user()->maskList()->first(); m; m = i->user()->maskList()->next())
{
QString tmp = m->nick();
if((tmp.indexOf('*') == -1) && (tmp.indexOf('?') == -1) && (!tmp.isEmpty()))
{
if(!szMask.isEmpty())
szMask.append(' ');
szMask.append(tmp);
}
}
// if the nickname list is still empty, build a dummy nick to notify
if(szMask.isEmpty())
{
szMask = i->user()->name();
szMask.replace(" ", "");
szMask.replace("'", "");
szMask.replace("&", "");
szMask.replace(",", "");
}
i->user()->setProperty("notify", szMask);
}
else
{
i->user()->setProperty("notify", QString("")); // kill that
}
m_pListView->repaint(r);
}
}
}
示例4: addMaskClicked
void RegisteredUserEntryDialog::addMaskClicked()
{
KviIrcMask mk;
RegisteredUserMaskDialog * dlg = new RegisteredUserMaskDialog(this,&mk);
if(dlg->exec() == QDialog::Accepted)
{
QString m = mk.nick();
m += QChar('!');
m += mk.user();
m += QChar('@');
m += mk.host();
m_pMaskListBox->addItem(m);
}
delete dlg;
}
示例5: KviTalTabDialog
RegisteredUserEntryDialog::RegisteredUserEntryDialog(QWidget *p,KviRegisteredUser * r,bool bModal)
: KviTalTabDialog(p,"reguser_entry_editor",bModal)
{
m_pUser = r;
m_pCustomColor = new QColor();
if(r)
{
QString col=r->getProperty("customColor");
KviStringConversion::fromString(col,(*m_pCustomColor));
}
m_pPropertyDict = new KviPointerHashTable<QString,QString>(17,false);
m_pPropertyDict->setAutoDelete(true);
//setMinimumSize(400,450);
setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Linux)));
setWindowTitle(__tr2qs_ctx("Registered User Entry","register"));
QWidget * p1 = new QWidget(this);
QGridLayout * g = new QGridLayout(p1);
QLabel * l = new QLabel(__tr2qs_ctx("Name:","register"),p1);
g->addWidget(l,0,0);
m_pNameEdit = new QLineEdit(p1);
g->addWidget(m_pNameEdit,0,1);
l = new QLabel(__tr2qs_ctx("Comment:","register"),p1);
g->addWidget(l,1,0);
m_pCommentEdit = new QLineEdit(p1);
g->addWidget(m_pCommentEdit,1,1);
QFrame * f = new QFrame(p1);
g->addWidget(f,2,0,1,2);
f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
l = new QLabel(__tr2qs_ctx("Masks:","register"),p1);
g->addWidget(l,3,0,1,2);
m_pMaskListBox = new QListWidget(p1);
connect(m_pMaskListBox,SIGNAL(itemSelectionChanged()),this,SLOT(maskCurrentChanged()));
m_pMaskListBox->setMinimumSize(300,200);
g->addWidget(m_pMaskListBox,4,0,1,2);
KviTalHBox * b = new KviTalHBox(p1);
g->addWidget(b,5,0,1,2);
b->setSpacing(4);
m_pAddMaskButton = new QPushButton(__tr2qs_ctx("&Add...","register"),b);
connect(m_pAddMaskButton,SIGNAL(clicked()),this,SLOT(addMaskClicked()));
m_pAddMaskButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NewItem)));
m_pDelMaskButton = new QPushButton(__tr2qs_ctx("Re&move","register"),b);
m_pDelMaskButton->setEnabled(false);
connect(m_pDelMaskButton,SIGNAL(clicked()),this,SLOT(delMaskClicked()));
m_pDelMaskButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::DeleteItem)));
m_pEditMaskButton = new QPushButton(__tr2qs_ctx("&Edit","register"),b);
m_pEditMaskButton->setEnabled(false);
connect(m_pEditMaskButton,SIGNAL(clicked()),this,SLOT(editMaskClicked()));
m_pEditMaskButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::EditItem)));
g->setRowStretch(4,1);
g->setColumnStretch(1,1);
addTab(p1,__tr2qs_ctx("Identity","register"));
QWidget * p2 = new QWidget(this);
g = new QGridLayout(p2);
m_pNotifyCheck = new QCheckBox(__tr2qs_ctx("Notify when user is online","register"),p2);
g->addWidget(m_pNotifyCheck,0,0,1,3);
m_pNotifyLabel = new QLabel(__tr2qs_ctx("Notify nicknames:","register"),p2);
m_pNotifyLabel->setEnabled(m_pNotifyCheck->isChecked());
g->addWidget(m_pNotifyLabel,1,0);
m_pNotifyCheck->setToolTip(__tr2qs_ctx("<center>You can enter a space separated list of nicknames.</center>","register"));
m_pNotifyNick = new QLineEdit(p2);
m_pNotifyNick->setEnabled(false);
g->addWidget(m_pNotifyNick,1,1,1,2);
connect(m_pNotifyCheck,SIGNAL(toggled(bool)),this,SLOT(notifyCheckClicked(bool)));
f = new QFrame(p2);
f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
g->addWidget(f,2,0,1,3);
m_pAvatar = 0;
if(r)
{
const QString av = r->getProperty("avatar");
//.........这里部分代码省略.........
示例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();
}
}
//.........这里部分代码省略.........
示例7: doMatchUser
bool KviWatchNotifyListManager::doMatchUser(KviIrcMessage * msg, const QString & notifyString, const KviIrcMask & mask)
{
QString * nam = m_pRegUserDict->find(notifyString);
if(nam)
{
// ok...find the user
if(KviRegisteredUser * u = g_pRegisteredUserDataBase->findUserByName(*nam))
{
// ok ... match the user
if(u->matchesFixed(mask))
{
// new user online
if(!(m_pConsole->notifyListView()->findEntry(mask.nick())))
{
notifyOnLine(mask.nick(), mask.user(), mask.host(), "watch");
}
else
{
// else already online, and matching...all ok
if(msg->numeric() == RPL_NOWON)
{
// This is a reply to a /watch +something (should not happen, unless the user is messing) or to /watch l (user requested)
notifyOnLine(mask.nick(), mask.user(), mask.host(),
__tr2qs("watch entry listing requested by user"), false);
}
else
{
// This is a RPL_LOGON....we're desynched ?
notifyOnLine(mask.nick(), mask.user(), mask.host(),
__tr2qs("possible watch list desync"), false);
}
}
}
else
{
// not matched.... has he been online before ?
if(m_pConsole->notifyListView()->findEntry(mask.nick()))
{
// has been online just a sec ago, but now the mask does not match
// prolly the reguserdb has been changed
notifyOffLine(mask.nick(), mask.user(), mask.host(),
__tr2qs("registration mask changed or desync with the watch service"));
}
else
{
// has never been online
if(_OUTPUT_VERBOSE)
m_pConsole->output(KVI_OUT_SYSTEMMESSAGE,
__tr("Notify list: \r!n\r%Q\r appears to be online, but the mask [%[email protected]\r!h\r%Q\r] does not match (watch: registration mask does not match, or nickname is being used by someone else)"),
&(mask.nick()), &(mask.user()), &(mask.host()));
}
}
}
else
{
// ops... unexpected inconsistency .... reguser db modified ?
m_pConsole->output(KVI_OUT_SYSTEMWARNING,
__tr2qs("Notify list: Unexpected inconsistency, registered user DB modified? (watch: restarting)"));
stop();
start();
return false; // critical ... exit from the call stack
}
}
else
{
// not in our dictionary
// prolly someone used /WATCH behind our back... bad boy!
if(!(m_pConsole->notifyListView()->findEntry(mask.nick())))
{
notifyOnLine(mask.nick(), mask.user(), mask.host(), __tr2qs("watch entry added by user"));
}
}
return true;
}
示例8: 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);
//.........这里部分代码省略.........