+void CoreSession::destroyNetwork(NetworkId id) {
+ QList<BufferId> removedBuffers = Core::requestBufferIdsForNetwork(user(), id);
+ Network *net = _networks.take(id);
+ if(net && Core::removeNetwork(user(), id)) {
+ foreach(BufferId bufferId, removedBuffers) {
+ _bufferSyncer->removeBuffer(bufferId);
+ }
+ emit networkRemoved(id);
+ net->deleteLater();
+ }
+}
+
+void CoreSession::renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName) {
+ BufferInfo bufferInfo = Core::bufferInfo(user(), networkId, BufferInfo::QueryBuffer, oldName, false);
+ if(bufferInfo.isValid()) {
+ _bufferSyncer->renameBuffer(bufferInfo.bufferId(), newName);
+ }
+}
+
+void CoreSession::clientsConnected() {
+ QHash<NetworkId, CoreNetwork *>::iterator netIter = _networks.begin();
+ Identity *identity = 0;
+ CoreNetwork *net = 0;
+ IrcUser *me = 0;
+ QString awayReason;
+ while(netIter != _networks.end()) {
+ net = *netIter;
+ netIter++;
+
+ if(!net->isConnected())
+ continue;
+ identity = net->identityPtr();
+ if(!identity)
+ continue;
+ me = net->me();
+ if(!me)
+ continue;
+
+ if(identity->detachAwayEnabled() && me->isAway()) {
+ net->userInputHandler()->handleAway(BufferInfo(), QString());
+ }
+ }
+}
+
+void CoreSession::clientsDisconnected() {
+ QHash<NetworkId, CoreNetwork *>::iterator netIter = _networks.begin();
+ Identity *identity = 0;
+ CoreNetwork *net = 0;
+ IrcUser *me = 0;
+ QString awayReason;
+ while(netIter != _networks.end()) {
+ net = *netIter;
+ netIter++;
+
+ if(!net->isConnected())
+ continue;
+ identity = net->identityPtr();
+ if(!identity)
+ continue;
+ me = net->me();
+ if(!me)
+ continue;
+
+ if(identity->detachAwayEnabled() && !me->isAway()) {
+ if(identity->detachAwayReasonEnabled())
+ awayReason = identity->detachAwayReason();
+ else
+ awayReason = identity->awayReason();
+ net->setAutoAwayActive(true);
+ net->userInputHandler()->handleAway(BufferInfo(), awayReason);
+ }
+ }
+}