From d8accaeed5f95340e8d293d6d5d1bb136c57fe35 Mon Sep 17 00:00:00 2001 From: wazlaf Date: Sat, 21 Sep 2002 07:11:10 +0000 Subject: CTCP action now work via /me, HTML escaping now also works for text sent by yourself --- (limited to 'noncore') diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp index 754442a..3267525 100644 --- a/noncore/net/opieirc/ircchanneltab.cpp +++ b/noncore/net/opieirc/ircchanneltab.cpp @@ -45,9 +45,11 @@ void IRCChannelTab::processCommand() { /* 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("<"+m_parentTab->server()->nick()+"> "+m_field->text()+"
"); + appendText("<"+m_parentTab->server()->nick()+"> "+IRCOutput::toHTML(m_field->text())+"
"); } } } else { diff --git a/noncore/net/opieirc/ircoutput.cpp b/noncore/net/opieirc/ircoutput.cpp index 878bc9b..4822fc4 100644 --- a/noncore/net/opieirc/ircoutput.cpp +++ b/noncore/net/opieirc/ircoutput.cpp @@ -14,7 +14,11 @@ QString IRCOutput::message() { } QString IRCOutput::htmlMessage() { - QString htmlMessage =m_message.replace(QRegExp("&"), "&"); + return toHTML(m_message); +} + +QString IRCOutput::toHTML(QString message) { + QString htmlMessage =message.replace(QRegExp("&"), "&"); htmlMessage = htmlMessage.replace(QRegExp(">"), ">"); htmlMessage = htmlMessage.replace(QRegExp("<"), "<"); return htmlMessage; diff --git a/noncore/net/opieirc/ircoutput.h b/noncore/net/opieirc/ircoutput.h index 72361d4..e8cc524 100644 --- a/noncore/net/opieirc/ircoutput.h +++ b/noncore/net/opieirc/ircoutput.h @@ -62,6 +62,8 @@ public: QString message(); /* Return the message with all HTML code escaped (for example < instead of '<') */ QString htmlMessage(); + + static QString toHTML(QString message); void *getParam(int index); protected: IRCOutputType m_type; diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp index 2ad56a8..503a758 100644 --- a/noncore/net/opieirc/ircservertab.cpp +++ b/noncore/net/opieirc/ircservertab.cpp @@ -59,6 +59,17 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) { } else { tab->appendText("Unknown channel format!
"); } + } else if (command == "ME") { + QString text = IRCOutput::toHTML(line.right(line.length()-4)); + if (text.length() > 0) { + if (tab->isA("IRCChannelTab")) { + tab->appendText("*" + m_server.nick() + " " + text + "
"); + m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); + } else if (tab->isA("IRCQueryTab")) { + } else { + tab->appendText("Invalid tab for this command
"); + } + } } else { tab->appendText("Unknown command
"); } diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp index 89df68c..122a943 100644 --- a/noncore/net/opieirc/ircsession.cpp +++ b/noncore/net/opieirc/ircsession.cpp @@ -36,6 +36,14 @@ void IRCSession::sendMessage(IRCChannel *channel, QString message) { m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); } +void IRCSession::sendAction(IRCChannel *channel, QString message) { + m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); +} + +void IRCSession::sendAction(IRCPerson *person, QString message) { + m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); +} + bool IRCSession::isSessionActive() { return m_connection->isConnected(); } diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h index 59c26aa..aa4bed3 100644 --- a/noncore/net/opieirc/ircsession.h +++ b/noncore/net/opieirc/ircsession.h @@ -50,6 +50,8 @@ public: void sendMessage(IRCPerson *person, QString message); void sendMessage(IRCChannel *channel, QString message); + void sendAction(IRCPerson *person, QString message); + void sendAction(IRCChannel *channel, QString message); IRCChannel *getChannel(QString channelname); IRCPerson *getPerson(QString nickname); protected: -- cgit v0.9.0.2