diff options
| author | 2010-08-21 16:28:29 +0000 | |
|---|---|---|
| committer | 2010-08-21 16:28:29 +0000 | |
| commit | abf04e92e2e072358af3b4b2b74bfdafce6bea68 (patch) | |
| tree | a3bb9780ab3e6fb29c883990d5d81136582494a7 /src | |
| parent | Fix unclear comments (diff) | |
| download | KVIrc-abf04e92e2e072358af3b4b2b74bfdafce6bea68.tar.gz KVIrc-abf04e92e2e072358af3b4b2b74bfdafce6bea68.tar.bz2 KVIrc-abf04e92e2e072358af3b4b2b74bfdafce6bea68.zip | |
- handle channel list modes dinamically (only +b is hardcoded)
- added support for reop lists (+R, ircnet), channel owner lists (+q, unrealircd), channel admin lists (+a, unrealircd)
- added $chan.matchmask, $chan.masklist, $chan.maskcount
- fixed kvichannel to correctly report the sync time checking the request queue
- fixes #912
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4919 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp | 18 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnectionrequestqueue.h | 9 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp | 9 | ||||
| -rw-r--r-- | src/kvirc/sparser/kvi_sp_numeric.cpp | 42 | ||||
| -rw-r--r-- | src/kvirc/sparser/kvi_sp_tables.cpp | 12 | ||||
| -rw-r--r-- | src/kvirc/sparser/kvi_sparser.h | 6 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_channel.cpp | 343 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_channel.h | 233 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_maskeditor.cpp | 102 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_maskeditor.h | 5 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_modeeditor.cpp | 20 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_modeeditor.h | 1 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_modew.cpp | 14 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_modew.h | 1 | ||||
| -rw-r--r-- | src/modules/chan/libkvichan.cpp | 190 |
15 files changed, 530 insertions, 475 deletions
diff --git a/src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp b/src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp index c390d65fb..4c9bdab2e 100644 --- a/src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp +++ b/src/kvirc/kernel/kvi_ircconnectionrequestqueue.cpp @@ -87,40 +87,40 @@ void KviRequestQueue::timerSlot() switch(m_curType) { case BanException: - if(pChan->connection()->serverInfo()->supportsModesIe() && + if(pChan->serverInfo()->supportsModesIe() && !KVI_OPTION_BOOL(KviOption_boolDisableBanExceptionListRequestOnJoin) && - !( pChan->connection()->serverInfo()->getNeedsOpToListModeseI() && + !( pChan->serverInfo()->getNeedsOpToListModeseI() && !pChan->isMeOp() ) ) { if(!pChan->connection()->sendFmtData("MODE %s e",encodedChan.data())) clearAll(); // disconnected - else pChan->setSentBanExceptionListRequest(); + else pChan->setSentListRequest('e'); m_curType = Invite; break; } case Invite: - if(pChan->connection()->serverInfo()->supportsModesIe() && + if(pChan->serverInfo()->supportsModesIe() && !KVI_OPTION_BOOL(KviOption_boolDisableInviteListRequestOnJoin) && - !( pChan->connection()->serverInfo()->getNeedsOpToListModeseI() && + !( pChan->serverInfo()->getNeedsOpToListModeseI() && !pChan->isMeOp() ) ) { if(!pChan->connection()->sendFmtData("MODE %s I",encodedChan.data())) clearAll(); // disconnected - else pChan->setSentInviteListRequest(); + else pChan->setSentListRequest('I'); m_curType = QuietBan; break; } case QuietBan: - if(pChan->connection()->serverInfo()->supportsModeq() && + if(pChan->serverInfo()->supportsModeq() && !KVI_OPTION_BOOL(KviOption_boolDisableQuietBanListRequestOnJoin)) { if(!pChan->connection()->sendFmtData("MODE %s q",encodedChan.data())) clearAll(); // disconnected - else pChan->setSentQuietBanListRequest(); + else pChan->setSentListRequest('q'); m_curType = Who; break; } @@ -145,7 +145,7 @@ void KviRequestQueue::timerSlot() { if(!pChan->connection()->sendFmtData("MODE %s b",encodedChan.data())) clearAll(); // disconnected - else pChan->setSentBanListRequest(); + else pChan->setSentListRequest('b'); m_channels.dequeue(); m_curType = Mode; break; diff --git a/src/kvirc/kernel/kvi_ircconnectionrequestqueue.h b/src/kvirc/kernel/kvi_ircconnectionrequestqueue.h index e763bb821..1e4a06070 100644 --- a/src/kvirc/kernel/kvi_ircconnectionrequestqueue.h +++ b/src/kvirc/kernel/kvi_ircconnectionrequestqueue.h @@ -91,7 +91,14 @@ public: * \return void */ void dequeueChannel(KviChannel * pChan); - + + /** + * \brief Checks if a channel is in the queue stack + * \param pChan The channel to check + * \return bool + */ + bool isQueued(KviChannel * pChan) { return m_channels.contains(pChan); }; + /** * \brief Clears the queue stack * \return void diff --git a/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp b/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp index 3bcefbe2c..5625938a5 100644 --- a/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp +++ b/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp @@ -262,11 +262,11 @@ const QString & KviBasicIrcServerInfo::getChannelModeDescription(char mode) switch(mode) { // case '7': return __tr2qs("Only 7-bit letters in nicknames allowed"); break; - case 'I': return __tr2qs("Invite exception masks"); break; - case 'R': return __tr2qs("Reop masks"); break; + case 'I': return __tr2qs("Invite Exceptions"); break; + case 'R': return __tr2qs("Reop Masks"); break; case 'a': return __tr2qs("Anonymous messages"); break; - case 'b': return __tr2qs("Ban masks"); break; - case 'e': return __tr2qs("Ban exception masks"); break; + case 'b': return __tr2qs("Ban Masks"); break; + case 'e': return __tr2qs("Ban Exceptions"); break; case 'i': return __tr2qs("Invite only"); break; case 'k': return __tr2qs("Key"); break; case 'l': return __tr2qs("Limited number of users"); break; @@ -350,6 +350,7 @@ const QString & KviIrcdSevenIrcServerInfo::getChannelModeDescription(char mode) case 'g': return __tr2qs("Allow anybody to invite");break; case 'j': return __tr2qs("Join throttling (<num>:<secs>)"); break; case 'p': return __tr2qs("Paranoid (disable KNOCK)"); break; + case 'q': return __tr2qs("Quiet Ban Editor"); break; case 'r': return __tr2qs("Need auth to join channel"); break; case 'z': return __tr2qs("Reduced moderation for ops"); break; } diff --git a/src/kvirc/sparser/kvi_sp_numeric.cpp b/src/kvirc/sparser/kvi_sp_numeric.cpp index 89c70e11f..86f19fbe4 100644 --- a/src/kvirc/sparser/kvi_sp_numeric.cpp +++ b/src/kvirc/sparser/kvi_sp_numeric.cpp @@ -691,12 +691,12 @@ void KviServerParser::parseNumeric367(KviIrcMessage *msg) KviChannel * chan = msg->connection()->findChannel(szChan); if(chan) { - if(msg->connection()->serverInfo()->supportsModeq() && chan->sentQuietBanListRequest()) + if(msg->connection()->serverInfo()->supportsModeq() && chan->sentListRequest('q')) { chan->setMask('q',banmask,true,bansetby,QString(msg->safeParam(4)).toUInt()); return; } - if(chan->sentBanListRequest()) + if(chan->sentListRequest('b')) { chan->setMask('b',banmask,true,bansetby,QString(msg->safeParam(4)).toUInt()); return; @@ -717,16 +717,14 @@ void KviServerParser::parseNumeric368(KviIrcMessage *msg) KviChannel * chan = msg->connection()->findChannel(szChan); if(chan) { - if(msg->connection()->serverInfo()->supportsModeq() && chan->sentQuietBanListRequest()) + if(msg->connection()->serverInfo()->supportsModeq() && chan->sentListRequest('q')) { - chan->setHasQuietBanList(); - chan->setQuietBanListDone(); + chan->setListRequestDone('q'); return; } - if(chan->sentBanListRequest()) + if(chan->sentListRequest('b')) { - chan->setHasBanList(); - chan->setBanListDone(); + chan->setListRequestDone('b'); return; } } @@ -738,17 +736,16 @@ void KviServerParser::parseNumeric368(KviIrcMessage *msg) } } -#define PARSE_NUMERIC_ENDOFLIST(__funcname,__setGotIt,__didSendRequest,__setDone,__daicon,__szWhatQString) \ +#define PARSE_NUMERIC_ENDOFLIST(__funcname,__modechar,__daicon,__szWhatQString) \ void KviServerParser::__funcname(KviIrcMessage *msg) \ { \ QString szChan = msg->connection()->decodeText(msg->safeParam(1)); \ KviChannel * chan = msg->connection()->findChannel(szChan); \ if(chan) \ { \ - chan->__setGotIt(); \ - if(chan->__didSendRequest()) \ + if(chan->sentListRequest(__modechar)) \ { \ - chan->__setDone(); \ + chan->setListRequestDone(__modechar); \ return; \ } \ } \ @@ -760,10 +757,14 @@ void KviServerParser::parseNumeric368(KviIrcMessage *msg) } \ } -PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfInviteList,setHasInviteList,sentInviteListRequest,setInviteListDone,KVI_OUT_INVITEEXCEPT,__tr2qs("invite list")) -PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfExceptList,setHasBanExceptionList,sentBanExceptionListRequest,setBanExceptionListDone,KVI_OUT_BANEXCEPT,__tr2qs("ban exception list")) +PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfInviteList,'I',KVI_OUT_INVITEEXCEPT,__tr2qs("invite list")) +PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfExceptList,'e',KVI_OUT_BANEXCEPT,__tr2qs("ban exception list")) -#define PARSE_NUMERIC_LIST(__funcname,__modechar,__sentRequest,__ico,__szWhatQString) \ +PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfQList,'q',KVI_OUT_BAN,__tr2qs("owner list")) +PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfAList,'a',KVI_OUT_BAN,__tr2qs("protected/admin list")) +PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfReopList,'R',KVI_OUT_BAN,__tr2qs("reop list")) + +#define PARSE_NUMERIC_LIST(__funcname,__modechar,__ico,__szWhatQString) \ void KviServerParser::__funcname(KviIrcMessage *msg) \ { \ QString szChan = msg->connection()->decodeText(msg->safeParam(1)); \ @@ -776,7 +777,7 @@ PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfExceptList,setHasBanExceptionList,sentB if(chan) \ { \ chan->setMask(__modechar,banmask,true,bansetby,QString(msg->safeParam(4)).toUInt()); \ - if(chan->__sentRequest())return; \ + if(chan->sentListRequest(__modechar))return; \ } \ if(!msg->haltOutput()) \ { \ @@ -787,12 +788,13 @@ PARSE_NUMERIC_ENDOFLIST(parseNumericEndOfExceptList,setHasBanExceptionList,sentB } \ } -// 346: RPL_INVITELIST [I,E,U,D] -// :prefix 346 target <channel> <invitemask> [invitesetby] [invitesetat] -PARSE_NUMERIC_LIST(parseNumericInviteList,'I',sentInviteListRequest,KVI_OUT_INVITEEXCEPT,__tr2qs("Invite listing")) // 346: RPL_EXCEPTLIST [I,E,U,D] // :prefix 346 target <channel> <banmask> [bansetby] [bansetat] -PARSE_NUMERIC_LIST(parseNumericExceptList,'e',sentBanExceptionListRequest,KVI_OUT_BANEXCEPT,__tr2qs("Ban exception listing")); +PARSE_NUMERIC_LIST(parseNumericInviteList,'I',KVI_OUT_INVITEEXCEPT,__tr2qs("Invite listing")) +PARSE_NUMERIC_LIST(parseNumericExceptList,'e',KVI_OUT_BANEXCEPT,__tr2qs("Ban exception listing")); +PARSE_NUMERIC_LIST(parseNumericQList,'q',KVI_OUT_BAN,__tr2qs("Owner listing")); +PARSE_NUMERIC_LIST(parseNumericAList,'a',KVI_OUT_BAN,__tr2qs("Admin/protected nicks listing")); +PARSE_NUMERIC_LIST(parseNumericReopList,'R',KVI_OUT_BAN,__tr2qs("Reop masks listing")); void KviServerParser::parseNumericWhoReply(KviIrcMessage *msg) { diff --git a/src/kvirc/sparser/kvi_sp_tables.cpp b/src/kvirc/sparser/kvi_sp_tables.cpp index 53d113cfc..dc2b62cc8 100644 --- a/src/kvirc/sparser/kvi_sp_tables.cpp +++ b/src/kvirc/sparser/kvi_sp_tables.cpp @@ -432,8 +432,8 @@ messageParseProc KviServerParser::m_numericParseProcTable[1000]= PTM(parseNumericInviting) , // 351 RPL_INVITING 0, // 342 0, // 343 - 0, // 344 - 0, // 345 + PTM(parseNumericReopList) , // 344 RPL_REOPLIST + PTM(parseNumericEndOfReopList) , // 345 RPL_ENDOFREOPLIST PTM(parseNumericInviteList) , // 346 RPL_INVITELIST PTM(parseNumericEndOfInviteList) , // 347 RPL_ENDOFINVITELIST PTM(parseNumericExceptList) , // 348 RPL_EXCEPTLIST @@ -474,10 +474,10 @@ messageParseProc KviServerParser::m_numericParseProcTable[1000]= 0, // 383 0, // 384 0, // 385 - 0, // 386 - 0, // 387 - 0, // 388 - 0, // 389 + PTM(parseNumericQList) , // 386 RPL_QLIST + PTM(parseNumericEndOfQList) , // 387 RPL_ENDOFQLIST + PTM(parseNumericAList) , // 388 RPL_ALIST + PTM(parseNumericEndOfAList) , // 389 RPL_ENDOFALIST 0, // 390 PTM(parseNumericTime) , // 391 RPL_TIME 0, // 392 diff --git a/src/kvirc/sparser/kvi_sparser.h b/src/kvirc/sparser/kvi_sparser.h index 90ad15c34..431aa3f9b 100644 --- a/src/kvirc/sparser/kvi_sparser.h +++ b/src/kvirc/sparser/kvi_sparser.h @@ -151,6 +151,12 @@ private: void parseNumericEndOfInviteList(KviIrcMessage *msg); void parseNumericExceptList(KviIrcMessage *msg); void parseNumericEndOfExceptList(KviIrcMessage *msg); + void parseNumericQList(KviIrcMessage *msg); + void parseNumericEndOfQList(KviIrcMessage *msg); + void parseNumericAList(KviIrcMessage *msg); + void parseNumericEndOfAList(KviIrcMessage *msg); + void parseNumericReopList(KviIrcMessage *msg); + void parseNumericEndOfReopList(KviIrcMessage *msg); void parseNumericWhoReply(KviIrcMessage *msg); void parseNumericEndOfWho(KviIrcMessage *msg); void parseNumericNicknameProblem(KviIrcMessage *msg); diff --git a/src/kvirc/ui/kvi_channel.cpp b/src/kvirc/ui/kvi_channel.cpp index f4a3a5302..f90174c25 100644 --- a/src/kvirc/ui/kvi_channel.cpp +++ b/src/kvirc/ui/kvi_channel.cpp @@ -47,6 +47,7 @@ #include "kvi_ircconnection.h" #include "kvi_ircconnectionuserinfo.h" #include "kvi_ircconnectionserverinfo.h" +#include "kvi_ircconnectionrequestqueue.h" #include "kvi_defaults.h" #include "kvi_sparser.h" #include "kvi_modew.h" @@ -79,7 +80,6 @@ // FIXME: #warning "+a Anonymous channel mode!" -// FIXME: #warning "+R channel mode (reop)" // FIXME: #warning "OnChannelFlood event...." @@ -89,14 +89,6 @@ KviChannel::KviChannel(KviFrame * lpFrm, KviConsole * lpConsole, const QString & // Init some member variables m_pInput = 0; m_iStateFlags = 0; - m_pBanList = new KviPointerList<KviMaskEntry>; - m_pBanList->setAutoDelete(true); - m_pBanExceptionList = new KviPointerList<KviMaskEntry>; - m_pBanExceptionList->setAutoDelete(true); - m_pInviteList = new KviPointerList<KviMaskEntry>; - m_pInviteList->setAutoDelete(true); - m_pQuietBanList = new KviPointerList<KviMaskEntry>; - m_pQuietBanList->setAutoDelete(true); m_pActionHistory = new KviPointerList<KviChannelAction>; m_pActionHistory->setAutoDelete(true); m_uActionHistoryHotActionCount = 0; @@ -156,31 +148,58 @@ KviChannel::KviChannel(KviFrame * lpFrm, KviConsole * lpConsole, const QString & m_pListViewButton = new KviWindowToolPageButton(KVI_SMALLICON_HIDELISTVIEW,KVI_SMALLICON_SHOWLISTVIEW,__tr2qs("User List"),buttonContainer(),true,"list_view_button"); connect(m_pListViewButton,SIGNAL(clicked()),this,SLOT(toggleListView())); - m_pBanEditorButton = new KviWindowToolPageButton(KVI_SMALLICON_UNBAN,KVI_SMALLICON_BAN,__tr2qs("Ban Editor"),buttonContainer(),false,"ban_editor_button"); - connect(m_pBanEditorButton,SIGNAL(clicked()),this,SLOT(toggleBanEditor())); - if(m_pConsole->connection()->serverInfo()->supportedListModes().contains('e')) - { - m_pBanExceptionEditorButton =new KviWindowToolPageButton(KVI_SMALLICON_BANUNEXCEPT,KVI_SMALLICON_BANEXCEPT,__tr2qs("Ban Exception Editor"),buttonContainer(),false,"ban_exception_editor_button"); - connect(m_pBanExceptionEditorButton,SIGNAL(clicked()),this,SLOT(toggleBanExceptionEditor())); - } else { - m_pBanExceptionEditorButton=0; - } - - if(m_pConsole->connection()->serverInfo()->supportedListModes().contains('I')) - { - m_pInviteEditorButton =new KviWindowToolPageButton(KVI_SMALLICON_INVITEUNEXCEPT,KVI_SMALLICON_INVITEEXCEPT,__tr2qs("Invite Exception Editor"),buttonContainer(),false,"invite_exception_editor_button"); - connect(m_pInviteEditorButton,SIGNAL(clicked()),this,SLOT(toggleInviteEditor())); - } else { - m_pInviteEditorButton = 0; - } + //list modes (bans, bans exceptions, etc) + KviWindowToolPageButton * pButton = 0; + char cMode = 0; + QString szDescription = ""; + KviIrcConnectionServerInfo * pServerInfo = serverInfo(); + // bans are hardcoded + cMode='b'; + + if(pServerInfo) + szDescription = pServerInfo->getChannelModeDescription(cMode); + if(szDescription.isEmpty()) + szDescription = __tr2qs("Mode \"%1\" Masks").arg(cMode); - if(m_pConsole->connection()->serverInfo()->supportedListModes().contains('q')) + pButton = new KviWindowToolPageButton(KVI_SMALLICON_UNBAN,KVI_SMALLICON_BAN,szDescription,buttonContainer(),false,"ban_editor_button"); + connect(pButton,SIGNAL(clicked()),this,SLOT(toggleListModeEditor())); + m_pListEditorButtons.insert(cMode, pButton); + + //other list modes (dynamic) + QString szListModes = ""; + if(pServerInfo) { - m_pQuietBanEditorButton =new KviWindowToolPageButton(KVI_SMALLICON_UNBAN,KVI_SMALLICON_BAN,__tr2qs("Quiet Ban Editor"),buttonContainer(),false,"quiet_ban_editor_button"); - connect(m_pQuietBanEditorButton,SIGNAL(clicked()),this,SLOT(toggleQuietBanEditor())); - } else { - m_pQuietBanEditorButton = 0; + szListModes = pServerInfo->supportedListModes(); + szListModes.remove('b'); + + for(int i=0;i<szListModes.size();++i) + { + char cMode = szListModes.at(i).unicode(); + QString szDescription = pServerInfo->getChannelModeDescription(cMode); + if(szDescription.isEmpty()) + szDescription = __tr2qs("Mode \"%1\" Masks").arg(cMode); + int iIconOn, iIconOff; + switch(cMode) + { + case 'e': + iIconOn = KVI_SMALLICON_BANUNEXCEPT; + iIconOff = KVI_SMALLICON_BANEXCEPT; + break; + case 'I': + iIconOn = KVI_SMALLICON_INVITEUNEXCEPT; + iIconOff = KVI_SMALLICON_INVITEEXCEPT; + break; + default: + iIconOn = KVI_SMALLICON_UNBAN; + iIconOff = KVI_SMALLICON_BAN; + break; + } + + pButton = new KviWindowToolPageButton(iIconOn,iIconOff,szDescription,buttonContainer(),false,"list_mode_editor_button"); + connect(pButton,SIGNAL(clicked()),this,SLOT(toggleListModeEditor())); + m_pListEditorButtons.insert(cMode, pButton); + } } m_pModeEditorButton = new KviWindowToolPageButton(KVI_SMALLICON_CHANMODEHIDE,KVI_SMALLICON_CHANMODE,__tr2qs("Mode Editor"),buttonContainer(),false,"mode_editor_button"); @@ -207,11 +226,7 @@ KviChannel::KviChannel(KviFrame * lpFrm, KviConsole * lpConsole, const QString & //m_pEditorsContainer->raiseWidget(m_pUserListView); // And finally the input line on the bottom m_pInput = new KviInput(this,m_pUserListView); - // no mask editors yet - m_pBanEditor = 0; - m_pBanExceptionEditor = 0; - m_pInviteEditor = 0; - m_pQuietBanEditor = 0; + // Ensure proper focusing //setFocusHandler(m_pInput,this); // And turn on the secondary IRC view if needed @@ -240,11 +255,14 @@ KviChannel::~KviChannel() m_pUserListView->partAll(); delete m_pActionHistory; - delete m_pBanList; - delete m_pBanExceptionList; - delete m_pInviteList; - delete m_pQuietBanList; delete m_pTmpHighLighted; + + qDeleteAll(m_pListEditors); + m_pListEditors.clear(); + qDeleteAll(m_pListEditorButtons); + m_pListEditorButtons.clear(); + qDeleteAll(m_pModeLists); + m_pModeLists.clear(); } void KviChannel::toggleToolButtons() @@ -475,88 +493,57 @@ void KviChannel::setMode(QString & szMode) connection()->sendFmtData("MODE %s %s",channelName.data(),modes.data()); } -void KviChannel::toggleBanEditor() +void KviChannel::toggleListModeEditor() { - toggleEditor(&m_pBanEditor,&m_pBanEditorButton,m_pBanList,'b',"ban_editor"); -} - -void KviChannel::toggleBanExceptionEditor() -{ - toggleEditor(&m_pBanExceptionEditor,&m_pBanExceptionEditorButton,m_pBanExceptionList,'e',"ban_exception_editor"); -} + KviWindowToolPageButton* pButton = (KviWindowToolPageButton*)sender(); + if(!pButton) + return; //wtf? -void KviChannel::toggleInviteEditor() -{ - toggleEditor(&m_pInviteEditor,&m_pInviteEditorButton,m_pInviteList,'I',"invite_exception_editor"); -} - -void KviChannel::toggleQuietBanEditor() -{ - toggleEditor(&m_pQuietBanEditor,&m_pQuietBanEditorButton,m_pQuietBanList,'q',"quiet_ban_editor"); -} - -void KviChannel::toggleEditor(KviMaskEditor ** ppEd, KviWindowToolPageButton ** ppBtn, KviPointerList<KviMaskEntry> * l, char cFlag, const char * pcEdName) -{ - if(*ppEd) + char cMode=0; + QMap<char, KviWindowToolPageButton*>::const_iterator iter = m_pListEditorButtons.constBegin(); + + while (iter != m_pListEditorButtons.constEnd()) { - delete *ppEd; - *ppEd = 0; - - if(!(*ppBtn)) - return; - if((*ppBtn)->isChecked()) - (*ppBtn)->setChecked(false); - } else { - bool bHasList = true; - switch(cFlag) + if(iter.value()==pButton) { - case 'b': - if(!(bHasList = hasBanList())) - { - m_pBanList->clear(); - setSentBanListRequest(); - } - break; - case 'e': - if(!(bHasList = hasBanExceptionList())) - { - m_pBanExceptionList->clear(); - setSentBanExceptionListRequest(); - } - break; - case 'I': - if(!(bHasList = hasInviteList())) - { - m_pInviteList->clear(); - setSentInviteListRequest(); - } - break; - case 'q': - if(!(bHasList = hasQuietBanList())) - { - m_pQuietBanList->clear(); - setSentQuietBanListRequest(); - } + cMode=iter.key(); break; } + ++iter; + } + + if(!cMode) + return; //wtf? + + if(m_pListEditors.contains(cMode)) + { + KviMaskEditor * pEditor = m_pListEditors.value(cMode); + m_pListEditors.remove(cMode); + pEditor->deleteLater(); - if(!bHasList) + pButton->setChecked(false); + } else { + if(!m_pModeLists.contains(cMode)) { + KviPointerList<KviMaskEntry>* pModeList = new KviPointerList<KviMaskEntry>; + pModeList->setAutoDelete(true); + m_pModeLists.insert(cMode,pModeList); + + m_szSentModeRequests.append(cMode); + if(connection()) { QByteArray szName = connection()->encodeText(m_szName); - connection()->sendFmtData("MODE %s %c",szName.data(),cFlag); + connection()->sendFmtData("MODE %s %c",szName.data(),cMode); } } - *ppEd = new KviMaskEditor(m_pSplitter,*ppBtn,l,cFlag,pcEdName); - connect(*ppEd,SIGNAL(removeMasks(KviMaskEditor *,KviPointerList<KviMaskEntry> *)),this,SLOT(removeMasks(KviMaskEditor *,KviPointerList<KviMaskEntry> *))); - //setFocusHandler(m_pInput,*ppEd); //socket it! - (*ppEd)->show(); - if(!(*ppBtn)) - return; - if(!((*ppBtn)->isChecked())) - (*ppBtn)->setChecked(true); + KviPointerList<KviMaskEntry> * pMaskList = m_pModeLists.value(cMode); + KviMaskEditor * pEditor = new KviMaskEditor(m_pSplitter,this,pButton,pMaskList,cMode,"list_mode_editor"); + connect(pEditor,SIGNAL(removeMasks(KviMaskEditor *,KviPointerList<KviMaskEntry> *)),this,SLOT(removeMasks(KviMaskEditor *,KviPointerList<KviMaskEntry> *))); + m_pListEditors.insert(cMode,pEditor); + pEditor->show(); + pButton->setChecked(true); } } @@ -564,7 +551,14 @@ void KviChannel::removeMasks(KviMaskEditor * ed, KviPointerList<KviMaskEntry> * { QString szMasks; QString szFlags; - unsigned int uCount = 0; + int uCount = 0; + int iModesPerLine=3; // a good default + KviIrcConnectionServerInfo * pServerInfo = serverInfo(); + if(pServerInfo) + { + iModesPerLine = pServerInfo->maxModeChanges(); + if(iModesPerLine < 1) iModesPerLine = 1; + } for(KviMaskEntry * e = l->first(); e; e = l->next()) { @@ -575,7 +569,7 @@ void KviChannel::removeMasks(KviMaskEditor * ed, KviPointerList<KviMaskEntry> * szFlags.append(ed->flag()); uCount++; - if(uCount == (unsigned int) connection()->serverInfo()->maxModeChanges()) + if(uCount == iModesPerLine) { if(connection()) { @@ -622,9 +616,13 @@ QSize KviChannel::sizeHint() const void KviChannel::setChannelMode(char mode, bool bAdd) { - // skip modes that ends up in a list (eg: bans) - if(m_pConsole->connection()->serverInfo()->supportedListModes().contains(mode)) - return; + // skip modes that ends up in a list (bans are hardcoded) + KviIrcConnectionServerInfo * pServerInfo = serverInfo(); + if(pServerInfo || mode == 'b') + { + if(pServerInfo->supportedListModes().contains(mode)) + return; + } if(bAdd) { @@ -695,19 +693,24 @@ void KviChannel::setDeadChan() m_pUserListView->enableUpdates(true); m_pUserListView->setUserDataBase(0); - m_pBanList->clear(); - m_pBanExceptionList->clear(); - m_pInviteList->clear(); - m_pQuietBanList->clear(); - - if(m_pBanEditor) m_pBanEditor->clear(); - if(m_pBanExceptionEditor) m_pBanExceptionEditor->clear(); - if(m_pInviteEditor) m_pInviteEditor->clear(); - if(m_pQuietBanEditor) m_pQuietBanEditor->clear(); - + //clear all mask lists (eg bans) + QMap<char, KviPointerList<KviMaskEntry>*>::const_iterator iter = m_pModeLists.constBegin(); + while (iter != m_pModeLists.constEnd()) + { + iter.value()->clear(); + ++iter; + } + + //clear all mask editors + QMap<char, KviMaskEditor*>::const_iterator iter2 = m_pListEditors.constBegin(); + while (iter2 != m_pListEditors.constEnd()) + { + iter.value()->clear(); + ++iter; + } + m_pTopicWidget->reset(); - m_pActionHistory->clear(); m_uActionHistoryHotActionCount = 0; @@ -1627,37 +1630,26 @@ int KviChannel::myFlags() return m_pUserListView->flags(connection()->currentNickName()); } -void KviChannel::setMask(char cFlag, const QString & szMask, bool bAdd, const QString & szSetBy, unsigned int uSetAt) +void KviChannel::setMask(char cMode, const QString & szMask, bool bAdd, const QString & szSetBy, unsigned int uSetAt) { if(!connection()) return; - KviPointerList<KviMaskEntry> * list = m_pBanList; - KviMaskEditor * editor = m_pBanEditor; - switch(cFlag) + if(!m_pModeLists.contains(cMode)) { - case 'b': - m_iStateFlags ^= KVI_CHANNEL_STATE_HAVEBANLIST; - break; - case 'e': - m_iStateFlags ^= KVI_CHANNEL_STATE_HAVEBANEXCEPTIONLIST; - list = m_pBanExceptionList; - editor = m_pBanExceptionEditor; - break; - case 'I': - m_iStateFlags ^= KVI_CHANNEL_STATE_HAVEINVITELIST; - list = m_pInviteList; - editor = m_pInviteEditor; - break; - case 'q': - m_iStateFlags ^= KVI_CHANNEL_STATE_HAVEQUIETBANLIST; - list = m_pQuietBanList; - editor = m_pQuietBanEditor; - break; + // lazily insert it + KviPointerList<KviMaskEntry>* pModeList = new KviPointerList<KviMaskEntry>; + pModeList->setAutoDelete(true); + m_pModeLists.insert(cMode,pModeList); } + KviPointerList<KviMaskEntry> * list = m_pModeLists.value(cMode); + KviMaskEditor * editor = 0; + if(m_pListEditors.contains(cMode)) + editor = m_pListEditors.value(cMode); + internalMask(szMask,bAdd,szSetBy,uSetAt,list,&editor); - m_pUserListView->setMaskEntries(cFlag,(int)list->count()); + m_pUserListView->setMaskEntries(cMode,(int)list->count()); } void KviChannel::internalMask(const QString & szMask, bool bAdd, const QString & szSetBy, unsigned int uSetAt, KviPointerList<KviMaskEntry> * l, KviMaskEditor ** ppEd) @@ -1698,9 +1690,12 @@ void KviChannel::updateModeLabel() QString szTip = __tr2qs("<b>Channel mode:</b>"); KviStr szMod = m_szChannelMode; const char * pcAux = szMod.ptr(); + KviIrcConnectionServerInfo * pServerInfo = serverInfo(); + while(*pcAux) { - KviQString::appendFormatted(szTip,"<br>%c: %Q",*pcAux,&(m_pConsole->connection()->serverInfo()->getChannelModeDescription(*pcAux))); + if(pServerInfo) + KviQString::appendFormatted(szTip,"<br>%c: %Q",*pcAux,&(m_pConsole->connection()->serverInfo()->getChannelModeDescription(*pcAux))); ++pcAux; } @@ -1738,29 +1733,13 @@ void KviChannel::checkChannelSync() return; } - if(m_iStateFlags & KVI_CHANNEL_STATE_SENTBANLISTREQUEST) - { - if(!(m_iStateFlags & KVI_CHANNEL_STATE_HAVEBANLIST)) - return; - } - - if(m_iStateFlags & KVI_CHANNEL_STATE_SENTBANEXCEPTIONLISTREQUEST) - { - if(!(m_iStateFlags & KVI_CHANNEL_STATE_HAVEBANEXCEPTIONLIST)) - return; - } - - if(m_iStateFlags & KVI_CHANNEL_STATE_SENTINVITELISTREQUEST) - { - if(!(m_iStateFlags & KVI_CHANNEL_STATE_HAVEINVITELIST)) - return; - } - - if(m_iStateFlags & KVI_CHANNEL_STATE_SENTQUIETBANLISTREQUEST) - { - if(!(m_iStateFlags & KVI_CHANNEL_STATE_HAVEQUIETBANLIST)) - return; - } + // check if we're in the on-join request queue list + if(connection()->requestQueue()->isQueued(this)) + return; + + // check if there's any request still runinng + if(m_szSentModeRequests.size() != 0) + return; m_iStateFlags |= KVI_CHANNEL_STATE_SYNCHRONIZED; // we already have all the spontaneous server replies @@ -1798,17 +1777,15 @@ void KviChannel::preprocessMessage(QString & szMessage) QString szTmp = KviMircCntrl::stripControlBytes(*it); if(findEntry(*it)) *it = QString("\r!n\r%1\r").arg(*it); - if(m_pConsole) + KviIrcConnectionServerInfo * pServerInfo = serverInfo(); + if(pServerInfo) { - if(m_pConsole->connection()) + if(pServerInfo->supportedChannelTypes().contains(szTmp[0])) { - if(m_pConsole->connection()->serverInfo()->supportedChannelTypes().contains(szTmp[0])) - { - if((*it) == szTmp) - *it = QString("\r!c\r%1\r").arg(*it); - else - *it = QString("\r!c%1\r%2\r").arg(szTmp, *it); - } + if((*it) == szTmp) + *it = QString("\r!c\r%1\r").arg(*it); + else + *it = QString("\r!c%1\r%2\r").arg(szTmp, *it); } } } @@ -1822,6 +1799,12 @@ void KviChannel::unhighlight() m_pWindowListItem->unhighlight(); } +inline KviIrcConnectionServerInfo * KviChannel::serverInfo() +{ + if(!connection()) return 0; + return connection()->serverInfo(); +} + void KviChannel::pasteLastLog() { QString szChannel = target().toLower(); diff --git a/src/kvirc/ui/kvi_channel.h b/src/kvirc/ui/kvi_channel.h index d6e9f3a0b..4d4aab3eb 100644 --- a/src/kvirc/ui/kvi_channel.h +++ b/src/kvirc/ui/kvi_channel.h @@ -64,16 +64,8 @@ class KviModeEditor; /** * \def KVI_CHANNEL_STATE_HAVEALLNAMES Flag for "have all names" -* \def KVI_CHANNEL_STATE_HAVEBANLIST Flag for "have ban list" * \def KVI_CHANNEL_STATE_HAVEWHOLIST Flag for "have WHO list" -* \def KVI_CHANNEL_STATE_HAVEBANEXCEPTIONLIST Flag for "have ban exception list" -* \def KVI_CHANNEL_STATE_HAVEINVITELIST Flag for "have invite list" -* \def KVI_CHANNEL_STATE_HAVEQUIETBANLIST Flag for "have quiet ban list" * \def KVI_CHANNEL_STATE_DEADCHAN Flag for "dead channel" -* \def KVI_CHANNEL_STATE_SENTBANLISTREQUEST Flag to set ban list request -* \def KVI_CHANNEL_STATE_SENTBANEXCEPTIONLISTREQUEST Flag to set ban exception list request -* \def KVI_CHANNEL_STATE_SENTINVITELISTREQUEST Flag to set invite list request -* \def KVI_CHANNEL_STATE_SENTQUIETBANLISTREQUEST Flag to set ban list request * \def KVI_CHANNEL_STATE_SENTWHOREQUEST Flag to set WHO request * \def KVI_CHANNEL_STATE_SENTPART Flag to set PART request * \def KVI_CHANNEL_STATE_SYNCHRONIZED Flag to set SYNC request @@ -81,21 +73,17 @@ class KviModeEditor; * \def KVI_CHANNEL_STATE_SENTSYNCWHOREQUEST Flag for SYNC request */ #define KVI_CHANNEL_STATE_HAVEALLNAMES 1 -#define KVI_CHANNEL_STATE_HAVEBANLIST (1 << 1) #define KVI_CHANNEL_STATE_HAVEWHOLIST (1 << 2) -#define KVI_CHANNEL_STATE_HAVEBANEXCEPTIONLIST (1 << 3) -#define KVI_CHANNEL_STATE_HAVEINVITELIST (1 << 4) -#define KVI_CHANNEL_STATE_HAVEQUIETBANLIST (1 << 5) -#define KVI_CHANNEL_STATE_DEADCHAN (1 << 6) -#define KVI_CHANNEL_STATE_SENTBANLISTREQUEST (1 << 7) -#define KVI_CHANNEL_STATE_SENTBANEXCEPTIONLISTREQUEST (1 << 8) -#define KVI_CHANNEL_STATE_SENTINVITELISTREQUEST (1 << 9) -#define KVI_CHANNEL_STATE_SENTQUIETBANLISTREQUEST (1 << 10) -#define KVI_CHANNEL_STATE_SENTWHOREQUEST (1 << 11) -#define KVI_CHANNEL_STATE_SENTPART (1 << 12) -#define KVI_CHANNEL_STATE_SYNCHRONIZED (1 << 13) -#define KVI_CHANNEL_STATE_NOCLOSEONPART (1 << 14) -#define KVI_CHANNEL_STATE_SENTSYNCWHOREQUEST (1 << 15) +#define KVI_CHANNEL_STATE_DEADCHAN (1 << 3) +#define KVI_CHANNEL_STATE_SENTWHOREQUEST (1 << 4) +#define KVI_CHANNEL_STATE_SENTPART (1 << 5) +#define KVI_CHANNEL_STATE_SYNCHRONIZED (1 << 6) +#define KVI_CHANNEL_STATE_NOCLOSEONPART (1 << 7) +#define KVI_CHANNEL_STATE_SENTSYNCWHOREQUEST (1 << 8) + +#define KVI_CHANNEL_STATE_MODELIST_NONE 0 +#define KVI_CHANNEL_STATE_MODELIST_REQUEST 1 +#define KVI_CHANNEL_STATE_MODELIST_GOTIT 2 /** * \def KVI_CHANACTIVITY_LIMIT_ICE The limit to be "ice" @@ -185,27 +173,19 @@ protected: KviTalSplitter * m_pVertSplitter; QToolButton * m_pDoubleViewButton; KviWindowToolPageButton * m_pListViewButton; - KviWindowToolPageButton * m_pBanEditorButton; - KviWindowToolPageButton * m_pBanExceptionEditorButton; - KviWindowToolPageButton * m_pInviteEditorButton; - KviWindowToolPageButton * m_pQuietBanEditorButton; KviWindowToolPageButton * m_pModeEditorButton; - KviMaskEditor * m_pBanEditor; - KviMaskEditor * m_pBanExceptionEditor; - KviMaskEditor * m_pInviteEditor; - KviMaskEditor * m_pQuietBanEditor; + QMap<char, KviWindowToolPageButton*> m_pListEditorButtons; + QMap<char, KviMaskEditor*> m_pListEditors; KviModeEditor * m_pModeEditor; KviIrcView * m_pMessageView; KviTopicWidget * m_pTopicWidget; KviUserListView * m_pUserListView; KviModeWidget * m_pModeWidget; int m_iStateFlags; + QString m_szSentModeRequests; QString m_szChannelMode; QMap<char, QString> m_szChannelParameterModes; - KviPointerList<KviMaskEntry> * m_pBanList; - KviPointerList<KviMaskEntry> * m_pBanExceptionList; - KviPointerList<KviMaskEntry> * m_pInviteList; - KviPointerList<KviMaskEntry> * m_pQuietBanList; + QMap<char, KviPointerList<KviMaskEntry>*> m_pModeLists; KviPixmap m_privateBackground; QDateTime m_joinTime; QString m_szNameWithUserFlag; @@ -241,28 +221,34 @@ public: QFrame * buttonContainer() { return (QFrame*)m_pButtonContainer; }; /** + * \brief Returns a list of masks for a specific mode + * \return KviPointerList<KviMaskEntry> * + */ + inline KviPointerList<KviMaskEntry> * modeMasks(char cMode){ if(m_pModeLists.contains(cMode)) return m_pModeLists.value(cMode); return 0; }; + + /** * \brief Returns the list of bans set * \return KviPointerList<KviMaskEntry> * */ - KviPointerList<KviMaskEntry> * banList(){ return m_pBanList; }; + KviPointerList<KviMaskEntry> * banList(){ return modeMasks('b'); }; /** * \brief Returns the list of ban exceptions set * \return KviPointerList<KviMaskEntry> * */ - KviPointerList<KviMaskEntry> * banExceptionList(){ return m_pBanExceptionList; }; + KviPointerList<KviMaskEntry> * banExceptionList(){ return modeMasks('e'); }; /** - * \brief Returns the list of invites set + * \brief Returns the list of invite exceptions set * \return KviPointerList<KviMaskEntry> * */ - KviPointerList<KviMaskEntry> * inviteList(){ return m_pInviteList; }; + KviPointerList<KviMaskEntry> * inviteList(){ return modeMasks('I'); }; /** * \brief Returns the list of quiet bans set * \return KviPointerList<KviMaskEntry> * */ - KviPointerList<KviMaskEntry> * quietBanList(){ return m_pQuietBanList; }; + KviPointerList<KviMaskEntry> * quietBanList(){ return modeMasks('q'); }; /** * \brief Returns the first selected nickname in the userlist @@ -344,45 +330,51 @@ public: unsigned int count(){ return m_pUserListView->count(); }; /** + * \brief Returns the number of masks is a channel mode list + * \return unsigned int + */ + unsigned int maskCount(char cMode){ if(m_pModeLists.contains(cMode)) return m_pModeLists.value(cMode)->count(); return 0; }; + + /** * \brief Returns the number of ban masks * \return unsigned int */ - unsigned int banCount(){ return m_pBanList->count(); }; + unsigned int banCount(){ if(m_pModeLists.contains('b')) return m_pModeLists.value('b')->count(); return 0; }; /** * \brief Returns the number of ban exceptions masks list * \return unsigned int */ - unsigned int banExceptionCount(){ return m_pBanExceptionList->count(); }; + unsigned int banExceptionCount(){ if(m_pModeLists.contains('e')) return m_pModeLists.value('e')->count(); return 0; }; /** * \brief Returns the number of invite masks * \return unsigned int */ - unsigned int inviteCount(){ return m_pInviteList->count(); }; + unsigned int inviteCount(){ if(m_pModeLists.contains('I')) return m_pModeLists.value('I')->count(); return 0; }; /** * \brief Returns the number of quiet ban masks * \return unsigned int */ - unsigned int quietBanCount(){ return m_pQuietBanList->count(); }; + unsigned int quietBanCount(){ if(m_pModeLists.contains('q')) return m_pModeLists.value('q')->count(); return 0; }; /** - * \brief Called when someone sets a mask in the channel's lists + * \brief Called when someone sets a channel mode that is stored in a list; these modes require a parameter that is tipically a mask * - * The type of the mask can be: - * - b: ban - * - e: ban exception - * - I: invite - * - q: quiet ban - * \param cFlag The type of the mask - * \param szMask The mask set + * Examples: + * - b: ban with mask + * - e: ban exception with mask + * - I: invite exception with mask + * - q: channel owner with nick (unreal) or quiet ban (ircd-seven) + * \param cMode The type of the mask + * \param szMask The mask set (more generically, the parameter) * \param bAdd Whether to add or remove the mask * \param szSetBy Who set the mask * \param uSetAt The datetime when the mask was set * \return void */ - void setMask(char cFlag, const QString & szMask, bool bAdd, const QString & szSetBy, unsigned int uSetAt); + void setMask(char cMode, const QString & szMask, bool bAdd, const QString & szSetBy, unsigned int uSetAt); /** * \brief Returns the time of the last received WHO reply @@ -428,76 +420,22 @@ public: void setSentWhoRequest(){ m_iStateFlags |= KVI_CHANNEL_STATE_SENTWHOREQUEST; }; /** - * \brief Returns true if we have sent the invite list request + * \brief Returns true if we have sent a list request for a specific channel mode * \return bool */ - bool sentInviteListRequest(){ return (m_iStateFlags & KVI_CHANNEL_STATE_SENTINVITELISTREQUEST); }; + bool sentListRequest(char cMode){ return m_szSentModeRequests.contains(cMode); }; /** - * \brief Sets the invite request flag + * \brief Sets the "sent request" flag for a specific channel mode * \return void */ - void setSentInviteListRequest(){ m_iStateFlags |= KVI_CHANNEL_STATE_SENTINVITELISTREQUEST; }; + void setSentListRequest(char cMode){ m_szSentModeRequests.append(cMode); }; /** - * \brief Clears the invite request flag + * \brief Clears the "sent request" flag for a specific chanel mode * \return void */ - void setInviteListDone(){ m_iStateFlags ^= KVI_CHANNEL_STATE_SENTINVITELISTREQUEST; }; - - /** - * \brief Returns true if we have sent the ban list request - * \return bool - */ - bool sentBanListRequest(){ return (m_iStateFlags & KVI_CHANNEL_STATE_SENTBANLISTREQUEST); }; - - /** - * \brief Sets the ban request flag - * \return void - */ - void setSentBanListRequest(){ m_iStateFlags |= KVI_CHANNEL_STATE_SENTBANLISTREQUEST; }; - - /** - * \brief Clears the ban request flag - * \return void - */ - void setBanListDone(){ m_iStateFlags ^= KVI_CHANNEL_STATE_SENTBANLISTREQUEST; }; - - /** - * \brief Returns true if we have sent the ban exception list request - * \return bool - */ - bool sentBanExceptionListRequest(){ return (m_iStateFlags & KVI_CHANNEL_STATE_SENTBANEXCEPTIONLISTREQUEST); }; - - /** - * \brief Sets the ban exception request flag - * \return void - */ - void setSentBanExceptionListRequest(){ m_iStateFlags |= KVI_CHANNEL_STATE_SENTBANEXCEPTIONLISTREQUEST; }; - - /** - * \brief Clears the ban exception request flag - * \return void - */ - void setBanExceptionListDone(){ m_iStateFlags ^= KVI_CHANNEL_STATE_SENTBANEXCEPTIONLISTREQUEST; }; - - /** - * \brief Returns true if we have sent the quiet ban list request - * \return bool - */ - bool sentQuietBanListRequest(){ return (m_iStateFlags & KVI_CHANNEL_STATE_SENTQUIETBANLISTREQUEST); }; - - /** - * \brief Sets the quiet ban request flag - * \return void - */ - void setSentQuietBanListRequest(){ m_iStateFlags |= KVI_CHANNEL_STATE_SENTQUIETBANLISTREQUEST; }; - - /** - * \brief Clears the quiet ban request flag - * \return void - */ - void setQuietBanListDone(){ m_iStateFlags ^= KVI_CHANNEL_STATE_SENTQUIETBANLISTREQUEST; }; + void setListRequestDone(char cMode){ m_szSentModeRequests.remove(cMode); checkChannelSync(); }; /** * \brief Returns true if the channel has all names @@ -515,13 +453,7 @@ public: * \brief Returns true if the channel has an invite list * \return bool */ - bool hasInviteList(){ return (m_iStateFlags & KVI_CHANNEL_STATE_HAVEINVITELIST); checkChannelSync(); }; - - /** - * \brief Sets the existance of the invite list - * \return void - */ - void setHasInviteList(){ m_iStateFlags |= KVI_CHANNEL_STATE_HAVEINVITELIST; }; + bool hasInviteList(){ return m_pModeLists.contains('I'); }; /** * \brief Returns true if the channel has a WHO list @@ -539,37 +471,19 @@ public: * \brief Returns true if the channel has a ban list * \return bool */ - bool hasBanList(){ return (m_iStateFlags & KVI_CHANNEL_STATE_HAVEBANLIST); }; - - /** - * \brief Sets the existance of the ban list - * \return void - */ - void setHasBanList(){ m_iStateFlags |= KVI_CHANNEL_STATE_HAVEBANLIST; checkChannelSync(); }; + bool hasBanList(){ return m_pModeLists.contains('b'); }; /** * \brief Returns true if the channel has a ban exception list * \return bool */ - bool hasBanExceptionList(){ return (m_iStateFlags & KVI_CHANNEL_STATE_HAVEBANEXCEPTIONLIST); }; - - /** - * \brief Sets the existance of the ban exception list - * \return void - */ - void setHasBanExceptionList(){ m_iStateFlags |= KVI_CHANNEL_STATE_HAVEBANEXCEPTIONLIST; checkChannelSync(); }; + bool hasBanExceptionList(){ return m_pModeLists.contains('e'); }; /** * \brief Returns true if the channel has a quiet ban list * \return bool */ - bool hasQuietBanList(){ return (m_iStateFlags & KVI_CHANNEL_STATE_HAVEQUIETBANLIST); }; - - /** - * \brief Sets the existance of the quiet ban list - * \return void - */ - void setHasQuietBanList(){ m_iStateFlags |= KVI_CHANNEL_STATE_HAVEQUIETBANLIST; checkChannelSync(); }; + bool hasQuietBanList(){ return m_pModeLists.contains('q'); }; /** * \brief Returns true if the channel has to be closed on part @@ -1009,6 +923,12 @@ public: * \return QByteArray */ QByteArray loadLogFile(const QString & szFileName, bool bGzip); + + /** + * \brief Gets the KviIrcConnectionServerInfo structure associated to the current connection + * \return KviIrcConnectionServerInfo* + */ + KviIrcConnectionServerInfo * serverInfo(); protected: /** * \brief Filters the events @@ -1071,17 +991,6 @@ protected: virtual void triggerCreationEvents(); /** - * \brief Called when we toggle bans, quiet bans, exceptions or invites editor - * \param ppEd The mask editor - * \param ppBtn The toolpage button - * \param l The masks list - * \param cFlag The type of flag - * \param pcEdName Tee editor name - * \return void - */ - void toggleEditor(KviMaskEditor ** ppEd, KviWindowToolPageButton ** ppBtn, KviPointerList<KviMaskEntry> * l, char cFlag, const char * pcEdName); - - /** * \brief Called when someone sets a mask in the channel's lists * \param szMask The mask set * \param bAdd Whether to add or remove the mask @@ -1148,28 +1057,10 @@ private slots: void toggleListView(); /** - * \brief Toggles the ban editor - * \return void - */ - void toggleBanEditor(); - - /** - * \brief Toggles the ban exception editor - * \return void - */ - void toggleBanExceptionEditor(); - - /** - * \brief Toggles the invite editor - * \return void - */ - void toggleInviteEditor(); - - /** - * \brief Toggles the quiet ban editor + * \brief Toggles a list mode editor * \return void */ - void toggleQuietBanEditor(); + void toggleListModeEditor(); /** * \brief Toggles the mode editor diff --git a/src/kvirc/ui/kvi_maskeditor.cpp b/src/kvirc/ui/kvi_maskeditor.cpp index 2294bea77..a3ba78da2 100644 --- a/src/kvirc/ui/kvi_maskeditor.cpp +++ b/src/kvirc/ui/kvi_maskeditor.cpp @@ -28,6 +28,7 @@ #include "kvi_iconmanager.h" #include "kvi_qstring.h" #include "kvi_channel.h" +#include "kvi_ircconnectionserverinfo.h" #include "kvi_ircconnectionuserinfo.h" #include "kvi_toolwindows_container.h" #include "kvi_channel.h" @@ -123,60 +124,56 @@ void KviMaskInputDialog::accept() QDialog::accept(); } -KviMaskEditor::KviMaskEditor(QWidget * par,KviWindowToolPageButton* button,KviPointerList<KviMaskEntry> * maskList,char flag,const char *) +KviMaskEditor::KviMaskEditor(QWidget * par,KviChannel * pChannel,KviWindowToolPageButton* button,KviPointerList<KviMaskEntry> * maskList,char cMode,const char *name) : KviWindowToolWidget(par,button) { + setObjectName(name); bool isEnabled=1; - - QObject * w = parent(); - while(w) + m_pChannel = pChannel; + if(m_pChannel) { - if(w->inherits("KviChannel")) - { - KviChannel *chan = ((KviChannel *)w); - if(!( chan->isMeHalfOp() || chan->isMeOp() || chan->isMeChanOwner() || chan->isMeChanAdmin() ) ) - isEnabled=0; - break; - } - w = w->parent(); + if(!( m_pChannel->isMeHalfOp() || + m_pChannel->isMeOp() || + m_pChannel->isMeChanOwner() || + m_pChannel->isMeChanAdmin() ) + ) isEnabled=0; } setFocusPolicy(Qt::ClickFocus); QGridLayout *g = new QGridLayout(this); - m_cFlag = flag; + m_cFlag = cMode; - QString txt; - switch(flag) + KviIrcConnectionServerInfo * pServerInfo = 0; + QString szDescription = ""; + if(m_pChannel) + pServerInfo = m_pChannel->serverInfo(); + if(pServerInfo) + szDescription = pServerInfo->getChannelModeDescription(cMode); + if(szDescription.isEmpty()) + szDescription = __tr2qs("Mode \"%1\" Masks").arg(cMode); + switch(cMode) { case 'b': - txt = __tr2qs("Active Bans"); m_iIconId = KVI_SMALLICON_BAN; - break; - case 'I': - txt = __tr2qs("Active Invite Exceptions"); - m_iIconId = KVI_SMALLICON_INVITEEXCEPT; - break; + break; case 'e': - txt = __tr2qs("Active Ban Exceptions"); m_iIconId = KVI_SMALLICON_BANEXCEPT; - break; - case 'q': - txt = __tr2qs("Active Quiet Bans"); - m_iIconId = KVI_SMALLICON_BAN; - break; + break; + case 'I': + m_iIconId = KVI_SMALLICON_INVITEEXCEPT; + break; default: - txt = "?"; - m_iIconId = KVI_SMALLICON_UNHANDLED; - break; + m_iIconId = KVI_SMALLICON_BAN; + break; } QLabel * l = new QLabel("",this); l->setPixmap(*(g_pIconManager->getSmallIcon(m_iIconId))); g->addWidget(l,0,0); - l = new QLabel(txt,this); + l = new QLabel(szDescription,this); g->addWidget(l,0,1); KviTalHBox * hb = new KviTalHBox(this); @@ -274,20 +271,18 @@ void KviMaskEditor::removeClicked() void KviMaskEditor::addClicked() { - QObject * w = parent(); - while(w) + if(m_pChannel) { - if(w->inherits("KviChannel")) + if(m_pChannel->isMeHalfOp() || + m_pChannel->isMeOp() || + m_pChannel->isMeChanAdmin() || + m_pChannel->isMeChanOwner() || + m_pChannel->connection()->userInfo()->hasUserMode('o') || + m_pChannel->connection()->userInfo()->hasUserMode('O')) { - KviChannel *chan = ((KviChannel *)w); - if(chan->isMeHalfOp() || chan->isMeOp() || chan->isMeChanAdmin() || chan->isMeChanOwner() || chan->connection()->userInfo()->hasUserMode('o') || chan->connection()->userInfo()->hasUserMode('O')) - { - KviMaskInputDialog* pDialog=new KviMaskInputDialog("",this,chan); - pDialog->show(); - } - break; + KviMaskInputDialog* pDialog=new KviMaskInputDialog("",this,m_pChannel); + pDialog->show(); } - w = w->parent(); } } @@ -324,22 +319,17 @@ void KviMaskEditor::clear() void KviMaskEditor::itemDoubleClicked( QTreeWidgetItem * pItem, int ) { - if(pItem) + if(pItem && m_pChannel) { - QObject * w = parent(); - while(w) + if(m_pChannel->isMeHalfOp() || + m_pChannel->isMeOp() || + m_pChannel->isMeChanAdmin() || + m_pChannel->isMeChanOwner() || + m_pChannel->connection()->userInfo()->hasUserMode('o') || + m_pChannel->connection()->userInfo()->hasUserMode('O')) { - if(w->inherits("KviChannel")) - { - KviChannel *chan = ((KviChannel *)w); - if(chan->isMeHalfOp() || chan->isMeOp() || chan->isMeChanAdmin() || chan->isMeChanOwner() || chan->connection()->userInfo()->hasUserMode('o') || chan->connection()->userInfo()->hasUserMode('O')) - { - KviMaskInputDialog* pDialog=new KviMaskInputDialog(pItem->text(0),this,chan); - pDialog->show(); - } - break; - } - w = w->parent(); + KviMaskInputDialog* pDialog=new KviMaskInputDialog(pItem->text(0),this,m_pChannel); + pDialog->show(); } } } diff --git a/src/kvirc/ui/kvi_maskeditor.h b/src/kvirc/ui/kvi_maskeditor.h index b330bf2a8..cd986f57a 100644 --- a/src/kvirc/ui/kvi_maskeditor.h +++ b/src/kvirc/ui/kvi_maskeditor.h @@ -95,10 +95,11 @@ class KVIRC_API KviMaskEditor : public KviWindowToolWidget { Q_OBJECT public: - KviMaskEditor(QWidget * par,KviWindowToolPageButton* button,KviPointerList<KviMaskEntry> * maskList, - char flag,const char * nam); + KviMaskEditor(QWidget * par,KviChannel * pChannel, KviWindowToolPageButton* button,KviPointerList<KviMaskEntry> * maskList, + char cMode,const char * name); ~KviMaskEditor(); protected: + KviChannel * m_pChannel; QTreeWidget * m_pMaskBox; QPushButton * m_pRemoveMask; QPushButton * m_pAddButton; diff --git a/src/kvirc/ui/kvi_modeeditor.cpp b/src/kvirc/ui/kvi_modeeditor.cpp index 0ecb8c44a..738d2d2f5 100644 --- a/src/kvirc/ui/kvi_modeeditor.cpp +++ b/src/kvirc/ui/kvi_modeeditor.cpp @@ -148,7 +148,8 @@ KviModeEditor::KviModeEditor(QWidget * par,KviWindowToolPageButton* button,const } // third, check if the we have any info about other modes supported by the server - KviIrcConnectionServerInfo * pServerInfo = getServerInfo(); + KviIrcConnectionServerInfo * pServerInfo = 0; + if(m_pChannel) pServerInfo = m_pChannel->serverInfo(); if(!pServerInfo) { g->setRowStretch(++iRow,1); @@ -320,7 +321,8 @@ void KviModeEditor::commit() // now flush out mode changes int iModesPerLine=3; // a good default - KviIrcConnectionServerInfo * pServerInfo = getServerInfo(); + KviIrcConnectionServerInfo * pServerInfo = 0; + if(m_pChannel) pServerInfo = m_pChannel->serverInfo(); if(pServerInfo) { iModesPerLine = pServerInfo->maxModeChanges(); @@ -407,17 +409,10 @@ void KviModeEditor::commit() emit done(); } -inline KviIrcConnectionServerInfo * KviModeEditor::getServerInfo() -{ - if(!m_pChannel) return 0; - if(!m_pChannel->console()) return 0; - if(!m_pChannel->console()->connection()) return 0; - return m_pChannel->console()->connection()->serverInfo(); -} - inline const QString * KviModeEditor::getModeDescription(char cMode) { - KviIrcConnectionServerInfo * pServerInfo = getServerInfo(); + if(!m_pChannel) return 0; + KviIrcConnectionServerInfo * pServerInfo = m_pChannel->serverInfo(); if(pServerInfo) return &(pServerInfo->getChannelModeDescription(cMode)); return 0; //safe, as will be used with KviQString::sprintf("%Q", ..); @@ -425,7 +420,8 @@ inline const QString * KviModeEditor::getModeDescription(char cMode) inline bool KviModeEditor::modeNeedsParameterOnlyWhenSet(char cMode) { - KviIrcConnectionServerInfo * pServerInfo = getServerInfo(); + if(!m_pChannel) return 0; + KviIrcConnectionServerInfo * pServerInfo = m_pChannel->serverInfo(); if(pServerInfo) return pServerInfo->supportedParameterWhenSetModes().contains(cMode); return false; diff --git a/src/kvirc/ui/kvi_modeeditor.h b/src/kvirc/ui/kvi_modeeditor.h index 34007f533..4b9f12d06 100644 --- a/src/kvirc/ui/kvi_modeeditor.h +++ b/src/kvirc/ui/kvi_modeeditor.h @@ -54,7 +54,6 @@ protected: // fields protected: const QString * getModeDescription(char cMode); bool modeNeedsParameterOnlyWhenSet(char cMode); - KviIrcConnectionServerInfo * getServerInfo(); signals: void setMode(QString & szMode); void done(); diff --git a/src/kvirc/ui/kvi_modew.cpp b/src/kvirc/ui/kvi_modew.cpp index ddfdf6b9c..847dfde57 100644 --- a/src/kvirc/ui/kvi_modew.cpp +++ b/src/kvirc/ui/kvi_modew.cpp @@ -181,7 +181,8 @@ void KviModeWidget::editorReturnPressed() // now flush out mode changes int iModesPerLine=3; // a good default - KviIrcConnectionServerInfo * pServerInfo = getServerInfo(); + KviIrcConnectionServerInfo * pServerInfo = 0; + if(m_pChannel) pServerInfo = m_pChannel->serverInfo(); if(pServerInfo) { iModesPerLine = pServerInfo->maxModeChanges(); @@ -268,17 +269,10 @@ void KviModeWidget::editorReturnPressed() reset(); } -inline KviIrcConnectionServerInfo * KviModeWidget::getServerInfo() -{ - if(!m_pChannel) return 0; - if(!m_pChannel->console()) return 0; - if(!m_pChannel->console()->connection()) return 0; - return m_pChannel->console()->connection()->serverInfo(); -} - inline bool KviModeWidget::modeNeedsParameterOnlyWhenSet(char cMode) { - KviIrcConnectionServerInfo * pServerInfo = getServerInfo(); + KviIrcConnectionServerInfo * pServerInfo = 0; + if(m_pChannel) pServerInfo = m_pChannel->serverInfo(); if(pServerInfo) return pServerInfo->supportedParameterWhenSetModes().contains(cMode); return false; diff --git a/src/kvirc/ui/kvi_modew.h b/src/kvirc/ui/kvi_modew.h index 62cfde7f8..d7dcf97a8 100644 --- a/src/kvirc/ui/kvi_modew.h +++ b/src/kvirc/ui/kvi_modew.h @@ -45,7 +45,6 @@ protected: void mouseDoubleClickEvent(QMouseEvent * e); void keyReleaseEvent (QKeyEvent * e); bool modeNeedsParameterOnlyWhenSet(char cMode); - KviIrcConnectionServerInfo * getServerInfo(); public slots: void editorReturnPressed(); signals: diff --git a/src/modules/chan/libkvichan.cpp b/src/modules/chan/libkvichan.cpp index 9f8acbae7..11308d33c 100644 --- a/src/modules/chan/libkvichan.cpp +++ b/src/modules/chan/libkvichan.cpp @@ -564,6 +564,41 @@ static bool chan_kvs_fnc_invitecount(KviKvsModuleFunctionCall * c) return true; } + +/* + @doc: chan.maskcount + @type: + function + @title: + $chan.maskcount + @short: + Returns the number of entries in the mask list for a channel mode + @syntax: + <integer> $chan.maskcount(<mode:char>) + <integer> $chan.maskcount(<mode:char>,[window_id:string]) + @description: + The first form returns the number of entries in the ban list of the current channel (assuming that the current window + is a channel at all). If the current window is not a channel, a warning is printed + and 0 is returned.[br] + The second form returns the number entries in the ban list of the channel specified by <window_id>.[br] + The number of list entries is returned if it is known form at the call time: this means that + if the channel is not synchronized with the server (as just after the join, for example) + you might get a number that is actually smaller.[br] +*/ +static bool chan_kvs_fnc_maskcount(KviKvsModuleFunctionCall * c) +{ + QString szId, szMode; + KVSM_PARAMETERS_BEGIN(c) + KVSM_PARAMETER("mode",KVS_PT_NONEMPTYSTRING,0,szMode) + KVSM_PARAMETER("window id",KVS_PT_STRING,KVS_PF_OPTIONAL,szId) + KVSM_PARAMETERS_END(c) + + char cMode = szMode.at(0).unicode(); + KviChannel * ch = chan_kvs_find_channel(c,szId); + if (ch) c->returnValue()->setInteger(ch->maskCount(cMode)); + return true; +} + /* @doc: chan.ison @type: @@ -1193,6 +1228,10 @@ next_item: Returns an array of ban masks set ont the channel identified by [window_id].[br] If [window_id] is empty, the current window is used.[br] If the window designated by [window_id] is not a channel a warning is printed and an empty array is returned.[br] + @seealso: + [fnc]$chan.masklist[/fnc] + [fnc]$chan.invitelist[/fnc] + [fnc]$chan.banexceptionlist[/fnc] */ static bool chan_kvs_fnc_banlist(KviKvsModuleFunctionCall * c) { @@ -1211,6 +1250,7 @@ static bool chan_kvs_fnc_banlist(KviKvsModuleFunctionCall * c) int idx = 0; KviPointerList<KviMaskEntry> * l = ch->banList(); + if(!l) return true; for(KviMaskEntry * e = l->first();e;e = l->next()) { @@ -1235,6 +1275,10 @@ static bool chan_kvs_fnc_banlist(KviKvsModuleFunctionCall * c) Returns an array of ban exception masks set ont the channel identified by [window_id].[br] If [window_id] is empty, the current window is used.[br] If the window designated by [window_id] is not a channel a warning is printed and an empty array is returned.[br] + @seealso: + [fnc]$chan.banlist[/fnc] + [fnc]$chan.invitelist[/fnc] + [fnc]$chan.masklist[/fnc] */ static bool chan_kvs_fnc_banexceptionlist(KviKvsModuleFunctionCall * c) { @@ -1253,6 +1297,7 @@ static bool chan_kvs_fnc_banexceptionlist(KviKvsModuleFunctionCall * c) int idx = 0; KviPointerList<KviMaskEntry> * l = ch->banExceptionList(); + if(!l) return true; for(KviMaskEntry * e = l->first();e;e = l->next()) { @@ -1277,6 +1322,10 @@ static bool chan_kvs_fnc_banexceptionlist(KviKvsModuleFunctionCall * c) Returns an array of invite masks set ont the channel identified by [window_id].[br] If [window_id] is empty, the current window is used.[br] If the window designated by [window_id] is not a channel a warning is printed and an empty array is returned.[br] + @seealso: + [fnc]$chan.banlist[/fnc] + [fnc]$chan.masklist[/fnc] + [fnc]$chan.banexceptionlist[/fnc] */ static bool chan_kvs_fnc_invitelist(KviKvsModuleFunctionCall * c) { @@ -1295,6 +1344,57 @@ static bool chan_kvs_fnc_invitelist(KviKvsModuleFunctionCall * c) int idx = 0; KviPointerList<KviMaskEntry> * l = ch->inviteList(); + if(!l) return true; + + for(KviMaskEntry * e = l->first();e;e = l->next()) + { + pArray->set(idx,new KviKvsVariant(e->szMask)); + idx++; + } + + return true; +} + +/* + @doc: chan.masklist + @type: + function + @title: + $chan.masklist + @short: + Returns an array of masks for a channel mode + @syntax: + $chan.masklist(<mode:char>[,window_id]) + @description: + Returns an array of masks set for the channel mode <mode> on the channel identified by [window_id].[br] + If [window_id] is empty, the current window is used.[br] + If the window designated by [window_id] is not a channel a warning is printed and an empty array is returned.[br] + @seealso: + [fnc]$chan.banlist[/fnc] + [fnc]$chan.invitelist[/fnc] + [fnc]$chan.banexceptionlist[/fnc] +*/ +static bool chan_kvs_fnc_masklist(KviKvsModuleFunctionCall * c) +{ + QString szWinId,szMask,szMode; + KVSM_PARAMETERS_BEGIN(c) + KVSM_PARAMETER("mode",KVS_PT_NONEMPTYSTRING,0,szMode) + KVSM_PARAMETER("window id",KVS_PT_STRING,KVS_PF_OPTIONAL,szWinId) + KVSM_PARAMETERS_END(c) + + char cMode = szMode.at(0).unicode(); + + KviKvsArray * pArray = new KviKvsArray(); + c->returnValue()->setArray(pArray); + + KviChannel * ch = chan_kvs_find_channel(c,szWinId); + + if(!ch)return true; + + int idx = 0; + + KviPointerList<KviMaskEntry> * l = ch->modeMasks(cMode); + if(!l) return true; for(KviMaskEntry * e = l->first();e;e = l->next()) { @@ -1339,6 +1439,11 @@ static bool chan_kvs_fnc_matchban(KviKvsModuleFunctionCall * c) } KviPointerList<KviMaskEntry> * l = ch->banList(); + if(!l) + { + c->returnValue()->setNothing(); + return true; + } for(KviMaskEntry * e = l->first();e;e = l->next()) { @@ -1387,6 +1492,11 @@ static bool chan_kvs_fnc_matchbanexception(KviKvsModuleFunctionCall * c) } KviPointerList<KviMaskEntry> * l = ch->banExceptionList(); + if(!l) + { + c->returnValue()->setNothing(); + return true; + } for(KviMaskEntry * e = l->first();e;e = l->next()) { @@ -1435,6 +1545,11 @@ static bool chan_kvs_fnc_matchinvite(KviKvsModuleFunctionCall * c) } KviPointerList<KviMaskEntry> * l = ch->inviteList(); + if(!l) + { + c->returnValue()->setNothing(); + return true; + } for(KviMaskEntry * e = l->first();e;e = l->next()) { @@ -1460,8 +1575,11 @@ static bool chan_kvs_fnc_matchinvite(KviKvsModuleFunctionCall * c) @syntax: <string> $chan.matchqban([window_id],<complete_mask>) @description: - Some networks use +q channel mode to set "mute bans". - When an user mask matches such a ban, he won't be able to send messages to the channel. + Warning: this function is network-specific, makes some (bad) assumptions about a non-standard channel mode and + will probably be dropped in a future version.[br] + Use [fnc]$chan.matchmask[/fnc] instead.[br] + Some networks use +q channel mode to set "mute bans".[br] + When an user mask matches such a ban, he won't be able to send messages to the channel.[br] The "mute bans" masks will be inserted in the normal channel bans list, with a percent sign % prepended This function returns the "mute ban" mask that matches <complete_mask> on channel identified by [window_id].[br] If no ban mask matches <complete_mask> an empty string is returned.[br] @@ -1487,6 +1605,71 @@ static bool chan_kvs_fnc_matchqban(KviKvsModuleFunctionCall * c) } KviPointerList<KviMaskEntry> * l = ch->banList(); + if(!l) + { + c->returnValue()->setNothing(); + return true; + } + + for(KviMaskEntry * e = l->first();e;e = l->next()) + { + if(KviQString::matchString(e->szMask,szMask)) + { + c->returnValue()->setString(e->szMask); + return true; + } + } + + c->returnValue()->setNothing(); + return true; +} + +/* + @doc: chan.matchmask + @type: + function + @title: + $chan.matchmask + @short: + Matches a mask agains the channel list for a specific mode + @syntax: + <string> $chan.matchmask(<mode:char>,<complete_mask:string>[,window_id]) + @description: + + Some networks use +q channel mode to set "mute bans".[br] + When an user mask matches such a ban, he won't be able to send messages to the channel.[br] + The "mute bans" masks will be inserted in the normal channel bans list, with a percent sign % prepended + This function returns the "mute ban" mask that matches <complete_mask> on channel identified by [window_id].[br] + If no ban mask matches <complete_mask> an empty string is returned.[br] + If [window_id] is empty, the current window is used.[br] + If the window designated by [window_id] is not a channel a warning is printed and an empty string is returned.[br] + This function is useful to determine if a "mute ban" set on the channel matches an user.[br] +*/ +static bool chan_kvs_fnc_matchmask(KviKvsModuleFunctionCall * c) +{ + QString szWinId,szMask,szMode; + + KVSM_PARAMETERS_BEGIN(c) + KVSM_PARAMETER("mode",KVS_PT_NONEMPTYSTRING,0,szMode) + KVSM_PARAMETER("mask",KVS_PT_STRING,0,szMask) + KVSM_PARAMETER("window id",KVS_PT_STRING,KVS_PF_OPTIONAL,szWinId) + KVSM_PARAMETERS_END(c) + + char cMode = szMode.at(0).unicode(); + KviChannel * ch = chan_kvs_find_channel(c,szWinId); + + if(!ch) + { + c->returnValue()->setNothing(); + return true; + } + + KviPointerList<KviMaskEntry> * l = ch->modeMasks(cMode); + if(!l) + { + c->returnValue()->setNothing(); + return true; + } for(KviMaskEntry * e = l->first();e;e = l->next()) { @@ -1675,10 +1858,13 @@ static bool chan_module_init(KviModule * m) KVSM_REGISTER_FUNCTION(m,"isvoice",chan_kvs_fnc_isvoice); KVSM_REGISTER_FUNCTION(m,"key",chan_kvs_fnc_key); KVSM_REGISTER_FUNCTION(m,"limit",chan_kvs_fnc_limit); + KVSM_REGISTER_FUNCTION(m,"masklist",chan_kvs_fnc_masklist); + KVSM_REGISTER_FUNCTION(m,"maskcount",chan_kvs_fnc_maskcount); KVSM_REGISTER_FUNCTION(m,"matchban",chan_kvs_fnc_matchban); KVSM_REGISTER_FUNCTION(m,"matchqban",chan_kvs_fnc_matchqban); KVSM_REGISTER_FUNCTION(m,"matchbanexception",chan_kvs_fnc_matchbanexception); KVSM_REGISTER_FUNCTION(m,"matchinvite",chan_kvs_fnc_matchinvite); + KVSM_REGISTER_FUNCTION(m,"matchmask",chan_kvs_fnc_matchmask); KVSM_REGISTER_FUNCTION(m,"mode",chan_kvs_fnc_mode); KVSM_REGISTER_FUNCTION(m,"modeParam",chan_kvs_fnc_modeParam); KVSM_REGISTER_FUNCTION(m,"name",chan_kvs_fnc_name); |
