-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 32e1011..c449a65 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -212,457 +212,472 @@ void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { | |||
212 | m_session->addPerson(person); | 212 | m_session->addPerson(person); |
213 | } | 213 | } |
214 | IRCChannelPerson *chanperson = new IRCChannelPerson(person); | 214 | IRCChannelPerson *chanperson = new IRCChannelPerson(person); |
215 | channel->addPerson(chanperson); | 215 | channel->addPerson(chanperson); |
216 | IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName )); | 216 | IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName )); |
217 | output.addParam(channel); | 217 | output.addParam(channel); |
218 | output.addParam(chanperson); | 218 | output.addParam(chanperson); |
219 | emit outputReady(output); | 219 | emit outputReady(output); |
220 | } else { | 220 | } else { |
221 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); | 221 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); |
222 | } | 222 | } |
223 | } else { | 223 | } else { |
224 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); | 224 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { | 229 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { |
230 | QString channelName = message->param(0).lower(); | 230 | QString channelName = message->param(0).lower(); |
231 | IRCChannel *channel = m_session->getChannel(channelName); | 231 | IRCChannel *channel = m_session->getChannel(channelName); |
232 | IRCPerson mask(message->prefix()); | 232 | IRCPerson mask(message->prefix()); |
233 | if (channel) { | 233 | if (channel) { |
234 | if (mask.nick() == m_session->m_server->nick()) { | 234 | if (mask.nick() == m_session->m_server->nick()) { |
235 | m_session->removeChannel(channel); | 235 | m_session->removeChannel(channel); |
236 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName )); | 236 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName )); |
237 | output.addParam(channel); | 237 | output.addParam(channel); |
238 | emit outputReady(output); | 238 | emit outputReady(output); |
239 | delete channel; | 239 | delete channel; |
240 | } else { | 240 | } else { |
241 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 241 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
242 | if (person) { | 242 | if (person) { |
243 | channel->removePerson(person); | 243 | channel->removePerson(person); |
244 | 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) ); |
245 | output.addParam(channel); | 245 | output.addParam(channel); |
246 | output.addParam(person); | 246 | output.addParam(person); |
247 | emit outputReady(output); | 247 | emit outputReady(output); |
248 | delete person; | 248 | delete person; |
249 | } else { | 249 | } else { |
250 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); | 250 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } else { | 253 | } else { |
254 | 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?"))); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | 257 | ||
258 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | 258 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { |
259 | if (m_session->m_server->nick().lower() == message->param(0).lower() ) { | 259 | if (m_session->m_server->nick().lower() == message->param(0).lower() ) { |
260 | /* IRC Query message detected, verify sender and display it */ | 260 | /* IRC Query message detected, verify sender and display it */ |
261 | IRCPerson mask(message->prefix()); | 261 | IRCPerson mask(message->prefix()); |
262 | IRCPerson *person = m_session->getPerson(mask.nick()); | 262 | IRCPerson *person = m_session->getPerson(mask.nick()); |
263 | if (!person) { | 263 | if (!person) { |
264 | /* Person not yet known, create and add to the current session */ | 264 | /* Person not yet known, create and add to the current session */ |
265 | person = new IRCPerson(message->prefix()); | 265 | person = new IRCPerson(message->prefix()); |
266 | m_session->addPerson(person); | 266 | m_session->addPerson(person); |
267 | } | 267 | } |
268 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); | 268 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); |
269 | output.addParam(person); | 269 | output.addParam(person); |
270 | emit outputReady(output); | 270 | emit outputReady(output); |
271 | } | 271 | } |
272 | else | 272 | else |
273 | if (IRCChannel::isValid(message->param(0))) { | 273 | if (IRCChannel::isValid(message->param(0))) { |
274 | /* IRC Channel message detected, verify sender, channel and display it */ | 274 | /* IRC Channel message detected, verify sender, channel and display it */ |
275 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 275 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
276 | if (channel) { | 276 | if (channel) { |
277 | IRCPerson mask(message->prefix()); | 277 | IRCPerson mask(message->prefix()); |
278 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 278 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
279 | if (person) { | 279 | if (person) { |
280 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); | 280 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); |
281 | output.addParam(channel); | 281 | output.addParam(channel); |
282 | output.addParam(person); | 282 | output.addParam(person); |
283 | emit outputReady(output); | 283 | emit outputReady(output); |
284 | } | 284 | } |
285 | else { | 285 | else { |
286 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); | 286 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | else { | 289 | else { |
290 | 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()) )); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 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"))); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 297 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
298 | IRCPerson mask(message->prefix()); | 298 | IRCPerson mask(message->prefix()); |
299 | m_session->updateNickname(mask.nick(), message->param(0)); | 299 | m_session->updateNickname(mask.nick(), message->param(0)); |
300 | /* this way of handling nick changes really sucks | 300 | /* this way of handling nick changes really sucks |
301 | if (mask.nick() == m_session->m_server->nick()) { | 301 | if (mask.nick() == m_session->m_server->nick()) { |
302 | We are changing our nickname | 302 | We are changing our nickname |
303 | m_session->m_server->setNick(message->param(0)); | 303 | m_session->m_server->setNick(message->param(0)); |
304 | 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))); |
305 | output.addParam(0); | 305 | output.addParam(0); |
306 | emit outputReady(output); | 306 | emit outputReady(output); |
307 | } else { | 307 | } else { |
308 | Someone else is | 308 | Someone else is |
309 | RCPerson *person = m_session->getPerson(mask.nick()); | 309 | RCPerson *person = m_session->getPerson(mask.nick()); |
310 | if (person) { | 310 | if (person) { |
311 | //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))); |
312 | 312 | ||
313 | new code starts here -- this removes the person from all channels | 313 | new code starts here -- this removes the person from all channels |
314 | QList<IRCChannel> channels; | 314 | QList<IRCChannel> channels; |
315 | m_session->getChannelsByPerson(person, channels); | 315 | m_session->getChannelsByPerson(person, channels); |
316 | QListIterator<IRCChannel> it(channels); | 316 | QListIterator<IRCChannel> it(channels); |
317 | for (;it.current(); ++it) { | 317 | for (;it.current(); ++it) { |
318 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 318 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
319 | it.current()->removePerson(chanperson); | 319 | it.current()->removePerson(chanperson); |
320 | chanperson->person->setNick(message->param(0)); | 320 | chanperson->person->setNick(message->param(0)); |
321 | it.current()->addPerson(chanperson); | 321 | it.current()->addPerson(chanperson); |
322 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); | 322 | IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); |
323 | output.addParam(person); | 323 | output.addParam(person); |
324 | emit outputReady(output); | 324 | emit outputReady(output); |
325 | } | 325 | } |
326 | new code ends here | 326 | new code ends here |
327 | } else { | 327 | } else { |
328 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 328 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
329 | } | 329 | } |
330 | }*/ | 330 | }*/ |
331 | } | 331 | } |
332 | 332 | ||
333 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 333 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
334 | IRCPerson mask(message->prefix()); | 334 | IRCPerson mask(message->prefix()); |
335 | IRCPerson *person = m_session->getPerson(mask.nick()); | 335 | IRCPerson *person = m_session->getPerson(mask.nick()); |
336 | if (person) { | 336 | if (person) { |
337 | QList<IRCChannel> channels; | 337 | QList<IRCChannel> channels; |
338 | m_session->getChannelsByPerson(person, channels); | 338 | m_session->getChannelsByPerson(person, channels); |
339 | QListIterator<IRCChannel> it(channels); | 339 | QListIterator<IRCChannel> it(channels); |
340 | for (;it.current(); ++it) { | 340 | for (;it.current(); ++it) { |
341 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 341 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
342 | it.current()->removePerson(chanperson); | 342 | it.current()->removePerson(chanperson); |
343 | delete chanperson; | 343 | delete chanperson; |
344 | } | 344 | } |
345 | m_session->removePerson(person); | 345 | m_session->removePerson(person); |
346 | IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); | 346 | IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); |
347 | output.addParam(person); | 347 | output.addParam(person); |
348 | emit outputReady(output); | 348 | emit outputReady(output); |
349 | delete person; | 349 | delete person; |
350 | } else { | 350 | } else { |
351 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); | 351 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { | 355 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { |
356 | IRCPerson mask(message->prefix()); | 356 | IRCPerson mask(message->prefix()); |
357 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 357 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
358 | if (channel) { | 358 | if (channel) { |
359 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); | 359 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); |
360 | output.addParam(channel); | 360 | output.addParam(channel); |
361 | emit outputReady(output); | 361 | emit outputReady(output); |
362 | } else { | 362 | } else { |
363 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); | 363 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { | 367 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { |
368 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); | 368 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); |
369 | } | 369 | } |
370 | 370 | ||
371 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | 371 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { |
372 | IRCPerson mask(message->prefix()); | 372 | IRCPerson mask(message->prefix()); |
373 | if(message->isCTCPReply()) { | 373 | if(message->isCTCPReply()) { |
374 | unsigned int sentTime = message->param(0).toUInt(); | 374 | unsigned int sentTime = message->param(0).toUInt(); |
375 | QDateTime tm; | 375 | QDateTime tm; |
376 | tm.setTime_t(0); | 376 | tm.setTime_t(0); |
377 | unsigned int receivedTime = tm.secsTo(QDateTime::currentDateTime()); | 377 | unsigned int receivedTime = tm.secsTo(QDateTime::currentDateTime()); |
378 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING reply from %1: %2 seconds").arg(mask.nick()).arg(receivedTime-sentTime))); | 378 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING reply from %1: %2 seconds").arg(mask.nick()).arg(receivedTime-sentTime))); |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | m_session->m_connection->sendCTCPReply(mask.nick(), "PING", message->allParameters()); | 381 | m_session->m_connection->sendCTCPReply(mask.nick(), "PING", message->allParameters()); |
382 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING request from %1").arg(mask.nick()))); | 382 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING request from %1").arg(mask.nick()))); |
383 | 383 | ||
384 | //IRCPerson mask(message->prefix()); | 384 | //IRCPerson mask(message->prefix()); |
385 | QString dest = message->ctcpDestination(); | 385 | QString dest = message->ctcpDestination(); |
386 | if (dest.startsWith("#")) { | 386 | if (dest.startsWith("#")) { |
387 | IRCChannel *channel = m_session->getChannel(dest.lower()); | 387 | IRCChannel *channel = m_session->getChannel(dest.lower()); |
388 | if (channel) { | 388 | if (channel) { |
389 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 389 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
390 | if (person) { | 390 | if (person) { |
391 | IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ; | 391 | IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ; |
392 | output.addParam(channel); | 392 | output.addParam(channel); |
393 | output.addParam(person); | 393 | output.addParam(person); |
394 | emit outputReady(output); | 394 | emit outputReady(output); |
395 | } else { | 395 | } else { |
396 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?"))); | 396 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?"))); |
397 | } | 397 | } |
398 | } else { | 398 | } else { |
399 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?"))); | 399 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?"))); |
400 | } | 400 | } |
401 | } else { | 401 | } else { |
402 | if (message->ctcpDestination() == m_session->m_server->nick()) { | 402 | if (message->ctcpDestination() == m_session->m_server->nick()) { |
403 | IRCPerson *person = m_session->getPerson(mask.nick()); | 403 | IRCPerson *person = m_session->getPerson(mask.nick()); |
404 | if (!person) { | 404 | if (!person) { |
405 | /* Person not yet known, create and add to the current session */ | 405 | /* Person not yet known, create and add to the current session */ |
406 | person = new IRCPerson(message->prefix()); | 406 | person = new IRCPerson(message->prefix()); |
407 | m_session->addPerson(person); | 407 | m_session->addPerson(person); |
408 | } | 408 | } |
409 | IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() ); | 409 | IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() ); |
410 | output.addParam(person); | 410 | output.addParam(person); |
411 | emit outputReady(output); | 411 | emit outputReady(output); |
412 | } else { | 412 | } else { |
413 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient"))); | 413 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient"))); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | } | 417 | } |
418 | 418 | ||
419 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 419 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
420 | IRCPerson mask(message->prefix()); | 420 | IRCPerson mask(message->prefix()); |
421 | IRCOutput output(OUTPUT_CTCP); | 421 | IRCOutput output(OUTPUT_CTCP); |
422 | if(message->isCTCPRequest()) { | 422 | if(message->isCTCPRequest()) { |
423 | m_session->m_connection->sendCTCPReply(mask.nick(), "VERSION", APP_VERSION " " APP_COPYSTR); | 423 | m_session->m_connection->sendCTCPReply(mask.nick(), "VERSION", APP_VERSION " " APP_COPYSTR); |
424 | output.setMessage(tr("Received a CTCP VERSION request from ") + mask.nick()); | 424 | output.setMessage(tr("Received a CTCP VERSION request from ") + mask.nick()); |
425 | } | 425 | } |
426 | 426 | ||
427 | else { | 427 | else { |
428 | output.setMessage("Received CTCP VERSION reply from " + mask.nick() + ":" + message->param(0)); | 428 | output.setMessage("Received CTCP VERSION reply from " + mask.nick() + ":" + message->param(0)); |
429 | } | 429 | } |
430 | emit outputReady(output); | 430 | emit outputReady(output); |
431 | } | 431 | } |
432 | 432 | ||
433 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | 433 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { |
434 | IRCPerson mask(message->prefix()); | 434 | IRCPerson mask(message->prefix()); |
435 | QString dest = message->ctcpDestination(); | 435 | QString dest = message->ctcpDestination(); |
436 | if (dest.startsWith("#")) { | 436 | if (dest.startsWith("#")) { |
437 | IRCChannel *channel = m_session->getChannel(dest.lower()); | 437 | IRCChannel *channel = m_session->getChannel(dest.lower()); |
438 | if (channel) { | 438 | if (channel) { |
439 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 439 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
440 | if (person) { | 440 | if (person) { |
441 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); | 441 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); |
442 | output.addParam(channel); | 442 | output.addParam(channel); |
443 | output.addParam(person); | 443 | output.addParam(person); |
444 | emit outputReady(output); | 444 | emit outputReady(output); |
445 | } else { | 445 | } else { |
446 | 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?"))); |
447 | } | 447 | } |
448 | } else { | 448 | } else { |
449 | 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?"))); |
450 | } | 450 | } |
451 | } else { | 451 | } else { |
452 | if (message->ctcpDestination() == m_session->m_server->nick()) { | 452 | if (message->ctcpDestination() == m_session->m_server->nick()) { |
453 | IRCPerson *person = m_session->getPerson(mask.nick()); | 453 | IRCPerson *person = m_session->getPerson(mask.nick()); |
454 | if (!person) { | 454 | if (!person) { |
455 | /* Person not yet known, create and add to the current session */ | 455 | /* Person not yet known, create and add to the current session */ |
456 | person = new IRCPerson(message->prefix()); | 456 | person = new IRCPerson(message->prefix()); |
457 | m_session->addPerson(person); | 457 | m_session->addPerson(person); |
458 | } | 458 | } |
459 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 459 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
460 | output.addParam(person); | 460 | output.addParam(person); |
461 | emit outputReady(output); | 461 | emit outputReady(output); |
462 | } else { | 462 | } else { |
463 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 463 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { | 468 | void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { |
469 | QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace()); | 469 | QStringList params = QStringList::split(' ', message->param(0).stripWhiteSpace()); |
470 | 470 | ||
471 | if(params[0] == "SEND") { | 471 | if(params[0] == "SEND") { |
472 | QString nickname = IRCPerson(message->prefix()).nick(); | 472 | QString nickname = IRCPerson(message->prefix()).nick(); |
473 | if( params.count() != 5) { | 473 | if( params.count() != 5) { |
474 | 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))); |
475 | return; | 475 | return; |
476 | } | 476 | } |
477 | 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()); |
478 | if(!accepted) | 478 | if(!accepted) |
479 | return; | 479 | return; |
480 | QString filename = Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED_ALL, | 480 | QString filename = Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED_ALL, |
481 | QString::null, params[1], MimeTypes(), 0, tr("Save As")); | 481 | QString::null, params[1], MimeTypes(), 0, tr("Save As")); |
482 | if(filename.isEmpty()) | 482 | if(filename.isEmpty()) |
483 | return; | 483 | return; |
484 | 484 | ||
485 | odebug << "Receiving file " << filename << " from " << nickname << oendl; | 485 | odebug << "Receiving file " << filename << " from " << nickname << oendl; |
486 | 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(), |
487 | filename, nickname, params[4].toUInt()); | 487 | filename, nickname, params[4].toUInt()); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | 490 | ||
491 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 491 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
492 | IRCPerson mask(message->prefix()); | 492 | IRCPerson mask(message->prefix()); |
493 | 493 | ||
494 | if (IRCChannel::isValid(message->param(0))) { | 494 | if (IRCChannel::isValid(message->param(0))) { |
495 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 495 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
496 | if (channel) { | 496 | if (channel) { |
497 | 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); |
498 | QTextIStream stream(¶meters); | 498 | QTextIStream stream(¶meters); |
499 | bool set = FALSE; | 499 | bool set = FALSE; |
500 | while (!stream.atEnd()) { | 500 | while (!stream.atEnd()) { |
501 | stream >> temp; | 501 | stream >> temp; |
502 | if (temp.startsWith("+")) { | 502 | if (temp.startsWith("+")) { |
503 | set = TRUE; | 503 | set = TRUE; |
504 | temp = temp.right(1); | 504 | temp = temp.right(1); |
505 | } | 505 | } |
506 | else | 506 | else |
507 | if (temp.startsWith("-")) { | 507 | if (temp.startsWith("-")) { |
508 | set = FALSE; | 508 | set = FALSE; |
509 | temp = temp.right(1); | 509 | temp = temp.right(1); |
510 | } | 510 | } |
511 | else { | 511 | else { |
512 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); | 512 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); |
513 | return; | 513 | return; |
514 | } | 514 | } |
515 | if (temp == "o") { | 515 | if (temp == "o") { |
516 | stream >> temp; | 516 | stream >> temp; |
517 | IRCChannelPerson *person = channel->getPerson(temp); | 517 | IRCChannelPerson *person = channel->getPerson(temp); |
518 | if (person) { | 518 | if (person) { |
519 | IRCOutput output(OUTPUT_CHANPERSONMODE, person->setOp(mask.nick(), set)); | 519 | IRCOutput output(OUTPUT_CHANPERSONMODE, person->setOp(mask.nick(), set)); |
520 | output.addParam(channel); | 520 | output.addParam(channel); |
521 | output.addParam(person); | 521 | output.addParam(person); |
522 | emit outputReady(output); | 522 | emit outputReady(output); |
523 | } | 523 | } |
524 | else { | 524 | else { |
525 | 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?"))); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | else | 528 | else |
529 | if (temp == "v") { | 529 | if (temp == "v") { |
530 | stream >> temp; | 530 | stream >> temp; |
531 | IRCChannelPerson *person = channel->getPerson(temp); | 531 | IRCChannelPerson *person = channel->getPerson(temp); |
532 | if (person) { | 532 | if (person) { |
533 | IRCOutput output(OUTPUT_CHANPERSONMODE, person->setVoice(mask.nick(), set)); | 533 | IRCOutput output(OUTPUT_CHANPERSONMODE, person->setVoice(mask.nick(), set)); |
534 | output.addParam(channel); | 534 | output.addParam(channel); |
535 | output.addParam(person); | 535 | output.addParam(person); |
536 | emit outputReady(output); | 536 | emit outputReady(output); |
537 | } | 537 | } |
538 | else { | 538 | else { |
539 | 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?"))); |
540 | } | 540 | } |
541 | } | 541 | } |
542 | else { | 542 | else { |
543 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); | 543 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | } else { | 546 | } else { |
547 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); | 547 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); |
548 | } | 548 | } |
549 | } else { | 549 | } else { |
550 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); | 550 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); |
551 | } | 551 | } |
552 | } | 552 | } |
553 | 553 | ||
554 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | 554 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { |
555 | IRCPerson mask(message->prefix()); | 555 | IRCPerson mask(message->prefix()); |
556 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 556 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
557 | if (channel) { | 557 | if (channel) { |
558 | IRCChannelPerson *person = channel->getPerson(message->param(1)); | 558 | IRCChannelPerson *person = channel->getPerson(message->param(1)); |
559 | if (person) { | 559 | if (person) { |
560 | if (person->nick() == m_session->m_server->nick()) { | 560 | if (person->nick() == m_session->m_server->nick()) { |
561 | m_session->removeChannel(channel); | 561 | m_session->removeChannel(channel); |
562 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); | 562 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); |
563 | output.addParam(channel); | 563 | output.addParam(channel); |
564 | emit outputReady(output); | 564 | emit outputReady(output); |
565 | } else { | 565 | } else { |
566 | /* someone else got kicked */ | 566 | /* someone else got kicked */ |
567 | channel->removePerson(person); | 567 | channel->removePerson(person); |
568 | IRCOutput output(OUTPUT_OTHERKICK, person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); | 568 | IRCOutput output(OUTPUT_OTHERKICK, person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); |
569 | output.addParam(channel); | 569 | output.addParam(channel); |
570 | output.addParam(person); | 570 | output.addParam(person); |
571 | emit outputReady(output); | 571 | emit outputReady(output); |
572 | } | 572 | } |
573 | } else { | 573 | } else { |
574 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); | 574 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); | 577 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | 581 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { |
582 | /* Name list sent when joining a channel */ | 582 | /* Name list sent when joining a channel */ |
583 | IRCChannel *channel = m_session->getChannel(message->param(2).lower()); | 583 | IRCChannel *channel = m_session->getChannel(message->param(2).lower()); |
584 | if (channel != 0) { | 584 | if (channel != 0) { |
585 | QString people = message->param(3); | 585 | QString people = message->param(3); |
586 | QTextIStream stream(&people); | 586 | QTextIStream stream(&people); |
587 | QString temp; | 587 | QString temp; |
588 | 588 | ||
589 | while (!stream.atEnd()) { | 589 | while (!stream.atEnd()) { |
590 | stream >> temp; | 590 | stream >> temp; |
591 | 591 | ||
592 | char flagch = temp.at(0).latin1(); | 592 | char flagch = temp.at(0).latin1(); |
593 | int flag = 0; | 593 | int flag = 0; |
594 | QString nick; | 594 | QString nick; |
595 | /* Parse person flags */ | 595 | /* Parse person flags */ |
596 | if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { | 596 | if (flagch == '~' || flagch == '&' || flagch == '@' || flagch == '+' || |
597 | flagch=='%' || flagch == '*') { | ||
597 | 598 | ||
598 | nick = temp.right(temp.length()-1); | 599 | nick = temp.right(temp.length()-1); |
599 | switch (flagch) { | 600 | switch (flagch) { |
600 | case '@': flag = IRCChannelPerson::PERSON_FLAG_OP; break; | 601 | /** |
601 | case '+': flag = IRCChannelPerson::PERSON_FLAG_VOICE; break; | 602 | * @note '~' and `&' are extensions of the unrealircd irc |
602 | case '%': flag = IRCChannelPerson::PERSON_FLAG_HALFOP; break; | 603 | * daemon. This app can't see users w/out checking for these |
603 | default : flag = 0; break; | 604 | * chars. |
605 | */ | ||
606 | case '~': | ||
607 | case '&': | ||
608 | case '@': | ||
609 | flag = IRCChannelPerson::PERSON_FLAG_OP; | ||
610 | break; | ||
611 | case '+': | ||
612 | flag = IRCChannelPerson::PERSON_FLAG_VOICE; | ||
613 | break; | ||
614 | case '%': | ||
615 | flag = IRCChannelPerson::PERSON_FLAG_HALFOP; | ||
616 | break; | ||
617 | default : | ||
618 | flag = 0; | ||
619 | break; | ||
604 | } | 620 | } |
605 | } else { | 621 | } else |
606 | nick = temp; | 622 | nick = temp; |
607 | } | ||
608 | 623 | ||
609 | IRCPerson *person = m_session->getPerson(nick); | 624 | IRCPerson *person = m_session->getPerson(nick); |
610 | if (person == 0) { | 625 | if (person == 0) { |
611 | person = new IRCPerson(); | 626 | person = new IRCPerson(); |
612 | person->setNick(nick); | 627 | person->setNick(nick); |
613 | m_session->addPerson(person); | 628 | m_session->addPerson(person); |
614 | } | 629 | } |
615 | IRCChannelPerson *chan_person = new IRCChannelPerson(person); | 630 | IRCChannelPerson *chan_person = new IRCChannelPerson(person); |
616 | chan_person->setFlags(flag); | 631 | chan_person->setFlags(flag); |
617 | channel->addPerson(chan_person); | 632 | channel->addPerson(chan_person); |
618 | } | 633 | } |
619 | } else { | 634 | } else |
620 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 635 | emit outputReady(IRCOutput(OUTPUT_ERROR, |
621 | } | 636 | tr("Server message with unknown channel"))); |
622 | } | 637 | } |
623 | 638 | ||
624 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { | 639 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { |
625 | /* Done syncing to channel */ | 640 | /* Done syncing to channel */ |
626 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); | 641 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); |
627 | if (channel) { | 642 | if (channel) { |
628 | channel->setHasPeople(TRUE); | 643 | channel->setHasPeople(TRUE); |
629 | /* Yes, we want the names before anything happens inside the GUI */ | 644 | /* Yes, we want the names before anything happens inside the GUI */ |
630 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); | 645 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); |
631 | output.addParam(channel); | 646 | output.addParam(channel); |
632 | emit outputReady(output); | 647 | emit outputReady(output); |
633 | } else { | 648 | } else { |
634 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 649 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
635 | } | 650 | } |
636 | } | 651 | } |
637 | 652 | ||
638 | 653 | ||
639 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { | 654 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { |
640 | /* If we are connnected this error is not critical */ | 655 | /* If we are connnected this error is not critical */ |
641 | if(m_session->isLoggedIn()) | 656 | if(m_session->isLoggedIn()) |
642 | return; | 657 | return; |
643 | 658 | ||
644 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); | 659 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); |
645 | m_session->endSession(); | 660 | m_session->endSession(); |
646 | } | 661 | } |
647 | 662 | ||
648 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { | 663 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { |
649 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); | 664 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); |
650 | } | 665 | } |
651 | 666 | ||
652 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { | 667 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { |
653 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); | 668 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); |
654 | if (channel) { | 669 | if (channel) { |
655 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); | 670 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); |
656 | output.addParam(channel); | 671 | output.addParam(channel); |
657 | emit outputReady(output); | 672 | emit outputReady(output); |
658 | } else { | 673 | } else { |
659 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); | 674 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); |
660 | output.addParam(0); | 675 | output.addParam(0); |
661 | emit outputReady(output); | 676 | emit outputReady(output); |
662 | } | 677 | } |
663 | } | 678 | } |
664 | 679 | ||
665 | void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) { | 680 | void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) { |
666 | } | 681 | } |
667 | 682 | ||
668 | 683 | ||