fixing the creating of new buffers in the client. bye bye Client::buffer(BufferId)
[quassel.git] / src / client / client.cpp
index d297263..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,21 +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());
 }
 
-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;