-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 20 | ||||
-rw-r--r-- | noncore/net/opieirc/ircperson.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.cpp | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index e8d3b1a..6b88f34 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp | |||
@@ -10,298 +10,298 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { | |||
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: %1").arg( 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: %1").arg( 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: %1").arg( 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 ,tr("%1 joined channel %2").arg( mask.nick() ).arg( 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 %1").arg( 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, tr("%1 left channel %2").arg( mask.nick() ).arg( 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) == '#' || 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 %1").arg(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 %1").arg( 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, tr("%1 is now known as %2").arg( mask.nick() ).arg( 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, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( 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); |
diff --git a/noncore/net/opieirc/ircperson.cpp b/noncore/net/opieirc/ircperson.cpp index 2f5b435..1dd2679 100644 --- a/noncore/net/opieirc/ircperson.cpp +++ b/noncore/net/opieirc/ircperson.cpp | |||
@@ -1,55 +1,55 @@ | |||
1 | #include "ircperson.h" | 1 | #include "ircperson.h" |
2 | 2 | ||
3 | IRCPerson::IRCPerson() { | 3 | IRCPerson::IRCPerson() { |
4 | m_nick = ""; | 4 | m_nick = ""; |
5 | m_user = ""; | 5 | m_user = ""; |
6 | m_host = ""; | 6 | m_host = ""; |
7 | } | 7 | } |
8 | 8 | ||
9 | IRCPerson::IRCPerson(const IRCPerson &person) { | 9 | IRCPerson::IRCPerson(const IRCPerson &person) { |
10 | m_nick = person.m_nick; | 10 | m_nick = person.m_nick; |
11 | m_user = person.m_user; | 11 | m_user = person.m_user; |
12 | m_host = person.m_host; | 12 | m_host = person.m_host; |
13 | } | 13 | } |
14 | 14 | ||
15 | IRCPerson::IRCPerson(QString mask) { | 15 | IRCPerson::IRCPerson(QString mask) { |
16 | IRCPerson(); | 16 | IRCPerson(); |
17 | fromMask(mask); | 17 | fromMask(mask); |
18 | } | 18 | } |
19 | 19 | ||
20 | void IRCPerson::fromMask(QString mask) { | 20 | void IRCPerson::fromMask(QString mask) { |
21 | int sep1 = mask.find("!"); | 21 | int sep1 = mask.find("!"); |
22 | int sep2 = mask.find("@"); | 22 | int sep2 = mask.find("@"); |
23 | 23 | ||
24 | m_nick = mask.left(sep1); | 24 | m_nick = mask.left(sep1); |
25 | m_user = mask.mid(sep1+1, sep2-sep1-1); | 25 | m_user = mask.mid(sep1+1, sep2-sep1-1); |
26 | m_host = mask.right(mask.length()-sep2-1); | 26 | m_host = mask.right(mask.length()-sep2-1); |
27 | } | 27 | } |
28 | 28 | ||
29 | QString IRCPerson::toMask() { | 29 | QString IRCPerson::toMask() { |
30 | return m_nick + "!" + m_user + "@" + m_host; | 30 | return m_nick + "!" + m_user + "@" + m_host; |
31 | } | 31 | } |
32 | 32 | ||
33 | void IRCPerson::setNick(QString nick) { | 33 | void IRCPerson::setNick(QString nick) { |
34 | m_nick = nick; | 34 | m_nick = nick; |
35 | } | 35 | } |
36 | 36 | ||
37 | void IRCPerson::setUser(QString user) { | 37 | void IRCPerson::setUser(QString user) { |
38 | m_user = user; | 38 | m_user = user; |
39 | } | 39 | } |
40 | 40 | ||
41 | void IRCPerson::setHost(QString host) { | 41 | void IRCPerson::setHost(QString host) { |
42 | m_host = host; | 42 | m_host = host; |
43 | } | 43 | } |
44 | 44 | // -- GETTER FUNCS -- | |
45 | QString IRCPerson::nick() { | 45 | QString IRCPerson::nick() { |
46 | return m_nick; | 46 | return m_nick; |
47 | } | 47 | } |
48 | 48 | ||
49 | QString IRCPerson::user() { | 49 | QString IRCPerson::user() { |
50 | return m_user; | 50 | return m_user; |
51 | } | 51 | } |
52 | 52 | ||
53 | QString IRCPerson::host() { | 53 | QString IRCPerson::host() { |
54 | return m_host; | 54 | return m_host; |
55 | } | 55 | } |
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp index b110a5b..70d5445 100644 --- a/noncore/net/opieirc/ircsettings.cpp +++ b/noncore/net/opieirc/ircsettings.cpp | |||
@@ -1,76 +1,76 @@ | |||
1 | #include <opie/ocolorbutton.h> | 1 | #include <opie/ocolorbutton.h> |
2 | #include <opie/otabwidget.h> | 2 | #include <opie/otabwidget.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qvalidator.h> | 4 | #include <qvalidator.h> |
5 | #include <qscrollview.h> | 5 | #include <qscrollview.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include "ircsettings.h" | 7 | #include "ircsettings.h" |
8 | #include "irctab.h" | 8 | #include "irctab.h" |
9 | #include "ircmisc.h" | 9 | #include "ircmisc.h" |
10 | 10 | ||
11 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { | 11 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { |
12 | setCaption("Settings"); | 12 | setCaption(tr("Settings") ); |
13 | m_config = new Config("OpieIRC"); | 13 | m_config = new Config("OpieIRC"); |
14 | m_config->setGroup("OpieIRC"); | 14 | m_config->setGroup("OpieIRC"); |
15 | QHBoxLayout *l = new QHBoxLayout(this, 2, 2); | 15 | QHBoxLayout *l = new QHBoxLayout(this, 2, 2); |
16 | OTabWidget *tw = new OTabWidget(this); | 16 | OTabWidget *tw = new OTabWidget(this); |
17 | l->addWidget(tw); | 17 | l->addWidget(tw); |
18 | /* General Configuration */ | 18 | /* General Configuration */ |
19 | QWidget *genwidget = new QWidget(tw); | 19 | QWidget *genwidget = new QWidget(tw); |
20 | QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); | 20 | QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); |
21 | QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); | 21 | QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); |
22 | layout->addWidget(label, 0, 0); | 22 | layout->addWidget(label, 0, 0); |
23 | m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); | 23 | m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); |
24 | QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this")); | 24 | QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this")); |
25 | QIntValidator *validator = new QIntValidator(this); | 25 | QIntValidator *validator = new QIntValidator(this); |
26 | validator->setTop(10000); | 26 | validator->setTop(10000); |
27 | validator->setBottom(0); | 27 | validator->setBottom(0); |
28 | m_lines->setValidator(validator); | 28 | m_lines->setValidator(validator); |
29 | layout->addWidget(m_lines, 0, 1); | 29 | layout->addWidget(m_lines, 0, 1); |
30 | tw->addTab(genwidget, "opieirc/settings", tr("General")); | 30 | tw->addTab(genwidget, "opieirc/settings", tr("General")); |
31 | 31 | ||
32 | /* Color configuration */ | 32 | /* Color configuration */ |
33 | QScrollView *view = new QScrollView(this); | 33 | QScrollView *view = new QScrollView(this); |
34 | view->setResizePolicy(QScrollView::AutoOneFit); | 34 | view->setResizePolicy(QScrollView::AutoOneFit); |
35 | view->setFrameStyle( QFrame::NoFrame ); | 35 | view->setFrameStyle( QFrame::NoFrame ); |
36 | QWidget *widget = new QWidget(view->viewport()); | 36 | QWidget *widget = new QWidget(view->viewport()); |
37 | view->addChild(widget); | 37 | view->addChild(widget); |
38 | layout = new QGridLayout(widget, 7, 2, 5, 0); | 38 | layout = new QGridLayout(widget, 7, 2, 5, 0); |
39 | label = new QLabel(tr("Background color :"), widget); | 39 | label = new QLabel(tr("Background color :"), widget); |
40 | layout->addWidget(label, 0, 0); | 40 | layout->addWidget(label, 0, 0); |
41 | m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF")); | 41 | m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF")); |
42 | QWhatsThis::add(m_background, tr("Background color to be used in chats")); | 42 | QWhatsThis::add(m_background, tr("Background color to be used in chats")); |
43 | layout->addWidget(m_background, 0, 1); | 43 | layout->addWidget(m_background, 0, 1); |
44 | label = new QLabel(tr("Normal text color :"), widget); | 44 | label = new QLabel(tr("Normal text color :"), widget); |
45 | layout->addWidget(label, 1, 0); | 45 | layout->addWidget(label, 1, 0); |
46 | m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000")); | 46 | m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000")); |
47 | QWhatsThis::add(m_text, tr("Text color to be used in chats")); | 47 | QWhatsThis::add(m_text, tr("Text color to be used in chats")); |
48 | layout->addWidget(m_text, 1, 1); | 48 | layout->addWidget(m_text, 1, 1); |
49 | label = new QLabel(tr("Error color :"), widget); | 49 | label = new QLabel(tr("Error color :"), widget); |
50 | layout->addWidget(label, 2, 0); | 50 | layout->addWidget(label, 2, 0); |
51 | m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000")); | 51 | m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000")); |
52 | QWhatsThis::add(m_error, tr("Text color to be used to display errors")); | 52 | QWhatsThis::add(m_error, tr("Text color to be used to display errors")); |
53 | layout->addWidget(m_error, 2, 1); | 53 | layout->addWidget(m_error, 2, 1); |
54 | label = new QLabel(tr("Text written by yourself :"), widget); | 54 | label = new QLabel(tr("Text written by yourself :"), widget); |
55 | layout->addWidget(label, 3, 0); | 55 | layout->addWidget(label, 3, 0); |
56 | m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); | 56 | m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); |
57 | QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); | 57 | QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); |
58 | layout->addWidget(m_self, 3, 1); | 58 | layout->addWidget(m_self, 3, 1); |
59 | label = new QLabel(tr("Text written by others :"), widget); | 59 | label = new QLabel(tr("Text written by others :"), widget); |
60 | layout->addWidget(label, 4, 0); | 60 | layout->addWidget(label, 4, 0); |
61 | m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB")); | 61 | m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB")); |
62 | QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); | 62 | QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); |
63 | layout->addWidget(m_other, 4, 1); | 63 | layout->addWidget(m_other, 4, 1); |
64 | label = new QLabel(tr("Text written by the server :"), widget); | 64 | label = new QLabel(tr("Text written by the server :"), widget); |
65 | layout->addWidget(label, 5, 0); | 65 | layout->addWidget(label, 5, 0); |
66 | m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF")); | 66 | m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF")); |
67 | QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); | 67 | QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); |
68 | layout->addWidget(m_server, 5, 1); | 68 | layout->addWidget(m_server, 5, 1); |
69 | label = new QLabel(tr("Notifications :"), widget); | 69 | label = new QLabel(tr("Notifications :"), widget); |
70 | layout->addWidget(label, 6, 0); | 70 | layout->addWidget(label, 6, 0); |
71 | m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); | 71 | m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); |
72 | QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); | 72 | QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); |
73 | layout->addWidget(m_notification, 6, 1); | 73 | layout->addWidget(m_notification, 6, 1); |
74 | tw->addTab(view, "opieirc/colors", tr("Colors")); | 74 | tw->addTab(view, "opieirc/colors", tr("Colors")); |
75 | tw->setCurrentTab( genwidget ); | 75 | tw->setCurrentTab( genwidget ); |
76 | showMaximized(); | 76 | showMaximized(); |