summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp7
-rw-r--r--noncore/net/opieirc/ircmessage.cpp1
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp10
-rw-r--r--noncore/net/opieirc/ircmessageparser.h1
-rw-r--r--noncore/net/opieirc/ircperson.cpp6
-rw-r--r--noncore/net/opieirc/ircperson.h3
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp76
-rw-r--r--noncore/net/opieirc/ircquerytab.h27
-rw-r--r--noncore/net/opieirc/ircservertab.cpp54
-rw-r--r--noncore/net/opieirc/ircservertab.h7
10 files changed, 182 insertions, 10 deletions
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index 3267525..4675265 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -14,6 +14,7 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
m_listVisible = TRUE;
m_listButton = new QPushButton(">", m_textview);
m_textview->setCornerWidget(m_listButton);
+ m_textview->setTextFormat(RichText);
connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
m_list = new IRCChannelList(m_channel, hbox);
m_list->update();
@@ -47,10 +48,8 @@ void IRCChannelTab::processCommand() {
} else {
if (text.startsWith("//"))
text = text.right(text.length()-1);
- if (session()->isSessionActive()) {
- session()->sendMessage(m_channel, m_field->text());
- appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>");
- }
+ session()->sendMessage(m_channel, m_field->text());
+ appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>");
}
} else {
appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>");
diff --git a/noncore/net/opieirc/ircmessage.cpp b/noncore/net/opieirc/ircmessage.cpp
index 9c2869c..d823ad1 100644
--- a/noncore/net/opieirc/ircmessage.cpp
+++ b/noncore/net/opieirc/ircmessage.cpp
@@ -77,7 +77,6 @@ IRCMessage::IRCMessage(QString line) {
printf("CTCP Command : '%s'\n", m_ctcpCommand.latin1());
printf("CTCP Destination : '%s'\n", m_ctcpDestination.latin1());
printf("CTCP param count is : '%i'\n", m_parameters.count());
-
*/
}
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 4038673..3063741 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -44,7 +44,9 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
{ 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD
{ 377, FUNC(parseNumericalStats) }, // RPL_MOTD2
{ 378, FUNC(parseNumericalStats) }, // RPL_MOTD3
- { 412, FUNC(parseNumericalStats) }, // ERNOTEXTTOSEND
+ { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK
+ { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK
+ { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND
{ 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
{ 0, 0 }
};
@@ -172,7 +174,7 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
person = new IRCPerson(message->prefix());
m_session->addPerson(person);
}
- IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
+ IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1));
output.addParam(person);
emit outputReady(output);
} else if (message->param(0).at(0) == '#') {
@@ -479,3 +481,7 @@ void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname")));
m_session->endSession();
}
+
+void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) {
+ emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname")));
+}
diff --git a/noncore/net/opieirc/ircmessageparser.h b/noncore/net/opieirc/ircmessageparser.h
index b45b8f0..f774047 100644
--- a/noncore/net/opieirc/ircmessageparser.h
+++ b/noncore/net/opieirc/ircmessageparser.h
@@ -81,6 +81,7 @@ private:
void parseNumericalNames(IRCMessage *message);
void parseNumericalEndOfNames(IRCMessage *message);
void parseNumericalNicknameInUse(IRCMessage *message);
+ void parseNumericalNoSuchNick(IRCMessage *message);
void parseCTCPPing(IRCMessage *message);
void parseCTCPVersion(IRCMessage *message);
void parseCTCPAction(IRCMessage *message);
diff --git a/noncore/net/opieirc/ircperson.cpp b/noncore/net/opieirc/ircperson.cpp
index bd6b8d6..bd341f1 100644
--- a/noncore/net/opieirc/ircperson.cpp
+++ b/noncore/net/opieirc/ircperson.cpp
@@ -7,6 +7,12 @@ IRCPerson::IRCPerson() {
m_host = "";
}
+IRCPerson::IRCPerson(const IRCPerson &person) {
+ m_nick = person.m_nick;
+ m_user = person.m_user;
+ m_host = person.m_host;
+}
+
IRCPerson::IRCPerson(QString mask) {
IRCPerson();
fromMask(mask);
diff --git a/noncore/net/opieirc/ircperson.h b/noncore/net/opieirc/ircperson.h
index 850f91b..38732c4 100644
--- a/noncore/net/opieirc/ircperson.h
+++ b/noncore/net/opieirc/ircperson.h
@@ -31,7 +31,10 @@
class IRCPerson {
public:
IRCPerson();
+ /* Create an IRCPerson from an IRC style description (nick!user@host) */
IRCPerson(QString mask);
+ /* Copy constructor */
+ IRCPerson(const IRCPerson &person);
void fromMask(QString mask);
void setNick(QString name);
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
index 6d24845..642cc5b 100644
--- a/noncore/net/opieirc/ircquerytab.cpp
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -1,2 +1,78 @@
+#include <qhbox.h>
#include "ircquerytab.h"
+#include "ircservertab.h"
+
+IRCQueryTab::IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
+ m_mainWindow = mainWindow;
+ m_parentTab = parentTab;
+ m_person = new IRCPerson(*person); /* We need this (the person might sign off and the original IRCPerson gets deleted) */
+ m_description->setText(tr("Talking to ") + " <b>" + person->nick() + "</b>");
+ QHBox *hbox = new QHBox(this);
+ m_textview = new QTextView(hbox);
+ m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
+ m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
+ m_textview->setTextFormat(RichText);
+ m_field = new QLineEdit(this);
+ m_layout->add(hbox);
+ hbox->show();
+ m_layout->add(m_field);
+ m_field->setFocus();
+ connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
+
+}
+
+void IRCQueryTab::appendText(QString text) {
+ /* not using append because it creates layout problems */
+ m_textview->setText(m_textview->text() + text);
+ m_textview->ensureVisible(0, m_textview->contentsHeight());
+}
+
+IRCQueryTab::~IRCQueryTab() {
+ m_parentTab->removeQueryTab(this);
+ delete m_person;
+}
+
+void IRCQueryTab::processCommand() {
+ 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 (text.startsWith("//"))
+ text = text.right(text.length()-1);
+ session()->sendMessage(m_person, m_field->text());
+ appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>");
+ }
+ } else {
+ appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>");
+ }
+ }
+ m_field->clear();
+}
+
+void IRCQueryTab::display(IRCOutput output) {
+ if (output.type() == OUTPUT_QUERYPRIVMSG) {
+ appendText("&lt;<font color=\"#0000dd\">"+m_person->nick()+"</font>&gt; " + output.htmlMessage() + "<br>");
+ } else if (output.type() == OUTPUT_QUERYACTION) {
+ appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "<br>");
+ }
+}
+
+QString IRCQueryTab::title() {
+ return m_person->nick();
+}
+
+IRCSession *IRCQueryTab::session() {
+ return m_parentTab->session();
+}
+
+void IRCQueryTab::remove() {
+ m_mainWindow->killTab(this);
+}
+
+IRCPerson *IRCQueryTab::person() {
+ return m_person;
+}
diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h
index fac976d..ea777f4 100644
--- a/noncore/net/opieirc/ircquerytab.h
+++ b/noncore/net/opieirc/ircquerytab.h
@@ -21,4 +21,31 @@
#ifndef __IRCQUERYTAB_H
#define __IRCQUERYTAB_H
+#include "ircsession.h"
+#include "mainwindow.h"
+
+class IRCServerTab;
+class IRCQueryTab : public IRCTab {
+ Q_OBJECT
+public:
+ /* IRCTab implementation */
+ IRCQueryTab(IRCPerson *person, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
+ ~IRCQueryTab();
+ QString title();
+ IRCSession *session();
+ IRCPerson *person();
+ void appendText(QString text);
+public slots:
+ void remove();
+ void processCommand();
+ void display(IRCOutput output);
+protected:
+ bool m_close;
+ MainWindow *m_mainWindow;
+ IRCServerTab *m_parentTab;
+ IRCPerson *m_person;
+ QTextView *m_textview;
+ QLineEdit *m_field;
+};
+
#endif /* __IRCQUERYTAB_H */
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 503a758..8b8771f 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -11,6 +11,7 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
m_textview = new QTextView(this);
m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
+ m_textview->setTextFormat(RichText);
m_layout->add(m_textview);
m_field = new QLineEdit(this);
m_layout->add(m_field);
@@ -33,6 +34,10 @@ void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
m_channelTabs.remove(tab);
}
+void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
+ m_queryTabs.remove(tab);
+}
+
QString IRCServerTab::title() {
return "Server";
}
@@ -60,16 +65,30 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>");
}
} else if (command == "ME") {
- QString text = IRCOutput::toHTML(line.right(line.length()-4));
+ QString text = line.right(line.length()-4);
if (text.length() > 0) {
if (tab->isA("IRCChannelTab")) {
- tab->appendText("<font color=\"#cc0000\">*" + m_server.nick() + " " + text + "</font><br>");
+ tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
} else if (tab->isA("IRCQueryTab")) {
+ tab->appendText("<font color=\"#cc0000\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
+ m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
} else {
tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>");
}
}
+ } else if (command == "MSG") {
+ QString nickname;
+ stream >> nickname;
+ if (nickname.length() > 0) {
+ if (line.length() > 6 + nickname.length()) {
+ QString text = line.right(line.length()-nickname.length()-6);
+ IRCPerson person;
+ person.setNick(nickname);
+ tab->appendText("&gt;<font color=\"#0000dd\">"+IRCOutput::toHTML(nickname)+"</font>&lt; "+IRCOutput::toHTML(text)+"<br>");
+ m_session->sendMessage(&person, text);
+ }
+ }
} else {
tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>");
}
@@ -100,6 +119,10 @@ void IRCServerTab::remove() {
while (m_channelTabs.current() != 0) {
m_mainWindow->killTab(m_channelTabs.current());
}
+ m_queryTabs.first();
+ while (m_queryTabs.current() != 0) {
+ m_mainWindow->killTab(m_queryTabs.current());
+ }
m_mainWindow->killTab(this);
}
}
@@ -114,6 +137,16 @@ IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
return 0;
}
+IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
+ QListIterator<IRCQueryTab> it(m_queryTabs);
+
+ for (; it.current(); ++it) {
+ if (it.current()->person()->nick() == person->nick())
+ return it.current();
+ }
+ return 0;
+}
+
void IRCServerTab::display(IRCOutput output) {
/* All messages to be displayed inside the GUI get here */
@@ -124,6 +157,10 @@ void IRCServerTab::display(IRCOutput output) {
while (m_channelTabs.current() != 0) {
m_mainWindow->killTab(m_channelTabs.current());
}
+ m_queryTabs.first();
+ while (m_queryTabs.current() != 0) {
+ m_mainWindow->killTab(m_queryTabs.current());
+ }
m_mainWindow->killTab(this);
} else {
appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>");
@@ -141,7 +178,18 @@ void IRCServerTab::display(IRCOutput output) {
break;
case OUTPUT_CHANPRIVMSG: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
- channelTab->appendText("&lt;<font color=\"#0000dd\">"+((IRCChannelPerson *)output.getParam(1))->person->nick()+"</font>&gt; "+output.htmlMessage()+"<br>");
+ channelTab->appendText("&lt;<font color=\"#0000dd\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font>&gt; "+output.htmlMessage()+"<br>");
+ }
+ break;
+ case OUTPUT_QUERYACTION:
+ case OUTPUT_QUERYPRIVMSG: {
+ IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
+ if (!queryTab) {
+ queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
+ m_queryTabs.append(queryTab);
+ m_mainWindow->addTab(queryTab);
+ }
+ queryTab->display(output);
}
break;
case OUTPUT_SELFPART: {
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h
index cfa0832..e439d84 100644
--- a/noncore/net/opieirc/ircservertab.h
+++ b/noncore/net/opieirc/ircservertab.h
@@ -25,6 +25,7 @@
#include "ircsession.h"
#include "mainwindow.h"
#include "ircchanneltab.h"
+#include "ircquerytab.h"
class IRCServerTab : public IRCTab {
Q_OBJECT
@@ -38,13 +39,16 @@ public:
/* Start the server session */
void doConnect();
+ /* Remove tabs from the internal tab lists */
void removeChannelTab(IRCChannelTab *tab);
+ void removeQueryTab(IRCQueryTab *tab);
/* Execute a user command such as /join */
void executeCommand(IRCTab *tab, QString line);
protected:
void appendText(QString text);
IRCChannelTab *getTabForChannel(IRCChannel *channel);
+ IRCQueryTab *getTabForQuery(IRCPerson *person);
public slots:
void remove();
void processCommand();
@@ -57,7 +61,10 @@ protected:
MainWindow *m_mainWindow;
QTextView *m_textview;
QLineEdit *m_field;
+ /* Channel tabs associated with this server tab */
QList<IRCChannelTab> m_channelTabs;
+ /* Query tabs associated with this server tab */
+ QList<IRCQueryTab> m_queryTabs;
};
#endif /* __IRCSERVERTAB_H */