X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcoresession.cpp;h=0fbfed4d712d8da3f2e883bd980e9aad13f365bb;hb=f3834efcf968a7f38c77ec34876ef011a46f944c;hp=8237d25361c17fc729224bca272344f8415681ce;hpb=674ad8ee4369cbc9516eb6d6629a616e9310c71f;p=quassel.git diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 8237d253..0fbfed4d 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.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 * @@ -51,7 +51,6 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) _coreInfo(this), scriptEngine(new QScriptEngine(this)) { - SignalProxy *p = signalProxy(); connect(p, SIGNAL(peerRemoved(QIODevice *)), this, SLOT(removeClient(QIODevice *))); @@ -69,36 +68,24 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) p->attachSignal(this, SIGNAL(networkCreated(NetworkId))); p->attachSignal(this, SIGNAL(networkRemoved(NetworkId))); - p->attachSlot(SIGNAL(createNetwork(const NetworkInfo &)), this, SLOT(createNetwork(const NetworkInfo &))); + p->attachSlot(SIGNAL(createNetwork(const NetworkInfo &, const QStringList &)), this, SLOT(createNetwork(const NetworkInfo &, const QStringList &))); p->attachSlot(SIGNAL(removeNetwork(NetworkId)), this, SLOT(removeNetwork(NetworkId))); loadSettings(); initScriptEngine(); - // init BufferSyncer - QHash lastSeenHash = Core::bufferLastSeenMsgIds(user()); - foreach(BufferId id, lastSeenHash.keys()) - _bufferSyncer->requestSetLastSeenMsg(id, lastSeenHash[id]); - connect(&(Core::instance()->syncTimer()), SIGNAL(timeout()), _bufferSyncer, SLOT(storeDirtyIds())); - p->synchronize(_bufferSyncer); - + connect(&(Core::instance()->syncTimer()), SIGNAL(timeout()), _bufferViewManager, SLOT(saveBufferViews())); - // init alias manager + p->synchronize(_bufferSyncer); p->synchronize(&aliasManager()); - - // init BacklogManager p->synchronize(_backlogManager); - p->dumpSyncMap(_backlogManager); - - // init IrcListHelper p->synchronize(ircListHelper()); - - // init CoreInfo p->synchronize(&_coreInfo); // Restore session state - if(restoreState) restoreSessionState(); + if(restoreState) + restoreSessionState(); emit initialized(); } @@ -146,12 +133,6 @@ void CoreSession::loadSettings() { foreach(CoreIdentity identity, Core::identities(user())) { createIdentity(identity); } - if(!_identities.count()) { - Identity identity; - identity.setToDefaults(); - identity.setIdentityName(tr("Default Identity")); - createIdentity(identity, QVariantMap()); - } foreach(NetworkInfo info, Core::networks(user())) { createNetwork(info); @@ -160,6 +141,7 @@ void CoreSession::loadSettings() { void CoreSession::saveSessionState() const { _bufferSyncer->storeDirtyIds(); + _bufferViewManager->saveBufferViews(); } void CoreSession::restoreSessionState() { @@ -200,7 +182,6 @@ void CoreSession::removeClient(QIODevice *iodev) { QHash CoreSession::persistentChannels(NetworkId id) const { return Core::persistentChannels(user(), id); - return QHash(); } // FIXME switch to BufferId @@ -325,7 +306,7 @@ void CoreSession::removeIdentity(IdentityId id) { /*** Network Handling ***/ -void CoreSession::createNetwork(const NetworkInfo &info_) { +void CoreSession::createNetwork(const NetworkInfo &info_, const QStringList &persistentChans) { NetworkInfo info = info_; int id; @@ -339,6 +320,20 @@ void CoreSession::createNetwork(const NetworkInfo &info_) { id = info.networkId.toInt(); if(!_networks.contains(id)) { + + // create persistent chans + QRegExp rx("\\s*(\\S+)(?:\\s*(\\S+))?\\s*"); + foreach(QString channel, persistentChans) { + if(!rx.exactMatch(channel)) { + qWarning() << QString("Invalid persistent channel declaration: %1").arg(channel); + continue; + } + Core::bufferInfo(user(), info.networkId, BufferInfo::ChannelBuffer, rx.cap(1), true); + Core::setChannelPersistent(user(), info.networkId, rx.cap(1), true); + if(!rx.cap(2).isEmpty()) + Core::setPersistentChannelKey(user(), info.networkId, rx.cap(1), rx.cap(2)); + } + CoreNetwork *net = new CoreNetwork(id, this); connect(net, SIGNAL(displayMsg(Message::Type, BufferInfo::Type, QString, QString, QString, Message::Flags)), this, SLOT(recvMessageFromServer(Message::Type, BufferInfo::Type, QString, QString, QString, Message::Flags))); @@ -383,7 +378,9 @@ void CoreSession::destroyNetwork(NetworkId id) { void CoreSession::renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName) { BufferInfo bufferInfo = Core::bufferInfo(user(), networkId, BufferInfo::QueryBuffer, oldName, false); - _bufferSyncer->renameBuffer(bufferInfo.bufferId(), newName); + if(bufferInfo.isValid()) { + _bufferSyncer->renameBuffer(bufferInfo.bufferId(), newName); + } } void CoreSession::clientsConnected() { @@ -391,7 +388,6 @@ void CoreSession::clientsConnected() { Identity *identity = 0; CoreNetwork *net = 0; IrcUser *me = 0; - QString awayReason; while(netIter != _networks.end()) { net = *netIter; netIter++; @@ -431,10 +427,8 @@ void CoreSession::clientsDisconnected() { continue; if(identity->detachAwayEnabled() && !me->isAway()) { - if(identity->detachAwayReasonEnabled()) + if(!identity->detachAwayReason().isEmpty()) awayReason = identity->detachAwayReason(); - else - awayReason = identity->awayReason(); net->setAutoAwayActive(true); net->userInputHandler()->handleAway(BufferInfo(), awayReason); }