summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircservertab.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/opieirc/ircservertab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircservertab.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index e031d4d..90353f2 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -8,42 +8,43 @@
bool IRCServerTab::containsPing( const QString& text, IRCServerTab* tab ) {
return (text.contains(IRCMessageParser::tr("Received a CTCP PING from "))) ||
(text.find("ping") != -1 && text.find( tab->server()->nick() != -1));
}
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_lines = 0;
- m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
+ m_description->setText(tr("Connecting 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);
QWhatsThis::add(m_textview, tr("Server messages"));
m_layout->add(m_textview);
m_field = new IRCHistoryLineEdit(this);
connect(m_field, SIGNAL(nextTab()), this, SIGNAL(nextTab()));
connect(m_field, SIGNAL(prevTab()), this, SIGNAL(prevTab()));
connect(m_field, SIGNAL(closeTab()), this, SIGNAL(closeTab()));
connect(this, SIGNAL(editFocus()), m_field, SLOT(setEditFocus()));
QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
m_layout->add(m_field);
connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
+ connect(m_session, SIGNAL(updateChannels()), this, SLOT(slotUpdateChannels()));
settingsChanged();
m_field->setFocus();
m_field->setActiveWindow();
}
void IRCServerTab::scrolling(){
m_textview->ensureVisible(0, m_textview->contentsHeight());
}
@@ -104,25 +105,31 @@ void IRCServerTab::settingsChanged() {
}
void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
QTextIStream stream(&line);
QString command;
stream >> command;
command = command.upper().right(command.length()-1);
//JOIN
if (command == "JOIN" || command == "J") {
QString channel;
stream >> channel;
- if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {
+ /* According to RFC 1459 */
+ if (channel.length() > 0 && channel.length() < 200 &&
+ channel.find(",") == -1 && channel.find("") == -1) {
+
+ if (!channel.startsWith("#") && !channel.startsWith("&")) {
+ channel = channel.prepend("#");
+ }
m_session->join(channel);
} else {
tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
}
}
//KICK
else if (command == "KICK"){
QString nickname;
stream >> nickname;
if (nickname.length() > 0) {
if (line.length() > 7 + nickname.length()) {
@@ -336,58 +343,72 @@ void IRCServerTab::display(IRCOutput output) {
channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
}
break;
case OUTPUT_TOPIC: {
IRCChannel *channel = (IRCChannel *) output.getParam(0);
if (channel) {
IRCChannelTab *channelTab = getTabForChannel(channel);
if (channelTab) {
channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
return;
}
}
- appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
+ IRCChannelTab::enqueue(channel->channelname(), "<font color=\"" + m_notificationColor + "\">"+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=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
it.current()->list()->update();
}
}
}
break;
-/* case OUTPUT_NICKCHANGE: {
- //WAS HERE
- QString nick = ((IRCPerson *)output.getParam(0))->nick();
+ case OUTPUT_NICKCHANGE: {
+ QString *nick = static_cast<QString*>(output.getParam(0));
+ if(!nick) {
+ appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
+ break;
+ }
QListIterator<IRCChannelTab> it(m_channelTabs);
for (; it.current(); ++it) {
- if (it.current()->list()->hasPerson(nick)) {
+ if (it.current()->list()->hasPerson(*nick)) {
it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
- it.current()->list()->update();
}
}
+ delete nick;
}
break;
- */ case OUTPUT_OTHERJOIN:
+ case OUTPUT_OTHERJOIN:
case OUTPUT_OTHERKICK:
case OUTPUT_CHANPERSONMODE:
case OUTPUT_OTHERPART: {
IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
channelTab->list()->update();
}
break;
case OUTPUT_CTCP:
appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
break;
case OUTPUT_ERROR:
appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
break;
+ case OUTPUT_TITLE:
+ m_description->setText(output.message());
+ break;
default:
appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>");
break;
}
}
+
+void IRCServerTab::slotUpdateChannels() {
+ QListIterator<IRCChannelTab> it(m_channelTabs);
+ for (; it.current(); ++it) {
+ it.current()->list()->update();
+ }
+}
+