summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieirc/ircoutput.cpp45
-rw-r--r--noncore/net/opieirc/ircoutput.h17
2 files changed, 54 insertions, 8 deletions
diff --git a/noncore/net/opieirc/ircoutput.cpp b/noncore/net/opieirc/ircoutput.cpp
index 4822fc4..d2c730f 100644
--- a/noncore/net/opieirc/ircoutput.cpp
+++ b/noncore/net/opieirc/ircoutput.cpp
@@ -1,6 +1,16 @@
1#include <qtopia/stringutil.h>
2
1#include "ircoutput.h" 3#include "ircoutput.h"
2 4
5
6IRCOutputEscapeSecuences IRCOutput::m_escapeSecuences[] = {
7 { '', "<b>", "</b>"},
8 { '', "<u>", "</u>"},
9 { 0, 0, 0},
10};
11
3IRCOutput::IRCOutput(IRCOutputType type, QString message) { 12IRCOutput::IRCOutput(IRCOutputType type, QString message) {
4 m_type = type; 13 m_type = type;
5 m_message = message; 14 /* Filter color, bold and underline escape sequences, since they aren't implemented yet */
15 m_message = message.replace(QRegExp("[1-9]*,*[1-9]*"), "");
6} 16}
@@ -15,2 +25,10 @@ QString IRCOutput::message() {
15 25
26void IRCOutput::setType(IRCOutputType type) {
27 m_type = type;
28}
29
30void IRCOutput::setMessage(const QString &message) {
31 m_message = message;
32}
33
16QString IRCOutput::htmlMessage() { 34QString IRCOutput::htmlMessage() {
@@ -19,6 +37,22 @@ QString IRCOutput::htmlMessage() {
19 37
20QString IRCOutput::toHTML(QString message) { 38QString IRCOutput::toHTML(const QString &message) {
21 QString htmlMessage =message.replace(QRegExp("&"), "&amp;"); 39 QString htmlMessage = Qtopia::escapeString(message);
22 htmlMessage = htmlMessage.replace(QRegExp(">"), "&gt;"); 40
23 htmlMessage = htmlMessage.replace(QRegExp("<"), "&lt;"); 41 for(int i=0; m_escapeSecuences[i].escape != 0;++i) {
42 int pos = 0;
43 bool isOpen = false;
44 while( (pos = htmlMessage.find(m_escapeSecuences[i].escape, pos)) != -1) {
45 htmlMessage.remove(pos, 1);
46 if(isOpen)
47 htmlMessage.insert(pos, m_escapeSecuences[i].close);
48 else
49 htmlMessage.insert(pos, m_escapeSecuences[i].open);
50
51 isOpen = !isOpen;
52 }
53 if(isOpen)
54 htmlMessage.append(m_escapeSecuences[i].close);
55 }
56
57 htmlMessage = htmlMessage.replace(QRegExp("\n"), "<br>");
24 return htmlMessage; 58 return htmlMessage;
@@ -33 +67,2 @@ void *IRCOutput::getParam(int index) {
33} 67}
68
diff --git a/noncore/net/opieirc/ircoutput.h b/noncore/net/opieirc/ircoutput.h
index 9c0b8bb..934dbda 100644
--- a/noncore/net/opieirc/ircoutput.h
+++ b/noncore/net/opieirc/ircoutput.h
@@ -47,3 +47,10 @@ enum IRCOutputType {
47 OUTPUT_CHANPERSONMODE = 16, /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */ 47 OUTPUT_CHANPERSONMODE = 16, /* parameters : channel (IRCCHannel) person (IRCChannelPerson) */
48 OUTPUT_TOPIC = 17 /* parameters : channel (IRCChannel) */ 48 OUTPUT_TOPIC = 17, /* parameters : channel (IRCChannel) */
49 OUTPUT_TITLE = 18 /* parameters : channel (IRCChannel) */
50};
51
52typedef struct IRCOutputEscapeSecuences {
53 char escape;
54 char *open;
55 char *close;
49}; 56};
@@ -56,3 +63,3 @@ class IRCOutput {
56public: 63public:
57 IRCOutput(IRCOutputType type, QString message); 64 IRCOutput(IRCOutputType type = OUTPUT_SERVERMESSAGE, QString message = QString::null);
58 /* Used to add a parameter to this IRCOutput. Parameters are dependent 65 /* Used to add a parameter to this IRCOutput. Parameters are dependent
@@ -66,3 +73,6 @@ public:
66 73
67 static QString toHTML(QString message); 74 void setType(IRCOutputType);
75 void setMessage(const QString &message);
76
77 static QString toHTML(const QString &message);
68 void *getParam(int index); 78 void *getParam(int index);
@@ -72,2 +82,3 @@ protected:
72 QList<void> m_parameters; 82 QList<void> m_parameters;
83 static IRCOutputEscapeSecuences m_escapeSecuences[];
73}; 84};