1 /***************************************************************************
2 * Copyright (C) 2005-2013 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #include "coresessioneventprocessor.h"
23 #include "coreirclisthelper.h"
24 #include "corenetwork.h"
25 #include "coresession.h"
26 #include "ctcpevent.h"
29 #include "messageevent.h"
33 CoreSessionEventProcessor::CoreSessionEventProcessor(CoreSession *session)
34 : BasicHandler("handleCtcp", session),
37 connect(coreSession(), SIGNAL(networkDisconnected(NetworkId)), this, SLOT(destroyNetsplits(NetworkId)));
38 connect(this, SIGNAL(newEvent(Event *)), coreSession()->eventManager(), SLOT(postEvent(Event *)));
42 bool CoreSessionEventProcessor::checkParamCount(IrcEvent *e, int minParams)
44 if (e->params().count() < minParams) {
45 if (e->type() == EventManager::IrcEventNumeric) {
46 qWarning() << "Command " << static_cast<IrcEventNumeric *>(e)->number() << " requires " << minParams << "params, got: " << e->params();
49 QString name = coreSession()->eventManager()->enumName(e->type());
50 qWarning() << qPrintable(name) << "requires" << minParams << "params, got:" << e->params();
59 void CoreSessionEventProcessor::tryNextNick(NetworkEvent *e, const QString &errnick, bool erroneus)
61 QStringList desiredNicks = coreSession()->identity(e->network()->identity())->nicks();
62 int nextNickIdx = desiredNicks.indexOf(errnick) + 1;
64 if (nextNickIdx > 0 && desiredNicks.size() > nextNickIdx) {
65 nextNick = desiredNicks[nextNickIdx];
69 // FIXME Make this an ErrorEvent or something like that, so it's translated in the client
70 MessageEvent *msgEvent = new MessageEvent(Message::Error, e->network(),
71 tr("No free and valid nicks in nicklist found. use: /nick <othernick> to continue"),
72 QString(), QString(), Message::None, e->timestamp());
73 emit newEvent(msgEvent);
77 nextNick = errnick + "_";
80 // FIXME Use a proper output event for this
81 coreNetwork(e)->putRawLine("NICK " + coreNetwork(e)->encodeServerString(nextNick));
85 void CoreSessionEventProcessor::processIrcEventNumeric(IrcEventNumeric *e)
87 switch (e->number()) {
94 qobject_cast<CoreNetwork *>(e->network())->putRawLine("CAP END");
103 void CoreSessionEventProcessor::processIrcEventAuthenticate(IrcEvent *e)
105 if (!checkParamCount(e, 1))
108 if (e->params().at(0) != "+") {
109 qWarning() << "Invalid AUTHENTICATE" << e;
113 CoreNetwork *net = coreNetwork(e);
115 QString construct = net->saslAccount();
116 construct.append(QChar(QChar::Null));
117 construct.append(net->saslAccount());
118 construct.append(QChar(QChar::Null));
119 construct.append(net->saslPassword());
120 QByteArray saslData = QByteArray(construct.toAscii().toBase64());
121 saslData.prepend("AUTHENTICATE ");
122 net->putRawLine(saslData);
126 void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e)
128 // for SASL, there will only be a single param of 'sasl', however you can check here for
129 // additional CAP messages (ls, multi-prefix, et cetera).
131 if (e->params().count() == 3) {
132 if (e->params().at(2).startsWith("sasl")) { // Freenode (at least) sends "sasl " with a trailing space for some reason!
134 coreNetwork(e)->putRawLine(coreNetwork(e)->serverEncode("AUTHENTICATE PLAIN")); // Only working with PLAIN atm, blowfish later
140 void CoreSessionEventProcessor::processIrcEventInvite(IrcEvent *e)
142 if (checkParamCount(e, 2)) {
143 e->network()->updateNickFromMask(e->prefix());
148 void CoreSessionEventProcessor::processIrcEventJoin(IrcEvent *e)
150 if (e->testFlag(EventManager::Fake)) // generated by handleEarlyNetsplitJoin
153 if (!checkParamCount(e, 1))
156 CoreNetwork *net = coreNetwork(e);
157 QString channel = e->params()[0];
158 IrcUser *ircuser = net->updateNickFromMask(e->prefix());
160 bool handledByNetsplit = false;
161 foreach(Netsplit* n, _netsplits.value(e->network())) {
162 handledByNetsplit = n->userJoined(e->prefix(), channel);
163 if (handledByNetsplit)
167 if (!handledByNetsplit)
168 ircuser->joinChannel(channel);
170 e->setFlag(EventManager::Netsplit);
172 if (net->isMe(ircuser)) {
173 net->setChannelJoined(channel);
175 net->putRawLine(net->serverEncode("MODE " + channel)); // we want to know the modes of the channel we just joined, so we ask politely
180 void CoreSessionEventProcessor::lateProcessIrcEventKick(IrcEvent *e)
182 if (checkParamCount(e, 2)) {
183 e->network()->updateNickFromMask(e->prefix());
184 IrcUser *victim = e->network()->ircUser(e->params().at(1));
186 victim->partChannel(e->params().at(0));
187 //if(e->network()->isMe(victim)) e->network()->setKickedFromChannel(channel);
193 void CoreSessionEventProcessor::processIrcEventMode(IrcEvent *e)
195 if (!checkParamCount(e, 2))
198 if (e->network()->isChannelName(e->params().first())) {
201 IrcChannel *channel = e->network()->ircChannel(e->params()[0]);
203 // we received mode information for a channel we're not in. that means probably we've just been kicked out or something like that
204 // anyways: we don't have a place to store the data --> discard the info.
208 QString modes = e->params()[1];
211 for (int c = 0; c < modes.length(); c++) {
212 if (modes[c] == '+') {
216 if (modes[c] == '-') {
221 if (e->network()->prefixModes().contains(modes[c])) {
222 // user channel modes (op, voice, etc...)
223 if (paramOffset < e->params().count()) {
224 IrcUser *ircUser = e->network()->ircUser(e->params()[paramOffset]);
226 qWarning() << Q_FUNC_INFO << "Unknown IrcUser:" << e->params()[paramOffset];
230 bool handledByNetsplit = false;
231 QHash<QString, Netsplit *> splits = _netsplits.value(e->network());
232 foreach(Netsplit* n, _netsplits.value(e->network())) {
233 handledByNetsplit = n->userAlreadyJoined(ircUser->hostmask(), channel->name());
234 if (handledByNetsplit) {
235 n->addMode(ircUser->hostmask(), channel->name(), QString(modes[c]));
239 if (!handledByNetsplit)
240 channel->addUserMode(ircUser, QString(modes[c]));
243 channel->removeUserMode(ircUser, QString(modes[c]));
247 qWarning() << "Received MODE with too few parameters:" << e->params();
252 // regular channel modes
254 Network::ChannelModeType modeType = e->network()->channelModeType(modes[c]);
255 if (modeType == Network::A_CHANMODE || modeType == Network::B_CHANMODE || (modeType == Network::C_CHANMODE && add)) {
256 if (paramOffset < e->params().count()) {
257 value = e->params()[paramOffset];
260 qWarning() << "Received MODE with too few parameters:" << e->params();
266 channel->addChannelMode(modes[c], value);
268 channel->removeChannelMode(modes[c], value);
274 IrcUser *ircUser = e->network()->newIrcUser(e->params().first());
275 QString modeString(e->params()[1]);
279 for (int c = 0; c < modeString.count(); c++) {
280 if (modeString[c] == '+') {
284 if (modeString[c] == '-') {
289 addModes += modeString[c];
291 removeModes += modeString[c];
293 if (!addModes.isEmpty())
294 ircUser->addUserModes(addModes);
295 if (!removeModes.isEmpty())
296 ircUser->removeUserModes(removeModes);
298 if (e->network()->isMe(ircUser)) {
299 coreNetwork(e)->updatePersistentModes(addModes, removeModes);
305 void CoreSessionEventProcessor::lateProcessIrcEventNick(IrcEvent *e)
307 if (checkParamCount(e, 1)) {
308 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
310 qWarning() << Q_FUNC_INFO << "Unknown IrcUser!";
313 QString newnick = e->params().at(0);
314 QString oldnick = ircuser->nick();
316 // the order is cruicial
317 // otherwise the client would rename the buffer, see that the assigned ircuser doesn't match anymore
318 // and remove the ircuser from the querybuffer leading to a wrong on/offline state
319 ircuser->setNick(newnick);
320 coreSession()->renameBuffer(e->networkId(), newnick, oldnick);
325 void CoreSessionEventProcessor::lateProcessIrcEventPart(IrcEvent *e)
327 if (checkParamCount(e, 1)) {
328 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
330 qWarning() << Q_FUNC_INFO<< "Unknown IrcUser!";
333 QString channel = e->params().at(0);
334 ircuser->partChannel(channel);
335 if (e->network()->isMe(ircuser))
336 qobject_cast<CoreNetwork *>(e->network())->setChannelParted(channel);
341 void CoreSessionEventProcessor::processIrcEventPing(IrcEvent *e)
343 QString param = e->params().count() ? e->params().first() : QString();
345 coreNetwork(e)->putRawLine("PONG " + coreNetwork(e)->serverEncode(param));
349 void CoreSessionEventProcessor::processIrcEventPong(IrcEvent *e)
351 // the server is supposed to send back what we passed as param. and we send a timestamp
352 // but using quote and whatnought one can send arbitrary pings, so we have to do some sanity checks
353 if (checkParamCount(e, 2)) {
354 QString timestamp = e->params().at(1);
355 QTime sendTime = QTime::fromString(timestamp, "hh:mm:ss.zzz");
356 if (sendTime.isValid())
357 e->network()->setLatency(sendTime.msecsTo(QTime::currentTime()) / 2);
362 void CoreSessionEventProcessor::processIrcEventQuit(IrcEvent *e)
364 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
369 if (e->params().count() > 0)
370 msg = e->params()[0];
373 if (Netsplit::isNetsplit(msg)) {
375 if (!_netsplits[e->network()].contains(msg)) {
376 n = new Netsplit(e->network(), this);
377 connect(n, SIGNAL(finished()), this, SLOT(handleNetsplitFinished()));
378 connect(n, SIGNAL(netsplitJoin(Network*, QString, QStringList, QStringList, QString)),
379 this, SLOT(handleNetsplitJoin(Network*, QString, QStringList, QStringList, QString)));
380 connect(n, SIGNAL(netsplitQuit(Network*, QString, QStringList, QString)),
381 this, SLOT(handleNetsplitQuit(Network*, QString, QStringList, QString)));
382 connect(n, SIGNAL(earlyJoin(Network*, QString, QStringList, QStringList)),
383 this, SLOT(handleEarlyNetsplitJoin(Network*, QString, QStringList, QStringList)));
384 _netsplits[e->network()].insert(msg, n);
387 n = _netsplits[e->network()][msg];
389 // add this user to the netsplit
390 n->userQuit(e->prefix(), ircuser->channels(), msg);
391 e->setFlag(EventManager::Netsplit);
393 // normal quit is handled in lateProcessIrcEventQuit()
397 void CoreSessionEventProcessor::lateProcessIrcEventQuit(IrcEvent *e)
399 if (e->testFlag(EventManager::Netsplit))
402 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
410 void CoreSessionEventProcessor::processIrcEventTopic(IrcEvent *e)
412 if (checkParamCount(e, 2)) {
413 e->network()->updateNickFromMask(e->prefix());
414 IrcChannel *channel = e->network()->ircChannel(e->params().at(0));
416 channel->setTopic(e->params().at(1));
422 void CoreSessionEventProcessor::processIrcEvent001(IrcEvent *e)
424 if (!checkParamCount(e, 1))
427 QString myhostmask = e->params().at(0).section(' ', -1, -1);
428 e->network()->setCurrentServer(e->prefix());
429 e->network()->setMyNick(nickFromMask(myhostmask));
434 // TODO Complete 005 handling, also use sensible defaults for non-sent stuff
435 void CoreSessionEventProcessor::processIrcEvent005(IrcEvent *e)
437 if (!checkParamCount(e, 1))
441 for (int i = 0; i < e->params().count() - 1; i++) {
442 QString key = e->params()[i].section("=", 0, 0);
443 QString value = e->params()[i].section("=", 1);
444 e->network()->addSupport(key, value);
447 /* determine our prefixes here to get an accurate result */
448 e->network()->determinePrefixes();
452 /* RPL_UMODEIS - "<user_modes> [<user_mode_params>]" */
453 void CoreSessionEventProcessor::processIrcEvent221(IrcEvent *)
455 // TODO: save information in network object
459 /* RPL_STATSCONN - "Highest connection cout: 8000 (7999 clients)" */
460 void CoreSessionEventProcessor::processIrcEvent250(IrcEvent *)
462 // TODO: save information in network object
466 /* RPL_LOCALUSERS - "Current local user: 5024 Max: 7999 */
467 void CoreSessionEventProcessor::processIrcEvent265(IrcEvent *)
469 // TODO: save information in network object
473 /* RPL_GLOBALUSERS - "Current global users: 46093 Max: 47650" */
474 void CoreSessionEventProcessor::processIrcEvent266(IrcEvent *)
476 // TODO: save information in network object
482 Replies 311 - 313, 317 - 319 are all replies generated in response to a WHOIS message.
484 "<nick> :<away message>"
486 Replies 352 and 315 paired are used to answer a WHO message.
489 Replies 314 and 369 are responses to a WHOWAS message.
493 /* RPL_AWAY - "<nick> :<away message>" */
494 void CoreSessionEventProcessor::processIrcEvent301(IrcEvent *e)
496 if (!checkParamCount(e, 2))
499 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
501 ircuser->setAway(true);
502 ircuser->setAwayMessage(e->params().at(1));
503 //ircuser->setLastAwayMessage(now);
508 /* RPL_UNAWAY - ":You are no longer marked as being away" */
509 void CoreSessionEventProcessor::processIrcEvent305(IrcEvent *e)
511 IrcUser *me = e->network()->me();
515 if (e->network()->autoAwayActive()) {
516 e->network()->setAutoAwayActive(false);
517 e->setFlag(EventManager::Silent);
522 /* RPL_NOWAWAY - ":You have been marked as being away" */
523 void CoreSessionEventProcessor::processIrcEvent306(IrcEvent *e)
525 IrcUser *me = e->network()->me();
531 /* RPL_WHOISSERVICE - "<user> is registered nick" */
532 void CoreSessionEventProcessor::processIrcEvent307(IrcEvent *e)
534 if (!checkParamCount(e, 1))
537 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
539 ircuser->setWhoisServiceReply(e->params().join(" "));
543 /* RPL_SUSERHOST - "<user> is available for help." */
544 void CoreSessionEventProcessor::processIrcEvent310(IrcEvent *e)
546 if (!checkParamCount(e, 1))
549 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
551 ircuser->setSuserHost(e->params().join(" "));
555 /* RPL_WHOISUSER - "<nick> <user> <host> * :<real name>" */
556 void CoreSessionEventProcessor::processIrcEvent311(IrcEvent *e)
558 if (!checkParamCount(e, 3))
561 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
563 ircuser->setUser(e->params().at(1));
564 ircuser->setHost(e->params().at(2));
565 ircuser->setRealName(e->params().last());
570 /* RPL_WHOISSERVER - "<nick> <server> :<server info>" */
571 void CoreSessionEventProcessor::processIrcEvent312(IrcEvent *e)
573 if (!checkParamCount(e, 2))
576 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
578 ircuser->setServer(e->params().at(1));
582 /* RPL_WHOISOPERATOR - "<nick> :is an IRC operator" */
583 void CoreSessionEventProcessor::processIrcEvent313(IrcEvent *e)
585 if (!checkParamCount(e, 1))
588 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
590 ircuser->setIrcOperator(e->params().last());
594 /* RPL_ENDOFWHO: "<name> :End of WHO list" */
595 void CoreSessionEventProcessor::processIrcEvent315(IrcEvent *e)
597 if (!checkParamCount(e, 1))
600 if (coreNetwork(e)->setAutoWhoDone(e->params()[0]))
601 e->setFlag(EventManager::Silent);
605 /* RPL_WHOISIDLE - "<nick> <integer> :seconds idle"
606 (real life: "<nick> <integer> <integer> :seconds idle, signon time) */
607 void CoreSessionEventProcessor::processIrcEvent317(IrcEvent *e)
609 if (!checkParamCount(e, 2))
614 int idleSecs = e->params()[1].toInt();
615 if (e->params().count() > 3) { // if we have more then 3 params we have the above mentioned "real life" situation
616 int logintime = e->params()[2].toInt();
617 loginTime = QDateTime::fromTime_t(logintime);
620 IrcUser *ircuser = e->network()->ircUser(e->params()[0]);
622 ircuser->setIdleTime(e->timestamp().addSecs(-idleSecs));
623 if (loginTime.isValid())
624 ircuser->setLoginTime(loginTime);
629 /* RPL_LIST - "<channel> <# visible> :<topic>" */
630 void CoreSessionEventProcessor::processIrcEvent322(IrcEvent *e)
632 if (!checkParamCount(e, 1))
636 quint32 userCount = 0;
639 switch (e->params().count()) {
641 topic = e->params()[2];
643 userCount = e->params()[1].toUInt();
645 channelName = e->params()[0];
649 if (coreSession()->ircListHelper()->addChannel(e->networkId(), channelName, userCount, topic))
650 e->stop(); // consumed by IrcListHelper, so don't further process/show this event
654 /* RPL_LISTEND ":End of LIST" */
655 void CoreSessionEventProcessor::processIrcEvent323(IrcEvent *e)
657 if (!checkParamCount(e, 1))
660 if (coreSession()->ircListHelper()->endOfChannelList(e->networkId()))
661 e->stop(); // consumed by IrcListHelper, so don't further process/show this event
665 /* RPL_CHANNELMODEIS - "<channel> <mode> <mode params>" */
666 void CoreSessionEventProcessor::processIrcEvent324(IrcEvent *e)
668 processIrcEventMode(e);
673 void CoreSessionEventProcessor::processIrcEvent331(IrcEvent *e)
675 if (!checkParamCount(e, 1))
678 IrcChannel *chan = e->network()->ircChannel(e->params()[0]);
680 chan->setTopic(QString());
685 void CoreSessionEventProcessor::processIrcEvent332(IrcEvent *e)
687 if (!checkParamCount(e, 2))
690 IrcChannel *chan = e->network()->ircChannel(e->params()[0]);
692 chan->setTopic(e->params()[1]);
696 /* RPL_WHOREPLY: "<channel> <user> <host> <server> <nick>
697 ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] :<hopcount> <real name>" */
698 void CoreSessionEventProcessor::processIrcEvent352(IrcEvent *e)
700 if (!checkParamCount(e, 6))
703 QString channel = e->params()[0];
704 IrcUser *ircuser = e->network()->ircUser(e->params()[4]);
706 ircuser->setUser(e->params()[1]);
707 ircuser->setHost(e->params()[2]);
709 bool away = e->params()[5].startsWith("G");
710 ircuser->setAway(away);
711 ircuser->setServer(e->params()[3]);
712 ircuser->setRealName(e->params().last().section(" ", 1));
715 if (coreNetwork(e)->isAutoWhoInProgress(channel))
716 e->setFlag(EventManager::Silent);
721 void CoreSessionEventProcessor::processIrcEvent353(IrcEvent *e)
723 if (!checkParamCount(e, 3))
726 // param[0] is either "=", "*" or "@" indicating a public, private or secret channel
727 // we don't use this information at the time beeing
728 QString channelname = e->params()[1];
730 IrcChannel *channel = e->network()->ircChannel(channelname);
732 qWarning() << Q_FUNC_INFO << "Received unknown target channel:" << channelname;
739 foreach(QString nick, e->params()[2].split(' ')) {
742 if (e->network()->prefixes().contains(nick[0])) {
743 mode = e->network()->prefixToMode(nick[0]);
751 channel->joinIrcUsers(nicks, modes);
755 /* ERR_ERRONEUSNICKNAME */
756 void CoreSessionEventProcessor::processIrcEvent432(IrcEventNumeric *e)
758 if (!checkParamCount(e, 1))
762 if (e->params().count() < 2) {
763 // handle unreal-ircd bug, where unreal ircd doesnt supply a TARGET in ERR_ERRONEUSNICKNAME during registration phase:
765 // :irc.scortum.moep.net 432 @@@ :Erroneous Nickname: Illegal characters
766 // correct server reply:
767 // :irc.scortum.moep.net 432 * @@@ :Erroneous Nickname: Illegal characters
768 e->params().prepend(e->target());
771 errnick = e->params()[0];
773 tryNextNick(e, errnick, true /* erroneus */);
777 /* ERR_NICKNAMEINUSE */
778 void CoreSessionEventProcessor::processIrcEvent433(IrcEventNumeric *e)
780 if (!checkParamCount(e, 1))
783 QString errnick = e->params().first();
785 // if there is a problem while connecting to the server -> we handle it
786 // but only if our connection has not been finished yet...
787 if (!e->network()->currentServer().isEmpty())
790 tryNextNick(e, errnick);
794 /* ERR_UNAVAILRESOURCE */
795 void CoreSessionEventProcessor::processIrcEvent437(IrcEventNumeric *e)
797 if (!checkParamCount(e, 1))
800 QString errnick = e->params().first();
802 // if there is a problem while connecting to the server -> we handle it
803 // but only if our connection has not been finished yet...
804 if (!e->network()->currentServer().isEmpty())
807 if (!e->network()->isChannelName(errnick))
808 tryNextNick(e, errnick);
813 void CoreSessionEventProcessor::processIrcEvent(IrcEvent *e) {
814 if(!checkParamCount(e, 1))
820 /* Handle signals from Netsplit objects */
822 void CoreSessionEventProcessor::handleNetsplitJoin(Network *net,
823 const QString &channel,
824 const QStringList &users,
825 const QStringList &modes,
826 const QString &quitMessage)
828 IrcChannel *ircChannel = net->ircChannel(channel);
832 QList<IrcUser *> ircUsers;
833 QStringList newModes = modes;
834 QStringList newUsers = users;
836 foreach(const QString &user, users) {
837 IrcUser *iu = net->ircUser(nickFromMask(user));
840 else { // the user already quit
841 int idx = users.indexOf(user);
842 newUsers.removeAt(idx);
843 newModes.removeAt(idx);
847 ircChannel->joinIrcUsers(ircUsers, newModes);
848 NetworkSplitEvent *event = new NetworkSplitEvent(EventManager::NetworkSplitJoin, net, channel, newUsers, quitMessage);
849 emit newEvent(event);
853 void CoreSessionEventProcessor::handleNetsplitQuit(Network *net, const QString &channel, const QStringList &users, const QString &quitMessage)
855 NetworkSplitEvent *event = new NetworkSplitEvent(EventManager::NetworkSplitQuit, net, channel, users, quitMessage);
856 emit newEvent(event);
857 foreach(QString user, users) {
858 IrcUser *iu = net->ircUser(nickFromMask(user));
865 void CoreSessionEventProcessor::handleEarlyNetsplitJoin(Network *net, const QString &channel, const QStringList &users, const QStringList &modes)
867 IrcChannel *ircChannel = net->ircChannel(channel);
869 qDebug() << "handleEarlyNetsplitJoin(): channel " << channel << " invalid";
872 QList<NetworkEvent *> events;
873 QList<IrcUser *> ircUsers;
874 QStringList newModes = modes;
876 foreach(QString user, users) {
877 IrcUser *iu = net->updateNickFromMask(user);
880 // fake event for scripts that consume join events
881 events << new IrcEvent(EventManager::IrcEventJoin, net, iu->hostmask(), QStringList() << channel);
884 newModes.removeAt(users.indexOf(user));
887 ircChannel->joinIrcUsers(ircUsers, newModes);
888 foreach(NetworkEvent *event, events) {
889 event->setFlag(EventManager::Fake); // ignore this in here!
890 emit newEvent(event);
895 void CoreSessionEventProcessor::handleNetsplitFinished()
897 Netsplit *n = qobject_cast<Netsplit *>(sender());
899 QHash<QString, Netsplit *> splithash = _netsplits.take(n->network());
900 splithash.remove(splithash.key(n));
901 if (splithash.count())
902 _netsplits[n->network()] = splithash;
907 void CoreSessionEventProcessor::destroyNetsplits(NetworkId netId)
909 Network *net = coreSession()->network(netId);
913 QHash<QString, Netsplit *> splits = _netsplits.take(net);
918 /*******************************/
919 /******** CTCP HANDLING ********/
920 /*******************************/
922 void CoreSessionEventProcessor::processCtcpEvent(CtcpEvent *e)
924 if (e->testFlag(EventManager::Self))
925 return; // ignore ctcp events generated by user input
927 if (e->type() != EventManager::CtcpEvent || e->ctcpType() != CtcpEvent::Query)
930 handle(e->ctcpCmd(), Q_ARG(CtcpEvent *, e));
934 void CoreSessionEventProcessor::defaultHandler(const QString &ctcpCmd, CtcpEvent *e)
936 // This handler is only there to avoid warnings for unknown CTCPs
942 void CoreSessionEventProcessor::handleCtcpAction(CtcpEvent *e)
944 // This handler is only there to feed CLIENTINFO
949 void CoreSessionEventProcessor::handleCtcpClientinfo(CtcpEvent *e)
951 QStringList supportedHandlers;
952 foreach(QString handler, providesHandlers())
953 supportedHandlers << handler.toUpper();
954 qSort(supportedHandlers);
955 e->setReply(supportedHandlers.join(" "));
959 void CoreSessionEventProcessor::handleCtcpPing(CtcpEvent *e)
961 e->setReply(e->param());
965 void CoreSessionEventProcessor::handleCtcpTime(CtcpEvent *e)
967 e->setReply(QDateTime::currentDateTime().toString());
971 void CoreSessionEventProcessor::handleCtcpVersion(CtcpEvent *e)
973 e->setReply(QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org")
974 .arg(Quassel::buildInfo().plainVersionString).arg(Quassel::buildInfo().buildDate));