Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index ad9de2b..939cdae 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -1,19 +1,24 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | 3 | ||
4 | #include <opie2/ofiledialog.h> | ||
5 | #include <opie2/ofileselector.h> | ||
6 | #include <opie2/odebug.h> | ||
7 | |||
4 | #include "ircmessageparser.h" | 8 | #include "ircmessageparser.h" |
5 | #include "ircversion.h" | 9 | #include "ircversion.h" |
6 | #include "ircchannelperson.h" | 10 | #include "ircchannelperson.h" |
7 | //#include "transferreceiver.h" | 11 | #include "dcctransfertab.h" |
12 | #include "ircservertab.h" | ||
8 | 13 | ||
9 | /* Lookup table for literal commands */ | 14 | /* Lookup table for literal commands */ |
10 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | 15 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { |
11 | { "PING", FUNC(parseLiteralPing) }, | 16 | { "PING", FUNC(parseLiteralPing) }, |
12 | { "NOTICE", FUNC(parseLiteralNotice) }, | 17 | { "NOTICE", FUNC(parseLiteralNotice) }, |
13 | { "JOIN", FUNC(parseLiteralJoin) }, | 18 | { "JOIN", FUNC(parseLiteralJoin) }, |
14 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, | 19 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, |
15 | { "NICK", FUNC(parseLiteralNick) }, | 20 | { "NICK", FUNC(parseLiteralNick) }, |
16 | { "PART", FUNC(parseLiteralPart) }, | 21 | { "PART", FUNC(parseLiteralPart) }, |
17 | { "QUIT", FUNC(parseLiteralQuit) }, | 22 | { "QUIT", FUNC(parseLiteralQuit) }, |
18 | { "ERROR", FUNC(parseLiteralError) }, | 23 | { "ERROR", FUNC(parseLiteralError) }, |
19 | { "ERROR:", FUNC(parseLiteralError) }, | 24 | { "ERROR:", FUNC(parseLiteralError) }, |
@@ -452,30 +457,43 @@ void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | |||
452 | } | 457 | } |
453 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 458 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
454 | output.addParam(person); | 459 | output.addParam(person); |
455 | emit outputReady(output); | 460 | emit outputReady(output); |
456 | } else { | 461 | } else { |
457 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 462 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
458 | } | 463 | } |
459 | } | 464 | } |
460 | } | 465 | } |
461 | 466 | ||
462 | void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { | 467 | void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { |
463 | QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace()); | 468 | QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace()); |
469 | |||
470 | if(params[0] == "SEND") { | ||
471 | QString nickname = IRCPerson(message->prefix()).nick(); | ||
464 | if( params.count() != 5) { | 472 | if( params.count() != 5) { |
465 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from ") + IRCPerson(message->prefix()).nick())); | 473 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from %1").arg(nickname))); |
466 | return; | 474 | return; |
467 | } | 475 | } |
476 | bool accepted = DCCTransferTab::confirm(static_cast<QWidget*>(m_session->parent()), nickname, params[1], params[4].toUInt()); | ||
477 | if(!accepted) | ||
478 | return; | ||
479 | QString filename = Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED_ALL, | ||
480 | QString::null, params[1], MimeTypes(), 0, tr("Save As")); | ||
481 | if(filename.isEmpty()) | ||
482 | return; | ||
468 | 483 | ||
469 | //TransferReceiver *foo = new TransferReceiver(params[2].toUInt(), params[3].toUInt(), params[1], params[4].toUInt()); | 484 | 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 | filename, nickname, params[4].toUInt()); | ||
487 | } | ||
470 | } | 488 | } |
471 | 489 | ||
472 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 490 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
473 | IRCPerson mask(message->prefix()); | 491 | IRCPerson mask(message->prefix()); |
474 | 492 | ||
475 | if (message->param(0).startsWith("#")) { | 493 | if (message->param(0).startsWith("#")) { |
476 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 494 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
477 | if (channel) { | 495 | if (channel) { |
478 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); | 496 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); |
479 | QTextIStream stream(¶meters); | 497 | QTextIStream stream(¶meters); |
480 | bool set = FALSE; | 498 | bool set = FALSE; |
481 | while (!stream.atEnd()) { | 499 | while (!stream.atEnd()) { |