author | skyhusker <skyhusker> | 2005-06-09 17:30:09 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-06-09 17:30:09 (UTC) |
commit | 2ed64fcf5a3c93ce613e63461cb925568c7df887 (patch) (unidiff) | |
tree | ac95266cc27b3bd50e374ab718aadf243ce99524 | |
parent | 6be140832d97bb485ba98bc9ea0f5cf622330595 (diff) | |
download | opie-2ed64fcf5a3c93ce613e63461cb925568c7df887.zip opie-2ed64fcf5a3c93ce613e63461cb925568c7df887.tar.gz opie-2ed64fcf5a3c93ce613e63461cb925568c7df887.tar.bz2 |
Fix #1667
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 939cdae..32e1011 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -55,48 +55,49 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | |||
55 | { 253, QT_TR_NOOP("There are %1 unknown connection(s)"), "1", 0 }, // RPL_LUSERUNKNOWN | 55 | { 253, QT_TR_NOOP("There are %1 unknown connection(s)"), "1", 0 }, // RPL_LUSERUNKNOWN |
56 | { 254, QT_TR_NOOP("There are %1 channels formed"), "1", 0 }, // RPL_LUSERCHANNELS | 56 | { 254, QT_TR_NOOP("There are %1 channels formed"), "1", 0 }, // RPL_LUSERCHANNELS |
57 | { 255, "%1", "1", 0 }, // RPL_LUSERME | 57 | { 255, "%1", "1", 0 }, // RPL_LUSERME |
58 | { 263, QT_TR_NOOP("Please wait a while and try again"), 0, 0 }, // RPL_TRYAGAIN | 58 | { 263, QT_TR_NOOP("Please wait a while and try again"), 0, 0 }, // RPL_TRYAGAIN |
59 | { 265, "%1", "1", 0 }, // RPL_LOCALUSERS | 59 | { 265, "%1", "1", 0 }, // RPL_LOCALUSERS |
60 | { 266, "%1", "1", 0 }, // RPL_GLOBALUSERS | 60 | { 266, "%1", "1", 0 }, // RPL_GLOBALUSERS |
61 | { 311, QT_TR_NOOP("Whois %1 (%2@%3)\nReal name: %4"), "1:3,5", 0 }, // RPL_WHOISUSER | 61 | { 311, QT_TR_NOOP("Whois %1 (%2@%3)\nReal name: %4"), "1:3,5", 0 }, // RPL_WHOISUSER |
62 | { 312, QT_TR_NOOP("%1 is using server %2"), "1,2", 0 }, // RPL_WHOISSERVER | 62 | { 312, QT_TR_NOOP("%1 is using server %2"), "1,2", 0 }, // RPL_WHOISSERVER |
63 | { 317, 0, 0, FUNC(parseNumericalWhoisIdle) }, // RPL_WHOISIDLE | 63 | { 317, 0, 0, FUNC(parseNumericalWhoisIdle) }, // RPL_WHOISIDLE |
64 | { 318, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOIS | 64 | { 318, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOIS |
65 | { 319, QT_TR_NOOP("%1 is on channels: %2"), "1,2", 0 }, // RPL_WHOISCHANNELS | 65 | { 319, QT_TR_NOOP("%1 is on channels: %2"), "1,2", 0 }, // RPL_WHOISCHANNELS |
66 | { 320, "%1 %2", "1,2", 0}, // RPL_WHOISVIRT | 66 | { 320, "%1 %2", "1,2", 0}, // RPL_WHOISVIRT |
67 | { 332, 0, 0, FUNC(parseNumericalTopic) }, // RPL_TOPIC | 67 | { 332, 0, 0, FUNC(parseNumericalTopic) }, // RPL_TOPIC |
68 | { 333, 0, 0, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME*/ | 68 | { 333, 0, 0, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME*/ |
69 | { 353, QT_TR_NOOP("Names for %1: %2"), "2,3", FUNC(parseNumericalNames) }, // RPL_NAMREPLY | 69 | { 353, QT_TR_NOOP("Names for %1: %2"), "2,3", FUNC(parseNumericalNames) }, // RPL_NAMREPLY |
70 | { 366, "%1 :%2", "1,2", FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES | 70 | { 366, "%1 :%2", "1,2", FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES |
71 | { 369, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOWAS | 71 | { 369, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOWAS |
72 | { 372, "%1", "1", 0 }, // RPL_MOTD | 72 | { 372, "%1", "1", 0 }, // RPL_MOTD |
73 | { 375, "%1", "1", 0 }, // RPL_MOTDSTART | 73 | { 375, "%1", "1", 0 }, // RPL_MOTDSTART |
74 | { 376, "%1", "1", 0 }, // RPL_ENDOFMOTD | 74 | { 376, "%1", "1", 0 }, // RPL_ENDOFMOTD |
75 | { 377, "%1", "1", 0 }, // RPL_MOTD2 | 75 | { 377, "%1", "1", 0 }, // RPL_MOTD2 |
76 | { 378, "%1", "1", 0 }, // RPL_MOTD3 | 76 | { 378, "%1", "1", 0 }, // RPL_MOTD3 |
77 | { 391, QT_TR_NOOP("Time on server %1 is %2"), "1,2", 0 }, // RPL_TIME | 77 | { 391, QT_TR_NOOP("Time on server %1 is %2"), "1,2", 0 }, // RPL_TIME |
78 | { 401, QT_TR_NOOP("Channel or nick %1 doesn't exists"), "1", 0 }, // ERR_NOSUCHNICK | 78 | { 401, QT_TR_NOOP("Channel or nick %1 doesn't exists"), "1", 0 }, // ERR_NOSUCHNICK |
79 | { 403, QT_TR_NOOP("Channel %1 doesn't exists"), "1", 0 }, // ERR_ERR_NOSUCHCHANNEL | ||
79 | { 406, QT_TR_NOOP("There is no history information for %1"), "1", 0 }, // ERR_WASNOSUCHNICK | 80 | { 406, QT_TR_NOOP("There is no history information for %1"), "1", 0 }, // ERR_WASNOSUCHNICK |
80 | { 409, "%1", "1", 0 }, // ERR_NOORIGIN | 81 | { 409, "%1", "1", 0 }, // ERR_NOORIGIN |
81 | { 411, "%1", "1", 0 }, // ERR_NORECIPIENT | 82 | { 411, "%1", "1", 0 }, // ERR_NORECIPIENT |
82 | { 412, "%1", "1", 0 }, // ERR_NOTEXTTOSEND | 83 | { 412, "%1", "1", 0 }, // ERR_NOTEXTTOSEND |
83 | { 421, QT_TR_NOOP("Unknown command: %1"), "1", 0 }, // ERR_ERR_UNKNOWNCOMMAND | 84 | { 421, QT_TR_NOOP("Unknown command: %1"), "1", 0 }, // ERR_ERR_UNKNOWNCOMMAND |
84 | { 422, "%1", "1", 0 }, // ERR_NOMOTD | 85 | { 422, "%1", "1", 0 }, // ERR_NOMOTD |
85 | { 433, QT_TR_NOOP("Can't change nick to %1: %2"), "1,2", FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE | 86 | { 433, QT_TR_NOOP("Can't change nick to %1: %2"), "1,2", FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE |
86 | { 442, QT_TR_NOOP("You're not on channel %1"), "1", 0}, // ERR_NOTONCHANNEL | 87 | { 442, QT_TR_NOOP("You're not on channel %1"), "1", 0}, // ERR_NOTONCHANNEL |
87 | { 477, "%1", "1", 0 }, // ERR_NOCHANMODES || ERR_NEEDREGGEDNICK | 88 | { 477, "%1", "1", 0 }, // ERR_NOCHANMODES || ERR_NEEDREGGEDNICK |
88 | { 482, QT_TR_NOOP("[%1] Operation not permitted, you don't have enough channel privileges"), "1", 0 }, //ERR_CHANOPRIVSNEEDED | 89 | { 482, QT_TR_NOOP("[%1] Operation not permitted, you don't have enough channel privileges"), "1", 0 }, //ERR_CHANOPRIVSNEEDED |
89 | { 0, 0, 0, 0 } | 90 | { 0, 0, 0, 0 } |
90 | }; | 91 | }; |
91 | 92 | ||
92 | 93 | ||
93 | IRCMessageParser::IRCMessageParser(IRCSession *session) { | 94 | IRCMessageParser::IRCMessageParser(IRCSession *session) { |
94 | m_session = session; | 95 | m_session = session; |
95 | } | 96 | } |
96 | 97 | ||
97 | void IRCMessageParser::parse(IRCMessage *message) { | 98 | void IRCMessageParser::parse(IRCMessage *message) { |
98 | /* Find out what kind of message we have here and call the appropriate handler using | 99 | /* Find out what kind of message we have here and call the appropriate handler using |
99 | the parser tables. If no handler can be found, print out an error message */ | 100 | the parser tables. If no handler can be found, print out an error message */ |
100 | if (message->isNumerical()) { | 101 | if (message->isNumerical()) { |
101 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { | 102 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { |
102 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { | 103 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { |
@@ -248,49 +249,49 @@ void IRCMessageParser::parseLiteralPart(IRCMessage *message) { | |||
248 | } else { | 249 | } else { |
249 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); | 250 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); |
250 | } | 251 | } |
251 | } | 252 | } |
252 | } else { | 253 | } else { |
253 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); | 254 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); |
254 | } | 255 | } |
255 | } | 256 | } |
256 | 257 | ||
257 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | 258 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { |
258 | if (m_session->m_server->nick().lower() == message->param(0).lower() ) { | 259 | if (m_session->m_server->nick().lower() == message->param(0).lower() ) { |
259 | /* IRC Query message detected, verify sender and display it */ | 260 | /* IRC Query message detected, verify sender and display it */ |
260 | IRCPerson mask(message->prefix()); | 261 | IRCPerson mask(message->prefix()); |
261 | IRCPerson *person = m_session->getPerson(mask.nick()); | 262 | IRCPerson *person = m_session->getPerson(mask.nick()); |
262 | if (!person) { | 263 | if (!person) { |
263 | /* Person not yet known, create and add to the current session */ | 264 | /* Person not yet known, create and add to the current session */ |
264 | person = new IRCPerson(message->prefix()); | 265 | person = new IRCPerson(message->prefix()); |
265 | m_session->addPerson(person); | 266 | m_session->addPerson(person); |
266 | } | 267 | } |
267 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); | 268 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); |
268 | output.addParam(person); | 269 | output.addParam(person); |
269 | emit outputReady(output); | 270 | emit outputReady(output); |
270 | } | 271 | } |
271 | else | 272 | else |
272 | if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') { | 273 | if (IRCChannel::isValid(message->param(0))) { |
273 | /* IRC Channel message detected, verify sender, channel and display it */ | 274 | /* IRC Channel message detected, verify sender, channel and display it */ |
274 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 275 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
275 | if (channel) { | 276 | if (channel) { |
276 | IRCPerson mask(message->prefix()); | 277 | IRCPerson mask(message->prefix()); |
277 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 278 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
278 | if (person) { | 279 | if (person) { |
279 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); | 280 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); |
280 | output.addParam(channel); | 281 | output.addParam(channel); |
281 | output.addParam(person); | 282 | output.addParam(person); |
282 | emit outputReady(output); | 283 | emit outputReady(output); |
283 | } | 284 | } |
284 | else { | 285 | else { |
285 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); | 286 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); |
286 | } | 287 | } |
287 | } | 288 | } |
288 | else { | 289 | else { |
289 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); | 290 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); |
290 | } | 291 | } |
291 | } | 292 | } |
292 | else {emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); | 293 | else {emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); |
293 | } | 294 | } |
294 | } | 295 | } |
295 | 296 | ||
296 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 297 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
@@ -469,49 +470,49 @@ void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { | |||
469 | 470 | ||
470 | if(params[0] == "SEND") { | 471 | if(params[0] == "SEND") { |
471 | QString nickname = IRCPerson(message->prefix()).nick(); | 472 | QString nickname = IRCPerson(message->prefix()).nick(); |
472 | if( params.count() != 5) { | 473 | if( params.count() != 5) { |
473 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from %1").arg(nickname))); | 474 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from %1").arg(nickname))); |
474 | return; | 475 | return; |
475 | } | 476 | } |
476 | bool accepted = DCCTransferTab::confirm(static_cast<QWidget*>(m_session->parent()), nickname, params[1], params[4].toUInt()); | 477 | bool accepted = DCCTransferTab::confirm(static_cast<QWidget*>(m_session->parent()), nickname, params[1], params[4].toUInt()); |
477 | if(!accepted) | 478 | if(!accepted) |
478 | return; | 479 | return; |
479 | QString filename = Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED_ALL, | 480 | QString filename = Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED_ALL, |
480 | QString::null, params[1], MimeTypes(), 0, tr("Save As")); | 481 | QString::null, params[1], MimeTypes(), 0, tr("Save As")); |
481 | if(filename.isEmpty()) | 482 | if(filename.isEmpty()) |
482 | return; | 483 | return; |
483 | 484 | ||
484 | odebug << "Receiving file " << filename << " from " << nickname << oendl; | 485 | odebug << "Receiving file " << filename << " from " << nickname << oendl; |
485 | static_cast<IRCServerTab*>(m_session->parent())->mainwindow()->addDCC(DCCTransfer::Recv, params[2].toUInt(), params[3].toUInt(), | 486 | static_cast<IRCServerTab*>(m_session->parent())->mainwindow()->addDCC(DCCTransfer::Recv, params[2].toUInt(), params[3].toUInt(), |
486 | filename, nickname, params[4].toUInt()); | 487 | filename, nickname, params[4].toUInt()); |
487 | } | 488 | } |
488 | } | 489 | } |
489 | 490 | ||
490 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 491 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
491 | IRCPerson mask(message->prefix()); | 492 | IRCPerson mask(message->prefix()); |
492 | 493 | ||
493 | if (message->param(0).startsWith("#")) { | 494 | if (IRCChannel::isValid(message->param(0))) { |
494 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 495 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
495 | if (channel) { | 496 | if (channel) { |
496 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); | 497 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); |
497 | QTextIStream stream(¶meters); | 498 | QTextIStream stream(¶meters); |
498 | bool set = FALSE; | 499 | bool set = FALSE; |
499 | while (!stream.atEnd()) { | 500 | while (!stream.atEnd()) { |
500 | stream >> temp; | 501 | stream >> temp; |
501 | if (temp.startsWith("+")) { | 502 | if (temp.startsWith("+")) { |
502 | set = TRUE; | 503 | set = TRUE; |
503 | temp = temp.right(1); | 504 | temp = temp.right(1); |
504 | } | 505 | } |
505 | else | 506 | else |
506 | if (temp.startsWith("-")) { | 507 | if (temp.startsWith("-")) { |
507 | set = FALSE; | 508 | set = FALSE; |
508 | temp = temp.right(1); | 509 | temp = temp.right(1); |
509 | } | 510 | } |
510 | else { | 511 | else { |
511 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); | 512 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); |
512 | return; | 513 | return; |
513 | } | 514 | } |
514 | if (temp == "o") { | 515 | if (temp == "o") { |
515 | stream >> temp; | 516 | stream >> temp; |
516 | IRCChannelPerson *person = channel->getPerson(temp); | 517 | IRCChannelPerson *person = channel->getPerson(temp); |
517 | if (person) { | 518 | if (person) { |