summaryrefslogtreecommitdiff
authorskyhusker <skyhusker>2005-06-09 17:30:09 (UTC)
committer skyhusker <skyhusker>2005-06-09 17:30:09 (UTC)
commit2ed64fcf5a3c93ce613e63461cb925568c7df887 (patch) (unidiff)
treeac95266cc27b3bd50e374ab718aadf243ce99524
parent6be140832d97bb485ba98bc9ea0f5cf622330595 (diff)
downloadopie-2ed64fcf5a3c93ce613e63461cb925568c7df887.zip
opie-2ed64fcf5a3c93ce613e63461cb925568c7df887.tar.gz
opie-2ed64fcf5a3c93ce613e63461cb925568c7df887.tar.bz2
Fix #1667
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp5
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
@@ -31,96 +31,97 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
31/* Lookup table for literal commands */ 31/* Lookup table for literal commands */
32IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 32IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
33 { "PING", FUNC(parseCTCPPing) }, 33 { "PING", FUNC(parseCTCPPing) },
34 { "VERSION", FUNC(parseCTCPVersion) }, 34 { "VERSION", FUNC(parseCTCPVersion) },
35 { "ACTION", FUNC(parseCTCPAction) }, 35 { "ACTION", FUNC(parseCTCPAction) },
36 { "DCC", FUNC(parseCTCPDCC) }, 36 { "DCC", FUNC(parseCTCPDCC) },
37 { 0 , 0 } 37 { 0 , 0 }
38}; 38};
39 39
40/* Lookup table for numerical commands 40/* Lookup table for numerical commands
41 * According to: 41 * According to:
42 * http://www.faqs.org/rfcs/rfc1459.html 42 * http://www.faqs.org/rfcs/rfc1459.html
43 * http://www.faqs.org/rfcs/rfc2812.html 43 * http://www.faqs.org/rfcs/rfc2812.html
44*/ 44*/
45 45
46IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { 46IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
47 { 1, "%1", "1", FUNC(parseNumericalServerName) }, // RPL_WELCOME 47 { 1, "%1", "1", FUNC(parseNumericalServerName) }, // RPL_WELCOME
48 { 2, "%1", "1", 0 }, // RPL_YOURHOST 48 { 2, "%1", "1", 0 }, // RPL_YOURHOST
49 { 3, "%1", "1", 0 }, // RPL_CREATED 49 { 3, "%1", "1", 0 }, // RPL_CREATED
50 { 4, QT_TR_NOOP("Server %1 version %2 supports usermodes '%3' and channelmodes '%4'"), "1:4", FUNC(parseNumericalServerFeatures) }, // RPL_MYINFO 50 { 4, QT_TR_NOOP("Server %1 version %2 supports usermodes '%3' and channelmodes '%4'"), "1:4", FUNC(parseNumericalServerFeatures) }, // RPL_MYINFO
51 { 5, 0, 0, FUNC(parseNumericalServerProtocol) }, // RPL_BOUNCE, RPL_PROTOCTL 51 { 5, 0, 0, FUNC(parseNumericalServerProtocol) }, // RPL_BOUNCE, RPL_PROTOCTL
52 { 250, "%1", "1", 0 }, // RPL_STATSCONN 52 { 250, "%1", "1", 0 }, // RPL_STATSCONN
53 { 251, "%1", "1", 0 }, // RPL_LUSERCLIENT 53 { 251, "%1", "1", 0 }, // RPL_LUSERCLIENT
54 { 252, QT_TR_NOOP("There are %1 operators connected"), "1", 0 }, // RPL_LUSEROP 54 { 252, QT_TR_NOOP("There are %1 operators connected"), "1", 0 }, // RPL_LUSEROP
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
93IRCMessageParser::IRCMessageParser(IRCSession *session) { 94IRCMessageParser::IRCMessageParser(IRCSession *session) {
94 m_session = session; 95 m_session = session;
95} 96}
96 97
97void IRCMessageParser::parse(IRCMessage *message) { 98void 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) {
103 parseNumerical(message, i); 104 parseNumerical(message, i);
104 return; 105 return;
105 } 106 }
106 } 107 }
107 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) ))); 108 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) )));
108 } else if (message->isCTCP()) { 109 } else if (message->isCTCP()) {
109 for (int i=0; ctcpParserProcTable[i].commandName; i++) { 110 for (int i=0; ctcpParserProcTable[i].commandName; i++) {
110 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { 111 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) {
111 parseCTCP(message, i); 112 parseCTCP(message, i);
112 return; 113 return;
113 } 114 }
114 } 115 }
115 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) ); 116 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) );
116 } else { 117 } else {
117 for (int i=0; literalParserProcTable[i].commandName; i++) { 118 for (int i=0; literalParserProcTable[i].commandName; i++) {
118 if (message->command() == literalParserProcTable[i].commandName) { 119 if (message->command() == literalParserProcTable[i].commandName) {
119 (this->*(literalParserProcTable[i].proc))(message); 120 (this->*(literalParserProcTable[i].proc))(message);
120 return; 121 return;
121 } 122 }
122 } 123 }
123 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) )); 124 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) ));
124 } 125 }
125} 126}
126 127
@@ -224,97 +225,97 @@ void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
224 } 225 }
225 } 226 }
226} 227}
227 228
228void IRCMessageParser::parseLiteralPart(IRCMessage *message) { 229void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
229 QString channelName = message->param(0).lower(); 230 QString channelName = message->param(0).lower();
230 IRCChannel *channel = m_session->getChannel(channelName); 231 IRCChannel *channel = m_session->getChannel(channelName);
231 IRCPerson mask(message->prefix()); 232 IRCPerson mask(message->prefix());
232 if (channel) { 233 if (channel) {
233 if (mask.nick() == m_session->m_server->nick()) { 234 if (mask.nick() == m_session->m_server->nick()) {
234 m_session->removeChannel(channel); 235 m_session->removeChannel(channel);
235 IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName )); 236 IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName ));
236 output.addParam(channel); 237 output.addParam(channel);
237 emit outputReady(output); 238 emit outputReady(output);
238 delete channel; 239 delete channel;
239 } else { 240 } else {
240 IRCChannelPerson *person = channel->getPerson(mask.nick()); 241 IRCChannelPerson *person = channel->getPerson(mask.nick());
241 if (person) { 242 if (person) {
242 channel->removePerson(person); 243 channel->removePerson(person);
243 IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) ); 244 IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) );
244 output.addParam(channel); 245 output.addParam(channel);
245 output.addParam(person); 246 output.addParam(person);
246 emit outputReady(output); 247 emit outputReady(output);
247 delete person; 248 delete person;
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
257void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { 258void 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
296void IRCMessageParser::parseLiteralNick(IRCMessage *message) { 297void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
297 IRCPerson mask(message->prefix()); 298 IRCPerson mask(message->prefix());
298 m_session->updateNickname(mask.nick(), message->param(0)); 299 m_session->updateNickname(mask.nick(), message->param(0));
299 /* this way of handling nick changes really sucks 300 /* this way of handling nick changes really sucks
300 if (mask.nick() == m_session->m_server->nick()) { 301 if (mask.nick() == m_session->m_server->nick()) {
301 We are changing our nickname 302 We are changing our nickname
302 m_session->m_server->setNick(message->param(0)); 303 m_session->m_server->setNick(message->param(0));
303 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); 304 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0)));
304 output.addParam(0); 305 output.addParam(0);
305 emit outputReady(output); 306 emit outputReady(output);
306 } else { 307 } else {
307 Someone else is 308 Someone else is
308 RCPerson *person = m_session->getPerson(mask.nick()); 309 RCPerson *person = m_session->getPerson(mask.nick());
309 if (person) { 310 if (person) {
310 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 311 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
311 312
312 new code starts here -- this removes the person from all channels 313 new code starts here -- this removes the person from all channels
313 QList<IRCChannel> channels; 314 QList<IRCChannel> channels;
314 m_session->getChannelsByPerson(person, channels); 315 m_session->getChannelsByPerson(person, channels);
315 QListIterator<IRCChannel> it(channels); 316 QListIterator<IRCChannel> it(channels);
316 for (;it.current(); ++it) { 317 for (;it.current(); ++it) {
317 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 318 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
318 it.current()->removePerson(chanperson); 319 it.current()->removePerson(chanperson);
319 chanperson->person->setNick(message->param(0)); 320 chanperson->person->setNick(message->param(0));
320 it.current()->addPerson(chanperson); 321 it.current()->addPerson(chanperson);
@@ -445,97 +446,97 @@ void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
445 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); 446 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));
446 } 447 }
447 } else { 448 } else {
448 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); 449 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?")));
449 } 450 }
450 } else { 451 } else {
451 if (message->ctcpDestination() == m_session->m_server->nick()) { 452 if (message->ctcpDestination() == m_session->m_server->nick()) {
452 IRCPerson *person = m_session->getPerson(mask.nick()); 453 IRCPerson *person = m_session->getPerson(mask.nick());
453 if (!person) { 454 if (!person) {
454 /* Person not yet known, create and add to the current session */ 455 /* Person not yet known, create and add to the current session */
455 person = new IRCPerson(message->prefix()); 456 person = new IRCPerson(message->prefix());
456 m_session->addPerson(person); 457 m_session->addPerson(person);
457 } 458 }
458 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); 459 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0));
459 output.addParam(person); 460 output.addParam(person);
460 emit outputReady(output); 461 emit outputReady(output);
461 } else { 462 } else {
462 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); 463 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
463 } 464 }
464 } 465 }
465} 466}
466 467
467void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { 468void IRCMessageParser::parseCTCPDCC(IRCMessage *message) {
468 QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace()); 469 QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace());
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
490void IRCMessageParser::parseLiteralMode(IRCMessage *message) { 491void 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(&parameters); 498 QTextIStream stream(&parameters);
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) {
518 IRCOutput output(OUTPUT_CHANPERSONMODE, person->setOp(mask.nick(), set)); 519 IRCOutput output(OUTPUT_CHANPERSONMODE, person->setOp(mask.nick(), set));
519 output.addParam(channel); 520 output.addParam(channel);
520 output.addParam(person); 521 output.addParam(person);
521 emit outputReady(output); 522 emit outputReady(output);
522 } 523 }
523 else { 524 else {
524 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); 525 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
525 } 526 }
526 } 527 }
527 else 528 else
528 if (temp == "v") { 529 if (temp == "v") {
529 stream >> temp; 530 stream >> temp;
530 IRCChannelPerson *person = channel->getPerson(temp); 531 IRCChannelPerson *person = channel->getPerson(temp);
531 if (person) { 532 if (person) {
532 IRCOutput output(OUTPUT_CHANPERSONMODE, person->setVoice(mask.nick(), set)); 533 IRCOutput output(OUTPUT_CHANPERSONMODE, person->setVoice(mask.nick(), set));
533 output.addParam(channel); 534 output.addParam(channel);
534 output.addParam(person); 535 output.addParam(person);
535 emit outputReady(output); 536 emit outputReady(output);
536 } 537 }
537 else { 538 else {
538 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); 539 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
539 } 540 }
540 } 541 }
541 else { 542 else {