X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=575314c113210b0b9a1163d64132168b8f3209a2;hb=7857ea0a520226e856af8d275550b76627f59c56;hp=b61ebd7e1aac1c6a50f2b38de8c0f400525ad4a1;hpb=f08065ca12cb5485d3bd82c8b29cbff13344712a;p=quassel.git diff --git a/src/client/client.cpp b/src/client/client.cpp index b61ebd7e..575314c1 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -56,21 +56,21 @@ Client *Client::instance() { void Client::destroy() { if(instanceptr) { - delete instanceptr->mainUi; + delete instanceptr->mainUi(); instanceptr->deleteLater(); instanceptr = 0; } } void Client::init(AbstractUi *ui) { - instance()->mainUi = ui; + instance()->_mainUi = ui; instance()->init(); } Client::Client(QObject *parent) : QObject(parent), _signalProxy(new SignalProxy(SignalProxy::Client, this)), - mainUi(0), + _mainUi(0), _networkModel(0), _bufferModel(0), _bufferSyncer(0), @@ -98,8 +98,8 @@ void Client::init() { _networkModel, SLOT(networkRemoved(NetworkId))); _bufferModel = new BufferModel(_networkModel); - _messageModel = mainUi->createMessageModel(this); - _messageProcessor = mainUi->createMessageProcessor(this); + _messageModel = mainUi()->createMessageModel(this); + _messageProcessor = mainUi()->createMessageProcessor(this); SignalProxy *p = signalProxy(); @@ -122,10 +122,10 @@ void Client::init() { connect(p, SIGNAL(disconnected()), this, SLOT(disconnectedFromCore())); - //connect(mainUi, SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &))); - connect(mainUi, SIGNAL(disconnectFromCore()), this, SLOT(disconnectFromCore())); - connect(this, SIGNAL(connected()), mainUi, SLOT(connectedToCore())); - connect(this, SIGNAL(disconnected()), mainUi, SLOT(disconnectedFromCore())); + //connect(mainUi(), SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &))); + connect(mainUi(), SIGNAL(disconnectFromCore()), this, SLOT(disconnectFromCore())); + connect(this, SIGNAL(connected()), mainUi(), SLOT(connectedToCore())); + connect(this, SIGNAL(disconnected()), mainUi(), SLOT(disconnectedFromCore())); // attach backlog manager p->synchronize(backlogManager()); @@ -134,6 +134,10 @@ void Client::init() { /*** public static methods ***/ +AbstractUi *Client::mainUi() { + return instance()->_mainUi; +} + AccountId Client::currentCoreAccount() { return _currentCoreAccount; } @@ -259,20 +263,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 +281,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(); }