author | wazlaf <wazlaf> | 2002-09-29 21:45:16 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-29 21:45:16 (UTC) |
commit | a54430dbebd980109afdf604c7bfc9b0e15c4fdb (patch) (unidiff) | |
tree | b81722f654163301c67e98b4d210b1bcf068c20b | |
parent | 75c85d30c3f7de8d2785f70e0f28ef838ea7f419 (diff) | |
download | opie-a54430dbebd980109afdf604c7bfc9b0e15c4fdb.zip opie-a54430dbebd980109afdf604c7bfc9b0e15c4fdb.tar.gz opie-a54430dbebd980109afdf604c7bfc9b0e15c4fdb.tar.bz2 |
modeless channel support
-rw-r--r-- | noncore/net/opieirc/ircconnection.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/noncore/net/opieirc/ircconnection.cpp b/noncore/net/opieirc/ircconnection.cpp index 5eb0cf2..2325cca 100644 --- a/noncore/net/opieirc/ircconnection.cpp +++ b/noncore/net/opieirc/ircconnection.cpp | |||
@@ -1,102 +1,102 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include "ircconnection.h" | 3 | #include "ircconnection.h" |
4 | 4 | ||
5 | IRCConnection::IRCConnection(IRCServer *server) { | 5 | IRCConnection::IRCConnection(IRCServer *server) { |
6 | m_server = server; | 6 | m_server = server; |
7 | m_socket = new QSocket(this); | 7 | m_socket = new QSocket(this); |
8 | m_connected = FALSE; | 8 | m_connected = FALSE; |
9 | m_loggedIn = FALSE; | 9 | m_loggedIn = FALSE; |
10 | connect(m_socket, SIGNAL(connected()), this, SLOT(login())); | 10 | connect(m_socket, SIGNAL(connected()), this, SLOT(login())); |
11 | connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReady())); | 11 | connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReady())); |
12 | connect(m_socket, SIGNAL(error(int)), this, SLOT(error(int))); | 12 | connect(m_socket, SIGNAL(error(int)), this, SLOT(error(int))); |
13 | connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(disconnect())); | 13 | connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(disconnect())); |
14 | connect(m_socket, SIGNAL(delayedCloseFinished()), this, SLOT(disconnect())); | 14 | connect(m_socket, SIGNAL(delayedCloseFinished()), this, SLOT(disconnect())); |
15 | } | 15 | } |
16 | 16 | ||
17 | /* Connect to the IRC server */ | 17 | /* Connect to the IRC server */ |
18 | void IRCConnection::doConnect() { | 18 | void IRCConnection::doConnect() { |
19 | ASSERT(!m_connected); | 19 | ASSERT(!m_connected); |
20 | m_socket->connectToHost(m_server->hostname(), m_server->port()); | 20 | m_socket->connectToHost(m_server->hostname(), m_server->port()); |
21 | } | 21 | } |
22 | 22 | ||
23 | /* Send commands to the IRC server */ | 23 | /* Send commands to the IRC server */ |
24 | void IRCConnection::sendLine(QString line) { | 24 | void IRCConnection::sendLine(QString line) { |
25 | while((line.right(1) == "\n") || (line.right(1) == "\r")) | 25 | while((line.right(1) == "\n") || (line.right(1) == "\r")) |
26 | line = line.left(line.length() - 1); | 26 | line = line.left(line.length() - 1); |
27 | line.append("\r\n"); | 27 | line.append("\r\n"); |
28 | m_socket->writeBlock(line, line.length()); | 28 | m_socket->writeBlock(line, line.length()); |
29 | } | 29 | } |
30 | 30 | ||
31 | void IRCConnection::sendCTCP(QString nick, QString line) { | 31 | void IRCConnection::sendCTCP(QString nick, QString line) { |
32 | sendLine("NOTICE " + nick + " :\001"+line+"\001"); | 32 | sendLine("NOTICE " + nick + " :\001"+line+"\001"); |
33 | } | 33 | } |
34 | 34 | ||
35 | /* | 35 | /* |
36 | * login() is called right after the connection | 36 | * login() is called right after the connection |
37 | * to the IRC server has been established | 37 | * to the IRC server has been established |
38 | */ | 38 | */ |
39 | void IRCConnection::login() { | 39 | void IRCConnection::login() { |
40 | char hostname[256]; | 40 | char hostname[256]; |
41 | QString loginString; | 41 | QString loginString; |
42 | 42 | ||
43 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Connected, logging in .."))); | 43 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Connected, logging in .."))); |
44 | m_connected = TRUE; | 44 | m_connected = TRUE; |
45 | gethostname(hostname, sizeof(hostname)-1); | 45 | gethostname(hostname, sizeof(hostname)-1); |
46 | hostname[sizeof (hostname) - 1] = 0; | 46 | hostname[sizeof (hostname) - 1] = 0; |
47 | 47 | ||
48 | /* Create a logon string and send it */ | 48 | /* Create a logon string and send it */ |
49 | if (m_server->password().length()>0) { | 49 | if (m_server->password().length()>0) { |
50 | loginString += "PASS " + m_server->password() + "\r\n"; | 50 | loginString += "PASS " + m_server->password() + "\r\n"; |
51 | } | 51 | } |
52 | loginString += "NICK " + m_server->nick() + "\r\n" + | 52 | loginString += "NICK " + m_server->nick() + "\r\n" + |
53 | "USER " + m_server->username() + " " + hostname + | 53 | "USER " + m_server->username() + " " + hostname + |
54 | " " + m_server->hostname() + " :" + m_server->realname() + "\r\n"; | 54 | " " + m_server->hostname() + " :" + m_server->realname() + "\r\n"; |
55 | sendLine(loginString); | 55 | sendLine(loginString); |
56 | } | 56 | } |
57 | 57 | ||
58 | /* Called when data arrives on the socket */ | 58 | /* Called when data arrives on the socket */ |
59 | void IRCConnection::dataReady() { | 59 | void IRCConnection::dataReady() { |
60 | while(m_socket->canReadLine()) { | 60 | while(m_socket->canReadLine()) { |
61 | IRCMessage message(m_socket->readLine()); | 61 | IRCMessage message(m_socket->readLine()); |
62 | if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) { | 62 | if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) { |
63 | /* Now autojoin all channels specified inside the server profile */ | 63 | /* Now autojoin all channels specified inside the server profile */ |
64 | QStringList channels = QStringList::split(QChar(','), m_server->channels()); | 64 | QStringList channels = QStringList::split(QChar(','), m_server->channels()); |
65 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { | 65 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { |
66 | QString channelName = (*it).stripWhiteSpace(); | 66 | QString channelName = (*it).stripWhiteSpace(); |
67 | if (channelName.startsWith("#")) { | 67 | if (channelName.startsWith("#") || channelName.startsWith("+")) { |
68 | sendLine("JOIN "+ channelName); | 68 | sendLine("JOIN "+ channelName); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | m_loggedIn = TRUE; | 71 | m_loggedIn = TRUE; |
72 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in."))); | 72 | emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in."))); |
73 | } | 73 | } |
74 | emit messageArrived(&message); | 74 | emit messageArrived(&message); |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | /* Called if any type of socket error occurs */ | 78 | /* Called if any type of socket error occurs */ |
79 | void IRCConnection::error(int num) { | 79 | void IRCConnection::error(int num) { |
80 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Socket error : ") + strerror(num))); | 80 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Socket error : ") + strerror(num))); |
81 | } | 81 | } |
82 | 82 | ||
83 | void IRCConnection::disconnect() { | 83 | void IRCConnection::disconnect() { |
84 | m_connected = FALSE; | 84 | m_connected = FALSE; |
85 | m_loggedIn = FALSE; | 85 | m_loggedIn = FALSE; |
86 | emit outputReady(IRCOutput(OUTPUT_CONNCLOSE, tr("Connection closed"))); | 86 | emit outputReady(IRCOutput(OUTPUT_CONNCLOSE, tr("Connection closed"))); |
87 | } | 87 | } |
88 | 88 | ||
89 | bool IRCConnection::isConnected() { | 89 | bool IRCConnection::isConnected() { |
90 | return m_connected; | 90 | return m_connected; |
91 | } | 91 | } |
92 | 92 | ||
93 | bool IRCConnection::isLoggedIn() { | 93 | bool IRCConnection::isLoggedIn() { |
94 | return m_loggedIn; | 94 | return m_loggedIn; |
95 | } | 95 | } |
96 | 96 | ||
97 | void IRCConnection::close() { | 97 | void IRCConnection::close() { |
98 | m_socket->close(); | 98 | m_socket->close(); |
99 | if (m_socket->state()==QSocket::Idle) { | 99 | if (m_socket->state()==QSocket::Idle) { |
100 | disconnect(); | 100 | disconnect(); |
101 | } | 101 | } |
102 | } | 102 | } |
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 2b77414..a95c64e 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -1,442 +1,442 @@ | |||
1 | #include <qtextstream.h> | 1 | #include <qtextstream.h> |
2 | #include "ircmessageparser.h" | 2 | #include "ircmessageparser.h" |
3 | #include "ircversion.h" | 3 | #include "ircversion.h" |
4 | 4 | ||
5 | /* Lookup table for literal commands */ | 5 | /* Lookup table for literal commands */ |
6 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | 6 | IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { |
7 | { "PING", FUNC(parseLiteralPing) }, | 7 | { "PING", FUNC(parseLiteralPing) }, |
8 | { "NOTICE", FUNC(parseLiteralNotice) }, | 8 | { "NOTICE", FUNC(parseLiteralNotice) }, |
9 | { "JOIN", FUNC(parseLiteralJoin) }, | 9 | { "JOIN", FUNC(parseLiteralJoin) }, |
10 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, | 10 | { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, |
11 | { "NICK", FUNC(parseLiteralNick) }, | 11 | { "NICK", FUNC(parseLiteralNick) }, |
12 | { "PART", FUNC(parseLiteralPart) }, | 12 | { "PART", FUNC(parseLiteralPart) }, |
13 | { "QUIT", FUNC(parseLiteralQuit) }, | 13 | { "QUIT", FUNC(parseLiteralQuit) }, |
14 | { "ERROR", FUNC(parseLiteralError) }, | 14 | { "ERROR", FUNC(parseLiteralError) }, |
15 | { "ERROR:", FUNC(parseLiteralError) }, | 15 | { "ERROR:", FUNC(parseLiteralError) }, |
16 | { "MODE", FUNC(parseLiteralMode) }, | 16 | { "MODE", FUNC(parseLiteralMode) }, |
17 | { "KICK", FUNC(parseLiteralKick) }, | 17 | { "KICK", FUNC(parseLiteralKick) }, |
18 | { "TOPIC", FUNC(parseLiteralTopic) }, | 18 | { "TOPIC", FUNC(parseLiteralTopic) }, |
19 | { 0 , 0 } | 19 | { 0 , 0 } |
20 | }; | 20 | }; |
21 | 21 | ||
22 | /* Lookup table for literal commands */ | 22 | /* Lookup table for literal commands */ |
23 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { | 23 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { |
24 | { "PING", FUNC(parseCTCPPing) }, | 24 | { "PING", FUNC(parseCTCPPing) }, |
25 | { "VERSION", FUNC(parseCTCPVersion) }, | 25 | { "VERSION", FUNC(parseCTCPVersion) }, |
26 | { "ACTION", FUNC(parseCTCPAction) }, | 26 | { "ACTION", FUNC(parseCTCPAction) }, |
27 | { 0 , 0 } | 27 | { 0 , 0 } |
28 | }; | 28 | }; |
29 | 29 | ||
30 | /* Lookup table for numerical commands */ | 30 | /* Lookup table for numerical commands */ |
31 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | 31 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { |
32 | { 1, FUNC(parseNumerical001) }, // RPL_WELCOME | 32 | { 1, FUNC(parseNumerical001) }, // RPL_WELCOME |
33 | { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST | 33 | { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST |
34 | { 3, FUNC(parseNumerical003) }, // RPL_CREATED | 34 | { 3, FUNC(parseNumerical003) }, // RPL_CREATED |
35 | { 4, FUNC(parseNumerical004) }, // RPL_MYINFO | 35 | { 4, FUNC(parseNumerical004) }, // RPL_MYINFO |
36 | { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL | 36 | { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL |
37 | { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT | 37 | { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT |
38 | { 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP | 38 | { 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP |
39 | { 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS | 39 | { 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS |
40 | { 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS | 40 | { 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS |
41 | { 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN | 41 | { 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN |
42 | { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS | 42 | { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS |
43 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME | 43 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME |
44 | { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC | 44 | { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC |
45 | { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME | 45 | { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME |
46 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY | 46 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY |
47 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES | 47 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES |
48 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART | 48 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART |
49 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD | 49 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD |
50 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD | 50 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD |
51 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 | 51 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 |
52 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 | 52 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 |
53 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK | 53 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK |
54 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK | 54 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK |
55 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND | 55 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND |
56 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE | 56 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE |
57 | { 0, 0 } | 57 | { 0, 0 } |
58 | }; | 58 | }; |
59 | 59 | ||
60 | IRCMessageParser::IRCMessageParser(IRCSession *session) { | 60 | IRCMessageParser::IRCMessageParser(IRCSession *session) { |
61 | m_session = session; | 61 | m_session = session; |
62 | } | 62 | } |
63 | 63 | ||
64 | void IRCMessageParser::parse(IRCMessage *message) { | 64 | void IRCMessageParser::parse(IRCMessage *message) { |
65 | /* Find out what kind of message we have here and call the appropriate handler using | 65 | /* Find out what kind of message we have here and call the appropriate handler using |
66 | the parser tables. If no handler can be found, print out an error message */ | 66 | the parser tables. If no handler can be found, print out an error message */ |
67 | if (message->isNumerical()) { | 67 | if (message->isNumerical()) { |
68 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { | 68 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { |
69 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { | 69 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { |
70 | (this->*(numericalParserProcTable[i].proc))(message); | 70 | (this->*(numericalParserProcTable[i].proc))(message); |
71 | return; | 71 | return; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); | 74 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); |
75 | } else if (message->isCTCP()) { | 75 | } else if (message->isCTCP()) { |
76 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { | 76 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { |
77 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { | 77 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { |
78 | (this->*(ctcpParserProcTable[i].proc))(message); | 78 | (this->*(ctcpParserProcTable[i].proc))(message); |
79 | return; | 79 | return; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); | 82 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); |
83 | } else { | 83 | } else { |
84 | for (int i=0; literalParserProcTable[i].commandName; i++) { | 84 | for (int i=0; literalParserProcTable[i].commandName; i++) { |
85 | if (message->command() == literalParserProcTable[i].commandName) { | 85 | if (message->command() == literalParserProcTable[i].commandName) { |
86 | (this->*(literalParserProcTable[i].proc))(message); | 86 | (this->*(literalParserProcTable[i].proc))(message); |
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); | 90 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | void IRCMessageParser::nullFunc(IRCMessage *) { | 94 | void IRCMessageParser::nullFunc(IRCMessage *) { |
95 | /* Do nothing */ | 95 | /* Do nothing */ |
96 | } | 96 | } |
97 | 97 | ||
98 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { | 98 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { |
99 | m_session->m_connection->sendLine("PONG " + message->allParameters()); | 99 | m_session->m_connection->sendLine("PONG " + message->allParameters()); |
100 | } | 100 | } |
101 | 101 | ||
102 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { | 102 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { |
103 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 103 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
104 | } | 104 | } |
105 | 105 | ||
106 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { | 106 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { |
107 | QString channelName = message->param(0).lower(); | 107 | QString channelName = message->param(0).lower(); |
108 | IRCPerson mask(message->prefix()); | 108 | IRCPerson mask(message->prefix()); |
109 | IRCChannel *channel = m_session->getChannel(channelName); | 109 | IRCChannel *channel = m_session->getChannel(channelName); |
110 | if (!channel) { | 110 | if (!channel) { |
111 | /* We joined */ | 111 | /* We joined */ |
112 | if (mask.nick() == m_session->m_server->nick()) { | 112 | if (mask.nick() == m_session->m_server->nick()) { |
113 | channel = new IRCChannel(channelName); | 113 | channel = new IRCChannel(channelName); |
114 | m_session->addChannel(channel); | 114 | m_session->addChannel(channel); |
115 | } else { | 115 | } else { |
116 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); | 116 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); |
117 | } | 117 | } |
118 | } else { | 118 | } else { |
119 | /* Someone else joined */ | 119 | /* Someone else joined */ |
120 | if (mask.nick() != m_session->m_server->nick()) { | 120 | if (mask.nick() != m_session->m_server->nick()) { |
121 | if (!channel->getPerson(mask.nick())) { | 121 | if (!channel->getPerson(mask.nick())) { |
122 | IRCChannelPerson *chanperson = new IRCChannelPerson(); | 122 | IRCChannelPerson *chanperson = new IRCChannelPerson(); |
123 | IRCPerson *person = m_session->getPerson(mask.nick()); | 123 | IRCPerson *person = m_session->getPerson(mask.nick()); |
124 | if (!person) { | 124 | if (!person) { |
125 | person = new IRCPerson(message->prefix()); | 125 | person = new IRCPerson(message->prefix()); |
126 | m_session->addPerson(person); | 126 | m_session->addPerson(person); |
127 | } | 127 | } |
128 | chanperson->flags = 0; | 128 | chanperson->flags = 0; |
129 | chanperson->person = person; | 129 | chanperson->person = person; |
130 | channel->addPerson(chanperson); | 130 | channel->addPerson(chanperson); |
131 | IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); | 131 | IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); |
132 | output.addParam(channel); | 132 | output.addParam(channel); |
133 | output.addParam(chanperson); | 133 | output.addParam(chanperson); |
134 | emit outputReady(output); | 134 | emit outputReady(output); |
135 | } else { | 135 | } else { |
136 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); | 136 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); |
137 | } | 137 | } |
138 | } else { | 138 | } else { |
139 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); | 139 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { | 144 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { |
145 | QString channelName = message->param(0).lower(); | 145 | QString channelName = message->param(0).lower(); |
146 | IRCChannel *channel = m_session->getChannel(channelName); | 146 | IRCChannel *channel = m_session->getChannel(channelName); |
147 | IRCPerson mask(message->prefix()); | 147 | IRCPerson mask(message->prefix()); |
148 | if (channel) { | 148 | if (channel) { |
149 | if (mask.nick() == m_session->m_server->nick()) { | 149 | if (mask.nick() == m_session->m_server->nick()) { |
150 | m_session->removeChannel(channel); | 150 | m_session->removeChannel(channel); |
151 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); | 151 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); |
152 | output.addParam(channel); | 152 | output.addParam(channel); |
153 | emit outputReady(output); | 153 | emit outputReady(output); |
154 | delete channel; | 154 | delete channel; |
155 | } else { | 155 | } else { |
156 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 156 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
157 | if (person) { | 157 | if (person) { |
158 | channel->removePerson(person); | 158 | channel->removePerson(person); |
159 | IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); | 159 | IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); |
160 | output.addParam(channel); | 160 | output.addParam(channel); |
161 | output.addParam(person); | 161 | output.addParam(person); |
162 | emit outputReady(output); | 162 | emit outputReady(output); |
163 | delete person; | 163 | delete person; |
164 | } else { | 164 | } else { |
165 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); | 165 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } else { | 168 | } else { |
169 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); | 169 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | 173 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { |
174 | if (m_session->m_server->nick() == message->param(0)) { | 174 | if (m_session->m_server->nick() == message->param(0)) { |
175 | /* IRC Query message detected, verify sender and display it */ | 175 | /* IRC Query message detected, verify sender and display it */ |
176 | IRCPerson mask(message->prefix()); | 176 | IRCPerson mask(message->prefix()); |
177 | IRCPerson *person = m_session->getPerson(mask.nick()); | 177 | IRCPerson *person = m_session->getPerson(mask.nick()); |
178 | if (!person) { | 178 | if (!person) { |
179 | /* Person not yet known, create and add to the current session */ | 179 | /* Person not yet known, create and add to the current session */ |
180 | person = new IRCPerson(message->prefix()); | 180 | person = new IRCPerson(message->prefix()); |
181 | m_session->addPerson(person); | 181 | m_session->addPerson(person); |
182 | } | 182 | } |
183 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); | 183 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); |
184 | output.addParam(person); | 184 | output.addParam(person); |
185 | emit outputReady(output); | 185 | emit outputReady(output); |
186 | } else if (message->param(0).at(0) == '#') { | 186 | } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') { |
187 | /* IRC Channel message detected, verify sender, channel and display it */ | 187 | /* IRC Channel message detected, verify sender, channel and display it */ |
188 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 188 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
189 | if (channel) { | 189 | if (channel) { |
190 | IRCPerson mask(message->prefix()); | 190 | IRCPerson mask(message->prefix()); |
191 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 191 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
192 | if (person) { | 192 | if (person) { |
193 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); | 193 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); |
194 | output.addParam(channel); | 194 | output.addParam(channel); |
195 | output.addParam(person); | 195 | output.addParam(person); |
196 | emit outputReady(output); | 196 | emit outputReady(output); |
197 | } else { | 197 | } else { |
198 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); | 198 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); |
199 | } | 199 | } |
200 | } else { | 200 | } else { |
201 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0).lower())); | 201 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0).lower())); |
202 | } | 202 | } |
203 | } else { | 203 | } else { |
204 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); | 204 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 208 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
209 | IRCPerson mask(message->prefix()); | 209 | IRCPerson mask(message->prefix()); |
210 | 210 | ||
211 | if (mask.nick() == m_session->m_server->nick()) { | 211 | if (mask.nick() == m_session->m_server->nick()) { |
212 | /* We are changing our nickname */ | 212 | /* We are changing our nickname */ |
213 | m_session->m_server->setNick(message->param(0)); | 213 | m_session->m_server->setNick(message->param(0)); |
214 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); | 214 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); |
215 | output.addParam(0); | 215 | output.addParam(0); |
216 | emit outputReady(output); | 216 | emit outputReady(output); |
217 | } else { | 217 | } else { |
218 | /* Someone else is */ | 218 | /* Someone else is */ |
219 | IRCPerson *person = m_session->getPerson(mask.nick()); | 219 | IRCPerson *person = m_session->getPerson(mask.nick()); |
220 | if (person) { | 220 | if (person) { |
221 | IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); | 221 | IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); |
222 | output.addParam(person); | 222 | output.addParam(person); |
223 | emit outputReady(output); | 223 | emit outputReady(output); |
224 | } else { | 224 | } else { |
225 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 225 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 230 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
231 | IRCPerson mask(message->prefix()); | 231 | IRCPerson mask(message->prefix()); |
232 | IRCPerson *person = m_session->getPerson(mask.nick()); | 232 | IRCPerson *person = m_session->getPerson(mask.nick()); |
233 | if (person) { | 233 | if (person) { |
234 | QList<IRCChannel> channels; | 234 | QList<IRCChannel> channels; |
235 | m_session->getChannelsByPerson(person, channels); | 235 | m_session->getChannelsByPerson(person, channels); |
236 | QListIterator<IRCChannel> it(channels); | 236 | QListIterator<IRCChannel> it(channels); |
237 | for (;it.current(); ++it) { | 237 | for (;it.current(); ++it) { |
238 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 238 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
239 | it.current()->removePerson(chanperson); | 239 | it.current()->removePerson(chanperson); |
240 | delete chanperson; | 240 | delete chanperson; |
241 | } | 241 | } |
242 | m_session->removePerson(person); | 242 | m_session->removePerson(person); |
243 | IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); | 243 | IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); |
244 | output.addParam(person); | 244 | output.addParam(person); |
245 | emit outputReady(output); | 245 | emit outputReady(output); |
246 | delete person; | 246 | delete person; |
247 | } else { | 247 | } else { |
248 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); | 248 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { | 252 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { |
253 | IRCPerson mask(message->prefix()); | 253 | IRCPerson mask(message->prefix()); |
254 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 254 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
255 | if (channel) { | 255 | if (channel) { |
256 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); | 256 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); |
257 | output.addParam(channel); | 257 | output.addParam(channel); |
258 | emit outputReady(output); | 258 | emit outputReady(output); |
259 | } else { | 259 | } else { |
260 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); | 260 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { | 264 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { |
265 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); | 265 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); |
266 | } | 266 | } |
267 | 267 | ||
268 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | 268 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { |
269 | IRCPerson mask(message->prefix()); | 269 | IRCPerson mask(message->prefix()); |
270 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); | 270 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); |
271 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); | 271 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); |
272 | } | 272 | } |
273 | 273 | ||
274 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 274 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
275 | IRCPerson mask(message->prefix()); | 275 | IRCPerson mask(message->prefix()); |
276 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); | 276 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); |
277 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); | 277 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); |
278 | } | 278 | } |
279 | 279 | ||
280 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | 280 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { |
281 | IRCPerson mask(message->prefix()); | 281 | IRCPerson mask(message->prefix()); |
282 | QString dest = message->ctcpDestination(); | 282 | QString dest = message->ctcpDestination(); |
283 | if (dest.startsWith("#")) { | 283 | if (dest.startsWith("#")) { |
284 | IRCChannel *channel = m_session->getChannel(dest.lower()); | 284 | IRCChannel *channel = m_session->getChannel(dest.lower()); |
285 | if (channel) { | 285 | if (channel) { |
286 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 286 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
287 | if (person) { | 287 | if (person) { |
288 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); | 288 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); |
289 | output.addParam(channel); | 289 | output.addParam(channel); |
290 | output.addParam(person); | 290 | output.addParam(person); |
291 | emit outputReady(output); | 291 | emit outputReady(output); |
292 | } else { | 292 | } else { |
293 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); | 293 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); |
294 | } | 294 | } |
295 | } else { | 295 | } else { |
296 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); | 296 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); |
297 | } | 297 | } |
298 | } else { | 298 | } else { |
299 | if (message->ctcpDestination() == m_session->m_server->nick()) { | 299 | if (message->ctcpDestination() == m_session->m_server->nick()) { |
300 | IRCPerson *person = m_session->getPerson(mask.nick()); | 300 | IRCPerson *person = m_session->getPerson(mask.nick()); |
301 | if (!person) { | 301 | if (!person) { |
302 | /* Person not yet known, create and add to the current session */ | 302 | /* Person not yet known, create and add to the current session */ |
303 | person = new IRCPerson(message->prefix()); | 303 | person = new IRCPerson(message->prefix()); |
304 | m_session->addPerson(person); | 304 | m_session->addPerson(person); |
305 | } | 305 | } |
306 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 306 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
307 | output.addParam(person); | 307 | output.addParam(person); |
308 | emit outputReady(output); | 308 | emit outputReady(output); |
309 | } else { | 309 | } else { |
310 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 310 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 315 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
316 | IRCPerson mask(message->prefix()); | 316 | IRCPerson mask(message->prefix()); |
317 | 317 | ||
318 | if (message->param(0).startsWith("#")) { | 318 | if (message->param(0).startsWith("#")) { |
319 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 319 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
320 | if (channel) { | 320 | if (channel) { |
321 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); | 321 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); |
322 | QTextIStream stream(¶meters); | 322 | QTextIStream stream(¶meters); |
323 | bool set = FALSE; | 323 | bool set = FALSE; |
324 | while (!stream.atEnd()) { | 324 | while (!stream.atEnd()) { |
325 | stream >> temp; | 325 | stream >> temp; |
326 | if (temp.startsWith("+")) { | 326 | if (temp.startsWith("+")) { |
327 | set = TRUE; | 327 | set = TRUE; |
328 | temp = temp.right(1); | 328 | temp = temp.right(1); |
329 | } else if (temp.startsWith("-")) { | 329 | } else if (temp.startsWith("-")) { |
330 | set = FALSE; | 330 | set = FALSE; |
331 | temp = temp.right(1); | 331 | temp = temp.right(1); |
332 | } else { | 332 | } else { |
333 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); | 333 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); |
334 | return; | 334 | return; |
335 | } | 335 | } |
336 | if (temp == "o") { | 336 | if (temp == "o") { |
337 | stream >> temp; | 337 | stream >> temp; |
338 | IRCChannelPerson *person = channel->getPerson(temp); | 338 | IRCChannelPerson *person = channel->getPerson(temp); |
339 | if (person) { | 339 | if (person) { |
340 | if (set) { | 340 | if (set) { |
341 | person->flags |= PERSON_FLAG_OP; | 341 | person->flags |= PERSON_FLAG_OP; |
342 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); | 342 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); |
343 | output.addParam(channel); | 343 | output.addParam(channel); |
344 | output.addParam(person); | 344 | output.addParam(person); |
345 | emit outputReady(output); | 345 | emit outputReady(output); |
346 | } else { | 346 | } else { |
347 | person->flags &= 0xFFFF - PERSON_FLAG_OP; | 347 | person->flags &= 0xFFFF - PERSON_FLAG_OP; |
348 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); | 348 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); |
349 | output.addParam(channel); | 349 | output.addParam(channel); |
350 | output.addParam(person); | 350 | output.addParam(person); |
351 | emit outputReady(output); | 351 | emit outputReady(output); |
352 | } | 352 | } |
353 | } else { | 353 | } else { |
354 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 354 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
355 | } | 355 | } |
356 | } else if (temp == "v") { | 356 | } else if (temp == "v") { |
357 | stream >> temp; | 357 | stream >> temp; |
358 | IRCChannelPerson *person = channel->getPerson(temp); | 358 | IRCChannelPerson *person = channel->getPerson(temp); |
359 | if (person) { | 359 | if (person) { |
360 | if (set) { | 360 | if (set) { |
361 | person->flags |= PERSON_FLAG_VOICE; | 361 | person->flags |= PERSON_FLAG_VOICE; |
362 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); | 362 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); |
363 | output.addParam(channel); | 363 | output.addParam(channel); |
364 | output.addParam(person); | 364 | output.addParam(person); |
365 | emit outputReady(output); | 365 | emit outputReady(output); |
366 | } else { | 366 | } else { |
367 | person->flags &= 0xFFFF - PERSON_FLAG_VOICE; | 367 | person->flags &= 0xFFFF - PERSON_FLAG_VOICE; |
368 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); | 368 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); |
369 | output.addParam(channel); | 369 | output.addParam(channel); |
370 | output.addParam(person); | 370 | output.addParam(person); |
371 | emit outputReady(output); | 371 | emit outputReady(output); |
372 | } | 372 | } |
373 | } else { | 373 | } else { |
374 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 374 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
375 | } | 375 | } |
376 | } else { | 376 | } else { |
377 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); | 377 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | } else { | 380 | } else { |
381 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); | 381 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); |
382 | } | 382 | } |
383 | } else { | 383 | } else { |
384 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); | 384 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | 388 | void IRCMessageParser::parseLiteralKick(IRCMessage *message) { |
389 | IRCPerson mask(message->prefix()); | 389 | IRCPerson mask(message->prefix()); |
390 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); | 390 | IRCChannel *channel = m_session->getChannel(message->param(0).lower()); |
391 | if (channel) { | 391 | if (channel) { |
392 | IRCChannelPerson *person = channel->getPerson(message->param(1)); | 392 | IRCChannelPerson *person = channel->getPerson(message->param(1)); |
393 | if (person) { | 393 | if (person) { |
394 | if (person->person->nick() == m_session->m_server->nick()) { | 394 | if (person->person->nick() == m_session->m_server->nick()) { |
395 | m_session->removeChannel(channel); | 395 | m_session->removeChannel(channel); |
396 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); | 396 | IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); |
397 | output.addParam(channel); | 397 | output.addParam(channel); |
398 | emit outputReady(output); | 398 | emit outputReady(output); |
399 | } else { | 399 | } else { |
400 | channel->removePerson(person); | 400 | channel->removePerson(person); |
401 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); | 401 | IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); |
402 | output.addParam(channel); | 402 | output.addParam(channel); |
403 | output.addParam(person); | 403 | output.addParam(person); |
404 | emit outputReady(output); | 404 | emit outputReady(output); |
405 | } | 405 | } |
406 | } else { | 406 | } else { |
407 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); | 407 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); |
408 | } | 408 | } |
409 | } else { | 409 | } else { |
410 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); | 410 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); |
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
414 | void IRCMessageParser::parseNumerical001(IRCMessage *message) { | 414 | void IRCMessageParser::parseNumerical001(IRCMessage *message) { |
415 | /* Welcome to IRC message, display */ | 415 | /* Welcome to IRC message, display */ |
416 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 416 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
417 | } | 417 | } |
418 | 418 | ||
419 | void IRCMessageParser::parseNumerical002(IRCMessage *message) { | 419 | void IRCMessageParser::parseNumerical002(IRCMessage *message) { |
420 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 420 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
421 | } | 421 | } |
422 | 422 | ||
423 | void IRCMessageParser::parseNumerical003(IRCMessage *message) { | 423 | void IRCMessageParser::parseNumerical003(IRCMessage *message) { |
424 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 424 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
425 | } | 425 | } |
426 | 426 | ||
427 | void IRCMessageParser::parseNumerical004(IRCMessage *message) { | 427 | void IRCMessageParser::parseNumerical004(IRCMessage *message) { |
428 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 428 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
429 | } | 429 | } |
430 | 430 | ||
431 | void IRCMessageParser::parseNumerical005(IRCMessage *message) { | 431 | void IRCMessageParser::parseNumerical005(IRCMessage *message) { |
432 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 432 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
433 | } | 433 | } |
434 | 434 | ||
435 | void IRCMessageParser::parseNumericalStats(IRCMessage *message) { | 435 | void IRCMessageParser::parseNumericalStats(IRCMessage *message) { |
436 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 436 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
437 | } | 437 | } |
438 | 438 | ||
439 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | 439 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { |
440 | /* Name list sent when joining a channel */ | 440 | /* Name list sent when joining a channel */ |
441 | IRCChannel *channel = m_session->getChannel(message->param(2).lower()); | 441 | IRCChannel *channel = m_session->getChannel(message->param(2).lower()); |
442 | if (channel != 0) { | 442 | if (channel != 0) { |
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp index 5e916ae..f976c84 100644 --- a/noncore/net/opieirc/ircservereditor.cpp +++ b/noncore/net/opieirc/ircservereditor.cpp | |||
@@ -1,77 +1,77 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include "ircservereditor.h" | 4 | #include "ircservereditor.h" |
5 | 5 | ||
6 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { | 6 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { |
7 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); | 7 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); |
8 | QLabel *label = new QLabel(tr("Profile name :"), this); | 8 | QLabel *label = new QLabel(tr("Profile name :"), this); |
9 | m_name = new QLineEdit(server.name(), this); | 9 | m_name = new QLineEdit(server.name(), this); |
10 | layout->addWidget(label, 0, 0); | 10 | layout->addWidget(label, 0, 0); |
11 | layout->addWidget(m_name, 0, 1); | 11 | layout->addWidget(m_name, 0, 1); |
12 | label = new QLabel(tr("Hostname :"), this); | 12 | label = new QLabel(tr("Hostname :"), this); |
13 | m_hostname = new QLineEdit(server.hostname(), this); | 13 | m_hostname = new QLineEdit(server.hostname(), this); |
14 | layout->addWidget(label, 1, 0); | 14 | layout->addWidget(label, 1, 0); |
15 | layout->addWidget(m_hostname, 1, 1); | 15 | layout->addWidget(m_hostname, 1, 1); |
16 | label = new QLabel(tr("Port :"), this); | 16 | label = new QLabel(tr("Port :"), this); |
17 | m_port = new QLineEdit(QString::number(server.port()), this); | 17 | m_port = new QLineEdit(QString::number(server.port()), this); |
18 | layout->addWidget(label, 2, 0); | 18 | layout->addWidget(label, 2, 0); |
19 | layout->addWidget(m_port, 2, 1); | 19 | layout->addWidget(m_port, 2, 1); |
20 | label = new QLabel(tr("Nickname :"), this); | 20 | label = new QLabel(tr("Nickname :"), this); |
21 | m_nickname = new QLineEdit(server.nick(), this); | 21 | m_nickname = new QLineEdit(server.nick(), this); |
22 | layout->addWidget(label, 3, 0); | 22 | layout->addWidget(label, 3, 0); |
23 | layout->addWidget(m_nickname, 3, 1); | 23 | layout->addWidget(m_nickname, 3, 1); |
24 | label = new QLabel(tr("Realname :"), this); | 24 | label = new QLabel(tr("Realname :"), this); |
25 | m_realname = new QLineEdit(server.realname(), this); | 25 | m_realname = new QLineEdit(server.realname(), this); |
26 | layout->addWidget(label, 4, 0); | 26 | layout->addWidget(label, 4, 0); |
27 | layout->addWidget(m_realname, 4, 1); | 27 | layout->addWidget(m_realname, 4, 1); |
28 | label = new QLabel(tr("Password :"), this); | 28 | label = new QLabel(tr("Password :"), this); |
29 | m_password = new QLineEdit(server.password(), this); | 29 | m_password = new QLineEdit(server.password(), this); |
30 | layout->addWidget(label, 5, 0); | 30 | layout->addWidget(label, 5, 0); |
31 | layout->addWidget(m_password, 5, 1); | 31 | layout->addWidget(m_password, 5, 1); |
32 | label = new QLabel(tr("Channels :"), this); | 32 | label = new QLabel(tr("Channels :"), this); |
33 | m_channels = new QLineEdit(server.channels(), this); | 33 | m_channels = new QLineEdit(server.channels(), this); |
34 | layout->addWidget(label, 6, 0); | 34 | layout->addWidget(label, 6, 0); |
35 | layout->addWidget(m_channels, 6, 1); | 35 | layout->addWidget(m_channels, 6, 1); |
36 | setCaption(tr("Edit server information")); | 36 | setCaption(tr("Edit server information")); |
37 | showMaximized(); | 37 | showMaximized(); |
38 | } | 38 | } |
39 | 39 | ||
40 | 40 | ||
41 | void IRCServerEditor::accept() { | 41 | void IRCServerEditor::accept() { |
42 | if (m_name->text().length()==0) | 42 | if (m_name->text().length()==0) |
43 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); | 43 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); |
44 | else if (m_hostname->text().length()==0) | 44 | else if (m_hostname->text().length()==0) |
45 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); | 45 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); |
46 | else if (m_port->text().toInt()<=0) | 46 | else if (m_port->text().toInt()<=0) |
47 | QMessageBox::critical(this, tr("Error"), tr("Port required")); | 47 | QMessageBox::critical(this, tr("Error"), tr("Port required")); |
48 | else if (m_nickname->text().length()==0) | 48 | else if (m_nickname->text().length()==0) |
49 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); | 49 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); |
50 | else if (m_realname->text().length()==0) | 50 | else if (m_realname->text().length()==0) |
51 | QMessageBox::critical(this, tr("Error"), tr("Realname required")); | 51 | QMessageBox::critical(this, tr("Error"), tr("Realname required")); |
52 | else { | 52 | else { |
53 | /* Now verify whether the channel list has a valid format */ | 53 | /* Now verify whether the channel list has a valid format */ |
54 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); | 54 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); |
55 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { | 55 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { |
56 | QString channelName = (*it).stripWhiteSpace(); | 56 | QString channelName = (*it).stripWhiteSpace(); |
57 | if (!channelName.startsWith("#")) { | 57 | if (!channelName.startsWith("#") && !channelName.startsWith("+")) { |
58 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'")); | 58 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with either '#' or '+'")); |
59 | return; | 59 | return; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | QDialog::accept(); | 62 | QDialog::accept(); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | IRCServer IRCServerEditor::getServer() { | 66 | IRCServer IRCServerEditor::getServer() { |
67 | IRCServer server; | 67 | IRCServer server; |
68 | server.setName(m_name->text()); | 68 | server.setName(m_name->text()); |
69 | server.setHostname(m_hostname->text()); | 69 | server.setHostname(m_hostname->text()); |
70 | server.setPort(m_port->text().toInt()); | 70 | server.setPort(m_port->text().toInt()); |
71 | server.setNick(m_nickname->text()); | 71 | server.setNick(m_nickname->text()); |
72 | server.setRealname(m_realname->text()); | 72 | server.setRealname(m_realname->text()); |
73 | server.setUsername(m_nickname->text()); | 73 | server.setUsername(m_nickname->text()); |
74 | server.setPassword(m_password->text()); | 74 | server.setPassword(m_password->text()); |
75 | server.setChannels(m_channels->text()); | 75 | server.setChannels(m_channels->text()); |
76 | return server; | 76 | return server; |
77 | } | 77 | } |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index aea58a3..d16c05f 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -1,264 +1,264 @@ | |||
1 | #include <qpe/config.h> | 1 | #include <qpe/config.h> |
2 | #include <qtextstream.h> | 2 | #include <qtextstream.h> |
3 | #include "ircservertab.h" | 3 | #include "ircservertab.h" |
4 | 4 | ||
5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 5 | IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { |
6 | m_server = server; | 6 | m_server = server; |
7 | m_session = new IRCSession(&m_server); | 7 | m_session = new IRCSession(&m_server); |
8 | m_mainWindow = mainWindow; | 8 | m_mainWindow = mainWindow; |
9 | m_close = FALSE; | 9 | m_close = FALSE; |
10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); | 10 | m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); |
11 | m_textview = new QTextView(this); | 11 | m_textview = new QTextView(this); |
12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 12 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 13 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
14 | m_textview->setTextFormat(RichText); | 14 | m_textview->setTextFormat(RichText); |
15 | m_layout->add(m_textview); | 15 | m_layout->add(m_textview); |
16 | m_field = new QLineEdit(this); | 16 | m_field = new QLineEdit(this); |
17 | m_layout->add(m_field); | 17 | m_layout->add(m_field); |
18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 18 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
19 | m_field->setFocus(); | 19 | m_field->setFocus(); |
20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 20 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
21 | settingsChanged(); | 21 | settingsChanged(); |
22 | } | 22 | } |
23 | 23 | ||
24 | void IRCServerTab::appendText(QString text) { | 24 | void IRCServerTab::appendText(QString text) { |
25 | /* not using append because it creates layout problems */ | 25 | /* not using append because it creates layout problems */ |
26 | m_textview->setText(m_textview->text() + text); | 26 | m_textview->setText(m_textview->text() + text); |
27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 27 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
28 | } | 28 | } |
29 | 29 | ||
30 | IRCServerTab::~IRCServerTab() { | 30 | IRCServerTab::~IRCServerTab() { |
31 | delete m_session; | 31 | delete m_session; |
32 | } | 32 | } |
33 | 33 | ||
34 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | 34 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { |
35 | m_channelTabs.remove(tab); | 35 | m_channelTabs.remove(tab); |
36 | } | 36 | } |
37 | 37 | ||
38 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { | 38 | void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { |
39 | m_queryTabs.remove(tab); | 39 | m_queryTabs.remove(tab); |
40 | } | 40 | } |
41 | 41 | ||
42 | void IRCServerTab::addQueryTab(IRCQueryTab *tab) { | 42 | void IRCServerTab::addQueryTab(IRCQueryTab *tab) { |
43 | m_queryTabs.append(tab); | 43 | m_queryTabs.append(tab); |
44 | } | 44 | } |
45 | 45 | ||
46 | QString IRCServerTab::title() { | 46 | QString IRCServerTab::title() { |
47 | return "Server"; | 47 | return "Server"; |
48 | } | 48 | } |
49 | 49 | ||
50 | IRCSession *IRCServerTab::session() { | 50 | IRCSession *IRCServerTab::session() { |
51 | return m_session; | 51 | return m_session; |
52 | } | 52 | } |
53 | 53 | ||
54 | IRCServer *IRCServerTab::server() { | 54 | IRCServer *IRCServerTab::server() { |
55 | return &m_server; | 55 | return &m_server; |
56 | } | 56 | } |
57 | 57 | ||
58 | void IRCServerTab::settingsChanged() { | 58 | void IRCServerTab::settingsChanged() { |
59 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); | 59 | m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); |
60 | } | 60 | } |
61 | 61 | ||
62 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { | 62 | void IRCServerTab::executeCommand(IRCTab *tab, QString line) { |
63 | QTextIStream stream(&line); | 63 | QTextIStream stream(&line); |
64 | QString command; | 64 | QString command; |
65 | stream >> command; | 65 | stream >> command; |
66 | command = command.upper().right(command.length()-1); | 66 | command = command.upper().right(command.length()-1); |
67 | 67 | ||
68 | if (command == "JOIN") { | 68 | if (command == "JOIN") { |
69 | QString channel; | 69 | QString channel; |
70 | stream >> channel; | 70 | stream >> channel; |
71 | if (channel.length() > 0 && channel.startsWith("#")) { | 71 | if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { |
72 | m_session->join(channel); | 72 | m_session->join(channel); |
73 | } else { | 73 | } else { |
74 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); | 74 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); |
75 | } | 75 | } |
76 | } else if (command == "ME") { | 76 | } else if (command == "ME") { |
77 | QString text = line.right(line.length()-4); | 77 | QString text = line.right(line.length()-4); |
78 | if (text.length() > 0) { | 78 | if (text.length() > 0) { |
79 | if (tab->isA("IRCChannelTab")) { | 79 | if (tab->isA("IRCChannelTab")) { |
80 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 80 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
81 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); | 81 | m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); |
82 | } else if (tab->isA("IRCQueryTab")) { | 82 | } else if (tab->isA("IRCQueryTab")) { |
83 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); | 83 | tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); |
84 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); | 84 | m_session->sendAction(((IRCQueryTab *)tab)->person(), text); |
85 | } else { | 85 | } else { |
86 | tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); | 86 | tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } else if (command == "MSG") { | 89 | } else if (command == "MSG") { |
90 | QString nickname; | 90 | QString nickname; |
91 | stream >> nickname; | 91 | stream >> nickname; |
92 | if (nickname.length() > 0) { | 92 | if (nickname.length() > 0) { |
93 | if (line.length() > 6 + nickname.length()) { | 93 | if (line.length() > 6 + nickname.length()) { |
94 | QString text = line.right(line.length()-nickname.length()-6); | 94 | QString text = line.right(line.length()-nickname.length()-6); |
95 | IRCPerson person; | 95 | IRCPerson person; |
96 | person.setNick(nickname); | 96 | person.setNick(nickname); |
97 | tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); | 97 | tab->appendText("<font color=\"" + m_textColor + "\">></font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">< "+IRCOutput::toHTML(text)+"</font><br>"); |
98 | m_session->sendMessage(&person, text); | 98 | m_session->sendMessage(&person, text); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | } else { | 101 | } else { |
102 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); | 102 | tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | void IRCServerTab::processCommand() { | 106 | void IRCServerTab::processCommand() { |
107 | QString text = m_field->text(); | 107 | QString text = m_field->text(); |
108 | if (text.startsWith("/") && !text.startsWith("//")) { | 108 | if (text.startsWith("/") && !text.startsWith("//")) { |
109 | /* Command mode */ | 109 | /* Command mode */ |
110 | executeCommand(this, text); | 110 | executeCommand(this, text); |
111 | } | 111 | } |
112 | m_field->clear(); | 112 | m_field->clear(); |
113 | } | 113 | } |
114 | 114 | ||
115 | void IRCServerTab::doConnect() { | 115 | void IRCServerTab::doConnect() { |
116 | m_session->beginSession(); | 116 | m_session->beginSession(); |
117 | } | 117 | } |
118 | 118 | ||
119 | void IRCServerTab::remove() { | 119 | void IRCServerTab::remove() { |
120 | /* Close requested */ | 120 | /* Close requested */ |
121 | if (m_session->isSessionActive()) { | 121 | if (m_session->isSessionActive()) { |
122 | /* While there is a running session */ | 122 | /* While there is a running session */ |
123 | m_close = TRUE; | 123 | m_close = TRUE; |
124 | m_session->endSession(); | 124 | m_session->endSession(); |
125 | } else { | 125 | } else { |
126 | /* Session has previously been closed */ | 126 | /* Session has previously been closed */ |
127 | m_channelTabs.first(); | 127 | m_channelTabs.first(); |
128 | while (m_channelTabs.current() != 0) { | 128 | while (m_channelTabs.current() != 0) { |
129 | m_mainWindow->killTab(m_channelTabs.current()); | 129 | m_mainWindow->killTab(m_channelTabs.current()); |
130 | } | 130 | } |
131 | m_queryTabs.first(); | 131 | m_queryTabs.first(); |
132 | while (m_queryTabs.current() != 0) { | 132 | while (m_queryTabs.current() != 0) { |
133 | m_mainWindow->killTab(m_queryTabs.current()); | 133 | m_mainWindow->killTab(m_queryTabs.current()); |
134 | } | 134 | } |
135 | m_mainWindow->killTab(this); | 135 | m_mainWindow->killTab(this); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { | 139 | IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { |
140 | QListIterator<IRCChannelTab> it(m_channelTabs); | 140 | QListIterator<IRCChannelTab> it(m_channelTabs); |
141 | 141 | ||
142 | for (; it.current(); ++it) { | 142 | for (; it.current(); ++it) { |
143 | if (it.current()->channel() == channel) | 143 | if (it.current()->channel() == channel) |
144 | return it.current(); | 144 | return it.current(); |
145 | } | 145 | } |
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 148 | ||
149 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { | 149 | IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { |
150 | QListIterator<IRCQueryTab> it(m_queryTabs); | 150 | QListIterator<IRCQueryTab> it(m_queryTabs); |
151 | 151 | ||
152 | for (; it.current(); ++it) { | 152 | for (; it.current(); ++it) { |
153 | if (it.current()->person()->nick() == person->nick()) | 153 | if (it.current()->person()->nick() == person->nick()) |
154 | return it.current(); | 154 | return it.current(); |
155 | } | 155 | } |
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | void IRCServerTab::display(IRCOutput output) { | 159 | void IRCServerTab::display(IRCOutput output) { |
160 | 160 | ||
161 | /* All messages to be displayed inside the GUI get here */ | 161 | /* All messages to be displayed inside the GUI get here */ |
162 | switch (output.type()) { | 162 | switch (output.type()) { |
163 | case OUTPUT_CONNCLOSE: | 163 | case OUTPUT_CONNCLOSE: |
164 | if (m_close) { | 164 | if (m_close) { |
165 | m_channelTabs.first(); | 165 | m_channelTabs.first(); |
166 | while (m_channelTabs.current() != 0) { | 166 | while (m_channelTabs.current() != 0) { |
167 | m_mainWindow->killTab(m_channelTabs.current()); | 167 | m_mainWindow->killTab(m_channelTabs.current()); |
168 | } | 168 | } |
169 | m_queryTabs.first(); | 169 | m_queryTabs.first(); |
170 | while (m_queryTabs.current() != 0) { | 170 | while (m_queryTabs.current() != 0) { |
171 | m_mainWindow->killTab(m_queryTabs.current()); | 171 | m_mainWindow->killTab(m_queryTabs.current()); |
172 | } | 172 | } |
173 | m_mainWindow->killTab(this); | 173 | m_mainWindow->killTab(this); |
174 | } else { | 174 | } else { |
175 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); | 175 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); |
176 | QListIterator<IRCChannelTab> it(m_channelTabs); | 176 | QListIterator<IRCChannelTab> it(m_channelTabs); |
177 | for (; it.current(); ++it) { | 177 | for (; it.current(); ++it) { |
178 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); | 178 | it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | break; | 181 | break; |
182 | case OUTPUT_SELFJOIN: { | 182 | case OUTPUT_SELFJOIN: { |
183 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 183 | IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
184 | m_channelTabs.append(channeltab); | 184 | m_channelTabs.append(channeltab); |
185 | m_mainWindow->addTab(channeltab); | 185 | m_mainWindow->addTab(channeltab); |
186 | } | 186 | } |
187 | break; | 187 | break; |
188 | case OUTPUT_CHANPRIVMSG: { | 188 | case OUTPUT_CHANPRIVMSG: { |
189 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 189 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
190 | channelTab->appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage()+"</font><br>"); | 190 | channelTab->appendText("<font color=\"" + m_textColor + "\"><</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">> " + output.htmlMessage()+"</font><br>"); |
191 | } | 191 | } |
192 | break; | 192 | break; |
193 | case OUTPUT_QUERYACTION: | 193 | case OUTPUT_QUERYACTION: |
194 | case OUTPUT_QUERYPRIVMSG: { | 194 | case OUTPUT_QUERYPRIVMSG: { |
195 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); | 195 | IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); |
196 | if (!queryTab) { | 196 | if (!queryTab) { |
197 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); | 197 | queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); |
198 | m_queryTabs.append(queryTab); | 198 | m_queryTabs.append(queryTab); |
199 | m_mainWindow->addTab(queryTab); | 199 | m_mainWindow->addTab(queryTab); |
200 | } | 200 | } |
201 | queryTab->display(output); | 201 | queryTab->display(output); |
202 | } | 202 | } |
203 | break; | 203 | break; |
204 | case OUTPUT_SELFPART: { | 204 | case OUTPUT_SELFPART: { |
205 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 205 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
206 | if (channelTab) | 206 | if (channelTab) |
207 | m_mainWindow->killTab(channelTab); | 207 | m_mainWindow->killTab(channelTab); |
208 | } | 208 | } |
209 | break; | 209 | break; |
210 | case OUTPUT_SELFKICK: { | 210 | case OUTPUT_SELFKICK: { |
211 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 211 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
212 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 212 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
213 | if (channelTab) | 213 | if (channelTab) |
214 | m_mainWindow->killTab(channelTab); | 214 | m_mainWindow->killTab(channelTab); |
215 | } | 215 | } |
216 | break; | 216 | break; |
217 | case OUTPUT_CHANACTION: { | 217 | case OUTPUT_CHANACTION: { |
218 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 218 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
219 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); | 219 | channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); |
220 | } | 220 | } |
221 | break; | 221 | break; |
222 | case OUTPUT_TOPIC: { | 222 | case OUTPUT_TOPIC: { |
223 | IRCChannel *channel = (IRCChannel *) output.getParam(0); | 223 | IRCChannel *channel = (IRCChannel *) output.getParam(0); |
224 | if (channel) { | 224 | if (channel) { |
225 | IRCChannelTab *channelTab = getTabForChannel(channel); | 225 | IRCChannelTab *channelTab = getTabForChannel(channel); |
226 | if (channelTab) { | 226 | if (channelTab) { |
227 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 227 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 231 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | case OUTPUT_QUIT: { | 234 | case OUTPUT_QUIT: { |
235 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 235 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); |
236 | QListIterator<IRCChannelTab> it(m_channelTabs); | 236 | QListIterator<IRCChannelTab> it(m_channelTabs); |
237 | for (; it.current(); ++it) { | 237 | for (; it.current(); ++it) { |
238 | if (it.current()->list()->hasPerson(nick)) { | 238 | if (it.current()->list()->hasPerson(nick)) { |
239 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 239 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
240 | it.current()->list()->update(); | 240 | it.current()->list()->update(); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | break; | 244 | break; |
245 | case OUTPUT_OTHERJOIN: | 245 | case OUTPUT_OTHERJOIN: |
246 | case OUTPUT_OTHERKICK: | 246 | case OUTPUT_OTHERKICK: |
247 | case OUTPUT_CHANPERSONMODE: | 247 | case OUTPUT_CHANPERSONMODE: |
248 | case OUTPUT_OTHERPART: { | 248 | case OUTPUT_OTHERPART: { |
249 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 249 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
250 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 250 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
251 | channelTab->list()->update(); | 251 | channelTab->list()->update(); |
252 | } | 252 | } |
253 | break; | 253 | break; |
254 | case OUTPUT_CTCP: | 254 | case OUTPUT_CTCP: |
255 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); | 255 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); |
256 | break; | 256 | break; |
257 | case OUTPUT_ERROR: | 257 | case OUTPUT_ERROR: |
258 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 258 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
259 | break; | 259 | break; |
260 | default: | 260 | default: |
261 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); | 261 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); |
262 | break; | 262 | break; |
263 | } | 263 | } |
264 | } | 264 | } |