clientbufferviewconfig.cpp
clientbufferviewmanager.cpp
clientidentity.cpp
+ clientignorelistmanager.cpp
clientirclisthelper.cpp
clientsettings.cpp
clientsyncer.cpp
clientbufferviewmanager.h
clientcoreinfo.h
clientidentity.h
+ clientignorelistmanager.h
clientirclisthelper.h
clientuserinputhandler.h
clientsyncer.h
#include "clientbufferviewmanager.h"
#include "clientirclisthelper.h"
#include "clientidentity.h"
+#include "clientignorelistmanager.h"
#include "clientuserinputhandler.h"
#include "ircchannel.h"
#include "ircuser.h"
_ircListHelper(new ClientIrcListHelper(this)),
_inputHandler(0),
_networkConfig(0),
+ _ignoreListManager(0),
_messageModel(0),
_messageProcessor(0),
_connectedToCore(false),
_networkConfig = new NetworkConfig("GlobalNetworkConfig", this);
signalProxy()->synchronize(networkConfig());
+ // create IgnoreListManager
+ Q_ASSERT(!_ignoreListManager);
+ _ignoreListManager = new ClientIgnoreListManager(this);
+ signalProxy()->synchronize(ignoreListManager());
+
// trigger backlog request once all active bufferviews are initialized
connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
_aliasManager = 0;
}
+ if(_ignoreListManager) {
+ _ignoreListManager->deleteLater();
+ _ignoreListManager = 0;
+ }
// we probably don't want to save pending input for reconnect
_userInputBuffer.clear();
emit instance()->logUpdated(msgString);
}
}
-
class ClientAliasManager;
class ClientBacklogManager;
class ClientBufferViewManager;
+class ClientIgnoreListManager;
class ClientIrcListHelper;
class ClientSyncer;
class ClientUserInputHandler;
static inline BufferViewOverlay *bufferViewOverlay() { return instance()->_bufferViewOverlay; }
static inline ClientUserInputHandler *inputHandler() { return instance()->_inputHandler; }
static inline NetworkConfig *networkConfig() { return instance()->_networkConfig; }
+ static inline ClientIgnoreListManager *ignoreListManager() { return instance()->_ignoreListManager; }
static AccountId currentCoreAccount();
ClientIrcListHelper *_ircListHelper;
ClientUserInputHandler *_inputHandler;
NetworkConfig *_networkConfig;
+ ClientIgnoreListManager *_ignoreListManager;
MessageModel *_messageModel;
AbstractMessageProcessor *_messageProcessor;
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-09 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "clientignorelistmanager.h"
+
+ClientIgnoreListManager::ClientIgnoreListManager(QObject *parent)
+ : IgnoreListManager(parent)
+{
+ connect(this, SIGNAL(updated(const QVariantMap&)), this, SLOT(ignoreListUpdated(const QVariantMap&)));
+}
+
+void ClientIgnoreListManager::ignoreListUpdated(const QVariantMap &newMap) {
+ if(newMap != initIgnoreList())
+ emit ignoreListChanged();
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-09 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef CLIENTIGNORELISTMANAGER_H
+#define CLIENTIGNORELISTMANAGER_H
+
+#include "ignorelistmanager.h"
+
+class ClientIgnoreListManager : public IgnoreListManager
+{
+ Q_OBJECT
+
+public:
+ explicit ClientIgnoreListManager(QObject *parent = 0);
+ inline virtual const QMetaObject *syncMetaObject() const { return &IgnoreListManager::staticMetaObject; }
+
+signals:
+ void ignoreListChanged();
+
+private slots:
+ void ignoreListUpdated(const QVariantMap &newMap);
+};
+
+#endif // CLIENTIGNORELISTMANAGER_H
#include "buffermodel.h"
#include "messagemodel.h"
#include "networkmodel.h"
+#include "clientignorelistmanager.h"
MessageFilter::MessageFilter(QAbstractItemModel *source, QObject *parent)
: QSortFilterProxyModel(parent),
if(myNetworkId != msgNetworkId)
return false;
+ // ignorelist handling
+ const MessageModelItem *item = const_cast<const MessageModel*>(static_cast<MessageModel*>(sourceModel()))->messageItemAt(sourceRow);
+ // only match if message is not flagged as server msg
+ if(!(item->message().flags() & Message::ServerMsg) &&
+ Client::ignoreListManager()->match(item->message(), Client::networkModel()->networkName(item->bufferId())))
+ return false;
if(flags & Message::Redirected) {
int redirectionTarget = 0;
void messageTypeFilterChanged();
void messageRedirectionChanged();
void requestBacklog();
+ // redefined as public slot
+ void invalidateFilter() { QSortFilterProxyModel::invalidateFilter(); }
protected:
QString bufferName() const { return Client::networkModel()->bufferName(singleBufferId()); }
void clear();
+ virtual const MessageModelItem *messageItemAt(int i) const = 0;
+
public slots:
void requestBacklog(BufferId bufferId);
void messagesReceived(BufferId bufferId, int count);
virtual int messageCount() const = 0;
virtual bool messagesIsEmpty() const = 0;
- virtual const MessageModelItem *messageItemAt(int i) const = 0;
virtual MessageModelItem *messageItemAt(int i) = 0;
virtual const MessageModelItem *firstMessageItem() const= 0;
virtual MessageModelItem *firstMessageItem() = 0;
bufferviewmanager.cpp
cliparser.cpp
identity.cpp
+ ignorelistmanager.cpp
ircchannel.cpp
irclisthelper.cpp
ircuser.cpp
bufferviewmanager.h
coreinfo.h
identity.h
+ ignorelistmanager.h
ircchannel.h
irclisthelper.h
ircuser.h
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-09 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "ignorelistmanager.h"
+
+#include <QDebug>
+#include <QStringList>
+#include <QRegExp>
+
+#include "message.h"
+
+IgnoreListManager &IgnoreListManager::operator=(const IgnoreListManager &other) {
+ if(this == &other)
+ return *this;
+
+ SyncableObject::operator=(other);
+ _ignoreList = other._ignoreList;
+ return *this;
+}
+
+int IgnoreListManager::indexOf(const QString &ignore) const {
+ for(int i = 0; i < _ignoreList.count(); i++) {
+ if(_ignoreList[i].ignoreRule == ignore)
+ return i;
+ }
+ return -1;
+}
+
+QVariantMap IgnoreListManager::initIgnoreList() const {
+ QVariantMap ignoreListMap;
+ QVariantList ignoreTypeList;
+ QStringList ignoreRuleList;
+ QStringList scopeRuleList;
+ QVariantList isRegExList;
+ QVariantList scopeList;
+ QVariantList strictnessList;
+ QVariantList isActiveList;
+
+ for(int i = 0; i < _ignoreList.count(); i++) {
+ ignoreTypeList << _ignoreList[i].type;
+ ignoreRuleList << _ignoreList[i].ignoreRule;
+ scopeRuleList << _ignoreList[i].scopeRule;
+ isRegExList << _ignoreList[i].isRegEx;
+ scopeList << _ignoreList[i].scope;
+ strictnessList << _ignoreList[i].strictness;
+ isActiveList << _ignoreList[i].isActive;
+ }
+
+ ignoreListMap["ignoreType"] = ignoreTypeList;
+ ignoreListMap["ignoreRule"] = ignoreRuleList;
+ ignoreListMap["scopeRule"] = scopeRuleList;
+ ignoreListMap["isRegEx"] = isRegExList;
+ ignoreListMap["scope"] = scopeList;
+ ignoreListMap["strictness"] = strictnessList;
+ ignoreListMap["isActive"] = isActiveList;
+ return ignoreListMap;
+}
+
+void IgnoreListManager::initSetIgnoreList(const QVariantMap &ignoreList) {
+ QVariantList ignoreType = ignoreList["ignoreType"].toList();
+ QStringList ignoreRule = ignoreList["ignoreRule"].toStringList();
+ QStringList scopeRule = ignoreList["scopeRule"].toStringList();
+ QVariantList isRegEx = ignoreList["isRegEx"].toList();
+ QVariantList scope = ignoreList["scope"].toList();
+ QVariantList strictness = ignoreList["strictness"].toList();
+ QVariantList isActive = ignoreList["isActive"].toList();
+
+ int count = ignoreRule.count();
+ if(count != scopeRule.count() || count != isRegEx.count() ||
+ count != scope.count() || count != strictness.count() || count != ignoreType.count() || count != isActive.count()) {
+ qWarning() << "Corrupted IgnoreList settings! (Count missmatch)";
+ return;
+ }
+
+ _ignoreList.clear();
+ for(int i = 0; i < ignoreRule.count(); i++) {
+ _ignoreList << IgnoreListItem(static_cast<IgnoreType>(ignoreType[i].toInt()), ignoreRule[i], isRegEx[i].toBool(),
+ static_cast<StrictnessType>(strictness[i].toInt()), static_cast<ScopeType>(scope[i].toInt()),
+ scopeRule[i], isActive[i].toBool());
+ }
+}
+
+void IgnoreListManager::addIgnoreListItem(const IgnoreListItem &item) {
+ addIgnoreListItem(item.type, item.ignoreRule, item.isRegEx, item.strictness, item.scope, item.scopeRule, item.isActive);
+}
+
+void IgnoreListManager::addIgnoreListItem(IgnoreType type, const QString &ignoreRule, bool isRegEx, StrictnessType strictness,
+ ScopeType scope, const QString &scopeRule, bool isActive) {
+ if(contains(ignoreRule)) {
+ return;
+ }
+
+ _ignoreList << IgnoreListItem(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive);
+
+ emit ignoreAdded(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive);
+}
+
+IgnoreListManager::StrictnessType IgnoreListManager::match(const Message &msg, const QString &network) {
+ if(!(msg.type() & (Message::Plain | Message::Notice | Message::Action)))
+ return UnmatchedStrictness;
+
+ foreach(IgnoreListItem item, _ignoreList) {
+ if(!item.isActive)
+ continue;
+ if(item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network)) ||
+ (item.scope == ChannelScope && scopeMatch(item.scopeRule, msg.bufferInfo().bufferName()))) {
+
+ QString str;
+ if(item.type == MessageIgnore)
+ str = msg.contents();
+ else
+ str = msg.sender();
+
+ QRegExp ruleRx = QRegExp(item.ignoreRule);
+ ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
+ if(!item.isRegEx) {
+ ruleRx.setPatternSyntax(QRegExp::Wildcard);
+ }
+
+// qDebug() << "IgnoreListManager::match: ";
+// qDebug() << "string: " << str;
+// qDebug() << "pattern: " << ruleRx.pattern();
+// qDebug() << "scopeRule: " << item.scopeRule;
+// qDebug() << "now testing";
+ if((!item.isRegEx && ruleRx.exactMatch(str)) ||
+ (item.isRegEx && ruleRx.indexIn(str) != -1)) {
+// qDebug() << "MATCHED!";
+ return item.strictness;
+ }
+ }
+ }
+ return UnmatchedStrictness;
+}
+
+bool IgnoreListManager::scopeMatch(const QString &scopeRule, const QString &string) {
+ foreach(QString rule, scopeRule.split(";")) {
+ QRegExp ruleRx = QRegExp(rule.trimmed());
+ ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
+ ruleRx.setPatternSyntax(QRegExp::Wildcard);
+ if(ruleRx.exactMatch(string)) {
+ return true;
+ }
+ }
+ return false;
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-09 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef IGNORELISTMANAGER_H
+#define IGNORELISTMANAGER_H
+
+#include <QString>
+
+#include "syncableobject.h"
+
+class Message;
+
+class IgnoreListManager : public SyncableObject
+{
+ Q_OBJECT
+public:
+ inline IgnoreListManager(QObject *parent = 0) : SyncableObject(parent) { setAllowClientUpdates(true); }
+ IgnoreListManager &operator=(const IgnoreListManager &other);
+
+ enum IgnoreType {
+ SenderIgnore,
+ MessageIgnore
+ };
+
+ enum StrictnessType {
+ UnmatchedStrictness = 0,
+ SoftStrictness = 1,
+ HardStrictness = 2
+ };
+
+ enum ScopeType {
+ GlobalScope,
+ NetworkScope,
+ ChannelScope,
+ };
+
+ struct IgnoreListItem {
+ IgnoreType type;
+ QString ignoreRule;
+ bool isRegEx;
+ StrictnessType strictness;
+ ScopeType scope;
+ QString scopeRule;
+ bool isActive;
+ IgnoreListItem() {}
+ IgnoreListItem(IgnoreType type_, const QString &ignoreRule_, bool isRegEx_, StrictnessType strictness_,
+ ScopeType scope_, const QString &scopeRule_, bool isActive_)
+ : type(type_), ignoreRule(ignoreRule_), isRegEx(isRegEx_), strictness(strictness_), scope(scope_), scopeRule(scopeRule_), isActive(isActive_) {}
+ bool operator!=(const IgnoreListItem &other) {
+ return (type != other.type ||
+ ignoreRule != other.ignoreRule ||
+ isRegEx != other.isRegEx ||
+ strictness != other.strictness ||
+ scope != other.scope ||
+ scopeRule != other.scopeRule ||
+ isActive != other.isActive);
+ }
+ };
+ typedef QList<IgnoreListItem> IgnoreList;
+
+ int indexOf(const QString &ignore) const;
+ inline bool contains(const QString &ignore) const { return indexOf(ignore) != -1; }
+ inline bool isEmpty() const { return _ignoreList.isEmpty(); }
+ inline int count() const { return _ignoreList.count(); }
+ inline void removeAt(int index) { _ignoreList.removeAt(index); }
+ inline IgnoreListItem &operator[](int i) { return _ignoreList[i]; }
+ inline const IgnoreListItem &operator[](int i) const { return _ignoreList.at(i); }
+ inline const IgnoreList &ignoreList() const { return _ignoreList; }
+
+ //! Check if a message matches the IgnoreRule
+ /** This method checks if a message matches the users ignorelist.
+ * \param msg The Message that should be checked
+ * \param network The networkname the message belongs to
+ * \return UnmatchedStrictness, HardStrictness or SoftStrictness representing the match type
+ */
+ StrictnessType match(const Message &msg, const QString &network = QString());
+
+public slots:
+ virtual QVariantMap initIgnoreList() const;
+ virtual void initSetIgnoreList(const QVariantMap &ignoreList);
+
+ virtual void addIgnoreListItem(IgnoreType type, const QString &ignoreRule, bool isRegEx, StrictnessType strictness,
+ ScopeType scope, const QString &scopeRule, bool isActive);
+ virtual void addIgnoreListItem(const IgnoreListItem &item);
+protected:
+ void setIgnoreList(const QList<IgnoreListItem> &ignoreList) { _ignoreList = ignoreList; }
+
+signals:
+ void ignoreAdded(IgnoreType type, const QString &ignoreRule, bool isRegex, StrictnessType strictness, ScopeType scope, const QVariant &scopeRule, bool isActive);
+
+private:
+ // scopeRule is a ; separated list, string is a network/channel-name
+ bool scopeMatch(const QString &scopeRule, const QString &string);
+ IgnoreList _ignoreList;
+};
+
+#endif // IGNORELISTMANAGER_H
corebufferviewmanager.cpp
corecoreinfo.cpp
coreidentity.cpp
+ coreignorelistmanager.cpp
coreircchannel.cpp
coreirclisthelper.cpp
corenetwork.cpp
corebufferviewmanager.h
corecoreinfo.h
coreidentity.h
+ coreignorelistmanager.h
coreircchannel.h
coreirclisthelper.h
corenetwork.h
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-09 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "coreignorelistmanager.h"
+
+#include "core.h"
+#include "coresession.h"
+
+CoreIgnoreListManager::CoreIgnoreListManager(CoreSession *parent)
+ : IgnoreListManager(parent)
+{
+ CoreSession *session = qobject_cast<CoreSession *>(parent);
+ if(!session) {
+ qWarning() << "CoreIgnoreListManager: unable to load IgnoreList. Parent is not a Coresession!";
+ //loadDefaults();
+ return;
+ }
+
+ initSetIgnoreList(Core::getUserSetting(session->user(), "IgnoreList").toMap());
+ //if(isEmpty())
+ //loadDefaults();
+}
+
+CoreIgnoreListManager::~CoreIgnoreListManager() {
+ CoreSession *session = qobject_cast<CoreSession *>(parent());
+ if(!session) {
+ qWarning() << "CoreIgnoreListManager: unable to save IgnoreList. Parent is not a Coresession!";
+ return;
+ }
+
+ Core::setUserSetting(session->user(), "IgnoreList", initIgnoreList());
+}
+
+//void CoreIgnoreListManager::loadDefaults() {
+// foreach(IgnoreListItem item, IgnoreListManager::defaults()) {
+// addIgnoreListItem(item.ignoreRule, item.isRegEx, item.strictness, item.scope, item.scopeRule);
+// }
+//}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-09 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef COREIGNORELISTMANAGER_H
+#define COREIGNORELISTMANAGER_H
+
+#include "ignorelistmanager.h"
+
+class CoreSession;
+
+class CoreIgnoreListManager : public IgnoreListManager {
+ Q_OBJECT
+
+public:
+ explicit CoreIgnoreListManager(CoreSession *parent);
+ ~CoreIgnoreListManager();
+
+ inline virtual const QMetaObject *syncMetaObject() const { return &IgnoreListManager::staticMetaObject; }
+
+//private:
+// void loadDefaults();
+
+};
+
+#endif //COREIGNORELISTMANAGER_H
#include "util.h"
#include "coreusersettings.h"
#include "logger.h"
+#include "coreignorelistmanager.h"
class ProcessMessagesEvent : public QEvent {
public:
_networkConfig(new CoreNetworkConfig("GlobalNetworkConfig", this)),
_coreInfo(this),
scriptEngine(new QScriptEngine(this)),
- _processMessages(false)
+ _processMessages(false),
+ _ignoreListManager(this)
{
SignalProxy *p = signalProxy();
connect(p, SIGNAL(peerRemoved(QIODevice *)), this, SLOT(removeClient(QIODevice *)));
p->synchronize(ircListHelper());
p->synchronize(networkConfig());
p->synchronize(&_coreInfo);
-
+ p->synchronize(&_ignoreListManager);
// Restore session state
if(restoreState)
restoreSessionState();
}
void CoreSession::processMessages() {
+ QString networkName;
if(_messageQueue.count() == 1) {
const RawMessage &rawMsg = _messageQueue.first();
BufferInfo bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, rawMsg.bufferType, rawMsg.target);
Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags);
- Core::storeMessage(msg);
- emit displayMsg(msg);
+
+ networkName = _networks.value(bufferInfo.networkId())->networkName();
+ // if message is ignored with "HardStrictness" we discard it here
+ if(_ignoreListManager.match(msg, networkName) != IgnoreListManager::HardStrictness) {
+ Core::storeMessage(msg);
+ emit displayMsg(msg);
+ }
} else {
QHash<NetworkId, QHash<QString, BufferInfo> > bufferInfoCache;
MessageList messages;
bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, rawMsg.bufferType, rawMsg.target);
bufferInfoCache[rawMsg.networkId][rawMsg.target] = bufferInfo;
}
- messages << Message(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags);
+
+ Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags);
+ networkName = _networks.value(bufferInfo.networkId())->networkName();
+ // if message is ignored with "HardStrictness" we discard it here
+ if(_ignoreListManager.match(msg, networkName) == IgnoreListManager::HardStrictness)
+ continue;
+ messages << msg;
}
Core::storeMessages(messages);
// FIXME: extend protocol to a displayMessages(MessageList)
#include "corecoreinfo.h"
#include "corealiasmanager.h"
+#include "coreignorelistmanager.h"
#include "message.h"
#include "storage.h"
};
QList<RawMessage> _messageQueue;
bool _processMessages;
+ CoreIgnoreListManager _ignoreListManager;
};
#endif
typedef ChatLineModelItem::Word Word;
typedef ChatLineModelItem::WrapList WrapList;
-
+ virtual inline const MessageModelItem *messageItemAt(int i) const { return &_messageList[i]; }
protected:
// virtual MessageModelItem *createMessageModelItem(const Message &);
virtual inline int messageCount() const { return _messageList.count(); }
virtual inline bool messagesIsEmpty() const { return _messageList.isEmpty(); }
- virtual inline const MessageModelItem *messageItemAt(int i) const { return &_messageList[i]; }
virtual inline MessageModelItem *messageItemAt(int i) { return &_messageList[i]; }
virtual inline const MessageModelItem *firstMessageItem() const { return &_messageList.first(); }
virtual inline MessageModelItem *firstMessageItem() { return &_messageList.first(); }
#include "chatlinemodel.h"
#include "networkmodel.h"
#include "chatviewsettings.h"
+#include "clientignorelistmanager.h"
ChatMonitorFilter::ChatMonitorFilter(MessageModel *model, QObject *parent)
: MessageFilter(model, parent)
&& !_bufferIds.contains(source_index.data(MessageModel::BufferIdRole).value<BufferId>()))
return false;
+ // ignorelist handling
+ const MessageModelItem *item = const_cast<const MessageModel*>(static_cast<MessageModel*>(sourceModel()))->messageItemAt(sourceRow);
+ // only match if message is not flagged as server msg
+ if(!(item->message().flags() & Message::ServerMsg) &&
+ Client::ignoreListManager()->match(item->message(), Client::networkModel()->networkName(item->bufferId())))
+ return false;
return true;
}
foreach (QVariant v, newValue.toList()) {
_bufferIds << v.value<BufferId>();
}
+ invalidate();
}
#include "qtuisettings.h"
#include "settingspagedlg.h"
#include "settingspages/chatmonitorsettingspage.h"
+#include "clientignorelistmanager.h"
ChatMonitorView::ChatMonitorView(ChatMonitorFilter *filter, QWidget *parent)
: ChatView(filter, parent),
_filter(filter)
{
scene()->setSenderCutoffMode(ChatScene::CutoffLeft);
+ connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
}
void ChatMonitorView::addActionsToMenu(QMenu *menu, const QPointF &pos) {
SettingsPageDlg dlg(new ChatMonitorSettingsPage(), this);
dlg.exec();
}
+
+// connect only after client is synced to core since ChatMonitorView is created before
+// the ignoreListManager
+void ChatMonitorView::coreConnectionStateChanged(bool connected) {
+ if(connected)
+ connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), _filter, SLOT(invalidateFilter()));
+}
private slots:
void showFieldsChanged(bool checked);
void showSettingsPage();
+ virtual void coreConnectionStateChanged(bool connected);
protected:
inline ChatMonitorFilter *filter() const { return _filter; }
#include "messagefilter.h"
#include "qtui.h"
#include "qtuistyle.h"
+#include "clientignorelistmanager.h"
ChatView::ChatView(BufferId bufferId, QWidget *parent)
: QGraphicsView(parent),
setScene(_scene);
connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(verticalScrollbarChanged(int)));
+
+ // only connect if client is synched with a core
+ if(Client::isSynced())
+ connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), filter, SLOT(invalidateFilter()));
}
bool ChatView::event(QEvent *event) {