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) (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
@@ -1,95 +1,94 @@
#include <qhbox.h>
#include "ircchanneltab.h"
#include "ircservertab.h"
IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
m_mainWindow = mainWindow;
m_parentTab = parentTab;
m_channel = channel;
m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
QHBox *hbox = new QHBox(this);
m_textview = new QTextView(hbox);
m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
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();
m_list->setMaximumWidth(LISTWIDTH);
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 IRCChannelTab::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());
}
IRCChannelTab::~IRCChannelTab() {
m_parentTab->removeChannelTab(this);
}
void IRCChannelTab::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);
- 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>");
}
}
m_field->clear();
}
void IRCChannelTab::toggleList() {
if (m_listVisible) {
m_list->setMaximumWidth(0);
m_listButton->setText("<");
} else {
m_list->setMaximumWidth(LISTWIDTH);
m_listButton->setText(">");
}
m_listVisible = !m_listVisible;
}
QString IRCChannelTab::title() {
return m_channel->channelname();
}
IRCSession *IRCChannelTab::session() {
return m_parentTab->session();
}
void IRCChannelTab::remove() {
if (session()->isSessionActive()) {
session()->part(m_channel);
} else {
m_mainWindow->killTab(this);
}
}
IRCChannel *IRCChannelTab::channel() {
return m_channel;
}
IRCChannelList *IRCChannelTab::list() {
return m_list;
}
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
@@ -1,123 +1,122 @@
#include <qtextstream.h>
#include "ircmessage.h"
/*
* Create a new IRCMessage by evaluating
* a received string
*/
IRCMessage::IRCMessage(QString line) {
/* Remove CRs from the message */
while((line.right(1) == "\n") || (line.right(1) == "\r"))
line = line.left(line.length() - 1);
QTextIStream stream(&line);
QString temp;
stream >> temp;
if (temp.startsWith(":")) {
/* extract the prefix */
m_prefix = temp.right(temp.length()-1);
stream >> temp;
m_command = temp.upper();
m_allParameters = line.right(line.length() - m_prefix.length() - m_command.length() - 3);
} else {
m_command = temp.upper();
m_allParameters = line.right(line.length() - m_command.length() - 1);
}
/* Create a list of all parameters */
while(!(stream.atEnd())) {
stream >> temp;
if (temp.startsWith(":")) {
/* last parameter */
m_trailing = line.right(line.length() - line.find(QChar(':'), 1) - 1);
m_parameters << m_trailing;
break;
} else {
m_parameters << temp;
}
}
m_commandNumber = m_command.toInt(&m_isNumerical);
/* Is this a CTCP command */
if ((m_command == "PRIVMSG" || m_command == "NOTICE") && m_trailing.length()>0 && m_trailing.left(1) == QChar(1)) {
m_ctcp = TRUE;
/* Strip CTCP \001 characters */
m_allParameters = m_allParameters.replace(QRegExp(QChar(1)), "");
QTextIStream ctcpStream(&m_allParameters);
if (m_command == "PRIVMSG")
ctcpStream >> m_ctcpDestination;
ctcpStream >> temp;
m_ctcpCommand = temp.upper().right(temp.length()-1);
m_parameters.clear();
int length = m_allParameters.length() - m_ctcpCommand.length() - 1;
if (m_command == "PRIVMSG")
length -= m_ctcpDestination.length() + 1;
if (length <= 0) {
m_allParameters = "";
} else {
m_allParameters = m_allParameters.right(length);
m_parameters << m_allParameters;
}
} else {
m_ctcp = FALSE;
}
/*
-- Uncomment to debug --
printf("Parsed : '%s'\n", line.ascii());
printf("Prefix : '%s'\n", m_prefix.ascii());
printf("Command : '%s'\n", m_command.ascii());
printf("Allparameters : '%s'\n", m_allParameters.ascii());
for (unsigned int i=0; i<m_parameters.count(); i++) {
printf("Parameter %i : '%s'\n", i, m_parameters[i].ascii());
}
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());
-
*/
}
QString IRCMessage::param(int param) {
return m_parameters[param];
}
QString IRCMessage::prefix() {
return m_prefix;
}
QString IRCMessage::command() {
return m_command;
}
QString IRCMessage::ctcpCommand() {
return m_ctcpCommand;
}
QString IRCMessage::ctcpDestination() {
return m_ctcpDestination;
}
unsigned short IRCMessage::commandNumber() {
return m_commandNumber;
}
bool IRCMessage::isNumerical() {
return m_isNumerical;
}
bool IRCMessage::isCTCP() {
return m_ctcp;
}
QString IRCMessage::trailing() {
return m_trailing;
}
QString IRCMessage::allParameters() {
return m_allParameters;
}
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
@@ -1,481 +1,487 @@
#include <qtextstream.h>
#include "ircmessageparser.h"
#include "ircversion.h"
#include <stdio.h>
/* Lookup table for literal commands */
IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
{ "PING", FUNC(parseLiteralPing) },
{ "NOTICE", FUNC(parseLiteralNotice) },
{ "JOIN", FUNC(parseLiteralJoin) },
{ "PRIVMSG", FUNC(parseLiteralPrivMsg) },
{ "NICK", FUNC(parseLiteralNick) },
{ "PART", FUNC(parseLiteralPart) },
{ "QUIT", FUNC(parseLiteralQuit) },
{ "ERROR", FUNC(parseLiteralError) },
{ "ERROR:", FUNC(parseLiteralError) },
{ "MODE", FUNC(parseLiteralMode) },
{ "KICK", FUNC(parseLiteralKick) },
{ 0 , 0 }
};
/* Lookup table for literal commands */
IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
{ "PING", FUNC(parseCTCPPing) },
{ "VERSION", FUNC(parseCTCPVersion) },
{ "ACTION", FUNC(parseCTCPAction) },
{ 0 , 0 }
};
/* Lookup table for numerical commands */
IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
{ 1, FUNC(parseNumerical001) }, // RPL_WELCOME
{ 2, FUNC(parseNumerical002) }, // RPL_YOURHOST
{ 3, FUNC(parseNumerical003) }, // RPL_CREATED
{ 4, FUNC(parseNumerical004) }, // RPL_MYINFO
{ 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL
{ 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT
{ 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS
{ 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME
{ 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY
{ 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
{ 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART
{ 372, FUNC(parseNumericalStats) }, // RPL_MOTD
{ 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 }
};
IRCMessageParser::IRCMessageParser(IRCSession *session) {
m_session = session;
}
void IRCMessageParser::parse(IRCMessage *message) {
/* Find out what kind of message we have here and call the appropriate handler using
the parser tables. If no handler can be found, print out an error message */
if (message->isNumerical()) {
for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) {
if (message->commandNumber() == numericalParserProcTable[i].commandNumber) {
(this->*(numericalParserProcTable[i].proc))(message);
return;
}
}
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber())));
} else if (message->isCTCP()) {
for (int i=0; ctcpParserProcTable[i].commandName; i++) {
if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) {
(this->*(ctcpParserProcTable[i].proc))(message);
return;
}
}
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand()));
} else {
for (int i=0; literalParserProcTable[i].commandName; i++) {
if (message->command() == literalParserProcTable[i].commandName) {
(this->*(literalParserProcTable[i].proc))(message);
return;
}
}
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command()));
}
}
void IRCMessageParser::nullFunc(IRCMessage *) {
/* Do nothing */
}
void IRCMessageParser::parseLiteralPing(IRCMessage *message) {
m_session->m_connection->sendLine("PONG " + message->allParameters());
}
void IRCMessageParser::parseLiteralNotice(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
}
void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
QString channelName = message->param(0);
IRCPerson mask(message->prefix());
IRCChannel *channel = m_session->getChannel(channelName);
if (!channel) {
/* We joined */
if (mask.nick() == m_session->m_server->nick()) {
channel = new IRCChannel(channelName);
m_session->addChannel(channel);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?")));
}
} else {
/* Someone else joined */
if (mask.nick() != m_session->m_server->nick()) {
if (!channel->getPerson(mask.nick())) {
IRCChannelPerson *chanperson = new IRCChannelPerson();
IRCPerson *person = m_session->getPerson(mask.nick());
if (!person) {
person = new IRCPerson(message->prefix());
m_session->addPerson(person);
}
chanperson->flags = 0;
chanperson->person = person;
channel->addPerson(chanperson);
IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName);
output.addParam(channel);
output.addParam(chanperson);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?")));
}
}
}
void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
QString channelName = message->param(0);
IRCChannel *channel = m_session->getChannel(channelName);
IRCPerson mask(message->prefix());
if (channel) {
if (mask.nick() == m_session->m_server->nick()) {
m_session->removeChannel(channel);
IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName);
output.addParam(channel);
emit outputReady(output);
delete channel;
} else {
IRCChannelPerson *person = channel->getPerson(mask.nick());
if (person) {
channel->removePerson(person);
IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName);
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
delete person;
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?")));
}
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
}
}
void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
if (m_session->m_server->nick() == message->param(0)) {
/* IRC Query message detected, verify sender and display it */
IRCPerson mask(message->prefix());
IRCPerson *person = m_session->getPerson(mask.nick());
if (!person) {
/* Person not yet known, create and add to the current session */
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) == '#') {
/* IRC Channel message detected, verify sender, channel and display it */
IRCChannel *channel = m_session->getChannel(message->param(0));
if (channel) {
IRCPerson mask(message->prefix());
IRCChannelPerson *person = channel->getPerson(mask.nick());
if (person) {
IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
}
}
void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
IRCPerson mask(message->prefix());
if (mask.nick() == m_session->m_server->nick()) {
/* We are changing our nickname */
m_session->m_server->setNick(message->param(0));
IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0));
output.addParam(0);
emit outputReady(output);
} else {
/* Someone else is */
IRCPerson *person = m_session->getPerson(mask.nick());
if (person) {
IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0));
output.addParam(person);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
}
}
}
void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
IRCPerson mask(message->prefix());
IRCPerson *person = m_session->getPerson(mask.nick());
if (person) {
QList<IRCChannel> channels;
m_session->getChannelsByPerson(person, channels);
QListIterator<IRCChannel> it(channels);
for (;it.current(); ++it) {
IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
it.current()->removePerson(chanperson);
delete chanperson;
}
m_session->removePerson(person);
IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")");
output.addParam(person);
emit outputReady(output);
delete person;
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
}
}
void IRCMessageParser::parseLiteralError(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
}
void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
IRCPerson mask(message->prefix());
m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters());
emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick()));
}
void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
IRCPerson mask(message->prefix());
m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR);
emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick()));
}
void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
IRCPerson mask(message->prefix());
QString dest = message->ctcpDestination();
if (dest.startsWith("#")) {
IRCChannel *channel = m_session->getChannel(dest);
if (channel) {
IRCChannelPerson *person = channel->getPerson(mask.nick());
if (person) {
IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?")));
}
} else {
if (message->ctcpDestination() == m_session->m_server->nick()) {
IRCPerson *person = m_session->getPerson(mask.nick());
if (!person) {
/* Person not yet known, create and add to the current session */
person = new IRCPerson(message->prefix());
m_session->addPerson(person);
}
IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0));
output.addParam(person);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
}
}
}
void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
IRCPerson mask(message->prefix());
if (message->param(0).startsWith("#")) {
IRCChannel *channel = m_session->getChannel(message->param(0));
if (channel) {
QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1);
QTextIStream stream(&parameters);
bool set = FALSE;
while (!stream.atEnd()) {
stream >> temp;
if (temp.startsWith("+")) {
set = TRUE;
temp = temp.right(1);
} else if (temp.startsWith("-")) {
set = FALSE;
temp = temp.right(1);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type")));
return;
}
if (temp == "o") {
stream >> temp;
IRCChannelPerson *person = channel->getPerson(temp);
if (person) {
if (set) {
person->flags |= PERSON_FLAG_OP;
IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick()));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
} else {
person->flags &= 0xFFFF - PERSON_FLAG_OP;
IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick()));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
}
} else if (temp == "v") {
stream >> temp;
IRCChannelPerson *person = channel->getPerson(temp);
if (person) {
if (set) {
person->flags |= PERSON_FLAG_VOICE;
IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick()));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
} else {
person->flags &= 0xFFFF - PERSON_FLAG_VOICE;
IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick()));
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag")));
}
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet")));
}
}
void IRCMessageParser::parseLiteralKick(IRCMessage *message) {
IRCPerson mask(message->prefix());
IRCChannel *channel = m_session->getChannel(message->param(0));
if (channel) {
IRCChannelPerson *person = channel->getPerson(message->param(1));
if (person) {
if (person->person->nick() == m_session->m_server->nick()) {
m_session->removeChannel(channel);
IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")");
output.addParam(channel);
emit outputReady(output);
} else {
channel->removePerson(person);
IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")");
output.addParam(channel);
output.addParam(person);
emit outputReady(output);
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?")));
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?")));
}
}
void IRCMessageParser::parseNumerical001(IRCMessage *message) {
/* Welcome to IRC message, display */
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
}
void IRCMessageParser::parseNumerical002(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
}
void IRCMessageParser::parseNumerical003(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
}
void IRCMessageParser::parseNumerical004(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
}
void IRCMessageParser::parseNumerical005(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
}
void IRCMessageParser::parseNumericalStats(IRCMessage *message) {
emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
}
void IRCMessageParser::parseNumericalNames(IRCMessage *message) {
/* Name list sent when joining a channel */
IRCChannel *channel = m_session->getChannel(message->param(2));
if (channel != 0) {
QString people = message->param(3);
QTextIStream stream(&people);
QString temp;
while (!stream.atEnd()) {
stream >> temp;
char flagch = temp.at(0).latin1();
int flag = 0;
QString nick;
/* Parse person flags */
if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') {
nick = temp.right(temp.length()-1);
switch (flagch) {
case '@': flag = PERSON_FLAG_OP; break;
case '+': flag = PERSON_FLAG_VOICE; break;
case '%': flag = PERSON_FLAG_HALFOP; break;
default : flag = 0; break;
}
} else {
nick = temp;
}
IRCChannelPerson *chan_person = new IRCChannelPerson();
IRCPerson *person = m_session->getPerson(nick);
if (person == 0) {
person = new IRCPerson();
person->setNick(nick);
m_session->addPerson(person);
}
chan_person->person = person;
chan_person->flags = flag;
channel->addPerson(chan_person);
}
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
}
}
void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) {
/* Done syncing to channel */
IRCChannel *channel = m_session->getChannel(message->param(1));
if (channel) {
channel->setHasPeople(TRUE);
/* Yes, we want the names before anything happens inside the GUI */
IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname());
output.addParam(channel);
emit outputReady(output);
} else {
emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
}
}
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
@@ -1,95 +1,96 @@
/*
OpieIRC - An embedded IRC client
Copyright (C) 2002 Wenzel Jakob
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __IRCMESSAGEPARSER_H
#define __IRCMESSAGEPARSER_H
#include "ircsession.h"
/* Macro to facilitate the parser table's creation */
#define FUNC(__proc) &IRCMessageParser::__proc
class IRCMessageParser;
/* Typedef representing a parser function */
typedef void (IRCMessageParser::*IRCMessageParseProc)(IRCMessage *);
/* Struct representing a literal command handler */
typedef struct IRCLiteralMessageParserStruct {
char *commandName;
IRCMessageParseProc proc;
};
/* Struct representing a ctcp command handler */
typedef struct IRCCTCPMessageParserStruct {
char *commandName;
IRCMessageParseProc proc;
};
/* Struct representing a numerical command handler */
typedef struct IRCNumericalMessageParserStruct {
unsigned short commandNumber;
IRCMessageParseProc proc;
};
class IRCMessageParser : public QObject {
Q_OBJECT
public:
/* Create an IRCMessageParser object */
IRCMessageParser(IRCSession *session);
/* Parse a server message and take the appropriate actions */
void parse(IRCMessage *message);
signals:
/* Used to send commands to the UI (such as displaying text etc) */
void outputReady(IRCOutput output);
private:
/* Parser functions */
void nullFunc(IRCMessage *message);
void parseLiteralPing(IRCMessage *message);
void parseLiteralNotice(IRCMessage *message);
void parseLiteralJoin(IRCMessage *message);
void parseLiteralPrivMsg(IRCMessage *message);
void parseLiteralNick(IRCMessage *message);
void parseLiteralPart(IRCMessage *message);
void parseLiteralQuit(IRCMessage *message);
void parseLiteralError(IRCMessage *message);
void parseLiteralMode(IRCMessage *message);
void parseLiteralKick(IRCMessage *message);
void parseNumerical001(IRCMessage *message);
void parseNumerical002(IRCMessage *message);
void parseNumerical003(IRCMessage *message);
void parseNumerical004(IRCMessage *message);
void parseNumerical005(IRCMessage *message);
void parseNumericalStats(IRCMessage *message);
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);
protected:
IRCSession *m_session;
/* Parser tables */
static IRCLiteralMessageParserStruct literalParserProcTable[];
static IRCNumericalMessageParserStruct numericalParserProcTable[];
static IRCCTCPMessageParserStruct ctcpParserProcTable[];
};
#endif /* __IRCMESSAGEPARSER_H */
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
@@ -1,50 +1,56 @@
#include "ircperson.h"
#include <stdio.h>
IRCPerson::IRCPerson() {
m_nick = "";
m_user = "";
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);
}
void IRCPerson::fromMask(QString mask) {
int sep1 = mask.find("!");
int sep2 = mask.find("@");
m_nick = mask.left(sep1);
m_user = mask.mid(sep1+1, sep2-sep1-1);
m_host = mask.right(mask.length()-sep2-1);
}
QString IRCPerson::toMask() {
return m_nick + "!" + m_user + "@" + m_host;
}
void IRCPerson::setNick(QString nick) {
m_nick = nick;
}
void IRCPerson::setUser(QString user) {
m_user = user;
}
void IRCPerson::setHost(QString host) {
m_host = host;
}
QString IRCPerson::nick() {
return m_nick;
}
QString IRCPerson::user() {
return m_user;
}
QString IRCPerson::host() {
return m_host;
}
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
@@ -1,50 +1,53 @@
/*
OpieIRC - An embedded IRC client
Copyright (C) 2002 Wenzel Jakob
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __IRCPERSON
#define __IRCPERSON
#include <qstring.h>
/* This class requires all required information relating to a person
on the IRC network. This class can be used as an input mask for
IRCMessage-prefixes too
*/
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);
void setUser(QString user);
void setHost(QString host);
QString toMask();
QString nick();
QString user();
QString host();
protected:
QString m_nick;
QString m_user;
QString m_host;
};
#endif /* __IRCPERSON */
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
@@ -1,24 +1,51 @@
/*
OpieIRC - An embedded IRC client
Copyright (C) 2002 Wenzel Jakob
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#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
@@ -1,195 +1,243 @@
#include <stdio.h>
#include <qtextstream.h>
#include "ircservertab.h"
IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
m_server = server;
m_session = new IRCSession(&m_server);
m_mainWindow = mainWindow;
m_close = FALSE;
m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
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);
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
m_field->setFocus();
connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
}
void IRCServerTab::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());
}
IRCServerTab::~IRCServerTab() {
delete m_session;
}
void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
m_channelTabs.remove(tab);
}
+void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
+ m_queryTabs.remove(tab);
+}
+
QString IRCServerTab::title() {
return "Server";
}
IRCSession *IRCServerTab::session() {
return m_session;
}
IRCServer *IRCServerTab::server() {
return &m_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 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>");
}
}
void IRCServerTab::processCommand() {
QString text = m_field->text();
if (text.startsWith("/") && !text.startsWith("//")) {
/* Command mode */
executeCommand(this, text);
}
m_field->clear();
}
void IRCServerTab::doConnect() {
m_session->beginSession();
}
void IRCServerTab::remove() {
/* Close requested */
if (m_session->isSessionActive()) {
/* While there is a running session */
m_close = TRUE;
m_session->endSession();
} else {
/* Session has previously been closed */
m_channelTabs.first();
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);
}
}
IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
if (it.current()->channel() == channel)
return it.current();
}
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 */
switch (output.type()) {
case OUTPUT_CONNCLOSE:
if (m_close) {
m_channelTabs.first();
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>");
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
it.current()->appendText("<font color=\"#0000dd\">" + output.htmlMessage() +"</font><br>");
}
}
break;
case OUTPUT_SELFJOIN: {
IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
m_channelTabs.append(channeltab);
m_mainWindow->addTab(channeltab);
}
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: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
if (channelTab)
m_mainWindow->killTab(channelTab);
}
break;
case OUTPUT_SELFKICK: {
appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>");
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
if (channelTab)
m_mainWindow->killTab(channelTab);
}
break;
case OUTPUT_CHANACTION: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
channelTab->appendText("<font color=\"#cc0000\">"+output.htmlMessage()+"</font><br>");
}
break;
case OUTPUT_QUIT: {
QString nick = ((IRCPerson *)output.getParam(0))->nick();
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
if (it.current()->list()->hasPerson(nick)) {
it.current()->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>");
it.current()->list()->update();
}
}
}
break;
case OUTPUT_OTHERJOIN:
case OUTPUT_OTHERKICK:
case OUTPUT_CHANPERSONMODE:
case OUTPUT_OTHERPART: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
channelTab->appendText("<font color=\"#aa3e00\">"+output.htmlMessage()+"</font><br>");
channelTab->list()->update();
}
break;
case OUTPUT_CTCP:
appendText("<font color=\"#00bb00\">" + output.htmlMessage() + "</font><br>");
break;
case OUTPUT_ERROR:
appendText("<font color=\"#ff0000\">" + output.htmlMessage() + "</font><br>");
break;
default:
appendText("<font color=\"#0000dd\">" + output.htmlMessage() + "</font><br>");
break;
}
}
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
@@ -1,63 +1,70 @@
/*
OpieIRC - An embedded IRC client
Copyright (C) 2002 Wenzel Jakob
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __IRCSERVERTAB_H
#define __IRCSERVERTAB_H
#include "irctab.h"
#include "ircsession.h"
#include "mainwindow.h"
#include "ircchanneltab.h"
+#include "ircquerytab.h"
class IRCServerTab : public IRCTab {
Q_OBJECT
public:
/* IRCTab implementation */
IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
~IRCServerTab();
QString title();
IRCSession *session();
IRCServer *server();
/* 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();
protected slots:
void display(IRCOutput output);
protected:
bool m_close;
IRCServer m_server;
IRCSession *m_session;
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 */