author | erik <erik> | 2007-07-09 22:06:00 (UTC) |
---|---|---|
committer | erik <erik> | 2007-07-09 22:06:00 (UTC) |
commit | a91bbaee9eb419dc985d9f5c3689831c8aa75c1e (patch) (unidiff) | |
tree | ba0da224a93f7af1a80a4bef3186edff8dc9483f | |
parent | 1ec355e1cc016edd2e322ff7d57469feaa46474b (diff) | |
download | opie-a91bbaee9eb419dc985d9f5c3689831c8aa75c1e.zip opie-a91bbaee9eb419dc985d9f5c3689831c8aa75c1e.tar.gz opie-a91bbaee9eb419dc985d9f5c3689831c8aa75c1e.tar.bz2 |
Fix for opie bug 1719. This should make opie-irc play nicer with utf-8.
Patches were culled from OE. Thanks to whoever the original patch author
was.
-rw-r--r-- | noncore/net/opieirc/ircconnection.cpp | 5 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/noncore/net/opieirc/ircconnection.cpp b/noncore/net/opieirc/ircconnection.cpp index 88e63f7..fb7e168 100644 --- a/noncore/net/opieirc/ircconnection.cpp +++ b/noncore/net/opieirc/ircconnection.cpp | |||
@@ -1,122 +1,123 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <string.h> | 2 | #include <string.h> |
3 | 3 | ||
4 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
5 | #include <qdatetime.h> | 5 | #include <qdatetime.h> |
6 | 6 | ||
7 | #include "ircconnection.h" | 7 | #include "ircconnection.h" |
8 | 8 | ||
9 | IRCConnection::IRCConnection(IRCServer *server) { | 9 | IRCConnection::IRCConnection(IRCServer *server) { |
10 | m_server = server; | 10 | m_server = server; |
11 | m_socket = new QSocket(this); | 11 | m_socket = new QSocket(this); |
12 | m_connected = FALSE; | 12 | m_connected = FALSE; |
13 | m_loggedIn = FALSE; | 13 | m_loggedIn = FALSE; |
14 | connect(m_socket, SIGNAL(connected()), this, SLOT(login())); | 14 | connect(m_socket, SIGNAL(connected()), this, SLOT(login())); |
15 | connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReady())); | 15 | connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReady())); |
16 | connect(m_socket, SIGNAL(error(int)), this, SLOT(error(int))); | 16 | connect(m_socket, SIGNAL(error(int)), this, SLOT(error(int))); |
17 | connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(disconnect())); | 17 | connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(disconnect())); |
18 | connect(m_socket, SIGNAL(delayedCloseFinished()), this, SLOT(disconnect())); | 18 | connect(m_socket, SIGNAL(delayedCloseFinished()), this, SLOT(disconnect())); |
19 | } | 19 | } |
20 | 20 | ||
21 | /* Connect to the IRC server */ | 21 | /* Connect to the IRC server */ |
22 | void IRCConnection::doConnect() { | 22 | void IRCConnection::doConnect() { |
23 | ASSERT(!m_connected); | 23 | ASSERT(!m_connected); |
24 | m_socket->connectToHost(m_server->hostname(), m_server->port()); | 24 | m_socket->connectToHost(m_server->hostname(), m_server->port()); |
25 | } | 25 | } |
26 | 26 | ||
27 | /* Send commands to the IRC server */ | 27 | /* Send commands to the IRC server */ |
28 | void IRCConnection::sendLine(QString line) { | 28 | void IRCConnection::sendLine(QString line) { |
29 | while((line.right(1) == "\n") || (line.right(1) == "\r")) | 29 | while((line.right(1) == "\n") || (line.right(1) == "\r")) |
30 | line = line.left(line.length() - 1); | 30 | line = line.left(line.length() - 1); |
31 | line.append("\r\n"); | 31 | line.append("\r\n"); |
32 | m_socket->writeBlock(line, line.length()); | 32 | QCString uline = line.utf8(); |
33 | m_socket->writeBlock(uline, uline.length()); | ||
33 | } | 34 | } |
34 | 35 | ||
35 | void IRCConnection::sendCTCPReply(const QString &nickname, const QString &type, const QString &args) { | 36 | void IRCConnection::sendCTCPReply(const QString &nickname, const QString &type, const QString &args) { |
36 | sendLine("NOTICE " + nickname + " :\001" + type + " " + args + "\001"); | 37 | sendLine("NOTICE " + nickname + " :\001" + type + " " + args + "\001"); |
37 | } | 38 | } |
38 | 39 | ||
39 | void IRCConnection::sendCTCPRequest(const QString &nickname, const QString &type, const QString &args) { | 40 | void IRCConnection::sendCTCPRequest(const QString &nickname, const QString &type, const QString &args) { |
40 | sendLine("PRIVMSG " + nickname + " :\001" + type + " " + args + "\001"); | 41 | sendLine("PRIVMSG " + nickname + " :\001" + type + " " + args + "\001"); |
41 | } | 42 | } |
42 | 43 | ||
43 | void IRCConnection::sendCTCPPing(const QString &nickname) { | 44 | void IRCConnection::sendCTCPPing(const QString &nickname) { |
44 | QDateTime tm; | 45 | QDateTime tm; |
45 | tm.setTime_t(0); | 46 | tm.setTime_t(0); |
46 | QString strtime = QString::number(tm.secsTo(QDateTime::currentDateTime())); | 47 | QString strtime = QString::number(tm.secsTo(QDateTime::currentDateTime())); |
47 | sendCTCPRequest(nickname, "PING", strtime); | 48 | sendCTCPRequest(nickname, "PING", strtime); |
48 | } | 49 | } |
49 | 50 | ||
50 | void IRCConnection::whois(const QString &nickname) { | 51 | void IRCConnection::whois(const QString &nickname) { |
51 | sendLine("WHOIS " + nickname); | 52 | sendLine("WHOIS " + nickname); |
52 | } | 53 | } |
53 | 54 | ||
54 | /* | 55 | /* |
55 | * login() is called right after the connection | 56 | * login() is called right after the connection |
56 | * to the IRC server has been established | 57 | * to the IRC server has been established |
57 | */ | 58 | */ |
58 | void IRCConnection::login() { | 59 | void IRCConnection::login() { |
59 | char hostname[256]; | 60 | char hostname[256]; |
60 | QString loginString; | 61 | QString loginString; |
61 | 62 | ||
62 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Connected, logging in .."))); | 63 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Connected, logging in .."))); |
63 | m_connected = TRUE; | 64 | m_connected = TRUE; |
64 | gethostname(hostname, sizeof(hostname)-1); | 65 | gethostname(hostname, sizeof(hostname)-1); |
65 | hostname[sizeof (hostname) - 1] = 0; | 66 | hostname[sizeof (hostname) - 1] = 0; |
66 | 67 | ||
67 | /* Create a logon string and send it */ | 68 | /* Create a logon string and send it */ |
68 | if (m_server->password().length()>0) { | 69 | if (m_server->password().length()>0) { |
69 | loginString += "PASS " + m_server->password() + "\r\n"; | 70 | loginString += "PASS " + m_server->password() + "\r\n"; |
70 | } | 71 | } |
71 | loginString += "NICK " + m_server->nick() + "\r\n" + | 72 | loginString += "NICK " + m_server->nick() + "\r\n" + |
72 | "USER " + m_server->username() + " " + hostname + | 73 | "USER " + m_server->username() + " " + hostname + |
73 | " " + m_server->hostname() + " :" + m_server->realname() + "\r\n"; | 74 | " " + m_server->hostname() + " :" + m_server->realname() + "\r\n"; |
74 | sendLine(loginString); | 75 | sendLine(loginString); |
75 | } | 76 | } |
76 | 77 | ||
77 | /* Called when data arrives on the socket */ | 78 | /* Called when data arrives on the socket */ |
78 | void IRCConnection::dataReady() { | 79 | void IRCConnection::dataReady() { |
79 | while(m_socket->canReadLine()) { | 80 | while(m_socket->canReadLine()) { |
80 | IRCMessage message(m_socket->readLine()); | 81 | IRCMessage message(QString::fromUtf8(m_socket->readLine())); |
81 | if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) { | 82 | if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) { |
82 | /* Now autojoin all channels specified inside the server profile */ | 83 | /* Now autojoin all channels specified inside the server profile */ |
83 | QStringList channels = QStringList::split(QChar(','), m_server->channels()); | 84 | QStringList channels = QStringList::split(QChar(','), m_server->channels()); |
84 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { | 85 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { |
85 | QString channelName = (*it).stripWhiteSpace(); | 86 | QString channelName = (*it).stripWhiteSpace(); |
86 | if (channelName.startsWith("#") || channelName.startsWith("+")) { | 87 | if (channelName.startsWith("#") || channelName.startsWith("+")) { |
87 | sendLine("JOIN "+ channelName); | 88 | sendLine("JOIN "+ channelName); |
88 | } | 89 | } |
89 | } | 90 | } |
90 | m_loggedIn = TRUE; | 91 | m_loggedIn = TRUE; |
91 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in."))); | 92 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in."))); |
92 | } | 93 | } |
93 | emit messageArrived(&message); | 94 | emit messageArrived(&message); |
94 | } | 95 | } |
95 | } | 96 | } |
96 | 97 | ||
97 | /* Called if any type of socket error occurs */ | 98 | /* Called if any type of socket error occurs */ |
98 | void IRCConnection::error(int num) { | 99 | void IRCConnection::error(int num) { |
99 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Socket error : ") + strerror(num))); | 100 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Socket error : ") + strerror(num))); |
100 | } | 101 | } |
101 | 102 | ||
102 | void IRCConnection::disconnect() { | 103 | void IRCConnection::disconnect() { |
103 | m_connected = FALSE; | 104 | m_connected = FALSE; |
104 | m_loggedIn = FALSE; | 105 | m_loggedIn = FALSE; |
105 | emit outputReady(IRCOutput(OUTPUT_CONNCLOSE, tr("Connection closed"))); | 106 | emit outputReady(IRCOutput(OUTPUT_CONNCLOSE, tr("Connection closed"))); |
106 | } | 107 | } |
107 | 108 | ||
108 | bool IRCConnection::isConnected() { | 109 | bool IRCConnection::isConnected() { |
109 | return m_connected; | 110 | return m_connected; |
110 | } | 111 | } |
111 | 112 | ||
112 | bool IRCConnection::isLoggedIn() { | 113 | bool IRCConnection::isLoggedIn() { |
113 | return m_loggedIn; | 114 | return m_loggedIn; |
114 | } | 115 | } |
115 | 116 | ||
116 | void IRCConnection::close() { | 117 | void IRCConnection::close() { |
117 | m_socket->close(); | 118 | m_socket->close(); |
118 | if (m_socket->state()==QSocket::Idle) { | 119 | if (m_socket->state()==QSocket::Idle) { |
119 | disconnect(); | 120 | disconnect(); |
120 | } | 121 | } |
121 | } | 122 | } |
122 | 123 | ||
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index c449a65..ae47f69 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -478,206 +478,206 @@ void IRCMessageParser::parseCTCPDCC(IRCMessage *message) { | |||
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 | flagch=='%' || flagch == '*') { |
598 | 598 | ||
599 | nick = temp.right(temp.length()-1); | 599 | nick = temp.right(temp.length()-1); |
600 | switch (flagch) { | 600 | switch (flagch) { |
601 | /** | 601 | /** |
602 | * @note '~' and `&' are extensions of the unrealircd irc | 602 | * @note '~' and `&' are extensions of the unrealircd irc |
603 | * daemon. This app can't see users w/out checking for these | 603 | * daemon. This app can't see users w/out checking for these |
604 | * chars. | 604 | * chars. |
605 | */ | 605 | */ |
606 | case '~': | 606 | case '~': |
607 | case '&': | 607 | case '&': |
608 | case '@': | 608 | case '@': |
609 | flag = IRCChannelPerson::PERSON_FLAG_OP; | 609 | flag = IRCChannelPerson::PERSON_FLAG_OP; |
610 | break; | 610 | break; |
611 | case '+': | 611 | case '+': |
612 | flag = IRCChannelPerson::PERSON_FLAG_VOICE; | 612 | flag = IRCChannelPerson::PERSON_FLAG_VOICE; |
613 | break; | 613 | break; |
614 | case '%': | 614 | case '%': |
615 | flag = IRCChannelPerson::PERSON_FLAG_HALFOP; | 615 | flag = IRCChannelPerson::PERSON_FLAG_HALFOP; |
616 | break; | 616 | break; |
617 | default : | 617 | default : |
618 | flag = 0; | 618 | flag = 0; |
619 | break; | 619 | break; |
620 | } | 620 | } |
621 | } else | 621 | } else |
622 | nick = temp; | 622 | nick = temp; |
623 | 623 | ||
624 | IRCPerson *person = m_session->getPerson(nick); | 624 | IRCPerson *person = m_session->getPerson(nick); |
625 | if (person == 0) { | 625 | if (person == 0) { |
626 | person = new IRCPerson(); | 626 | person = new IRCPerson(); |
627 | person->setNick(nick); | 627 | person->setNick(nick); |
628 | m_session->addPerson(person); | 628 | m_session->addPerson(person); |
629 | } | 629 | } |
630 | IRCChannelPerson *chan_person = new IRCChannelPerson(person); | 630 | IRCChannelPerson *chan_person = new IRCChannelPerson(person); |
631 | chan_person->setFlags(flag); | 631 | chan_person->setFlags(flag); |
632 | channel->addPerson(chan_person); | 632 | channel->addPerson(chan_person); |
633 | } | 633 | } |
634 | } else | 634 | } else |
635 | emit outputReady(IRCOutput(OUTPUT_ERROR, | 635 | emit outputReady(IRCOutput(OUTPUT_ERROR, |
636 | tr("Server message with unknown channel"))); | 636 | tr("Server message with unknown channel"))); |
637 | } | 637 | } |
638 | 638 | ||
639 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { | 639 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { |
640 | /* Done syncing to channel */ | 640 | /* Done syncing to channel */ |
641 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); | 641 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); |
642 | if (channel) { | 642 | if (channel) { |
643 | channel->setHasPeople(TRUE); | 643 | channel->setHasPeople(TRUE); |
644 | /* Yes, we want the names before anything happens inside the GUI */ | 644 | /* Yes, we want the names before anything happens inside the GUI */ |
645 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); | 645 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); |
646 | output.addParam(channel); | 646 | output.addParam(channel); |
647 | emit outputReady(output); | 647 | emit outputReady(output); |
648 | } else { | 648 | } else { |
649 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 649 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | 652 | ||
653 | 653 | ||
654 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { | 654 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { |
655 | /* If we are connnected this error is not critical */ | 655 | /* If we are connnected this error is not critical */ |
656 | if(m_session->isLoggedIn()) | 656 | if(m_session->isLoggedIn()) |
657 | return; | 657 | return; |
658 | 658 | ||
659 | 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"))); |
660 | m_session->endSession(); | 660 | m_session->endSession(); |
661 | } | 661 | } |
662 | 662 | ||
663 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { | 663 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { |
664 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); | 664 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); |
665 | } | 665 | } |
666 | 666 | ||
667 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { | 667 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { |
668 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); | 668 | IRCChannel *channel = m_session->getChannel(message->param(1).lower()); |
669 | if (channel) { | 669 | if (channel) { |
670 | 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() + tr(" is \"") + message->param(2) + "\""); |
671 | output.addParam(channel); | 671 | output.addParam(channel); |
672 | emit outputReady(output); | 672 | emit outputReady(output); |
673 | } else { | 673 | } else { |
674 | 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) + tr(" is \"") + message->param(2) + "\""); |
675 | output.addParam(0); | 675 | output.addParam(0); |
676 | emit outputReady(output); | 676 | emit outputReady(output); |
677 | } | 677 | } |
678 | } | 678 | } |
679 | 679 | ||
680 | void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) { | 680 | void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) { |
681 | } | 681 | } |
682 | 682 | ||
683 | 683 | ||