X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fignorelistmanager.cpp;h=81382b2682790384b474fc8b4a5c111ab08dc5d4;hp=dfd9ae2db03b1b747db4a53cb67ca5036b801ddd;hb=ac374ec32612798c230d54665f6bce7faf416602;hpb=602816ed2eecfe077e270a5d948a9827119fdcc5 diff --git a/src/common/ignorelistmanager.cpp b/src/common/ignorelistmanager.cpp index dfd9ae2d..81382b26 100644 --- a/src/common/ignorelistmanager.cpp +++ b/src/common/ignorelistmanager.cpp @@ -178,3 +178,28 @@ void IgnoreListManager::toggleIgnoreRule(const QString &ignoreRule) { _ignoreList[idx].isActive = !_ignoreList[idx].isActive; SYNC(ARG(ignoreRule)) } + +bool IgnoreListManager::ctcpMatch(const QString sender, const QString &network, const QString &type) { + foreach(IgnoreListItem item, _ignoreList) { + if(!item.isActive) + continue; + if(item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network))) { + QString sender_; + QStringList types = item.ignoreRule.split(QRegExp("\\s+"), QString::SkipEmptyParts); + + sender_ = types.takeAt(0); + + QRegExp ruleRx = QRegExp(sender_); + ruleRx.setCaseSensitivity(Qt::CaseInsensitive); + if(!item.isRegEx) + ruleRx.setPatternSyntax(QRegExp::Wildcard); + if((!item.isRegEx && ruleRx.exactMatch(sender)) || + (item.isRegEx && ruleRx.indexIn(sender) != -1)) { + + if(types.isEmpty() || types.contains(type, Qt::CaseInsensitive)) + return true; + } + } + } + return false; +}