author | wazlaf <wazlaf> | 2002-09-29 19:54:12 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-29 19:54:12 (UTC) |
commit | 1dd254c95a582c2c86c816516a1b4433d8142d8a (patch) (unidiff) | |
tree | a3225293a4b399494a04e5bb07154bd673ba0acf | |
parent | f91ea4e068f38e9df17b06c87cd8635628837a4f (diff) | |
download | opie-1dd254c95a582c2c86c816516a1b4433d8142d8a.zip opie-1dd254c95a582c2c86c816516a1b4433d8142d8a.tar.gz opie-1dd254c95a582c2c86c816516a1b4433d8142d8a.tar.bz2 |
some more message types supported to make this work more smoothly with freenode.net
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 33 | ||||
-rw-r--r-- | noncore/net/opieirc/ircmessageparser.h | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircoutput.h | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 12 |
4 files changed, 49 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index 5c70753..d1b70a5 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -1,340 +1,355 @@ | |||
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 | { 0 , 0 } | 19 | { 0 , 0 } |
19 | }; | 20 | }; |
20 | 21 | ||
21 | /* Lookup table for literal commands */ | 22 | /* Lookup table for literal commands */ |
22 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { | 23 | IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { |
23 | { "PING", FUNC(parseCTCPPing) }, | 24 | { "PING", FUNC(parseCTCPPing) }, |
24 | { "VERSION", FUNC(parseCTCPVersion) }, | 25 | { "VERSION", FUNC(parseCTCPVersion) }, |
25 | { "ACTION", FUNC(parseCTCPAction) }, | 26 | { "ACTION", FUNC(parseCTCPAction) }, |
26 | { 0 , 0 } | 27 | { 0 , 0 } |
27 | }; | 28 | }; |
28 | 29 | ||
29 | /* Lookup table for numerical commands */ | 30 | /* Lookup table for numerical commands */ |
30 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { | 31 | IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { |
31 | { 1, FUNC(parseNumerical001) }, // RPL_WELCOME | 32 | { 1, FUNC(parseNumerical001) }, // RPL_WELCOME |
32 | { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST | 33 | { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST |
33 | { 3, FUNC(parseNumerical003) }, // RPL_CREATED | 34 | { 3, FUNC(parseNumerical003) }, // RPL_CREATED |
34 | { 4, FUNC(parseNumerical004) }, // RPL_MYINFO | 35 | { 4, FUNC(parseNumerical004) }, // RPL_MYINFO |
35 | { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL | 36 | { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL |
36 | { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT | 37 | { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT |
37 | { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS | 38 | { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS |
38 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME | 39 | { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME |
40 | { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC | ||
41 | { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME | ||
39 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY | 42 | { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY |
40 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES | 43 | { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES |
41 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART | 44 | { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART |
42 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD | 45 | { 372, FUNC(parseNumericalStats) }, // RPL_MOTD |
43 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD | 46 | { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD |
44 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 | 47 | { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 |
45 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 | 48 | { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 |
46 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK | 49 | { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK |
47 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK | 50 | { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK |
48 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND | 51 | { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND |
49 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE | 52 | { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE |
50 | { 0, 0 } | 53 | { 0, 0 } |
51 | }; | 54 | }; |
52 | 55 | ||
53 | IRCMessageParser::IRCMessageParser(IRCSession *session) { | 56 | IRCMessageParser::IRCMessageParser(IRCSession *session) { |
54 | m_session = session; | 57 | m_session = session; |
55 | } | 58 | } |
56 | 59 | ||
57 | void IRCMessageParser::parse(IRCMessage *message) { | 60 | void IRCMessageParser::parse(IRCMessage *message) { |
58 | /* Find out what kind of message we have here and call the appropriate handler using | 61 | /* Find out what kind of message we have here and call the appropriate handler using |
59 | the parser tables. If no handler can be found, print out an error message */ | 62 | the parser tables. If no handler can be found, print out an error message */ |
60 | if (message->isNumerical()) { | 63 | if (message->isNumerical()) { |
61 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { | 64 | for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { |
62 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { | 65 | if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { |
63 | (this->*(numericalParserProcTable[i].proc))(message); | 66 | (this->*(numericalParserProcTable[i].proc))(message); |
64 | return; | 67 | return; |
65 | } | 68 | } |
66 | } | 69 | } |
67 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); | 70 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); |
68 | } else if (message->isCTCP()) { | 71 | } else if (message->isCTCP()) { |
69 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { | 72 | for (int i=0; ctcpParserProcTable[i].commandName; i++) { |
70 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { | 73 | if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { |
71 | (this->*(ctcpParserProcTable[i].proc))(message); | 74 | (this->*(ctcpParserProcTable[i].proc))(message); |
72 | return; | 75 | return; |
73 | } | 76 | } |
74 | } | 77 | } |
75 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); | 78 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); |
76 | } else { | 79 | } else { |
77 | for (int i=0; literalParserProcTable[i].commandName; i++) { | 80 | for (int i=0; literalParserProcTable[i].commandName; i++) { |
78 | if (message->command() == literalParserProcTable[i].commandName) { | 81 | if (message->command() == literalParserProcTable[i].commandName) { |
79 | (this->*(literalParserProcTable[i].proc))(message); | 82 | (this->*(literalParserProcTable[i].proc))(message); |
80 | return; | 83 | return; |
81 | } | 84 | } |
82 | } | 85 | } |
83 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); | 86 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); |
84 | } | 87 | } |
85 | } | 88 | } |
86 | 89 | ||
87 | void IRCMessageParser::nullFunc(IRCMessage *) { | 90 | void IRCMessageParser::nullFunc(IRCMessage *) { |
88 | /* Do nothing */ | 91 | /* Do nothing */ |
89 | } | 92 | } |
90 | 93 | ||
91 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { | 94 | void IRCMessageParser::parseLiteralPing(IRCMessage *message) { |
92 | m_session->m_connection->sendLine("PONG " + message->allParameters()); | 95 | m_session->m_connection->sendLine("PONG " + message->allParameters()); |
93 | } | 96 | } |
94 | 97 | ||
95 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { | 98 | void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { |
96 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 99 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
97 | } | 100 | } |
98 | 101 | ||
99 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { | 102 | void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { |
100 | QString channelName = message->param(0); | 103 | QString channelName = message->param(0); |
101 | IRCPerson mask(message->prefix()); | 104 | IRCPerson mask(message->prefix()); |
102 | IRCChannel *channel = m_session->getChannel(channelName); | 105 | IRCChannel *channel = m_session->getChannel(channelName); |
103 | if (!channel) { | 106 | if (!channel) { |
104 | /* We joined */ | 107 | /* We joined */ |
105 | if (mask.nick() == m_session->m_server->nick()) { | 108 | if (mask.nick() == m_session->m_server->nick()) { |
106 | channel = new IRCChannel(channelName); | 109 | channel = new IRCChannel(channelName); |
107 | m_session->addChannel(channel); | 110 | m_session->addChannel(channel); |
108 | } else { | 111 | } else { |
109 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); | 112 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); |
110 | } | 113 | } |
111 | } else { | 114 | } else { |
112 | /* Someone else joined */ | 115 | /* Someone else joined */ |
113 | if (mask.nick() != m_session->m_server->nick()) { | 116 | if (mask.nick() != m_session->m_server->nick()) { |
114 | if (!channel->getPerson(mask.nick())) { | 117 | if (!channel->getPerson(mask.nick())) { |
115 | IRCChannelPerson *chanperson = new IRCChannelPerson(); | 118 | IRCChannelPerson *chanperson = new IRCChannelPerson(); |
116 | IRCPerson *person = m_session->getPerson(mask.nick()); | 119 | IRCPerson *person = m_session->getPerson(mask.nick()); |
117 | if (!person) { | 120 | if (!person) { |
118 | person = new IRCPerson(message->prefix()); | 121 | person = new IRCPerson(message->prefix()); |
119 | m_session->addPerson(person); | 122 | m_session->addPerson(person); |
120 | } | 123 | } |
121 | chanperson->flags = 0; | 124 | chanperson->flags = 0; |
122 | chanperson->person = person; | 125 | chanperson->person = person; |
123 | channel->addPerson(chanperson); | 126 | channel->addPerson(chanperson); |
124 | IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); | 127 | IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); |
125 | output.addParam(channel); | 128 | output.addParam(channel); |
126 | output.addParam(chanperson); | 129 | output.addParam(chanperson); |
127 | emit outputReady(output); | 130 | emit outputReady(output); |
128 | } else { | 131 | } else { |
129 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); | 132 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); |
130 | } | 133 | } |
131 | } else { | 134 | } else { |
132 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); | 135 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); |
133 | } | 136 | } |
134 | } | 137 | } |
135 | } | 138 | } |
136 | 139 | ||
137 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { | 140 | void IRCMessageParser::parseLiteralPart(IRCMessage *message) { |
138 | QString channelName = message->param(0); | 141 | QString channelName = message->param(0); |
139 | IRCChannel *channel = m_session->getChannel(channelName); | 142 | IRCChannel *channel = m_session->getChannel(channelName); |
140 | IRCPerson mask(message->prefix()); | 143 | IRCPerson mask(message->prefix()); |
141 | if (channel) { | 144 | if (channel) { |
142 | if (mask.nick() == m_session->m_server->nick()) { | 145 | if (mask.nick() == m_session->m_server->nick()) { |
143 | m_session->removeChannel(channel); | 146 | m_session->removeChannel(channel); |
144 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); | 147 | IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); |
145 | output.addParam(channel); | 148 | output.addParam(channel); |
146 | emit outputReady(output); | 149 | emit outputReady(output); |
147 | delete channel; | 150 | delete channel; |
148 | } else { | 151 | } else { |
149 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 152 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
150 | if (person) { | 153 | if (person) { |
151 | channel->removePerson(person); | 154 | channel->removePerson(person); |
152 | IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); | 155 | IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); |
153 | output.addParam(channel); | 156 | output.addParam(channel); |
154 | output.addParam(person); | 157 | output.addParam(person); |
155 | emit outputReady(output); | 158 | emit outputReady(output); |
156 | delete person; | 159 | delete person; |
157 | } else { | 160 | } else { |
158 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); | 161 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); |
159 | } | 162 | } |
160 | } | 163 | } |
161 | } else { | 164 | } else { |
162 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); | 165 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); |
163 | } | 166 | } |
164 | } | 167 | } |
165 | 168 | ||
166 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { | 169 | void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { |
167 | if (m_session->m_server->nick() == message->param(0)) { | 170 | if (m_session->m_server->nick() == message->param(0)) { |
168 | /* IRC Query message detected, verify sender and display it */ | 171 | /* IRC Query message detected, verify sender and display it */ |
169 | IRCPerson mask(message->prefix()); | 172 | IRCPerson mask(message->prefix()); |
170 | IRCPerson *person = m_session->getPerson(mask.nick()); | 173 | IRCPerson *person = m_session->getPerson(mask.nick()); |
171 | if (!person) { | 174 | if (!person) { |
172 | /* Person not yet known, create and add to the current session */ | 175 | /* Person not yet known, create and add to the current session */ |
173 | person = new IRCPerson(message->prefix()); | 176 | person = new IRCPerson(message->prefix()); |
174 | m_session->addPerson(person); | 177 | m_session->addPerson(person); |
175 | } | 178 | } |
176 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); | 179 | IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); |
177 | output.addParam(person); | 180 | output.addParam(person); |
178 | emit outputReady(output); | 181 | emit outputReady(output); |
179 | } else if (message->param(0).at(0) == '#') { | 182 | } else if (message->param(0).at(0) == '#') { |
180 | /* IRC Channel message detected, verify sender, channel and display it */ | 183 | /* IRC Channel message detected, verify sender, channel and display it */ |
181 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 184 | IRCChannel *channel = m_session->getChannel(message->param(0)); |
182 | if (channel) { | 185 | if (channel) { |
183 | IRCPerson mask(message->prefix()); | 186 | IRCPerson mask(message->prefix()); |
184 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 187 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
185 | if (person) { | 188 | if (person) { |
186 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); | 189 | IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); |
187 | output.addParam(channel); | 190 | output.addParam(channel); |
188 | output.addParam(person); | 191 | output.addParam(person); |
189 | emit outputReady(output); | 192 | emit outputReady(output); |
190 | } else { | 193 | } else { |
191 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); | 194 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); |
192 | } | 195 | } |
193 | } else { | 196 | } else { |
194 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel"))); | 197 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0))); |
195 | } | 198 | } |
196 | } else { | 199 | } else { |
197 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); | 200 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); |
198 | } | 201 | } |
199 | } | 202 | } |
200 | 203 | ||
201 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { | 204 | void IRCMessageParser::parseLiteralNick(IRCMessage *message) { |
202 | IRCPerson mask(message->prefix()); | 205 | IRCPerson mask(message->prefix()); |
203 | 206 | ||
204 | if (mask.nick() == m_session->m_server->nick()) { | 207 | if (mask.nick() == m_session->m_server->nick()) { |
205 | /* We are changing our nickname */ | 208 | /* We are changing our nickname */ |
206 | m_session->m_server->setNick(message->param(0)); | 209 | m_session->m_server->setNick(message->param(0)); |
207 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); | 210 | IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); |
208 | output.addParam(0); | 211 | output.addParam(0); |
209 | emit outputReady(output); | 212 | emit outputReady(output); |
210 | } else { | 213 | } else { |
211 | /* Someone else is */ | 214 | /* Someone else is */ |
212 | IRCPerson *person = m_session->getPerson(mask.nick()); | 215 | IRCPerson *person = m_session->getPerson(mask.nick()); |
213 | if (person) { | 216 | if (person) { |
214 | IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); | 217 | IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); |
215 | output.addParam(person); | 218 | output.addParam(person); |
216 | emit outputReady(output); | 219 | emit outputReady(output); |
217 | } else { | 220 | } else { |
218 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); | 221 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); |
219 | } | 222 | } |
220 | } | 223 | } |
221 | } | 224 | } |
222 | 225 | ||
223 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { | 226 | void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { |
224 | IRCPerson mask(message->prefix()); | 227 | IRCPerson mask(message->prefix()); |
225 | IRCPerson *person = m_session->getPerson(mask.nick()); | 228 | IRCPerson *person = m_session->getPerson(mask.nick()); |
226 | if (person) { | 229 | if (person) { |
227 | QList<IRCChannel> channels; | 230 | QList<IRCChannel> channels; |
228 | m_session->getChannelsByPerson(person, channels); | 231 | m_session->getChannelsByPerson(person, channels); |
229 | QListIterator<IRCChannel> it(channels); | 232 | QListIterator<IRCChannel> it(channels); |
230 | for (;it.current(); ++it) { | 233 | for (;it.current(); ++it) { |
231 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); | 234 | IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); |
232 | it.current()->removePerson(chanperson); | 235 | it.current()->removePerson(chanperson); |
233 | delete chanperson; | 236 | delete chanperson; |
234 | } | 237 | } |
235 | m_session->removePerson(person); | 238 | m_session->removePerson(person); |
236 | IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); | 239 | IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); |
237 | output.addParam(person); | 240 | output.addParam(person); |
238 | emit outputReady(output); | 241 | emit outputReady(output); |
239 | delete person; | 242 | delete person; |
240 | } else { | 243 | } else { |
241 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); | 244 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); |
242 | } | 245 | } |
243 | } | 246 | } |
244 | 247 | ||
248 | void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { | ||
249 | IRCPerson mask(message->prefix()); | ||
250 | IRCChannel *channel = m_session->getChannel(message->param(0)); | ||
251 | if (channel) { | ||
252 | IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); | ||
253 | output.addParam(channel); | ||
254 | emit outputReady(output); | ||
255 | } else { | ||
256 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); | ||
257 | } | ||
258 | } | ||
259 | |||
245 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { | 260 | void IRCMessageParser::parseLiteralError(IRCMessage *message) { |
246 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); | 261 | emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); |
247 | } | 262 | } |
248 | 263 | ||
249 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { | 264 | void IRCMessageParser::parseCTCPPing(IRCMessage *message) { |
250 | IRCPerson mask(message->prefix()); | 265 | IRCPerson mask(message->prefix()); |
251 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); | 266 | m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); |
252 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); | 267 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); |
253 | } | 268 | } |
254 | 269 | ||
255 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { | 270 | void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { |
256 | IRCPerson mask(message->prefix()); | 271 | IRCPerson mask(message->prefix()); |
257 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); | 272 | m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); |
258 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); | 273 | emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); |
259 | } | 274 | } |
260 | 275 | ||
261 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { | 276 | void IRCMessageParser::parseCTCPAction(IRCMessage *message) { |
262 | IRCPerson mask(message->prefix()); | 277 | IRCPerson mask(message->prefix()); |
263 | QString dest = message->ctcpDestination(); | 278 | QString dest = message->ctcpDestination(); |
264 | if (dest.startsWith("#")) { | 279 | if (dest.startsWith("#")) { |
265 | IRCChannel *channel = m_session->getChannel(dest); | 280 | IRCChannel *channel = m_session->getChannel(dest); |
266 | if (channel) { | 281 | if (channel) { |
267 | IRCChannelPerson *person = channel->getPerson(mask.nick()); | 282 | IRCChannelPerson *person = channel->getPerson(mask.nick()); |
268 | if (person) { | 283 | if (person) { |
269 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); | 284 | IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); |
270 | output.addParam(channel); | 285 | output.addParam(channel); |
271 | output.addParam(person); | 286 | output.addParam(person); |
272 | emit outputReady(output); | 287 | emit outputReady(output); |
273 | } else { | 288 | } else { |
274 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); | 289 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); |
275 | } | 290 | } |
276 | } else { | 291 | } else { |
277 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); | 292 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); |
278 | } | 293 | } |
279 | } else { | 294 | } else { |
280 | if (message->ctcpDestination() == m_session->m_server->nick()) { | 295 | if (message->ctcpDestination() == m_session->m_server->nick()) { |
281 | IRCPerson *person = m_session->getPerson(mask.nick()); | 296 | IRCPerson *person = m_session->getPerson(mask.nick()); |
282 | if (!person) { | 297 | if (!person) { |
283 | /* Person not yet known, create and add to the current session */ | 298 | /* Person not yet known, create and add to the current session */ |
284 | person = new IRCPerson(message->prefix()); | 299 | person = new IRCPerson(message->prefix()); |
285 | m_session->addPerson(person); | 300 | m_session->addPerson(person); |
286 | } | 301 | } |
287 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); | 302 | IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); |
288 | output.addParam(person); | 303 | output.addParam(person); |
289 | emit outputReady(output); | 304 | emit outputReady(output); |
290 | } else { | 305 | } else { |
291 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); | 306 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); |
292 | } | 307 | } |
293 | } | 308 | } |
294 | } | 309 | } |
295 | 310 | ||
296 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { | 311 | void IRCMessageParser::parseLiteralMode(IRCMessage *message) { |
297 | IRCPerson mask(message->prefix()); | 312 | IRCPerson mask(message->prefix()); |
298 | 313 | ||
299 | if (message->param(0).startsWith("#")) { | 314 | if (message->param(0).startsWith("#")) { |
300 | IRCChannel *channel = m_session->getChannel(message->param(0)); | 315 | IRCChannel *channel = m_session->getChannel(message->param(0)); |
301 | if (channel) { | 316 | if (channel) { |
302 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); | 317 | QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); |
303 | QTextIStream stream(¶meters); | 318 | QTextIStream stream(¶meters); |
304 | bool set = FALSE; | 319 | bool set = FALSE; |
305 | while (!stream.atEnd()) { | 320 | while (!stream.atEnd()) { |
306 | stream >> temp; | 321 | stream >> temp; |
307 | if (temp.startsWith("+")) { | 322 | if (temp.startsWith("+")) { |
308 | set = TRUE; | 323 | set = TRUE; |
309 | temp = temp.right(1); | 324 | temp = temp.right(1); |
310 | } else if (temp.startsWith("-")) { | 325 | } else if (temp.startsWith("-")) { |
311 | set = FALSE; | 326 | set = FALSE; |
312 | temp = temp.right(1); | 327 | temp = temp.right(1); |
313 | } else { | 328 | } else { |
314 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); | 329 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); |
315 | return; | 330 | return; |
316 | } | 331 | } |
317 | if (temp == "o") { | 332 | if (temp == "o") { |
318 | stream >> temp; | 333 | stream >> temp; |
319 | IRCChannelPerson *person = channel->getPerson(temp); | 334 | IRCChannelPerson *person = channel->getPerson(temp); |
320 | if (person) { | 335 | if (person) { |
321 | if (set) { | 336 | if (set) { |
322 | person->flags |= PERSON_FLAG_OP; | 337 | person->flags |= PERSON_FLAG_OP; |
323 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); | 338 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); |
324 | output.addParam(channel); | 339 | output.addParam(channel); |
325 | output.addParam(person); | 340 | output.addParam(person); |
326 | emit outputReady(output); | 341 | emit outputReady(output); |
327 | } else { | 342 | } else { |
328 | person->flags &= 0xFFFF - PERSON_FLAG_OP; | 343 | person->flags &= 0xFFFF - PERSON_FLAG_OP; |
329 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); | 344 | IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); |
330 | output.addParam(channel); | 345 | output.addParam(channel); |
331 | output.addParam(person); | 346 | output.addParam(person); |
332 | emit outputReady(output); | 347 | emit outputReady(output); |
333 | } | 348 | } |
334 | } else { | 349 | } else { |
335 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); | 350 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); |
336 | } | 351 | } |
337 | } else if (temp == "v") { | 352 | } else if (temp == "v") { |
338 | stream >> temp; | 353 | stream >> temp; |
339 | IRCChannelPerson *person = channel->getPerson(temp); | 354 | IRCChannelPerson *person = channel->getPerson(temp); |
340 | if (person) { | 355 | if (person) { |
@@ -391,96 +406,112 @@ void IRCMessageParser::parseLiteralKick(IRCMessage *message) { | |||
391 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); | 406 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); |
392 | } | 407 | } |
393 | } | 408 | } |
394 | 409 | ||
395 | void IRCMessageParser::parseNumerical001(IRCMessage *message) { | 410 | void IRCMessageParser::parseNumerical001(IRCMessage *message) { |
396 | /* Welcome to IRC message, display */ | 411 | /* Welcome to IRC message, display */ |
397 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 412 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
398 | } | 413 | } |
399 | 414 | ||
400 | void IRCMessageParser::parseNumerical002(IRCMessage *message) { | 415 | void IRCMessageParser::parseNumerical002(IRCMessage *message) { |
401 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 416 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
402 | } | 417 | } |
403 | 418 | ||
404 | void IRCMessageParser::parseNumerical003(IRCMessage *message) { | 419 | void IRCMessageParser::parseNumerical003(IRCMessage *message) { |
405 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 420 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
406 | } | 421 | } |
407 | 422 | ||
408 | void IRCMessageParser::parseNumerical004(IRCMessage *message) { | 423 | void IRCMessageParser::parseNumerical004(IRCMessage *message) { |
409 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 424 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
410 | } | 425 | } |
411 | 426 | ||
412 | void IRCMessageParser::parseNumerical005(IRCMessage *message) { | 427 | void IRCMessageParser::parseNumerical005(IRCMessage *message) { |
413 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); | 428 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); |
414 | } | 429 | } |
415 | 430 | ||
416 | void IRCMessageParser::parseNumericalStats(IRCMessage *message) { | 431 | void IRCMessageParser::parseNumericalStats(IRCMessage *message) { |
417 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); | 432 | emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); |
418 | } | 433 | } |
419 | 434 | ||
420 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { | 435 | void IRCMessageParser::parseNumericalNames(IRCMessage *message) { |
421 | /* Name list sent when joining a channel */ | 436 | /* Name list sent when joining a channel */ |
422 | IRCChannel *channel = m_session->getChannel(message->param(2)); | 437 | IRCChannel *channel = m_session->getChannel(message->param(2)); |
423 | if (channel != 0) { | 438 | if (channel != 0) { |
424 | QString people = message->param(3); | 439 | QString people = message->param(3); |
425 | QTextIStream stream(&people); | 440 | QTextIStream stream(&people); |
426 | QString temp; | 441 | QString temp; |
427 | 442 | ||
428 | while (!stream.atEnd()) { | 443 | while (!stream.atEnd()) { |
429 | stream >> temp; | 444 | stream >> temp; |
430 | 445 | ||
431 | char flagch = temp.at(0).latin1(); | 446 | char flagch = temp.at(0).latin1(); |
432 | int flag = 0; | 447 | int flag = 0; |
433 | QString nick; | 448 | QString nick; |
434 | /* Parse person flags */ | 449 | /* Parse person flags */ |
435 | if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { | 450 | if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { |
436 | 451 | ||
437 | nick = temp.right(temp.length()-1); | 452 | nick = temp.right(temp.length()-1); |
438 | switch (flagch) { | 453 | switch (flagch) { |
439 | case '@': flag = PERSON_FLAG_OP; break; | 454 | case '@': flag = PERSON_FLAG_OP; break; |
440 | case '+': flag = PERSON_FLAG_VOICE; break; | 455 | case '+': flag = PERSON_FLAG_VOICE; break; |
441 | case '%': flag = PERSON_FLAG_HALFOP; break; | 456 | case '%': flag = PERSON_FLAG_HALFOP; break; |
442 | default : flag = 0; break; | 457 | default : flag = 0; break; |
443 | } | 458 | } |
444 | } else { | 459 | } else { |
445 | nick = temp; | 460 | nick = temp; |
446 | } | 461 | } |
447 | 462 | ||
448 | IRCChannelPerson *chan_person = new IRCChannelPerson(); | 463 | IRCChannelPerson *chan_person = new IRCChannelPerson(); |
449 | IRCPerson *person = m_session->getPerson(nick); | 464 | IRCPerson *person = m_session->getPerson(nick); |
450 | if (person == 0) { | 465 | if (person == 0) { |
451 | person = new IRCPerson(); | 466 | person = new IRCPerson(); |
452 | person->setNick(nick); | 467 | person->setNick(nick); |
453 | m_session->addPerson(person); | 468 | m_session->addPerson(person); |
454 | } | 469 | } |
455 | chan_person->person = person; | 470 | chan_person->person = person; |
456 | chan_person->flags = flag; | 471 | chan_person->flags = flag; |
457 | channel->addPerson(chan_person); | 472 | channel->addPerson(chan_person); |
458 | } | 473 | } |
459 | } else { | 474 | } else { |
460 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 475 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
461 | } | 476 | } |
462 | } | 477 | } |
463 | 478 | ||
464 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { | 479 | void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { |
465 | /* Done syncing to channel */ | 480 | /* Done syncing to channel */ |
466 | IRCChannel *channel = m_session->getChannel(message->param(1)); | 481 | IRCChannel *channel = m_session->getChannel(message->param(1)); |
467 | if (channel) { | 482 | if (channel) { |
468 | channel->setHasPeople(TRUE); | 483 | channel->setHasPeople(TRUE); |
469 | /* Yes, we want the names before anything happens inside the GUI */ | 484 | /* Yes, we want the names before anything happens inside the GUI */ |
470 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); | 485 | IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); |
471 | output.addParam(channel); | 486 | output.addParam(channel); |
472 | emit outputReady(output); | 487 | emit outputReady(output); |
473 | } else { | 488 | } else { |
474 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); | 489 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); |
475 | } | 490 | } |
476 | } | 491 | } |
477 | 492 | ||
478 | 493 | ||
479 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { | 494 | void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { |
480 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); | 495 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); |
481 | m_session->endSession(); | 496 | m_session->endSession(); |
482 | } | 497 | } |
483 | 498 | ||
484 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { | 499 | void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { |
485 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); | 500 | emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); |
486 | } | 501 | } |
502 | |||
503 | void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { | ||
504 | IRCChannel *channel = m_session->getChannel(message->param(1)); | ||
505 | if (channel) { | ||
506 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); | ||
507 | output.addParam(channel); | ||
508 | emit outputReady(output); | ||
509 | } else { | ||
510 | IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); | ||
511 | output.addParam(0); | ||
512 | emit outputReady(output); | ||
513 | } | ||
514 | } | ||
515 | |||
516 | void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *message) { | ||
517 | } | ||
diff --git a/noncore/net/opieirc/ircmessageparser.h b/noncore/net/opieirc/ircmessageparser.h index f774047..c4dd96c 100644 --- a/noncore/net/opieirc/ircmessageparser.h +++ b/noncore/net/opieirc/ircmessageparser.h | |||
@@ -1,96 +1,99 @@ | |||
1 | /* | 1 | /* |
2 | OpieIRC - An embedded IRC client | 2 | OpieIRC - An embedded IRC client |
3 | Copyright (C) 2002 Wenzel Jakob | 3 | Copyright (C) 2002 Wenzel Jakob |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCMESSAGEPARSER_H | 21 | #ifndef __IRCMESSAGEPARSER_H |
22 | #define __IRCMESSAGEPARSER_H | 22 | #define __IRCMESSAGEPARSER_H |
23 | 23 | ||
24 | #include "ircsession.h" | 24 | #include "ircsession.h" |
25 | 25 | ||
26 | /* Macro to facilitate the parser table's creation */ | 26 | /* Macro to facilitate the parser table's creation */ |
27 | #define FUNC(__proc) &IRCMessageParser::__proc | 27 | #define FUNC(__proc) &IRCMessageParser::__proc |
28 | 28 | ||
29 | class IRCMessageParser; | 29 | class IRCMessageParser; |
30 | 30 | ||
31 | /* Typedef representing a parser function */ | 31 | /* Typedef representing a parser function */ |
32 | typedef void (IRCMessageParser::*IRCMessageParseProc)(IRCMessage *); | 32 | typedef void (IRCMessageParser::*IRCMessageParseProc)(IRCMessage *); |
33 | 33 | ||
34 | /* Struct representing a literal command handler */ | 34 | /* Struct representing a literal command handler */ |
35 | typedef struct IRCLiteralMessageParserStruct { | 35 | typedef struct IRCLiteralMessageParserStruct { |
36 | char *commandName; | 36 | char *commandName; |
37 | IRCMessageParseProc proc; | 37 | IRCMessageParseProc proc; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | /* Struct representing a ctcp command handler */ | 40 | /* Struct representing a ctcp command handler */ |
41 | typedef struct IRCCTCPMessageParserStruct { | 41 | typedef struct IRCCTCPMessageParserStruct { |
42 | char *commandName; | 42 | char *commandName; |
43 | IRCMessageParseProc proc; | 43 | IRCMessageParseProc proc; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | /* Struct representing a numerical command handler */ | 46 | /* Struct representing a numerical command handler */ |
47 | typedef struct IRCNumericalMessageParserStruct { | 47 | typedef struct IRCNumericalMessageParserStruct { |
48 | unsigned short commandNumber; | 48 | unsigned short commandNumber; |
49 | IRCMessageParseProc proc; | 49 | IRCMessageParseProc proc; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | class IRCMessageParser : public QObject { | 52 | class IRCMessageParser : public QObject { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | /* Create an IRCMessageParser object */ | 55 | /* Create an IRCMessageParser object */ |
56 | IRCMessageParser(IRCSession *session); | 56 | IRCMessageParser(IRCSession *session); |
57 | /* Parse a server message and take the appropriate actions */ | 57 | /* Parse a server message and take the appropriate actions */ |
58 | void parse(IRCMessage *message); | 58 | void parse(IRCMessage *message); |
59 | signals: | 59 | signals: |
60 | /* Used to send commands to the UI (such as displaying text etc) */ | 60 | /* Used to send commands to the UI (such as displaying text etc) */ |
61 | void outputReady(IRCOutput output); | 61 | void outputReady(IRCOutput output); |
62 | private: | 62 | private: |
63 | /* Parser functions */ | 63 | /* Parser functions */ |
64 | void nullFunc(IRCMessage *message); | 64 | void nullFunc(IRCMessage *message); |
65 | void parseLiteralPing(IRCMessage *message); | 65 | void parseLiteralPing(IRCMessage *message); |
66 | void parseLiteralNotice(IRCMessage *message); | 66 | void parseLiteralNotice(IRCMessage *message); |
67 | void parseLiteralJoin(IRCMessage *message); | 67 | void parseLiteralJoin(IRCMessage *message); |
68 | void parseLiteralPrivMsg(IRCMessage *message); | 68 | void parseLiteralPrivMsg(IRCMessage *message); |
69 | void parseLiteralNick(IRCMessage *message); | 69 | void parseLiteralNick(IRCMessage *message); |
70 | void parseLiteralPart(IRCMessage *message); | 70 | void parseLiteralPart(IRCMessage *message); |
71 | void parseLiteralQuit(IRCMessage *message); | 71 | void parseLiteralQuit(IRCMessage *message); |
72 | void parseLiteralError(IRCMessage *message); | 72 | void parseLiteralError(IRCMessage *message); |
73 | void parseLiteralMode(IRCMessage *message); | 73 | void parseLiteralMode(IRCMessage *message); |
74 | void parseLiteralKick(IRCMessage *message); | 74 | void parseLiteralKick(IRCMessage *message); |
75 | void parseLiteralTopic(IRCMessage *message); | ||
75 | void parseNumerical001(IRCMessage *message); | 76 | void parseNumerical001(IRCMessage *message); |
76 | void parseNumerical002(IRCMessage *message); | 77 | void parseNumerical002(IRCMessage *message); |
77 | void parseNumerical003(IRCMessage *message); | 78 | void parseNumerical003(IRCMessage *message); |
78 | void parseNumerical004(IRCMessage *message); | 79 | void parseNumerical004(IRCMessage *message); |
79 | void parseNumerical005(IRCMessage *message); | 80 | void parseNumerical005(IRCMessage *message); |
80 | void parseNumericalStats(IRCMessage *message); | 81 | void parseNumericalStats(IRCMessage *message); |
81 | void parseNumericalNames(IRCMessage *message); | 82 | void parseNumericalNames(IRCMessage *message); |
82 | void parseNumericalEndOfNames(IRCMessage *message); | 83 | void parseNumericalEndOfNames(IRCMessage *message); |
83 | void parseNumericalNicknameInUse(IRCMessage *message); | 84 | void parseNumericalNicknameInUse(IRCMessage *message); |
84 | void parseNumericalNoSuchNick(IRCMessage *message); | 85 | void parseNumericalNoSuchNick(IRCMessage *message); |
86 | void parseNumericalTopic(IRCMessage *message); | ||
87 | void parseNumericalTopicWhoTime(IRCMessage *message); | ||
85 | void parseCTCPPing(IRCMessage *message); | 88 | void parseCTCPPing(IRCMessage *message); |
86 | void parseCTCPVersion(IRCMessage *message); | 89 | void parseCTCPVersion(IRCMessage *message); |
87 | void parseCTCPAction(IRCMessage *message); | 90 | void parseCTCPAction(IRCMessage *message); |
88 | protected: | 91 | protected: |
89 | IRCSession *m_session; | 92 | IRCSession *m_session; |
90 | /* Parser tables */ | 93 | /* Parser tables */ |
91 | static IRCLiteralMessageParserStruct literalParserProcTable[]; | 94 | static IRCLiteralMessageParserStruct literalParserProcTable[]; |
92 | static IRCNumericalMessageParserStruct numericalParserProcTable[]; | 95 | static IRCNumericalMessageParserStruct numericalParserProcTable[]; |
93 | static IRCCTCPMessageParserStruct ctcpParserProcTable[]; | 96 | static IRCCTCPMessageParserStruct ctcpParserProcTable[]; |
94 | }; | 97 | }; |
95 | 98 | ||
96 | #endif /* __IRCMESSAGEPARSER_H */ | 99 | #endif /* __IRCMESSAGEPARSER_H */ |
diff --git a/noncore/net/opieirc/ircoutput.h b/noncore/net/opieirc/ircoutput.h index e8cc524..9c0b8bb 100644 --- a/noncore/net/opieirc/ircoutput.h +++ b/noncore/net/opieirc/ircoutput.h | |||
@@ -1,74 +1,75 @@ | |||
1 | /* | 1 | /* |
2 | OpieIRC - An embedded IRC client | 2 | OpieIRC - An embedded IRC client |
3 | Copyright (C) 2002 Wenzel Jakob | 3 | Copyright (C) 2002 Wenzel Jakob |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCOUTPUT_H | 21 | #ifndef __IRCOUTPUT_H |
22 | #define __IRCOUTPUT_H | 22 | #define __IRCOUTPUT_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qlist.h> | 25 | #include <qlist.h> |
26 | #include "ircchannel.h" | 26 | #include "ircchannel.h" |
27 | 27 | ||
28 | /* Types of possible IRC output */ | 28 | /* Types of possible IRC output */ |
29 | enum IRCOutputType { | 29 | enum IRCOutputType { |
30 | OUTPUT_ERROR = -1, /* parameters : none */ | 30 | OUTPUT_ERROR = -1, /* parameters : none */ |
31 | OUTPUT_SERVERMESSAGE = 0, /* parameters : none */ | 31 | OUTPUT_SERVERMESSAGE = 0, /* parameters : none */ |
32 | OUTPUT_CLIENTMESSAGE = 1, /* parameters : none */ | 32 | OUTPUT_CLIENTMESSAGE = 1, /* parameters : none */ |
33 | OUTPUT_CHANPRIVMSG = 2, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ | 33 | OUTPUT_CHANPRIVMSG = 2, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ |
34 | OUTPUT_QUERYPRIVMSG = 3, /* parameters : person (IRCPerson) */ | 34 | OUTPUT_QUERYPRIVMSG = 3, /* parameters : person (IRCPerson) */ |
35 | OUTPUT_NICKCHANGE = 4, /* parameters : person (IRCPerson) */ | 35 | OUTPUT_NICKCHANGE = 4, /* parameters : person (IRCPerson) */ |
36 | OUTPUT_SELFJOIN = 5, /* parameters : channel (IRCChannel) */ | 36 | OUTPUT_SELFJOIN = 5, /* parameters : channel (IRCChannel) */ |
37 | OUTPUT_OTHERJOIN = 6, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ | 37 | OUTPUT_OTHERJOIN = 6, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ |
38 | OUTPUT_SELFPART = 7, /* parameters : channel (IRCChannel) */ | 38 | OUTPUT_SELFPART = 7, /* parameters : channel (IRCChannel) */ |
39 | OUTPUT_OTHERPART = 8, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ | 39 | OUTPUT_OTHERPART = 8, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ |
40 | OUTPUT_QUIT = 9, /* parameters : person (IRCPerson) */ | 40 | OUTPUT_QUIT = 9, /* parameters : person (IRCPerson) */ |
41 | OUTPUT_CONNCLOSE = 10, /* parameters : none */ | 41 | OUTPUT_CONNCLOSE = 10, /* parameters : none */ |
42 | OUTPUT_CTCP = 11, /* parameters : none */ | 42 | OUTPUT_CTCP = 11, /* parameters : none */ |
43 | OUTPUT_SELFKICK = 12, /* parameters : channel (IRCChannel) */ | 43 | OUTPUT_SELFKICK = 12, /* parameters : channel (IRCChannel) */ |
44 | OUTPUT_OTHERKICK = 13, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */ | 44 | OUTPUT_OTHERKICK = 13, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */ |
45 | OUTPUT_CHANACTION = 14, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */ | 45 | OUTPUT_CHANACTION = 14, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */ |
46 | OUTPUT_QUERYACTION = 15, /* parameters : person (IRCPerson) */ | 46 | OUTPUT_QUERYACTION = 15, /* parameters : person (IRCPerson) */ |
47 | OUTPUT_CHANPERSONMODE = 16 /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */ | 47 | OUTPUT_CHANPERSONMODE = 16, /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */ |
48 | OUTPUT_TOPIC = 17 /* parameters : channel (IRCChannel) */ | ||
48 | }; | 49 | }; |
49 | 50 | ||
50 | /* The IRCOutput class is used as a kind of message which is sent by the | 51 | /* The IRCOutput class is used as a kind of message which is sent by the |
51 | IRC parser to inform the GUI of changes. This could for example be a | 52 | IRC parser to inform the GUI of changes. This could for example be a |
52 | channel message or a nickname change */ | 53 | channel message or a nickname change */ |
53 | 54 | ||
54 | class IRCOutput { | 55 | class IRCOutput { |
55 | public: | 56 | public: |
56 | IRCOutput(IRCOutputType type, QString message); | 57 | IRCOutput(IRCOutputType type, QString message); |
57 | /* Used to add a parameter to this IRCOutput. Parameters are dependent | 58 | /* Used to add a parameter to this IRCOutput. Parameters are dependent |
58 | on which IRCOutputType we are using (see above) */ | 59 | on which IRCOutputType we are using (see above) */ |
59 | void addParam(void *data); | 60 | void addParam(void *data); |
60 | 61 | ||
61 | IRCOutputType type(); | 62 | IRCOutputType type(); |
62 | QString message(); | 63 | QString message(); |
63 | /* Return the message with all HTML code escaped (for example < instead of '<') */ | 64 | /* Return the message with all HTML code escaped (for example < instead of '<') */ |
64 | QString htmlMessage(); | 65 | QString htmlMessage(); |
65 | 66 | ||
66 | static QString toHTML(QString message); | 67 | static QString toHTML(QString message); |
67 | void *getParam(int index); | 68 | void *getParam(int index); |
68 | protected: | 69 | protected: |
69 | IRCOutputType m_type; | 70 | IRCOutputType m_type; |
70 | QString m_message; | 71 | QString m_message; |
71 | QList<void> m_parameters; | 72 | QList<void> m_parameters; |
72 | }; | 73 | }; |
73 | 74 | ||
74 | #endif | 75 | #endif |
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 4be60ef..aea58a3 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp | |||
@@ -126,127 +126,139 @@ void IRCServerTab::remove() { | |||
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: { | ||
223 | IRCChannel *channel = (IRCChannel *) output.getParam(0); | ||
224 | if (channel) { | ||
225 | IRCChannelTab *channelTab = getTabForChannel(channel); | ||
226 | if (channelTab) { | ||
227 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | ||
228 | return; | ||
229 | } | ||
230 | } | ||
231 | appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | ||
232 | } | ||
233 | break; | ||
222 | case OUTPUT_QUIT: { | 234 | case OUTPUT_QUIT: { |
223 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); | 235 | QString nick = ((IRCPerson *)output.getParam(0))->nick(); |
224 | QListIterator<IRCChannelTab> it(m_channelTabs); | 236 | QListIterator<IRCChannelTab> it(m_channelTabs); |
225 | for (; it.current(); ++it) { | 237 | for (; it.current(); ++it) { |
226 | if (it.current()->list()->hasPerson(nick)) { | 238 | if (it.current()->list()->hasPerson(nick)) { |
227 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 239 | it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
228 | it.current()->list()->update(); | 240 | it.current()->list()->update(); |
229 | } | 241 | } |
230 | } | 242 | } |
231 | } | 243 | } |
232 | break; | 244 | break; |
233 | case OUTPUT_OTHERJOIN: | 245 | case OUTPUT_OTHERJOIN: |
234 | case OUTPUT_OTHERKICK: | 246 | case OUTPUT_OTHERKICK: |
235 | case OUTPUT_CHANPERSONMODE: | 247 | case OUTPUT_CHANPERSONMODE: |
236 | case OUTPUT_OTHERPART: { | 248 | case OUTPUT_OTHERPART: { |
237 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); | 249 | IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); |
238 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); | 250 | channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); |
239 | channelTab->list()->update(); | 251 | channelTab->list()->update(); |
240 | } | 252 | } |
241 | break; | 253 | break; |
242 | case OUTPUT_CTCP: | 254 | case OUTPUT_CTCP: |
243 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); | 255 | appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); |
244 | break; | 256 | break; |
245 | case OUTPUT_ERROR: | 257 | case OUTPUT_ERROR: |
246 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); | 258 | appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); |
247 | break; | 259 | break; |
248 | default: | 260 | default: |
249 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); | 261 | appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); |
250 | break; | 262 | break; |
251 | } | 263 | } |
252 | } | 264 | } |