summaryrefslogtreecommitdiff
authorwazlaf <wazlaf>2002-09-21 23:59:08 (UTC)
committer wazlaf <wazlaf>2002-09-21 23:59:08 (UTC)
commitd60625b5551f26cdc35f7b2497ab538de859537d (patch) (side-by-side diff)
tree998c8d2e1f12a9c7ab9b55fa578f93d1a178ade6
parent54238c669808ceccaa6fb0ab0dcbf4565b370196 (diff)
downloadopie-d60625b5551f26cdc35f7b2497ab538de859537d.zip
opie-d60625b5551f26cdc35f7b2497ab538de859537d.tar.gz
opie-d60625b5551f26cdc35f7b2497ab538de859537d.tar.bz2
query windows and basic commands such as /me, /msg
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp3
-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, 180 insertions, 8 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
@@ -16,2 +16,3 @@ IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainW
m_textview->setCornerWidget(m_listButton);
+ m_textview->setTextFormat(RichText);
connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
@@ -49,3 +50,2 @@ void IRCChannelTab::processCommand() {
text = text.right(text.length()-1);
- if (session()->isSessionActive()) {
session()->sendMessage(m_channel, m_field->text());
@@ -53,3 +53,2 @@ void IRCChannelTab::processCommand() {
}
- }
} else {
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
@@ -79,3 +79,2 @@ IRCMessage::IRCMessage(QString line) {
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
@@ -46,3 +46,5 @@ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
{ 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
@@ -174,3 +176,3 @@ void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
}
- IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
+ IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1));
output.addParam(person);
@@ -481 +483,5 @@ void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) {
}
+
+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
@@ -83,2 +83,3 @@ private:
void parseNumericalNicknameInUse(IRCMessage *message);
+ void parseNumericalNoSuchNick(IRCMessage *message);
void parseCTCPPing(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
@@ -9,2 +9,8 @@ IRCPerson::IRCPerson() {
+IRCPerson::IRCPerson(const IRCPerson &person) {
+ m_nick = person.m_nick;
+ m_user = person.m_user;
+ m_host = person.m_host;
+}
+
IRCPerson::IRCPerson(QString 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
@@ -33,3 +33,6 @@ public:
IRCPerson();
+ /* Create an IRCPerson from an IRC style description (nick!user@host) */
IRCPerson(QString mask);
+ /* Copy constructor */
+ IRCPerson(const IRCPerson &person);
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
@@ -23,2 +23,29 @@
+#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
@@ -13,2 +13,3 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
+ m_textview->setTextFormat(RichText);
m_layout->add(m_textview);
@@ -35,2 +36,6 @@ void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
+void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
+ m_queryTabs.remove(tab);
+}
+
QString IRCServerTab::title() {
@@ -62,8 +67,10 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
} 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 {
@@ -72,2 +79,14 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
}
+ } 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 {
@@ -102,2 +121,6 @@ void IRCServerTab::remove() {
}
+ m_queryTabs.first();
+ while (m_queryTabs.current() != 0) {
+ m_mainWindow->killTab(m_queryTabs.current());
+ }
m_mainWindow->killTab(this);
@@ -116,2 +139,12 @@ IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
+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) {
@@ -126,2 +159,6 @@ void IRCServerTab::display(IRCOutput output) {
}
+ m_queryTabs.first();
+ while (m_queryTabs.current() != 0) {
+ m_mainWindow->killTab(m_queryTabs.current());
+ }
m_mainWindow->killTab(this);
@@ -143,3 +180,14 @@ 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.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);
}
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
@@ -27,2 +27,3 @@
#include "ircchanneltab.h"
+#include "ircquerytab.h"
@@ -40,3 +41,5 @@ public:
void doConnect();
+ /* Remove tabs from the internal tab lists */
void removeChannelTab(IRCChannelTab *tab);
+ void removeQueryTab(IRCQueryTab *tab);
@@ -47,2 +50,3 @@ protected:
IRCChannelTab *getTabForChannel(IRCChannel *channel);
+ IRCQueryTab *getTabForQuery(IRCPerson *person);
public slots:
@@ -59,3 +63,6 @@ protected:
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;
};