summaryrefslogtreecommitdiff
path: root/noncore/net
Unidiff
Diffstat (limited to 'noncore/net') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp4
-rw-r--r--noncore/net/opieirc/ircoutput.cpp6
-rw-r--r--noncore/net/opieirc/ircoutput.h2
-rw-r--r--noncore/net/opieirc/ircservertab.cpp11
-rw-r--r--noncore/net/opieirc/ircsession.cpp8
-rw-r--r--noncore/net/opieirc/ircsession.h2
6 files changed, 31 insertions, 2 deletions
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
@@ -36,27 +36,29 @@ void IRCChannelTab::appendText(QString text) {
36IRCChannelTab::~IRCChannelTab() { 36IRCChannelTab::~IRCChannelTab() {
37 m_parentTab->removeChannelTab(this); 37 m_parentTab->removeChannelTab(this);
38} 38}
39 39
40void IRCChannelTab::processCommand() { 40void IRCChannelTab::processCommand() {
41 QString text = m_field->text(); 41 QString text = m_field->text();
42 if (text.length()>0) { 42 if (text.length()>0) {
43 if (session()->isSessionActive()) { 43 if (session()->isSessionActive()) {
44 if (text.startsWith("/") && !text.startsWith("//")) { 44 if (text.startsWith("/") && !text.startsWith("//")) {
45 /* Command mode */ 45 /* Command mode */
46 m_parentTab->executeCommand(this, text);; 46 m_parentTab->executeCommand(this, text);;
47 } else { 47 } else {
48 if (text.startsWith("//"))
49 text = text.right(text.length()-1);
48 if (session()->isSessionActive()) { 50 if (session()->isSessionActive()) {
49 session()->sendMessage(m_channel, m_field->text()); 51 session()->sendMessage(m_channel, m_field->text());
50 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+m_field->text()+"<br>"); 52 appendText("&lt;<font color=\"#dd0000\">"+m_parentTab->server()->nick()+"</font>&gt; "+IRCOutput::toHTML(m_field->text())+"<br>");
51 } 53 }
52 } 54 }
53 } else { 55 } else {
54 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>"); 56 appendText("<font color=\"#ff0000\">"+tr("Disconnected")+"</font><br>");
55 } 57 }
56 } 58 }
57 m_field->clear(); 59 m_field->clear();
58} 60}
59 61
60void IRCChannelTab::toggleList() { 62void IRCChannelTab::toggleList() {
61 if (m_listVisible) { 63 if (m_listVisible) {
62 m_list->setMaximumWidth(0); 64 m_list->setMaximumWidth(0);
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
@@ -5,25 +5,29 @@ IRCOutput::IRCOutput(IRCOutputType type, QString message) {
5 m_message = message; 5 m_message = message;
6} 6}
7 7
8IRCOutputType IRCOutput::type() { 8IRCOutputType IRCOutput::type() {
9 return m_type; 9 return m_type;
10} 10}
11 11
12QString IRCOutput::message() { 12QString IRCOutput::message() {
13 return m_message; 13 return m_message;
14} 14}
15 15
16QString IRCOutput::htmlMessage() { 16QString IRCOutput::htmlMessage() {
17 QString htmlMessage =m_message.replace(QRegExp("&"), "&amp;"); 17 return toHTML(m_message);
18}
19
20QString IRCOutput::toHTML(QString message) {
21 QString htmlMessage =message.replace(QRegExp("&"), "&amp;");
18 htmlMessage = htmlMessage.replace(QRegExp(">"), "&gt;"); 22 htmlMessage = htmlMessage.replace(QRegExp(">"), "&gt;");
19 htmlMessage = htmlMessage.replace(QRegExp("<"), "&lt;"); 23 htmlMessage = htmlMessage.replace(QRegExp("<"), "&lt;");
20 return htmlMessage; 24 return htmlMessage;
21} 25}
22 26
23void IRCOutput::addParam(void *data) { 27void IRCOutput::addParam(void *data) {
24 m_parameters.append(data); 28 m_parameters.append(data);
25} 29}
26 30
27void *IRCOutput::getParam(int index) { 31void *IRCOutput::getParam(int index) {
28 return m_parameters.at(index); 32 return m_parameters.at(index);
29} 33}
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
@@ -53,20 +53,22 @@ enum IRCOutputType {
53 53
54class IRCOutput { 54class IRCOutput {
55public: 55public:
56 IRCOutput(IRCOutputType type, QString message); 56 IRCOutput(IRCOutputType type, QString message);
57 /* Used to add a parameter to this IRCOutput. Parameters are dependent 57 /* Used to add a parameter to this IRCOutput. Parameters are dependent
58 on which IRCOutputType we are using (see above) */ 58 on which IRCOutputType we are using (see above) */
59 void addParam(void *data); 59 void addParam(void *data);
60 60
61 IRCOutputType type(); 61 IRCOutputType type();
62 QString message(); 62 QString message();
63 /* Return the message with all HTML code escaped (for example &lt; instead of '<') */ 63 /* Return the message with all HTML code escaped (for example &lt; instead of '<') */
64 QString htmlMessage(); 64 QString htmlMessage();
65
66 static QString toHTML(QString message);
65 void *getParam(int index); 67 void *getParam(int index);
66protected: 68protected:
67 IRCOutputType m_type; 69 IRCOutputType m_type;
68 QString m_message; 70 QString m_message;
69 QList<void> m_parameters; 71 QList<void> m_parameters;
70}; 72};
71 73
72#endif 74#endif
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
@@ -50,24 +50,35 @@ void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
50 QString command; 50 QString command;
51 stream >> command; 51 stream >> command;
52 command = command.upper().right(command.length()-1); 52 command = command.upper().right(command.length()-1);
53 53
54 if (command == "JOIN") { 54 if (command == "JOIN") {
55 QString channel; 55 QString channel;
56 stream >> channel; 56 stream >> channel;
57 if (channel.length() > 0 && channel.startsWith("#")) { 57 if (channel.length() > 0 && channel.startsWith("#")) {
58 m_session->join(channel); 58 m_session->join(channel);
59 } else { 59 } else {
60 tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>"); 60 tab->appendText("<font color=\"#ff0000\">Unknown channel format!</font><br>");
61 } 61 }
62 } else if (command == "ME") {
63 QString text = IRCOutput::toHTML(line.right(line.length()-4));
64 if (text.length() > 0) {
65 if (tab->isA("IRCChannelTab")) {
66 tab->appendText("<font color=\"#cc0000\">*" + m_server.nick() + " " + text + "</font><br>");
67 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
68 } else if (tab->isA("IRCQueryTab")) {
69 } else {
70 tab->appendText("<font color=\"#ff0000\">Invalid tab for this command</font><br>");
71 }
72 }
62 } else { 73 } else {
63 tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>"); 74 tab->appendText("<font color=\"#ff0000\">Unknown command</font><br>");
64 } 75 }
65} 76}
66 77
67void IRCServerTab::processCommand() { 78void IRCServerTab::processCommand() {
68 QString text = m_field->text(); 79 QString text = m_field->text();
69 if (text.startsWith("/") && !text.startsWith("//")) { 80 if (text.startsWith("/") && !text.startsWith("//")) {
70 /* Command mode */ 81 /* Command mode */
71 executeCommand(this, text); 82 executeCommand(this, text);
72 } 83 }
73 m_field->clear(); 84 m_field->clear();
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
@@ -27,24 +27,32 @@ void IRCSession::beginSession() {
27void IRCSession::join(QString channelname) { 27void IRCSession::join(QString channelname) {
28 m_connection->sendLine("JOIN "+channelname); 28 m_connection->sendLine("JOIN "+channelname);
29} 29}
30 30
31void IRCSession::sendMessage(IRCPerson *person, QString message) { 31void IRCSession::sendMessage(IRCPerson *person, QString message) {
32 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); 32 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message);
33} 33}
34 34
35void IRCSession::sendMessage(IRCChannel *channel, QString message) { 35void IRCSession::sendMessage(IRCChannel *channel, QString message) {
36 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); 36 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message);
37} 37}
38 38
39void IRCSession::sendAction(IRCChannel *channel, QString message) {
40 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001");
41}
42
43void IRCSession::sendAction(IRCPerson *person, QString message) {
44 m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001");
45}
46
39bool IRCSession::isSessionActive() { 47bool IRCSession::isSessionActive() {
40 return m_connection->isConnected(); 48 return m_connection->isConnected();
41} 49}
42 50
43void IRCSession::endSession() { 51void IRCSession::endSession() {
44 if (m_connection->isLoggedIn()) 52 if (m_connection->isLoggedIn())
45 m_connection->sendLine("QUIT :" APP_VERSION); 53 m_connection->sendLine("QUIT :" APP_VERSION);
46 else 54 else
47 m_connection->close(); 55 m_connection->close();
48} 56}
49 57
50void IRCSession::part(IRCChannel *channel) { 58void IRCSession::part(IRCChannel *channel) {
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
@@ -41,24 +41,26 @@ friend class IRCMessageParser;
41public: 41public:
42 IRCSession(IRCServer *server); 42 IRCSession(IRCServer *server);
43 ~IRCSession(); 43 ~IRCSession();
44 44
45 void join(QString channel); 45 void join(QString channel);
46 void part(IRCChannel *channel); 46 void part(IRCChannel *channel);
47 void beginSession(); 47 void beginSession();
48 bool isSessionActive(); 48 bool isSessionActive();
49 void endSession(); 49 void endSession();
50 50
51 void sendMessage(IRCPerson *person, QString message); 51 void sendMessage(IRCPerson *person, QString message);
52 void sendMessage(IRCChannel *channel, QString message); 52 void sendMessage(IRCChannel *channel, QString message);
53 void sendAction(IRCPerson *person, QString message);
54 void sendAction(IRCChannel *channel, QString message);
53 IRCChannel *getChannel(QString channelname); 55 IRCChannel *getChannel(QString channelname);
54 IRCPerson *getPerson(QString nickname); 56 IRCPerson *getPerson(QString nickname);
55protected: 57protected:
56 void addPerson(IRCPerson *person); 58 void addPerson(IRCPerson *person);
57 void addChannel(IRCChannel *channel); 59 void addChannel(IRCChannel *channel);
58 void removeChannel(IRCChannel *channel); 60 void removeChannel(IRCChannel *channel);
59 void removePerson(IRCPerson *person); 61 void removePerson(IRCPerson *person);
60 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels); 62 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels);
61protected slots: 63protected slots:
62 void handleMessage(IRCMessage *message); 64 void handleMessage(IRCMessage *message);
63signals: 65signals:
64 void outputReady(IRCOutput output); 66 void outputReady(IRCOutput output);