X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=ca219bbd02f9e7907a7fb03a299c13f608ab3502;hp=b599c9aab04ced81dd86d5d1f608bda3b49247ee;hb=faffcce49db14f404dc6446a76ecaf056f9eb481;hpb=93800658bba5dcbeca7f3deb02dd7091c455efe8 diff --git a/src/client/client.cpp b/src/client/client.cpp index b599c9aa..ca219bbd 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -21,15 +21,18 @@ #include "client.h" #include "abstractmessageprocessor.h" +#include "abstractui.h" #include "bufferinfo.h" #include "buffermodel.h" #include "buffersettings.h" #include "buffersyncer.h" #include "bufferviewconfig.h" -#include "bufferviewmanager.h" +#include "clientaliasmanager.h" #include "clientbacklogmanager.h" +#include "clientbufferviewmanager.h" #include "clientirclisthelper.h" #include "clientidentity.h" +#include "clientuserinputhandler.h" #include "ircchannel.h" #include "ircuser.h" #include "message.h" @@ -37,7 +40,6 @@ #include "network.h" #include "networkmodel.h" #include "quassel.h" -#include "quasselui.h" #include "signalproxy.h" #include "util.h" @@ -49,6 +51,11 @@ AccountId Client::_currentCoreAccount = 0; /*** Initialization/destruction ***/ +bool Client::instanceExists() +{ + return instanceptr; +} + Client *Client::instance() { if(!instanceptr) instanceptr = new Client(); @@ -75,9 +82,11 @@ Client::Client(QObject *parent) _networkModel(0), _bufferModel(0), _bufferSyncer(0), + _aliasManager(0), _backlogManager(new ClientBacklogManager(this)), _bufferViewManager(0), _ircListHelper(new ClientIrcListHelper(this)), + _inputHandler(0), _messageModel(0), _messageProcessor(0), _connectedToCore(false), @@ -102,6 +111,7 @@ void Client::init() { _bufferModel = new BufferModel(_networkModel); _messageModel = mainUi()->createMessageModel(this); _messageProcessor = mainUi()->createMessageProcessor(this); + _inputHandler = new ClientUserInputHandler(this); SignalProxy *p = signalProxy(); @@ -109,7 +119,7 @@ void Client::init() { p->attachSlot(SIGNAL(displayStatusMsg(QString, QString)), this, SLOT(recvStatusMsg(QString, QString))); p->attachSlot(SIGNAL(bufferInfoUpdated(BufferInfo)), _networkModel, SLOT(bufferUpdated(BufferInfo))); - p->attachSignal(this, SIGNAL(sendInput(BufferInfo, QString))); + p->attachSignal(inputHandler(), SIGNAL(sendInput(BufferInfo, QString))); p->attachSignal(this, SIGNAL(requestNetworkStates())); p->attachSignal(this, SIGNAL(requestCreateIdentity(const Identity &, const QVariantMap &)), SIGNAL(createIdentity(const Identity &, const QVariantMap &))); @@ -117,7 +127,7 @@ void Client::init() { p->attachSlot(SIGNAL(identityCreated(const Identity &)), this, SLOT(coreIdentityCreated(const Identity &))); p->attachSlot(SIGNAL(identityRemoved(IdentityId)), this, SLOT(coreIdentityRemoved(IdentityId))); - p->attachSignal(this, SIGNAL(requestCreateNetwork(const NetworkInfo &)), SIGNAL(createNetwork(const NetworkInfo &))); + p->attachSignal(this, SIGNAL(requestCreateNetwork(const NetworkInfo &, const QStringList &)), SIGNAL(createNetwork(const NetworkInfo &, const QStringList &))); p->attachSignal(this, SIGNAL(requestRemoveNetwork(NetworkId)), SIGNAL(removeNetwork(NetworkId))); p->attachSlot(SIGNAL(networkCreated(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId))); p->attachSlot(SIGNAL(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId))); @@ -167,8 +177,8 @@ const Network * Client::network(NetworkId networkid) { else return 0; } -void Client::createNetwork(const NetworkInfo &info) { - emit instance()->requestCreateNetwork(info); +void Client::createNetwork(const NetworkInfo &info, const QStringList &persistentChannels) { + emit instance()->requestCreateNetwork(info, persistentChannels); } void Client::removeNetwork(NetworkId id) { @@ -263,9 +273,21 @@ void Client::coreIdentityRemoved(IdentityId id) { } } -/*** ***/ -void Client::userInput(BufferInfo bufferInfo, QString message) { - emit instance()->sendInput(bufferInfo, message); +/*** User input handling ***/ + +void Client::userInput(const BufferInfo &bufferInfo, const QString &message) { + // we need to make sure that AliasManager is ready before processing input + if(aliasManager() && aliasManager()->isInitialized()) + inputHandler()->handleUserInput(bufferInfo, message); + else + instance()-> _userInputBuffer.append(qMakePair(bufferInfo, message)); +} + +void Client::sendBufferedUserInput() { + for(int i = 0; i < _userInputBuffer.count(); i++) + userInput(_userInputBuffer.at(i).first, _userInputBuffer.at(i).second); + + _userInputBuffer.clear(); } /*** core connection stuff ***/ @@ -297,11 +319,15 @@ void Client::setSyncedToCore() { // create a new BufferViewManager Q_ASSERT(!_bufferViewManager); - _bufferViewManager = new BufferViewManager(signalProxy(), this); + _bufferViewManager = new ClientBufferViewManager(signalProxy(), this); connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); - connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefautBufferView())); + connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefaultBufferView())); - createDefaultIdentity(); + // create AliasManager + Q_ASSERT(!_aliasManager); + _aliasManager = new ClientAliasManager(this); + connect(aliasManager(), SIGNAL(initDone()), SLOT(sendBufferedUserInput())); + signalProxy()->synchronize(aliasManager()); _syncedToCore = true; emit connected(); @@ -313,7 +339,7 @@ void Client::requestInitialBacklog() { Client::backlogManager()->requestInitialBacklog(); } -void Client::createDefautBufferView() { +void Client::createDefaultBufferView() { if(bufferViewManager()->bufferViewConfigs().isEmpty()) { BufferViewConfig config(-1); config.setBufferViewName(tr("All Buffers")); @@ -322,19 +348,6 @@ void Client::createDefautBufferView() { } } -void Client::createDefaultIdentity() { - if(_identities.isEmpty()) { - Identity identity; - identity.setToDefaults(); - identity.setIdentityName(tr("Default Identity")); - createIdentity(identity); - } -} - -void Client::setSecuredConnection() { - emit securedConnection(); -} - void Client::disconnectFromCore() { if(!isConnected()) return; @@ -364,6 +377,14 @@ void Client::disconnectedFromCore() { _bufferViewManager = 0; } + if(_aliasManager) { + _aliasManager->deleteLater(); + _aliasManager = 0; + } + + // we probably don't want to save pending input for reconnect + _userInputBuffer.clear(); + _messageModel->clear(); _networkModel->clear(); @@ -436,6 +457,12 @@ void Client::mergeBuffersPermanently(BufferId bufferId1, BufferId bufferId2) { bufferSyncer()->requestMergeBuffersPermanently(bufferId1, bufferId2); } +void Client::purgeKnownBufferIds() { + if(!bufferSyncer()) + return; + bufferSyncer()->requestPurgeBufferIds(); +} + void Client::bufferRemoved(BufferId bufferId) { // select a sane buffer (status buffer) /* we have to manually select a buffer because otherwise inconsitent changes @@ -474,6 +501,12 @@ void Client::logMessage(QtMsgType type, const char *msg) { 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); }