summaryrefslogtreecommitdiff
Side-by-side diff
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) {
+IRCChannel::~IRCChannel() {
+ /* We want this to get deleted */
+ m_people.setAutoDelete(TRUE);
+}
+
QString 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:
IRCChannel(QString channelname);
+ ~IRCChannel();
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() {
void IRCChannelTab::processCommand() {
- if (m_field->text().length()>0) {
- session()->sendMessage(m_channel, m_field->text());
- appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+m_field->text()+"<br>");
- m_field->clear();
+ QString text = m_field->text();
+ if (text.length()>0) {
+ if (session()->isSessionActive()) {
+ if (text.startsWith("/") && !text.startsWith("//")) {
+ /* Command mode */
+ m_parentTab->executeCommand(this, text);;
+ } else {
+ if (session()->isSessionActive()) {
+ session()->sendMessage(m_channel, m_field->text());
+ appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+m_field->text()+"<br>");
+ }
+ }
+ } else {
+ appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>");
+ }
}
+ m_field->clear();
}
@@ -67,3 +79,7 @@ IRCSession *IRCChannelTab::session() {
void IRCChannelTab::remove() {
- session()->part(m_channel);
+ if (session()->isSessionActive()) {
+ session()->part(m_channel);
+ } else {
+ m_mainWindow->killTab(this);
+ }
}
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() {
if (!m_loggedIn && message.isNumerical() && message.commandNumber() == 1) {
+ /* Now autojoin all channels specified inside the server profile */
+ QStringList channels = QStringList::split(QChar(','), m_server->channels());
+ for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
+ QString channelName = (*it).stripWhiteSpace();
+ if (channelName.startsWith("#")) {
+ sendLine("JOIN "+ channelName);
+ }
+ }
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) {
}
+
/* Create a list of all parameters */
@@ -38,2 +39,4 @@ IRCMessage::IRCMessage(QString line) {
}
+
+
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[] = {
};
+
/* Lookup table for numerical commands */
@@ -230,2 +231,3 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
it.current()->removePerson(chanperson);
+ delete chanperson;
}
@@ -235,2 +237,3 @@ void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
emit outputReady(output);
+ delete person;
} 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() {
+QString IRCOutput::htmlMessage() {
+ QString htmlMessage =m_message.replace(QRegExp("&"), "&amp;");
+ htmlMessage = htmlMessage.replace(QRegExp(">"), "&gt;");
+ htmlMessage = htmlMessage.replace(QRegExp("<"), "&lt;");
+ return htmlMessage;
+}
+
void 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:
QString message();
+ /* Return the message with all HTML code escaped (for example &lt; instead of '<') */
+ QString htmlMessage();
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() {
+/* Setter implementations */
+
void IRCServer::setHostname(QString hostname) {
@@ -34,2 +36,8 @@ void IRCServer::setRealname(QString realname) {
+void IRCServer::setChannels(QString channels) {
+ m_channels = channels;
+}
+
+/* Getter implementations */
+
QString IRCServer::hostname() {
@@ -62 +70,5 @@ QString IRCServer::realname() {
+QString IRCServer::channels() {
+ return m_channels;
+}
+
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 {
public:
+ /* Initialize to the default values */
IRCServer();
+ /* Setters */
void setName(QString name);
@@ -39,3 +41,5 @@ public:
void setRealname(QString realname);
+ void setChannels(QString channels);
+ /* Getters */
QString hostname();
@@ -47,2 +51,3 @@ public:
QString realname();
+ QString channels();
protected:
@@ -55,2 +60,3 @@ protected:
QString m_realname;
+ QString m_channels;
};
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 @@
IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) {
- QGridLayout *layout = new QGridLayout(this, 6, 2, 5, 5);
+ QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5);
QLabel *label = new QLabel(tr("Profile name :"), this);
@@ -31,2 +31,6 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
layout->addWidget(m_password, 5, 1);
+ label = new QLabel(tr("Channels :"), this);
+ m_channels = new QLineEdit(server.channels(), this);
+ layout->addWidget(label, 6, 0);
+ layout->addWidget(m_channels, 6, 1);
showMaximized();
@@ -46,4 +50,14 @@ void IRCServerEditor::accept() {
QMessageBox::critical(this, tr("Error"), tr("Realname required"));
- else
+ else {
+ /* Now verify whether the channel list has a valid format */
+ QStringList channels = QStringList::split(QChar(','), m_channels->text());
+ for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
+ QString channelName = (*it).stripWhiteSpace();
+ if (!channelName.startsWith("#")) {
+ QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with '#'"));
+ return;
+ }
+ }
QDialog::accept();
+ }
}
@@ -59,2 +73,3 @@ IRCServer IRCServerEditor::getServer() {
server.setPassword(m_password->text());
+ server.setChannels(m_channels->text());
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:
QLineEdit *m_realname;
+ QLineEdit *m_channels;
};
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
server.setRealname(m_config->readEntry("Realname"));
+ server.setChannels(m_config->readEntry("Channels"));
m_list->insertItem(new IRCListBoxServer(server));
@@ -116,2 +117,3 @@ int IRCServerList::exec() {
m_config->writeEntry("Realname", server.realname());
+ m_config->writeEntry("Channels", server.channels());
}
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 @@
#include <stdio.h>
+#include <qtextstream.h>
#include "ircservertab.h"
@@ -27,6 +28,2 @@ void IRCServerTab::appendText(QString text) {
IRCServerTab::~IRCServerTab() {
- QListIterator<IRCChannelTab> it(m_channelTabs);
- for (; it.current(); ++it) {
- m_mainWindow->killTab(it.current());
- }
delete m_session;
@@ -50,5 +47,28 @@ IRCServer *IRCServerTab::server() {
+void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
+ QTextIStream stream(&line);
+ QString command;
+ stream >> command;
+ command = command.upper().right(command.length()-1);
+
+ if (command == "JOIN") {
+ QString channel;
+ stream >> channel;
+ if (channel.length() > 0 && channel.startsWith("#")) {
+ m_session->join(channel);
+ } else {
+ tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>");
+ }
+ } else {
+ tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>");
+ }
+}
+
void IRCServerTab::processCommand() {
+ QString text = m_field->text();
+ if (text.startsWith("/") && !text.startsWith("//")) {
+ /* Command mode */
+ executeCommand(this, text);
+ }
m_field->clear();
- appendText("<font color=\"#ff0000\">Not supported yet</font><br>");
}
@@ -60,3 +80,5 @@ void IRCServerTab::doConnect() {
void IRCServerTab::remove() {
+ /* Close requested */
if (m_session->isSessionActive()) {
+ /* While there is a running session */
m_close = TRUE;
@@ -64,2 +86,7 @@ void IRCServerTab::remove() {
} else {
+ /* Session has previously been closed */
+ m_channelTabs.first();
+ while (m_channelTabs.current() != 0) {
+ m_mainWindow->killTab(m_channelTabs.current());
+ }
m_mainWindow->killTab(this);
@@ -79,8 +106,19 @@ IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
void IRCServerTab::display(IRCOutput output) {
+
+ /* All messages to be displayed inside the GUI get here */
switch (output.type()) {
case OUTPUT_CONNCLOSE:
- if (m_close)
+ if (m_close) {
+ m_channelTabs.first();
+ while (m_channelTabs.current() != 0) {
+ m_mainWindow->killTab(m_channelTabs.current());
+ }
m_mainWindow->killTab(this);
- else
- appendText("<font color=\"#0000dd\">" + output.message() +"</font><br>");
+ } else {
+ appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>");
+ QListIterator<IRCChannelTab> it(m_channelTabs);
+ for (; it.current(); ++it) {
+ it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>");
+ }
+ }
break;
@@ -94,3 +132,3 @@ void IRCServerTab::display(IRCOutput output) {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
- channelTab->appendText("&lt;<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>&gt; "+output.message()+"<br>");
+ channelTab->appendText("&lt;<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>&gt; "+output.htmlMessage()+"<br>");
}
@@ -104,3 +142,3 @@ void IRCServerTab::display(IRCOutput output) {
case OUTPUT_SELFKICK: {
- appendText("<font color=\"#ff0000\">" + output.message() + "</font><br>");
+ appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>");
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
@@ -112,3 +150,3 @@ void IRCServerTab::display(IRCOutput output) {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
- channelTab->appendText("<font color=\"#cc0000\">"+output.message()+"</font><br>");
+ channelTab->appendText("<font color=\"#cc0000\">"+output.htmlMessage()+"</font><br>");
}
@@ -120,3 +158,3 @@ void IRCServerTab::display(IRCOutput output) {
if (it.current()->list()->hasPerson(nick)) {
- it.current()->appendText("<font color=\"#aa3e00\">"+output.message()+"</font><br>");
+ it.current()->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>");
it.current()->list()->update();
@@ -131,3 +169,3 @@ void IRCServerTab::display(IRCOutput output) {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
- channelTab->appendText("<font color=\"#aa3e00\">"+output.message()+"</font><br>");
+ channelTab->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>");
channelTab->list()->update();
@@ -136,9 +174,9 @@ void IRCServerTab::display(IRCOutput output) {
case OUTPUT_CTCP:
- appendText("<font color=\"#00bb00\">" + output.message() + "</font><br>");
+ appendText("<font color=\"#00bb00\">" + output.htmlMessage() + "</font><br>");
break;
case OUTPUT_ERROR:
- appendText("<font color=\"#ff0000\">" + output.message() + "</font><br>");
+ appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>");
break;
default:
- appendText("<font color=\"#0000dd\">" + output.message() + "</font><br>");
+ appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "</font><br>");
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:
void removeChannelTab(IRCChannelTab *tab);
+
+ /* Execute a user command such as /join */
+ void executeCommand(IRCTab *tab, QString line);
protected:
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) {
IRCSession::~IRCSession() {
+ /* We want this to get deleted automatically */
+ m_channels.setAutoDelete(TRUE);
+ m_people.setAutoDelete(TRUE);
+
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:
virtual IRCSession *session() = 0;
+ virtual void appendText(QString text) = 0;
public 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 @@
-#define APP_VERSION "OpieIRC 0.1"
+#define APP_VERSION "OpieIRC 0.2"
#define APP_COPYSTR "(c) 2002 by Wenzel Jakob"