Initialize new buffers in the UI with their activity
[quassel.git] / src / client / client.cpp
index 9449fbb..343ad85 100644 (file)
@@ -38,6 +38,7 @@
 #include "clientuserinputhandler.h"
 #include "coreaccountmodel.h"
 #include "coreconnection.h"
+#include "dccconfig.h"
 #include "ircchannel.h"
 #include "ircuser.h"
 #include "message.h"
@@ -101,6 +102,7 @@ Client::Client(QObject *parent)
     _backlogManager(new ClientBacklogManager(this)),
     _bufferViewManager(0),
     _bufferViewOverlay(new BufferViewOverlay(this)),
+    _dccConfig(0),
     _ircListHelper(new ClientIrcListHelper(this)),
     _inputHandler(0),
     _networkConfig(0),
@@ -388,6 +390,7 @@ void Client::setSyncedToCore()
     connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), this, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
     connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), _messageModel, SLOT(buffersPermanentlyMerged(BufferId, BufferId)));
     connect(bufferSyncer(), SIGNAL(bufferMarkedAsRead(BufferId)), SIGNAL(bufferMarkedAsRead(BufferId)));
+    connect(bufferSyncer(), SIGNAL(bufferActivityChanged(BufferId, const Message::Types)), _networkModel, SLOT(bufferActivityChanged(BufferId, const Message::Types)));
     connect(networkModel(), SIGNAL(requestSetLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &)));
 
     SignalProxy *p = signalProxy();
@@ -414,33 +417,46 @@ void Client::setSyncedToCore()
     _ignoreListManager = new ClientIgnoreListManager(this);
     p->synchronize(ignoreListManager());
 
+    // create TransferManager and DccConfig if core supports them
+    Q_ASSERT(!_dccConfig);
     Q_ASSERT(!_transferManager);
-    _transferManager = new ClientTransferManager(this);
-    _transferModel->setManager(_transferManager);
-    p->synchronize(transferManager());
+    if (coreFeatures() & Quassel::DccFileTransfer) {
+        _dccConfig = new DccConfig(this);
+        p->synchronize(dccConfig());
+        _transferManager = new ClientTransferManager(this);
+        _transferModel->setManager(_transferManager);
+        p->synchronize(transferManager());
+    }
 
     // trigger backlog request once all active bufferviews are initialized
-    connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+    connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(finishConnectionInitialization()));
 
     _connected = true;
     emit connected();
     emit coreConnectionStateChanged(true);
 }
 
-
-void Client::requestInitialBacklog()
+void Client::finishConnectionInitialization()
 {
     // usually it _should_ take longer until the bufferViews are initialized, so that's what
     // triggers this slot. But we have to make sure that we know all buffers yet.
     // so we check the BufferSyncer and in case it wasn't initialized we wait for that instead
     if (!bufferSyncer()->isInitialized()) {
-        disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
-        connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+        disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(finishConnectionInitialization()));
+        connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(finishConnectionInitialization()));
         return;
     }
-    disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
-    disconnect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog()));
+    disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(finishConnectionInitialization()));
+    disconnect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(finishConnectionInitialization()));
+
+    requestInitialBacklog();
+    if (coreFeatures().testFlag(Quassel::BufferActivitySync))
+        bufferSyncer()->markActivitiesChanged();
+}
 
+
+void Client::requestInitialBacklog()
+{
     _backlogManager->requestInitialBacklog();
 }
 
@@ -495,6 +511,11 @@ void Client::setDisconnectedFromCore()
         _transferManager = nullptr;
     }
 
+    if (_dccConfig) {
+        _dccConfig->deleteLater();
+        _dccConfig = nullptr;
+    }
+
     // we probably don't want to save pending input for reconnect
     _userInputBuffer.clear();