summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircmessageparser.cpp
authorzecke <zecke>2004-09-06 22:47:48 (UTC)
committer zecke <zecke>2004-09-06 22:47:48 (UTC)
commit8f18e8b46dfaaa7e03b9ed1f3faed12da5b30cd5 (patch) (unidiff)
tree39158cd8abe423cf2df95b5038cdc7848de2e3dc /noncore/net/opieirc/ircmessageparser.cpp
parent8bf99aaa1b31e770b21b7bf50407a650a8f5d646 (diff)
downloadopie-8f18e8b46dfaaa7e03b9ed1f3faed12da5b30cd5.zip
opie-8f18e8b46dfaaa7e03b9ed1f3faed12da5b30cd5.tar.gz
opie-8f18e8b46dfaaa7e03b9ed1f3faed12da5b30cd5.tar.bz2
-Some keyboard handling
-ping notification merge of zautrixs work
Diffstat (limited to 'noncore/net/opieirc/ircmessageparser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 400ff41..90280d7 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -1,12 +1,12 @@
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 */
6IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { 6IRCLiteralMessageParserStruct 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) },
@@ -17,21 +17,21 @@ IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
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 */
23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 23IRCCTCPMessageParserStruct 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 */
31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { 31IRCNumericalMessageParserStruct 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
@@ -168,13 +168,13 @@ void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
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
173void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { 173void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
174 if (m_session->m_server->nick() == message->param(0)) { 174 if (m_session->m_server->nick().lower() == message->param(0).lower() ) {
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());
@@ -203,13 +203,13 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
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
208void IRCMessageParser::parseLiteralNick(IRCMessage *message) { 208void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
209 209
210 IRCPerson mask(message->prefix()); 210 IRCPerson mask(message->prefix());
211 /* this way of handling nick changes really sucks */ 211 /* this way of handling nick changes really sucks */
212 if (mask.nick() == m_session->m_server->nick()) { 212 if (mask.nick() == m_session->m_server->nick()) {
213 /* We are changing our nickname */ 213 /* We are changing our nickname */
214 m_session->m_server->setNick(message->param(0)); 214 m_session->m_server->setNick(message->param(0));
215 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); 215 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0)));
@@ -217,13 +217,13 @@ void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
217 emit outputReady(output); 217 emit outputReady(output);
218 } else { 218 } else {
219 /* Someone else is */ 219 /* Someone else is */
220 IRCPerson *person = m_session->getPerson(mask.nick()); 220 IRCPerson *person = m_session->getPerson(mask.nick());
221 if (person) { 221 if (person) {
222 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 222 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
223 223
224 /* new code starts here -- this removes the person from all channels */ 224 /* new code starts here -- this removes the person from all channels */
225 QList<IRCChannel> channels; 225 QList<IRCChannel> channels;
226 m_session->getChannelsByPerson(person, channels); 226 m_session->getChannelsByPerson(person, channels);
227 QListIterator<IRCChannel> it(channels); 227 QListIterator<IRCChannel> it(channels);
228 for (;it.current(); ++it) { 228 for (;it.current(); ++it) {
229 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 229 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
@@ -231,13 +231,13 @@ void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
231 chanperson->person->setNick(message->param(0)); 231 chanperson->person->setNick(message->param(0));
232 it.current()->addPerson(chanperson); 232 it.current()->addPerson(chanperson);
233 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 233 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
234 output.addParam(person); 234 output.addParam(person);
235 emit outputReady(output); 235 emit outputReady(output);
236 } 236 }
237 /* new code ends here */ 237 /* new code ends here */
238 } else { 238 } else {
239 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); 239 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
240 } 240 }
241 } 241 }
242} 242}
243 243
@@ -245,13 +245,13 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
245 IRCPerson mask(message->prefix()); 245 IRCPerson mask(message->prefix());
246 IRCPerson *person = m_session->getPerson(mask.nick()); 246 IRCPerson *person = m_session->getPerson(mask.nick());
247 if (person) { 247 if (person) {
248 QList<IRCChannel> channels; 248 QList<IRCChannel> channels;
249 m_session->getChannelsByPerson(person, channels); 249 m_session->getChannelsByPerson(person, channels);
250 QListIterator<IRCChannel> it(channels); 250 QListIterator<IRCChannel> it(channels);
251 for (;it.current(); ++it) { 251 for (;it.current(); ++it) {
252 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 252 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
253 it.current()->removePerson(chanperson); 253 it.current()->removePerson(chanperson);
254 delete chanperson; 254 delete chanperson;
255 } 255 }
256 m_session->removePerson(person); 256 m_session->removePerson(person);
257 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); 257 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) ));
@@ -322,13 +322,13 @@ void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
322 emit outputReady(output); 322 emit outputReady(output);
323 } else { 323 } else {
324 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); 324 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
325 } 325 }
326 } 326 }
327} 327}
328 328
329void IRCMessageParser::parseLiteralMode(IRCMessage *message) { 329void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
330 IRCPerson mask(message->prefix()); 330 IRCPerson mask(message->prefix());
331 331
332 if (message->param(0).startsWith("#")) { 332 if (message->param(0).startsWith("#")) {
333 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 333 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
334 if (channel) { 334 if (channel) {
@@ -458,30 +458,30 @@ void IRCMessageParser::parseNumericalNames(IRCMessage *message) {
458 QString people = message->param(3); 458 QString people = message->param(3);
459 QTextIStream stream(&people); 459 QTextIStream stream(&people);
460 QString temp; 460 QString temp;
461 461
462 while (!stream.atEnd()) { 462 while (!stream.atEnd()) {
463 stream >> temp; 463 stream >> temp;
464 464
465 char flagch = temp.at(0).latin1(); 465 char flagch = temp.at(0).latin1();
466 int flag = 0; 466 int flag = 0;
467 QString nick; 467 QString nick;
468 /* Parse person flags */ 468 /* Parse person flags */
469 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { 469 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') {
470 470
471 nick = temp.right(temp.length()-1); 471 nick = temp.right(temp.length()-1);
472 switch (flagch) { 472 switch (flagch) {
473 case '@': flag = PERSON_FLAG_OP; break; 473 case '@': flag = PERSON_FLAG_OP; break;
474 case '+': flag = PERSON_FLAG_VOICE; break; 474 case '+': flag = PERSON_FLAG_VOICE; break;
475 case '%': flag = PERSON_FLAG_HALFOP; break; 475 case '%': flag = PERSON_FLAG_HALFOP; break;
476 default : flag = 0; break; 476 default : flag = 0; break;
477 } 477 }
478 } else { 478 } else {
479 nick = temp; 479 nick = temp;
480 } 480 }
481 481
482 IRCChannelPerson *chan_person = new IRCChannelPerson(); 482 IRCChannelPerson *chan_person = new IRCChannelPerson();
483 IRCPerson *person = m_session->getPerson(nick); 483 IRCPerson *person = m_session->getPerson(nick);
484 if (person == 0) { 484 if (person == 0) {
485 person = new IRCPerson(); 485 person = new IRCPerson();
486 person->setNick(nick); 486 person->setNick(nick);
487 m_session->addPerson(person); 487 m_session->addPerson(person);