Quassel dumps now a human readable stacktrace to ${PWD}/Quassel-Crash-yyyyMMdd-hhmm...
[quassel.git] / src / client / client.cpp
index db60bcb..48c471c 100644 (file)
@@ -77,7 +77,6 @@ Client::Client(QObject *parent)
     _connectedToCore(false),
     _syncedToCore(false)
 {
-  _monitorBuffer = new Buffer(BufferInfo(), this);
   _signalProxy->synchronize(_ircListHelper);
 
   connect(_backlogManager, SIGNAL(backlog(BufferId, const QVariantList &)),
@@ -161,15 +160,10 @@ Buffer *Client::statusBuffer(const NetworkId &networkId) const {
     return 0;
 }
 
-Buffer *Client::buffer(BufferId bufferId) {
-  if(instance()->_buffers.contains(bufferId))
-    return instance()->_buffers[bufferId];
-  else
-    return 0;
-}
-
 Buffer *Client::buffer(BufferInfo bufferInfo) {
-  Buffer *buff = buffer(bufferInfo.bufferId());
+  Buffer *buff = 0;
+  if(instance()->_buffers.contains(bufferInfo.bufferId()))
+    buff = instance()->_buffers[bufferInfo.bufferId()];
 
   if(!buff) {
     Client *client = Client::instance();
@@ -309,7 +303,7 @@ void Client::setSyncedToCore() {
   // create buffersyncer
   Q_ASSERT(!_bufferSyncer);
   _bufferSyncer = new BufferSyncer(this);
-  connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), this, SLOT(updateLastSeenMsg(BufferId, MsgId)));
+  connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), _networkModel, SLOT(setLastSeenMsgId(BufferId, MsgId)));
   connect(bufferSyncer(), SIGNAL(bufferRemoved(BufferId)), this, SLOT(bufferRemoved(BufferId)));
   connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString)));
   signalProxy()->synchronize(bufferSyncer());
@@ -342,6 +336,8 @@ void Client::disconnectFromCore() {
   emit disconnected();
   emit coreConnectionStateChanged(false);
 
+  messageProcessor()->reset();
+
   // Clear internal data. Hopefully nothing relies on it at this point.
   setCurrentCoreAccount(0);
 
@@ -448,65 +444,14 @@ void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) {
   //QTime start = QTime::currentTime();
   QList<Message> msglist;
   foreach(QVariant v, msgs) {
-    msglist << v.value<Message>();
+    Message msg = v.value<Message>();
+    msg.setFlags(msg.flags() | Message::Backlog);
+    msglist << msg;
   }
   messageProcessor()->process(msglist);
   //qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
 }
 
-// TODO optimize checkForHighlight
-void Client::checkForHighlight(Message &msg) {
-  if(!((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self)))
-    return;
-
-  NotificationSettings notificationSettings;
-  const Network *net = network(msg.bufferInfo().networkId());
-  if(net && !net->myNick().isEmpty()) {
-    QStringList nickList;
-    if(notificationSettings.highlightNick() == NotificationSettings::CurrentNick) {
-      nickList << net->myNick();
-    } else if(notificationSettings.highlightNick() == NotificationSettings::AllNicks) {
-      const Identity *myIdentity = identity(net->identity());
-      if(myIdentity)
-       nickList = myIdentity->nicks();
-    }
-    foreach(QString nickname, nickList) {
-      QRegExp nickRegExp("^(.*\\W)?" + QRegExp::escape(nickname) + "(\\W.*)?$");
-      if(nickRegExp.exactMatch(msg.contents())) {
-        msg.setFlags(msg.flags() | Message::Highlight);
-        return;
-      }
-    }
-
-    foreach(QVariant highlight, notificationSettings.highlightList()) {
-      QVariantMap highlightRule = highlight.toMap();
-      if(!highlightRule["enable"].toBool())
-        continue;
-      Qt::CaseSensitivity caseSensitivity = highlightRule["cs"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive;
-      QString name = highlightRule["name"].toString();
-      QRegExp userRegExp;
-      if(highlightRule["regex"].toBool()) {
-        userRegExp = QRegExp(name, caseSensitivity);
-      } else {
-        userRegExp = QRegExp("^(.*\\W)?" + QRegExp::escape(name) + "(\\W.*)?$", caseSensitivity);
-      }
-      if(userRegExp.exactMatch(msg.contents())) {
-        msg.setFlags(msg.flags() | Message::Highlight);
-        return;
-      }
-    }
-  }
-}
-
-void Client::updateLastSeenMsg(BufferId id, const MsgId &msgId) {
-  Buffer *b = buffer(id);
-  if(!b) {
-    qWarning() << "Client::updateLastSeen(): Unknown buffer" << id;
-    return;
-  }
-  b->setLastSeenMsg(msgId);
-}
-
 void Client::setBufferLastSeenMsg(BufferId id, const MsgId &msgId) {
   if(!bufferSyncer())
     return;