Add support for chghost
[quassel.git] / src / core / coresessioneventprocessor.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2016 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #include "coresessioneventprocessor.h"
22
23 #include "coreirclisthelper.h"
24 #include "corenetwork.h"
25 #include "coresession.h"
26 #include "coretransfer.h"
27 #include "coretransfermanager.h"
28 #include "ctcpevent.h"
29 #include "ircevent.h"
30 #include "ircuser.h"
31 #include "logger.h"
32 #include "messageevent.h"
33 #include "netsplit.h"
34 #include "quassel.h"
35
36 #ifdef HAVE_QCA2
37 #  include "keyevent.h"
38 #endif
39
40 // IRCv3 capabilities
41 #include "irccap.h"
42
43 CoreSessionEventProcessor::CoreSessionEventProcessor(CoreSession *session)
44     : BasicHandler("handleCtcp", session),
45     _coreSession(session)
46 {
47     connect(coreSession(), SIGNAL(networkDisconnected(NetworkId)), this, SLOT(destroyNetsplits(NetworkId)));
48     connect(this, SIGNAL(newEvent(Event *)), coreSession()->eventManager(), SLOT(postEvent(Event *)));
49 }
50
51
52 bool CoreSessionEventProcessor::checkParamCount(IrcEvent *e, int minParams)
53 {
54     if (e->params().count() < minParams) {
55         if (e->type() == EventManager::IrcEventNumeric) {
56             qWarning() << "Command " << static_cast<IrcEventNumeric *>(e)->number() << " requires " << minParams << "params, got: " << e->params();
57         }
58         else {
59             QString name = coreSession()->eventManager()->enumName(e->type());
60             qWarning() << qPrintable(name) << "requires" << minParams << "params, got:" << e->params();
61         }
62         e->stop();
63         return false;
64     }
65     return true;
66 }
67
68
69 void CoreSessionEventProcessor::tryNextNick(NetworkEvent *e, const QString &errnick, bool erroneus)
70 {
71     QStringList desiredNicks = coreSession()->identity(e->network()->identity())->nicks();
72     int nextNickIdx = desiredNicks.indexOf(errnick) + 1;
73     QString nextNick;
74     if (nextNickIdx > 0 && desiredNicks.size() > nextNickIdx) {
75         nextNick = desiredNicks[nextNickIdx];
76     }
77     else {
78         if (erroneus) {
79             // FIXME Make this an ErrorEvent or something like that, so it's translated in the client
80             MessageEvent *msgEvent = new MessageEvent(Message::Error, e->network(),
81                 tr("No free and valid nicks in nicklist found. use: /nick <othernick> to continue"),
82                 QString(), QString(), Message::None, e->timestamp());
83             emit newEvent(msgEvent);
84             return;
85         }
86         else {
87             nextNick = errnick + "_";
88         }
89     }
90     // FIXME Use a proper output event for this
91     coreNetwork(e)->putRawLine("NICK " + coreNetwork(e)->encodeServerString(nextNick));
92 }
93
94
95 void CoreSessionEventProcessor::processIrcEventNumeric(IrcEventNumeric *e)
96 {
97     switch (e->number()) {
98     // SASL authentication replies
99     // See: http://ircv3.net/specs/extensions/sasl-3.1.html
100
101     //case 900:  // RPL_LOGGEDIN
102     //case 901:  // RPL_LOGGEDOUT
103     // Don't use 900 or 901 for updating the local hostmask.  Unreal 3.2 gives it as the IP address
104     // even when cloaked.
105     // Every other reply should result in moving on
106     // TODO Handle errors to stop connection if appropriate
107     case 902:  // ERR_NICKLOCKED
108     case 903:  // RPL_SASLSUCCESS
109     case 904:  // ERR_SASLFAIL
110     case 905:  // ERR_SASLTOOLONG
111     case 906:  // ERR_SASLABORTED
112     case 907:  // ERR_SASLALREADY
113         // Move on to the next capability
114         coreNetwork(e)->sendNextCap();
115         break;
116
117     default:
118         break;
119     }
120 }
121
122
123 void CoreSessionEventProcessor::processIrcEventAuthenticate(IrcEvent *e)
124 {
125     if (!checkParamCount(e, 1))
126         return;
127
128     if (e->params().at(0) != "+") {
129         qWarning() << "Invalid AUTHENTICATE" << e;
130         return;
131     }
132
133     CoreNetwork *net = coreNetwork(e);
134
135 #ifdef HAVE_SSL
136     if (net->identityPtr()->sslCert().isNull()) {
137 #endif
138         QString construct = net->saslAccount();
139         construct.append(QChar(QChar::Null));
140         construct.append(net->saslAccount());
141         construct.append(QChar(QChar::Null));
142         construct.append(net->saslPassword());
143         QByteArray saslData = QByteArray(construct.toLatin1().toBase64());
144         saslData.prepend("AUTHENTICATE ");
145         net->putRawLine(saslData);
146 #ifdef HAVE_SSL
147     } else {
148         net->putRawLine("AUTHENTICATE +");
149     }
150 #endif
151 }
152
153 void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e)
154 {
155     // Handle capability negotiation
156     // See: http://ircv3.net/specs/core/capability-negotiation-3.2.html
157     // And: http://ircv3.net/specs/core/capability-negotiation-3.1.html
158     if (e->params().count() >= 3) {
159         CoreNetwork *coreNet = coreNetwork(e);
160         QString capCommand = e->params().at(1).trimmed().toUpper();
161         if (capCommand == "LS" || capCommand == "NEW") {
162             // Either we've gotten a list of capabilities, or new capabilities we may want
163             // Server: CAP * LS * :multi-prefix extended-join account-notify batch invite-notify tls
164             // Server: CAP * LS * :cap-notify server-time example.org/dummy-cap=dummyvalue example.org/second-dummy-cap
165             // Server: CAP * LS :userhost-in-names sasl=EXTERNAL,DH-AES,DH-BLOWFISH,ECDSA-NIST256P-CHALLENGE,PLAIN
166             bool capListFinished;
167             QStringList availableCaps;
168             if (e->params().count() == 4) {
169                 // Middle of multi-line reply, ignore the asterisk
170                 capListFinished = false;
171                 availableCaps = e->params().at(3).split(' ');
172             } else {
173                 // Single line reply
174                 capListFinished = true;
175                 availableCaps = e->params().at(2).split(' ');
176             }
177             // Store what capabilities are available
178             QStringList availableCapPair;
179             for (int i = 0; i < availableCaps.count(); ++i) {
180                 // Capability may include values, e.g. CAP * LS :multi-prefix sasl=EXTERNAL
181                 availableCapPair = availableCaps[i].trimmed().split('=');
182                 if(availableCapPair.count() >= 2) {
183                     coreNet->addCap(availableCapPair.at(0).trimmed().toLower(), availableCapPair.at(1).trimmed());
184                 } else {
185                     coreNet->addCap(availableCapPair.at(0).trimmed().toLower());
186                 }
187             }
188
189             // Begin capability requests when capability listing complete
190             if (capListFinished)
191                 coreNet->beginCapNegotiation();
192         } else if (capCommand == "ACK") {
193             // Server: CAP * ACK :multi-prefix sasl
194             // Got the capability we want, handle as needed.
195             // As only one capability is requested at a time, no need to split
196             QString acceptedCap = e->params().at(2).trimmed().toLower();
197
198             // Mark this cap as accepted
199             coreNet->acknowledgeCap(acceptedCap);
200
201             if (!coreNet->capsRequiringConfiguration.contains(acceptedCap)) {
202                 // Some capabilities (e.g. SASL) require further messages to finish.  If so, do NOT
203                 // send the next capability; it will be handled elsewhere in CoreNetwork.
204                 // Otherwise, move on to the next capability
205                 coreNet->sendNextCap();
206             }
207         } else if (capCommand == "NAK" || capCommand == "DEL") {
208             // Either something went wrong with this capability, or it is no longer supported
209             // > For CAP NAK
210             // Server: CAP * NAK :multi-prefix sasl
211             // > For CAP DEL
212             // Server: :irc.example.com CAP modernclient DEL :multi-prefix sasl
213             // CAP NAK and CAP DEL replies are always single-line
214
215             QStringList removedCaps;
216             removedCaps = e->params().at(2).split(' ');
217
218             // Store what capability was denied or removed
219             QString removedCap;
220             for (int i = 0; i < removedCaps.count(); ++i) {
221                 removedCap = removedCaps[i].trimmed().toLower();
222                 // Mark this cap as removed
223                 coreNet->removeCap(removedCap);
224             }
225
226             if (capCommand == "NAK") {
227                 // Continue negotiation when capability listing complete only if this is the result
228                 // of a denied cap, not a removed cap
229                 coreNet->sendNextCap();
230             }
231         }
232     }
233 }
234
235 /* IRCv3 account-notify
236  * Log in:  ":nick!user@host ACCOUNT accountname"
237  * Log out: ":nick!user@host ACCOUNT *" */
238 void CoreSessionEventProcessor::processIrcEventAccount(IrcEvent *e)
239 {
240     if (!checkParamCount(e, 1))
241         return;
242
243     IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
244     if (ircuser) {
245         // FIXME Keep track of authed user account, requires adding support to ircuser.h/cpp
246         /*
247         if (e->params().at(0) != "*") {
248             // Account logged in
249             qDebug() << "account-notify:" << ircuser->nick() << "logged in to" << e->params().at(0);
250         } else {
251             // Account logged out
252             qDebug() << "account-notify:" << ircuser->nick() << "logged out";
253         }
254         */
255     } else {
256         qDebug() << "Received account-notify data for unknown user" << e->prefix();
257     }
258 }
259
260 /* IRCv3 away-notify - ":nick!user@host AWAY [:message]" */
261 void CoreSessionEventProcessor::processIrcEventAway(IrcEvent *e)
262 {
263     if (!checkParamCount(e, 2))
264         return;
265
266     // Nick is sent as part of parameters in order to split user/server decoding
267     IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
268     if (ircuser) {
269         if (!e->params().at(1).isEmpty()) {
270             ircuser->setAway(true);
271             ircuser->setAwayMessage(e->params().at(1));
272         } else {
273             ircuser->setAway(false);
274         }
275     } else {
276         qDebug() << "Received away-notify data for unknown user" << e->params().at(0);
277     }
278 }
279
280 /* IRCv3 chghost - ":nick!user@host CHGHOST newuser new.host.goes.here" */
281 void CoreSessionEventProcessor::processIrcEventChghost(IrcEvent *e)
282 {
283     if (!checkParamCount(e, 2))
284         return;
285
286     IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
287     if (ircuser) {
288         // Update with new user/hostname information.  setUser/setHost handles checking what
289         // actually changed.
290         ircuser->setUser(e->params().at(0));
291         ircuser->setHost(e->params().at(1));
292     } else {
293         qDebug() << "Received chghost data for unknown user" << e->prefix();
294     }
295 }
296
297 void CoreSessionEventProcessor::processIrcEventInvite(IrcEvent *e)
298 {
299     if (checkParamCount(e, 2)) {
300         e->network()->updateNickFromMask(e->prefix());
301     }
302 }
303
304
305 void CoreSessionEventProcessor::processIrcEventJoin(IrcEvent *e)
306 {
307     if (e->testFlag(EventManager::Fake)) // generated by handleEarlyNetsplitJoin
308         return;
309
310     if (!checkParamCount(e, 1))
311         return;
312
313     CoreNetwork *net = coreNetwork(e);
314     QString channel = e->params()[0];
315     IrcUser *ircuser = net->updateNickFromMask(e->prefix());
316
317     if (net->capEnabled(IrcCap::EXTENDED_JOIN)) {
318         if (!checkParamCount(e, 3))
319             return;
320         // If logged in, :nick!user@host JOIN #channelname accountname :Real Name
321         // If logged out, :nick!user@host JOIN #channelname * :Real Name
322         // See:  http://ircv3.net/specs/extensions/extended-join-3.1.html
323         // FIXME Keep track of authed user account, requires adding support to ircuser.h/cpp
324         ircuser->setRealName(e->params()[2]);
325     }
326     // Else :nick!user@host JOIN #channelname
327
328     bool handledByNetsplit = false;
329     foreach(Netsplit* n, _netsplits.value(e->network())) {
330         handledByNetsplit = n->userJoined(e->prefix(), channel);
331         if (handledByNetsplit)
332             break;
333     }
334
335     // If using away-notify, check new users.  Works around buggy IRC servers
336     // forgetting to send :away messages for users who join channels when away.
337     if (net->capEnabled(IrcCap::AWAY_NOTIFY)) {
338         net->queueAutoWhoOneshot(ircuser->nick());
339     }
340
341     if (!handledByNetsplit)
342         ircuser->joinChannel(channel);
343     else
344         e->setFlag(EventManager::Netsplit);
345
346     if (net->isMe(ircuser)) {
347         net->setChannelJoined(channel);
348         // FIXME use event
349         net->putRawLine(net->serverEncode("MODE " + channel)); // we want to know the modes of the channel we just joined, so we ask politely
350     }
351 }
352
353
354 void CoreSessionEventProcessor::lateProcessIrcEventKick(IrcEvent *e)
355 {
356     if (checkParamCount(e, 2)) {
357         e->network()->updateNickFromMask(e->prefix());
358         IrcUser *victim = e->network()->ircUser(e->params().at(1));
359         if (victim) {
360             victim->partChannel(e->params().at(0));
361             //if(e->network()->isMe(victim)) e->network()->setKickedFromChannel(channel);
362         }
363     }
364 }
365
366
367 void CoreSessionEventProcessor::processIrcEventMode(IrcEvent *e)
368 {
369     if (!checkParamCount(e, 2))
370         return;
371
372     if (e->network()->isChannelName(e->params().first())) {
373         // Channel Modes
374
375         IrcChannel *channel = e->network()->ircChannel(e->params()[0]);
376         if (!channel) {
377             // we received mode information for a channel we're not in. that means probably we've just been kicked out or something like that
378             // anyways: we don't have a place to store the data --> discard the info.
379             return;
380         }
381
382         QString modes = e->params()[1];
383         bool add = true;
384         int paramOffset = 2;
385         for (int c = 0; c < modes.length(); c++) {
386             if (modes[c] == '+') {
387                 add = true;
388                 continue;
389             }
390             if (modes[c] == '-') {
391                 add = false;
392                 continue;
393             }
394
395             if (e->network()->prefixModes().contains(modes[c])) {
396                 // user channel modes (op, voice, etc...)
397                 if (paramOffset < e->params().count()) {
398                     IrcUser *ircUser = e->network()->ircUser(e->params()[paramOffset]);
399                     if (!ircUser) {
400                         qWarning() << Q_FUNC_INFO << "Unknown IrcUser:" << e->params()[paramOffset];
401                     }
402                     else {
403                         if (add) {
404                             bool handledByNetsplit = false;
405                             QHash<QString, Netsplit *> splits = _netsplits.value(e->network());
406                             foreach(Netsplit* n, _netsplits.value(e->network())) {
407                                 handledByNetsplit = n->userAlreadyJoined(ircUser->hostmask(), channel->name());
408                                 if (handledByNetsplit) {
409                                     n->addMode(ircUser->hostmask(), channel->name(), QString(modes[c]));
410                                     break;
411                                 }
412                             }
413                             if (!handledByNetsplit)
414                                 channel->addUserMode(ircUser, QString(modes[c]));
415                         }
416                         else
417                             channel->removeUserMode(ircUser, QString(modes[c]));
418                     }
419                 }
420                 else {
421                     qWarning() << "Received MODE with too few parameters:" << e->params();
422                 }
423                 ++paramOffset;
424             }
425             else {
426                 // regular channel modes
427                 QString value;
428                 Network::ChannelModeType modeType = e->network()->channelModeType(modes[c]);
429                 if (modeType == Network::A_CHANMODE || modeType == Network::B_CHANMODE || (modeType == Network::C_CHANMODE && add)) {
430                     if (paramOffset < e->params().count()) {
431                         value = e->params()[paramOffset];
432                     }
433                     else {
434                         qWarning() << "Received MODE with too few parameters:" << e->params();
435                     }
436                     ++paramOffset;
437                 }
438
439                 if (add)
440                     channel->addChannelMode(modes[c], value);
441                 else
442                     channel->removeChannelMode(modes[c], value);
443             }
444         }
445     }
446     else {
447         // pure User Modes
448         IrcUser *ircUser = e->network()->newIrcUser(e->params().first());
449         QString modeString(e->params()[1]);
450         QString addModes;
451         QString removeModes;
452         bool add = false;
453         for (int c = 0; c < modeString.count(); c++) {
454             if (modeString[c] == '+') {
455                 add = true;
456                 continue;
457             }
458             if (modeString[c] == '-') {
459                 add = false;
460                 continue;
461             }
462             if (add)
463                 addModes += modeString[c];
464             else
465                 removeModes += modeString[c];
466         }
467         if (!addModes.isEmpty())
468             ircUser->addUserModes(addModes);
469         if (!removeModes.isEmpty())
470             ircUser->removeUserModes(removeModes);
471
472         if (e->network()->isMe(ircUser)) {
473             coreNetwork(e)->updatePersistentModes(addModes, removeModes);
474         }
475     }
476 }
477
478
479 void CoreSessionEventProcessor::lateProcessIrcEventNick(IrcEvent *e)
480 {
481     if (checkParamCount(e, 1)) {
482         IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
483         if (!ircuser) {
484             qWarning() << Q_FUNC_INFO << "Unknown IrcUser!";
485             return;
486         }
487         QString newnick = e->params().at(0);
488         QString oldnick = ircuser->nick();
489
490         // the order is cruicial
491         // otherwise the client would rename the buffer, see that the assigned ircuser doesn't match anymore
492         // and remove the ircuser from the querybuffer leading to a wrong on/offline state
493         ircuser->setNick(newnick);
494         coreSession()->renameBuffer(e->networkId(), newnick, oldnick);
495     }
496 }
497
498
499 void CoreSessionEventProcessor::lateProcessIrcEventPart(IrcEvent *e)
500 {
501     if (checkParamCount(e, 1)) {
502         IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
503         if (!ircuser) {
504             qWarning() << Q_FUNC_INFO<< "Unknown IrcUser!";
505             return;
506         }
507         QString channel = e->params().at(0);
508         ircuser->partChannel(channel);
509         if (e->network()->isMe(ircuser))
510             qobject_cast<CoreNetwork *>(e->network())->setChannelParted(channel);
511     }
512 }
513
514
515 void CoreSessionEventProcessor::processIrcEventPing(IrcEvent *e)
516 {
517     QString param = e->params().count() ? e->params().first() : QString();
518     // FIXME use events
519     coreNetwork(e)->putRawLine("PONG " + coreNetwork(e)->serverEncode(param));
520 }
521
522
523 void CoreSessionEventProcessor::processIrcEventPong(IrcEvent *e)
524 {
525     // the server is supposed to send back what we passed as param. and we send a timestamp
526     // but using quote and whatnought one can send arbitrary pings, so we have to do some sanity checks
527     if (checkParamCount(e, 2)) {
528         QString timestamp = e->params().at(1);
529         QTime sendTime = QTime::fromString(timestamp, "hh:mm:ss.zzz");
530         if (sendTime.isValid())
531             e->network()->setLatency(sendTime.msecsTo(QTime::currentTime()) / 2);
532     }
533 }
534
535
536 void CoreSessionEventProcessor::processIrcEventQuit(IrcEvent *e)
537 {
538     IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
539     if (!ircuser)
540         return;
541
542     QString msg;
543     if (e->params().count() > 0)
544         msg = e->params()[0];
545
546     // check if netsplit
547     if (Netsplit::isNetsplit(msg)) {
548         Netsplit *n;
549         if (!_netsplits[e->network()].contains(msg)) {
550             n = new Netsplit(e->network(), this);
551             connect(n, SIGNAL(finished()), this, SLOT(handleNetsplitFinished()));
552             connect(n, SIGNAL(netsplitJoin(Network*, QString, QStringList, QStringList, QString)),
553                 this, SLOT(handleNetsplitJoin(Network*, QString, QStringList, QStringList, QString)));
554             connect(n, SIGNAL(netsplitQuit(Network*, QString, QStringList, QString)),
555                 this, SLOT(handleNetsplitQuit(Network*, QString, QStringList, QString)));
556             connect(n, SIGNAL(earlyJoin(Network*, QString, QStringList, QStringList)),
557                 this, SLOT(handleEarlyNetsplitJoin(Network*, QString, QStringList, QStringList)));
558             _netsplits[e->network()].insert(msg, n);
559         }
560         else {
561             n = _netsplits[e->network()][msg];
562         }
563         // add this user to the netsplit
564         n->userQuit(e->prefix(), ircuser->channels(), msg);
565         e->setFlag(EventManager::Netsplit);
566     }
567     // normal quit is handled in lateProcessIrcEventQuit()
568 }
569
570
571 void CoreSessionEventProcessor::lateProcessIrcEventQuit(IrcEvent *e)
572 {
573     if (e->testFlag(EventManager::Netsplit))
574         return;
575
576     IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
577     if (!ircuser)
578         return;
579
580     ircuser->quit();
581 }
582
583
584 void CoreSessionEventProcessor::processIrcEventTopic(IrcEvent *e)
585 {
586     if (checkParamCount(e, 2)) {
587         e->network()->updateNickFromMask(e->prefix());
588         IrcChannel *channel = e->network()->ircChannel(e->params().at(0));
589         if (channel)
590             channel->setTopic(e->params().at(1));
591     }
592 }
593
594
595 #ifdef HAVE_QCA2
596 void CoreSessionEventProcessor::processKeyEvent(KeyEvent *e)
597 {
598     if (!Cipher::neededFeaturesAvailable()) {
599         emit newEvent(new MessageEvent(Message::Error, e->network(), tr("Unable to perform key exchange, missing qca-ossl plugin."), e->prefix(), e->target(), Message::None, e->timestamp()));
600         return;
601     }
602     CoreNetwork *net = qobject_cast<CoreNetwork*>(e->network());
603     Cipher *c = net->cipher(e->target());
604     if (!c) // happens when there is no CoreIrcChannel for the target (i.e. never?)
605         return;
606
607     if (e->exchangeType() == KeyEvent::Init) {
608         QByteArray pubKey = c->parseInitKeyX(e->key());
609         if (pubKey.isEmpty()) {
610             emit newEvent(new MessageEvent(Message::Error, e->network(), tr("Unable to parse the DH1080_INIT. Key exchange failed."), e->prefix(), e->target(), Message::None, e->timestamp()));
611             return;
612         } else {
613             net->setCipherKey(e->target(), c->key());
614             emit newEvent(new MessageEvent(Message::Info, e->network(), tr("Your key is set and messages will be encrypted."), e->prefix(), e->target(), Message::None, e->timestamp()));
615             QList<QByteArray> p;
616             p << net->serverEncode(e->target()) << net->serverEncode("DH1080_FINISH ")+pubKey;
617             net->putCmd("NOTICE", p);
618         }
619     } else {
620         if (c->parseFinishKeyX(e->key())) {
621             net->setCipherKey(e->target(), c->key());
622             emit newEvent(new MessageEvent(Message::Info, e->network(), tr("Your key is set and messages will be encrypted."), e->prefix(), e->target(), Message::None, e->timestamp()));
623         } else {
624             emit newEvent(new MessageEvent(Message::Info, e->network(), tr("Failed to parse DH1080_FINISH. Key exchange failed."), e->prefix(), e->target(), Message::None, e->timestamp()));
625         }
626     }
627 }
628 #endif
629
630
631 /* RPL_WELCOME */
632 void CoreSessionEventProcessor::processIrcEvent001(IrcEventNumeric *e)
633 {
634     e->network()->setCurrentServer(e->prefix());
635     e->network()->setMyNick(e->target());
636 }
637
638
639 /* RPL_ISUPPORT */
640 // TODO Complete 005 handling, also use sensible defaults for non-sent stuff
641 void CoreSessionEventProcessor::processIrcEvent005(IrcEvent *e)
642 {
643     if (!checkParamCount(e, 1))
644         return;
645
646     QString key, value;
647     for (int i = 0; i < e->params().count() - 1; i++) {
648         QString key = e->params()[i].section("=", 0, 0);
649         QString value = e->params()[i].section("=", 1);
650         e->network()->addSupport(key, value);
651     }
652
653     /* determine our prefixes here to get an accurate result */
654     e->network()->determinePrefixes();
655 }
656
657
658 /* RPL_UMODEIS - "<user_modes> [<user_mode_params>]" */
659 void CoreSessionEventProcessor::processIrcEvent221(IrcEvent *)
660 {
661     // TODO: save information in network object
662 }
663
664
665 /* RPL_STATSCONN - "Highest connection cout: 8000 (7999 clients)" */
666 void CoreSessionEventProcessor::processIrcEvent250(IrcEvent *)
667 {
668     // TODO: save information in network object
669 }
670
671
672 /* RPL_LOCALUSERS - "Current local user: 5024  Max: 7999 */
673 void CoreSessionEventProcessor::processIrcEvent265(IrcEvent *)
674 {
675     // TODO: save information in network object
676 }
677
678
679 /* RPL_GLOBALUSERS - "Current global users: 46093  Max: 47650" */
680 void CoreSessionEventProcessor::processIrcEvent266(IrcEvent *)
681 {
682     // TODO: save information in network object
683 }
684
685
686 /*
687 WHOIS-Message:
688    Replies 311 - 313, 317 - 319 are all replies generated in response to a WHOIS message.
689   and 301 (RPL_AWAY)
690               "<nick> :<away message>"
691 WHO-Message:
692    Replies 352 and 315 paired are used to answer a WHO message.
693
694 WHOWAS-Message:
695    Replies 314 and 369 are responses to a WHOWAS message.
696
697 */
698
699 /* RPL_AWAY - "<nick> :<away message>" */
700 void CoreSessionEventProcessor::processIrcEvent301(IrcEvent *e)
701 {
702     if (!checkParamCount(e, 2))
703         return;
704
705     IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
706     if (ircuser) {
707         ircuser->setAway(true);
708         ircuser->setAwayMessage(e->params().at(1));
709         //ircuser->setLastAwayMessage(now);
710     }
711 }
712
713
714 /* RPL_UNAWAY - ":You are no longer marked as being away" */
715 void CoreSessionEventProcessor::processIrcEvent305(IrcEvent *e)
716 {
717     IrcUser *me = e->network()->me();
718     if (me)
719         me->setAway(false);
720
721     if (e->network()->autoAwayActive()) {
722         e->network()->setAutoAwayActive(false);
723         e->setFlag(EventManager::Silent);
724     }
725 }
726
727
728 /* RPL_NOWAWAY - ":You have been marked as being away" */
729 void CoreSessionEventProcessor::processIrcEvent306(IrcEvent *e)
730 {
731     IrcUser *me = e->network()->me();
732     if (me)
733         me->setAway(true);
734 }
735
736
737 /* RPL_WHOISSERVICE - "<user> is registered nick" */
738 void CoreSessionEventProcessor::processIrcEvent307(IrcEvent *e)
739 {
740     if (!checkParamCount(e, 1))
741         return;
742
743     IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
744     if (ircuser)
745         ircuser->setWhoisServiceReply(e->params().join(" "));
746 }
747
748
749 /* RPL_SUSERHOST - "<user> is available for help." */
750 void CoreSessionEventProcessor::processIrcEvent310(IrcEvent *e)
751 {
752     if (!checkParamCount(e, 1))
753         return;
754
755     IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
756     if (ircuser)
757         ircuser->setSuserHost(e->params().join(" "));
758 }
759
760
761 /*  RPL_WHOISUSER - "<nick> <user> <host> * :<real name>" */
762 void CoreSessionEventProcessor::processIrcEvent311(IrcEvent *e)
763 {
764     if (!checkParamCount(e, 3))
765         return;
766
767     IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
768     if (ircuser) {
769         ircuser->setUser(e->params().at(1));
770         ircuser->setHost(e->params().at(2));
771         ircuser->setRealName(e->params().last());
772     }
773 }
774
775
776 /*  RPL_WHOISSERVER -  "<nick> <server> :<server info>" */
777 void CoreSessionEventProcessor::processIrcEvent312(IrcEvent *e)
778 {
779     if (!checkParamCount(e, 2))
780         return;
781
782     IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
783     if (ircuser)
784         ircuser->setServer(e->params().at(1));
785 }
786
787
788 /*  RPL_WHOISOPERATOR - "<nick> :is an IRC operator" */
789 void CoreSessionEventProcessor::processIrcEvent313(IrcEvent *e)
790 {
791     if (!checkParamCount(e, 1))
792         return;
793
794     IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
795     if (ircuser)
796         ircuser->setIrcOperator(e->params().last());
797 }
798
799
800 /*  RPL_ENDOFWHO: "<name> :End of WHO list" */
801 void CoreSessionEventProcessor::processIrcEvent315(IrcEvent *e)
802 {
803     if (!checkParamCount(e, 1))
804         return;
805
806     if (coreNetwork(e)->setAutoWhoDone(e->params()[0]))
807         e->setFlag(EventManager::Silent);
808 }
809
810
811 /*  RPL_WHOISIDLE - "<nick> <integer> :seconds idle"
812    (real life: "<nick> <integer> <integer> :seconds idle, signon time) */
813 void CoreSessionEventProcessor::processIrcEvent317(IrcEvent *e)
814 {
815     if (!checkParamCount(e, 2))
816         return;
817
818     QDateTime loginTime;
819
820     int idleSecs = e->params()[1].toInt();
821     if (e->params().count() > 3) { // if we have more then 3 params we have the above mentioned "real life" situation
822         int logintime = e->params()[2].toInt();
823         loginTime = QDateTime::fromTime_t(logintime);
824     }
825
826     IrcUser *ircuser = e->network()->ircUser(e->params()[0]);
827     if (ircuser) {
828         ircuser->setIdleTime(e->timestamp().addSecs(-idleSecs));
829         if (loginTime.isValid())
830             ircuser->setLoginTime(loginTime);
831     }
832 }
833
834
835 /* RPL_LIST -  "<channel> <# visible> :<topic>" */
836 void CoreSessionEventProcessor::processIrcEvent322(IrcEvent *e)
837 {
838     if (!checkParamCount(e, 1))
839         return;
840
841     QString channelName;
842     quint32 userCount = 0;
843     QString topic;
844
845     switch (e->params().count()) {
846     case 3:
847         topic = e->params()[2];
848     case 2:
849         userCount = e->params()[1].toUInt();
850     case 1:
851         channelName = e->params()[0];
852     default:
853         break;
854     }
855     if (coreSession()->ircListHelper()->addChannel(e->networkId(), channelName, userCount, topic))
856         e->stop();  // consumed by IrcListHelper, so don't further process/show this event
857 }
858
859
860 /* RPL_LISTEND ":End of LIST" */
861 void CoreSessionEventProcessor::processIrcEvent323(IrcEvent *e)
862 {
863     if (!checkParamCount(e, 1))
864         return;
865
866     if (coreSession()->ircListHelper()->endOfChannelList(e->networkId()))
867         e->stop();  // consumed by IrcListHelper, so don't further process/show this event
868 }
869
870
871 /* RPL_CHANNELMODEIS - "<channel> <mode> <mode params>" */
872 void CoreSessionEventProcessor::processIrcEvent324(IrcEvent *e)
873 {
874     processIrcEventMode(e);
875 }
876
877
878 /* RPL_NOTOPIC */
879 void CoreSessionEventProcessor::processIrcEvent331(IrcEvent *e)
880 {
881     if (!checkParamCount(e, 1))
882         return;
883
884     IrcChannel *chan = e->network()->ircChannel(e->params()[0]);
885     if (chan)
886         chan->setTopic(QString());
887 }
888
889
890 /* RPL_TOPIC */
891 void CoreSessionEventProcessor::processIrcEvent332(IrcEvent *e)
892 {
893     if (!checkParamCount(e, 2))
894         return;
895
896     IrcChannel *chan = e->network()->ircChannel(e->params()[0]);
897     if (chan)
898         chan->setTopic(e->params()[1]);
899 }
900
901
902 /*  RPL_WHOREPLY: "<channel> <user> <host> <server> <nick>
903               ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] :<hopcount> <real name>" */
904 void CoreSessionEventProcessor::processIrcEvent352(IrcEvent *e)
905 {
906     if (!checkParamCount(e, 6))
907         return;
908
909     QString channel = e->params()[0];
910     IrcUser *ircuser = e->network()->ircUser(e->params()[4]);
911     if (ircuser) {
912         ircuser->setUser(e->params()[1]);
913         ircuser->setHost(e->params()[2]);
914
915         bool away = e->params()[5].contains("G", Qt::CaseInsensitive);
916         ircuser->setAway(away);
917         ircuser->setServer(e->params()[3]);
918         ircuser->setRealName(e->params().last().section(" ", 1));
919
920         if (coreNetwork(e)->capEnabled(IrcCap::MULTI_PREFIX)) {
921             // If multi-prefix is enabled, all modes will be sent in WHO replies.
922             // :kenny.chatspike.net 352 guest #test grawity broken.symlink *.chatspike.net grawity H@%+ :0 Mantas M.
923             // See: http://ircv3.net/specs/extensions/multi-prefix-3.1.html
924             QString uncheckedModes = e->params()[5];
925             QString validModes = QString();
926             while (!uncheckedModes.isEmpty()) {
927                 // Mode found in 1 left-most character, add it to the list
928                 if (e->network()->prefixes().contains(uncheckedModes[0])) {
929                     validModes.append(e->network()->prefixToMode(uncheckedModes[0]));
930                 }
931                 // Remove this mode from the list of unchecked modes
932                 uncheckedModes = uncheckedModes.remove(0, 1);
933             }
934
935             // Some IRC servers decide to not follow the spec, returning only -some- of the user
936             // modes in WHO despite listing them all in NAMES.  For now, assume it can only add
937             // and not take away.  *sigh*
938             if (!validModes.isEmpty()) {
939                 if (channel != "*") {
940                     // Channel-specific modes received, apply to given channel only
941                     IrcChannel *ircChan = e->network()->ircChannel(channel);
942                     if (ircChan) {
943                         // Do one mode at a time
944                         // TODO Better way of syncing this without breaking protocol?
945                         for (int i = 0; i < validModes.count(); ++i) {
946                             ircChan->addUserMode(ircuser, validModes.at(i));
947                         }
948                     }
949                 } else {
950                     // Modes apply to the user everywhere
951                     ircuser->addUserModes(validModes);
952                 }
953             }
954         }
955     }
956
957     // Check if channel name has a who in progress.
958     // If not, then check if user nick exists and has a who in progress.
959     if (coreNetwork(e)->isAutoWhoInProgress(channel) ||
960         (ircuser && coreNetwork(e)->isAutoWhoInProgress(ircuser->nick()))) {
961         e->setFlag(EventManager::Silent);
962     }
963 }
964
965
966 /* RPL_NAMREPLY */
967 void CoreSessionEventProcessor::processIrcEvent353(IrcEvent *e)
968 {
969     if (!checkParamCount(e, 3))
970         return;
971
972     // param[0] is either "=", "*" or "@" indicating a public, private or secret channel
973     // we don't use this information at the time beeing
974     QString channelname = e->params()[1];
975
976     IrcChannel *channel = e->network()->ircChannel(channelname);
977     if (!channel) {
978         qWarning() << Q_FUNC_INFO << "Received unknown target channel:" << channelname;
979         return;
980     }
981
982     QStringList nicks;
983     QStringList modes;
984
985     // Cache result of multi-prefix to avoid unneeded casts and lookups with each iteration.
986     bool _useCapMultiPrefix = coreNetwork(e)->capEnabled(IrcCap::MULTI_PREFIX);
987
988     foreach(QString nick, e->params()[2].split(' ', QString::SkipEmptyParts)) {
989         QString mode;
990
991         if (_useCapMultiPrefix) {
992             // If multi-prefix is enabled, all modes will be sent in NAMES replies.
993             // :hades.arpa 353 guest = #tethys :~&@%+aji &@Attila @+alyx +KindOne Argure
994             // See: http://ircv3.net/specs/extensions/multi-prefix-3.1.html
995             while (e->network()->prefixes().contains(nick[0])) {
996                 // Mode found in 1 left-most character, add it to the list.
997                 // Note: sending multiple modes may cause a warning in older clients.
998                 // In testing, the clients still seemed to function fine.
999                 mode.append(e->network()->prefixToMode(nick[0]));
1000                 // Remove this mode from the nick
1001                 nick = nick.remove(0, 1);
1002             }
1003         } else if (e->network()->prefixes().contains(nick[0])) {
1004             // Multi-prefix is disabled and a mode prefix was found.
1005             mode = e->network()->prefixToMode(nick[0]);
1006             nick = nick.mid(1);
1007         }
1008
1009         // If userhost-in-names capability is enabled, the following will be
1010         // in the form "nick!user@host" rather than "nick".  This works without
1011         // special handling as the following use nickFromHost() as needed.
1012         // See: http://ircv3.net/specs/extensions/userhost-in-names-3.2.html
1013
1014         nicks << nick;
1015         modes << mode;
1016     }
1017
1018     channel->joinIrcUsers(nicks, modes);
1019 }
1020
1021
1022 /* ERR_ERRONEUSNICKNAME */
1023 void CoreSessionEventProcessor::processIrcEvent432(IrcEventNumeric *e)
1024 {
1025     if (!checkParamCount(e, 1))
1026         return;
1027
1028     QString errnick;
1029     if (e->params().count() < 2) {
1030         // handle unreal-ircd bug, where unreal ircd doesnt supply a TARGET in ERR_ERRONEUSNICKNAME during registration phase:
1031         // nick @@@
1032         // :irc.scortum.moep.net 432  @@@ :Erroneous Nickname: Illegal characters
1033         // correct server reply:
1034         // :irc.scortum.moep.net 432 * @@@ :Erroneous Nickname: Illegal characters
1035         e->params().prepend(e->target());
1036         e->setTarget("*");
1037     }
1038     errnick = e->params()[0];
1039
1040     tryNextNick(e, errnick, true /* erroneus */);
1041 }
1042
1043
1044 /* ERR_NICKNAMEINUSE */
1045 void CoreSessionEventProcessor::processIrcEvent433(IrcEventNumeric *e)
1046 {
1047     if (!checkParamCount(e, 1))
1048         return;
1049
1050     QString errnick = e->params().first();
1051
1052     // if there is a problem while connecting to the server -> we handle it
1053     // but only if our connection has not been finished yet...
1054     if (!e->network()->currentServer().isEmpty())
1055         return;
1056
1057     tryNextNick(e, errnick);
1058 }
1059
1060
1061 /* ERR_UNAVAILRESOURCE */
1062 void CoreSessionEventProcessor::processIrcEvent437(IrcEventNumeric *e)
1063 {
1064     if (!checkParamCount(e, 1))
1065         return;
1066
1067     QString errnick = e->params().first();
1068
1069     // if there is a problem while connecting to the server -> we handle it
1070     // but only if our connection has not been finished yet...
1071     if (!e->network()->currentServer().isEmpty())
1072         return;
1073
1074     if (!e->network()->isChannelName(errnick))
1075         tryNextNick(e, errnick);
1076 }
1077
1078
1079 /* template
1080 void CoreSessionEventProcessor::processIrcEvent(IrcEvent *e) {
1081   if(!checkParamCount(e, 1))
1082     return;
1083
1084 }
1085 */
1086
1087 /* Handle signals from Netsplit objects  */
1088
1089 void CoreSessionEventProcessor::handleNetsplitJoin(Network *net,
1090     const QString &channel,
1091     const QStringList &users,
1092     const QStringList &modes,
1093     const QString &quitMessage)
1094 {
1095     IrcChannel *ircChannel = net->ircChannel(channel);
1096     if (!ircChannel) {
1097         return;
1098     }
1099     QList<IrcUser *> ircUsers;
1100     QStringList newModes = modes;
1101     QStringList newUsers = users;
1102
1103     foreach(const QString &user, users) {
1104         IrcUser *iu = net->ircUser(nickFromMask(user));
1105         if (iu)
1106             ircUsers.append(iu);
1107         else { // the user already quit
1108             int idx = users.indexOf(user);
1109             newUsers.removeAt(idx);
1110             newModes.removeAt(idx);
1111         }
1112     }
1113
1114     ircChannel->joinIrcUsers(ircUsers, newModes);
1115     NetworkSplitEvent *event = new NetworkSplitEvent(EventManager::NetworkSplitJoin, net, channel, newUsers, quitMessage);
1116     emit newEvent(event);
1117 }
1118
1119
1120 void CoreSessionEventProcessor::handleNetsplitQuit(Network *net, const QString &channel, const QStringList &users, const QString &quitMessage)
1121 {
1122     NetworkSplitEvent *event = new NetworkSplitEvent(EventManager::NetworkSplitQuit, net, channel, users, quitMessage);
1123     emit newEvent(event);
1124     foreach(QString user, users) {
1125         IrcUser *iu = net->ircUser(nickFromMask(user));
1126         if (iu)
1127             iu->quit();
1128     }
1129 }
1130
1131
1132 void CoreSessionEventProcessor::handleEarlyNetsplitJoin(Network *net, const QString &channel, const QStringList &users, const QStringList &modes)
1133 {
1134     IrcChannel *ircChannel = net->ircChannel(channel);
1135     if (!ircChannel) {
1136         qDebug() << "handleEarlyNetsplitJoin(): channel " << channel << " invalid";
1137         return;
1138     }
1139     QList<NetworkEvent *> events;
1140     QList<IrcUser *> ircUsers;
1141     QStringList newModes = modes;
1142
1143     foreach(QString user, users) {
1144         IrcUser *iu = net->updateNickFromMask(user);
1145         if (iu) {
1146             ircUsers.append(iu);
1147             // fake event for scripts that consume join events
1148             events << new IrcEvent(EventManager::IrcEventJoin, net, iu->hostmask(), QStringList() << channel);
1149         }
1150         else {
1151             newModes.removeAt(users.indexOf(user));
1152         }
1153     }
1154     ircChannel->joinIrcUsers(ircUsers, newModes);
1155     foreach(NetworkEvent *event, events) {
1156         event->setFlag(EventManager::Fake); // ignore this in here!
1157         emit newEvent(event);
1158     }
1159 }
1160
1161
1162 void CoreSessionEventProcessor::handleNetsplitFinished()
1163 {
1164     Netsplit *n = qobject_cast<Netsplit *>(sender());
1165     Q_ASSERT(n);
1166     QHash<QString, Netsplit *> splithash  = _netsplits.take(n->network());
1167     splithash.remove(splithash.key(n));
1168     if (splithash.count())
1169         _netsplits[n->network()] = splithash;
1170     n->deleteLater();
1171 }
1172
1173
1174 void CoreSessionEventProcessor::destroyNetsplits(NetworkId netId)
1175 {
1176     Network *net = coreSession()->network(netId);
1177     if (!net)
1178         return;
1179
1180     QHash<QString, Netsplit *> splits = _netsplits.take(net);
1181     qDeleteAll(splits);
1182 }
1183
1184
1185 /*******************************/
1186 /******** CTCP HANDLING ********/
1187 /*******************************/
1188
1189 void CoreSessionEventProcessor::processCtcpEvent(CtcpEvent *e)
1190 {
1191     if (e->testFlag(EventManager::Self))
1192         return;  // ignore ctcp events generated by user input
1193
1194     if (e->type() != EventManager::CtcpEvent || e->ctcpType() != CtcpEvent::Query)
1195         return;
1196
1197     handle(e->ctcpCmd(), Q_ARG(CtcpEvent *, e));
1198 }
1199
1200
1201 void CoreSessionEventProcessor::defaultHandler(const QString &ctcpCmd, CtcpEvent *e)
1202 {
1203     // This handler is only there to avoid warnings for unknown CTCPs
1204     Q_UNUSED(e);
1205     Q_UNUSED(ctcpCmd);
1206 }
1207
1208
1209 void CoreSessionEventProcessor::handleCtcpAction(CtcpEvent *e)
1210 {
1211     // This handler is only there to feed CLIENTINFO
1212     Q_UNUSED(e);
1213 }
1214
1215
1216 void CoreSessionEventProcessor::handleCtcpClientinfo(CtcpEvent *e)
1217 {
1218     QStringList supportedHandlers;
1219     foreach(QString handler, providesHandlers())
1220     supportedHandlers << handler.toUpper();
1221     qSort(supportedHandlers);
1222     e->setReply(supportedHandlers.join(" "));
1223 }
1224
1225
1226 // http://www.irchelp.org/irchelp/rfc/ctcpspec.html
1227 // http://en.wikipedia.org/wiki/Direct_Client-to-Client
1228 void CoreSessionEventProcessor::handleCtcpDcc(CtcpEvent *e)
1229 {
1230     // DCC support is unfinished, experimental and potentially dangerous, so make it opt-in
1231     if (!Quassel::isOptionSet("enable-experimental-dcc")) {
1232         quInfo() << "DCC disabled, start core with --enable-experimental-dcc if you really want to try it out";
1233         return;
1234     }
1235
1236     // normal:  SEND <filename> <ip> <port> [<filesize>]
1237     // reverse: SEND <filename> <ip> 0 <filesize> <token>
1238     QStringList params = e->param().split(' ');
1239     if (params.count()) {
1240         QString cmd = params[0].toUpper();
1241         if (cmd == "SEND") {
1242             if (params.count() < 4) {
1243                 qWarning() << "Invalid DCC SEND request:" << e;  // TODO emit proper error to client
1244                 return;
1245             }
1246             QString filename = params[1];
1247             QHostAddress address;
1248             quint16 port = params[3].toUShort();
1249             quint64 size = 0;
1250             QString numIp = params[2]; // this is either IPv4 as a 32 bit value, or IPv6 (which always contains a colon)
1251             if (numIp.contains(':')) { // IPv6
1252                 if (!address.setAddress(numIp)) {
1253                     qWarning() << "Invalid IPv6:" << numIp;
1254                     return;
1255                 }
1256             }
1257             else {
1258                 address.setAddress(numIp.toUInt());
1259             }
1260
1261             if (port == 0) { // Reverse DCC is indicated by a 0 port
1262                 emit newEvent(new MessageEvent(Message::Error, e->network(), tr("Reverse DCC SEND not supported"), e->prefix(), e->target(), Message::None, e->timestamp()));
1263                 return;
1264             }
1265             if (port < 1024) {
1266                 qWarning() << "Privileged port requested:" << port; // FIXME ask user if this is ok
1267             }
1268
1269
1270             if (params.count() > 4) { // filesize is optional
1271                 size = params[4].toULong();
1272             }
1273
1274             // TODO: check if target is the right thing to use for the partner
1275             CoreTransfer *transfer = new CoreTransfer(Transfer::Direction::Receive, e->target(), filename, address, port, size, this);
1276             coreSession()->signalProxy()->synchronize(transfer);
1277             coreSession()->transferManager()->addTransfer(transfer);
1278         }
1279         else {
1280             emit newEvent(new MessageEvent(Message::Error, e->network(), tr("DCC %1 not supported").arg(cmd), e->prefix(), e->target(), Message::None, e->timestamp()));
1281             return;
1282         }
1283     }
1284 }
1285
1286
1287 void CoreSessionEventProcessor::handleCtcpPing(CtcpEvent *e)
1288 {
1289     e->setReply(e->param().isNull() ? "" : e->param());
1290 }
1291
1292
1293 void CoreSessionEventProcessor::handleCtcpTime(CtcpEvent *e)
1294 {
1295     e->setReply(QDateTime::currentDateTime().toString());
1296 }
1297
1298
1299 void CoreSessionEventProcessor::handleCtcpVersion(CtcpEvent *e)
1300 {
1301     e->setReply(QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org")
1302         .arg(Quassel::buildInfo().plainVersionString).arg(Quassel::buildInfo().commitDate));
1303 }