+
+void CoreSession::removeBufferRequested(BufferId bufferId) {
+ BufferInfo bufferInfo = Core::getBufferInfo(user(), bufferId);
+ if(!bufferInfo.isValid()) {
+ qWarning() << "CoreSession::removeBufferRequested(): invalid BufferId:" << bufferId << "for User:" << user();
+ return;
+ }
+
+ if(bufferInfo.type() == BufferInfo::StatusBuffer) {
+ qWarning() << "CoreSession::removeBufferRequested(): Status Buffers cannot be removed!";
+ return;
+ }
+
+ if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
+ CoreNetwork *net = network(bufferInfo.networkId());
+ if(!net) {
+ qWarning() << "CoreSession::removeBufferRequested(): Received BufferInfo with unknown networkId!";
+ return;
+ }
+ IrcChannel *chan = net->ircChannel(bufferInfo.bufferName());
+ if(chan) {
+ qWarning() << "CoreSession::removeBufferRequested(): Unable to remove Buffer for joined Channel:" << bufferInfo.bufferName();
+ return;
+ }
+ }
+ if(Core::removeBuffer(user(), bufferId))
+ emit bufferRemoved(bufferId);
+}
+
+void CoreSession::renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName) {
+ BufferId bufferId = Core::renameBuffer(user(), networkId, newName, oldName);
+ if(bufferId.isValid()) {
+ emit bufferRenamed(bufferId, newName);
+ }
+}
+
+void CoreSession::clientsConnected() {
+ QHash<NetworkId, NetworkConnection *>::iterator conIter = _connections.begin();
+ Identity *identity = 0;
+ NetworkConnection *con = 0;
+ Network *network = 0;
+ IrcUser *me = 0;
+ QString awayReason;
+ while(conIter != _connections.end()) {
+ con = *conIter;
+ conIter++;
+
+ if(!con->isConnected())
+ continue;
+ identity = con->identity();
+ if(!identity)
+ continue;
+ network = con->network();
+ if(!network)
+ continue;
+ me = network->me();
+ if(!me)
+ continue;
+
+ if(identity->detachAwayEnabled() && me->isAway()) {
+ con->userInputHandler()->handleAway(BufferInfo(), QString());
+ }
+ }
+}
+
+void CoreSession::clientsDisconnected() {
+ QHash<NetworkId, NetworkConnection *>::iterator conIter = _connections.begin();
+ Identity *identity = 0;
+ NetworkConnection *con = 0;
+ Network *network = 0;
+ IrcUser *me = 0;
+ QString awayReason;
+ while(conIter != _connections.end()) {
+ con = *conIter;
+ conIter++;
+
+ if(!con->isConnected())
+ continue;
+ identity = con->identity();
+ if(!identity)
+ continue;
+ network = con->network();
+ if(!network)
+ continue;
+ me = network->me();
+ if(!me)
+ continue;
+
+ if(identity->detachAwayEnabled() && !me->isAway()) {
+ if(identity->detachAwayReasonEnabled())
+ awayReason = identity->detachAwayReason();
+ else
+ awayReason = identity->awayReason();
+ network->setAutoAwayActive(true);
+ con->userInputHandler()->handleAway(BufferInfo(), awayReason);
+ }
+ }
+}