postponed backlog loading until custom views are loaded and the buffersyncer knows...
[quassel.git] / src / client / client.cpp
index b61ebd7..1643757 100644 (file)
@@ -259,20 +259,17 @@ void Client::userInput(BufferInfo bufferInfo, QString message) {
 
 /*** core connection stuff ***/
 
-void Client::setConnectedToCore(QIODevice *socket, AccountId id) {
-  // if the socket is an orphan, the signalProxy adopts it.
-  // -> we don't need to care about it anymore
-  socket->setParent(0);
-  signalProxy()->addPeer(socket);
+void Client::setConnectedToCore(AccountId id, QIODevice *socket) {
+  if(socket) { // external core
+    // if the socket is an orphan, the signalProxy adopts it.
+    // -> we don't need to care about it anymore
+    socket->setParent(0);
+    signalProxy()->addPeer(socket);
+  }
   _connectedToCore = true;
   setCurrentCoreAccount(id);
 }
 
-void Client::setConnectedToInternalCore() {
-  _connectedToCore = true;
-  setCurrentCoreAccount(AccountId());
-}
-
 void Client::setSyncedToCore() {
   // create buffersyncer
   Q_ASSERT(!_bufferSyncer);
@@ -280,16 +277,25 @@ void Client::setSyncedToCore() {
   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)));
+  connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+  connect(networkModel(), SIGNAL(setLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &)));
   signalProxy()->synchronize(bufferSyncer());
 
   // create a new BufferViewManager
+  Q_ASSERT(!_bufferViewManager);
   _bufferViewManager = new BufferViewManager(signalProxy(), this);
+  connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
 
   _syncedToCore = true;
   emit connected();
   emit coreConnectionStateChanged(true);
 }
 
+void Client::requestInitialBacklog() {
+  if(bufferViewManager()->isInitialized() && bufferSyncer()->isInitialized())
+    Client::backlogManager()->requestInitialBacklog();
+}
+
 void Client::setSecuredConnection() {
   emit securedConnection();
 }