summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircservertab.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index d3c0448..5eb1758 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -24,195 +24,196 @@ IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *pa
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());
}
void IRCServerTab::appendText(QString text) {
/* not using append because it creates layout problems */
QString txt = m_textview->text() + IRCTab::appendTimestamp( text );
if (m_maxLines > 0 && m_lines >= m_maxLines) {
int firstBreak = txt.find('\n');
if (firstBreak != -1) {
txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
}
} else {
m_lines++;
}
m_textview->setText(txt);
m_textview->ensureVisible(0, m_textview->contentsHeight());
emit changed(this);
}
IRCServerTab::~IRCServerTab() {
delete m_session;
}
void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
m_channelTabs.remove(tab);
}
void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
m_queryTabs.remove(tab);
}
void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
m_queryTabs.append(tab);
}
QString IRCServerTab::title() {
return "Server";
}
IRCSession *IRCServerTab::session() {
return m_session;
}
/*
QString *IRCServerTab::mynick() {
return (*m_server->nick());
} */
IRCServer *IRCServerTab::server() {
return &m_server;
}
void IRCServerTab::settingsChanged() {
m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
m_lines = 0;
}
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;
/* According to RFC 1459 */
if (channel.length() > 0 && channel.length() < 200 &&
- channel.find(",") == -1 && channel.find("") == -1) {
+ channel.find(",") == -1 && channel.find('\007') == -1) {
- if (!channel.startsWith("#") && !channel.startsWith("&")) {
+ if (!channel.startsWith("#") && !channel.startsWith("&")
+ && !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()) {
QString text = line.right(line.length()-nickname.length()-7);
IRCPerson person;
person.setNick(nickname);
m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
} else {
IRCPerson person;
person.setNick(nickname);
m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
}
}
}
else if (command == "OP"){
QString nickname;
stream >> nickname;
if (nickname.length() > 0) {
QString text = line.right(line.length()-nickname.length()-5);
IRCPerson person;
person.setNick(nickname);
m_session->op(((IRCChannelTab *)tab)->channel(), &person);
}
}
//SEND MODES
else if (command == "MODE"){
QString text = line.right(line.length()-6);
if (text.length() > 0) {
m_session->mode(text);
} else {
tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>");
}
}
//SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want
else if (command == "RAW"){
QString text = line.right(line.length()-5);
if (text.length() > 0) {
m_session->raw(text);
}
}
else if (command == "SUSPEND"){
QString text = line.right(line.length()-9);
if (text.upper() == "ON") {
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
}
else if (text.upper() == "OFF"){
QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
} else {
tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text);
}
}
else if (command == "QUIT"){
QString text = line.right(line.length()-6);
if (text.length() > 0) {
m_session->quit(text);
} else {
m_session->quit();
}
}
//SEND ACTION
else if (command == "ME") {
QString text = line.right(line.length()-4);
if (text.length() > 0) {
if (tab->isA("IRCChannelTab")) {
tab->appendText("<font color=\"" + m_selfColor + "\">*" + 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=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
} else {
tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
}
}
}
//SEND PRIVMSG
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);