summaryrefslogtreecommitdiff
Unidiff
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
@@ -8,2 +8,7 @@ IRCChannel::IRCChannel(QString channelname) {
8 8
9IRCChannel::~IRCChannel() {
10 /* We want this to get deleted */
11 m_people.setAutoDelete(TRUE);
12}
13
9QString IRCChannel::channelname() { 14QString IRCChannel::channelname() {
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
@@ -49,2 +49,3 @@ public:
49 IRCChannel(QString channelname); 49 IRCChannel(QString channelname);
50 ~IRCChannel();
50 51
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
@@ -40,7 +40,19 @@ IRCChannelTab::~IRCChannelTab() {
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}
@@ -67,3 +79,7 @@ IRCSession *IRCChannelTab::session() {
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}
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
@@ -62,2 +62,10 @@ void IRCConnection::dataReady() {
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;
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
@@ -26,2 +26,3 @@ IRCMessage::IRCMessage(QString line) {
26 } 26 }
27
27 /* Create a list of all parameters */ 28 /* Create a list of all parameters */
@@ -38,2 +39,4 @@ IRCMessage::IRCMessage(QString line) {
38 } 39 }
40
41
39 m_commandNumber = m_command.toInt(&m_isNumerical); 42 m_commandNumber = m_command.toInt(&m_isNumerical);
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
@@ -28,2 +28,3 @@ IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
28}; 28};
29
29/* Lookup table for numerical commands */ 30/* Lookup table for numerical commands */
@@ -230,2 +231,3 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
230 it.current()->removePerson(chanperson); 231 it.current()->removePerson(chanperson);
232 delete chanperson;
231 } 233 }
@@ -235,2 +237,3 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
235 emit outputReady(output); 237 emit outputReady(output);
238 delete person;
236 } else { 239 } else {
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
@@ -15,2 +15,9 @@ QString IRCOutput::message() {
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) {
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
@@ -62,2 +62,4 @@ public:
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);
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
@@ -6,2 +6,4 @@ IRCServer::IRCServer() {
6 6
7/* Setter implementations */
8
7void IRCServer::setHostname(QString hostname) { 9void IRCServer::setHostname(QString hostname) {
@@ -34,2 +36,8 @@ void IRCServer::setRealname(QString realname) {
34 36
37void IRCServer::setChannels(QString channels) {
38 m_channels = channels;
39}
40
41/* Getter implementations */
42
35QString IRCServer::hostname() { 43QString IRCServer::hostname() {
@@ -62 +70,5 @@ QString IRCServer::realname() {
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
@@ -30,4 +30,6 @@ class 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);
@@ -39,3 +41,5 @@ public:
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();
@@ -47,2 +51,3 @@ public:
47 QString realname(); 51 QString realname();
52 QString channels();
48protected: 53protected:
@@ -55,2 +60,3 @@ protected:
55 QString m_realname; 60 QString m_realname;
61 QString m_channels;
56}; 62};
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
@@ -6,3 +6,3 @@
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);
@@ -31,2 +31,6 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
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();
@@ -46,4 +50,14 @@ void IRCServerEditor::accept() {
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}
@@ -59,2 +73,3 @@ IRCServer IRCServerEditor::getServer() {
59 server.setPassword(m_password->text()); 73 server.setPassword(m_password->text());
74 server.setChannels(m_channels->text());
60 return server; 75 return server;
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
@@ -41,2 +41,3 @@ protected:
41 QLineEdit *m_realname; 41 QLineEdit *m_realname;
42 QLineEdit *m_channels;
42}; 43};
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
@@ -61,2 +61,3 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
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));
@@ -116,2 +117,3 @@ int IRCServerList::exec() {
116 m_config->writeEntry("Realname", server.realname()); 117 m_config->writeEntry("Realname", server.realname());
118 m_config->writeEntry("Channels", server.channels());
117 } 119 }
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,2 +1,3 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <qtextstream.h>
2#include "ircservertab.h" 3#include "ircservertab.h"
@@ -27,6 +28,2 @@ void IRCServerTab::appendText(QString text) {
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;
@@ -50,5 +47,28 @@ IRCServer *IRCServerTab::server() {
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}
@@ -60,3 +80,5 @@ void IRCServerTab::doConnect() {
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;
@@ -64,2 +86,7 @@ void IRCServerTab::remove() {
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);
@@ -79,8 +106,19 @@ IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
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;
@@ -94,3 +132,3 @@ void IRCServerTab::display(IRCOutput output) {
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 }
@@ -104,3 +142,3 @@ void IRCServerTab::display(IRCOutput output) {
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));
@@ -112,3 +150,3 @@ void IRCServerTab::display(IRCOutput output) {
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 }
@@ -120,3 +158,3 @@ void IRCServerTab::display(IRCOutput output) {
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();
@@ -131,3 +169,3 @@ void IRCServerTab::display(IRCOutput output) {
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();
@@ -136,9 +174,9 @@ void IRCServerTab::display(IRCOutput output) {
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;
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
@@ -41,2 +41,5 @@ public:
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:
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
@@ -14,2 +14,6 @@ IRCSession::IRCSession(IRCServer *server) {
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;
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
@@ -39,2 +39,3 @@ public:
39 virtual IRCSession *session() = 0; 39 virtual IRCSession *session() = 0;
40 virtual void appendText(QString text) = 0;
40public slots: 41public slots:
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
@@ -23,3 +23,3 @@
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"