summaryrefslogtreecommitdiff
authorwazlaf <wazlaf>2002-09-20 23:28:14 (UTC)
committer wazlaf <wazlaf>2002-09-20 23:28:14 (UTC)
commit912092425248f7fc5155b4c7c46b7d00ec2676bc (patch) (unidiff)
tree5bbf746e83b2dffad89542c42031a573c34da751
parentcd3df897c1b0ed93c2be3ab411011a0bdfe88bf9 (diff)
downloadopie-912092425248f7fc5155b4c7c46b7d00ec2676bc.zip
opie-912092425248f7fc5155b4c7c46b7d00ec2676bc.tar.gz
opie-912092425248f7fc5155b4c7c46b7d00ec2676bc.tar.bz2
support for client commands (only /join implemented so far), crash bugfix, fixed 2 leaks, server browser now includes a channel list
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchannel.cpp5
-rw-r--r--noncore/net/opieirc/ircchannel.h1
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp26
-rw-r--r--noncore/net/opieirc/ircconnection.cpp8
-rw-r--r--noncore/net/opieirc/ircmessage.cpp3
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp3
-rw-r--r--noncore/net/opieirc/ircoutput.cpp7
-rw-r--r--noncore/net/opieirc/ircoutput.h2
-rw-r--r--noncore/net/opieirc/ircserver.cpp12
-rw-r--r--noncore/net/opieirc/ircserver.h6
-rw-r--r--noncore/net/opieirc/ircservereditor.cpp19
-rw-r--r--noncore/net/opieirc/ircservereditor.h1
-rw-r--r--noncore/net/opieirc/ircserverlist.cpp2
-rw-r--r--noncore/net/opieirc/ircservertab.cpp70
-rw-r--r--noncore/net/opieirc/ircservertab.h3
-rw-r--r--noncore/net/opieirc/ircsession.cpp4
-rw-r--r--noncore/net/opieirc/irctab.h1
-rw-r--r--noncore/net/opieirc/ircversion.h2
18 files changed, 151 insertions, 24 deletions
diff --git a/noncore/net/opieirc/ircchannel.cpp b/noncore/net/opieirc/ircchannel.cpp
index 71ec03b..9814a26 100644
--- a/noncore/net/opieirc/ircchannel.cpp
+++ b/noncore/net/opieirc/ircchannel.cpp
@@ -1,43 +1,48 @@
1#include "ircchannel.h" 1#include "ircchannel.h"
2#include <stdio.h> 2#include <stdio.h>
3 3
4IRCChannel::IRCChannel(QString channelname) { 4IRCChannel::IRCChannel(QString channelname) {
5 m_hasPeople = FALSE; 5 m_hasPeople = FALSE;
6 m_channelname = channelname; 6 m_channelname = channelname;
7} 7}
8 8
9IRCChannel::~IRCChannel() {
10 /* We want this to get deleted */
11 m_people.setAutoDelete(TRUE);
12}
13
9QString IRCChannel::channelname() { 14QString IRCChannel::channelname() {
10 return m_channelname; 15 return m_channelname;
11} 16}
12 17
13bool IRCChannel::hasPeople() { 18bool IRCChannel::hasPeople() {
14 return m_hasPeople; 19 return m_hasPeople;
15} 20}
16 21
17void IRCChannel::setHasPeople(bool hasPeople) { 22void IRCChannel::setHasPeople(bool hasPeople) {
18 m_hasPeople = hasPeople; 23 m_hasPeople = hasPeople;
19} 24}
20 25
21void IRCChannel::addPerson(IRCChannelPerson *person) { 26void IRCChannel::addPerson(IRCChannelPerson *person) {
22 m_people.append(person); 27 m_people.append(person);
23} 28}
24 29
25void IRCChannel::removePerson(IRCChannelPerson *person) { 30void IRCChannel::removePerson(IRCChannelPerson *person) {
26 m_people.remove(person); 31 m_people.remove(person);
27} 32}
28 33
29QListIterator<IRCChannelPerson> IRCChannel::people() { 34QListIterator<IRCChannelPerson> IRCChannel::people() {
30 QListIterator<IRCChannelPerson> it(m_people); 35 QListIterator<IRCChannelPerson> it(m_people);
31 return it; 36 return it;
32} 37}
33 38
34IRCChannelPerson *IRCChannel::getPerson(QString nickname) { 39IRCChannelPerson *IRCChannel::getPerson(QString nickname) {
35 QListIterator<IRCChannelPerson> it(m_people); 40 QListIterator<IRCChannelPerson> it(m_people);
36 for (; it.current(); ++it) { 41 for (; it.current(); ++it) {
37 if (it.current()->person->nick() == nickname) { 42 if (it.current()->person->nick() == nickname) {
38 return it.current(); 43 return it.current();
39 } 44 }
40 } 45 }
41 return 0; 46 return 0;
42} 47}
43 48
diff --git a/noncore/net/opieirc/ircchannel.h b/noncore/net/opieirc/ircchannel.h
index c800b99..e78f182 100644
--- a/noncore/net/opieirc/ircchannel.h
+++ b/noncore/net/opieirc/ircchannel.h
@@ -1,68 +1,69 @@
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 __IRCCHANNEL_H 21#ifndef __IRCCHANNEL_H
22#define __IRCCHANNEL_H 22#define __IRCCHANNEL_H
23 23
24#include <qobject.h> 24#include <qobject.h>
25#include <qlist.h> 25#include <qlist.h>
26#include <qstring.h> 26#include <qstring.h>
27#include "ircperson.h" 27#include "ircperson.h"
28 28
29/* Flags which a person can have inside a channel */ 29/* Flags which a person can have inside a channel */
30enum IRCChannelPersonFlag { 30enum IRCChannelPersonFlag {
31 PERSON_FLAG_OP = 0x01, 31 PERSON_FLAG_OP = 0x01,
32 PERSON_FLAG_VOICE = 0x02, 32 PERSON_FLAG_VOICE = 0x02,
33 PERSON_FLAG_HALFOP = 0x04 33 PERSON_FLAG_HALFOP = 0x04
34}; 34};
35 35
36/* This struct encapsulates a IRCPerson and adds 36/* This struct encapsulates a IRCPerson and adds
37 channel specific information */ 37 channel specific information */
38typedef struct IRCChannelPerson { 38typedef struct IRCChannelPerson {
39 IRCPerson *person; 39 IRCPerson *person;
40 unsigned int flags; 40 unsigned int flags;
41}; 41};
42 42
43/* IRCChannel is the object-oriented representation 43/* IRCChannel is the object-oriented representation
44 of an IRC channel. It basically acts as a container 44 of an IRC channel. It basically acts as a container
45 for IRCChannelPersons */ 45 for IRCChannelPersons */
46class IRCChannel : public QObject { 46class IRCChannel : public QObject {
47 Q_OBJECT 47 Q_OBJECT
48public: 48public:
49 IRCChannel(QString channelname); 49 IRCChannel(QString channelname);
50 ~IRCChannel();
50 51
51 void addPerson(IRCChannelPerson *person); 52 void addPerson(IRCChannelPerson *person);
52 void removePerson(IRCChannelPerson *person); 53 void removePerson(IRCChannelPerson *person);
53 IRCChannelPerson *getPerson(QString nickname); 54 IRCChannelPerson *getPerson(QString nickname);
54 QListIterator<IRCChannelPerson> people(); 55 QListIterator<IRCChannelPerson> people();
55 56
56 /* hasPeople identifies whether the irc channel is 57 /* hasPeople identifies whether the irc channel is
57 done synchronizing with the current state - 58 done synchronizing with the current state -
58 this is only relevant when joining a channel */ 59 this is only relevant when joining a channel */
59 void setHasPeople(bool hasPeople); 60 void setHasPeople(bool hasPeople);
60 QString channelname(); 61 QString channelname();
61 bool hasPeople(); 62 bool hasPeople();
62protected: 63protected:
63 QList<IRCChannelPerson> m_people; 64 QList<IRCChannelPerson> m_people;
64 QString m_channelname; 65 QString m_channelname;
65 bool m_hasPeople; 66 bool m_hasPeople;
66}; 67};
67 68
68#endif /* __IRCCHANNEL_H */ 69#endif /* __IRCCHANNEL_H */
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index c96a365..754442a 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,77 +1,93 @@
1#include <qhbox.h> 1#include <qhbox.h>
2#include "ircchanneltab.h" 2#include "ircchanneltab.h"
3#include "ircservertab.h" 3#include "ircservertab.h"
4 4
5IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 5IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
6 m_mainWindow = mainWindow; 6 m_mainWindow = mainWindow;
7 m_parentTab = parentTab; 7 m_parentTab = parentTab;
8 m_channel = channel; 8 m_channel = channel;
9 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 9 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
10 QHBox *hbox = new QHBox(this); 10 QHBox *hbox = new QHBox(this);
11 m_textview = new QTextView(hbox); 11 m_textview = new QTextView(hbox);
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_listVisible = TRUE; 14 m_listVisible = TRUE;
15 m_listButton = new QPushButton(">", m_textview); 15 m_listButton = new QPushButton(">", m_textview);
16 m_textview->setCornerWidget(m_listButton); 16 m_textview->setCornerWidget(m_listButton);
17 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 17 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
18 m_list = new IRCChannelList(m_channel, hbox); 18 m_list = new IRCChannelList(m_channel, hbox);
19 m_list->update(); 19 m_list->update();
20 m_list->setMaximumWidth(LISTWIDTH); 20 m_list->setMaximumWidth(LISTWIDTH);
21 m_field = new QLineEdit(this); 21 m_field = new QLineEdit(this);
22 m_layout->add(hbox); 22 m_layout->add(hbox);
23 hbox->show(); 23 hbox->show();
24 m_layout->add(m_field); 24 m_layout->add(m_field);
25 m_field->setFocus(); 25 m_field->setFocus();
26 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 26 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
27 27
28} 28}
29 29
30void IRCChannelTab::appendText(QString text) { 30void IRCChannelTab::appendText(QString text) {
31 /* not using append because it creates layout problems */ 31 /* not using append because it creates layout problems */
32 m_textview->setText(m_textview->text() + text); 32 m_textview->setText(m_textview->text() + text);
33 m_textview->ensureVisible(0, m_textview->contentsHeight()); 33 m_textview->ensureVisible(0, m_textview->contentsHeight());
34} 34}
35 35
36IRCChannelTab::~IRCChannelTab() { 36IRCChannelTab::~IRCChannelTab() {
37 m_parentTab->removeChannelTab(this); 37 m_parentTab->removeChannelTab(this);
38} 38}
39 39
40void IRCChannelTab::processCommand() { 40void IRCChannelTab::processCommand() {
41 if (m_field->text().length()>0) { 41 QString text = m_field->text();
42 session()->sendMessage(m_channel, m_field->text()); 42 if (text.length()>0) {
43 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+m_field->text()+"<br>"); 43 if (session()->isSessionActive()) {
44 m_field->clear(); 44 if (text.startsWith("/") && !text.startsWith("//")) {
45 /* Command mode */
46 m_parentTab->executeCommand(this, text);;
47 } else {
48 if (session()->isSessionActive()) {
49 session()->sendMessage(m_channel, m_field->text());
50 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+m_field->text()+"<br>");
51 }
52 }
53 } else {
54 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>");
55 }
45 } 56 }
57 m_field->clear();
46} 58}
47 59
48void IRCChannelTab::toggleList() { 60void IRCChannelTab::toggleList() {
49 if (m_listVisible) { 61 if (m_listVisible) {
50 m_list->setMaximumWidth(0); 62 m_list->setMaximumWidth(0);
51 m_listButton->setText("<"); 63 m_listButton->setText("<");
52 } else { 64 } else {
53 m_list->setMaximumWidth(LISTWIDTH); 65 m_list->setMaximumWidth(LISTWIDTH);
54 m_listButton->setText(">"); 66 m_listButton->setText(">");
55 } 67 }
56 m_listVisible = !m_listVisible; 68 m_listVisible = !m_listVisible;
57} 69}
58 70
59QString IRCChannelTab::title() { 71QString IRCChannelTab::title() {
60 return m_channel->channelname(); 72 return m_channel->channelname();
61} 73}
62 74
63IRCSession *IRCChannelTab::session() { 75IRCSession *IRCChannelTab::session() {
64 return m_parentTab->session(); 76 return m_parentTab->session();
65} 77}
66 78
67void IRCChannelTab::remove() { 79void IRCChannelTab::remove() {
68 session()->part(m_channel); 80 if (session()->isSessionActive()) {
81 session()->part(m_channel);
82 } else {
83 m_mainWindow->killTab(this);
84 }
69} 85}
70 86
71IRCChannel *IRCChannelTab::channel() { 87IRCChannel *IRCChannelTab::channel() {
72 return m_channel; 88 return m_channel;
73} 89}
74 90
75IRCChannelList *IRCChannelTab::list() { 91IRCChannelList *IRCChannelTab::list() {
76 return m_list; 92 return m_list;
77} 93}
diff --git a/noncore/net/opieirc/ircconnection.cpp b/noncore/net/opieirc/ircconnection.cpp
index 02c4897..5eb0cf2 100644
--- a/noncore/net/opieirc/ircconnection.cpp
+++ b/noncore/net/opieirc/ircconnection.cpp
@@ -1,94 +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 */
64 QStringList channels = QStringList::split(QChar(','), m_server->channels());
65 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
66 QString channelName = (*it).stripWhiteSpace();
67 if (channelName.startsWith("#")) {
68 sendLine("JOIN "+ channelName);
69 }
70 }
63 m_loggedIn = TRUE; 71 m_loggedIn = TRUE;
64 emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in."))); 72 emit outputReady(IRCOutput(OUTPUT_CLIENTMESSAGE, tr("Successfully logged in.")));
65 } 73 }
66 emit messageArrived(&message); 74 emit messageArrived(&message);
67 } 75 }
68} 76}
69 77
70/* Called if any type of socket error occurs */ 78/* Called if any type of socket error occurs */
71void IRCConnection::error(int num) { 79void IRCConnection::error(int num) {
72 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Socket error : ") + strerror(num))); 80 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Socket error : ") + strerror(num)));
73} 81}
74 82
75void IRCConnection::disconnect() { 83void IRCConnection::disconnect() {
76 m_connected = FALSE; 84 m_connected = FALSE;
77 m_loggedIn = FALSE; 85 m_loggedIn = FALSE;
78 emit outputReady(IRCOutput(OUTPUT_CONNCLOSE, tr("Connection closed"))); 86 emit outputReady(IRCOutput(OUTPUT_CONNCLOSE, tr("Connection closed")));
79} 87}
80 88
81bool IRCConnection::isConnected() { 89bool IRCConnection::isConnected() {
82 return m_connected; 90 return m_connected;
83} 91}
84 92
85bool IRCConnection::isLoggedIn() { 93bool IRCConnection::isLoggedIn() {
86 return m_loggedIn; 94 return m_loggedIn;
87} 95}
88 96
89void IRCConnection::close() { 97void IRCConnection::close() {
90 m_socket->close(); 98 m_socket->close();
91 if (m_socket->state()==QSocket::Idle) { 99 if (m_socket->state()==QSocket::Idle) {
92 disconnect(); 100 disconnect();
93 } 101 }
94} 102}
diff --git a/noncore/net/opieirc/ircmessage.cpp b/noncore/net/opieirc/ircmessage.cpp
index 74e9c6f..9c2869c 100644
--- a/noncore/net/opieirc/ircmessage.cpp
+++ b/noncore/net/opieirc/ircmessage.cpp
@@ -1,120 +1,123 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include "ircmessage.h" 2#include "ircmessage.h"
3 3
4/* 4/*
5 * Create a new IRCMessage by evaluating 5 * Create a new IRCMessage by evaluating
6 * a received string 6 * a received string
7 */ 7 */
8 8
9IRCMessage::IRCMessage(QString line) { 9IRCMessage::IRCMessage(QString line) {
10 /* Remove CRs from the message */ 10 /* Remove CRs from the message */
11 while((line.right(1) == "\n") || (line.right(1) == "\r")) 11 while((line.right(1) == "\n") || (line.right(1) == "\r"))
12 line = line.left(line.length() - 1); 12 line = line.left(line.length() - 1);
13 QTextIStream stream(&line); 13 QTextIStream stream(&line);
14 QString temp; 14 QString temp;
15 15
16 stream >> temp; 16 stream >> temp;
17 if (temp.startsWith(":")) { 17 if (temp.startsWith(":")) {
18 /* extract the prefix */ 18 /* extract the prefix */
19 m_prefix = temp.right(temp.length()-1); 19 m_prefix = temp.right(temp.length()-1);
20 stream >> temp; 20 stream >> temp;
21 m_command = temp.upper(); 21 m_command = temp.upper();
22 m_allParameters = line.right(line.length() - m_prefix.length() - m_command.length() - 3); 22 m_allParameters = line.right(line.length() - m_prefix.length() - m_command.length() - 3);
23 } else { 23 } else {
24 m_command = temp.upper(); 24 m_command = temp.upper();
25 m_allParameters = line.right(line.length() - m_command.length() - 1); 25 m_allParameters = line.right(line.length() - m_command.length() - 1);
26 } 26 }
27
27 /* Create a list of all parameters */ 28 /* Create a list of all parameters */
28 while(!(stream.atEnd())) { 29 while(!(stream.atEnd())) {
29 stream >> temp; 30 stream >> temp;
30 if (temp.startsWith(":")) { 31 if (temp.startsWith(":")) {
31 /* last parameter */ 32 /* last parameter */
32 m_trailing = line.right(line.length() - line.find(QChar(':'), 1) - 1); 33 m_trailing = line.right(line.length() - line.find(QChar(':'), 1) - 1);
33 m_parameters << m_trailing; 34 m_parameters << m_trailing;
34 break; 35 break;
35 } else { 36 } else {
36 m_parameters << temp; 37 m_parameters << temp;
37 } 38 }
38 } 39 }
40
41
39 m_commandNumber = m_command.toInt(&m_isNumerical); 42 m_commandNumber = m_command.toInt(&m_isNumerical);
40 /* Is this a CTCP command */ 43 /* Is this a CTCP command */
41 if ((m_command == "PRIVMSG" || m_command == "NOTICE") && m_trailing.length()>0 && m_trailing.left(1) == QChar(1)) { 44 if ((m_command == "PRIVMSG" || m_command == "NOTICE") && m_trailing.length()>0 && m_trailing.left(1) == QChar(1)) {
42 m_ctcp = TRUE; 45 m_ctcp = TRUE;
43 /* Strip CTCP \001 characters */ 46 /* Strip CTCP \001 characters */
44 m_allParameters = m_allParameters.replace(QRegExp(QChar(1)), ""); 47 m_allParameters = m_allParameters.replace(QRegExp(QChar(1)), "");
45 QTextIStream ctcpStream(&m_allParameters); 48 QTextIStream ctcpStream(&m_allParameters);
46 if (m_command == "PRIVMSG") 49 if (m_command == "PRIVMSG")
47 ctcpStream >> m_ctcpDestination; 50 ctcpStream >> m_ctcpDestination;
48 ctcpStream >> temp; 51 ctcpStream >> temp;
49 m_ctcpCommand = temp.upper().right(temp.length()-1); 52 m_ctcpCommand = temp.upper().right(temp.length()-1);
50 m_parameters.clear(); 53 m_parameters.clear();
51 int length = m_allParameters.length() - m_ctcpCommand.length() - 1; 54 int length = m_allParameters.length() - m_ctcpCommand.length() - 1;
52 if (m_command == "PRIVMSG") 55 if (m_command == "PRIVMSG")
53 length -= m_ctcpDestination.length() + 1; 56 length -= m_ctcpDestination.length() + 1;
54 if (length <= 0) { 57 if (length <= 0) {
55 m_allParameters = ""; 58 m_allParameters = "";
56 } else { 59 } else {
57 m_allParameters = m_allParameters.right(length); 60 m_allParameters = m_allParameters.right(length);
58 m_parameters << m_allParameters; 61 m_parameters << m_allParameters;
59 } 62 }
60 } else { 63 } else {
61 m_ctcp = FALSE; 64 m_ctcp = FALSE;
62 } 65 }
63 66
64 /* 67 /*
65 -- Uncomment to debug -- 68 -- Uncomment to debug --
66 69
67 printf("Parsed : '%s'\n", line.ascii()); 70 printf("Parsed : '%s'\n", line.ascii());
68 printf("Prefix : '%s'\n", m_prefix.ascii()); 71 printf("Prefix : '%s'\n", m_prefix.ascii());
69 printf("Command : '%s'\n", m_command.ascii()); 72 printf("Command : '%s'\n", m_command.ascii());
70 printf("Allparameters : '%s'\n", m_allParameters.ascii()); 73 printf("Allparameters : '%s'\n", m_allParameters.ascii());
71 for (unsigned int i=0; i<m_parameters.count(); i++) { 74 for (unsigned int i=0; i<m_parameters.count(); i++) {
72 printf("Parameter %i : '%s'\n", i, m_parameters[i].ascii()); 75 printf("Parameter %i : '%s'\n", i, m_parameters[i].ascii());
73 } 76 }
74 printf("CTCP Command : '%s'\n", m_ctcpCommand.latin1()); 77 printf("CTCP Command : '%s'\n", m_ctcpCommand.latin1());
75 printf("CTCP Destination : '%s'\n", m_ctcpDestination.latin1()); 78 printf("CTCP Destination : '%s'\n", m_ctcpDestination.latin1());
76 printf("CTCP param count is : '%i'\n", m_parameters.count()); 79 printf("CTCP param count is : '%i'\n", m_parameters.count());
77 80
78 */ 81 */
79} 82}
80 83
81QString IRCMessage::param(int param) { 84QString IRCMessage::param(int param) {
82 return m_parameters[param]; 85 return m_parameters[param];
83} 86}
84 87
85QString IRCMessage::prefix() { 88QString IRCMessage::prefix() {
86 return m_prefix; 89 return m_prefix;
87} 90}
88 91
89QString IRCMessage::command() { 92QString IRCMessage::command() {
90 return m_command; 93 return m_command;
91} 94}
92 95
93QString IRCMessage::ctcpCommand() { 96QString IRCMessage::ctcpCommand() {
94 return m_ctcpCommand; 97 return m_ctcpCommand;
95} 98}
96 99
97QString IRCMessage::ctcpDestination() { 100QString IRCMessage::ctcpDestination() {
98 return m_ctcpDestination; 101 return m_ctcpDestination;
99} 102}
100 103
101unsigned short IRCMessage::commandNumber() { 104unsigned short IRCMessage::commandNumber() {
102 return m_commandNumber; 105 return m_commandNumber;
103} 106}
104 107
105bool IRCMessage::isNumerical() { 108bool IRCMessage::isNumerical() {
106 return m_isNumerical; 109 return m_isNumerical;
107} 110}
108 111
109bool IRCMessage::isCTCP() { 112bool IRCMessage::isCTCP() {
110 return m_ctcp; 113 return m_ctcp;
111} 114}
112 115
113QString IRCMessage::trailing() { 116QString IRCMessage::trailing() {
114 return m_trailing; 117 return m_trailing;
115} 118}
116 119
117QString IRCMessage::allParameters() { 120QString IRCMessage::allParameters() {
118 return m_allParameters; 121 return m_allParameters;
119} 122}
120 123
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index a2be5a4..4038673 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -1,124 +1,125 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include "ircmessageparser.h" 2#include "ircmessageparser.h"
3#include "ircversion.h" 3#include "ircversion.h"
4#include <stdio.h> 4#include <stdio.h>
5 5
6/* Lookup table for literal commands */ 6/* Lookup table for literal commands */
7IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { 7IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
8 { "PING", FUNC(parseLiteralPing) }, 8 { "PING", FUNC(parseLiteralPing) },
9 { "NOTICE", FUNC(parseLiteralNotice) }, 9 { "NOTICE", FUNC(parseLiteralNotice) },
10 { "JOIN", FUNC(parseLiteralJoin) }, 10 { "JOIN", FUNC(parseLiteralJoin) },
11 { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, 11 { "PRIVMSG", FUNC(parseLiteralPrivMsg) },
12 { "NICK", FUNC(parseLiteralNick) }, 12 { "NICK", FUNC(parseLiteralNick) },
13 { "PART", FUNC(parseLiteralPart) }, 13 { "PART", FUNC(parseLiteralPart) },
14 { "QUIT", FUNC(parseLiteralQuit) }, 14 { "QUIT", FUNC(parseLiteralQuit) },
15 { "ERROR", FUNC(parseLiteralError) }, 15 { "ERROR", FUNC(parseLiteralError) },
16 { "ERROR:", FUNC(parseLiteralError) }, 16 { "ERROR:", FUNC(parseLiteralError) },
17 { "MODE", FUNC(parseLiteralMode) }, 17 { "MODE", FUNC(parseLiteralMode) },
18 { "KICK", FUNC(parseLiteralKick) }, 18 { "KICK", FUNC(parseLiteralKick) },
19 { 0 , 0 } 19 { 0 , 0 }
20}; 20};
21 21
22/* Lookup table for literal commands */ 22/* Lookup table for literal commands */
23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
24 { "PING", FUNC(parseCTCPPing) }, 24 { "PING", FUNC(parseCTCPPing) },
25 { "VERSION", FUNC(parseCTCPVersion) }, 25 { "VERSION", FUNC(parseCTCPVersion) },
26 { "ACTION", FUNC(parseCTCPAction) }, 26 { "ACTION", FUNC(parseCTCPAction) },
27 { 0 , 0 } 27 { 0 , 0 }
28}; 28};
29
29/* Lookup table for numerical commands */ 30/* Lookup table for numerical commands */
30IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { 31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
31 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME 32 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME
32 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST 33 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST
33 { 3, FUNC(parseNumerical003) }, // RPL_CREATED 34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED
34 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO 35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO
35 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL 36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL
36 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT 37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT
37 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS 38 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS
38 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME 39 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME
39 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY 40 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY
40 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES 41 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
41 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART 42 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART
42 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD 43 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD
43 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD 44 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD
44 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 45 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2
45 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 46 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3
46 { 412, FUNC(parseNumericalStats) }, // ERNOTEXTTOSEND 47 { 412, FUNC(parseNumericalStats) }, // ERNOTEXTTOSEND
47 { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE 48 { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
48 { 0, 0 } 49 { 0, 0 }
49}; 50};
50 51
51IRCMessageParser::IRCMessageParser(IRCSession *session) { 52IRCMessageParser::IRCMessageParser(IRCSession *session) {
52 m_session = session; 53 m_session = session;
53} 54}
54 55
55void IRCMessageParser::parse(IRCMessage *message) { 56void IRCMessageParser::parse(IRCMessage *message) {
56 /* Find out what kind of message we have here and call the appropriate handler using 57 /* Find out what kind of message we have here and call the appropriate handler using
57 the parser tables. If no handler can be found, print out an error message */ 58 the parser tables. If no handler can be found, print out an error message */
58 if (message->isNumerical()) { 59 if (message->isNumerical()) {
59 for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { 60 for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) {
60 if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { 61 if (message->commandNumber() == numericalParserProcTable[i].commandNumber) {
61 (this->*(numericalParserProcTable[i].proc))(message); 62 (this->*(numericalParserProcTable[i].proc))(message);
62 return; 63 return;
63 } 64 }
64 } 65 }
65 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); 66 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber())));
66 } else if (message->isCTCP()) { 67 } else if (message->isCTCP()) {
67 for (int i=0; ctcpParserProcTable[i].commandName; i++) { 68 for (int i=0; ctcpParserProcTable[i].commandName; i++) {
68 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { 69 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) {
69 (this->*(ctcpParserProcTable[i].proc))(message); 70 (this->*(ctcpParserProcTable[i].proc))(message);
70 return; 71 return;
71 } 72 }
72 } 73 }
73 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); 74 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand()));
74 } else { 75 } else {
75 for (int i=0; literalParserProcTable[i].commandName; i++) { 76 for (int i=0; literalParserProcTable[i].commandName; i++) {
76 if (message->command() == literalParserProcTable[i].commandName) { 77 if (message->command() == literalParserProcTable[i].commandName) {
77 (this->*(literalParserProcTable[i].proc))(message); 78 (this->*(literalParserProcTable[i].proc))(message);
78 return; 79 return;
79 } 80 }
80 } 81 }
81 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); 82 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command()));
82 } 83 }
83} 84}
84 85
85void IRCMessageParser::nullFunc(IRCMessage *) { 86void IRCMessageParser::nullFunc(IRCMessage *) {
86 /* Do nothing */ 87 /* Do nothing */
87} 88}
88 89
89void IRCMessageParser::parseLiteralPing(IRCMessage *message) { 90void IRCMessageParser::parseLiteralPing(IRCMessage *message) {
90 m_session->m_connection->sendLine("PONG " + message->allParameters()); 91 m_session->m_connection->sendLine("PONG " + message->allParameters());
91} 92}
92 93
93void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { 94void IRCMessageParser::parseLiteralNotice(IRCMessage *message) {
94 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); 95 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
95} 96}
96 97
97void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { 98void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
98 QString channelName = message->param(0); 99 QString channelName = message->param(0);
99 IRCPerson mask(message->prefix()); 100 IRCPerson mask(message->prefix());
100 IRCChannel *channel = m_session->getChannel(channelName); 101 IRCChannel *channel = m_session->getChannel(channelName);
101 if (!channel) { 102 if (!channel) {
102 /* We joined */ 103 /* We joined */
103 if (mask.nick() == m_session->m_server->nick()) { 104 if (mask.nick() == m_session->m_server->nick()) {
104 channel = new IRCChannel(channelName); 105 channel = new IRCChannel(channelName);
105 m_session->addChannel(channel); 106 m_session->addChannel(channel);
106 } else { 107 } else {
107 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); 108 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?")));
108 } 109 }
109 } else { 110 } else {
110 /* Someone else joined */ 111 /* Someone else joined */
111 if (mask.nick() != m_session->m_server->nick()) { 112 if (mask.nick() != m_session->m_server->nick()) {
112 if (!channel->getPerson(mask.nick())) { 113 if (!channel->getPerson(mask.nick())) {
113 IRCChannelPerson *chanperson = new IRCChannelPerson(); 114 IRCChannelPerson *chanperson = new IRCChannelPerson();
114 IRCPerson *person = m_session->getPerson(mask.nick()); 115 IRCPerson *person = m_session->getPerson(mask.nick());
115 if (!person) { 116 if (!person) {
116 person = new IRCPerson(message->prefix()); 117 person = new IRCPerson(message->prefix());
117 m_session->addPerson(person); 118 m_session->addPerson(person);
118 } 119 }
119 chanperson->flags = 0; 120 chanperson->flags = 0;
120 chanperson->person = person; 121 chanperson->person = person;
121 channel->addPerson(chanperson); 122 channel->addPerson(chanperson);
122 IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); 123 IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName);
123 output.addParam(channel); 124 output.addParam(channel);
124 output.addParam(chanperson); 125 output.addParam(chanperson);
@@ -135,197 +136,199 @@ void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
135void IRCMessageParser::parseLiteralPart(IRCMessage *message) { 136void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
136 QString channelName = message->param(0); 137 QString channelName = message->param(0);
137 IRCChannel *channel = m_session->getChannel(channelName); 138 IRCChannel *channel = m_session->getChannel(channelName);
138 IRCPerson mask(message->prefix()); 139 IRCPerson mask(message->prefix());
139 if (channel) { 140 if (channel) {
140 if (mask.nick() == m_session->m_server->nick()) { 141 if (mask.nick() == m_session->m_server->nick()) {
141 m_session->removeChannel(channel); 142 m_session->removeChannel(channel);
142 IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); 143 IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName);
143 output.addParam(channel); 144 output.addParam(channel);
144 emit outputReady(output); 145 emit outputReady(output);
145 delete channel; 146 delete channel;
146 } else { 147 } else {
147 IRCChannelPerson *person = channel->getPerson(mask.nick()); 148 IRCChannelPerson *person = channel->getPerson(mask.nick());
148 if (person) { 149 if (person) {
149 channel->removePerson(person); 150 channel->removePerson(person);
150 IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); 151 IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName);
151 output.addParam(channel); 152 output.addParam(channel);
152 output.addParam(person); 153 output.addParam(person);
153 emit outputReady(output); 154 emit outputReady(output);
154 delete person; 155 delete person;
155 } else { 156 } else {
156 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); 157 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?")));
157 } 158 }
158 } 159 }
159 } else { 160 } else {
160 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); 161 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
161 } 162 }
162} 163}
163 164
164void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { 165void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
165 if (m_session->m_server->nick() == message->param(0)) { 166 if (m_session->m_server->nick() == message->param(0)) {
166 /* IRC Query message detected, verify sender and display it */ 167 /* IRC Query message detected, verify sender and display it */
167 IRCPerson mask(message->prefix()); 168 IRCPerson mask(message->prefix());
168 IRCPerson *person = m_session->getPerson(mask.nick()); 169 IRCPerson *person = m_session->getPerson(mask.nick());
169 if (!person) { 170 if (!person) {
170 /* Person not yet known, create and add to the current session */ 171 /* Person not yet known, create and add to the current session */
171 person = new IRCPerson(message->prefix()); 172 person = new IRCPerson(message->prefix());
172 m_session->addPerson(person); 173 m_session->addPerson(person);
173 } 174 }
174 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); 175 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
175 output.addParam(person); 176 output.addParam(person);
176 emit outputReady(output); 177 emit outputReady(output);
177 } else if (message->param(0).at(0) == '#') { 178 } else if (message->param(0).at(0) == '#') {
178 /* IRC Channel message detected, verify sender, channel and display it */ 179 /* IRC Channel message detected, verify sender, channel and display it */
179 IRCChannel *channel = m_session->getChannel(message->param(0)); 180 IRCChannel *channel = m_session->getChannel(message->param(0));
180 if (channel) { 181 if (channel) {
181 IRCPerson mask(message->prefix()); 182 IRCPerson mask(message->prefix());
182 IRCChannelPerson *person = channel->getPerson(mask.nick()); 183 IRCChannelPerson *person = channel->getPerson(mask.nick());
183 if (person) { 184 if (person) {
184 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); 185 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
185 output.addParam(channel); 186 output.addParam(channel);
186 output.addParam(person); 187 output.addParam(person);
187 emit outputReady(output); 188 emit outputReady(output);
188 } else { 189 } else {
189 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); 190 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender")));
190 } 191 }
191 } else { 192 } else {
192 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel"))); 193 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel")));
193 } 194 }
194 } else { 195 } else {
195 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); 196 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
196 } 197 }
197} 198}
198 199
199void IRCMessageParser::parseLiteralNick(IRCMessage *message) { 200void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
200 IRCPerson mask(message->prefix()); 201 IRCPerson mask(message->prefix());
201 202
202 if (mask.nick() == m_session->m_server->nick()) { 203 if (mask.nick() == m_session->m_server->nick()) {
203 /* We are changing our nickname */ 204 /* We are changing our nickname */
204 m_session->m_server->setNick(message->param(0)); 205 m_session->m_server->setNick(message->param(0));
205 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); 206 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0));
206 output.addParam(0); 207 output.addParam(0);
207 emit outputReady(output); 208 emit outputReady(output);
208 } else { 209 } else {
209 /* Someone else is */ 210 /* Someone else is */
210 IRCPerson *person = m_session->getPerson(mask.nick()); 211 IRCPerson *person = m_session->getPerson(mask.nick());
211 if (person) { 212 if (person) {
212 IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); 213 IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0));
213 output.addParam(person); 214 output.addParam(person);
214 emit outputReady(output); 215 emit outputReady(output);
215 } else { 216 } else {
216 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); 217 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
217 } 218 }
218 } 219 }
219} 220}
220 221
221void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { 222void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
222 IRCPerson mask(message->prefix()); 223 IRCPerson mask(message->prefix());
223 IRCPerson *person = m_session->getPerson(mask.nick()); 224 IRCPerson *person = m_session->getPerson(mask.nick());
224 if (person) { 225 if (person) {
225 QList<IRCChannel> channels; 226 QList<IRCChannel> channels;
226 m_session->getChannelsByPerson(person, channels); 227 m_session->getChannelsByPerson(person, channels);
227 QListIterator<IRCChannel> it(channels); 228 QListIterator<IRCChannel> it(channels);
228 for (;it.current(); ++it) { 229 for (;it.current(); ++it) {
229 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 230 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
230 it.current()->removePerson(chanperson); 231 it.current()->removePerson(chanperson);
232 delete chanperson;
231 } 233 }
232 m_session->removePerson(person); 234 m_session->removePerson(person);
233 IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); 235 IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")");
234 output.addParam(person); 236 output.addParam(person);
235 emit outputReady(output); 237 emit outputReady(output);
238 delete person;
236 } else { 239 } else {
237 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); 240 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
238 } 241 }
239} 242}
240 243
241void IRCMessageParser::parseLiteralError(IRCMessage *message) { 244void IRCMessageParser::parseLiteralError(IRCMessage *message) {
242 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); 245 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
243} 246}
244 247
245void IRCMessageParser::parseCTCPPing(IRCMessage *message) { 248void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
246 IRCPerson mask(message->prefix()); 249 IRCPerson mask(message->prefix());
247 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); 250 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters());
248 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); 251 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick()));
249} 252}
250 253
251void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { 254void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
252 IRCPerson mask(message->prefix()); 255 IRCPerson mask(message->prefix());
253 m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); 256 m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR);
254 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); 257 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick()));
255} 258}
256 259
257void IRCMessageParser::parseCTCPAction(IRCMessage *message) { 260void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
258 IRCPerson mask(message->prefix()); 261 IRCPerson mask(message->prefix());
259 QString dest = message->ctcpDestination(); 262 QString dest = message->ctcpDestination();
260 if (dest.startsWith("#")) { 263 if (dest.startsWith("#")) {
261 IRCChannel *channel = m_session->getChannel(dest); 264 IRCChannel *channel = m_session->getChannel(dest);
262 if (channel) { 265 if (channel) {
263 IRCChannelPerson *person = channel->getPerson(mask.nick()); 266 IRCChannelPerson *person = channel->getPerson(mask.nick());
264 if (person) { 267 if (person) {
265 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); 268 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0));
266 output.addParam(channel); 269 output.addParam(channel);
267 output.addParam(person); 270 output.addParam(person);
268 emit outputReady(output); 271 emit outputReady(output);
269 } else { 272 } else {
270 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); 273 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));
271 } 274 }
272 } else { 275 } else {
273 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); 276 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?")));
274 } 277 }
275 } else { 278 } else {
276 if (message->ctcpDestination() == m_session->m_server->nick()) { 279 if (message->ctcpDestination() == m_session->m_server->nick()) {
277 IRCPerson *person = m_session->getPerson(mask.nick()); 280 IRCPerson *person = m_session->getPerson(mask.nick());
278 if (!person) { 281 if (!person) {
279 /* Person not yet known, create and add to the current session */ 282 /* Person not yet known, create and add to the current session */
280 person = new IRCPerson(message->prefix()); 283 person = new IRCPerson(message->prefix());
281 m_session->addPerson(person); 284 m_session->addPerson(person);
282 } 285 }
283 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); 286 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0));
284 output.addParam(person); 287 output.addParam(person);
285 emit outputReady(output); 288 emit outputReady(output);
286 } else { 289 } else {
287 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); 290 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
288 } 291 }
289 } 292 }
290} 293}
291 294
292void IRCMessageParser::parseLiteralMode(IRCMessage *message) { 295void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
293 IRCPerson mask(message->prefix()); 296 IRCPerson mask(message->prefix());
294 297
295 if (message->param(0).startsWith("#")) { 298 if (message->param(0).startsWith("#")) {
296 IRCChannel *channel = m_session->getChannel(message->param(0)); 299 IRCChannel *channel = m_session->getChannel(message->param(0));
297 if (channel) { 300 if (channel) {
298 QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); 301 QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1);
299 QTextIStream stream(&parameters); 302 QTextIStream stream(&parameters);
300 bool set = FALSE; 303 bool set = FALSE;
301 while (!stream.atEnd()) { 304 while (!stream.atEnd()) {
302 stream >> temp; 305 stream >> temp;
303 if (temp.startsWith("+")) { 306 if (temp.startsWith("+")) {
304 set = TRUE; 307 set = TRUE;
305 temp = temp.right(1); 308 temp = temp.right(1);
306 } else if (temp.startsWith("-")) { 309 } else if (temp.startsWith("-")) {
307 set = FALSE; 310 set = FALSE;
308 temp = temp.right(1); 311 temp = temp.right(1);
309 } else { 312 } else {
310 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); 313 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type")));
311 return; 314 return;
312 } 315 }
313 if (temp == "o") { 316 if (temp == "o") {
314 stream >> temp; 317 stream >> temp;
315 IRCChannelPerson *person = channel->getPerson(temp); 318 IRCChannelPerson *person = channel->getPerson(temp);
316 if (person) { 319 if (person) {
317 if (set) { 320 if (set) {
318 person->flags |= PERSON_FLAG_OP; 321 person->flags |= PERSON_FLAG_OP;
319 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); 322 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick()));
320 output.addParam(channel); 323 output.addParam(channel);
321 output.addParam(person); 324 output.addParam(person);
322 emit outputReady(output); 325 emit outputReady(output);
323 } else { 326 } else {
324 person->flags &= 0xFFFF - PERSON_FLAG_OP; 327 person->flags &= 0xFFFF - PERSON_FLAG_OP;
325 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); 328 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick()));
326 output.addParam(channel); 329 output.addParam(channel);
327 output.addParam(person); 330 output.addParam(person);
328 emit outputReady(output); 331 emit outputReady(output);
329 } 332 }
330 } else { 333 } else {
331 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); 334 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
diff --git a/noncore/net/opieirc/ircoutput.cpp b/noncore/net/opieirc/ircoutput.cpp
index aa57d86..878bc9b 100644
--- a/noncore/net/opieirc/ircoutput.cpp
+++ b/noncore/net/opieirc/ircoutput.cpp
@@ -1,22 +1,29 @@
1#include "ircoutput.h" 1#include "ircoutput.h"
2 2
3IRCOutput::IRCOutput(IRCOutputType type, QString message) { 3IRCOutput::IRCOutput(IRCOutputType type, QString message) {
4 m_type = type; 4 m_type = type;
5 m_message = message; 5 m_message = message;
6} 6}
7 7
8IRCOutputType IRCOutput::type() { 8IRCOutputType IRCOutput::type() {
9 return m_type; 9 return m_type;
10} 10}
11 11
12QString IRCOutput::message() { 12QString IRCOutput::message() {
13 return m_message; 13 return m_message;
14} 14}
15 15
16QString IRCOutput::htmlMessage() {
17 QString htmlMessage =m_message.replace(QRegExp("&"), "&amp;");
18 htmlMessage = htmlMessage.replace(QRegExp(">"), "&gt;");
19 htmlMessage = htmlMessage.replace(QRegExp("<"), "&lt;");
20 return htmlMessage;
21}
22
16void IRCOutput::addParam(void *data) { 23void IRCOutput::addParam(void *data) {
17 m_parameters.append(data); 24 m_parameters.append(data);
18} 25}
19 26
20void *IRCOutput::getParam(int index) { 27void *IRCOutput::getParam(int index) {
21 return m_parameters.at(index); 28 return m_parameters.at(index);
22} 29}
diff --git a/noncore/net/opieirc/ircoutput.h b/noncore/net/opieirc/ircoutput.h
index 4b757ed..72361d4 100644
--- a/noncore/net/opieirc/ircoutput.h
+++ b/noncore/net/opieirc/ircoutput.h
@@ -1,70 +1,72 @@
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 __IRCOUTPUT_H 21#ifndef __IRCOUTPUT_H
22#define __IRCOUTPUT_H 22#define __IRCOUTPUT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qlist.h> 25#include <qlist.h>
26#include "ircchannel.h" 26#include "ircchannel.h"
27 27
28/* Types of possible IRC output */ 28/* Types of possible IRC output */
29enum IRCOutputType { 29enum IRCOutputType {
30 OUTPUT_ERROR = -1, /* parameters : none */ 30 OUTPUT_ERROR = -1, /* parameters : none */
31 OUTPUT_SERVERMESSAGE = 0, /* parameters : none */ 31 OUTPUT_SERVERMESSAGE = 0, /* parameters : none */
32 OUTPUT_CLIENTMESSAGE = 1, /* parameters : none */ 32 OUTPUT_CLIENTMESSAGE = 1, /* parameters : none */
33 OUTPUT_CHANPRIVMSG = 2, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ 33 OUTPUT_CHANPRIVMSG = 2, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */
34 OUTPUT_QUERYPRIVMSG = 3, /* parameters : person (IRCPerson) */ 34 OUTPUT_QUERYPRIVMSG = 3, /* parameters : person (IRCPerson) */
35 OUTPUT_NICKCHANGE = 4, /* parameters : person (IRCPerson) */ 35 OUTPUT_NICKCHANGE = 4, /* parameters : person (IRCPerson) */
36 OUTPUT_SELFJOIN = 5, /* parameters : channel (IRCChannel) */ 36 OUTPUT_SELFJOIN = 5, /* parameters : channel (IRCChannel) */
37 OUTPUT_OTHERJOIN = 6, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ 37 OUTPUT_OTHERJOIN = 6, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */
38 OUTPUT_SELFPART = 7, /* parameters : channel (IRCChannel) */ 38 OUTPUT_SELFPART = 7, /* parameters : channel (IRCChannel) */
39 OUTPUT_OTHERPART = 8, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */ 39 OUTPUT_OTHERPART = 8, /* parameters : channel (IRCChannel), person (IRCChannelPerson) */
40 OUTPUT_QUIT = 9, /* parameters : person (IRCPerson) */ 40 OUTPUT_QUIT = 9, /* parameters : person (IRCPerson) */
41 OUTPUT_CONNCLOSE = 10, /* parameters : none */ 41 OUTPUT_CONNCLOSE = 10, /* parameters : none */
42 OUTPUT_CTCP = 11, /* parameters : none */ 42 OUTPUT_CTCP = 11, /* parameters : none */
43 OUTPUT_SELFKICK = 12, /* parameters : channel (IRCChannel) */ 43 OUTPUT_SELFKICK = 12, /* parameters : channel (IRCChannel) */
44 OUTPUT_OTHERKICK = 13, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */ 44 OUTPUT_OTHERKICK = 13, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */
45 OUTPUT_CHANACTION = 14, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */ 45 OUTPUT_CHANACTION = 14, /* parameters : channel (IRCChannel) person (IRCChannelPerson) */
46 OUTPUT_QUERYACTION = 15, /* parameters : person (IRCPerson) */ 46 OUTPUT_QUERYACTION = 15, /* parameters : person (IRCPerson) */
47 OUTPUT_CHANPERSONMODE = 16 /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */ 47 OUTPUT_CHANPERSONMODE = 16 /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */
48}; 48};
49 49
50/* The IRCOutput class is used as a kind of message which is sent by the 50/* The IRCOutput class is used as a kind of message which is sent by the
51 IRC parser to inform the GUI of changes. This could for example be a 51 IRC parser to inform the GUI of changes. This could for example be a
52 channel message or a nickname change */ 52 channel message or a nickname change */
53 53
54class IRCOutput { 54class IRCOutput {
55public: 55public:
56 IRCOutput(IRCOutputType type, QString message); 56 IRCOutput(IRCOutputType type, QString message);
57 /* Used to add a parameter to this IRCOutput. Parameters are dependent 57 /* Used to add a parameter to this IRCOutput. Parameters are dependent
58 on which IRCOutputType we are using (see above) */ 58 on which IRCOutputType we are using (see above) */
59 void addParam(void *data); 59 void addParam(void *data);
60 60
61 IRCOutputType type(); 61 IRCOutputType type();
62 QString message(); 62 QString message();
63 /* Return the message with all HTML code escaped (for example &lt; instead of '<') */
64 QString htmlMessage();
63 void *getParam(int index); 65 void *getParam(int index);
64protected: 66protected:
65 IRCOutputType m_type; 67 IRCOutputType m_type;
66 QString m_message; 68 QString m_message;
67 QList<void> m_parameters; 69 QList<void> m_parameters;
68}; 70};
69 71
70#endif 72#endif
diff --git a/noncore/net/opieirc/ircserver.cpp b/noncore/net/opieirc/ircserver.cpp
index e16e2b2..e27e41d 100644
--- a/noncore/net/opieirc/ircserver.cpp
+++ b/noncore/net/opieirc/ircserver.cpp
@@ -1,62 +1,74 @@
1#include "ircserver.h" 1#include "ircserver.h"
2 2
3IRCServer::IRCServer() { 3IRCServer::IRCServer() {
4 m_port = 6667; 4 m_port = 6667;
5} 5}
6 6
7/* Setter implementations */
8
7void IRCServer::setHostname(QString hostname) { 9void IRCServer::setHostname(QString hostname) {
8 m_hostname = hostname; 10 m_hostname = hostname;
9} 11}
10 12
11void IRCServer::setName(QString name) { 13void IRCServer::setName(QString name) {
12 m_name = name; 14 m_name = name;
13} 15}
14 16
15void IRCServer::setPort(int port) { 17void IRCServer::setPort(int port) {
16 m_port = port; 18 m_port = port;
17} 19}
18 20
19void IRCServer::setUsername(QString username) { 21void IRCServer::setUsername(QString username) {
20 m_username = username; 22 m_username = username;
21} 23}
22 24
23void IRCServer::setPassword(QString password) { 25void IRCServer::setPassword(QString password) {
24 m_password = password; 26 m_password = password;
25} 27}
26 28
27void IRCServer::setNick(QString nick) { 29void IRCServer::setNick(QString nick) {
28 m_nick = nick; 30 m_nick = nick;
29} 31}
30 32
31void IRCServer::setRealname(QString realname) { 33void IRCServer::setRealname(QString realname) {
32 m_realname = realname; 34 m_realname = realname;
33} 35}
34 36
37void IRCServer::setChannels(QString channels) {
38 m_channels = channels;
39}
40
41/* Getter implementations */
42
35QString IRCServer::hostname() { 43QString IRCServer::hostname() {
36 return m_hostname; 44 return m_hostname;
37} 45}
38 46
39QString IRCServer::name() { 47QString IRCServer::name() {
40 return m_name; 48 return m_name;
41} 49}
42 50
43unsigned short int IRCServer::port() { 51unsigned short int IRCServer::port() {
44 return m_port; 52 return m_port;
45} 53}
46 54
47QString IRCServer::username() { 55QString IRCServer::username() {
48 return m_username; 56 return m_username;
49} 57}
50 58
51QString IRCServer::password() { 59QString IRCServer::password() {
52 return m_password; 60 return m_password;
53} 61}
54 62
55QString IRCServer::nick() { 63QString IRCServer::nick() {
56 return m_nick; 64 return m_nick;
57} 65}
58 66
59QString IRCServer::realname() { 67QString IRCServer::realname() {
60 return m_realname; 68 return m_realname;
61} 69}
62 70
71QString IRCServer::channels() {
72 return m_channels;
73}
74
diff --git a/noncore/net/opieirc/ircserver.h b/noncore/net/opieirc/ircserver.h
index f56f231..0bc7d4c 100644
--- a/noncore/net/opieirc/ircserver.h
+++ b/noncore/net/opieirc/ircserver.h
@@ -1,58 +1,64 @@
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 __IRCSERVER_H 21#ifndef __IRCSERVER_H
22#define __IRCSERVER_H 22#define __IRCSERVER_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26/* IRCServer stores all information required to 26/* IRCServer stores all information required to
27 establish a connection to a server. */ 27 establish a connection to a server. */
28 28
29class IRCServer { 29class IRCServer {
30public: 30public:
31 /* Initialize to the default values */
31 IRCServer(); 32 IRCServer();
32 33
34 /* Setters */
33 void setName(QString name); 35 void setName(QString name);
34 void setHostname(QString hostname); 36 void setHostname(QString hostname);
35 void setPort(int port); 37 void setPort(int port);
36 void setUsername(QString username); 38 void setUsername(QString username);
37 void setPassword(QString password); 39 void setPassword(QString password);
38 void setNick(QString nick); 40 void setNick(QString nick);
39 void setRealname(QString realname); 41 void setRealname(QString realname);
42 void setChannels(QString channels);
40 43
44 /* Getters */
41 QString hostname(); 45 QString hostname();
42 QString name(); 46 QString name();
43 unsigned short int port(); 47 unsigned short int port();
44 QString username(); 48 QString username();
45 QString password(); 49 QString password();
46 QString nick(); 50 QString nick();
47 QString realname(); 51 QString realname();
52 QString channels();
48protected: 53protected:
49 QString m_hostname; 54 QString m_hostname;
50 QString m_name; 55 QString m_name;
51 unsigned short int m_port; 56 unsigned short int m_port;
52 QString m_username; 57 QString m_username;
53 QString m_password; 58 QString m_password;
54 QString m_nick; 59 QString m_nick;
55 QString m_realname; 60 QString m_realname;
61 QString m_channels;
56}; 62};
57 63
58#endif /* __IRCSERVER_H */ 64#endif /* __IRCSERVER_H */
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp
index 798081f..c3a444d 100644
--- a/noncore/net/opieirc/ircservereditor.cpp
+++ b/noncore/net/opieirc/ircservereditor.cpp
@@ -1,61 +1,76 @@
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, 6, 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);
33 m_channels = new QLineEdit(server.channels(), this);
34 layout->addWidget(label, 6, 0);
35 layout->addWidget(m_channels, 6, 1);
32 showMaximized(); 36 showMaximized();
33} 37}
34 38
35 39
36void IRCServerEditor::accept() { 40void IRCServerEditor::accept() {
37 if (m_name->text().length()==0) 41 if (m_name->text().length()==0)
38 QMessageBox::critical(this, tr("Error"), tr("Profile name required")); 42 QMessageBox::critical(this, tr("Error"), tr("Profile name required"));
39 else if (m_hostname->text().length()==0) 43 else if (m_hostname->text().length()==0)
40 QMessageBox::critical(this, tr("Error"), tr("Host name required")); 44 QMessageBox::critical(this, tr("Error"), tr("Host name required"));
41 else if (m_port->text().toInt()<=0) 45 else if (m_port->text().toInt()<=0)
42 QMessageBox::critical(this, tr("Error"), tr("Port required")); 46 QMessageBox::critical(this, tr("Error"), tr("Port required"));
43 else if (m_nickname->text().length()==0) 47 else if (m_nickname->text().length()==0)
44 QMessageBox::critical(this, tr("Error"), tr("Nickname required")); 48 QMessageBox::critical(this, tr("Error"), tr("Nickname required"));
45 else if (m_realname->text().length()==0) 49 else if (m_realname->text().length()==0)
46 QMessageBox::critical(this, tr("Error"), tr("Realname required")); 50 QMessageBox::critical(this, tr("Error"), tr("Realname required"));
47 else 51 else {
52 /* Now verify whether the channel list has a valid format */
53 QStringList channels = QStringList::split(QChar(','), m_channels->text());
54 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
55 QString channelName = (*it).stripWhiteSpace();
56 if (!channelName.startsWith("#")) {
57 QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'"));
58 return;
59 }
60 }
48 QDialog::accept(); 61 QDialog::accept();
62 }
49} 63}
50 64
51IRCServer IRCServerEditor::getServer() { 65IRCServer IRCServerEditor::getServer() {
52 IRCServer server; 66 IRCServer server;
53 server.setName(m_name->text()); 67 server.setName(m_name->text());
54 server.setHostname(m_hostname->text()); 68 server.setHostname(m_hostname->text());
55 server.setPort(m_port->text().toInt()); 69 server.setPort(m_port->text().toInt());
56 server.setNick(m_nickname->text()); 70 server.setNick(m_nickname->text());
57 server.setRealname(m_realname->text()); 71 server.setRealname(m_realname->text());
58 server.setUsername(m_nickname->text()); 72 server.setUsername(m_nickname->text());
59 server.setPassword(m_password->text()); 73 server.setPassword(m_password->text());
74 server.setChannels(m_channels->text());
60 return server; 75 return server;
61} 76}
diff --git a/noncore/net/opieirc/ircservereditor.h b/noncore/net/opieirc/ircservereditor.h
index 20c94f7..22311f7 100644
--- a/noncore/net/opieirc/ircservereditor.h
+++ b/noncore/net/opieirc/ircservereditor.h
@@ -1,44 +1,45 @@
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 __IRCSERVEREDITOR 21#ifndef __IRCSERVEREDITOR
22#define __IRCSERVEREDITOR 22#define __IRCSERVEREDITOR
23 23
24#include <qdialog.h> 24#include <qdialog.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include "ircserver.h" 26#include "ircserver.h"
27 27
28class IRCServerEditor : public QDialog { 28class IRCServerEditor : public QDialog {
29 Q_OBJECT 29 Q_OBJECT
30public: 30public:
31 IRCServerEditor(IRCServer server, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); 31 IRCServerEditor(IRCServer server, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0);
32 IRCServer getServer(); 32 IRCServer getServer();
33protected slots: 33protected slots:
34 void accept(); 34 void accept();
35protected: 35protected:
36 QLineEdit *m_name; 36 QLineEdit *m_name;
37 QLineEdit *m_hostname; 37 QLineEdit *m_hostname;
38 QLineEdit *m_port; 38 QLineEdit *m_port;
39 QLineEdit *m_nickname; 39 QLineEdit *m_nickname;
40 QLineEdit *m_password; 40 QLineEdit *m_password;
41 QLineEdit *m_realname; 41 QLineEdit *m_realname;
42 QLineEdit *m_channels;
42}; 43};
43 44
44#endif /* __IRCSERVEREDITOR_H */ 45#endif /* __IRCSERVEREDITOR_H */
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp
index b2d746a..e664ba1 100644
--- a/noncore/net/opieirc/ircserverlist.cpp
+++ b/noncore/net/opieirc/ircserverlist.cpp
@@ -1,131 +1,133 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qhbox.h> 4#include <qhbox.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include "ircserverlist.h" 6#include "ircserverlist.h"
7#include "ircservereditor.h" 7#include "ircservereditor.h"
8#include <stdio.h> 8#include <stdio.h>
9 9
10class IRCListBoxServer : public QListBoxText { 10class IRCListBoxServer : public QListBoxText {
11public: 11public:
12 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { 12 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) {
13 m_server = server; 13 m_server = server;
14 } 14 }
15 15
16 IRCServer server() { 16 IRCServer server() {
17 return m_server; 17 return m_server;
18 } 18 }
19 19
20 void setServer(IRCServer server) { 20 void setServer(IRCServer server) {
21 m_server = server; 21 m_server = server;
22 setText(m_server.name()); 22 setText(m_server.name());
23 } 23 }
24protected: 24protected:
25 IRCServer m_server; 25 IRCServer m_server;
26}; 26};
27 27
28IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { 28IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) {
29 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); 29 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5);
30 setCaption(tr("Serverlist Browser")); 30 setCaption(tr("Serverlist Browser"));
31 QLabel *label = new QLabel(tr("Please choose a server profile"), this); 31 QLabel *label = new QLabel(tr("Please choose a server profile"), this);
32 label->setAlignment(AlignHCenter); 32 label->setAlignment(AlignHCenter);
33 layout->addWidget(label); 33 layout->addWidget(label);
34 m_list = new QListBox(this); 34 m_list = new QListBox(this);
35 layout->addWidget(m_list); 35 layout->addWidget(m_list);
36 QHBox *buttons = new QHBox(this); 36 QHBox *buttons = new QHBox(this);
37 QPushButton *del = new QPushButton(tr("Delete"), buttons); 37 QPushButton *del = new QPushButton(tr("Delete"), buttons);
38 QPushButton *edit = new QPushButton(tr("Edit"), buttons); 38 QPushButton *edit = new QPushButton(tr("Edit"), buttons);
39 QPushButton *add = new QPushButton(tr("Add"), buttons); 39 QPushButton *add = new QPushButton(tr("Add"), buttons);
40 connect(del, SIGNAL(clicked()), this, SLOT(delServer())); 40 connect(del, SIGNAL(clicked()), this, SLOT(delServer()));
41 connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); 41 connect(edit, SIGNAL(clicked()), this, SLOT(editServer()));
42 connect(add, SIGNAL(clicked()), this, SLOT(addServer())); 42 connect(add, SIGNAL(clicked()), this, SLOT(addServer()));
43 layout->addWidget(buttons); 43 layout->addWidget(buttons);
44 /* Load the configuration file */ 44 /* Load the configuration file */
45 m_config = new Config("OpieIRC"); 45 m_config = new Config("OpieIRC");
46 m_config->setGroup("OpieIRC"); 46 m_config->setGroup("OpieIRC");
47 int count = m_config->readNumEntry("ServerCount", 0); 47 int count = m_config->readNumEntry("ServerCount", 0);
48 if (count) { 48 if (count) {
49 for (int i=0; i<count; i++) { 49 for (int i=0; i<count; i++) {
50 m_config->setGroup("OpieIRC"); 50 m_config->setGroup("OpieIRC");
51 QString name = m_config->readEntry("Server"+QString::number(i)); 51 QString name = m_config->readEntry("Server"+QString::number(i));
52 if (name.length() > 0) { 52 if (name.length() > 0) {
53 IRCServer server; 53 IRCServer server;
54 m_config->setGroup(name); 54 m_config->setGroup(name);
55 server.setName(name); 55 server.setName(name);
56 server.setHostname(m_config->readEntry("Hostname")); 56 server.setHostname(m_config->readEntry("Hostname"));
57 server.setPort(m_config->readNumEntry("Port")); 57 server.setPort(m_config->readNumEntry("Port"));
58 server.setUsername(m_config->readEntry("Username")); 58 server.setUsername(m_config->readEntry("Username"));
59 server.setPassword(m_config->readEntry("Password")); 59 server.setPassword(m_config->readEntry("Password"));
60 server.setNick(m_config->readEntry("Nick")); 60 server.setNick(m_config->readEntry("Nick"));
61 server.setRealname(m_config->readEntry("Realname")); 61 server.setRealname(m_config->readEntry("Realname"));
62 server.setChannels(m_config->readEntry("Channels"));
62 m_list->insertItem(new IRCListBoxServer(server)); 63 m_list->insertItem(new IRCListBoxServer(server));
63 } 64 }
64 } 65 }
65 } 66 }
66 67
67 showMaximized(); 68 showMaximized();
68} 69}
69 70
70void IRCServerList::addServer() { 71void IRCServerList::addServer() {
71 IRCServer server; 72 IRCServer server;
72 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 73 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
73 if (editor.exec() == QDialog::Accepted) { 74 if (editor.exec() == QDialog::Accepted) {
74 server = editor.getServer(); 75 server = editor.getServer();
75 /* Gets deleted by QListBox, so this is ok */ 76 /* Gets deleted by QListBox, so this is ok */
76 m_list->insertItem(new IRCListBoxServer(server)); 77 m_list->insertItem(new IRCListBoxServer(server));
77 } 78 }
78} 79}
79 80
80void IRCServerList::delServer() { 81void IRCServerList::delServer() {
81 int index = m_list->currentItem(); 82 int index = m_list->currentItem();
82 if (index != -1) { 83 if (index != -1) {
83 m_list->removeItem(index); 84 m_list->removeItem(index);
84 } 85 }
85} 86}
86 87
87void IRCServerList::editServer() { 88void IRCServerList::editServer() {
88 int index = m_list->currentItem(); 89 int index = m_list->currentItem();
89 if (index != -1) { 90 if (index != -1) {
90 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); 91 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index);
91 IRCServer server = item->server(); 92 IRCServer server = item->server();
92 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 93 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
93 if (editor.exec() == QDialog::Accepted) { 94 if (editor.exec() == QDialog::Accepted) {
94 server = editor.getServer(); 95 server = editor.getServer();
95 item->setServer(server); 96 item->setServer(server);
96 } 97 }
97 } 98 }
98} 99}
99 100
100int IRCServerList::exec() { 101int IRCServerList::exec() {
101 int returncode = QDialog::exec(); 102 int returncode = QDialog::exec();
102 /* Now save the changes */ 103 /* Now save the changes */
103 m_config->setGroup("OpieIRC"); 104 m_config->setGroup("OpieIRC");
104 m_config->clearGroup(); 105 m_config->clearGroup();
105 m_config->writeEntry("ServerCount", QString::number(m_list->count())); 106 m_config->writeEntry("ServerCount", QString::number(m_list->count()));
106 for (unsigned int i=0; i<m_list->count(); i++) { 107 for (unsigned int i=0; i<m_list->count(); i++) {
107 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); 108 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
108 m_config->setGroup("OpieIRC"); 109 m_config->setGroup("OpieIRC");
109 m_config->writeEntry("Server"+QString::number(i), server.name()); 110 m_config->writeEntry("Server"+QString::number(i), server.name());
110 m_config->setGroup(server.name()); 111 m_config->setGroup(server.name());
111 m_config->writeEntry("Hostname", server.hostname()); 112 m_config->writeEntry("Hostname", server.hostname());
112 m_config->writeEntry("Port", QString::number(server.port())); 113 m_config->writeEntry("Port", QString::number(server.port()));
113 m_config->writeEntry("Username", server.username()); 114 m_config->writeEntry("Username", server.username());
114 m_config->writeEntry("Password", server.password()); 115 m_config->writeEntry("Password", server.password());
115 m_config->writeEntry("Nick", server.nick()); 116 m_config->writeEntry("Nick", server.nick());
116 m_config->writeEntry("Realname", server.realname()); 117 m_config->writeEntry("Realname", server.realname());
118 m_config->writeEntry("Channels", server.channels());
117 } 119 }
118 return returncode; 120 return returncode;
119} 121}
120 122
121bool IRCServerList::hasServer() { 123bool IRCServerList::hasServer() {
122 return (m_list->currentItem() != -1); 124 return (m_list->currentItem() != -1);
123} 125}
124 126
125IRCServer IRCServerList::server() { 127IRCServer IRCServerList::server() {
126 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); 128 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server();
127} 129}
128 130
129IRCServerList::~IRCServerList() { 131IRCServerList::~IRCServerList() {
130 delete m_config; 132 delete m_config;
131} 133}
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 724f4bd..2ad56a8 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,146 +1,184 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <qtextstream.h>
2#include "ircservertab.h" 3#include "ircservertab.h"
3 4
4IRCServerTab::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) {
5 m_server = server; 6 m_server = server;
6 m_session = new IRCSession(&m_server); 7 m_session = new IRCSession(&m_server);
7 m_mainWindow = mainWindow; 8 m_mainWindow = mainWindow;
8 m_close = FALSE; 9 m_close = FALSE;
9 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>");
10 m_textview = new QTextView(this); 11 m_textview = new QTextView(this);
11 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 12 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
12 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 13 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
13 m_layout->add(m_textview); 14 m_layout->add(m_textview);
14 m_field = new QLineEdit(this); 15 m_field = new QLineEdit(this);
15 m_layout->add(m_field); 16 m_layout->add(m_field);
16 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 17 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
17 m_field->setFocus(); 18 m_field->setFocus();
18 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 19 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
19} 20}
20 21
21void IRCServerTab::appendText(QString text) { 22void IRCServerTab::appendText(QString text) {
22 /* not using append because it creates layout problems */ 23 /* not using append because it creates layout problems */
23 m_textview->setText(m_textview->text() + text); 24 m_textview->setText(m_textview->text() + text);
24 m_textview->ensureVisible(0, m_textview->contentsHeight()); 25 m_textview->ensureVisible(0, m_textview->contentsHeight());
25} 26}
26 27
27IRCServerTab::~IRCServerTab() { 28IRCServerTab::~IRCServerTab() {
28 QListIterator<IRCChannelTab> it(m_channelTabs);
29 for (; it.current(); ++it) {
30 m_mainWindow->killTab(it.current());
31 }
32 delete m_session; 29 delete m_session;
33} 30}
34 31
35void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 32void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
36 m_channelTabs.remove(tab); 33 m_channelTabs.remove(tab);
37} 34}
38 35
39QString IRCServerTab::title() { 36QString IRCServerTab::title() {
40 return "Server"; 37 return "Server";
41} 38}
42 39
43IRCSession *IRCServerTab::session() { 40IRCSession *IRCServerTab::session() {
44 return m_session; 41 return m_session;
45} 42}
46 43
47IRCServer *IRCServerTab::server() { 44IRCServer *IRCServerTab::server() {
48 return &m_server; 45 return &m_server;
49} 46}
50 47
48void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
49 QTextIStream stream(&line);
50 QString command;
51 stream >> command;
52 command = command.upper().right(command.length()-1);
53
54 if (command == "JOIN") {
55 QString channel;
56 stream >> channel;
57 if (channel.length() > 0 && channel.startsWith("#")) {
58 m_session->join(channel);
59 } else {
60 tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>");
61 }
62 } else {
63 tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>");
64 }
65}
66
51void IRCServerTab::processCommand() { 67void IRCServerTab::processCommand() {
68 QString text = m_field->text();
69 if (text.startsWith("/") && !text.startsWith("//")) {
70 /* Command mode */
71 executeCommand(this, text);
72 }
52 m_field->clear(); 73 m_field->clear();
53 appendText("<font color=\"#ff0000\">Not supported yet</font><br>");
54} 74}
55 75
56void IRCServerTab::doConnect() { 76void IRCServerTab::doConnect() {
57 m_session->beginSession(); 77 m_session->beginSession();
58} 78}
59 79
60void IRCServerTab::remove() { 80void IRCServerTab::remove() {
81 /* Close requested */
61 if (m_session->isSessionActive()) { 82 if (m_session->isSessionActive()) {
83 /* While there is a running session */
62 m_close = TRUE; 84 m_close = TRUE;
63 m_session->endSession(); 85 m_session->endSession();
64 } else { 86 } else {
87 /* Session has previously been closed */
88 m_channelTabs.first();
89 while (m_channelTabs.current() != 0) {
90 m_mainWindow->killTab(m_channelTabs.current());
91 }
65 m_mainWindow->killTab(this); 92 m_mainWindow->killTab(this);
66 } 93 }
67} 94}
68 95
69IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 96IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
70 QListIterator<IRCChannelTab> it(m_channelTabs); 97 QListIterator<IRCChannelTab> it(m_channelTabs);
71 98
72 for (; it.current(); ++it) { 99 for (; it.current(); ++it) {
73 if (it.current()->channel() == channel) 100 if (it.current()->channel() == channel)
74 return it.current(); 101 return it.current();
75 } 102 }
76 return 0; 103 return 0;
77} 104}
78 105
79void IRCServerTab::display(IRCOutput output) { 106void IRCServerTab::display(IRCOutput output) {
107
108 /* All messages to be displayed inside the GUI get here */
80 switch (output.type()) { 109 switch (output.type()) {
81 case OUTPUT_CONNCLOSE: 110 case OUTPUT_CONNCLOSE:
82 if (m_close) 111 if (m_close) {
112 m_channelTabs.first();
113 while (m_channelTabs.current() != 0) {
114 m_mainWindow->killTab(m_channelTabs.current());
115 }
83 m_mainWindow->killTab(this); 116 m_mainWindow->killTab(this);
84 else 117 } else {
85 appendText("<font color=\"#0000dd\">" + output.message() +"</font><br>"); 118 appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>");
119 QListIterator<IRCChannelTab> it(m_channelTabs);
120 for (; it.current(); ++it) {
121 it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>");
122 }
123 }
86 break; 124 break;
87 case OUTPUT_SELFJOIN: { 125 case OUTPUT_SELFJOIN: {
88 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 126 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
89 m_channelTabs.append(channeltab); 127 m_channelTabs.append(channeltab);
90 m_mainWindow->addTab(channeltab); 128 m_mainWindow->addTab(channeltab);
91 } 129 }
92 break; 130 break;
93 case OUTPUT_CHANPRIVMSG: { 131 case OUTPUT_CHANPRIVMSG: {
94 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 132 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
95 channelTab->appendText("&lt;<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>&gt; "+output.message()+"<br>"); 133 channelTab->appendText("&lt;<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>&gt; "+output.htmlMessage()+"<br>");
96 } 134 }
97 break; 135 break;
98 case OUTPUT_SELFPART: { 136 case OUTPUT_SELFPART: {
99 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 137 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
100 if (channelTab) 138 if (channelTab)
101 m_mainWindow->killTab(channelTab); 139 m_mainWindow->killTab(channelTab);
102 } 140 }
103 break; 141 break;
104 case OUTPUT_SELFKICK: { 142 case OUTPUT_SELFKICK: {
105 appendText("<font color=\"#ff0000\">" + output.message() + "</font><br>"); 143 appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>");
106 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 144 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
107 if (channelTab) 145 if (channelTab)
108 m_mainWindow->killTab(channelTab); 146 m_mainWindow->killTab(channelTab);
109 } 147 }
110 break; 148 break;
111 case OUTPUT_CHANACTION: { 149 case OUTPUT_CHANACTION: {
112 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 150 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
113 channelTab->appendText("<font color=\"#cc0000\">"+output.message()+"</font><br>"); 151 channelTab->appendText("<font color=\"#cc0000\">"+output.htmlMessage()+"</font><br>");
114 } 152 }
115 break; 153 break;
116 case OUTPUT_QUIT: { 154 case OUTPUT_QUIT: {
117 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 155 QString nick = ((IRCPerson *)output.getParam(0))->nick();
118 QListIterator<IRCChannelTab> it(m_channelTabs); 156 QListIterator<IRCChannelTab> it(m_channelTabs);
119 for (; it.current(); ++it) { 157 for (; it.current(); ++it) {
120 if (it.current()->list()->hasPerson(nick)) { 158 if (it.current()->list()->hasPerson(nick)) {
121 it.current()->appendText("<font color=\"#aa3e00\">"+output.message()+"</font><br>"); 159 it.current()->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>");
122 it.current()->list()->update(); 160 it.current()->list()->update();
123 } 161 }
124 } 162 }
125 } 163 }
126 break; 164 break;
127 case OUTPUT_OTHERJOIN: 165 case OUTPUT_OTHERJOIN:
128 case OUTPUT_OTHERKICK: 166 case OUTPUT_OTHERKICK:
129 case OUTPUT_CHANPERSONMODE: 167 case OUTPUT_CHANPERSONMODE:
130 case OUTPUT_OTHERPART: { 168 case OUTPUT_OTHERPART: {
131 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 169 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
132 channelTab->appendText("<font color=\"#aa3e00\">"+output.message()+"</font><br>"); 170 channelTab->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>");
133 channelTab->list()->update(); 171 channelTab->list()->update();
134 } 172 }
135 break; 173 break;
136 case OUTPUT_CTCP: 174 case OUTPUT_CTCP:
137 appendText("<font color=\"#00bb00\">" + output.message() + "</font><br>"); 175 appendText("<font color=\"#00bb00\">" + output.htmlMessage() + "</font><br>");
138 break; 176 break;
139 case OUTPUT_ERROR: 177 case OUTPUT_ERROR:
140 appendText("<font color=\"#ff0000\">" + output.message() + "</font><br>"); 178 appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>");
141 break; 179 break;
142 default: 180 default:
143 appendText("<font color=\"#0000dd\">" + output.message() + "</font><br>"); 181 appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "</font><br>");
144 break; 182 break;
145 } 183 }
146} 184}
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h
index fa9a0a3..cfa0832 100644
--- a/noncore/net/opieirc/ircservertab.h
+++ b/noncore/net/opieirc/ircservertab.h
@@ -1,60 +1,63 @@
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 __IRCSERVERTAB_H 21#ifndef __IRCSERVERTAB_H
22#define __IRCSERVERTAB_H 22#define __IRCSERVERTAB_H
23 23
24#include "irctab.h" 24#include "irctab.h"
25#include "ircsession.h" 25#include "ircsession.h"
26#include "mainwindow.h" 26#include "mainwindow.h"
27#include "ircchanneltab.h" 27#include "ircchanneltab.h"
28 28
29class IRCServerTab : public IRCTab { 29class IRCServerTab : public IRCTab {
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 /* IRCTab implementation */ 32 /* IRCTab implementation */
33 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 33 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
34 ~IRCServerTab(); 34 ~IRCServerTab();
35 QString title(); 35 QString title();
36 IRCSession *session(); 36 IRCSession *session();
37 IRCServer *server(); 37 IRCServer *server();
38 38
39 /* Start the server session */ 39 /* Start the server session */
40 void doConnect(); 40 void doConnect();
41 void removeChannelTab(IRCChannelTab *tab); 41 void removeChannelTab(IRCChannelTab *tab);
42
43 /* Execute a user command such as /join */
44 void executeCommand(IRCTab *tab, QString line);
42protected: 45protected:
43 void appendText(QString text); 46 void appendText(QString text);
44 IRCChannelTab *getTabForChannel(IRCChannel *channel); 47 IRCChannelTab *getTabForChannel(IRCChannel *channel);
45public slots: 48public slots:
46 void remove(); 49 void remove();
47 void processCommand(); 50 void processCommand();
48protected slots: 51protected slots:
49 void display(IRCOutput output); 52 void display(IRCOutput output);
50protected: 53protected:
51 bool m_close; 54 bool m_close;
52 IRCServer m_server; 55 IRCServer m_server;
53 IRCSession *m_session; 56 IRCSession *m_session;
54 MainWindow *m_mainWindow; 57 MainWindow *m_mainWindow;
55 QTextView *m_textview; 58 QTextView *m_textview;
56 QLineEdit *m_field; 59 QLineEdit *m_field;
57 QList<IRCChannelTab> m_channelTabs; 60 QList<IRCChannelTab> m_channelTabs;
58}; 61};
59 62
60#endif /* __IRCSERVERTAB_H */ 63#endif /* __IRCSERVERTAB_H */
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp
index b81038f..89df68c 100644
--- a/noncore/net/opieirc/ircsession.cpp
+++ b/noncore/net/opieirc/ircsession.cpp
@@ -1,99 +1,103 @@
1#include "ircsession.h" 1#include "ircsession.h"
2#include "ircmessageparser.h" 2#include "ircmessageparser.h"
3#include "ircversion.h" 3#include "ircversion.h"
4 4
5IRCSession::IRCSession(IRCServer *server) { 5IRCSession::IRCSession(IRCServer *server) {
6 m_server = server; 6 m_server = server;
7 m_connection = new IRCConnection(m_server); 7 m_connection = new IRCConnection(m_server);
8 m_parser = new IRCMessageParser(this); 8 m_parser = new IRCMessageParser(this);
9 connect(m_connection, SIGNAL(messageArrived(IRCMessage *)), this, SLOT(handleMessage(IRCMessage *))); 9 connect(m_connection, SIGNAL(messageArrived(IRCMessage *)), this, SLOT(handleMessage(IRCMessage *)));
10 connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); 10 connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
11 connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); 11 connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
12} 12}
13 13
14IRCSession::~IRCSession() { 14IRCSession::~IRCSession() {
15 /* We want this to get deleted automatically */
16 m_channels.setAutoDelete(TRUE);
17 m_people.setAutoDelete(TRUE);
18
15 delete m_parser; 19 delete m_parser;
16 delete m_connection; 20 delete m_connection;
17} 21}
18 22
19void IRCSession::beginSession() { 23void IRCSession::beginSession() {
20 m_connection->doConnect(); 24 m_connection->doConnect();
21} 25}
22 26
23void IRCSession::join(QString channelname) { 27void IRCSession::join(QString channelname) {
24 m_connection->sendLine("JOIN "+channelname); 28 m_connection->sendLine("JOIN "+channelname);
25} 29}
26 30
27void IRCSession::sendMessage(IRCPerson *person, QString message) { 31void IRCSession::sendMessage(IRCPerson *person, QString message) {
28 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); 32 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message);
29} 33}
30 34
31void IRCSession::sendMessage(IRCChannel *channel, QString message) { 35void IRCSession::sendMessage(IRCChannel *channel, QString message) {
32 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); 36 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message);
33} 37}
34 38
35bool IRCSession::isSessionActive() { 39bool IRCSession::isSessionActive() {
36 return m_connection->isConnected(); 40 return m_connection->isConnected();
37} 41}
38 42
39void IRCSession::endSession() { 43void IRCSession::endSession() {
40 if (m_connection->isLoggedIn()) 44 if (m_connection->isLoggedIn())
41 m_connection->sendLine("QUIT :" APP_VERSION); 45 m_connection->sendLine("QUIT :" APP_VERSION);
42 else 46 else
43 m_connection->close(); 47 m_connection->close();
44} 48}
45 49
46void IRCSession::part(IRCChannel *channel) { 50void IRCSession::part(IRCChannel *channel) {
47 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); 51 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION);
48} 52}
49 53
50 54
51IRCChannel *IRCSession::getChannel(QString channelname) { 55IRCChannel *IRCSession::getChannel(QString channelname) {
52 QListIterator<IRCChannel> it(m_channels); 56 QListIterator<IRCChannel> it(m_channels);
53 for (; it.current(); ++it) { 57 for (; it.current(); ++it) {
54 if (it.current()->channelname() == channelname) { 58 if (it.current()->channelname() == channelname) {
55 return it.current(); 59 return it.current();
56 } 60 }
57 } 61 }
58 return 0; 62 return 0;
59} 63}
60 64
61IRCPerson *IRCSession::getPerson(QString nickname) { 65IRCPerson *IRCSession::getPerson(QString nickname) {
62 QListIterator<IRCPerson> it(m_people); 66 QListIterator<IRCPerson> it(m_people);
63 for (; it.current(); ++it) { 67 for (; it.current(); ++it) {
64 if (it.current()->nick() == nickname) { 68 if (it.current()->nick() == nickname) {
65 return it.current(); 69 return it.current();
66 } 70 }
67 } 71 }
68 return 0; 72 return 0;
69} 73}
70 74
71void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) { 75void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) {
72 QListIterator<IRCChannel> it(m_channels); 76 QListIterator<IRCChannel> it(m_channels);
73 for (; it.current(); ++it) { 77 for (; it.current(); ++it) {
74 if (it.current()->getPerson(person->nick()) != 0) { 78 if (it.current()->getPerson(person->nick()) != 0) {
75 channels.append(it.current()); 79 channels.append(it.current());
76 } 80 }
77 } 81 }
78} 82}
79 83
80void IRCSession::addPerson(IRCPerson *person) { 84void IRCSession::addPerson(IRCPerson *person) {
81 m_people.append(person); 85 m_people.append(person);
82} 86}
83 87
84void IRCSession::addChannel(IRCChannel *channel) { 88void IRCSession::addChannel(IRCChannel *channel) {
85 m_channels.append(channel); 89 m_channels.append(channel);
86} 90}
87 91
88void IRCSession::removeChannel(IRCChannel *channel) { 92void IRCSession::removeChannel(IRCChannel *channel) {
89 m_channels.remove(channel); 93 m_channels.remove(channel);
90} 94}
91 95
92void IRCSession::removePerson(IRCPerson *person) { 96void IRCSession::removePerson(IRCPerson *person) {
93 m_people.remove(person); 97 m_people.remove(person);
94} 98}
95 99
96void IRCSession::handleMessage(IRCMessage *message) { 100void IRCSession::handleMessage(IRCMessage *message) {
97 m_parser->parse(message); 101 m_parser->parse(message);
98} 102}
99 103
diff --git a/noncore/net/opieirc/irctab.h b/noncore/net/opieirc/irctab.h
index 3124980..0ce9777 100644
--- a/noncore/net/opieirc/irctab.h
+++ b/noncore/net/opieirc/irctab.h
@@ -1,47 +1,48 @@
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 __IRCTAB_H 21#ifndef __IRCTAB_H
22#define __IRCTAB_H 22#define __IRCTAB_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtextview.h> 25#include <qtextview.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include "ircsession.h" 29#include "ircsession.h"
30 30
31/* This is the base class for any tabs which need to be integrated into 31/* This is the base class for any tabs which need to be integrated into
32 the main GUI tab widget */ 32 the main GUI tab widget */
33 33
34class IRCTab : public QWidget { 34class IRCTab : public QWidget {
35 Q_OBJECT 35 Q_OBJECT
36public: 36public:
37 IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 37 IRCTab(QWidget *parent = 0, const char *name = 0, WFlags f = 0);
38 virtual QString title() = 0; 38 virtual QString title() = 0;
39 virtual IRCSession *session() = 0; 39 virtual IRCSession *session() = 0;
40 virtual void appendText(QString text) = 0;
40public slots: 41public slots:
41 virtual void remove() = 0; 42 virtual void remove() = 0;
42protected: 43protected:
43 QLabel *m_description; 44 QLabel *m_description;
44 QVBoxLayout *m_layout; 45 QVBoxLayout *m_layout;
45}; 46};
46 47
47#endif /* __IRCTAB_H */ 48#endif /* __IRCTAB_H */
diff --git a/noncore/net/opieirc/ircversion.h b/noncore/net/opieirc/ircversion.h
index 0ef0d2f..f8510e6 100644
--- a/noncore/net/opieirc/ircversion.h
+++ b/noncore/net/opieirc/ircversion.h
@@ -1,27 +1,27 @@
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 __IRCVERSION_H 21#ifndef __IRCVERSION_H
22#define __IRCVERSION_H 22#define __IRCVERSION_H
23 23
24#define APP_VERSION "OpieIRC 0.1" 24#define APP_VERSION "OpieIRC 0.2"
25#define APP_COPYSTR "(c) 2002 by Wenzel Jakob" 25#define APP_COPYSTR "(c) 2002 by Wenzel Jakob"
26 26
27#endif /* __IRCVERSION_H */ 27#endif /* __IRCVERSION_H */