summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircconnection.cpp2
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp2
-rw-r--r--noncore/net/opieirc/ircservereditor.cpp4
-rw-r--r--noncore/net/opieirc/ircservertab.cpp2
4 files changed, 5 insertions, 5 deletions
diff --git a/noncore/net/opieirc/ircconnection.cpp b/noncore/net/opieirc/ircconnection.cpp
index 5eb0cf2..2325cca 100644
--- a/noncore/net/opieirc/ircconnection.cpp
+++ b/noncore/net/opieirc/ircconnection.cpp
@@ -1,102 +1,102 @@
1#include <unistd.h> 1#include <unistd.h>
2#include <string.h> 2#include <string.h>
3#include "ircconnection.h" 3#include "ircconnection.h"
4 4
5IRCConnection::IRCConnection(IRCServer *server) { 5IRCConnection::IRCConnection(IRCServer *server) {
6 m_server = server; 6 m_server = server;
7 m_socket = new QSocket(this); 7 m_socket = new QSocket(this);
8 m_connected = FALSE; 8 m_connected = FALSE;
9 m_loggedIn = FALSE; 9 m_loggedIn = FALSE;
10 connect(m_socket, SIGNAL(connected()), this, SLOT(login())); 10 connect(m_socket, SIGNAL(connected()), this, SLOT(login()));
11 connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReady())); 11 connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReady()));
12 connect(m_socket, SIGNAL(error(int)), this, SLOT(error(int))); 12 connect(m_socket, SIGNAL(error(int)), this, SLOT(error(int)));
13 connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(disconnect())); 13 connect(m_socket, SIGNAL(connectionClosed()), this, SLOT(disconnect()));
14 connect(m_socket, SIGNAL(delayedCloseFinished()), this, SLOT(disconnect())); 14 connect(m_socket, SIGNAL(delayedCloseFinished()), this, SLOT(disconnect()));
15} 15}
16 16
17/* Connect to the IRC server */ 17/* Connect to the IRC server */
18void IRCConnection::doConnect() { 18void IRCConnection::doConnect() {
19 ASSERT(!m_connected); 19 ASSERT(!m_connected);
20 m_socket->connectToHost(m_server->hostname(), m_server->port()); 20 m_socket->connectToHost(m_server->hostname(), m_server->port());
21} 21}
22 22
23/* Send commands to the IRC server */ 23/* Send commands to the IRC server */
24void IRCConnection::sendLine(QString line) { 24void IRCConnection::sendLine(QString line) {
25 while((line.right(1) == "\n") || (line.right(1) == "\r")) 25 while((line.right(1) == "\n") || (line.right(1) == "\r"))
26 line = line.left(line.length() - 1); 26 line = line.left(line.length() - 1);
27 line.append("\r\n"); 27 line.append("\r\n");
28 m_socket->writeBlock(line, line.length()); 28 m_socket->writeBlock(line, line.length());
29} 29}
30 30
31void IRCConnection::sendCTCP(QString nick, QString line) { 31void IRCConnection::sendCTCP(QString nick, QString line) {
32 sendLine("NOTICE " + nick + " :\001"+line+"\001"); 32 sendLine("NOTICE " + nick + " :\001"+line+"\001");
33} 33}
34 34
35/* 35/*
36 * login() is called right after the connection 36 * login() is called right after the connection
37 * to the IRC server has been established 37 * to the IRC server has been established
38 */ 38 */
39void IRCConnection::login() { 39void IRCConnection::login() {
40 char hostname[256]; 40 char hostname[256];
41 QString loginString; 41 QString loginString;
42 42
43 emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Connected, logging in .."))); 43 emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Connected, logging in ..")));
44 m_connected = TRUE; 44 m_connected = TRUE;
45 gethostname(hostname, sizeof(hostname)-1); 45 gethostname(hostname, sizeof(hostname)-1);
46 hostname[sizeof (hostname) - 1] = 0; 46 hostname[sizeof (hostname) - 1] = 0;
47 47
48 /* Create a logon string and send it */ 48 /* Create a logon string and send it */
49 if (m_server->password().length()>0) { 49 if (m_server->password().length()>0) {
50 loginString += "PASS " + m_server->password() + "\r\n"; 50 loginString += "PASS " + m_server->password() + "\r\n";
51 } 51 }
52 loginString += "NICK " + m_server->nick() + "\r\n" + 52 loginString += "NICK " + m_server->nick() + "\r\n" +
53 "USER " + m_server->username() + " " + hostname + 53 "USER " + m_server->username() + " " + hostname +
54 " " + m_server->hostname() + " :" + m_server->realname() + "\r\n"; 54 " " + m_server->hostname() + " :" + m_server->realname() + "\r\n";
55 sendLine(loginString); 55 sendLine(loginString);
56} 56}
57 57
58/* Called when data arrives on the socket */ 58/* Called when data arrives on the socket */
59void IRCConnection::dataReady() { 59void IRCConnection::dataReady() {
60 while(m_socket->canReadLine()) { 60 while(m_socket->canReadLine()) {
61 IRCMessage message(m_socket->readLine()); 61 IRCMessage message(m_socket->readLine());
62 if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) { 62 if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) {
63 /* Now autojoin all channels specified inside the server profile */ 63 /* Now autojoin all channels specified inside the server profile */
64 QStringList channels = QStringList::split(QChar(','), m_server->channels()); 64 QStringList channels = QStringList::split(QChar(','), m_server->channels());
65 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { 65 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
66 QString channelName = (*it).stripWhiteSpace(); 66 QString channelName = (*it).stripWhiteSpace();
67 if (channelName.startsWith("#")) { 67 if (channelName.startsWith("#") || channelName.startsWith("+")) {
68 sendLine("JOIN "+ channelName); 68 sendLine("JOIN "+ channelName);
69 } 69 }
70 } 70 }
71 m_loggedIn = TRUE; 71 m_loggedIn = TRUE;
72 emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in."))); 72 emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in.")));
73 } 73 }
74 emit messageArrived(&message); 74 emit messageArrived(&message);
75 } 75 }
76} 76}
77 77
78/* Called if any type of socket error occurs */ 78/* Called if any type of socket error occurs */
79void IRCConnection::error(int num) { 79void IRCConnection::error(int num) {
80 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Socket error : ") + strerror(num))); 80 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Socket error : ") + strerror(num)));
81} 81}
82 82
83void IRCConnection::disconnect() { 83void IRCConnection::disconnect() {
84 m_connected = FALSE; 84 m_connected = FALSE;
85 m_loggedIn = FALSE; 85 m_loggedIn = FALSE;
86 emit outputReady(IRCOutput(OUTPUT_CONNCLOSE, tr("Connection closed"))); 86 emit outputReady(IRCOutput(OUTPUT_CONNCLOSE, tr("Connection closed")));
87} 87}
88 88
89bool IRCConnection::isConnected() { 89bool IRCConnection::isConnected() {
90 return m_connected; 90 return m_connected;
91} 91}
92 92
93bool IRCConnection::isLoggedIn() { 93bool IRCConnection::isLoggedIn() {
94 return m_loggedIn; 94 return m_loggedIn;
95} 95}
96 96
97void IRCConnection::close() { 97void IRCConnection::close() {
98 m_socket->close(); 98 m_socket->close();
99 if (m_socket->state()==QSocket::Idle) { 99 if (m_socket->state()==QSocket::Idle) {
100 disconnect(); 100 disconnect();
101 } 101 }
102} 102}
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 2b77414..a95c64e 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -90,193 +90,193 @@ void IRCMessageParser::parse(IRCMessage *message) {
90 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); 90 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command()));
91 } 91 }
92} 92}
93 93
94void IRCMessageParser::nullFunc(IRCMessage *) { 94void IRCMessageParser::nullFunc(IRCMessage *) {
95 /* Do nothing */ 95 /* Do nothing */
96} 96}
97 97
98void IRCMessageParser::parseLiteralPing(IRCMessage *message) { 98void 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
102void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { 102void IRCMessageParser::parseLiteralNotice(IRCMessage *message) {
103 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); 103 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
104} 104}
105 105
106void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { 106void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
107 QString channelName = message->param(0).lower(); 107 QString channelName = message->param(0).lower();
108 IRCPerson mask(message->prefix()); 108 IRCPerson mask(message->prefix());
109 IRCChannel *channel = m_session->getChannel(channelName); 109 IRCChannel *channel = m_session->getChannel(channelName);
110 if (!channel) { 110 if (!channel) {
111 /* We joined */ 111 /* We joined */
112 if (mask.nick() == m_session->m_server->nick()) { 112 if (mask.nick() == m_session->m_server->nick()) {
113 channel = new IRCChannel(channelName); 113 channel = new IRCChannel(channelName);
114 m_session->addChannel(channel); 114 m_session->addChannel(channel);
115 } else { 115 } else {
116 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); 116 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?")));
117 } 117 }
118 } else { 118 } else {
119 /* Someone else joined */ 119 /* Someone else joined */
120 if (mask.nick() != m_session->m_server->nick()) { 120 if (mask.nick() != m_session->m_server->nick()) {
121 if (!channel->getPerson(mask.nick())) { 121 if (!channel->getPerson(mask.nick())) {
122 IRCChannelPerson *chanperson = new IRCChannelPerson(); 122 IRCChannelPerson *chanperson = new IRCChannelPerson();
123 IRCPerson *person = m_session->getPerson(mask.nick()); 123 IRCPerson *person = m_session->getPerson(mask.nick());
124 if (!person) { 124 if (!person) {
125 person = new IRCPerson(message->prefix()); 125 person = new IRCPerson(message->prefix());
126 m_session->addPerson(person); 126 m_session->addPerson(person);
127 } 127 }
128 chanperson->flags = 0; 128 chanperson->flags = 0;
129 chanperson->person = person; 129 chanperson->person = person;
130 channel->addPerson(chanperson); 130 channel->addPerson(chanperson);
131 IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); 131 IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName);
132 output.addParam(channel); 132 output.addParam(channel);
133 output.addParam(chanperson); 133 output.addParam(chanperson);
134 emit outputReady(output); 134 emit outputReady(output);
135 } else { 135 } else {
136 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); 136 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?")));
137 } 137 }
138 } else { 138 } else {
139 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); 139 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?")));
140 } 140 }
141 } 141 }
142} 142}
143 143
144void IRCMessageParser::parseLiteralPart(IRCMessage *message) { 144void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
145 QString channelName = message->param(0).lower(); 145 QString channelName = message->param(0).lower();
146 IRCChannel *channel = m_session->getChannel(channelName); 146 IRCChannel *channel = m_session->getChannel(channelName);
147 IRCPerson mask(message->prefix()); 147 IRCPerson mask(message->prefix());
148 if (channel) { 148 if (channel) {
149 if (mask.nick() == m_session->m_server->nick()) { 149 if (mask.nick() == m_session->m_server->nick()) {
150 m_session->removeChannel(channel); 150 m_session->removeChannel(channel);
151 IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); 151 IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName);
152 output.addParam(channel); 152 output.addParam(channel);
153 emit outputReady(output); 153 emit outputReady(output);
154 delete channel; 154 delete channel;
155 } else { 155 } else {
156 IRCChannelPerson *person = channel->getPerson(mask.nick()); 156 IRCChannelPerson *person = channel->getPerson(mask.nick());
157 if (person) { 157 if (person) {
158 channel->removePerson(person); 158 channel->removePerson(person);
159 IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); 159 IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName);
160 output.addParam(channel); 160 output.addParam(channel);
161 output.addParam(person); 161 output.addParam(person);
162 emit outputReady(output); 162 emit outputReady(output);
163 delete person; 163 delete person;
164 } else { 164 } else {
165 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); 165 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?")));
166 } 166 }
167 } 167 }
168 } else { 168 } else {
169 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); 169 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
170 } 170 }
171} 171}
172 172
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() == message->param(0)) {
175 /* IRC Query message detected, verify sender and display it */ 175 /* IRC Query message detected, verify sender and display it */
176 IRCPerson mask(message->prefix()); 176 IRCPerson mask(message->prefix());
177 IRCPerson *person = m_session->getPerson(mask.nick()); 177 IRCPerson *person = m_session->getPerson(mask.nick());
178 if (!person) { 178 if (!person) {
179 /* Person not yet known, create and add to the current session */ 179 /* Person not yet known, create and add to the current session */
180 person = new IRCPerson(message->prefix()); 180 person = new IRCPerson(message->prefix());
181 m_session->addPerson(person); 181 m_session->addPerson(person);
182 } 182 }
183 IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); 183 IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1));
184 output.addParam(person); 184 output.addParam(person);
185 emit outputReady(output); 185 emit outputReady(output);
186 } else if (message->param(0).at(0) == '#') { 186 } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') {
187 /* IRC Channel message detected, verify sender, channel and display it */ 187 /* IRC Channel message detected, verify sender, channel and display it */
188 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 188 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
189 if (channel) { 189 if (channel) {
190 IRCPerson mask(message->prefix()); 190 IRCPerson mask(message->prefix());
191 IRCChannelPerson *person = channel->getPerson(mask.nick()); 191 IRCChannelPerson *person = channel->getPerson(mask.nick());
192 if (person) { 192 if (person) {
193 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); 193 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
194 output.addParam(channel); 194 output.addParam(channel);
195 output.addParam(person); 195 output.addParam(person);
196 emit outputReady(output); 196 emit outputReady(output);
197 } else { 197 } else {
198 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); 198 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender")));
199 } 199 }
200 } else { 200 } else {
201 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0).lower())); 201 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0).lower()));
202 } 202 }
203 } else { 203 } else {
204 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); 204 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
205 } 205 }
206} 206}
207 207
208void IRCMessageParser::parseLiteralNick(IRCMessage *message) { 208void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
209 IRCPerson mask(message->prefix()); 209 IRCPerson mask(message->prefix());
210 210
211 if (mask.nick() == m_session->m_server->nick()) { 211 if (mask.nick() == m_session->m_server->nick()) {
212 /* We are changing our nickname */ 212 /* We are changing our nickname */
213 m_session->m_server->setNick(message->param(0)); 213 m_session->m_server->setNick(message->param(0));
214 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); 214 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0));
215 output.addParam(0); 215 output.addParam(0);
216 emit outputReady(output); 216 emit outputReady(output);
217 } else { 217 } else {
218 /* Someone else is */ 218 /* Someone else is */
219 IRCPerson *person = m_session->getPerson(mask.nick()); 219 IRCPerson *person = m_session->getPerson(mask.nick());
220 if (person) { 220 if (person) {
221 IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); 221 IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0));
222 output.addParam(person); 222 output.addParam(person);
223 emit outputReady(output); 223 emit outputReady(output);
224 } else { 224 } else {
225 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); 225 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
226 } 226 }
227 } 227 }
228} 228}
229 229
230void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { 230void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
231 IRCPerson mask(message->prefix()); 231 IRCPerson mask(message->prefix());
232 IRCPerson *person = m_session->getPerson(mask.nick()); 232 IRCPerson *person = m_session->getPerson(mask.nick());
233 if (person) { 233 if (person) {
234 QList<IRCChannel> channels; 234 QList<IRCChannel> channels;
235 m_session->getChannelsByPerson(person, channels); 235 m_session->getChannelsByPerson(person, channels);
236 QListIterator<IRCChannel> it(channels); 236 QListIterator<IRCChannel> it(channels);
237 for (;it.current(); ++it) { 237 for (;it.current(); ++it) {
238 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 238 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
239 it.current()->removePerson(chanperson); 239 it.current()->removePerson(chanperson);
240 delete chanperson; 240 delete chanperson;
241 } 241 }
242 m_session->removePerson(person); 242 m_session->removePerson(person);
243 IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); 243 IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")");
244 output.addParam(person); 244 output.addParam(person);
245 emit outputReady(output); 245 emit outputReady(output);
246 delete person; 246 delete person;
247 } else { 247 } else {
248 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); 248 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
249 } 249 }
250} 250}
251 251
252void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { 252void 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
264void IRCMessageParser::parseLiteralError(IRCMessage *message) { 264void IRCMessageParser::parseLiteralError(IRCMessage *message) {
265 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); 265 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
266} 266}
267 267
268void IRCMessageParser::parseCTCPPing(IRCMessage *message) { 268void 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
274void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { 274void 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
280void IRCMessageParser::parseCTCPAction(IRCMessage *message) { 280void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
281 IRCPerson mask(message->prefix()); 281 IRCPerson mask(message->prefix());
282 QString dest = message->ctcpDestination(); 282 QString dest = message->ctcpDestination();
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp
index 5e916ae..f976c84 100644
--- a/noncore/net/opieirc/ircservereditor.cpp
+++ b/noncore/net/opieirc/ircservereditor.cpp
@@ -1,77 +1,77 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include "ircservereditor.h" 4#include "ircservereditor.h"
5 5
6IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { 6IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) {
7 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); 7 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5);
8 QLabel *label = new QLabel(tr("Profile name :"), this); 8 QLabel *label = new QLabel(tr("Profile name :"), this);
9 m_name = new QLineEdit(server.name(), this); 9 m_name = new QLineEdit(server.name(), this);
10 layout->addWidget(label, 0, 0); 10 layout->addWidget(label, 0, 0);
11 layout->addWidget(m_name, 0, 1); 11 layout->addWidget(m_name, 0, 1);
12 label = new QLabel(tr("Hostname :"), this); 12 label = new QLabel(tr("Hostname :"), this);
13 m_hostname = new QLineEdit(server.hostname(), this); 13 m_hostname = new QLineEdit(server.hostname(), this);
14 layout->addWidget(label, 1, 0); 14 layout->addWidget(label, 1, 0);
15 layout->addWidget(m_hostname, 1, 1); 15 layout->addWidget(m_hostname, 1, 1);
16 label = new QLabel(tr("Port :"), this); 16 label = new QLabel(tr("Port :"), this);
17 m_port = new QLineEdit(QString::number(server.port()), this); 17 m_port = new QLineEdit(QString::number(server.port()), this);
18 layout->addWidget(label, 2, 0); 18 layout->addWidget(label, 2, 0);
19 layout->addWidget(m_port, 2, 1); 19 layout->addWidget(m_port, 2, 1);
20 label = new QLabel(tr("Nickname :"), this); 20 label = new QLabel(tr("Nickname :"), this);
21 m_nickname = new QLineEdit(server.nick(), this); 21 m_nickname = new QLineEdit(server.nick(), this);
22 layout->addWidget(label, 3, 0); 22 layout->addWidget(label, 3, 0);
23 layout->addWidget(m_nickname, 3, 1); 23 layout->addWidget(m_nickname, 3, 1);
24 label = new QLabel(tr("Realname :"), this); 24 label = new QLabel(tr("Realname :"), this);
25 m_realname = new QLineEdit(server.realname(), this); 25 m_realname = new QLineEdit(server.realname(), this);
26 layout->addWidget(label, 4, 0); 26 layout->addWidget(label, 4, 0);
27 layout->addWidget(m_realname, 4, 1); 27 layout->addWidget(m_realname, 4, 1);
28 label = new QLabel(tr("Password :"), this); 28 label = new QLabel(tr("Password :"), this);
29 m_password = new QLineEdit(server.password(), this); 29 m_password = new QLineEdit(server.password(), this);
30 layout->addWidget(label, 5, 0); 30 layout->addWidget(label, 5, 0);
31 layout->addWidget(m_password, 5, 1); 31 layout->addWidget(m_password, 5, 1);
32 label = new QLabel(tr("Channels :"), this); 32 label = new QLabel(tr("Channels :"), this);
33 m_channels = new QLineEdit(server.channels(), this); 33 m_channels = new QLineEdit(server.channels(), this);
34 layout->addWidget(label, 6, 0); 34 layout->addWidget(label, 6, 0);
35 layout->addWidget(m_channels, 6, 1); 35 layout->addWidget(m_channels, 6, 1);
36 setCaption(tr("Edit server information")); 36 setCaption(tr("Edit server information"));
37 showMaximized(); 37 showMaximized();
38} 38}
39 39
40 40
41void IRCServerEditor::accept() { 41void IRCServerEditor::accept() {
42 if (m_name->text().length()==0) 42 if (m_name->text().length()==0)
43 QMessageBox::critical(this, tr("Error"), tr("Profile name required")); 43 QMessageBox::critical(this, tr("Error"), tr("Profile name required"));
44 else if (m_hostname->text().length()==0) 44 else if (m_hostname->text().length()==0)
45 QMessageBox::critical(this, tr("Error"), tr("Host name required")); 45 QMessageBox::critical(this, tr("Error"), tr("Host name required"));
46 else if (m_port->text().toInt()<=0) 46 else if (m_port->text().toInt()<=0)
47 QMessageBox::critical(this, tr("Error"), tr("Port required")); 47 QMessageBox::critical(this, tr("Error"), tr("Port required"));
48 else if (m_nickname->text().length()==0) 48 else if (m_nickname->text().length()==0)
49 QMessageBox::critical(this, tr("Error"), tr("Nickname required")); 49 QMessageBox::critical(this, tr("Error"), tr("Nickname required"));
50 else if (m_realname->text().length()==0) 50 else if (m_realname->text().length()==0)
51 QMessageBox::critical(this, tr("Error"), tr("Realname required")); 51 QMessageBox::critical(this, tr("Error"), tr("Realname required"));
52 else { 52 else {
53 /* Now verify whether the channel list has a valid format */ 53 /* Now verify whether the channel list has a valid format */
54 QStringList channels = QStringList::split(QChar(','), m_channels->text()); 54 QStringList channels = QStringList::split(QChar(','), m_channels->text());
55 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { 55 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
56 QString channelName = (*it).stripWhiteSpace(); 56 QString channelName = (*it).stripWhiteSpace();
57 if (!channelName.startsWith("#")) { 57 if (!channelName.startsWith("#") && !channelName.startsWith("+")) {
58 QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'")); 58 QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with either '#' or '+'"));
59 return; 59 return;
60 } 60 }
61 } 61 }
62 QDialog::accept(); 62 QDialog::accept();
63 } 63 }
64} 64}
65 65
66IRCServer IRCServerEditor::getServer() { 66IRCServer IRCServerEditor::getServer() {
67 IRCServer server; 67 IRCServer server;
68 server.setName(m_name->text()); 68 server.setName(m_name->text());
69 server.setHostname(m_hostname->text()); 69 server.setHostname(m_hostname->text());
70 server.setPort(m_port->text().toInt()); 70 server.setPort(m_port->text().toInt());
71 server.setNick(m_nickname->text()); 71 server.setNick(m_nickname->text());
72 server.setRealname(m_realname->text()); 72 server.setRealname(m_realname->text());
73 server.setUsername(m_nickname->text()); 73 server.setUsername(m_nickname->text());
74 server.setPassword(m_password->text()); 74 server.setPassword(m_password->text());
75 server.setChannels(m_channels->text()); 75 server.setChannels(m_channels->text());
76 return server; 76 return server;
77} 77}
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index aea58a3..d16c05f 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,167 +1,167 @@
1#include <qpe/config.h> 1#include <qpe/config.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include "ircservertab.h" 3#include "ircservertab.h"
4 4
5IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 5IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_server = server; 6 m_server = server;
7 m_session = new IRCSession(&m_server); 7 m_session = new IRCSession(&m_server);
8 m_mainWindow = mainWindow; 8 m_mainWindow = mainWindow;
9 m_close = FALSE; 9 m_close = FALSE;
10 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); 10 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
11 m_textview = new QTextView(this); 11 m_textview = new QTextView(this);
12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
14 m_textview->setTextFormat(RichText); 14 m_textview->setTextFormat(RichText);
15 m_layout->add(m_textview); 15 m_layout->add(m_textview);
16 m_field = new QLineEdit(this); 16 m_field = new QLineEdit(this);
17 m_layout->add(m_field); 17 m_layout->add(m_field);
18 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 18 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
19 m_field->setFocus(); 19 m_field->setFocus();
20 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 20 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
21 settingsChanged(); 21 settingsChanged();
22} 22}
23 23
24void IRCServerTab::appendText(QString text) { 24void IRCServerTab::appendText(QString text) {
25 /* not using append because it creates layout problems */ 25 /* not using append because it creates layout problems */
26 m_textview->setText(m_textview->text() + text); 26 m_textview->setText(m_textview->text() + text);
27 m_textview->ensureVisible(0, m_textview->contentsHeight()); 27 m_textview->ensureVisible(0, m_textview->contentsHeight());
28} 28}
29 29
30IRCServerTab::~IRCServerTab() { 30IRCServerTab::~IRCServerTab() {
31 delete m_session; 31 delete m_session;
32} 32}
33 33
34void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 34void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
35 m_channelTabs.remove(tab); 35 m_channelTabs.remove(tab);
36} 36}
37 37
38void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 38void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
39 m_queryTabs.remove(tab); 39 m_queryTabs.remove(tab);
40} 40}
41 41
42void IRCServerTab::addQueryTab(IRCQueryTab *tab) { 42void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
43 m_queryTabs.append(tab); 43 m_queryTabs.append(tab);
44} 44}
45 45
46QString IRCServerTab::title() { 46QString IRCServerTab::title() {
47 return "Server"; 47 return "Server";
48} 48}
49 49
50IRCSession *IRCServerTab::session() { 50IRCSession *IRCServerTab::session() {
51 return m_session; 51 return m_session;
52} 52}
53 53
54IRCServer *IRCServerTab::server() { 54IRCServer *IRCServerTab::server() {
55 return &m_server; 55 return &m_server;
56} 56}
57 57
58void IRCServerTab::settingsChanged() { 58void IRCServerTab::settingsChanged() {
59 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 59 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
60} 60}
61 61
62void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 62void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
63 QTextIStream stream(&line); 63 QTextIStream stream(&line);
64 QString command; 64 QString command;
65 stream >> command; 65 stream >> command;
66 command = command.upper().right(command.length()-1); 66 command = command.upper().right(command.length()-1);
67 67
68 if (command == "JOIN") { 68 if (command == "JOIN") {
69 QString channel; 69 QString channel;
70 stream >> channel; 70 stream >> channel;
71 if (channel.length() > 0 && channel.startsWith("#")) { 71 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {
72 m_session->join(channel); 72 m_session->join(channel);
73 } else { 73 } else {
74 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); 74 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
75 } 75 }
76 } else if (command == "ME") { 76 } else if (command == "ME") {
77 QString text = line.right(line.length()-4); 77 QString text = line.right(line.length()-4);
78 if (text.length() > 0) { 78 if (text.length() > 0) {
79 if (tab->isA("IRCChannelTab")) { 79 if (tab->isA("IRCChannelTab")) {
80 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 80 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
81 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); 81 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
82 } else if (tab->isA("IRCQueryTab")) { 82 } else if (tab->isA("IRCQueryTab")) {
83 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 83 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
84 m_session->sendAction(((IRCQueryTab *)tab)->person(), text); 84 m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
85 } else { 85 } else {
86 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); 86 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
87 } 87 }
88 } 88 }
89 } else if (command == "MSG") { 89 } else if (command == "MSG") {
90 QString nickname; 90 QString nickname;
91 stream >> nickname; 91 stream >> nickname;
92 if (nickname.length() > 0) { 92 if (nickname.length() > 0) {
93 if (line.length() > 6 + nickname.length()) { 93 if (line.length() > 6 + nickname.length()) {
94 QString text = line.right(line.length()-nickname.length()-6); 94 QString text = line.right(line.length()-nickname.length()-6);
95 IRCPerson person; 95 IRCPerson person;
96 person.setNick(nickname); 96 person.setNick(nickname);
97 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>"); 97 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>");
98 m_session->sendMessage(&person, text); 98 m_session->sendMessage(&person, text);
99 } 99 }
100 } 100 }
101 } else { 101 } else {
102 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); 102 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
103 } 103 }
104} 104}
105 105
106void IRCServerTab::processCommand() { 106void IRCServerTab::processCommand() {
107 QString text = m_field->text(); 107 QString text = m_field->text();
108 if (text.startsWith("/") && !text.startsWith("//")) { 108 if (text.startsWith("/") && !text.startsWith("//")) {
109 /* Command mode */ 109 /* Command mode */
110 executeCommand(this, text); 110 executeCommand(this, text);
111 } 111 }
112 m_field->clear(); 112 m_field->clear();
113} 113}
114 114
115void IRCServerTab::doConnect() { 115void IRCServerTab::doConnect() {
116 m_session->beginSession(); 116 m_session->beginSession();
117} 117}
118 118
119void IRCServerTab::remove() { 119void IRCServerTab::remove() {
120 /* Close requested */ 120 /* Close requested */
121 if (m_session->isSessionActive()) { 121 if (m_session->isSessionActive()) {
122 /* While there is a running session */ 122 /* While there is a running session */
123 m_close = TRUE; 123 m_close = TRUE;
124 m_session->endSession(); 124 m_session->endSession();
125 } else { 125 } else {
126 /* Session has previously been closed */ 126 /* Session has previously been closed */
127 m_channelTabs.first(); 127 m_channelTabs.first();
128 while (m_channelTabs.current() != 0) { 128 while (m_channelTabs.current() != 0) {
129 m_mainWindow->killTab(m_channelTabs.current()); 129 m_mainWindow->killTab(m_channelTabs.current());
130 } 130 }
131 m_queryTabs.first(); 131 m_queryTabs.first();
132 while (m_queryTabs.current() != 0) { 132 while (m_queryTabs.current() != 0) {
133 m_mainWindow->killTab(m_queryTabs.current()); 133 m_mainWindow->killTab(m_queryTabs.current());
134 } 134 }
135 m_mainWindow->killTab(this); 135 m_mainWindow->killTab(this);
136 } 136 }
137} 137}
138 138
139IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 139IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
140 QListIterator<IRCChannelTab> it(m_channelTabs); 140 QListIterator<IRCChannelTab> it(m_channelTabs);
141 141
142 for (; it.current(); ++it) { 142 for (; it.current(); ++it) {
143 if (it.current()->channel() == channel) 143 if (it.current()->channel() == channel)
144 return it.current(); 144 return it.current();
145 } 145 }
146 return 0; 146 return 0;
147} 147}
148 148
149IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { 149IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
150 QListIterator<IRCQueryTab> it(m_queryTabs); 150 QListIterator<IRCQueryTab> it(m_queryTabs);
151 151
152 for (; it.current(); ++it) { 152 for (; it.current(); ++it) {
153 if (it.current()->person()->nick() == person->nick()) 153 if (it.current()->person()->nick() == person->nick())
154 return it.current(); 154 return it.current();
155 } 155 }
156 return 0; 156 return 0;
157} 157}
158 158
159void IRCServerTab::display(IRCOutput output) { 159void IRCServerTab::display(IRCOutput output) {
160 160
161 /* All messages to be displayed inside the GUI get here */ 161 /* All messages to be displayed inside the GUI get here */
162 switch (output.type()) { 162 switch (output.type()) {
163 case OUTPUT_CONNCLOSE: 163 case OUTPUT_CONNCLOSE:
164 if (m_close) { 164 if (m_close) {
165 m_channelTabs.first(); 165 m_channelTabs.first();
166 while (m_channelTabs.current() != 0) { 166 while (m_channelTabs.current() != 0) {
167 m_mainWindow->killTab(m_channelTabs.current()); 167 m_mainWindow->killTab(m_channelTabs.current());