X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoresession.cpp;h=0dd335876f69da4bfddfd7bd9bf7ce12ef8ed362;hp=020950f6de73ee110f10f1ba6ed4da3d65023848;hb=eab5c456972d723fb3c67fe366548608f3bbeadc;hpb=5d05ab030c24ff57b0e5d00d9d66869c2f934a49 diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 020950f6..0dd33587 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -57,6 +57,9 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) SignalProxy *p = signalProxy(); connect(p, SIGNAL(peerRemoved(QIODevice *)), this, SLOT(removeClient(QIODevice *))); + connect(p, SIGNAL(connected()), this, SLOT(clientsConnected())); + connect(p, SIGNAL(disconnected()), this, SLOT(clientsDisconnected())); + //p->attachSlot(SIGNAL(disconnectFromNetwork(NetworkId)), this, SLOT(disconnectFromNetwork(NetworkId))); // FIXME p->attachSlot(SIGNAL(sendInput(BufferInfo, QString)), this, SLOT(msgFromClient(BufferInfo, QString))); p->attachSignal(this, SIGNAL(displayMsg(Message))); @@ -116,10 +119,6 @@ CoreSession::~CoreSession() { } } -UserId CoreSession::user() const { - return _user; -} - CoreNetwork *CoreSession::network(NetworkId id) const { if(_networks.contains(id)) return _networks[id]; return 0; @@ -503,3 +502,65 @@ void CoreSession::renameBuffer(const NetworkId &networkId, const QString &newNam emit bufferRenamed(bufferId, newName); } } + +void CoreSession::clientsConnected() { + QHash::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::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(); + con->userInputHandler()->handleAway(BufferInfo(), awayReason); + } + } +}