summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircmessageparser.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp30
1 files changed, 24 insertions, 6 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,31 +1,36 @@
#include <qtextstream.h>
#include <qdatetime.h>
+#include <opie2/ofiledialog.h>
+#include <opie2/ofileselector.h>
+#include <opie2/odebug.h>
+
#include "ircmessageparser.h"
#include "ircversion.h"
#include "ircchannelperson.h"
-//#include "transferreceiver.h"
+#include "dcctransfertab.h"
+#include "ircservertab.h"
/* Lookup table for literal commands */
IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
{ "PING", FUNC(parseLiteralPing) },
{ "NOTICE", FUNC(parseLiteralNotice) },
{ "JOIN", FUNC(parseLiteralJoin) },
{ "PRIVMSG", FUNC(parseLiteralPrivMsg) },
{ "NICK", FUNC(parseLiteralNick) },
{ "PART", FUNC(parseLiteralPart) },
{ "QUIT", FUNC(parseLiteralQuit) },
{ "ERROR", FUNC(parseLiteralError) },
{ "ERROR:", FUNC(parseLiteralError) },
{ "MODE", FUNC(parseLiteralMode) },
{ "KICK", FUNC(parseLiteralKick) },
{ "TOPIC", FUNC(parseLiteralTopic) },
{ 0 , 0 }
};
/* Lookup table for literal commands */
IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
{ "PING", FUNC(parseCTCPPing) },
{ "VERSION", FUNC(parseCTCPVersion) },
{ "ACTION", FUNC(parseCTCPAction) },
{ "DCC", FUNC(parseCTCPDCC) },
@@ -440,54 +445,67 @@ void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?")));
}
} else {
if (message->ctcpDestination() == m_session->m_server->nick()) {
IRCPerson *person = m_session->getPerson(mask.nick());
if (!person) {
/* Person not yet known, create and add to the current session */
person = new IRCPerson(message->prefix());
m_session->addPerson(person);
}
IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0));
output.addParam(person);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
}
}
}
void IRCMessageParser::parseCTCPDCC(IRCMessage *message) {
QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace());
- if( params.count() != 5) {
- emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from ") + IRCPerson(message->prefix()).nick()));
- return;
+
+ if(params[0] == "SEND") {
+ QString nickname = IRCPerson(message->prefix()).nick();
+ if( params.count() != 5) {
+ emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Malformed DCC request from %1").arg(nickname)));
+ return;
+ }
+ bool accepted = DCCTransferTab::confirm(static_cast<QWidget*>(m_session->parent()), nickname, params[1], params[4].toUInt());
+ if(!accepted)
+ return;
+ QString filename = Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED_ALL,
+ QString::null, params[1], MimeTypes(), 0, tr("Save As"));
+ if(filename.isEmpty())
+ return;
+
+ odebug << "Receiving file " << filename << " from " << nickname << oendl;
+ static_cast<IRCServerTab*>(m_session->parent())->mainwindow()->addDCC(DCCTransfer::Recv, params[2].toUInt(), params[3].toUInt(),
+ filename, nickname, params[4].toUInt());
}
-
- //TransferReceiver *foo = new TransferReceiver(params[2].toUInt(), params[3].toUInt(), params[1], params[4].toUInt());
}
void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
IRCPerson mask(message->prefix());
if (message->param(0).startsWith("#")) {
IRCChannel *channel = m_session->getChannel(message->param(0).lower());
if (channel) {
QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1);
QTextIStream stream(&parameters);
bool set = FALSE;
while (!stream.atEnd()) {
stream >> temp;
if (temp.startsWith("+")) {
set = TRUE;
temp = temp.right(1);
}
else
if (temp.startsWith("-")) {
set = FALSE;
temp = temp.right(1);
}
else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type")));