summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircservertab.cpp2
-rw-r--r--noncore/net/opieirc/ircsession.cpp3
-rw-r--r--noncore/net/opieirc/ircsession.h3
3 files changed, 5 insertions, 3 deletions
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index bddc37e..62a06e8 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,415 +1,415 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include <qwhatsthis.h> 2#include <qwhatsthis.h>
3 3
4#include "ircservertab.h" 4#include "ircservertab.h"
5#include "ircmessageparser.h" 5#include "ircmessageparser.h"
6#include "ircchannelperson.h" 6#include "ircchannelperson.h"
7 7
8 8
9bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) { 9bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) {
10 return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) || 10 return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) ||
11 (text.find("ping") != -1 && text.find( tab->server()->nick() != -1)); 11 (text.find("ping") != -1 && text.find( tab->server()->nick() != -1));
12} 12}
13 13
14 14
15IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 15IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
16 m_server = server; 16 m_server = server;
17 m_session = new IRCSession(&m_server); 17 m_session = new IRCSession(this, &m_server);
18 m_mainWindow = mainWindow; 18 m_mainWindow = mainWindow;
19 m_close = FALSE; 19 m_close = FALSE;
20 m_lines = 0; 20 m_lines = 0;
21 m_description->setText(tr("Connecting to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); 21 m_description->setText(tr("Connecting to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
22 m_textview = new QTextView(this); 22 m_textview = new QTextView(this);
23 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 23 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
24 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 24 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
25 m_textview->setTextFormat(RichText); 25 m_textview->setTextFormat(RichText);
26 QWhatsThis::add(m_textview, tr("Server messages")); 26 QWhatsThis::add(m_textview, tr("Server messages"));
27 m_layout->add(m_textview); 27 m_layout->add(m_textview);
28 m_field = new IRCHistoryLineEdit(this); 28 m_field = new IRCHistoryLineEdit(this);
29 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab())); 29 connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
30 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab())); 30 connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
31 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab())); 31 connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab()));
32 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus())); 32 connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
33 33
34 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); 34 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
35 m_layout->add(m_field); 35 m_layout->add(m_field);
36 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 36 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
37 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 37 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
38 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 38 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
39 connect(m_session, SIGNAL(updateChannels()), this, SLOT(slotUpdateChannels())); 39 connect(m_session, SIGNAL(updateChannels()), this, SLOT(slotUpdateChannels()));
40 settingsChanged(); 40 settingsChanged();
41 41
42 m_field->setFocus(); 42 m_field->setFocus();
43 m_field->setActiveWindow(); 43 m_field->setActiveWindow();
44 44
45} 45}
46 46
47void IRCServerTab::scrolling(){ 47void IRCServerTab::scrolling(){
48 m_textview->ensureVisible(0, m_textview->contentsHeight()); 48 m_textview->ensureVisible(0, m_textview->contentsHeight());
49} 49}
50 50
51 51
52void IRCServerTab::appendText(QString text) { 52void IRCServerTab::appendText(QString text) {
53 /* not using append because it creates layout problems */ 53 /* not using append because it creates layout problems */
54 QString txt = m_textview->text() + IRCTab::appendTimestamp( text ); 54 QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
55 55
56 56
57 57
58 if (m_maxLines > 0 && m_lines >= m_maxLines) { 58 if (m_maxLines > 0 && m_lines >= m_maxLines) {
59 int firstBreak = txt.find('\n'); 59 int firstBreak = txt.find('\n');
60 if (firstBreak != -1) { 60 if (firstBreak != -1) {
61 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 61 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
62 } 62 }
63 } else { 63 } else {
64 m_lines++; 64 m_lines++;
65 } 65 }
66 m_textview->setText(txt); 66 m_textview->setText(txt);
67 m_textview->ensureVisible(0, m_textview->contentsHeight()); 67 m_textview->ensureVisible(0, m_textview->contentsHeight());
68 emit changed(this); 68 emit changed(this);
69} 69}
70 70
71IRCServerTab::~IRCServerTab() { 71IRCServerTab::~IRCServerTab() {
72 delete m_session; 72 delete m_session;
73} 73}
74 74
75void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 75void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
76 m_channelTabs.remove(tab); 76 m_channelTabs.remove(tab);
77} 77}
78 78
79void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 79void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
80 m_queryTabs.remove(tab); 80 m_queryTabs.remove(tab);
81} 81}
82 82
83void IRCServerTab::addQueryTab(IRCQueryTab *tab) { 83void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
84 m_queryTabs.append(tab); 84 m_queryTabs.append(tab);
85} 85}
86 86
87QString IRCServerTab::title() { 87QString IRCServerTab::title() {
88 return "Server"; 88 return "Server";
89} 89}
90 90
91IRCSession *IRCServerTab::session() { 91IRCSession *IRCServerTab::session() {
92 return m_session; 92 return m_session;
93} 93}
94/* 94/*
95QString *IRCServerTab::mynick() { 95QString *IRCServerTab::mynick() {
96 return (*m_server->nick()); 96 return (*m_server->nick());
97} */ 97} */
98 98
99IRCServer *IRCServerTab::server() { 99IRCServer *IRCServerTab::server() {
100 return &m_server; 100 return &m_server;
101} 101}
102 102
103void IRCServerTab::settingsChanged() { 103void IRCServerTab::settingsChanged() {
104 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 104 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
105 m_lines = 0; 105 m_lines = 0;
106} 106}
107 107
108void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 108void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
109 QTextIStream stream(&line); 109 QTextIStream stream(&line);
110 QString command; 110 QString command;
111 stream >> command; 111 stream >> command;
112 command = command.upper().right(command.length()-1); 112 command = command.upper().right(command.length()-1);
113 113
114 //JOIN 114 //JOIN
115 if (command == "JOIN" || command == "J") { 115 if (command == "JOIN" || command == "J") {
116 QString channel; 116 QString channel;
117 stream >> channel; 117 stream >> channel;
118 /* According to RFC 1459 */ 118 /* According to RFC 1459 */
119 if (channel.length() > 0 && channel.length() < 200 && 119 if (channel.length() > 0 && channel.length() < 200 &&
120 channel.find(",") == -1 && channel.find("") == -1) { 120 channel.find(",") == -1 && channel.find("") == -1) {
121 121
122 if (!channel.startsWith("#") && !channel.startsWith("&")) { 122 if (!channel.startsWith("#") && !channel.startsWith("&")) {
123 channel = channel.prepend("#"); 123 channel = channel.prepend("#");
124 } 124 }
125 m_session->join(channel); 125 m_session->join(channel);
126 } else { 126 } else {
127 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); 127 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
128 } 128 }
129 } 129 }
130 130
131 //KICK 131 //KICK
132 else if (command == "KICK"){ 132 else if (command == "KICK"){
133 QString nickname; 133 QString nickname;
134 stream >> nickname; 134 stream >> nickname;
135 if (nickname.length() > 0) { 135 if (nickname.length() > 0) {
136 if (line.length() > 7 + nickname.length()) { 136 if (line.length() > 7 + nickname.length()) {
137 QString text = line.right(line.length()-nickname.length()-7); 137 QString text = line.right(line.length()-nickname.length()-7);
138 IRCPerson person; 138 IRCPerson person;
139 person.setNick(nickname); 139 person.setNick(nickname);
140 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text); 140 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
141 } else { 141 } else {
142 IRCPerson person; 142 IRCPerson person;
143 person.setNick(nickname); 143 person.setNick(nickname);
144 m_session->kick(((IRCChannelTab *)tab)->channel(), &person); 144 m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
145 } 145 }
146 } 146 }
147 } 147 }
148 148
149 else if (command == "OP"){ 149 else if (command == "OP"){
150 QString nickname; 150 QString nickname;
151 stream >> nickname; 151 stream >> nickname;
152 if (nickname.length() > 0) { 152 if (nickname.length() > 0) {
153 QString text = line.right(line.length()-nickname.length()-5); 153 QString text = line.right(line.length()-nickname.length()-5);
154 IRCPerson person; 154 IRCPerson person;
155 person.setNick(nickname); 155 person.setNick(nickname);
156 m_session->op(((IRCChannelTab *)tab)->channel(), &person); 156 m_session->op(((IRCChannelTab *)tab)->channel(), &person);
157 } 157 }
158 } 158 }
159 159
160 //SEND MODES 160 //SEND MODES
161 else if (command == "MODE"){ 161 else if (command == "MODE"){
162 QString text = line.right(line.length()-6); 162 QString text = line.right(line.length()-6);
163 if (text.length() > 0) { 163 if (text.length() > 0) {
164 m_session->mode(text); 164 m_session->mode(text);
165 } else { 165 } else {
166 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>"); 166 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>");
167 } 167 }
168 } 168 }
169 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want 169 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want
170 else if (command == "RAW"){ 170 else if (command == "RAW"){
171 QString text = line.right(line.length()-5); 171 QString text = line.right(line.length()-5);
172 if (text.length() > 0) { 172 if (text.length() > 0) {
173 m_session->raw(text); 173 m_session->raw(text);
174 } 174 }
175 } 175 }
176 else if (command == "SUSPEND"){ 176 else if (command == "SUSPEND"){
177 QString text = line.right(line.length()-9); 177 QString text = line.right(line.length()-9);
178 if (text.upper() == "ON") { 178 if (text.upper() == "ON") {
179 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 179 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
180 } 180 }
181 else if (text.upper() == "OFF"){ 181 else if (text.upper() == "OFF"){
182 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 182 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
183 } else { 183 } else {
184 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text); 184 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text);
185 } 185 }
186 } 186 }
187 187
188 else if (command == "QUIT"){ 188 else if (command == "QUIT"){
189 QString text = line.right(line.length()-6); 189 QString text = line.right(line.length()-6);
190 if (text.length() > 0) { 190 if (text.length() > 0) {
191 m_session->quit(text); 191 m_session->quit(text);
192 } else { 192 } else {
193 m_session->quit(); 193 m_session->quit();
194 } 194 }
195 } 195 }
196 196
197 //SEND ACTION 197 //SEND ACTION
198 else if (command == "ME") { 198 else if (command == "ME") {
199 QString text = line.right(line.length()-4); 199 QString text = line.right(line.length()-4);
200 if (text.length() > 0) { 200 if (text.length() > 0) {
201 if (tab->isA("IRCChannelTab")) { 201 if (tab->isA("IRCChannelTab")) {
202 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 202 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
203 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); 203 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
204 } else if (tab->isA("IRCQueryTab")) { 204 } else if (tab->isA("IRCQueryTab")) {
205 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 205 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
206 m_session->sendAction(((IRCQueryTab *)tab)->person(), text); 206 m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
207 } else { 207 } else {
208 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); 208 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
209 } 209 }
210 } 210 }
211 } 211 }
212 //SEND PRIVMSG 212 //SEND PRIVMSG
213 else if (command == "MSG") { 213 else if (command == "MSG") {
214 QString nickname; 214 QString nickname;
215 stream >> nickname; 215 stream >> nickname;
216 if (nickname.length() > 0) { 216 if (nickname.length() > 0) {
217 if (line.length() > 6 + nickname.length()) { 217 if (line.length() > 6 + nickname.length()) {
218 QString text = line.right(line.length()-nickname.length()-6); 218 QString text = line.right(line.length()-nickname.length()-6);
219 IRCPerson person; 219 IRCPerson person;
220 person.setNick(nickname); 220 person.setNick(nickname);
221 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>"); 221 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>");
222 m_session->sendMessage(&person, text); 222 m_session->sendMessage(&person, text);
223 } 223 }
224 } 224 }
225 } 225 }
226 else { 226 else {
227 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); 227 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
228 } 228 }
229} 229}
230 230
231void IRCServerTab::processCommand() { 231void IRCServerTab::processCommand() {
232 QString text = m_field->text(); 232 QString text = m_field->text();
233 if (text.startsWith("/") && !text.startsWith("//")) { 233 if (text.startsWith("/") && !text.startsWith("//")) {
234 /* Command mode */ 234 /* Command mode */
235 executeCommand(this, text); 235 executeCommand(this, text);
236 } 236 }
237 m_field->clear(); 237 m_field->clear();
238} 238}
239 239
240void IRCServerTab::doConnect() { 240void IRCServerTab::doConnect() {
241 m_session->beginSession(); 241 m_session->beginSession();
242} 242}
243 243
244void IRCServerTab::remove() { 244void IRCServerTab::remove() {
245 /* Close requested */ 245 /* Close requested */
246 if (m_session->isSessionActive()) { 246 if (m_session->isSessionActive()) {
247 /* While there is a running session */ 247 /* While there is a running session */
248 m_close = TRUE; 248 m_close = TRUE;
249 m_session->endSession(); 249 m_session->endSession();
250 } else { 250 } else {
251 /* Session has previously been closed */ 251 /* Session has previously been closed */
252 m_channelTabs.first(); 252 m_channelTabs.first();
253 while (m_channelTabs.current() != 0) { 253 while (m_channelTabs.current() != 0) {
254 m_mainWindow->killTab(m_channelTabs.current(), true); 254 m_mainWindow->killTab(m_channelTabs.current(), true);
255 } 255 }
256 m_queryTabs.first(); 256 m_queryTabs.first();
257 while (m_queryTabs.current() != 0) { 257 while (m_queryTabs.current() != 0) {
258 m_mainWindow->killTab(m_queryTabs.current(), true); 258 m_mainWindow->killTab(m_queryTabs.current(), true);
259 } 259 }
260 m_mainWindow->killTab(this); 260 m_mainWindow->killTab(this);
261 } 261 }
262} 262}
263 263
264IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 264IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
265 QListIterator<IRCChannelTab> it(m_channelTabs); 265 QListIterator<IRCChannelTab> it(m_channelTabs);
266 266
267 for (; it.current(); ++it) { 267 for (; it.current(); ++it) {
268 if (it.current()->channel() == channel) 268 if (it.current()->channel() == channel)
269 return it.current(); 269 return it.current();
270 } 270 }
271 return 0; 271 return 0;
272} 272}
273 273
274IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { 274IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
275 QListIterator<IRCQueryTab> it(m_queryTabs); 275 QListIterator<IRCQueryTab> it(m_queryTabs);
276 276
277 for (; it.current(); ++it) { 277 for (; it.current(); ++it) {
278 if (it.current()->person()->nick() == person->nick()) 278 if (it.current()->person()->nick() == person->nick())
279 return it.current(); 279 return it.current();
280 } 280 }
281 return 0; 281 return 0;
282} 282}
283 283
284void IRCServerTab::display(IRCOutput output) { 284void IRCServerTab::display(IRCOutput output) {
285 285
286 /* All messages to be displayed inside the GUI get here */ 286 /* All messages to be displayed inside the GUI get here */
287 switch (output.type()) { 287 switch (output.type()) {
288 case OUTPUT_CONNCLOSE: 288 case OUTPUT_CONNCLOSE:
289 if (m_close) { 289 if (m_close) {
290 m_channelTabs.first(); 290 m_channelTabs.first();
291 while (m_channelTabs.current() != 0) { 291 while (m_channelTabs.current() != 0) {
292 m_mainWindow->killTab(m_channelTabs.current(), true); 292 m_mainWindow->killTab(m_channelTabs.current(), true);
293 } 293 }
294 m_queryTabs.first(); 294 m_queryTabs.first();
295 while (m_queryTabs.current() != 0) { 295 while (m_queryTabs.current() != 0) {
296 m_mainWindow->killTab(m_queryTabs.current(), true); 296 m_mainWindow->killTab(m_queryTabs.current(), true);
297 } 297 }
298 m_mainWindow->killTab(this); 298 m_mainWindow->killTab(this);
299 } else { 299 } else {
300 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); 300 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
301 QListIterator<IRCChannelTab> it(m_channelTabs); 301 QListIterator<IRCChannelTab> it(m_channelTabs);
302 for (; it.current(); ++it) { 302 for (; it.current(); ++it) {
303 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); 303 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>");
304 } 304 }
305 } 305 }
306 break; 306 break;
307 case OUTPUT_SELFJOIN: { 307 case OUTPUT_SELFJOIN: {
308 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 308 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
309 m_channelTabs.append(channeltab); 309 m_channelTabs.append(channeltab);
310 m_mainWindow->addTab(channeltab); 310 m_mainWindow->addTab(channeltab);
311 } 311 }
312 break; 312 break;
313 case OUTPUT_CHANPRIVMSG: { 313 case OUTPUT_CHANPRIVMSG: {
314 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 314 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
315 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>"); 315 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>");
316 } 316 }
317 break; 317 break;
318 case OUTPUT_QUERYACTION: 318 case OUTPUT_QUERYACTION:
319 case OUTPUT_QUERYPRIVMSG: { 319 case OUTPUT_QUERYPRIVMSG: {
320 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); 320 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
321 if (!queryTab) { 321 if (!queryTab) {
322 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 322 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
323 m_queryTabs.append(queryTab); 323 m_queryTabs.append(queryTab);
324 m_mainWindow->addTab(queryTab); 324 m_mainWindow->addTab(queryTab);
325 } 325 }
326 queryTab->display(output); 326 queryTab->display(output);
327 } 327 }
328 break; 328 break;
329 case OUTPUT_SELFPART: { 329 case OUTPUT_SELFPART: {
330 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 330 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
331 if (channelTab) 331 if (channelTab)
332 m_mainWindow->killTab(channelTab, true); 332 m_mainWindow->killTab(channelTab, true);
333 } 333 }
334 break; 334 break;
335 case OUTPUT_SELFKICK: { 335 case OUTPUT_SELFKICK: {
336 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 336 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
337 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 337 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
338 if (channelTab) 338 if (channelTab)
339 m_mainWindow->killTab(channelTab, true); 339 m_mainWindow->killTab(channelTab, true);
340 } 340 }
341 break; 341 break;
342 case OUTPUT_CHANACTION: { 342 case OUTPUT_CHANACTION: {
343 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 343 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
344 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); 344 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
345 } 345 }
346 break; 346 break;
347 case OUTPUT_TOPIC: { 347 case OUTPUT_TOPIC: {
348 IRCChannel *channel = (IRCChannel *) output.getParam(0); 348 IRCChannel *channel = (IRCChannel *) output.getParam(0);
349 if (channel) { 349 if (channel) {
350 IRCChannelTab *channelTab = getTabForChannel(channel); 350 IRCChannelTab *channelTab = getTabForChannel(channel);
351 if (channelTab) { 351 if (channelTab) {
352 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 352 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
353 return; 353 return;
354 } 354 }
355 } 355 }
356 IRCChannelTab::enqueue(channel->channelname(), "<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 356 IRCChannelTab::enqueue(channel->channelname(), "<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
357 } 357 }
358 break; 358 break;
359 case OUTPUT_QUIT: { 359 case OUTPUT_QUIT: {
360 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 360 QString nick = ((IRCPerson *)output.getParam(0))->nick();
361 QListIterator<IRCChannelTab> it(m_channelTabs); 361 QListIterator<IRCChannelTab> it(m_channelTabs);
362 for (; it.current(); ++it) { 362 for (; it.current(); ++it) {
363 if (it.current()->list()->hasPerson(nick)) { 363 if (it.current()->list()->hasPerson(nick)) {
364 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 364 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
365 it.current()->list()->update(); 365 it.current()->list()->update();
366 } 366 }
367 } 367 }
368 } 368 }
369 break; 369 break;
370 case OUTPUT_NICKCHANGE: { 370 case OUTPUT_NICKCHANGE: {
371 QString *nick = static_cast<QString*>(output.getParam(0)); 371 QString *nick = static_cast<QString*>(output.getParam(0));
372 if(!nick) { 372 if(!nick) {
373 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 373 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
374 break; 374 break;
375 } 375 }
376 QListIterator<IRCChannelTab> it(m_channelTabs); 376 QListIterator<IRCChannelTab> it(m_channelTabs);
377 for (; it.current(); ++it) { 377 for (; it.current(); ++it) {
378 if (it.current()->list()->hasPerson(*nick)) { 378 if (it.current()->list()->hasPerson(*nick)) {
379 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 379 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
380 } 380 }
381 } 381 }
382 delete nick; 382 delete nick;
383 } 383 }
384 break; 384 break;
385 case OUTPUT_OTHERJOIN: 385 case OUTPUT_OTHERJOIN:
386 case OUTPUT_OTHERKICK: 386 case OUTPUT_OTHERKICK:
387 case OUTPUT_CHANPERSONMODE: 387 case OUTPUT_CHANPERSONMODE:
388 case OUTPUT_OTHERPART: { 388 case OUTPUT_OTHERPART: {
389 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 389 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
390 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 390 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
391 channelTab->list()->update(); 391 channelTab->list()->update();
392 } 392 }
393 break; 393 break;
394 case OUTPUT_CTCP: 394 case OUTPUT_CTCP:
395 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); 395 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
396 break; 396 break;
397 case OUTPUT_ERROR: 397 case OUTPUT_ERROR:
398 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 398 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
399 break; 399 break;
400 case OUTPUT_TITLE: 400 case OUTPUT_TITLE:
401 m_description->setText(output.message()); 401 m_description->setText(output.message());
402 break; 402 break;
403 default: 403 default:
404 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); 404 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>");
405 break; 405 break;
406 } 406 }
407} 407}
408 408
409void IRCServerTab::slotUpdateChannels() { 409void IRCServerTab::slotUpdateChannels() {
410 QListIterator<IRCChannelTab> it(m_channelTabs); 410 QListIterator<IRCChannelTab> it(m_channelTabs);
411 for (; it.current(); ++it) { 411 for (; it.current(); ++it) {
412 it.current()->list()->update(); 412 it.current()->list()->update();
413 } 413 }
414} 414}
415 415
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp
index 80a327a..fd8ba72 100644
--- a/noncore/net/opieirc/ircsession.cpp
+++ b/noncore/net/opieirc/ircsession.cpp
@@ -1,214 +1,215 @@
1 1
2#include "ircsession.h" 2#include "ircsession.h"
3#include "ircmessageparser.h" 3#include "ircmessageparser.h"
4#include "ircchannelperson.h" 4#include "ircchannelperson.h"
5#include "ircversion.h" 5#include "ircversion.h"
6 6
7IRCSession::IRCSession(IRCServer *server) { 7IRCSession::IRCSession(QWidget *parent, IRCServer *server) {
8 m_server = server; 8 m_server = server;
9 m_connection = new IRCConnection(m_server); 9 m_connection = new IRCConnection(m_server);
10 m_parser = new IRCMessageParser(this); 10 m_parser = new IRCMessageParser(this);
11 m_parent = parent;
11 connect(m_connection, SIGNAL(messageArrived(IRCMessage*)), this, SLOT(handleMessage(IRCMessage*))); 12 connect(m_connection, SIGNAL(messageArrived(IRCMessage*)), this, SLOT(handleMessage(IRCMessage*)));
12 connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); 13 connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
13 connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); 14 connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
14} 15}
15 16
16IRCSession::~IRCSession() { 17IRCSession::~IRCSession() {
17 /* We want this to get deleted automatically */ 18 /* We want this to get deleted automatically */
18 m_channels.setAutoDelete(TRUE); 19 m_channels.setAutoDelete(TRUE);
19 m_people.setAutoDelete(TRUE); 20 m_people.setAutoDelete(TRUE);
20 21
21 delete m_parser; 22 delete m_parser;
22 delete m_connection; 23 delete m_connection;
23} 24}
24 25
25void IRCSession::beginSession() { 26void IRCSession::beginSession() {
26 m_connection->doConnect(); 27 m_connection->doConnect();
27} 28}
28 29
29void IRCSession::join(QString channelname) { 30void IRCSession::join(QString channelname) {
30 m_connection->sendLine("JOIN " + channelname); 31 m_connection->sendLine("JOIN " + channelname);
31} 32}
32 33
33void IRCSession::quit(){ 34void IRCSession::quit(){
34 m_connection->sendLine("QUIT :[OI] I'm too good to need a reason"); 35 m_connection->sendLine("QUIT :[OI] I'm too good to need a reason");
35} 36}
36 37
37void IRCSession::quit(QString message){ 38void IRCSession::quit(QString message){
38 m_connection->sendLine("QUIT :" + message); 39 m_connection->sendLine("QUIT :" + message);
39} 40}
40 41
41void IRCSession::topic(IRCChannel *channel, QString message){ 42void IRCSession::topic(IRCChannel *channel, QString message){
42 m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message); 43 m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message);
43} 44}
44 45
45void IRCSession::mode(IRCChannel *channel, QString message){ 46void IRCSession::mode(IRCChannel *channel, QString message){
46 m_connection->sendLine("MODE " + channel->channelname() + " " + message); 47 m_connection->sendLine("MODE " + channel->channelname() + " " + message);
47} 48}
48 49
49void IRCSession::mode(IRCPerson *person, QString message){ 50void IRCSession::mode(IRCPerson *person, QString message){
50 m_connection->sendLine("MODE " + person->nick() + " " + message); 51 m_connection->sendLine("MODE " + person->nick() + " " + message);
51} 52}
52 53
53void IRCSession::mode(QString message){ 54void IRCSession::mode(QString message){
54 m_connection->sendLine("MODE " + message); 55 m_connection->sendLine("MODE " + message);
55} 56}
56 57
57void IRCSession::raw(QString message){ 58void IRCSession::raw(QString message){
58 m_connection->sendLine(message); 59 m_connection->sendLine(message);
59} 60}
60 61
61void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { 62void IRCSession::kick(IRCChannel *channel, IRCPerson *person) {
62 m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); 63 m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :0wn3d - no reason");
63} 64}
64 65
65void IRCSession::op(IRCChannel *channel, IRCPerson *person) { 66void IRCSession::op(IRCChannel *channel, IRCPerson *person) {
66 m_connection->sendLine("MODE " + channel->channelname() + " +ooo " + person->nick()); 67 m_connection->sendLine("MODE " + channel->channelname() + " +ooo " + person->nick());
67} 68}
68 69
69void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { 70void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) {
70 m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :" + message); 71 m_connection->sendLine("KICK " + channel->channelname() + " " + person->nick() +" :" + message);
71} 72}
72 73
73void IRCSession::sendMessage(IRCPerson *person, QString message) { 74void IRCSession::sendMessage(IRCPerson *person, QString message) {
74 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); 75 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message);
75} 76}
76 77
77void IRCSession::sendMessage(IRCChannel *channel, QString message) { 78void IRCSession::sendMessage(IRCChannel *channel, QString message) {
78 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); 79 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message);
79} 80}
80 81
81void IRCSession::sendAction(IRCChannel *channel, QString message) { 82void IRCSession::sendAction(IRCChannel *channel, QString message) {
82 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); 83 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001");
83} 84}
84 85
85void IRCSession::sendAction(IRCPerson *person, QString message) { 86void IRCSession::sendAction(IRCPerson *person, QString message) {
86 m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); 87 m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001");
87} 88}
88 89
89bool IRCSession::isSessionActive() { 90bool IRCSession::isSessionActive() {
90 return m_connection->isConnected(); 91 return m_connection->isConnected();
91} 92}
92 93
93bool IRCSession::isLoggedIn() { 94bool IRCSession::isLoggedIn() {
94 return m_connection->isLoggedIn(); 95 return m_connection->isLoggedIn();
95} 96}
96 97
97void IRCSession::endSession() { 98void IRCSession::endSession() {
98 if (m_connection->isLoggedIn()) 99 if (m_connection->isLoggedIn())
99 quit(APP_VERSION); 100 quit(APP_VERSION);
100 else 101 else
101 m_connection->close(); 102 m_connection->close();
102} 103}
103 104
104void IRCSession::part(IRCChannel *channel) { 105void IRCSession::part(IRCChannel *channel) {
105 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); 106 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION);
106} 107}
107 108
108void IRCSession::setValidUsermodes(const QString &modes) { 109void IRCSession::setValidUsermodes(const QString &modes) {
109 m_validUsermodes = modes; 110 m_validUsermodes = modes;
110} 111}
111 112
112void IRCSession::setValidChannelmodes(const QString &modes) { 113void IRCSession::setValidChannelmodes(const QString &modes) {
113 m_validChannelmodes = modes; 114 m_validChannelmodes = modes;
114} 115}
115 116
116void IRCSession::updateNickname(const QString &oldNickname, const QString &newNickname) { 117void IRCSession::updateNickname(const QString &oldNickname, const QString &newNickname) {
117 QList<IRCChannel> channels; 118 QList<IRCChannel> channels;
118 IRCOutput output; 119 IRCOutput output;
119 120
120 if (oldNickname == m_server->nick()) { 121 if (oldNickname == m_server->nick()) {
121 m_server->setNick(newNickname); 122 m_server->setNick(newNickname);
122 output = IRCOutput(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg(newNickname)); 123 output = IRCOutput(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg(newNickname));
123 channels = m_channels; 124 channels = m_channels;
124 } 125 }
125 126
126 else { 127 else {
127 IRCPerson *person = getPerson(oldNickname); 128 IRCPerson *person = getPerson(oldNickname);
128 129
129 if(!person) { 130 if(!person) {
130 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); 131 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
131 return; 132 return;
132 } 133 }
133 134
134 getChannelsByPerson(person, channels); 135 getChannelsByPerson(person, channels);
135 output = IRCOutput(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg(oldNickname).arg(newNickname)); 136 output = IRCOutput(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg(oldNickname).arg(newNickname));
136 } 137 }
137 138
138 QListIterator<IRCChannel> it(channels); 139 QListIterator<IRCChannel> it(channels);
139 for (;it.current(); ++it) { 140 for (;it.current(); ++it) {
140 IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname); 141 IRCChannelPerson *chanperson = it.current()->getPerson(oldNickname);
141 it.current()->removePerson(chanperson); 142 it.current()->removePerson(chanperson);
142 chanperson->setNick(newNickname); 143 chanperson->setNick(newNickname);
143 it.current()->addPerson(chanperson); 144 it.current()->addPerson(chanperson);
144 } 145 }
145 146
146 emit updateChannels(); 147 emit updateChannels();
147 output.addParam(new QString(newNickname)); 148 output.addParam(new QString(newNickname));
148 emit outputReady(output); 149 emit outputReady(output);
149} 150}
150 151
151IRCChannel *IRCSession::getChannel(QString channelname) { 152IRCChannel *IRCSession::getChannel(QString channelname) {
152 QListIterator<IRCChannel> it(m_channels); 153 QListIterator<IRCChannel> it(m_channels);
153 for (; it.current(); ++it) { 154 for (; it.current(); ++it) {
154 if (it.current()->channelname() == channelname) { 155 if (it.current()->channelname() == channelname) {
155 return it.current(); 156 return it.current();
156 } 157 }
157 } 158 }
158 return 0; 159 return 0;
159} 160}
160 161
161IRCPerson *IRCSession::getPerson(QString nickname) { 162IRCPerson *IRCSession::getPerson(QString nickname) {
162 QListIterator<IRCPerson> it(m_people); 163 QListIterator<IRCPerson> it(m_people);
163 for (; it.current(); ++it) { 164 for (; it.current(); ++it) {
164 if (it.current()->nick() == nickname) { 165 if (it.current()->nick() == nickname) {
165 return it.current(); 166 return it.current();
166 } 167 }
167 } 168 }
168 return 0; 169 return 0;
169} 170}
170 171
171void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) { 172void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) {
172 QListIterator<IRCChannel> it(m_channels); 173 QListIterator<IRCChannel> it(m_channels);
173 for (; it.current(); ++it) { 174 for (; it.current(); ++it) {
174 if (it.current()->getPerson(person->nick()) != 0) { 175 if (it.current()->getPerson(person->nick()) != 0) {
175 channels.append(it.current()); 176 channels.append(it.current());
176 } 177 }
177 } 178 }
178} 179}
179 180
180void IRCSession::addPerson(IRCPerson *person) { 181void IRCSession::addPerson(IRCPerson *person) {
181 m_people.append(person); 182 m_people.append(person);
182} 183}
183 184
184void IRCSession::addChannel(IRCChannel *channel) { 185void IRCSession::addChannel(IRCChannel *channel) {
185 m_channels.append(channel); 186 m_channels.append(channel);
186} 187}
187 188
188void IRCSession::removeChannel(IRCChannel *channel) { 189void IRCSession::removeChannel(IRCChannel *channel) {
189 m_channels.remove(channel); 190 m_channels.remove(channel);
190} 191}
191 192
192void IRCSession::removePerson(IRCPerson *person) { 193void IRCSession::removePerson(IRCPerson *person) {
193 m_people.remove(person); 194 m_people.remove(person);
194} 195}
195 196
196void IRCSession::handleMessage(IRCMessage *message) { 197void IRCSession::handleMessage(IRCMessage *message) {
197 m_parser->parse(message); 198 m_parser->parse(message);
198} 199}
199 200
200void IRCSession::whois(const QString &nickname) { 201void IRCSession::whois(const QString &nickname) {
201 m_connection->whois(nickname); 202 m_connection->whois(nickname);
202} 203}
203 204
204void IRCSession::sendCTCPPing(const QString &nickname) { 205void IRCSession::sendCTCPPing(const QString &nickname) {
205 m_connection->sendCTCPPing(nickname); 206 m_connection->sendCTCPPing(nickname);
206} 207}
207 208
208void IRCSession::sendCTCPRequest(const QString &nickname, const QString &type, const QString &args) { 209void IRCSession::sendCTCPRequest(const QString &nickname, const QString &type, const QString &args) {
209 m_connection->sendCTCPRequest(nickname, type, args); 210 m_connection->sendCTCPRequest(nickname, type, args);
210} 211}
211 212
212void IRCSession::sendCTCPReply(const QString &nickname, const QString &type, const QString &args) { 213void IRCSession::sendCTCPReply(const QString &nickname, const QString &type, const QString &args) {
213 m_connection->sendCTCPReply(nickname, type, args); 214 m_connection->sendCTCPReply(nickname, type, args);
214} 215}
diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h
index 3859b68..7c91893 100644
--- a/noncore/net/opieirc/ircsession.h
+++ b/noncore/net/opieirc/ircsession.h
@@ -1,95 +1,96 @@
1/* 1/*
2 OpieIRC - An embedded IRC client 2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob 3 Copyright (C) 2002 Wenzel Jakob
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18
19*/ 19*/
20 20
21#ifndef __IRCSESSION_H 21#ifndef __IRCSESSION_H
22#define __IRCSESSION_H 22#define __IRCSESSION_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qlist.h> 25#include <qlist.h>
26#include "ircserver.h" 26#include "ircserver.h"
27#include "ircconnection.h" 27#include "ircconnection.h"
28#include "ircmessage.h" 28#include "ircmessage.h"
29#include "ircchannel.h" 29#include "ircchannel.h"
30#include "ircoutput.h" 30#include "ircoutput.h"
31 31
32class IRCMessageParser; 32class IRCMessageParser;
33 33
34/* The IRCSession stores all information relating to the connection 34/* The IRCSession stores all information relating to the connection
35 to one IRC server. IRCSession makes it possible to run multiple 35 to one IRC server. IRCSession makes it possible to run multiple
36 IRC server connections from within the same program */ 36 IRC server connections from within the same program */
37 37
38class IRCSession : public QObject { 38class IRCSession : public QObject {
39friend class IRCMessageParser; 39friend class IRCMessageParser;
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 IRCSession(IRCServer *server); 42 IRCSession(QWidget *parent, IRCServer *server);
43 ~IRCSession(); 43 ~IRCSession();
44 44
45 void join(QString channel); 45 void join(QString channel);
46 void quit(QString message); 46 void quit(QString message);
47 void quit(); 47 void quit();
48 void raw(QString message); 48 void raw(QString message);
49 void topic(IRCChannel *channel, QString message); 49 void topic(IRCChannel *channel, QString message);
50 void mode(IRCChannel *channel, QString message); 50 void mode(IRCChannel *channel, QString message);
51 void mode(IRCPerson *person, QString message); 51 void mode(IRCPerson *person, QString message);
52 void mode(QString message); 52 void mode(QString message);
53 void part(IRCChannel *channel); 53 void part(IRCChannel *channel);
54 void op(IRCChannel *channel, IRCPerson *person); 54 void op(IRCChannel *channel, IRCPerson *person);
55 void kick(IRCChannel *channel, IRCPerson *person); 55 void kick(IRCChannel *channel, IRCPerson *person);
56 void kick(IRCChannel *channel, IRCPerson *person, QString message); 56 void kick(IRCChannel *channel, IRCPerson *person, QString message);
57 void beginSession(); 57 void beginSession();
58 bool isSessionActive(); 58 bool isSessionActive();
59 void endSession(); 59 void endSession();
60 bool isLoggedIn(); 60 bool isLoggedIn();
61 void sendMessage(IRCPerson *person, QString message); 61 void sendMessage(IRCPerson *person, QString message);
62 void sendMessage(IRCChannel *channel, QString message); 62 void sendMessage(IRCChannel *channel, QString message);
63 void sendAction(IRCPerson *person, QString message); 63 void sendAction(IRCPerson *person, QString message);
64 void sendAction(IRCChannel *channel, QString message); 64 void sendAction(IRCChannel *channel, QString message);
65 void updateNickname(const QString &oldNickname, const QString &newNickname); 65 void updateNickname(const QString &oldNickname, const QString &newNickname);
66 void setValidUsermodes(const QString &modes); 66 void setValidUsermodes(const QString &modes);
67 void setValidChannelmodes(const QString &modes); 67 void setValidChannelmodes(const QString &modes);
68 void whois(const QString &nickname); 68 void whois(const QString &nickname);
69 void sendCTCPPing(const QString &nickname); 69 void sendCTCPPing(const QString &nickname);
70 void sendCTCPRequest(const QString &nickname, const QString &type, const QString &args); 70 void sendCTCPRequest(const QString &nickname, const QString &type, const QString &args);
71 void sendCTCPReply(const QString &nickname, const QString &type, const QString &args); 71 void sendCTCPReply(const QString &nickname, const QString &type, const QString &args);
72 IRCChannel *getChannel(QString channelname); 72 IRCChannel *getChannel(QString channelname);
73 IRCPerson *getPerson(QString nickname); 73 IRCPerson *getPerson(QString nickname);
74protected: 74protected:
75 void addPerson(IRCPerson *person); 75 void addPerson(IRCPerson *person);
76 void addChannel(IRCChannel *channel); 76 void addChannel(IRCChannel *channel);
77 void removeChannel(IRCChannel *channel); 77 void removeChannel(IRCChannel *channel);
78 void removePerson(IRCPerson *person); 78 void removePerson(IRCPerson *person);
79 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels); 79 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels);
80protected slots: 80protected slots:
81 void handleMessage(IRCMessage *message); 81 void handleMessage(IRCMessage *message);
82signals: 82signals:
83 void outputReady(IRCOutput output); 83 void outputReady(IRCOutput output);
84 void updateChannels(); 84 void updateChannels();
85protected: 85protected:
86 IRCServer *m_server; 86 IRCServer *m_server;
87 IRCConnection *m_connection; 87 IRCConnection *m_connection;
88 IRCMessageParser *m_parser; 88 IRCMessageParser *m_parser;
89 QList<IRCChannel> m_channels; 89 QList<IRCChannel> m_channels;
90 QList<IRCPerson> m_people; 90 QList<IRCPerson> m_people;
91 QString m_validUsermodes; 91 QString m_validUsermodes;
92 QString m_validChannelmodes; 92 QString m_validChannelmodes;
93 QWidget *m_parent;
93}; 94};
94 95
95#endif /* __IRCSESSION_H */ 96#endif /* __IRCSESSION_H */