X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=21beda08313606669f038501b51b98e98e486c03;hp=019c67c97f7a2e1d479b18d1e1658b6608edcffa;hb=4ae8f86c1ce452582d6fe576956c7c1bc1460adf;hpb=fa00b68a21c777682d9feb37ade6b3904fc19d92 diff --git a/src/client/client.cpp b/src/client/client.cpp index 019c67c9..21beda08 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -52,6 +52,7 @@ #include QPointer Client::instanceptr = 0; +Quassel::Features Client::_coreFeatures = 0; /*** Initialization/destruction ***/ @@ -98,6 +99,7 @@ Client::Client(QObject *parent) _messageProcessor(0), _coreAccountModel(new CoreAccountModel(this)), _coreConnection(new CoreConnection(_coreAccountModel, this)), + _connected(false), _debugLog(&_debugLogBuffer) { _signalProxy->synchronize(_ircListHelper); @@ -158,12 +160,12 @@ AbstractUi *Client::mainUi() { return instance()->_mainUi; } -bool Client::isConnected() { - return coreConnection()->state() >= CoreConnection::Connected; +void Client::setCoreFeatures(Quassel::Features features) { + _coreFeatures = features; } -bool Client::isSynced() { - return coreConnection()->state() == CoreConnection::Synchronized; +bool Client::isConnected() { + return instance()->_connected; } bool Client::internalCore() { @@ -314,17 +316,19 @@ void Client::setSyncedToCore() { Q_ASSERT(!_bufferSyncer); _bufferSyncer = new BufferSyncer(this); connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), _networkModel, SLOT(setLastSeenMsgId(BufferId, MsgId))); + connect(bufferSyncer(), SIGNAL(markerLineSet(BufferId,MsgId)), _networkModel, SLOT(setMarkerLineMsgId(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(buffersPermanentlyMerged(BufferId, BufferId)), this, SLOT(buffersPermanentlyMerged(BufferId, BufferId))); connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), _messageModel, SLOT(buffersPermanentlyMerged(BufferId, BufferId))); - connect(networkModel(), SIGNAL(setLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &))); + connect(bufferSyncer(), SIGNAL(bufferMarkedAsRead(BufferId)), SIGNAL(bufferMarkedAsRead(BufferId))); + connect(networkModel(), SIGNAL(requestSetLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &))); signalProxy()->synchronize(bufferSyncer()); // create a new BufferViewManager Q_ASSERT(!_bufferViewManager); _bufferViewManager = new ClientBufferViewManager(signalProxy(), this); - connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefaultBufferView())); + connect(_bufferViewManager, SIGNAL(initDone()), _bufferViewOverlay, SLOT(restore())); // create AliasManager Q_ASSERT(!_aliasManager); @@ -345,6 +349,7 @@ void Client::setSyncedToCore() { // trigger backlog request once all active bufferviews are initialized connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); + _connected = true; emit connected(); emit coreConnectionStateChanged(true); } @@ -354,20 +359,14 @@ void Client::requestInitialBacklog() { // 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()) { - connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); + disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); return; } - _backlogManager->requestInitialBacklog(); -} + disconnect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); + disconnect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); -void Client::createDefaultBufferView() { - if(bufferViewManager()->bufferViewConfigs().isEmpty()) { - BufferViewConfig config(-1); - config.setBufferViewName(tr("All Chats")); - config.initSetBufferList(networkModel()->allBufferIdsSorted()); - bufferViewManager()->requestCreateBufferView(config.toVariantMap()); - } + _backlogManager->requestInitialBacklog(); } void Client::disconnectFromCore() { @@ -378,6 +377,9 @@ void Client::disconnectFromCore() { } void Client::setDisconnectedFromCore() { + _connected = false; + _coreFeatures = 0; + emit disconnected(); emit coreConnectionStateChanged(false); @@ -396,6 +398,8 @@ void Client::setDisconnectedFromCore() { _bufferViewManager = 0; } + _bufferViewOverlay->reset(); + if(_aliasManager) { _aliasManager->deleteLater(); _aliasManager = 0; @@ -462,9 +466,19 @@ void Client::recvMessage(const Message &msg) { } void Client::setBufferLastSeenMsg(BufferId id, const MsgId &msgId) { - if(!bufferSyncer()) - return; - bufferSyncer()->requestSetLastSeenMsg(id, msgId); + if(bufferSyncer()) + bufferSyncer()->requestSetLastSeenMsg(id, msgId); +} + +void Client::setMarkerLine(BufferId id, const MsgId &msgId) { + if(bufferSyncer()) + bufferSyncer()->requestSetMarkerLine(id, msgId); +} + +MsgId Client::markerLine(BufferId id) { + if(id.isValid() && networkModel()) + return networkModel()->markerLineMsgId(id); + return MsgId(); } void Client::removeBuffer(BufferId id) { @@ -521,6 +535,11 @@ void Client::buffersPermanentlyMerged(BufferId bufferId1, BufferId bufferId2) { networkModel()->removeBuffer(bufferId2); } +void Client::markBufferAsRead(BufferId id) { + if(bufferSyncer() && id.isValid()) + bufferSyncer()->requestMarkBufferAsRead(id); +} + void Client::logMessage(QtMsgType type, const char *msg) { fprintf(stderr, "%s\n", msg); fflush(stderr);