1 /***************************************************************************
2 * Copyright (C) 2005-2010 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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)));
40 bool CoreSessionEventProcessor::checkParamCount(IrcEvent *e, int minParams) {
41 if(e->params().count() < minParams) {
42 if(e->type() == EventManager::IrcEventNumeric) {
43 qWarning() << "Command " << static_cast<IrcEventNumeric *>(e)->number() << " requires " << minParams << "params, got: " << e->params();
45 QString name = coreSession()->eventManager()->enumName(e->type());
46 qWarning() << qPrintable(name) << "requires" << minParams << "params, got:" << e->params();
54 void CoreSessionEventProcessor::tryNextNick(NetworkEvent *e, const QString &errnick, bool erroneus) {
55 QStringList desiredNicks = coreSession()->identity(e->network()->identity())->nicks();
56 int nextNickIdx = desiredNicks.indexOf(errnick) + 1;
58 if(nextNickIdx > 0 && desiredNicks.size() > nextNickIdx) {
59 nextNick = desiredNicks[nextNickIdx];
62 // FIXME Make this an ErrorEvent or something like that, so it's translated in the client
63 MessageEvent *msgEvent = new MessageEvent(Message::Error, e->network(),
64 tr("No free and valid nicks in nicklist found. use: /nick <othernick> to continue"),
65 QString(), QString(), Message::None, e->timestamp());
66 coreSession()->eventManager()->sendEvent(msgEvent);
69 nextNick = errnick + "_";
72 // FIXME Use a proper output event for this
73 coreNetwork(e)->putRawLine("NICK " + coreNetwork(e)->encodeServerString(nextNick));
76 void CoreSessionEventProcessor::processIrcEventNumeric(IrcEventNumeric *e) {
80 case 903: case 904: case 905: case 906: case 907:
81 qobject_cast<CoreNetwork *>(e->network())->putRawLine("CAP END");
89 void CoreSessionEventProcessor::processIrcEventAuthenticate(IrcEvent *e) {
90 if(!checkParamCount(e, 1))
93 if(e->params().at(0) != "+") {
94 qWarning() << "Invalid AUTHENTICATE" << e;
98 CoreNetwork *net = coreNetwork(e);
100 QString construct = net->saslAccount();
101 construct.append(QChar(QChar::Null));
102 construct.append(net->saslAccount());
103 construct.append(QChar(QChar::Null));
104 construct.append(net->saslPassword());
105 QByteArray saslData = QByteArray(construct.toAscii().toBase64());
106 saslData.prepend("AUTHENTICATE ");
107 net->putRawLine(saslData);
110 void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e) {
111 // for SASL, there will only be a single param of 'sasl', however you can check here for
112 // additional CAP messages (ls, multi-prefix, et cetera).
114 if(e->params().count() == 3) {
115 if(e->params().at(2) == "sasl") {
117 coreNetwork(e)->putRawLine(coreNetwork(e)->serverEncode("AUTHENTICATE PLAIN")); // Only working with PLAIN atm, blowfish later
122 void CoreSessionEventProcessor::processIrcEventInvite(IrcEvent *e) {
123 if(checkParamCount(e, 2)) {
124 e->network()->updateNickFromMask(e->prefix());
128 void CoreSessionEventProcessor::processIrcEventJoin(IrcEvent *e) {
129 if(e->testFlag(EventManager::Fake)) // generated by handleEarlyNetsplitJoin
132 if(!checkParamCount(e, 1))
135 CoreNetwork *net = coreNetwork(e);
136 QString channel = e->params()[0];
137 IrcUser *ircuser = net->updateNickFromMask(e->prefix());
139 bool handledByNetsplit = false;
140 foreach(Netsplit* n, _netsplits.value(e->network())) {
141 handledByNetsplit = n->userJoined(e->prefix(), channel);
142 if(handledByNetsplit)
146 if(!handledByNetsplit)
147 ircuser->joinChannel(channel);
149 e->setFlag(EventManager::Netsplit);
151 if(net->isMe(ircuser)) {
152 net->setChannelJoined(channel);
154 net->putRawLine(net->serverEncode("MODE " + channel)); // we want to know the modes of the channel we just joined, so we ask politely
158 void CoreSessionEventProcessor::lateProcessIrcEventKick(IrcEvent *e) {
159 if(checkParamCount(e, 2)) {
160 e->network()->updateNickFromMask(e->prefix());
161 IrcUser *victim = e->network()->ircUser(e->params().at(1));
163 victim->partChannel(e->params().at(0));
164 //if(e->network()->isMe(victim)) e->network()->setKickedFromChannel(channel);
169 void CoreSessionEventProcessor::processIrcEventMode(IrcEvent *e) {
170 if(!checkParamCount(e, 2))
173 if(e->network()->isChannelName(e->params().first())) {
176 IrcChannel *channel = e->network()->ircChannel(e->params()[0]);
178 // we received mode information for a channel we're not in. that means probably we've just been kicked out or something like that
179 // anyways: we don't have a place to store the data --> discard the info.
183 QString modes = e->params()[1];
186 for(int c = 0; c < modes.length(); c++) {
187 if(modes[c] == '+') {
191 if(modes[c] == '-') {
196 if(e->network()->prefixModes().contains(modes[c])) {
197 // user channel modes (op, voice, etc...)
198 if(paramOffset < e->params().count()) {
199 IrcUser *ircUser = e->network()->ircUser(e->params()[paramOffset]);
201 qWarning() << Q_FUNC_INFO << "Unknown IrcUser:" << e->params()[paramOffset];
204 bool handledByNetsplit = false;
205 QHash<QString, Netsplit *> splits = _netsplits.value(e->network());
206 foreach(Netsplit* n, _netsplits.value(e->network())) {
207 handledByNetsplit = n->userAlreadyJoined(ircUser->hostmask(), channel->name());
208 if(handledByNetsplit) {
209 n->addMode(ircUser->hostmask(), channel->name(), QString(modes[c]));
213 if(!handledByNetsplit)
214 channel->addUserMode(ircUser, QString(modes[c]));
217 channel->removeUserMode(ircUser, QString(modes[c]));
220 qWarning() << "Received MODE with too few parameters:" << e->params();
224 // regular channel modes
226 Network::ChannelModeType modeType = e->network()->channelModeType(modes[c]);
227 if(modeType == Network::A_CHANMODE || modeType == Network::B_CHANMODE || (modeType == Network::C_CHANMODE && add)) {
228 if(paramOffset < e->params().count()) {
229 value = e->params()[paramOffset];
231 qWarning() << "Received MODE with too few parameters:" << e->params();
237 channel->addChannelMode(modes[c], value);
239 channel->removeChannelMode(modes[c], value);
245 IrcUser *ircUser = e->network()->newIrcUser(e->params().first());
246 QString modeString(e->params()[1]);
250 for(int c = 0; c < modeString.count(); c++) {
251 if(modeString[c] == '+') {
255 if(modeString[c] == '-') {
260 addModes += modeString[c];
262 removeModes += modeString[c];
264 if(!addModes.isEmpty())
265 ircUser->addUserModes(addModes);
266 if(!removeModes.isEmpty())
267 ircUser->removeUserModes(removeModes);
269 if(e->network()->isMe(ircUser)) {
270 coreNetwork(e)->updatePersistentModes(addModes, removeModes);
275 void CoreSessionEventProcessor::lateProcessIrcEventNick(IrcEvent *e) {
276 if(checkParamCount(e, 1)) {
277 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
279 qWarning() << Q_FUNC_INFO << "Unknown IrcUser!";
282 QString newnick = e->params().at(0);
283 QString oldnick = ircuser->nick();
285 // the order is cruicial
286 // otherwise the client would rename the buffer, see that the assigned ircuser doesn't match anymore
287 // and remove the ircuser from the querybuffer leading to a wrong on/offline state
288 ircuser->setNick(newnick);
289 coreSession()->renameBuffer(e->networkId(), newnick, oldnick);
293 void CoreSessionEventProcessor::lateProcessIrcEventPart(IrcEvent *e) {
294 if(checkParamCount(e, 1)) {
295 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
297 qWarning() << Q_FUNC_INFO<< "Unknown IrcUser!";
300 QString channel = e->params().at(0);
301 ircuser->partChannel(channel);
302 if(e->network()->isMe(ircuser))
303 qobject_cast<CoreNetwork *>(e->network())->setChannelParted(channel);
307 void CoreSessionEventProcessor::processIrcEventPing(IrcEvent *e) {
308 QString param = e->params().count()? e->params().first() : QString();
310 coreNetwork(e)->putRawLine("PONG " + coreNetwork(e)->serverEncode(param));
313 void CoreSessionEventProcessor::processIrcEventPong(IrcEvent *e) {
314 // the server is supposed to send back what we passed as param. and we send a timestamp
315 // but using quote and whatnought one can send arbitrary pings, so we have to do some sanity checks
316 if(checkParamCount(e, 2)) {
317 QString timestamp = e->params().at(1);
318 QTime sendTime = QTime::fromString(timestamp, "hh:mm:ss.zzz");
319 if(sendTime.isValid())
320 e->network()->setLatency(sendTime.msecsTo(QTime::currentTime()) / 2);
324 void CoreSessionEventProcessor::processIrcEventQuit(IrcEvent *e) {
325 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
330 if(e->params().count() > 0)
331 msg = e->params()[0];
334 if(Netsplit::isNetsplit(msg)) {
336 if(!_netsplits[e->network()].contains(msg)) {
337 n = new Netsplit(e->network(), this);
338 connect(n, SIGNAL(finished()), this, SLOT(handleNetsplitFinished()));
339 connect(n, SIGNAL(netsplitJoin(Network*,QString,QStringList,QStringList,QString)),
340 this, SLOT(handleNetsplitJoin(Network*,QString,QStringList,QStringList,QString)));
341 connect(n, SIGNAL(netsplitQuit(Network*,QString,QStringList,QString)),
342 this, SLOT(handleNetsplitQuit(Network*,QString,QStringList,QString)));
343 connect(n, SIGNAL(earlyJoin(Network*,QString,QStringList,QStringList)),
344 this, SLOT(handleEarlyNetsplitJoin(Network*,QString,QStringList,QStringList)));
345 _netsplits[e->network()].insert(msg, n);
348 n = _netsplits[e->network()][msg];
350 // add this user to the netsplit
351 n->userQuit(e->prefix(), ircuser->channels(), msg);
352 e->setFlag(EventManager::Netsplit);
354 // normal quit is handled in lateProcessIrcEventQuit()
357 void CoreSessionEventProcessor::lateProcessIrcEventQuit(IrcEvent *e) {
358 if(e->testFlag(EventManager::Netsplit))
361 IrcUser *ircuser = e->network()->updateNickFromMask(e->prefix());
368 void CoreSessionEventProcessor::processIrcEventTopic(IrcEvent *e) {
369 if(checkParamCount(e, 2)) {
370 e->network()->updateNickFromMask(e->prefix());
371 IrcChannel *channel = e->network()->ircChannel(e->params().at(0));
373 channel->setTopic(e->params().at(1));
378 void CoreSessionEventProcessor::processIrcEvent001(IrcEvent *e) {
379 if(!checkParamCount(e, 1))
382 QString myhostmask = e->params().at(0).section(' ', -1, -1);
383 e->network()->setCurrentServer(e->prefix());
384 e->network()->setMyNick(nickFromMask(myhostmask));
388 // TODO Complete 005 handling, also use sensible defaults for non-sent stuff
389 void CoreSessionEventProcessor::processIrcEvent005(IrcEvent *e) {
390 if(!checkParamCount(e, 1))
394 for(int i = 0; i < e->params().count() - 1; i++) {
395 QString key = e->params()[i].section("=", 0, 0);
396 QString value = e->params()[i].section("=", 1);
397 e->network()->addSupport(key, value);
400 /* determine our prefixes here to get an accurate result */
401 e->network()->determinePrefixes();
404 /* RPL_UMODEIS - "<user_modes> [<user_mode_params>]" */
405 void CoreSessionEventProcessor::processIrcEvent221(IrcEvent *) {
406 // TODO: save information in network object
409 /* RPL_STATSCONN - "Highest connection cout: 8000 (7999 clients)" */
410 void CoreSessionEventProcessor::processIrcEvent250(IrcEvent *) {
411 // TODO: save information in network object
414 /* RPL_LOCALUSERS - "Current local user: 5024 Max: 7999 */
415 void CoreSessionEventProcessor::processIrcEvent265(IrcEvent *) {
416 // TODO: save information in network object
419 /* RPL_GLOBALUSERS - "Current global users: 46093 Max: 47650" */
420 void CoreSessionEventProcessor::processIrcEvent266(IrcEvent *) {
421 // TODO: save information in network object
426 Replies 311 - 313, 317 - 319 are all replies generated in response to a WHOIS message.
428 "<nick> :<away message>"
430 Replies 352 and 315 paired are used to answer a WHO message.
433 Replies 314 and 369 are responses to a WHOWAS message.
437 /* RPL_AWAY - "<nick> :<away message>" */
438 void CoreSessionEventProcessor::processIrcEvent301(IrcEvent *e) {
439 if(!checkParamCount(e, 2))
442 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
444 ircuser->setAway(true);
445 ircuser->setAwayMessage(e->params().at(1));
446 //ircuser->setLastAwayMessage(now);
450 /* RPL_UNAWAY - ":You are no longer marked as being away" */
451 void CoreSessionEventProcessor::processIrcEvent305(IrcEvent *e) {
452 IrcUser *me = e->network()->me();
456 if(e->network()->autoAwayActive()) {
457 e->network()->setAutoAwayActive(false);
458 e->setFlag(EventManager::Silent);
462 /* RPL_NOWAWAY - ":You have been marked as being away" */
463 void CoreSessionEventProcessor::processIrcEvent306(IrcEvent *e) {
464 IrcUser *me = e->network()->me();
469 /* RPL_WHOISSERVICE - "<user> is registered nick" */
470 void CoreSessionEventProcessor::processIrcEvent307(IrcEvent *e) {
471 if(!checkParamCount(e, 1))
474 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
476 ircuser->setWhoisServiceReply(e->params().join(" "));
479 /* RPL_SUSERHOST - "<user> is available for help." */
480 void CoreSessionEventProcessor::processIrcEvent310(IrcEvent *e) {
481 if(!checkParamCount(e, 1))
484 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
486 ircuser->setSuserHost(e->params().join(" "));
489 /* RPL_WHOISUSER - "<nick> <user> <host> * :<real name>" */
490 void CoreSessionEventProcessor::processIrcEvent311(IrcEvent *e) {
491 if(!checkParamCount(e, 3))
494 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
496 ircuser->setUser(e->params().at(1));
497 ircuser->setHost(e->params().at(2));
498 ircuser->setRealName(e->params().last());
502 /* RPL_WHOISSERVER - "<nick> <server> :<server info>" */
503 void CoreSessionEventProcessor::processIrcEvent312(IrcEvent *e) {
504 if(!checkParamCount(e, 2))
507 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
509 ircuser->setServer(e->params().at(1));
512 /* RPL_WHOISOPERATOR - "<nick> :is an IRC operator" */
513 void CoreSessionEventProcessor::processIrcEvent313(IrcEvent *e) {
514 if(!checkParamCount(e, 1))
517 IrcUser *ircuser = e->network()->ircUser(e->params().at(0));
519 ircuser->setIrcOperator(e->params().last());
522 /* RPL_ENDOFWHO: "<name> :End of WHO list" */
523 void CoreSessionEventProcessor::processIrcEvent315(IrcEvent *e) {
524 if(!checkParamCount(e, 1))
527 if(coreNetwork(e)->setAutoWhoDone(e->params()[0]))
528 e->setFlag(EventManager::Silent);
531 /* RPL_WHOISIDLE - "<nick> <integer> :seconds idle"
532 (real life: "<nick> <integer> <integer> :seconds idle, signon time) */
533 void CoreSessionEventProcessor::processIrcEvent317(IrcEvent *e) {
534 if(!checkParamCount(e, 2))
539 int idleSecs = e->params()[1].toInt();
540 if(e->params().count() > 3) { // if we have more then 3 params we have the above mentioned "real life" situation
541 int logintime = e->params()[2].toInt();
542 loginTime = QDateTime::fromTime_t(logintime);
545 IrcUser *ircuser = e->network()->ircUser(e->params()[0]);
547 ircuser->setIdleTime(e->timestamp().addSecs(-idleSecs));
548 if(loginTime.isValid())
549 ircuser->setLoginTime(loginTime);
553 /* RPL_LIST - "<channel> <# visible> :<topic>" */
554 void CoreSessionEventProcessor::processIrcEvent322(IrcEvent *e) {
555 if(!checkParamCount(e, 1))
559 quint32 userCount = 0;
562 switch(e->params().count()) {
564 topic = e->params()[2];
566 userCount = e->params()[1].toUInt();
568 channelName = e->params()[0];
572 if(coreSession()->ircListHelper()->addChannel(e->networkId(), channelName, userCount, topic))
573 e->stop(); // consumed by IrcListHelper, so don't further process/show this event
576 /* RPL_LISTEND ":End of LIST" */
577 void CoreSessionEventProcessor::processIrcEvent323(IrcEvent *e) {
578 if(!checkParamCount(e, 1))
581 if(coreSession()->ircListHelper()->endOfChannelList(e->networkId()))
582 e->stop(); // consumed by IrcListHelper, so don't further process/show this event
585 /* RPL_CHANNELMODEIS - "<channel> <mode> <mode params>" */
586 void CoreSessionEventProcessor::processIrcEvent324(IrcEvent *e) {
587 processIrcEventMode(e);
591 void CoreSessionEventProcessor::processIrcEvent331(IrcEvent *e) {
592 if(!checkParamCount(e, 1))
595 IrcChannel *chan = e->network()->ircChannel(e->params()[0]);
597 chan->setTopic(QString());
601 void CoreSessionEventProcessor::processIrcEvent332(IrcEvent *e) {
602 if(!checkParamCount(e, 2))
605 IrcChannel *chan = e->network()->ircChannel(e->params()[0]);
607 chan->setTopic(e->params()[1]);
610 /* RPL_WHOREPLY: "<channel> <user> <host> <server> <nick>
611 ( "H" / "G" > ["*"] [ ( "@" / "+" ) ] :<hopcount> <real name>" */
612 void CoreSessionEventProcessor::processIrcEvent352(IrcEvent *e) {
613 if(!checkParamCount(e, 6))
616 QString channel = e->params()[0];
617 IrcUser *ircuser = e->network()->ircUser(e->params()[4]);
619 ircuser->setUser(e->params()[1]);
620 ircuser->setHost(e->params()[2]);
622 bool away = e->params()[5].startsWith("G");
623 ircuser->setAway(away);
624 ircuser->setServer(e->params()[3]);
625 ircuser->setRealName(e->params().last().section(" ", 1));
628 if(coreNetwork(e)->isAutoWhoInProgress(channel))
629 e->setFlag(EventManager::Silent);
633 void CoreSessionEventProcessor::processIrcEvent353(IrcEvent *e) {
634 if(!checkParamCount(e, 3))
637 // param[0] is either "=", "*" or "@" indicating a public, private or secret channel
638 // we don't use this information at the time beeing
639 QString channelname = e->params()[1];
641 IrcChannel *channel = e->network()->ircChannel(channelname);
643 qWarning() << Q_FUNC_INFO << "Received unknown target channel:" << channelname;
650 foreach(QString nick, e->params()[2].split(' ')) {
653 if(e->network()->prefixes().contains(nick[0])) {
654 mode = e->network()->prefixToMode(nick[0]);
662 channel->joinIrcUsers(nicks, modes);
665 /* ERR_ERRONEUSNICKNAME */
666 void CoreSessionEventProcessor::processIrcEvent432(IrcEventNumeric *e) {
668 if(e->params().count() < 2) {
669 // handle unreal-ircd bug, where unreal ircd doesnt supply a TARGET in ERR_ERRONEUSNICKNAME during registration phase:
671 // :irc.scortum.moep.net 432 @@@ :Erroneous Nickname: Illegal characters
672 // correct server reply:
673 // :irc.scortum.moep.net 432 * @@@ :Erroneous Nickname: Illegal characters
674 e->params().prepend(e->target());
677 errnick = e->params()[0];
679 tryNextNick(e, errnick, true /* erroneus */);
682 /* ERR_NICKNAMEINUSE */
683 void CoreSessionEventProcessor::processIrcEvent433(IrcEventNumeric *e) {
684 if(!checkParamCount(e, 1))
687 QString errnick = e->params().first();
689 // if there is a problem while connecting to the server -> we handle it
690 // but only if our connection has not been finished yet...
691 if(!e->network()->currentServer().isEmpty())
694 tryNextNick(e, errnick);
697 /* ERR_UNAVAILRESOURCE */
698 void CoreSessionEventProcessor::processIrcEvent437(IrcEventNumeric *e) {
699 if(!checkParamCount(e, 1))
702 QString errnick = e->params().first();
704 // if there is a problem while connecting to the server -> we handle it
705 // but only if our connection has not been finished yet...
706 if(!e->network()->currentServer().isEmpty())
709 if(!e->network()->isChannelName(errnick))
710 tryNextNick(e, errnick);
714 void CoreSessionEventProcessor::processIrcEvent(IrcEvent *e) {
715 if(!checkParamCount(e, 1))
721 /* Handle signals from Netsplit objects */
723 void CoreSessionEventProcessor::handleNetsplitJoin(Network *net,
724 const QString &channel,
725 const QStringList &users,
726 const QStringList &modes,
727 const QString& quitMessage)
729 IrcChannel *ircChannel = net->ircChannel(channel);
733 QList<IrcUser *> ircUsers;
734 QStringList newModes = modes;
735 QStringList newUsers = users;
737 foreach(const QString &user, users) {
738 IrcUser *iu = net->ircUser(nickFromMask(user));
741 else { // the user already quit
742 int idx = users.indexOf(user);
743 newUsers.removeAt(idx);
744 newModes.removeAt(idx);
748 ircChannel->joinIrcUsers(ircUsers, newModes);
749 NetworkSplitEvent *event = new NetworkSplitEvent(EventManager::NetworkSplitJoin, net, channel, newUsers, quitMessage);
750 coreSession()->eventManager()->sendEvent(event);
753 void CoreSessionEventProcessor::handleNetsplitQuit(Network *net, const QString &channel, const QStringList &users, const QString& quitMessage) {
754 NetworkSplitEvent *event = new NetworkSplitEvent(EventManager::NetworkSplitQuit, net, channel, users, quitMessage);
755 coreSession()->eventManager()->sendEvent(event);
756 foreach(QString user, users) {
757 IrcUser *iu = net->ircUser(nickFromMask(user));
763 void CoreSessionEventProcessor::handleEarlyNetsplitJoin(Network *net, const QString &channel, const QStringList &users, const QStringList &modes) {
764 IrcChannel *ircChannel = net->ircChannel(channel);
766 qDebug() << "handleEarlyNetsplitJoin(): channel " << channel << " invalid";
769 QList<NetworkEvent *> events;
770 QList<IrcUser *> ircUsers;
771 QStringList newModes = modes;
773 foreach(QString user, users) {
774 IrcUser *iu = net->updateNickFromMask(user);
777 // fake event for scripts that consume join events
778 events << new IrcEvent(EventManager::IrcEventJoin, net, iu->hostmask(), QStringList() << channel);
781 newModes.removeAt(users.indexOf(user));
784 ircChannel->joinIrcUsers(ircUsers, newModes);
785 foreach(NetworkEvent *event, events) {
786 event->setFlag(EventManager::Fake); // ignore this in here!
787 coreSession()->eventManager()->sendEvent(event);
791 void CoreSessionEventProcessor::handleNetsplitFinished() {
792 Netsplit* n = qobject_cast<Netsplit*>(sender());
794 QHash<QString, Netsplit *> splithash = _netsplits.take(n->network());
795 splithash.remove(splithash.key(n));
796 if(splithash.count())
797 _netsplits[n->network()] = splithash;
801 void CoreSessionEventProcessor::destroyNetsplits(NetworkId netId) {
802 Network *net = coreSession()->network(netId);
806 QHash<QString, Netsplit *> splits = _netsplits.take(net);
810 /*******************************/
811 /******** CTCP HANDLING ********/
812 /*******************************/
814 void CoreSessionEventProcessor::processCtcpEvent(CtcpEvent *e) {
815 if(e->testFlag(EventManager::Self))
816 return; // ignore ctcp events generated by user input
818 if(e->type() != EventManager::CtcpEvent || e->ctcpType() != CtcpEvent::Query)
821 handle(e->ctcpCmd(), Q_ARG(CtcpEvent *, e));
824 void CoreSessionEventProcessor::defaultHandler(const QString &ctcpCmd, CtcpEvent *e) {
825 // This handler is only there to avoid warnings for unknown CTCPs
830 void CoreSessionEventProcessor::handleCtcpAction(CtcpEvent *e) {
831 // This handler is only there to feed CLIENTINFO
835 void CoreSessionEventProcessor::handleCtcpClientinfo(CtcpEvent *e) {
836 QStringList supportedHandlers;
837 foreach(QString handler, providesHandlers())
838 supportedHandlers << handler.toUpper();
839 qSort(supportedHandlers);
840 e->setReply(supportedHandlers.join(" "));
843 void CoreSessionEventProcessor::handleCtcpPing(CtcpEvent *e) {
844 e->setReply(e->param());
847 void CoreSessionEventProcessor::handleCtcpTime(CtcpEvent *e) {
848 e->setReply(QDateTime::currentDateTime().toString());
851 void CoreSessionEventProcessor::handleCtcpVersion(CtcpEvent *e) {
852 e->setReply(QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org")
853 .arg(Quassel::buildInfo().plainVersionString).arg(Quassel::buildInfo().buildDate));