- if(!_sentQuit) {
- _quitTimer.stop();
- quitTimeout();
- }
- QHash<QString, QStringList>::iterator it;
- for(it = _joins.begin(); it != _joins.end(); ++it)
- emit netsplitJoin(it.key(), it.value(),_quitMsg);
- _joins.clear();
- _discardTimer.stop();
- emit finished();
+ if (!_sentQuit) {
+ _quitTimer.stop();
+ quitTimeout();
+ }
+
+ QHash<QString, QPair<QStringList, QStringList> >::iterator it;
+
+ /*
+ Try to catch server jumpers.
+ If we have too few joins for a netsplit-quit,
+ we assume that the users manually changed servers and join them
+ without ending the netsplit.
+ A netsplit is assumed over only if at least 1/3 of all quits had their corresponding
+ join again.
+ */
+ if (_joinCounter < _quitCounter/3) {
+ for (it = _joins.begin(); it != _joins.end(); ++it)
+ emit earlyJoin(network(), it.key(), it.value().first, it.value().second);
+
+ // we don't care about those anymore
+ _joins.clear();
+
+ // restart the timer with 5min timeout
+ // This might happen a few times if netsplit lasts longer.
+ // As soon as another user joins, the timer is set to a shorter timeout again.
+ _joinTimer.start(300000);
+ return;
+ }
+
+ // send netsplitJoin for every recorded channel
+ for (it = _joins.begin(); it != _joins.end(); ++it)
+ emit netsplitJoin(network(), it.key(), it.value().first, it.value().second, _quitMsg);
+ _joins.clear();
+ _discardTimer.stop();
+ emit finished();