X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=87fa59f82110179ffa66eddba478c7bf6555a39d;hb=48dda5f3e963e13e36300ddaef262660bf169672;hp=f8627d024fcf0e10a2454846041ae03422a36f2c;hpb=88ce73ff525535c00cc979fff357fbe4cb8cdc2b;p=quassel.git diff --git a/src/client/client.cpp b/src/client/client.cpp index f8627d02..87fa59f8 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -101,6 +101,7 @@ Client::Client(QObject *parent) _backlogManager(new ClientBacklogManager(this)), _bufferViewManager(0), _bufferViewOverlay(new BufferViewOverlay(this)), + _coreInfo(new CoreInfo(this)), _dccConfig(0), _ircListHelper(new ClientIrcListHelper(this)), _inputHandler(0), @@ -113,8 +114,7 @@ Client::Client(QObject *parent) _messageProcessor(0), _coreAccountModel(new CoreAccountModel(this)), _coreConnection(new CoreConnection(this)), - _connected(false), - _debugLog(&_debugLogBuffer) + _connected(false) { _signalProxy->synchronize(_ircListHelper); } @@ -168,12 +168,19 @@ void Client::init() connect(this, SIGNAL(connected()), mainUi(), SLOT(connectedToCore())); connect(this, SIGNAL(disconnected()), mainUi(), SLOT(disconnectedFromCore())); + // Listen to network removed events + connect(this, SIGNAL(networkRemoved(NetworkId)), + _messageProcessor, SLOT(networkRemoved(NetworkId))); + // attach backlog manager p->synchronize(backlogManager()); connect(backlogManager(), SIGNAL(messagesReceived(BufferId, int)), _messageModel, SLOT(messagesReceived(BufferId, int))); coreAccountModel()->load(); + // Attach CoreInfo + p->synchronize(coreInfo()); + connect(coreConnection(), SIGNAL(stateChanged(CoreConnection::ConnectionState)), SLOT(connectionStateChanged(CoreConnection::ConnectionState))); coreConnection()->init(); } @@ -205,6 +212,22 @@ bool Client::internalCore() } +void Client::onDbUpgradeInProgress(bool inProgress) +{ + emit dbUpgradeInProgress(inProgress); +} + + +void Client::onExitRequested(int exitCode, const QString &reason) +{ + if (!reason.isEmpty()) { + qCritical() << reason; + emit exitRequested(reason); + } + QCoreApplication::exit(exitCode); +} + + /*** Network handling ***/ QList Client::networkIds() @@ -425,6 +448,9 @@ void Client::setSyncedToCore() Q_ASSERT(!_highlightRuleManager); _highlightRuleManager = new HighlightRuleManager(this); p->synchronize(highlightRuleManager()); + // Listen to network removed events + connect(this, SIGNAL(networkRemoved(NetworkId)), + _highlightRuleManager, SLOT(networkRemoved(NetworkId))); /* not ready yet // create TransferManager and DccConfig if core supports them @@ -474,6 +500,27 @@ void Client::requestInitialBacklog() } +void Client::requestLegacyCoreInfo() +{ + // On older cores, the CoreInfo object was only synchronized on demand. Synchronize now if + // needed. + if (isConnected() && !isCoreFeatureEnabled(Quassel::Feature::SyncedCoreInfo)) { + // Delete the existing core info object (it will always exist as client is single-threaded) + _coreInfo->deleteLater(); + // No need to set to null when creating new one immediately after + + // Create a fresh, unsynchronized CoreInfo object, emulating legacy behavior of CoreInfo not + // persisting + _coreInfo = new CoreInfo(this); + // Synchronize the new object + signalProxy()->synchronize(_coreInfo); + + // Let others know signal handlers have been reset + emit coreInfoResynchronized(); + } +} + + void Client::disconnectFromCore() { if (!coreConnection()->isConnected()) @@ -500,6 +547,8 @@ void Client::setDisconnectedFromCore() _bufferSyncer = 0; } + _coreInfo->reset(); + if (_bufferViewManager) { _bufferViewManager->deleteLater(); _bufferViewManager = 0; @@ -694,6 +743,12 @@ void Client::markBufferAsRead(BufferId id) } +void Client::refreshLegacyCoreInfo() +{ + instance()->requestLegacyCoreInfo(); +} + + void Client::changePassword(const QString &oldPassword, const QString &newPassword) { CoreAccount account = currentCoreAccount(); account.setPassword(newPassword); @@ -714,48 +769,3 @@ void Client::corePasswordChanged(PeerPtr, bool success) coreAccountModel()->save(); emit passwordChanged(success); } - - -#if QT_VERSION < 0x050000 -void Client::logMessage(QtMsgType type, const char *msg) -{ - fprintf(stderr, "%s\n", msg); - fflush(stderr); - if (type == QtFatalMsg) { - Quassel::logFatalMessage(msg); - } - else { - QString msgString = QString("%1\n").arg(msg); - - //Check to see if there is an instance around, else we risk recursions - //when calling instance() and creating new ones. - if (!instanceExists()) - return; - - instance()->_debugLog << msgString; - emit instance()->logUpdated(msgString); - } -} -#else -void Client::logMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg) -{ - Q_UNUSED(context); - - fprintf(stderr, "%s\n", msg.toLocal8Bit().constData()); - fflush(stderr); - if (type == QtFatalMsg) { - Quassel::logFatalMessage(msg.toLocal8Bit().constData()); - } - else { - QString msgString = QString("%1\n").arg(msg); - - //Check to see if there is an instance around, else we risk recursions - //when calling instance() and creating new ones. - if (!instanceExists()) - return; - - instance()->_debugLog << msgString; - emit instance()->logUpdated(msgString); - } -} -#endif