summaryrefslogtreecommitdiff
authorskyhusker <skyhusker>2005-01-16 02:14:38 (UTC)
committer skyhusker <skyhusker>2005-01-16 02:14:38 (UTC)
commit986280fcb93a2c9550aa83a3109deb885ce50e8f (patch) (unidiff)
treed507028d909e7e7f1703aa80b3b2d7201573bd93
parente420e24bb1506e313cc38174111d424ba7274e33 (diff)
downloadopie-986280fcb93a2c9550aa83a3109deb885ce50e8f.zip
opie-986280fcb93a2c9550aa83a3109deb885ce50e8f.tar.gz
opie-986280fcb93a2c9550aa83a3109deb885ce50e8f.tar.bz2
Fixed a bug in nickname handling with networks using nickname:password for auth
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index fde156c..cfad2c1 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -1,617 +1,625 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include <qdatetime.h> 2#include <qdatetime.h>
3 3
4#include "ircmessageparser.h" 4#include "ircmessageparser.h"
5#include "ircversion.h" 5#include "ircversion.h"
6 6
7/* Lookup table for literal commands */ 7/* Lookup table for literal commands */
8IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { 8IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
9 { "PING", FUNC(parseLiteralPing) }, 9 { "PING", FUNC(parseLiteralPing) },
10 { "NOTICE", FUNC(parseLiteralNotice) }, 10 { "NOTICE", FUNC(parseLiteralNotice) },
11 { "JOIN", FUNC(parseLiteralJoin) }, 11 { "JOIN", FUNC(parseLiteralJoin) },
12 { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, 12 { "PRIVMSG", FUNC(parseLiteralPrivMsg) },
13 { "NICK", FUNC(parseLiteralNick) }, 13 { "NICK", FUNC(parseLiteralNick) },
14 { "PART", FUNC(parseLiteralPart) }, 14 { "PART", FUNC(parseLiteralPart) },
15 { "QUIT", FUNC(parseLiteralQuit) }, 15 { "QUIT", FUNC(parseLiteralQuit) },
16 { "ERROR", FUNC(parseLiteralError) }, 16 { "ERROR", FUNC(parseLiteralError) },
17 { "ERROR:", FUNC(parseLiteralError) }, 17 { "ERROR:", FUNC(parseLiteralError) },
18 { "MODE", FUNC(parseLiteralMode) }, 18 { "MODE", FUNC(parseLiteralMode) },
19 { "KICK", FUNC(parseLiteralKick) }, 19 { "KICK", FUNC(parseLiteralKick) },
20 { "TOPIC", FUNC(parseLiteralTopic) }, 20 { "TOPIC", FUNC(parseLiteralTopic) },
21 { 0 , 0 } 21 { 0 , 0 }
22}; 22};
23 23
24/* Lookup table for literal commands */ 24/* Lookup table for literal commands */
25IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 25IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
26 { "PING", FUNC(parseCTCPPing) }, 26 { "PING", FUNC(parseCTCPPing) },
27 { "VERSION", FUNC(parseCTCPVersion) }, 27 { "VERSION", FUNC(parseCTCPVersion) },
28 { "ACTION", FUNC(parseCTCPAction) }, 28 { "ACTION", FUNC(parseCTCPAction) },
29 { 0 , 0 } 29 { 0 , 0 }
30}; 30};
31 31
32/* Lookup table for numerical commands 32/* Lookup table for numerical commands
33 * According to: 33 * According to:
34 * http://www.faqs.org/rfcs/rfc1459.html 34 * http://www.faqs.org/rfcs/rfc1459.html
35 * http://www.faqs.org/rfcs/rfc2812.html 35 * http://www.faqs.org/rfcs/rfc2812.html
36*/ 36*/
37 37
38IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { 38IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
39 { 1, "%1", "1", FUNC(parseNumericalServerName) }, // RPL_WELCOME 39 { 1, "%1", "1", FUNC(parseNumericalServerName) }, // RPL_WELCOME
40 { 2, "%1", "1", 0 }, // RPL_YOURHOST 40 { 2, "%1", "1", 0 }, // RPL_YOURHOST
41 { 3, "%1", "1", 0 }, // RPL_CREATED 41 { 3, "%1", "1", 0 }, // RPL_CREATED
42 { 4, QT_TR_NOOP("Server %1 version %2 supports usermodes '%3' and channelmodes '%4'"), "1:4", FUNC(parseNumericalServerFeatures) }, // RPL_MYINFO 42 { 4, QT_TR_NOOP("Server %1 version %2 supports usermodes '%3' and channelmodes '%4'"), "1:4", FUNC(parseNumericalServerFeatures) }, // RPL_MYINFO
43 { 5, 0, 0, FUNC(parseNumericalServerProtocol) }, // RPL_BOUNCE, RPL_PROTOCTL 43 { 5, 0, 0, FUNC(parseNumericalServerProtocol) }, // RPL_BOUNCE, RPL_PROTOCTL
44 { 250, "%1", "1", 0 }, // RPL_STATSCONN 44 { 250, "%1", "1", 0 }, // RPL_STATSCONN
45 { 251, "%1", "1", 0 }, // RPL_LUSERCLIENT 45 { 251, "%1", "1", 0 }, // RPL_LUSERCLIENT
46 { 252, QT_TR_NOOP("There are %1 operators connected"), "1", 0 }, // RPL_LUSEROP 46 { 252, QT_TR_NOOP("There are %1 operators connected"), "1", 0 }, // RPL_LUSEROP
47 { 253, QT_TR_NOOP("There are %1 unknown connection(s)"), "1", 0 }, // RPL_LUSERUNKNOWN 47 { 253, QT_TR_NOOP("There are %1 unknown connection(s)"), "1", 0 }, // RPL_LUSERUNKNOWN
48 { 254, QT_TR_NOOP("There are %1 channels formed"), "1", 0 }, // RPL_LUSERCHANNELS 48 { 254, QT_TR_NOOP("There are %1 channels formed"), "1", 0 }, // RPL_LUSERCHANNELS
49 { 255, "%1", "1", 0 }, // RPL_LUSERME 49 { 255, "%1", "1", 0 }, // RPL_LUSERME
50 { 263, QT_TR_NOOP("Please wait a while and try again"), 0, 0 }, // RPL_TRYAGAIN 50 { 263, QT_TR_NOOP("Please wait a while and try again"), 0, 0 }, // RPL_TRYAGAIN
51 { 265, "%1", "1", 0 }, // RPL_LOCALUSERS 51 { 265, "%1", "1", 0 }, // RPL_LOCALUSERS
52 { 266, "%1", "1", 0 }, // RPL_GLOBALUSERS 52 { 266, "%1", "1", 0 }, // RPL_GLOBALUSERS
53 { 311, QT_TR_NOOP("Whois %1 (%2@%3)\nReal name: %4"), "1:3,5" }, // RPL_WHOISUSER 53 { 311, QT_TR_NOOP("Whois %1 (%2@%3)\nReal name: %4"), "1:3,5" }, // RPL_WHOISUSER
54 { 312, QT_TR_NOOP("%1 is using server %2"), "1,2", 0 }, // RPL_WHOISSERVER 54 { 312, QT_TR_NOOP("%1 is using server %2"), "1,2", 0 }, // RPL_WHOISSERVER
55 { 317, 0, 0, FUNC(parseNumericalWhoisIdle) }, // RPL_WHOISIDLE 55 { 317, 0, 0, FUNC(parseNumericalWhoisIdle) }, // RPL_WHOISIDLE
56 { 318, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOIS 56 { 318, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOIS
57 { 320, "%1 %2", "1,2", 0}, // RPL_WHOISVIRT 57 { 320, "%1 %2", "1,2", 0}, // RPL_WHOISVIRT
58 { 332, 0, 0, FUNC(parseNumericalTopic) }, // RPL_TOPIC 58 { 332, 0, 0, FUNC(parseNumericalTopic) }, // RPL_TOPIC
59 { 333, 0, 0, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME*/ 59 { 333, 0, 0, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME*/
60 { 353, QT_TR_NOOP("Names for %1: %2"), "2,3", FUNC(parseNumericalNames) }, // RPL_NAMREPLY 60 { 353, QT_TR_NOOP("Names for %1: %2"), "2,3", FUNC(parseNumericalNames) }, // RPL_NAMREPLY
61 { 366, "%1 :%2", "1,2", FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES 61 { 366, "%1 :%2", "1,2", FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
62 { 369, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOWAS 62 { 369, "%1 :%2", "1,2", 0 }, // RPL_ENDOFWHOWAS
63 { 372, "%1", "1", 0 }, // RPL_MOTD 63 { 372, "%1", "1", 0 }, // RPL_MOTD
64 { 375, "%1", "1", 0 }, // RPL_MOTDSTART 64 { 375, "%1", "1", 0 }, // RPL_MOTDSTART
65 { 376, "%1", "1", 0 }, // RPL_ENDOFMOTD 65 { 376, "%1", "1", 0 }, // RPL_ENDOFMOTD
66 { 377, "%1", "1", 0 }, // RPL_MOTD2 66 { 377, "%1", "1", 0 }, // RPL_MOTD2
67 { 378, "%1", "1", 0 }, // RPL_MOTD3 67 { 378, "%1", "1", 0 }, // RPL_MOTD3
68 { 391, QT_TR_NOOP("Time on server %1 is %2"), "1,2", 0 }, // RPL_TIME 68 { 391, QT_TR_NOOP("Time on server %1 is %2"), "1,2", 0 }, // RPL_TIME
69 { 401, QT_TR_NOOP("Channel or nick %1 doesn't exists"), "1", 0 }, // ERR_NOSUCHNICK 69 { 401, QT_TR_NOOP("Channel or nick %1 doesn't exists"), "1", 0 }, // ERR_NOSUCHNICK
70 { 406, QT_TR_NOOP("There is no history information for %1"), "1" }, // ERR_WASNOSUCHNICK 70 { 406, QT_TR_NOOP("There is no history information for %1"), "1" }, // ERR_WASNOSUCHNICK
71 { 409, "%1", "1", 0 }, // ERR_NOORIGIN 71 { 409, "%1", "1", 0 }, // ERR_NOORIGIN
72 { 411, "%1", "1", 0 }, // ERR_NORECIPIENT 72 { 411, "%1", "1", 0 }, // ERR_NORECIPIENT
73 { 412, "%1", "1", 0 }, // ERR_NOTEXTTOSEND 73 { 412, "%1", "1", 0 }, // ERR_NOTEXTTOSEND
74 { 421, QT_TR_NOOP("Unknown command: %1"), "1", 0 }, // ERR_NOMOTD 74 { 421, QT_TR_NOOP("Unknown command: %1"), "1", 0 }, // ERR_ERR_UNKNOWNCOMMAND
75 { 422, QT_TR_NOOP("You're not on channel %1"), "1", 0}, // ERR_NOTONCHANNEL
76 { 422, "%1", "1", 0 }, // ERR_NOMOTD 75 { 422, "%1", "1", 0 }, // ERR_NOMOTD
77 { 433, QT_TR_NOOP("Can't change nick to %1: %2"), "1,2", FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE 76 { 433, QT_TR_NOOP("Can't change nick to %1: %2"), "1,2", FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
77 { 442, QT_TR_NOOP("You're not on channel %1"), "1", 0}, // ERR_NOTONCHANNEL
78 { 477, "%1", "1", 0 }, // ERR_NOCHANMODES || ERR_NEEDREGGEDNICK 78 { 477, "%1", "1", 0 }, // ERR_NOCHANMODES || ERR_NEEDREGGEDNICK
79 { 482, QT_TR_NOOP("[%1] Operation not permitted, you don't have enough channel privileges"), "1", 0 }, //ERR_CHANOPRIVSNEEDED 79 { 482, QT_TR_NOOP("[%1] Operation not permitted, you don't have enough channel privileges"), "1", 0 }, //ERR_CHANOPRIVSNEEDED
80 { 0, 0, 0, 0 } 80 { 0, 0, 0, 0 }
81}; 81};
82 82
83 83
84IRCMessageParser::IRCMessageParser(IRCSession *session) { 84IRCMessageParser::IRCMessageParser(IRCSession *session) {
85 m_session = session; 85 m_session = session;
86} 86}
87 87
88void IRCMessageParser::parse(IRCMessage *message) { 88void IRCMessageParser::parse(IRCMessage *message) {
89 /* Find out what kind of message we have here and call the appropriate handler using 89 /* Find out what kind of message we have here and call the appropriate handler using
90 the parser tables. If no handler can be found, print out an error message */ 90 the parser tables. If no handler can be found, print out an error message */
91 if (message->isNumerical()) { 91 if (message->isNumerical()) {
92 for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { 92 for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) {
93 if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { 93 if (message->commandNumber() == numericalParserProcTable[i].commandNumber) {
94 parseNumerical(message, i); 94 parseNumerical(message, i);
95 return; 95 return;
96 } 96 }
97 } 97 }
98 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) ))); 98 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) )));
99 } else if (message->isCTCP()) { 99 } else if (message->isCTCP()) {
100 for (int i=0; ctcpParserProcTable[i].commandName; i++) { 100 for (int i=0; ctcpParserProcTable[i].commandName; i++) {
101 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { 101 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) {
102 (this->*(ctcpParserProcTable[i].proc))(message); 102 (this->*(ctcpParserProcTable[i].proc))(message);
103 return; 103 return;
104 } 104 }
105 } 105 }
106 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) ); 106 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) );
107 } else { 107 } else {
108 for (int i=0; literalParserProcTable[i].commandName; i++) { 108 for (int i=0; literalParserProcTable[i].commandName; i++) {
109 if (message->command() == literalParserProcTable[i].commandName) { 109 if (message->command() == literalParserProcTable[i].commandName) {
110 (this->*(literalParserProcTable[i].proc))(message); 110 (this->*(literalParserProcTable[i].proc))(message);
111 return; 111 return;
112 } 112 }
113 } 113 }
114 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) )); 114 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) ));
115 } 115 }
116} 116}
117 117
118void IRCMessageParser::parseNumerical(IRCMessage *message, int position) { 118void IRCMessageParser::parseNumerical(IRCMessage *message, int position) {
119 QString out = tr(numericalParserProcTable[position].message); 119 QString out = tr(numericalParserProcTable[position].message);
120 QString paramString = numericalParserProcTable[position].params; 120 QString paramString = numericalParserProcTable[position].params;
121 121
122 if(!out.isEmpty() && !paramString.isEmpty()) { 122 if(!out.isEmpty() && !paramString.isEmpty()) {
123 QStringList params = message->params(numericalParserProcTable[position].params); 123 QStringList params = message->params(numericalParserProcTable[position].params);
124 124
125 QStringList::Iterator end = params.end(); 125 QStringList::Iterator end = params.end();
126 for (QStringList::Iterator it = params.begin(); it != end; ++it) { 126 for (QStringList::Iterator it = params.begin(); it != end; ++it) {
127 out = out.arg(*it); 127 out = out.arg(*it);
128 } 128 }
129 129
130 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, out)); 130 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, out));
131 } 131 }
132 132
133 if(numericalParserProcTable[position].proc) 133 if(numericalParserProcTable[position].proc)
134 (this->*(numericalParserProcTable[position].proc))(message); 134 (this->*(numericalParserProcTable[position].proc))(message);
135} 135}
136 136
137void IRCMessageParser::parseNumericalServerName(IRCMessage *message) { 137void IRCMessageParser::parseNumericalServerName(IRCMessage *message) {
138 emit outputReady(IRCOutput(OUTPUT_TITLE, tr("Connected to")+" <b>" + message->prefix() + "</b>")); 138 emit outputReady(IRCOutput(OUTPUT_TITLE, tr("Connected to")+" <b>" + message->prefix() + "</b>"));
139 /* Register EFFECTIVE nickname, some networks (as irc-hispano) uses nick:password
140 * for authentication and the parser gets confused */
141 m_session->m_server->setNick(message->param(0));
142
139} 143}
140 144
141void IRCMessageParser::parseNumericalServerFeatures(IRCMessage *message) { 145void IRCMessageParser::parseNumericalServerFeatures(IRCMessage *message) {
142 m_session->setValidUsermodes(message->param(2)); 146 m_session->setValidUsermodes(message->param(2));
143 m_session->setValidChannelmodes(message->param(3)); 147 m_session->setValidChannelmodes(message->param(3));
144 148
145} 149}
146 150
147void IRCMessageParser::parseNumericalServerProtocol(IRCMessage *message) { 151void IRCMessageParser::parseNumericalServerProtocol(IRCMessage *message) {
148 /* XXX: Add some usefull features here */ 152 /* XXX: Add some usefull features here */
149 QString out = message->allParameters(); 153 QString out = message->allParameters();
150 out = out.mid(out.find(' ')+1); 154 out = out.mid(out.find(' ')+1);
151 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, out)); 155 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, out));
152} 156}
153void IRCMessageParser::parseNumericalWhoisIdle(IRCMessage *message) { 157void IRCMessageParser::parseNumericalWhoisIdle(IRCMessage *message) {
154 QDateTime dt; 158 QDateTime dt;
155 QTime t; 159 QTime t;
156 t = t.addSecs(message->param(2).toInt()); 160 t = t.addSecs(message->param(2).toInt());
157 dt.setTime_t(message->param(3).toInt()); 161 dt.setTime_t(message->param(3).toInt());
158 162
159 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, tr("%1 has been idle for %2").arg(message->param(1)).arg(t.toString()))); 163 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, tr("%1 has been idle for %2").arg(message->param(1)).arg(t.toString())));
160 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, tr("%1 signed on %2").arg(message->param(1)).arg(dt.toString()))); 164 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, tr("%1 signed on %2").arg(message->param(1)).arg(dt.toString())));
161 165
162} 166}
163 167
164void IRCMessageParser::parseLiteralPing(IRCMessage *message) { 168void IRCMessageParser::parseLiteralPing(IRCMessage *message) {
165 m_session->m_connection->sendLine("PONG " + message->allParameters()); 169 m_session->m_connection->sendLine("PONG " + message->allParameters());
166} 170}
167 171
168void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { 172void IRCMessageParser::parseLiteralNotice(IRCMessage *message) {
169 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); 173 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
170} 174}
171 175
172void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { 176void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
173 QString channelName = message->param(0).lower(); 177 QString channelName = message->param(0).lower();
174 IRCPerson mask(message->prefix()); 178 IRCPerson mask(message->prefix());
175 IRCChannel *channel = m_session->getChannel(channelName); 179 IRCChannel *channel = m_session->getChannel(channelName);
176 if (!channel) { 180 if (!channel) {
177 /* We joined */ 181 /* We joined */
178 if (mask.nick() == m_session->m_server->nick()) { 182 if (mask.nick() == m_session->m_server->nick()) {
179 channel = new IRCChannel(channelName); 183 channel = new IRCChannel(channelName);
180 m_session->addChannel(channel); 184 m_session->addChannel(channel);
181 } else { 185 } else {
182 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); 186 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?")));
183 } 187 }
184 } else { 188 } else {
185 /* Someone else joined */ 189 /* Someone else joined */
186 if (mask.nick() != m_session->m_server->nick()) { 190 if (mask.nick() != m_session->m_server->nick()) {
187 if (!channel->getPerson(mask.nick())) { 191 if (!channel->getPerson(mask.nick())) {
188 IRCChannelPerson *chanperson = new IRCChannelPerson(); 192 IRCChannelPerson *chanperson = new IRCChannelPerson();
189 IRCPerson *person = m_session->getPerson(mask.nick()); 193 IRCPerson *person = m_session->getPerson(mask.nick());
190 if (!person) { 194 if (!person) {
191 person = new IRCPerson(message->prefix()); 195 person = new IRCPerson(message->prefix());
192 m_session->addPerson(person); 196 m_session->addPerson(person);
193 } 197 }
194 chanperson->flags = 0; 198 chanperson->flags = 0;
195 chanperson->person = person; 199 chanperson->person = person;
196 channel->addPerson(chanperson); 200 channel->addPerson(chanperson);
197 IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName )); 201 IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName ));
198 output.addParam(channel); 202 output.addParam(channel);
199 output.addParam(chanperson); 203 output.addParam(chanperson);
200 emit outputReady(output); 204 emit outputReady(output);
201 } else { 205 } else {
202 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); 206 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?")));
203 } 207 }
204 } else { 208 } else {
205 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); 209 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?")));
206 } 210 }
207 } 211 }
208} 212}
209 213
210void IRCMessageParser::parseLiteralPart(IRCMessage *message) { 214void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
211 QString channelName = message->param(0).lower(); 215 QString channelName = message->param(0).lower();
212 IRCChannel *channel = m_session->getChannel(channelName); 216 IRCChannel *channel = m_session->getChannel(channelName);
213 IRCPerson mask(message->prefix()); 217 IRCPerson mask(message->prefix());
214 if (channel) { 218 if (channel) {
215 if (mask.nick() == m_session->m_server->nick()) { 219 if (mask.nick() == m_session->m_server->nick()) {
216 m_session->removeChannel(channel); 220 m_session->removeChannel(channel);
217 IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName )); 221 IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName ));
218 output.addParam(channel); 222 output.addParam(channel);
219 emit outputReady(output); 223 emit outputReady(output);
220 delete channel; 224 delete channel;
221 } else { 225 } else {
222 IRCChannelPerson *person = channel->getPerson(mask.nick()); 226 IRCChannelPerson *person = channel->getPerson(mask.nick());
223 if (person) { 227 if (person) {
224 channel->removePerson(person); 228 channel->removePerson(person);
225 IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) ); 229 IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) );
226 output.addParam(channel); 230 output.addParam(channel);
227 output.addParam(person); 231 output.addParam(person);
228 emit outputReady(output); 232 emit outputReady(output);
229 delete person; 233 delete person;
230 } else { 234 } else {
231 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); 235 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?")));
232 } 236 }
233 } 237 }
234 } else { 238 } else {
235 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); 239 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
236 } 240 }
237} 241}
238 242
239void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { 243void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
240 if (m_session->m_server->nick().lower() == message->param(0).lower() ) { 244 if (m_session->m_server->nick().lower() == message->param(0).lower() ) {
241 /* IRC Query message detected, verify sender and display it */ 245 /* IRC Query message detected, verify sender and display it */
242 IRCPerson mask(message->prefix()); 246 IRCPerson mask(message->prefix());
243 IRCPerson *person = m_session->getPerson(mask.nick()); 247 IRCPerson *person = m_session->getPerson(mask.nick());
244 if (!person) { 248 if (!person) {
245 /* Person not yet known, create and add to the current session */ 249 /* Person not yet known, create and add to the current session */
246 person = new IRCPerson(message->prefix()); 250 person = new IRCPerson(message->prefix());
247 m_session->addPerson(person); 251 m_session->addPerson(person);
248 } 252 }
249 IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); 253 IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1));
250 output.addParam(person); 254 output.addParam(person);
251 emit outputReady(output); 255 emit outputReady(output);
252 } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') { 256 }
253 /* IRC Channel message detected, verify sender, channel and display it */ 257 else
254 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 258 if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') {
255 if (channel) { 259 /* IRC Channel message detected, verify sender, channel and display it */
256 IRCPerson mask(message->prefix()); 260 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
257 IRCChannelPerson *person = channel->getPerson(mask.nick()); 261 if (channel) {
258 if (person) { 262 IRCPerson mask(message->prefix());
259 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); 263 IRCChannelPerson *person = channel->getPerson(mask.nick());
260 output.addParam(channel); 264 if (person) {
261 output.addParam(person); 265 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
262 emit outputReady(output); 266 output.addParam(channel);
263 } else { 267 output.addParam(person);
264 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); 268 emit outputReady(output);
269 }
270 else {
271 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender")));
272 }
273 }
274 else {
275 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) ));
265 } 276 }
266 } else { 277 }
267 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); 278 else {emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
268 }
269 } else {
270 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
271 } 279 }
272} 280}
273 281
274void IRCMessageParser::parseLiteralNick(IRCMessage *message) { 282void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
275 IRCPerson mask(message->prefix()); 283 IRCPerson mask(message->prefix());
276 m_session->updateNickname(mask.nick(), message->param(0)); 284 m_session->updateNickname(mask.nick(), message->param(0));
277 /* this way of handling nick changes really sucks 285 /* this way of handling nick changes really sucks
278 if (mask.nick() == m_session->m_server->nick()) { 286 if (mask.nick() == m_session->m_server->nick()) {
279 We are changing our nickname 287 We are changing our nickname
280 m_session->m_server->setNick(message->param(0)); 288 m_session->m_server->setNick(message->param(0));
281 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); 289 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0)));
282 output.addParam(0); 290 output.addParam(0);
283 emit outputReady(output); 291 emit outputReady(output);
284 } else { 292 } else {
285 Someone else is 293 Someone else is
286 RCPerson *person = m_session->getPerson(mask.nick()); 294 RCPerson *person = m_session->getPerson(mask.nick());
287 if (person) { 295 if (person) {
288 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 296 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
289 297
290 new code starts here -- this removes the person from all channels 298 new code starts here -- this removes the person from all channels
291 QList<IRCChannel> channels; 299 QList<IRCChannel> channels;
292 m_session->getChannelsByPerson(person, channels); 300 m_session->getChannelsByPerson(person, channels);
293 QListIterator<IRCChannel> it(channels); 301 QListIterator<IRCChannel> it(channels);
294 for (;it.current(); ++it) { 302 for (;it.current(); ++it) {
295 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 303 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
296 it.current()->removePerson(chanperson); 304 it.current()->removePerson(chanperson);
297 chanperson->person->setNick(message->param(0)); 305 chanperson->person->setNick(message->param(0));
298 it.current()->addPerson(chanperson); 306 it.current()->addPerson(chanperson);
299 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0))); 307 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
300 output.addParam(person); 308 output.addParam(person);
301 emit outputReady(output); 309 emit outputReady(output);
302 } 310 }
303 new code ends here 311 new code ends here
304 } else { 312 } else {
305 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); 313 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
306 } 314 }
307 }*/ 315 }*/
308} 316}
309 317
310void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { 318void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
311 IRCPerson mask(message->prefix()); 319 IRCPerson mask(message->prefix());
312 IRCPerson *person = m_session->getPerson(mask.nick()); 320 IRCPerson *person = m_session->getPerson(mask.nick());
313 if (person) { 321 if (person) {
314 QList<IRCChannel> channels; 322 QList<IRCChannel> channels;
315 m_session->getChannelsByPerson(person, channels); 323 m_session->getChannelsByPerson(person, channels);
316 QListIterator<IRCChannel> it(channels); 324 QListIterator<IRCChannel> it(channels);
317 for (;it.current(); ++it) { 325 for (;it.current(); ++it) {
318 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 326 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
319 it.current()->removePerson(chanperson); 327 it.current()->removePerson(chanperson);
320 delete chanperson; 328 delete chanperson;
321 } 329 }
322 m_session->removePerson(person); 330 m_session->removePerson(person);
323 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); 331 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) ));
324 output.addParam(person); 332 output.addParam(person);
325 emit outputReady(output); 333 emit outputReady(output);
326 delete person; 334 delete person;
327 } else { 335 } else {
328 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); 336 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
329 } 337 }
330} 338}
331 339
332void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { 340void IRCMessageParser::parseLiteralTopic(IRCMessage *message) {
333 IRCPerson mask(message->prefix()); 341 IRCPerson mask(message->prefix());
334 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 342 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
335 if (channel) { 343 if (channel) {
336 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); 344 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\"");
337 output.addParam(channel); 345 output.addParam(channel);
338 emit outputReady(output); 346 emit outputReady(output);
339 } else { 347 } else {
340 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); 348 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?")));
341 } 349 }
342} 350}
343 351
344void IRCMessageParser::parseLiteralError(IRCMessage *message) { 352void IRCMessageParser::parseLiteralError(IRCMessage *message) {
345 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); 353 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
346} 354}
347 355
348void IRCMessageParser::parseCTCPPing(IRCMessage *message) { 356void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
349 IRCPerson mask(message->prefix()); 357 IRCPerson mask(message->prefix());
350 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); 358 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters());
351 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); 359 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick()));
352 360
353 //IRCPerson mask(message->prefix()); 361 //IRCPerson mask(message->prefix());
354 QString dest = message->ctcpDestination(); 362 QString dest = message->ctcpDestination();
355 if (dest.startsWith("#")) { 363 if (dest.startsWith("#")) {
356 IRCChannel *channel = m_session->getChannel(dest.lower()); 364 IRCChannel *channel = m_session->getChannel(dest.lower());
357 if (channel) { 365 if (channel) {
358 IRCChannelPerson *person = channel->getPerson(mask.nick()); 366 IRCChannelPerson *person = channel->getPerson(mask.nick());
359 if (person) { 367 if (person) {
360 IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ; 368 IRCOutput output(OUTPUT_CHANACTION, tr("Received a CTCP PING from ")+ mask.nick()) ;
361 output.addParam(channel); 369 output.addParam(channel);
362 output.addParam(person); 370 output.addParam(person);
363 emit outputReady(output); 371 emit outputReady(output);
364 } else { 372 } else {
365 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?"))); 373 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown person - Desynchronized?")));
366 } 374 }
367 } else { 375 } else {
368 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?"))); 376 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with unknown channel - Desynchronized?")));
369 } 377 }
370 } else { 378 } else {
371 if (message->ctcpDestination() == m_session->m_server->nick()) { 379 if (message->ctcpDestination() == m_session->m_server->nick()) {
372 IRCPerson *person = m_session->getPerson(mask.nick()); 380 IRCPerson *person = m_session->getPerson(mask.nick());
373 if (!person) { 381 if (!person) {
374 /* Person not yet known, create and add to the current session */ 382 /* Person not yet known, create and add to the current session */
375 person = new IRCPerson(message->prefix()); 383 person = new IRCPerson(message->prefix());
376 m_session->addPerson(person); 384 m_session->addPerson(person);
377 } 385 }
378 IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() ); 386 IRCOutput output(OUTPUT_QUERYACTION, tr("Received a CTCP PING from ")+ mask.nick() );
379 output.addParam(person); 387 output.addParam(person);
380 emit outputReady(output); 388 emit outputReady(output);
381 } else { 389 } else {
382 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient"))); 390 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP PING with bad recipient")));
383 } 391 }
384 } 392 }
385 393
386} 394}
387 395
388void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { 396void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
389 IRCPerson mask(message->prefix()); 397 IRCPerson mask(message->prefix());
390 m_session->m_connection->sendCTCP(mask.nick(), "VERSION " APP_VERSION " " APP_COPYSTR); 398 m_session->m_connection->sendCTCP(mask.nick(), "VERSION " APP_VERSION " " APP_COPYSTR);
391 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); 399 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick()));
392} 400}
393 401
394void IRCMessageParser::parseCTCPAction(IRCMessage *message) { 402void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
395 IRCPerson mask(message->prefix()); 403 IRCPerson mask(message->prefix());
396 QString dest = message->ctcpDestination(); 404 QString dest = message->ctcpDestination();
397 if (dest.startsWith("#")) { 405 if (dest.startsWith("#")) {
398 IRCChannel *channel = m_session->getChannel(dest.lower()); 406 IRCChannel *channel = m_session->getChannel(dest.lower());
399 if (channel) { 407 if (channel) {
400 IRCChannelPerson *person = channel->getPerson(mask.nick()); 408 IRCChannelPerson *person = channel->getPerson(mask.nick());
401 if (person) { 409 if (person) {
402 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); 410 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0));
403 output.addParam(channel); 411 output.addParam(channel);
404 output.addParam(person); 412 output.addParam(person);
405 emit outputReady(output); 413 emit outputReady(output);
406 } else { 414 } else {
407 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); 415 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));
408 } 416 }
409 } else { 417 } else {
410 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); 418 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?")));
411 } 419 }
412 } else { 420 } else {
413 if (message->ctcpDestination() == m_session->m_server->nick()) { 421 if (message->ctcpDestination() == m_session->m_server->nick()) {
414 IRCPerson *person = m_session->getPerson(mask.nick()); 422 IRCPerson *person = m_session->getPerson(mask.nick());
415 if (!person) { 423 if (!person) {
416 /* Person not yet known, create and add to the current session */ 424 /* Person not yet known, create and add to the current session */
417 person = new IRCPerson(message->prefix()); 425 person = new IRCPerson(message->prefix());
418 m_session->addPerson(person); 426 m_session->addPerson(person);
419 } 427 }
420 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); 428 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0));
421 output.addParam(person); 429 output.addParam(person);
422 emit outputReady(output); 430 emit outputReady(output);
423 } else { 431 } else {
424 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); 432 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
425 } 433 }
426 } 434 }
427} 435}
428 436
429void IRCMessageParser::parseLiteralMode(IRCMessage *message) { 437void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
430 IRCPerson mask(message->prefix()); 438 IRCPerson mask(message->prefix());
431 439
432 if (message->param(0).startsWith("#")) { 440 if (message->param(0).startsWith("#")) {
433 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 441 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
434 if (channel) { 442 if (channel) {
435 QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); 443 QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1);
436 QTextIStream stream(&parameters); 444 QTextIStream stream(&parameters);
437 bool set = FALSE; 445 bool set = FALSE;
438 while (!stream.atEnd()) { 446 while (!stream.atEnd()) {
439 stream >> temp; 447 stream >> temp;
440 if (temp.startsWith("+")) { 448 if (temp.startsWith("+")) {
441 set = TRUE; 449 set = TRUE;
442 temp = temp.right(1); 450 temp = temp.right(1);
443 } else if (temp.startsWith("-")) { 451 } else if (temp.startsWith("-")) {
444 set = FALSE; 452 set = FALSE;
445 temp = temp.right(1); 453 temp = temp.right(1);
446 } else { 454 } else {
447 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); 455 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type")));
448 return; 456 return;
449 } 457 }
450 if (temp == "o") { 458 if (temp == "o") {
451 stream >> temp; 459 stream >> temp;
452 IRCChannelPerson *person = channel->getPerson(temp); 460 IRCChannelPerson *person = channel->getPerson(temp);
453 if (person) { 461 if (person) {
454 if (set) { 462 if (set) {
455 person->flags |= PERSON_FLAG_OP; 463 person->flags |= PERSON_FLAG_OP;
456 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); 464 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick()));
457 output.addParam(channel); 465 output.addParam(channel);
458 output.addParam(person); 466 output.addParam(person);
459 emit outputReady(output); 467 emit outputReady(output);
460 } else { 468 } else {
461 person->flags &= 0xFFFF - PERSON_FLAG_OP; 469 person->flags &= 0xFFFF - PERSON_FLAG_OP;
462 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); 470 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick()));
463 output.addParam(channel); 471 output.addParam(channel);
464 output.addParam(person); 472 output.addParam(person);
465 emit outputReady(output); 473 emit outputReady(output);
466 } 474 }
467 } else { 475 } else {
468 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); 476 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
469 } 477 }
470 } else if (temp == "v") { 478 } else if (temp == "v") {
471 stream >> temp; 479 stream >> temp;
472 IRCChannelPerson *person = channel->getPerson(temp); 480 IRCChannelPerson *person = channel->getPerson(temp);
473 if (person) { 481 if (person) {
474 if (set) { 482 if (set) {
475 person->flags |= PERSON_FLAG_VOICE; 483 person->flags |= PERSON_FLAG_VOICE;
476 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); 484 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick()));
477 output.addParam(channel); 485 output.addParam(channel);
478 output.addParam(person); 486 output.addParam(person);
479 emit outputReady(output); 487 emit outputReady(output);
480 } else { 488 } else {
481 person->flags &= 0xFFFF - PERSON_FLAG_VOICE; 489 person->flags &= 0xFFFF - PERSON_FLAG_VOICE;
482 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); 490 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick()));
483 output.addParam(channel); 491 output.addParam(channel);
484 output.addParam(person); 492 output.addParam(person);
485 emit outputReady(output); 493 emit outputReady(output);
486 } 494 }
487 } else { 495 } else {
488 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); 496 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
489 } 497 }
490 } else { 498 } else {
491 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); 499 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag")));
492 } 500 }
493 } 501 }
494 } else { 502 } else {
495 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); 503 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?")));
496 } 504 }
497 } else { 505 } else {
498 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); 506 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet")));
499 } 507 }
500} 508}
501 509
502void IRCMessageParser::parseLiteralKick(IRCMessage *message) { 510void IRCMessageParser::parseLiteralKick(IRCMessage *message) {
503 IRCPerson mask(message->prefix()); 511 IRCPerson mask(message->prefix());
504 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 512 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
505 if (channel) { 513 if (channel) {
506 IRCChannelPerson *person = channel->getPerson(message->param(1)); 514 IRCChannelPerson *person = channel->getPerson(message->param(1));
507 if (person) { 515 if (person) {
508 if (person->person->nick() == m_session->m_server->nick()) { 516 if (person->person->nick() == m_session->m_server->nick()) {
509 m_session->removeChannel(channel); 517 m_session->removeChannel(channel);
510 IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); 518 IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")");
511 output.addParam(channel); 519 output.addParam(channel);
512 emit outputReady(output); 520 emit outputReady(output);
513 } else { 521 } else {
514 /* someone else got kicked */ 522 /* someone else got kicked */
515 channel->removePerson(person); 523 channel->removePerson(person);
516 IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); 524 IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")");
517 output.addParam(channel); 525 output.addParam(channel);
518 output.addParam(person); 526 output.addParam(person);
519 emit outputReady(output); 527 emit outputReady(output);
520 } 528 }
521 } else { 529 } else {
522 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); 530 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?")));
523 } 531 }
524 } else { 532 } else {
525 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); 533 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?")));
526 } 534 }
527} 535}
528 536
529void IRCMessageParser::parseNumericalNames(IRCMessage *message) { 537void IRCMessageParser::parseNumericalNames(IRCMessage *message) {
530 /* Name list sent when joining a channel */ 538 /* Name list sent when joining a channel */
531 IRCChannel *channel = m_session->getChannel(message->param(2).lower()); 539 IRCChannel *channel = m_session->getChannel(message->param(2).lower());
532 if (channel != 0) { 540 if (channel != 0) {
533 QString people = message->param(3); 541 QString people = message->param(3);
534 QTextIStream stream(&people); 542 QTextIStream stream(&people);
535 QString temp; 543 QString temp;
536 544
537 while (!stream.atEnd()) { 545 while (!stream.atEnd()) {
538 stream >> temp; 546 stream >> temp;
539 547
540 char flagch = temp.at(0).latin1(); 548 char flagch = temp.at(0).latin1();
541 int flag = 0; 549 int flag = 0;
542 QString nick; 550 QString nick;
543 /* Parse person flags */ 551 /* Parse person flags */
544 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { 552 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') {
545 553
546 nick = temp.right(temp.length()-1); 554 nick = temp.right(temp.length()-1);
547 switch (flagch) { 555 switch (flagch) {
548 case '@': flag = PERSON_FLAG_OP; break; 556 case '@': flag = PERSON_FLAG_OP; break;
549 case '+': flag = PERSON_FLAG_VOICE; break; 557 case '+': flag = PERSON_FLAG_VOICE; break;
550 case '%': flag = PERSON_FLAG_HALFOP; break; 558 case '%': flag = PERSON_FLAG_HALFOP; break;
551 default : flag = 0; break; 559 default : flag = 0; break;
552 } 560 }
553 } else { 561 } else {
554 nick = temp; 562 nick = temp;
555 } 563 }
556 564
557 IRCChannelPerson *chan_person = new IRCChannelPerson(); 565 IRCChannelPerson *chan_person = new IRCChannelPerson();
558 IRCPerson *person = m_session->getPerson(nick); 566 IRCPerson *person = m_session->getPerson(nick);
559 if (person == 0) { 567 if (person == 0) {
560 person = new IRCPerson(); 568 person = new IRCPerson();
561 person->setNick(nick); 569 person->setNick(nick);
562 m_session->addPerson(person); 570 m_session->addPerson(person);
563 } 571 }
564 chan_person->person = person; 572 chan_person->person = person;
565 chan_person->flags = flag; 573 chan_person->flags = flag;
566 channel->addPerson(chan_person); 574 channel->addPerson(chan_person);
567 } 575 }
568 } else { 576 } else {
569 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); 577 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
570 } 578 }
571} 579}
572 580
573void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { 581void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) {
574 /* Done syncing to channel */ 582 /* Done syncing to channel */
575 IRCChannel *channel = m_session->getChannel(message->param(1).lower()); 583 IRCChannel *channel = m_session->getChannel(message->param(1).lower());
576 if (channel) { 584 if (channel) {
577 channel->setHasPeople(TRUE); 585 channel->setHasPeople(TRUE);
578 /* Yes, we want the names before anything happens inside the GUI */ 586 /* Yes, we want the names before anything happens inside the GUI */
579 IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); 587 IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname());
580 output.addParam(channel); 588 output.addParam(channel);
581 emit outputReady(output); 589 emit outputReady(output);
582 } else { 590 } else {
583 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); 591 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
584 } 592 }
585} 593}
586 594
587 595
588void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { 596void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) {
589 /* If we are connnected this error is not critical */ 597 /* If we are connnected this error is not critical */
590 if(m_session->isLoggedIn()) 598 if(m_session->isLoggedIn())
591 return; 599 return;
592 600
593 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); 601 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname")));
594 m_session->endSession(); 602 m_session->endSession();
595} 603}
596 604
597void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { 605void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) {
598 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); 606 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname")));
599} 607}
600 608
601void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { 609void IRCMessageParser::parseNumericalTopic(IRCMessage *message) {
602 IRCChannel *channel = m_session->getChannel(message->param(1).lower()); 610 IRCChannel *channel = m_session->getChannel(message->param(1).lower());
603 if (channel) { 611 if (channel) {
604 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); 612 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\""));
605 output.addParam(channel); 613 output.addParam(channel);
606 emit outputReady(output); 614 emit outputReady(output);
607 } else { 615 } else {
608 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); 616 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\""));
609 output.addParam(0); 617 output.addParam(0);
610 emit outputReady(output); 618 emit outputReady(output);
611 } 619 }
612} 620}
613 621
614void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) { 622void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) {
615} 623}
616 624
617 625