X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=164375700ecbb7222d939a708ca3f9c4093140f3;hp=f981040e72070385d2214f5617ca616895bb5df9;hb=f7e987956ef7e469a493a669e2f0c0901f5a7ead;hpb=034708a59ca1ee3195263a90941a2b145c520fef diff --git a/src/client/client.cpp b/src/client/client.cpp index f981040e..16437570 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -40,6 +40,9 @@ #include "signalproxy.h" #include "util.h" +#include +#include + QPointer Client::instanceptr = 0; AccountId Client::_currentCoreAccount = 0; @@ -256,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); @@ -277,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(); } @@ -406,22 +415,14 @@ void Client::bufferRenamed(BufferId bufferId, const QString &newName) { } void Client::logMessage(QtMsgType type, const char *msg) { - QString prefix; - switch (type) { - case QtDebugMsg: - prefix = "Debug"; - break; - case QtWarningMsg: - prefix = "Warning"; - break; - case QtCriticalMsg: - prefix = "Critical"; - break; - case QtFatalMsg: + fprintf(stderr, "%s\n", msg); + fflush(stderr); + if(type == QtFatalMsg) { Quassel::logFatalMessage(msg); - return; + } else { + QString msgString = QString("%1\n").arg(msg); + instance()->_debugLog << msgString; + emit instance()->logUpdated(msgString); } - instance()->_debugLog << prefix << ": " << msg << "\n"; - emit instance()->logUpdated(); }