Proof-reading.
[kdenetwork.git] / kopete / protocols / irc / libkirc / kircengine_numericreplies.cpp
blob3ab153a472ed035f6be2fc32a5d87ab61b0e4775
1 /*
2 kircnumericreplies.cpp - IRC Client
4 Copyright (c) 2002 by Nick Betcher <nbetcher@kde.org>
5 Copyright (c) 2003 by Jason Keirstead <jason@keirstead.org>
6 Copyright (c) 2003-2007 by Michel Hermier <michel.hermier@gmail.com>
8 Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
10 *************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 *************************************************************************
20 #include "kircengine.h"
22 #include <kdebug.h>
23 #include <klocale.h>
25 #include <qdatetime.h>
27 using namespace KIRC;
29 /* IMPORTANT NOTE:
30 * Numeric replies always have the current nick or * as first argmuent.
31 * NOTE: * means undefined in most (all ?) of the cases.
34 void Engine::bindNumericReplies()
36 bind(1, this, SLOT(numericReply_001(KIRC::Message &)), 1, 1);
37 bind(2, this, SLOT(numericReply_002(KIRC::Message &)), 1, 1);
38 bind(3, this, SLOT(numericReply_003(KIRC::Message &)), 1, 1);
39 bind(4, this, SLOT(numericReply_004(KIRC::Message &)), 5, 5);
40 bind(5, this, SLOT(numericReply_004(KIRC::Message &)), 1, 1);
42 bind(250, this, SLOT(numericReply_250(KIRC::Message &)));
43 bind(251, this, SLOT(numericReply_251(KIRC::Message &)));
44 bind(252, this, SLOT(numericReply_252(KIRC::Message &)), 2, 2);
45 bind(253, this, SLOT(numericReply_253(KIRC::Message &)), 2, 2);
46 bind(254, this, SLOT(numericReply_254(KIRC::Message &)), 2, 2);
47 bind(255, this, SLOT(numericReply_255(KIRC::Message &)), 1, 1);
49 bind(263, this, SLOT(numericReply_263(KIRC::Message &)));
50 bind(265, this, SLOT(numericReply_265(KIRC::Message &)));
51 bind(266, this, SLOT(numericReply_266(KIRC::Message &)));
53 bind(301, this, SLOT(numericReply_301(KIRC::Message &)), 2, 2);
54 bind(303, this, SLOT(numericReply_303(KIRC::Message &)), 1, 1);
55 // bind(305, this, SLOT(ignoreMessage(KIRC::Message &)), 0, 0 );
56 // bind(306, this, SLOT(ignoreMessage(KIRC::Message &)), 0, 0 );
57 bind(307, this, SLOT(numericReply_307(KIRC::Message &)), 1, 1);
58 bind(311, this, SLOT(numericReply_311(KIRC::Message &)), 5, 5);
59 bind(312, this, SLOT(numericReply_312(KIRC::Message &)), 3, 3);
60 bind(313, this, SLOT(numericReply_313(KIRC::Message &)), 2, 2);
61 bind(314, this, SLOT(numericReply_314(KIRC::Message &)), 5, 5);
62 bind(315, this, SLOT(numericReply_315(KIRC::Message &)), 2, 2);
63 bind(317, this, SLOT(numericReply_317(KIRC::Message &)), 3, 4);
64 bind(318, this, SLOT(numericReply_318(KIRC::Message &)), 2, 2);
65 bind(319, this, SLOT(numericReply_319(KIRC::Message &)), 2, 2);
66 bind(320, this, SLOT(numericReply_320(KIRC::Message &)), 2, 2);
67 // bind(321, this, SLOT(ignoreMessage(KIRC::Message &)), 0, 0 );
68 bind(322, this, SLOT(numericReply_322(KIRC::Message &)), 3, 3);
69 bind(323, this, SLOT(numericReply_323(KIRC::Message &)), 1, 1);
70 bind(324, this, SLOT(numericReply_324(KIRC::Message &)), 2, 4);
71 bind(328, this, SLOT(numericReply_328(KIRC::Message &)), 2, 2);
72 bind(329, this, SLOT(numericReply_329(KIRC::Message &)), 3, 3);
73 // bind(330, this, SLOT(ignoreMessage(KIRC::Message &)), 3, 3); // ???
74 bind(331, this, SLOT(numericReply_331(KIRC::Message &)), 2, 2);
75 bind(332, this, SLOT(numericReply_332(KIRC::Message &)), 2, 2);
76 bind(333, this, SLOT(numericReply_333(KIRC::Message &)), 4, 4);
77 bind(352, this, SLOT(numericReply_352(KIRC::Message &)), 5, 10);
78 bind(353, this, SLOT(numericReply_353(KIRC::Message &)), 3, 3);
79 bind(366, this, SLOT(numericReply_366(KIRC::Message &)), 2, 2);
80 bind(369, this, SLOT(numericReply_369(KIRC::Message &)), 2, 2);
81 bind(372, this, SLOT(numericReply_372(KIRC::Message &)), 1, 1);
82 bind(375, this, SLOT(ignoreMessage(KIRC::Message&)), 0, 0 );
83 bind(376, this, SLOT(ignoreMessage(KIRC::Message&)), 0, 0 );
85 bind(401, this, SLOT(numericReply_401(KIRC::Message &)), 2, 2);
86 bind(404, this, SLOT(numericReply_404(KIRC::Message &)), 2, 2);
87 bind(406, this, SLOT(numericReply_406(KIRC::Message &)), 2, 2);
88 bind(422, this, SLOT(numericReply_422(KIRC::Message &)), 1, 1);
89 bind(433, this, SLOT(numericReply_433(KIRC::Message &)), 2, 2);
90 bind(442, this, SLOT(numericReply_442(KIRC::Message &)), 2, 2);
91 bind(464, this, SLOT(numericReply_464(KIRC::Message &)), 1, 1);
92 bind(471, this, SLOT(numericReply_471(KIRC::Message &)), 2, 2);
93 bind(473, this, SLOT(numericReply_473(KIRC::Message &)), 2, 2);
94 bind(474, this, SLOT(numericReply_474(KIRC::Message &)), 2, 2);
95 bind(475, this, SLOT(numericReply_475(KIRC::Message &)), 2, 2);
97 //Freenode seems to use this for a non-RFC compliant purpose, as does Unreal
98 bind(477, this, SLOT(receivedServerMessage(KIRC::Message&)),0,0);
101 /* 001: "Welcome to the Internet Relay Network <nick>!<user>@<host>"
102 * Gives a welcome message in the form of:
104 void Engine::numericReply_001(Message &msg)
106 kDebug(14121) ;
108 /* At this point we are connected and the server is ready for us to being taking commands
109 * although the MOTD comes *after* this.
111 receivedServerMessage(msg);
113 setConnectionState(Connected);
116 /* 002: ":Your host is <servername>, running version <ver>"
117 * Gives information about the host. The given information are close to 004.
119 void Engine::numericReply_002(Message &msg)
121 receivedServerMessage(msg);
124 /* 003: "This server was created <date>"
125 * Gives the date that this server was created.
126 * NOTE: This is useful for determining the uptime of the server).
128 void Engine::numericReply_003(Message &msg)
130 receivedServerMessage(msg);
133 /* 004: "<servername> <version> <available user modes> <available channel modes>"
134 * Gives information about the servername, version, available modes, etc.
136 void Engine::numericReply_004(Message &msg)
138 // emit incomingHostInfo(msg.arg(1),msg.arg(2),msg.arg(3),msg.arg(4));
141 /* 005:
142 * Gives capability information. TODO: This is important!
144 void Engine::numericReply_005(Message &msg)
146 receivedServerMessage(msg);
149 /* 250: ":Highest connection count: <integer> (<integer> clients)
150 * (<integer> since server was (re)started)"
151 * Tells connections statistics about the server for the uptime activity.
152 * NOT IN RFC1459 NOR RFC2812
154 void Engine::numericReply_250(Message &msg)
156 receivedServerMessage(msg);
159 /* 251: ":There are <integer> users and <integer> services on <integer> servers"
160 * Tells how many user there are on all the different servers in the form of:
162 void Engine::numericReply_251(Message &msg)
164 receivedServerMessage(msg);
167 /* 252: "<integer> :operator(s) online"
168 * Issues a number of operators on the server in the form of:
170 void Engine::numericReply_252(Message &msg)
172 receivedServerMessage(msg, i18np("There is one operator online", "There are %1 operators online.", msg.arg(1)));
175 /* 253: "<integer> :unknown connection(s)"
176 * Tells how many unknown connections the server has in the form of:
178 void Engine::numericReply_253(Message &msg)
180 receivedServerMessage(msg, i18np("There is one unknown connection", "There are %1 unknown connections.", msg.arg(1)));
183 /* 254: "<integer> :channels formed"
184 * Tells how many total channels there are on this network.
185 * */
186 void Engine::numericReply_254(Message &msg)
188 receivedServerMessage(msg, i18np("There has been one channel formed", "There have been %1 channels formed.", msg.arg(1)));
191 /* 255: ":I have <integer> clients and <integer> servers"
192 * Tells how many clients and servers *this* server handles.
194 void Engine::numericReply_255(Message &msg)
196 receivedServerMessage(msg);
199 /* 263: "<command> :Please wait a while and try again."
200 * Server is too busy.
202 void Engine::numericReply_263(Message &msg)
204 receivedServerMessage(msg, i18n("Server was too busy to execute %1.", msg.arg(1)));
207 /* 265: ":Current local users: <integer> Max: <integer>"
208 * Tells statistics about the current local server state.
209 * NOT IN RFC2812
211 void Engine::numericReply_265(Message &msg)
213 receivedServerMessage(msg);
216 /* 266: ":Current global users: <integer> Max: <integer>"
217 * Tells statistics about the current global(the whole irc server chain) server state:
219 void Engine::numericReply_266(Message &msg)
221 receivedServerMessage(msg);
224 /* 301: "<nick> :<away message>"
226 void Engine::numericReply_301(Message &msg)
229 Entity entity = msg.entityFromArg(1);
230 entity->setAwayMessage(msg.suffix);
231 entity->setMode("+a");
233 receivedServerMessage(msg);
237 /* 303: ":*1<nick> *(" " <nick> )"
239 void Engine::numericReply_303(Message &msg)
242 QStringList nicks = QStringList::split(QRegExp(QChar(' ')), msg.suffix());
243 for(QStringList::Iterator it = nicks.begin(); it != nicks.end(); ++it)
245 if (!(*it).trimmed().isEmpty())
246 emit incomingUserOnline(*it);
251 /* 305: ":You are no longer marked as being away"
253 void Engine::numericReply_305(Message &msg)
256 EntityPtr self = this->self();
257 self->setAwayMessage(QString());
258 // self->setModes("-a");
259 receivedServerMessage(msg, i18n("You are no longer marked as being away."));
264 /* 306: ":You have been marked as being away"
266 void Engine::numericReply_306(Message &msg)
268 EntityPtr self = this->self();
269 // self->setModes("+a");
270 receivedServerMessage(msg, i18n("You have been marked as being away."));
273 /* 307: ":is a registered nick"
274 * DALNET: Indicates that this user is identified with NICSERV.
276 void Engine::numericReply_307(Message &msg)
278 receivedServerMessage(msg, i18n("%1 is a registered nick.", msg.arg(1)));
281 /* 311: "<nick> <user> <host> * :<real name>"
282 * Show info about a user (part of a /whois) in the form of:
284 void Engine::numericReply_311(Message &msg)
286 // emit incomingWhoIsUser(msg.arg(1), msg.arg(2), msg.arg(3), msg.suffix());
289 /* 312: "<nick> <server> :<server info>"
290 * Show info about a server (part of a /whois).
292 void Engine::numericReply_312(Message &msg)
294 // emit incomingWhoIsServer(msg.arg(1), msg.arg(2), msg.suffix());
297 /* 313: "<nick> :is an IRC operator"
298 * Show info about an operator (part of a /whois).
300 void Engine::numericReply_313(Message &msg)
302 receivedServerMessage(msg, i18n("%1 is an IRC operator.", msg.arg(1)));
305 /* 314: "<nick> <user> <host> * :<real name>"
306 * Show WHOWAS Info
308 void Engine::numericReply_314(Message &msg)
310 // emit incomingWhoWasUser(msg.arg(1), msg.arg(2), msg.arg(3), msg.suffix());
313 /* 315: "<name> :End of WHO list"
314 * End of WHO list.
316 void Engine::numericReply_315(Message &msg)
318 receivedServerMessage(msg);
321 /* RFC say: "<nick> <integer> :seconds idle"
322 * Some servers say: "<nick> <integer> <integer> :seconds idle, signon time"
323 * Show info about someone who is idle (part of a /whois) in the form of:
325 void Engine::numericReply_317(Message &msg)
328 emit incomingWhoIsIdle(msg.arg(1), msg.arg(2).toULong());
329 if (msg.argsSize()==4)
330 emit incomingSignOnTime(msg.arg(1),msg.arg(3).toULong());
334 /* 318: "<nick>{<space><realname>} :End of /WHOIS list"
335 * End of WHOIS for a given nick.
337 void Engine::numericReply_318(Message &msg)
339 emit receivedServerMessage(msg);
342 /* 319: "<nick> :{[@|+]<channel><space>}"
343 * Show info a channel a user is logged in (part of a /whois) in the form of:
345 void Engine::numericReply_319(Message &msg)
347 // emit incomingWhoIsChannels(msg.arg(1), msg.suffix());
350 /* 320:
351 * Indicates that this user is identified with NICSERV on FREENODE.
353 void Engine::numericReply_320(Message &msg)
355 // emit incomingWhoIsIdentified(msg.arg(1));
358 /* 321: "<channel> :Users Name" ("Channel :Users Name")
359 * RFC1459: Declared.
360 * RFC2812: Obsoleted.
363 /* 322: "<channel> <# visible> :<topic>"
364 * Received one channel from the LIST command.
366 void Engine::numericReply_322(Message &msg)
368 // emit incomingListedChan(msg.arg(1), msg.arg(2).toUInt(), msg.suffix());
371 /* 323: ":End of LIST"
372 * End of the LIST command.
374 void Engine::numericReply_323(Message &msg)
376 emit receivedServerMessage(msg);
379 /* 324: "<channel> <mode> <mode params>"
381 void Engine::numericReply_324(Message &msg)
383 // emit incomingChannelMode(msg.arg(1), msg.arg(2), msg.arg(3));
386 /* 328: "<channel> <mode> <mode params>"
388 void Engine::numericReply_328(Message &msg)
390 // emit incomingChannelHomePage(msg.arg(1), msg.suffix());
393 /* 329: "%s %lu"
394 * NOTE: What is the meaning of this arguments. DAL-ircd say it's a RPL_CREATIONTIME
395 * NOT IN RFC1459 NOR RFC2812
397 void Engine::numericReply_329( Message & )
401 /* 331: "<channel> :No topic is set"
402 * Gives the existing topic for a channel after a join.
404 void Engine::numericReply_331( Message & )
406 // emit incomingExistingTopic(msg.arg(1), suffix);
409 /* 332: "<channel> :<topic>"
410 * Gives the existing topic for a channel after a join.
412 void Engine::numericReply_332( Message &msg )
414 // emit incomingExistingTopic(msg.arg(1), msg.suffix());
417 /* 333:
418 * Gives the nickname and time who changed the topic
420 void Engine::numericReply_333( Message &msg )
423 QDateTime d;
424 d.setTime_t( msg.arg(3).toLong() );
425 emit incomingTopicUser(msg.arg(1), msg.arg(2), d );
429 /* 352:
430 * WHO Reply
432 void Engine::numericReply_352(Message &msg)
435 QStringList suffix = QStringList::split( ' ', msg.suffix() );
437 emit incomingWhoReply(
438 msg.arg(5),
439 msg.arg(1),
440 msg.arg(2),
441 msg.arg(3),
442 msg.arg(4),
443 msg.arg(6)[0] != 'H',
444 msg.arg(7),
445 msg.suffix().section(' ', 0, 1 ).toUInt(),
446 msg.suffix().section(' ', 1 )
452 /* 353:
453 * NAMES list
455 void Engine::numericReply_353(Message &msg)
457 // emit incomingNamesList(msg.arg(2), QStringList::split(' ', msg.suffix()));
460 /* 366: "<channel> :End of NAMES list"
461 * Gives a signal to indicate that the NAMES list has ended for channel.
463 void Engine::numericReply_366(Message &msg)
465 emit receivedServerMessage(msg);
468 /* 369: "<nick> :End of WHOWAS"
469 * End of WHOWAS Request
471 void Engine::numericReply_369(Message &msg)
473 emit receivedServerMessage(msg);
476 /* 372: ":- <text>"
477 * Part of the MOTD.
479 void Engine::numericReply_372(Message &msg)
481 #ifdef __GNUC__
482 #warning FIXME remove the "- " in front.
483 #endif
484 receivedServerMessage(msg);
487 /* 375: ":- <server> Message of the day - "
488 * Beginging the motd. This isn't emitted because the MOTD is sent out line by line.
491 /* 376: ":End of MOTD command"
492 * End of the motd.
494 void Engine::numericReply_376(Message &msg)
496 receivedServerMessage(msg);
499 /* 401: "<nickname> :No such nick/channel"
500 * Gives a signal to indicate that the command issued failed because the person/channel not being on IRC.
501 * - Used to indicate the nickname parameter supplied to a command is currently unused.
503 void Engine::numericReply_401(Message &msg)
505 // i18n("The channel \"%1\" does not exist").arg(nick)
506 // i18n("The nickname \"%1\" does not exist").arg(nick)
509 /* 404: "<channel name> :Cannot send to channel"
511 void Engine::numericReply_404(Message &msg)
513 receivedServerMessage(msg, i18n("You cannot send messages to channel %1.", msg.arg(1)));
516 /* 406: "<nickname> :There was no such nickname"
517 * Like case 401, but when there *was* no such nickname.
519 void Engine::numericReply_406(Message &msg)
521 #ifdef __GNUC__
522 #warning FIXME 406 MEANS *NEVER*, unlike 401
523 #endif
524 // i18n("The channel \"%1\" does not exist").arg(nick)
525 // i18n("The nickname \"%1\" does not exist").arg(nick)
528 /* 422: ":MOTD File is missing"
530 * Server's MOTD file could not be opened by the server.
532 void Engine::numericReply_422(Message &msg)
534 receivedServerMessage(msg);
537 /* 433: "<nick> :Nickname is already in use"
538 * Tells us that our nickname is already in use.
540 void Engine::numericReply_433(Message &msg)
542 // if(m_status == Authentifying)
544 // This tells us that our nickname is, but we aren't logged in.
545 // This differs because the server won't send us a response back telling us our nick changed
546 // (since we aren't logged in).
547 // m_FailedNickOnLogin = true;
548 // emit incomingFailedNickOnLogin(msg.arg(1));
550 // else
551 // {
552 // And this is the signal for if someone is trying to use the /nick command or such when already logged in,
553 // but it's already in use
554 // emit incomingNickInUse(msg.arg(1));
555 // }
558 /* 442: "<channel> :You're not on that channel"
560 void Engine::numericReply_442(Message &msg)
562 receivedServerMessage(msg, i18n("You are not on channel %1.", msg.arg(1)));
565 /* 464: ":Password Incorrect"
566 * Bad server password
568 void Engine::numericReply_464(Message &/*msg*/)
570 /* Server need pass.. Call disconnect*/
571 // emit incomingFailedServerPassword();
574 /* 465: ":You are banned from this server"
577 /* 471: "<channel> :Cannot join channel (+l)"
578 * Channel is Full
580 void Engine::numericReply_471(Message &msg)
582 receivedServerMessage(msg, i18n("Cannot join %1, channel is full.", msg.arg(1)) );
585 /* 472: "<char> :is unknown mode char to me for <channel>"
588 /* 473: "<channel> :Cannot join channel (+i)"
589 * Invite Only.
591 void Engine::numericReply_473(Message &msg)
593 receivedServerMessage(msg, i18n("Cannot join %1, channel is invite only.", msg.arg(1)) );
596 /* 474: "<channel> :Cannot join channel (+b)"
597 * Banned.
599 void Engine::numericReply_474(Message &msg)
601 receivedServerMessage(msg, i18n("Cannot join %1, you are banned from that channel.", msg.arg(1)) );
604 /* 475: "<channel> :Cannot join channel (+k)"
605 * Wrong Chan-key.
607 void Engine::numericReply_475(Message &msg)
609 receivedServerMessage(msg, i18n("Cannot join %1, wrong channel key was given.", msg.arg(1)) );
612 /* 476: "<channel> :Bad Channel Mask"
615 /* 477: "<channel> :Channel doesn't support modes" RFC-2812
616 * 477: "<channel> :You need a registered nick to join that channel." DALNET
618 // void Engine::numericReply_477(Message &msg)
619 // {
620 // emit incomingChannelNeedRegistration(msg.arg(2), msg.suffix());
621 // }
623 /* 478: "<channel> <char> :Channel list is full"
626 /* 481: ":Permission Denied- You're not an IRC operator"
629 /* 482: "<channel> :You're not channel operator"
632 /* 483: ":You can't kill a server!"
635 /* 484: ":Your connection is restricted!"
638 /* 485: ":You're not the original channel operator"
641 /* 491: ":No O-lines for your host"
644 /* 501: ":Unknown MODE flag"
647 /* 502: ":Cannot change mode for other users"