+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);
+
+ CoreNetwork *currentNetwork = network(bufferInfo.networkId());
+ networkName = currentNetwork ? currentNetwork->networkName() : QString("");
+ // 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 bufferInfo;
+ for(int i = 0; i < _messageQueue.count(); i++) {
+ const RawMessage &rawMsg = _messageQueue.at(i);
+ if(bufferInfoCache.contains(rawMsg.networkId) && bufferInfoCache[rawMsg.networkId].contains(rawMsg.target)) {
+ bufferInfo = bufferInfoCache[rawMsg.networkId][rawMsg.target];
+ } else {
+ bufferInfo = Core::bufferInfo(user(), rawMsg.networkId, rawMsg.bufferType, rawMsg.target);
+ bufferInfoCache[rawMsg.networkId][rawMsg.target] = bufferInfo;
+ }
+
+ Message msg(bufferInfo, rawMsg.type, rawMsg.text, rawMsg.sender, rawMsg.flags);
+ CoreNetwork *currentNetwork = network(bufferInfo.networkId());
+ networkName = currentNetwork ? currentNetwork->networkName() : QString("");
+ // 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)
+ for(int i = 0; i < messages.count(); i++) {
+ emit displayMsg(messages[i]);
+ }
+ }
+ _processMessages = false;
+ _messageQueue.clear();
+}