author | wazlaf <wazlaf> | 2002-09-29 20:06:27 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-29 20:06:27 (UTC) |
commit | 84c3b7409eb543066e42816328cc3f0a26d413cc (patch) (unidiff) | |
tree | a2b8b8c7f7d56bdcffaa54f2c5e03ce08e184a81 /noncore/net/opieirc/ircmessageparser.cpp | |
parent | 1dd254c95a582c2c86c816516a1b4433d8142d8a (diff) | |
download | opie-84c3b7409eb543066e42816328cc3f0a26d413cc.zip opie-84c3b7409eb543066e42816328cc3f0a26d413cc.tar.gz opie-84c3b7409eb543066e42816328cc3f0a26d413cc.tar.bz2 |
some more message types supported to make this work more smoothly with freenode.net
Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index d1b70a5..2b77414 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -1,517 +1,521 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include "ircmessageparser.h" | 2 | #include "ircmessageparser.h" |
3 | #include "ircversion.h" | 3 | #include "ircversion.h" |
4 | 4 | ||
5 | /* Lookup table for literal commands */ | 5 | /* Lookup table for literal commands */ |
6 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | 6 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { |
7 | { "PING", FUNC(parseLiteralPing) }, | 7 | { "PING", FUNC(parseLiteralPing) }, |
8 | { "NOTICE", FUNC(parseLiteralNotice) }, | 8 | { "NOTICE", FUNC(parseLiteralNotice) }, |
9 | { "JOIN", FUNC(parseLiteralJoin) }, | 9 | { "JOIN", FUNC(parseLiteralJoin) }, |
10 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, | 10 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, |
11 | { "NICK", FUNC(parseLiteralNick) }, | 11 | { "NICK", FUNC(parseLiteralNick) }, |
12 | { "PART", FUNC(parseLiteralPart) }, | 12 | { "PART", FUNC(parseLiteralPart) }, |
13 | { "QUIT", FUNC(parseLiteralQuit) }, | 13 | { "QUIT", FUNC(parseLiteralQuit) }, |
14 | { "ERROR", FUNC(parseLiteralError) }, | 14 | { "ERROR", FUNC(parseLiteralError) }, |
15 | { "ERROR:", FUNC(parseLiteralError) }, | 15 | { "ERROR:", FUNC(parseLiteralError) }, |
16 | { "MODE", FUNC(parseLiteralMode) }, | 16 | { "MODE", FUNC(parseLiteralMode) }, |
17 | { "KICK", FUNC(parseLiteralKick) }, | 17 | { "KICK", FUNC(parseLiteralKick) }, |
18 | { "TOPIC", FUNC(parseLiteralTopic) }, | 18 | { "TOPIC", FUNC(parseLiteralTopic) }, |
19 | { 0 , 0 } | 19 | { 0 , 0 } |
20 | }; | 20 | }; |
21 | 21 | ||
22 | /* Lookup table for literal commands */ | 22 | /* Lookup table for literal commands */ |
23 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { | 23 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { |
24 | { "PING", FUNC(parseCTCPPing) }, | 24 | { "PING", FUNC(parseCTCPPing) }, |
25 | { "VERSION", FUNC(parseCTCPVersion) }, | 25 | { "VERSION", FUNC(parseCTCPVersion) }, |
26 | { "ACTION", FUNC(parseCTCPAction) }, | 26 | { "ACTION", FUNC(parseCTCPAction) }, |
27 | { 0 , 0 } | 27 | { 0 , 0 } |
28 | }; | 28 | }; |
29 | 29 | ||
30 | /* Lookup table for numerical commands */ | 30 | /* Lookup table for numerical commands */ |
31 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | 31 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { |
32 | { 1, FUNC(parseNumerical001) }, // RPL_WELCOME | 32 | { 1, FUNC(parseNumerical001) }, // RPL_WELCOME |
33 | { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST | 33 | { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST |
34 | { 3, FUNC(parseNumerical003) }, // RPL_CREATED | 34 | { 3, FUNC(parseNumerical003) }, // RPL_CREATED |
35 | { 4, FUNC(parseNumerical004) }, // RPL_MYINFO | 35 | { 4, FUNC(parseNumerical004) }, // RPL_MYINFO |
36 | { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL | 36 | { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL |
37 | { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT | 37 | { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT |
38 | { 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP | ||
39 | { 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS | ||
40 | { 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS | ||
41 | { 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN | ||
38 | { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS | 42 | { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS |
39 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME | 43 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME |
40 | { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC | 44 | { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC |
41 | { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME | 45 | { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME |
42 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY | 46 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY |
43 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES | 47 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES |
44 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART | 48 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART |
45 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD | 49 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD |
46 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD | 50 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD |
47 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 | 51 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 |
48 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 | 52 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 |
49 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK | 53 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK |
50 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK | 54 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK |
51 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND | 55 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND |
52 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE | 56 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE |
53 | { 0, 0 } | 57 | { 0, 0 } |
54 | }; | 58 | }; |
55 | 59 | ||
56 | IRCMessageParser::IRCMessageParser(IRCSession *session) { | 60 | IRCMessageParser::IRCMessageParser(IRCSession *session) { |
57 | m_session = session; | 61 | m_session = session; |
58 | } | 62 | } |
59 | 63 | ||
60 | void IRCMessageParser::parse(IRCMessage *message) { | 64 | void IRCMessageParser::parse(IRCMessage *message) { |
61 | /* Find out what kind of message we have here and call the appropriate handler using | 65 | /* Find out what kind of message we have here and call the appropriate handler using |
62 | the parser tables. If no handler can be found, print out an error message */ | 66 | the parser tables. If no handler can be found, print out an error message */ |
63 | if (message->isNumerical()) { | 67 | if (message->isNumerical()) { |
64 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { | 68 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { |
65 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { | 69 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { |
66 | (this->*(numericalParserProcTable[i].proc))(message); | 70 | (this->*(numericalParserProcTable[i].proc))(message); |
67 | return; | 71 | return; |
68 | } | 72 | } |
69 | } | 73 | } |
70 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); | 74 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); |
71 | } else if (message->isCTCP()) { | 75 | } else if (message->isCTCP()) { |
72 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { | 76 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { |
73 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { | 77 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { |
74 | (this->*(ctcpParserProcTable[i].proc))(message); | 78 | (this->*(ctcpParserProcTable[i].proc))(message); |
75 | return; | 79 | return; |
76 | } | 80 | } |
77 | } | 81 | } |
78 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); | 82 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); |
79 | } else { | 83 | } else { |
80 | for (int i=0; literalParserProcTable[i].commandName; i++) { | 84 | for (int i=0; literalParserProcTable[i].commandName; i++) { |
81 | if (message->command() == literalParserProcTable[i].commandName) { | 85 | if (message->command() == literalParserProcTable[i].commandName) { |
82 | (this->*(literalParserProcTable[i].proc))(message); | 86 | (this->*(literalParserProcTable[i].proc))(message); |
83 | return; | 87 | return; |
84 | } | 88 | } |
85 | } | 89 | } |
86 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); | 90 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); |
87 | } | 91 | } |
88 | } | 92 | } |
89 | 93 | ||
90 | void IRCMessageParser::nullFunc(IRCMessage *) { | 94 | void IRCMessageParser::nullFunc(IRCMessage *) { |
91 | /* Do nothing */ | 95 | /* Do nothing */ |
92 | } | 96 | } |
93 | 97 | ||
94 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { | 98 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { |
95 | m_session->m_connection->sendLine("PONG " + message->allParameters()); | 99 | m_session->m_connection->sendLine("PONG " + message->allParameters()); |
96 | } | 100 | } |
97 | 101 | ||
98 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { | 102 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { |
99 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 103 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
100 | } | 104 | } |
101 | 105 | ||
102 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { | 106 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { |
103 | QString channelName = message->param(0); | 107 | QString channelName = message->param(0).lower(); |
104 | IRCPerson mask(message->prefix()); | 108 | IRCPerson mask(message->prefix()); |
105 | IRCChannel *channel = m_session->getChannel(channelName); | 109 | IRCChannel *channel = m_session->getChannel(channelName); |
106 | if (!channel) { | 110 | if (!channel) { |
107 | /* We joined */ | 111 | /* We joined */ |
108 | if (mask.nick() == m_session->m_server->nick()) { | 112 | if (mask.nick() == m_session->m_server->nick()) { |
109 | channel = new IRCChannel(channelName); | 113 | channel = new IRCChannel(channelName); |
110 | m_session->addChannel(channel); | 114 | m_session->addChannel(channel); |
111 | } else { | 115 | } else { |
112 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); | 116 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); |
113 | } | 117 | } |
114 | } else { | 118 | } else { |
115 | /* Someone else joined */ | 119 | /* Someone else joined */ |
116 | if (mask.nick() != m_session->m_server->nick()) { | 120 | if (mask.nick() != m_session->m_server->nick()) { |
117 | if (!channel->getPerson(mask.nick())) { | 121 | if (!channel->getPerson(mask.nick())) { |
118 | IRCChannelPerson *chanperson = new IRCChannelPerson(); | 122 | IRCChannelPerson *chanperson = new IRCChannelPerson(); |
119 | IRCPerson *person = m_session->getPerson(mask.nick()); | 123 | IRCPerson *person = m_session->getPerson(mask.nick()); |
120 | if (!person) { | 124 | if (!person) { |
121 | person = new IRCPerson(message->prefix()); | 125 | person = new IRCPerson(message->prefix()); |
122 | m_session->addPerson(person); | 126 | m_session->addPerson(person); |
123 | } | 127 | } |
124 | chanperson->flags = 0; | 128 | chanperson->flags = 0; |
125 | chanperson->person = person; | 129 | chanperson->person = person; |
126 | channel->addPerson(chanperson); | 130 | channel->addPerson(chanperson); |
127 | IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); | 131 | IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); |
128 | output.addParam(channel); | 132 | output.addParam(channel); |
129 | output.addParam(chanperson); | 133 | output.addParam(chanperson); |
130 | emit outputReady(output); | 134 | emit outputReady(output); |
131 | } else { | 135 | } else { |
132 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); | 136 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); |
133 | } | 137 | } |
134 | } else { | 138 | } else { |
135 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); | 139 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); |
136 | } | 140 | } |
137 | } | 141 | } |
138 | } | 142 | } |
139 | 143 | ||
140 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { | 144 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { |
141 | QString channelName = message->param(0); | 145 | QString channelName = message->param(0).lower(); |
142 | IRCChannel *channel = m_session->getChannel(channelName); | 146 | IRCChannel *channel = m_session->getChannel(channelName); |
143 | IRCPerson mask(message->prefix()); | 147 | IRCPerson mask(message->prefix()); |
144 | if (channel) { | 148 | if (channel) { |
145 | if (mask.nick() == m_session->m_server->nick()) { | 149 | if (mask.nick() == m_session->m_server->nick()) { |
146 | m_session->removeChannel(channel); | 150 | m_session->removeChannel(channel); |
147 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); | 151 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); |
148 | output.addParam(channel); | 152 | output.addParam(channel); |
149 | emit outputReady(output); | 153 | emit outputReady(output); |
150 | delete channel; | 154 | delete channel; |
151 | } else { | 155 | } else { |
152 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 156 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
153 | if (person) { | 157 | if (person) { |
154 | channel->removePerson(person); | 158 | channel->removePerson(person); |
155 | IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); | 159 | IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); |
156 | output.addParam(channel); | 160 | output.addParam(channel); |
157 | output.addParam(person); | 161 | output.addParam(person); |
158 | emit outputReady(output); | 162 | emit outputReady(output); |
159 | delete person; | 163 | delete person; |
160 | } else { | 164 | } else { |
161 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); | 165 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); |
162 | } | 166 | } |
163 | } | 167 | } |
164 | } else { | 168 | } else { |
165 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); | 169 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); |
166 | } | 170 | } |
167 | } | 171 | } |
168 | 172 | ||
169 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | 173 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { |
170 | if (m_session->m_server->nick() == message->param(0)) { | 174 | if (m_session->m_server->nick() == message->param(0)) { |
171 | /* IRC Query message detected, verify sender and display it */ | 175 | /* IRC Query message detected, verify sender and display it */ |
172 | IRCPerson mask(message->prefix()); | 176 | IRCPerson mask(message->prefix()); |
173 | IRCPerson *person = m_session->getPerson(mask.nick()); | 177 | IRCPerson *person = m_session->getPerson(mask.nick()); |
174 | if (!person) { | 178 | if (!person) { |
175 | /* Person not yet known, create and add to the current session */ | 179 | /* Person not yet known, create and add to the current session */ |
176 | person = new IRCPerson(message->prefix()); | 180 | person = new IRCPerson(message->prefix()); |
177 | m_session->addPerson(person); | 181 | m_session->addPerson(person); |
178 | } | 182 | } |
179 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); | 183 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); |
180 | output.addParam(person); | 184 | output.addParam(person); |
181 | emit outputReady(output); | 185 | emit outputReady(output); |
182 | } else if (message->param(0).at(0) == '#') { | 186 | } else if (message->param(0).at(0) == '#') { |
183 | /* IRC Channel message detected, verify sender, channel and display it */ | 187 | /* IRC Channel message detected, verify sender, channel and display it */ |
184 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 188 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
185 | if (channel) { | 189 | if (channel) { |
186 | IRCPerson mask(message->prefix()); | 190 | IRCPerson mask(message->prefix()); |
187 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 191 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
188 | if (person) { | 192 | if (person) { |
189 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); | 193 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); |
190 | output.addParam(channel); | 194 | output.addParam(channel); |
191 | output.addParam(person); | 195 | output.addParam(person); |
192 | emit outputReady(output); | 196 | emit outputReady(output); |
193 | } else { | 197 | } else { |
194 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); | 198 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); |
195 | } | 199 | } |
196 | } else { | 200 | } else { |
197 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0))); | 201 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0).lower())); |
198 | } | 202 | } |
199 | } else { | 203 | } else { |
200 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); | 204 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); |
201 | } | 205 | } |
202 | } | 206 | } |
203 | 207 | ||
204 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 208 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
205 | IRCPerson mask(message->prefix()); | 209 | IRCPerson mask(message->prefix()); |
206 | 210 | ||
207 | if (mask.nick() == m_session->m_server->nick()) { | 211 | if (mask.nick() == m_session->m_server->nick()) { |
208 | /* We are changing our nickname */ | 212 | /* We are changing our nickname */ |
209 | m_session->m_server->setNick(message->param(0)); | 213 | m_session->m_server->setNick(message->param(0)); |
210 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); | 214 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); |
211 | output.addParam(0); | 215 | output.addParam(0); |
212 | emit outputReady(output); | 216 | emit outputReady(output); |
213 | } else { | 217 | } else { |
214 | /* Someone else is */ | 218 | /* Someone else is */ |
215 | IRCPerson *person = m_session->getPerson(mask.nick()); | 219 | IRCPerson *person = m_session->getPerson(mask.nick()); |
216 | if (person) { | 220 | if (person) { |
217 | IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); | 221 | IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); |
218 | output.addParam(person); | 222 | output.addParam(person); |
219 | emit outputReady(output); | 223 | emit outputReady(output); |
220 | } else { | 224 | } else { |
221 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 225 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
222 | } | 226 | } |
223 | } | 227 | } |
224 | } | 228 | } |
225 | 229 | ||
226 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 230 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
227 | IRCPerson mask(message->prefix()); | 231 | IRCPerson mask(message->prefix()); |
228 | IRCPerson *person = m_session->getPerson(mask.nick()); | 232 | IRCPerson *person = m_session->getPerson(mask.nick()); |
229 | if (person) { | 233 | if (person) { |
230 | QList<IRCChannel> channels; | 234 | QList<IRCChannel> channels; |
231 | m_session->getChannelsByPerson(person, channels); | 235 | m_session->getChannelsByPerson(person, channels); |
232 | QListIterator<IRCChannel> it(channels); | 236 | QListIterator<IRCChannel> it(channels); |
233 | for (;it.current(); ++it) { | 237 | for (;it.current(); ++it) { |
234 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 238 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
235 | it.current()->removePerson(chanperson); | 239 | it.current()->removePerson(chanperson); |
236 | delete chanperson; | 240 | delete chanperson; |
237 | } | 241 | } |
238 | m_session->removePerson(person); | 242 | m_session->removePerson(person); |
239 | IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); | 243 | IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); |
240 | output.addParam(person); | 244 | output.addParam(person); |
241 | emit outputReady(output); | 245 | emit outputReady(output); |
242 | delete person; | 246 | delete person; |
243 | } else { | 247 | } else { |
244 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); | 248 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); |
245 | } | 249 | } |
246 | } | 250 | } |
247 | 251 | ||
248 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { | 252 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { |
249 | IRCPerson mask(message->prefix()); | 253 | IRCPerson mask(message->prefix()); |
250 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 254 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
251 | if (channel) { | 255 | if (channel) { |
252 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); | 256 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); |
253 | output.addParam(channel); | 257 | output.addParam(channel); |
254 | emit outputReady(output); | 258 | emit outputReady(output); |
255 | } else { | 259 | } else { |
256 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); | 260 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); |
257 | } | 261 | } |
258 | } | 262 | } |
259 | 263 | ||
260 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { | 264 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { |
261 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); | 265 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); |
262 | } | 266 | } |
263 | 267 | ||
264 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | 268 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { |
265 | IRCPerson mask(message->prefix()); | 269 | IRCPerson mask(message->prefix()); |
266 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); | 270 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); |
267 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); | 271 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); |
268 | } | 272 | } |
269 | 273 | ||
270 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 274 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
271 | IRCPerson mask(message->prefix()); | 275 | IRCPerson mask(message->prefix()); |
272 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); | 276 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); |
273 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); | 277 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); |
274 | } | 278 | } |
275 | 279 | ||
276 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | 280 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { |
277 | IRCPerson mask(message->prefix()); | 281 | IRCPerson mask(message->prefix()); |
278 | QString dest = message->ctcpDestination(); | 282 | QString dest = message->ctcpDestination(); |
279 | if (dest.startsWith("#")) { | 283 | if (dest.startsWith("#")) { |
280 | IRCChannel *channel = m_session->getChannel(dest); | 284 | IRCChannel *channel = m_session->getChannel(dest.lower()); |
281 | if (channel) { | 285 | if (channel) { |
282 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 286 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
283 | if (person) { | 287 | if (person) { |
284 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); | 288 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); |
285 | output.addParam(channel); | 289 | output.addParam(channel); |
286 | output.addParam(person); | 290 | output.addParam(person); |
287 | emit outputReady(output); | 291 | emit outputReady(output); |
288 | } else { | 292 | } else { |
289 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); | 293 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); |
290 | } | 294 | } |
291 | } else { | 295 | } else { |
292 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); | 296 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); |
293 | } | 297 | } |
294 | } else { | 298 | } else { |
295 | if (message->ctcpDestination() == m_session->m_server->nick()) { | 299 | if (message->ctcpDestination() == m_session->m_server->nick()) { |
296 | IRCPerson *person = m_session->getPerson(mask.nick()); | 300 | IRCPerson *person = m_session->getPerson(mask.nick()); |
297 | if (!person) { | 301 | if (!person) { |
298 | /* Person not yet known, create and add to the current session */ | 302 | /* Person not yet known, create and add to the current session */ |
299 | person = new IRCPerson(message->prefix()); | 303 | person = new IRCPerson(message->prefix()); |
300 | m_session->addPerson(person); | 304 | m_session->addPerson(person); |
301 | } | 305 | } |
302 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 306 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
303 | output.addParam(person); | 307 | output.addParam(person); |
304 | emit outputReady(output); | 308 | emit outputReady(output); |
305 | } else { | 309 | } else { |
306 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 310 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
307 | } | 311 | } |
308 | } | 312 | } |
309 | } | 313 | } |
310 | 314 | ||
311 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 315 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
312 | IRCPerson mask(message->prefix()); | 316 | IRCPerson mask(message->prefix()); |
313 | 317 | ||
314 | if (message->param(0).startsWith("#")) { | 318 | if (message->param(0).startsWith("#")) { |
315 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 319 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
316 | if (channel) { | 320 | if (channel) { |
317 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); | 321 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); |
318 | QTextIStream stream(¶meters); | 322 | QTextIStream stream(¶meters); |
319 | bool set = FALSE; | 323 | bool set = FALSE; |
320 | while (!stream.atEnd()) { | 324 | while (!stream.atEnd()) { |
321 | stream >> temp; | 325 | stream >> temp; |
322 | if (temp.startsWith("+")) { | 326 | if (temp.startsWith("+")) { |
323 | set = TRUE; | 327 | set = TRUE; |
324 | temp = temp.right(1); | 328 | temp = temp.right(1); |
325 | } else if (temp.startsWith("-")) { | 329 | } else if (temp.startsWith("-")) { |
326 | set = FALSE; | 330 | set = FALSE; |
327 | temp = temp.right(1); | 331 | temp = temp.right(1); |
328 | } else { | 332 | } else { |
329 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); | 333 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); |
330 | return; | 334 | return; |
331 | } | 335 | } |
332 | if (temp == "o") { | 336 | if (temp == "o") { |
333 | stream >> temp; | 337 | stream >> temp; |
334 | IRCChannelPerson *person = channel->getPerson(temp); | 338 | IRCChannelPerson *person = channel->getPerson(temp); |
335 | if (person) { | 339 | if (person) { |
336 | if (set) { | 340 | if (set) { |
337 | person->flags |= PERSON_FLAG_OP; | 341 | person->flags |= PERSON_FLAG_OP; |
338 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); | 342 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); |
339 | output.addParam(channel); | 343 | output.addParam(channel); |
340 | output.addParam(person); | 344 | output.addParam(person); |
341 | emit outputReady(output); | 345 | emit outputReady(output); |
342 | } else { | 346 | } else { |
343 | person->flags &= 0xFFFF - PERSON_FLAG_OP; | 347 | person->flags &= 0xFFFF - PERSON_FLAG_OP; |
344 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); | 348 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); |
345 | output.addParam(channel); | 349 | output.addParam(channel); |
346 | output.addParam(person); | 350 | output.addParam(person); |
347 | emit outputReady(output); | 351 | emit outputReady(output); |
348 | } | 352 | } |
349 | } else { | 353 | } else { |
350 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 354 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
351 | } | 355 | } |
352 | } else if (temp == "v") { | 356 | } else if (temp == "v") { |
353 | stream >> temp; | 357 | stream >> temp; |
354 | IRCChannelPerson *person = channel->getPerson(temp); | 358 | IRCChannelPerson *person = channel->getPerson(temp); |
355 | if (person) { | 359 | if (person) { |
356 | if (set) { | 360 | if (set) { |
357 | person->flags |= PERSON_FLAG_VOICE; | 361 | person->flags |= PERSON_FLAG_VOICE; |
358 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); | 362 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); |
359 | output.addParam(channel); | 363 | output.addParam(channel); |
360 | output.addParam(person); | 364 | output.addParam(person); |
361 | emit outputReady(output); | 365 | emit outputReady(output); |
362 | } else { | 366 | } else { |
363 | person->flags &= 0xFFFF - PERSON_FLAG_VOICE; | 367 | person->flags &= 0xFFFF - PERSON_FLAG_VOICE; |
364 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); | 368 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); |
365 | output.addParam(channel); | 369 | output.addParam(channel); |
366 | output.addParam(person); | 370 | output.addParam(person); |
367 | emit outputReady(output); | 371 | emit outputReady(output); |
368 | } | 372 | } |
369 | } else { | 373 | } else { |
370 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 374 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
371 | } | 375 | } |
372 | } else { | 376 | } else { |
373 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); | 377 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); |
374 | } | 378 | } |
375 | } | 379 | } |
376 | } else { | 380 | } else { |
377 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); | 381 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); |
378 | } | 382 | } |
379 | } else { | 383 | } else { |
380 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); | 384 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); |
381 | } | 385 | } |
382 | } | 386 | } |
383 | 387 | ||
384 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | 388 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { |
385 | IRCPerson mask(message->prefix()); | 389 | IRCPerson mask(message->prefix()); |
386 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 390 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
387 | if (channel) { | 391 | if (channel) { |
388 | IRCChannelPerson *person = channel->getPerson(message->param(1)); | 392 | IRCChannelPerson *person = channel->getPerson(message->param(1)); |
389 | if (person) { | 393 | if (person) { |
390 | if (person->person->nick() == m_session->m_server->nick()) { | 394 | if (person->person->nick() == m_session->m_server->nick()) { |
391 | m_session->removeChannel(channel); | 395 | m_session->removeChannel(channel); |
392 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); | 396 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); |
393 | output.addParam(channel); | 397 | output.addParam(channel); |
394 | emit outputReady(output); | 398 | emit outputReady(output); |
395 | } else { | 399 | } else { |
396 | channel->removePerson(person); | 400 | channel->removePerson(person); |
397 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); | 401 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); |
398 | output.addParam(channel); | 402 | output.addParam(channel); |
399 | output.addParam(person); | 403 | output.addParam(person); |
400 | emit outputReady(output); | 404 | emit outputReady(output); |
401 | } | 405 | } |
402 | } else { | 406 | } else { |
403 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); | 407 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); |
404 | } | 408 | } |
405 | } else { | 409 | } else { |
406 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); | 410 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); |
407 | } | 411 | } |
408 | } | 412 | } |
409 | 413 | ||
410 | void IRCMessageParser::parseNumerical001(IRCMessage *message) { | 414 | void IRCMessageParser::parseNumerical001(IRCMessage *message) { |
411 | /* Welcome to IRC message, display */ | 415 | /* Welcome to IRC message, display */ |
412 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 416 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
413 | } | 417 | } |
414 | 418 | ||
415 | void IRCMessageParser::parseNumerical002(IRCMessage *message) { | 419 | void IRCMessageParser::parseNumerical002(IRCMessage *message) { |
416 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 420 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
417 | } | 421 | } |
418 | 422 | ||
419 | void IRCMessageParser::parseNumerical003(IRCMessage *message) { | 423 | void IRCMessageParser::parseNumerical003(IRCMessage *message) { |
420 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 424 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
421 | } | 425 | } |
422 | 426 | ||
423 | void IRCMessageParser::parseNumerical004(IRCMessage *message) { | 427 | void IRCMessageParser::parseNumerical004(IRCMessage *message) { |
424 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 428 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
425 | } | 429 | } |
426 | 430 | ||
427 | void IRCMessageParser::parseNumerical005(IRCMessage *message) { | 431 | void IRCMessageParser::parseNumerical005(IRCMessage *message) { |
428 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 432 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
429 | } | 433 | } |
430 | 434 | ||
431 | void IRCMessageParser::parseNumericalStats(IRCMessage *message) { | 435 | void IRCMessageParser::parseNumericalStats(IRCMessage *message) { |
432 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 436 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
433 | } | 437 | } |
434 | 438 | ||
435 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | 439 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { |
436 | /* Name list sent when joining a channel */ | 440 | /* Name list sent when joining a channel */ |
437 | IRCChannel *channel = m_session->getChannel(message->param(2)); | 441 | IRCChannel *channel = m_session->getChannel(message->param(2).lower()); |
438 | if (channel != 0) { | 442 | if (channel != 0) { |
439 | QString people = message->param(3); | 443 | QString people = message->param(3); |
440 | QTextIStream stream(&people); | 444 | QTextIStream stream(&people); |
441 | QString temp; | 445 | QString temp; |
442 | 446 | ||
443 | while (!stream.atEnd()) { | 447 | while (!stream.atEnd()) { |
444 | stream >> temp; | 448 | stream >> temp; |
445 | 449 | ||
446 | char flagch = temp.at(0).latin1(); | 450 | char flagch = temp.at(0).latin1(); |
447 | int flag = 0; | 451 | int flag = 0; |
448 | QString nick; | 452 | QString nick; |
449 | /* Parse person flags */ | 453 | /* Parse person flags */ |
450 | if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { | 454 | if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { |
451 | 455 | ||
452 | nick = temp.right(temp.length()-1); | 456 | nick = temp.right(temp.length()-1); |
453 | switch (flagch) { | 457 | switch (flagch) { |
454 | case '@': flag = PERSON_FLAG_OP; break; | 458 | case '@': flag = PERSON_FLAG_OP; break; |
455 | case '+': flag = PERSON_FLAG_VOICE; break; | 459 | case '+': flag = PERSON_FLAG_VOICE; break; |
456 | case '%': flag = PERSON_FLAG_HALFOP; break; | 460 | case '%': flag = PERSON_FLAG_HALFOP; break; |
457 | default : flag = 0; break; | 461 | default : flag = 0; break; |
458 | } | 462 | } |
459 | } else { | 463 | } else { |
460 | nick = temp; | 464 | nick = temp; |
461 | } | 465 | } |
462 | 466 | ||
463 | IRCChannelPerson *chan_person = new IRCChannelPerson(); | 467 | IRCChannelPerson *chan_person = new IRCChannelPerson(); |
464 | IRCPerson *person = m_session->getPerson(nick); | 468 | IRCPerson *person = m_session->getPerson(nick); |
465 | if (person == 0) { | 469 | if (person == 0) { |
466 | person = new IRCPerson(); | 470 | person = new IRCPerson(); |
467 | person->setNick(nick); | 471 | person->setNick(nick); |
468 | m_session->addPerson(person); | 472 | m_session->addPerson(person); |
469 | } | 473 | } |
470 | chan_person->person = person; | 474 | chan_person->person = person; |
471 | chan_person->flags = flag; | 475 | chan_person->flags = flag; |
472 | channel->addPerson(chan_person); | 476 | channel->addPerson(chan_person); |
473 | } | 477 | } |
474 | } else { | 478 | } else { |
475 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 479 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
476 | } | 480 | } |
477 | } | 481 | } |
478 | 482 | ||
479 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { | 483 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { |
480 | /* Done syncing to channel */ | 484 | /* Done syncing to channel */ |
481 | IRCChannel *channel = m_session->getChannel(message->param(1)); | 485 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); |
482 | if (channel) { | 486 | if (channel) { |
483 | channel->setHasPeople(TRUE); | 487 | channel->setHasPeople(TRUE); |
484 | /* Yes, we want the names before anything happens inside the GUI */ | 488 | /* Yes, we want the names before anything happens inside the GUI */ |
485 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); | 489 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); |
486 | output.addParam(channel); | 490 | output.addParam(channel); |
487 | emit outputReady(output); | 491 | emit outputReady(output); |
488 | } else { | 492 | } else { |
489 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 493 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
490 | } | 494 | } |
491 | } | 495 | } |
492 | 496 | ||
493 | 497 | ||
494 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { | 498 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { |
495 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); | 499 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); |
496 | m_session->endSession(); | 500 | m_session->endSession(); |
497 | } | 501 | } |
498 | 502 | ||
499 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { | 503 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { |
500 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); | 504 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); |
501 | } | 505 | } |
502 | 506 | ||
503 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { | 507 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { |
504 | IRCChannel *channel = m_session->getChannel(message->param(1)); | 508 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); |
505 | if (channel) { | 509 | if (channel) { |
506 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); | 510 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); |
507 | output.addParam(channel); | 511 | output.addParam(channel); |
508 | emit outputReady(output); | 512 | emit outputReady(output); |
509 | } else { | 513 | } else { |
510 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); | 514 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); |
511 | output.addParam(0); | 515 | output.addParam(0); |
512 | emit outputReady(output); | 516 | emit outputReady(output); |
513 | } | 517 | } |
514 | } | 518 | } |
515 | 519 | ||
516 | void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *message) { | 520 | void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *message) { |
517 | } | 521 | } |