Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 6b88f34..400ff41 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -197,39 +197,53 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | |||
197 | } else { | 197 | } else { |
198 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); | 198 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); |
199 | } | 199 | } |
200 | } else { | 200 | } else { |
201 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); | 201 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); |
202 | } | 202 | } |
203 | } else { | 203 | } else { |
204 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); | 204 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 208 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
209 | |||
209 | IRCPerson mask(message->prefix()); | 210 | IRCPerson mask(message->prefix()); |
210 | 211 | /* this way of handling nick changes really sucks */ | |
211 | if (mask.nick() == m_session->m_server->nick()) { | 212 | if (mask.nick() == m_session->m_server->nick()) { |
212 | /* We are changing our nickname */ | 213 | /* We are changing our nickname */ |
213 | m_session->m_server->setNick(message->param(0)); | 214 | m_session->m_server->setNick(message->param(0)); |
214 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); | 215 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); |
215 | output.addParam(0); | 216 | output.addParam(0); |
216 | emit outputReady(output); | 217 | emit outputReady(output); |
217 | } else { | 218 | } else { |
218 | /* Someone else is */ | 219 | /* Someone else is */ |
219 | IRCPerson *person = m_session->getPerson(mask.nick()); | 220 | IRCPerson *person = m_session->getPerson(mask.nick()); |
220 | if (person) { | 221 | if (person) { |
221 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0 ))); | 222 | //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); |
222 | output.addParam(person); | 223 | |
223 | emit outputReady(output); | 224 | /* new code starts here -- this removes the person from all channels */ |
225 | QList<IRCChannel> channels; | ||
226 | m_session->getChannelsByPerson(person, channels); | ||
227 | QListIterator<IRCChannel> it(channels); | ||
228 | for (;it.current(); ++it) { | ||
229 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | ||
230 | it.current()->removePerson(chanperson); | ||
231 | chanperson->person->setNick(message->param(0)); | ||
232 | it.current()->addPerson(chanperson); | ||
233 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); | ||
234 | output.addParam(person); | ||
235 | emit outputReady(output); | ||
236 | } | ||
237 | /* new code ends here */ | ||
224 | } else { | 238 | } else { |
225 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 239 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
226 | } | 240 | } |
227 | } | 241 | } |
228 | } | 242 | } |
229 | 243 | ||
230 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 244 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
231 | IRCPerson mask(message->prefix()); | 245 | IRCPerson mask(message->prefix()); |
232 | IRCPerson *person = m_session->getPerson(mask.nick()); | 246 | IRCPerson *person = m_session->getPerson(mask.nick()); |
233 | if (person) { | 247 | if (person) { |
234 | QList<IRCChannel> channels; | 248 | QList<IRCChannel> channels; |
235 | m_session->getChannelsByPerson(person, channels); | 249 | m_session->getChannelsByPerson(person, channels); |
@@ -388,24 +402,25 @@ void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | |||
388 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | 402 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { |
389 | IRCPerson mask(message->prefix()); | 403 | IRCPerson mask(message->prefix()); |
390 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 404 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
391 | if (channel) { | 405 | if (channel) { |
392 | IRCChannelPerson *person = channel->getPerson(message->param(1)); | 406 | IRCChannelPerson *person = channel->getPerson(message->param(1)); |
393 | if (person) { | 407 | if (person) { |
394 | if (person->person->nick() == m_session->m_server->nick()) { | 408 | if (person->person->nick() == m_session->m_server->nick()) { |
395 | m_session->removeChannel(channel); | 409 | m_session->removeChannel(channel); |
396 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); | 410 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); |
397 | output.addParam(channel); | 411 | output.addParam(channel); |
398 | emit outputReady(output); | 412 | emit outputReady(output); |
399 | } else { | 413 | } else { |
414 | /* someone else got kicked */ | ||
400 | channel->removePerson(person); | 415 | channel->removePerson(person); |
401 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); | 416 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); |
402 | output.addParam(channel); | 417 | output.addParam(channel); |
403 | output.addParam(person); | 418 | output.addParam(person); |
404 | emit outputReady(output); | 419 | emit outputReady(output); |
405 | } | 420 | } |
406 | } else { | 421 | } else { |
407 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); | 422 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); |
408 | } | 423 | } |
409 | } else { | 424 | } else { |
410 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); | 425 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); |
411 | } | 426 | } |