summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/libiris/iris/xmpp-core/parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/protocols/jabber/libiris/iris/xmpp-core/parser.cpp')
-rw-r--r--kopete/protocols/jabber/libiris/iris/xmpp-core/parser.cpp174
1 files changed, 87 insertions, 87 deletions
diff --git a/kopete/protocols/jabber/libiris/iris/xmpp-core/parser.cpp b/kopete/protocols/jabber/libiris/iris/xmpp-core/parser.cpp
index 558a5fcd..2348c88e 100644
--- a/kopete/protocols/jabber/libiris/iris/xmpp-core/parser.cpp
+++ b/kopete/protocols/jabber/libiris/iris/xmpp-core/parser.cpp
@@ -24,12 +24,12 @@
For XMPP::Parser to be "perfect", some things must be solved/changed in the
Qt library:
- - Fix weird QDomElement::haveAttributeNS() bug (patch submitted to
+ - Fix weird TQDomElement::haveAttributeNS() bug (patch submitted to
Trolltech on Aug 31st, 2003).
- - Fix weird behavior in QXmlSimpleReader of reporting endElement() when
+ - Fix weird behavior in TQXmlSimpleReader of reporting endElement() when
the '/' character of a self-closing tag is reached, instead of when
the final '>' is reached.
- - Fix incremental parsing bugs in QXmlSimpleReader. At the moment, the
+ - Fix incremental parsing bugs in TQXmlSimpleReader. At the moment, the
only bug I've found is related to attribute parsing, but there might
be more (search for '###' in $QTDIR/src/xml/qxml.cpp).
@@ -38,10 +38,10 @@
- Deal with the <?xml?> processing instruction as an event type, so that we
can feed it back to the application properly. Right now it is completely
untrackable and is simply tacked into the first event's actualString. We
- can't easily do this because QXmlSimpleReader eats an extra byte beyond
+ can't easily do this because TQXmlSimpleReader eats an extra byte beyond
the processing instruction before reporting it.
- - Make QXmlInputSource capable of accepting data incrementally, to ensure
+ - Make TQXmlInputSource capable of accepting data incrementally, to ensure
proper text encoding detection and processing over a network. This is
technically not a bug, as we have our own subclass below to do it, but
it would be nice if Qt had this already.
@@ -49,8 +49,8 @@
#include"parser.h"
-#include<qtextcodec.h>
-#include<qptrlist.h>
+#include<tqtextcodec.h>
+#include<tqptrlist.h>
#include<string.h>
using namespace XMPP;
@@ -85,7 +85,7 @@ public:
paused = false;
mightChangeEncoding = true;
checkBad = true;
- last = QChar();
+ last = TQChar();
v_encoding = "";
resetLastData();
}
@@ -95,12 +95,12 @@ public:
last_string = "";
}
- QString lastString() const
+ TQString lastString() const
{
return last_string;
}
- void appendData(const QByteArray &a)
+ void appendData(const TQByteArray &a)
{
int oldsize = in.size();
in.resize(oldsize + a.size());
@@ -108,12 +108,12 @@ public:
processBuf();
}
- QChar lastRead()
+ TQChar lastRead()
{
return last;
}
- QChar next()
+ TQChar next()
{
if(paused)
return EndOfData;
@@ -123,14 +123,14 @@ public:
// NOTE: setting 'peek' to true allows the same char to be read again,
// however this still advances the internal byte processing.
- QChar readNext(bool peek=false)
+ TQChar readNext(bool peek=false)
{
- QChar c;
+ TQChar c;
if(mightChangeEncoding)
c = EndOfData;
else {
if(out.isEmpty()) {
- QString s;
+ TQString s;
if(!tryExtractPart(&s))
c = EndOfData;
else {
@@ -158,9 +158,9 @@ public:
return c;
}
- QByteArray unprocessed() const
+ TQByteArray unprocessed() const
{
- QByteArray a(in.size() - at);
+ TQByteArray a(in.size() - at);
memcpy(a.data(), in.data() + at, a.size());
return a;
}
@@ -175,21 +175,21 @@ public:
return paused;
}
- QString encoding() const
+ TQString encoding() const
{
return v_encoding;
}
private:
- QTextDecoder *dec;
- QByteArray in;
- QString out;
+ TQTextDecoder *dec;
+ TQByteArray in;
+ TQString out;
int at;
bool paused;
bool mightChangeEncoding;
- QChar last;
- QString v_encoding;
- QString last_string;
+ TQChar last;
+ TQString v_encoding;
+ TQString last_string;
bool checkBad;
void processBuf()
@@ -198,7 +198,7 @@ private:
printf("processing. size=%d, at=%d\n", in.size(), at);
#endif
if(!dec) {
- QTextCodec *codec = 0;
+ TQTextCodec *codec = 0;
uchar *p = (uchar *)in.data() + at;
int size = in.size() - at;
@@ -216,9 +216,9 @@ private:
}
}
if(utf16)
- codec = QTextCodec::codecForMib(1000); // UTF-16
+ codec = TQTextCodec::codecForMib(1000); // UTF-16
else
- codec = QTextCodec::codecForMib(106); // UTF-8
+ codec = TQTextCodec::codecForMib(106); // UTF-8
v_encoding = codec->name();
dec = codec->makeDecoder();
@@ -238,11 +238,11 @@ private:
int n2 = out.find('>', n);
if(n2 != -1) {
++n2;
- QString h = out.mid(n, n2-n);
- QString enc = processXmlHeader(h);
- QTextCodec *codec = 0;
+ TQString h = out.mid(n, n2-n);
+ TQString enc = processXmlHeader(h);
+ TQTextCodec *codec = 0;
if(!enc.isEmpty())
- codec = QTextCodec::codecForName(enc.latin1());
+ codec = TQTextCodec::codecForName(enc.latin1());
// changing codecs
if(codec) {
@@ -257,7 +257,7 @@ private:
break;
}
}
- QString s;
+ TQString s;
if(!tryExtractPart(&s))
break;
if(checkBad && checkForBadChars(s)) {
@@ -273,7 +273,7 @@ private:
}
}
- QString processXmlHeader(const QString &h)
+ TQString processXmlHeader(const TQString &h)
{
if(h.left(5) != "<?xml")
return "";
@@ -281,7 +281,7 @@ private:
int endPos = h.find(">");
int startPos = h.find("encoding");
if(startPos < endPos && startPos != -1) {
- QString encoding;
+ TQString encoding;
do {
startPos++;
if(startPos > endPos) {
@@ -302,13 +302,13 @@ private:
return "";
}
- bool tryExtractPart(QString *s)
+ bool tryExtractPart(TQString *s)
{
int size = in.size() - at;
if(size == 0)
return false;
uchar *p = (uchar *)in.data() + at;
- QString nextChars;
+ TQString nextChars;
while(1) {
nextChars = dec->toUnicode((const char *)p, 1);
++p;
@@ -333,7 +333,7 @@ private:
return true;
}
- bool checkForBadChars(const QString &s)
+ bool checkForBadChars(const TQString &s)
{
int len = s.find('<');
if(len == -1)
@@ -357,7 +357,7 @@ namespace XMPP
class ParserHandler : public QXmlDefaultHandler
{
public:
- ParserHandler(StreamInput *_in, QDomDocument *_doc)
+ ParserHandler(StreamInput *_in, TQDomDocument *_doc)
{
in = _in;
doc = _doc;
@@ -381,7 +381,7 @@ namespace XMPP
return true;
}
- bool startPrefixMapping(const QString &prefix, const QString &uri)
+ bool startPrefixMapping(const TQString &prefix, const TQString &uri)
{
if(depth == 0) {
nsnames += prefix;
@@ -390,14 +390,14 @@ namespace XMPP
return true;
}
- bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
+ bool startElement(const TQString &namespaceURI, const TQString &localName, const TQString &qName, const TQXmlAttributes &atts)
{
if(depth == 0) {
Parser::Event *e = new Parser::Event;
- QXmlAttributes a;
+ TQXmlAttributes a;
for(int n = 0; n < atts.length(); ++n) {
- QString uri = atts.uri(n);
- QString ln = atts.localName(n);
+ TQString uri = atts.uri(n);
+ TQString ln = atts.localName(n);
if(a.index(uri, ln) == -1)
a.append(atts.qName(n), uri, ln, atts.value(n));
}
@@ -411,10 +411,10 @@ namespace XMPP
in->pause(true);
}
else {
- QDomElement e = doc->createElementNS(namespaceURI, qName);
+ TQDomElement e = doc->createElementNS(namespaceURI, qName);
for(int n = 0; n < atts.length(); ++n) {
- QString uri = atts.uri(n);
- QString ln = atts.localName(n);
+ TQString uri = atts.uri(n);
+ TQString ln = atts.localName(n);
bool have;
if(!uri.isEmpty()) {
have = e.hasAttributeNS(uri, ln);
@@ -440,7 +440,7 @@ namespace XMPP
return true;
}
- bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
+ bool endElement(const TQString &namespaceURI, const TQString &localName, const TQString &qName)
{
--depth;
if(depth == 0) {
@@ -461,8 +461,8 @@ namespace XMPP
eventList.append(e);
in->pause(true);
- elem = QDomElement();
- current = QDomElement();
+ elem = TQDomElement();
+ current = TQDomElement();
}
else
current = current.parentNode().toElement();
@@ -474,22 +474,22 @@ namespace XMPP
return true;
}
- bool characters(const QString &str)
+ bool characters(const TQString &str)
{
if(depth >= 1) {
- QString content = str;
+ TQString content = str;
if(content.isEmpty())
return true;
if(!current.isNull()) {
- QDomText text = doc->createTextNode(content);
+ TQDomText text = doc->createTextNode(content);
current.appendChild(text);
}
}
return true;
}
- /*bool processingInstruction(const QString &target, const QString &data)
+ /*bool processingInstruction(const TQString &target, const TQString &data)
{
printf("Processing: [%s], [%s]\n", target.latin1(), data.latin1());
in->resetLastData();
@@ -498,22 +498,22 @@ namespace XMPP
void checkNeedMore()
{
- // Here we will work around QXmlSimpleReader strangeness and self-closing tags.
+ // Here we will work around TQXmlSimpleReader strangeness and self-closing tags.
// The problem is that endElement() is called when the '/' is read, not when
// the final '>' is read. This is a potential problem when obtaining unprocessed
// bytes from StreamInput after this event, as the '>' character will end up
// in the unprocessed chunk. To work around this, we need to advance StreamInput's
// internal byte processing, but not the xml character data. This way, the '>'
// will get processed and will no longer be in the unprocessed return, but
- // QXmlSimpleReader can still read it. To do this, we call StreamInput::readNext
+ // TQXmlSimpleReader can still read it. To do this, we call StreamInput::readNext
// with 'peek' mode.
- QChar c = in->readNext(true); // peek
- if(c == QXmlInputSource::EndOfData) {
+ TQChar c = in->readNext(true); // peek
+ if(c == TQXmlInputSource::EndOfData) {
needMore = true;
}
else {
// We'll assume the next char is a '>'. If it isn't, then
- // QXmlSimpleReader will deal with that problem on the next
+ // TQXmlSimpleReader will deal with that problem on the next
// parse. We don't need to take any action here.
needMore = false;
@@ -540,11 +540,11 @@ namespace XMPP
}
StreamInput *in;
- QDomDocument *doc;
+ TQDomDocument *doc;
int depth;
- QStringList nsnames, nsvalues;
- QDomElement elem, current;
- QPtrList<Parser::Event> eventList;
+ TQStringList nsnames, nsvalues;
+ TQDomElement elem, current;
+ TQPtrList<Parser::Event> eventList;
bool needMore;
};
}
@@ -557,11 +557,11 @@ class Parser::Event::Private
{
public:
int type;
- QString ns, ln, qn;
- QXmlAttributes a;
- QDomElement e;
- QString str;
- QStringList nsnames, nsvalues;
+ TQString ns, ln, qn;
+ TQXmlAttributes a;
+ TQDomElement e;
+ TQString str;
+ TQStringList nsnames, nsvalues;
};
Parser::Event::Event()
@@ -601,49 +601,49 @@ int Parser::Event::type() const
return d->type;
}
-QString Parser::Event::nsprefix(const QString &s) const
+TQString Parser::Event::nsprefix(const TQString &s) const
{
- QStringList::ConstIterator it = d->nsnames.begin();
- QStringList::ConstIterator it2 = d->nsvalues.begin();
+ TQStringList::ConstIterator it = d->nsnames.begin();
+ TQStringList::ConstIterator it2 = d->nsvalues.begin();
for(; it != d->nsnames.end(); ++it) {
if((*it) == s)
return (*it2);
++it2;
}
- return QString::null;
+ return TQString::null;
}
-QString Parser::Event::namespaceURI() const
+TQString Parser::Event::namespaceURI() const
{
return d->ns;
}
-QString Parser::Event::localName() const
+TQString Parser::Event::localName() const
{
return d->ln;
}
-QString Parser::Event::qName() const
+TQString Parser::Event::qName() const
{
return d->qn;
}
-QXmlAttributes Parser::Event::atts() const
+TQXmlAttributes Parser::Event::atts() const
{
return d->a;
}
-QString Parser::Event::actualString() const
+TQString Parser::Event::actualString() const
{
return d->str;
}
-QDomElement Parser::Event::element() const
+TQDomElement Parser::Event::element() const
{
return d->e;
}
-void Parser::Event::setDocumentOpen(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts, const QStringList &nsnames, const QStringList &nsvalues)
+void Parser::Event::setDocumentOpen(const TQString &namespaceURI, const TQString &localName, const TQString &qName, const TQXmlAttributes &atts, const TQStringList &nsnames, const TQStringList &nsvalues)
{
if(!d)
d = new Private;
@@ -656,7 +656,7 @@ void Parser::Event::setDocumentOpen(const QString &namespaceURI, const QString &
d->nsvalues = nsvalues;
}
-void Parser::Event::setDocumentClose(const QString &namespaceURI, const QString &localName, const QString &qName)
+void Parser::Event::setDocumentClose(const TQString &namespaceURI, const TQString &localName, const TQString &qName)
{
if(!d)
d = new Private;
@@ -666,7 +666,7 @@ void Parser::Event::setDocumentClose(const QString &namespaceURI, const QString
d->qn = qName;
}
-void Parser::Event::setElement(const QDomElement &elem)
+void Parser::Event::setElement(const TQDomElement &elem)
{
if(!d)
d = new Private;
@@ -681,7 +681,7 @@ void Parser::Event::setError()
d->type = Error;
}
-void Parser::Event::setActualString(const QString &str)
+void Parser::Event::setActualString(const TQString &str)
{
d->str = str;
}
@@ -727,10 +727,10 @@ public:
}
}
- QDomDocument *doc;
+ TQDomDocument *doc;
StreamInput *in;
ParserHandler *handler;
- QXmlSimpleReader *reader;
+ TQXmlSimpleReader *reader;
};
Parser::Parser()
@@ -740,7 +740,7 @@ Parser::Parser()
// check for evil bug in Qt <= 3.2.1
if(!qt_bug_check) {
qt_bug_check = true;
- QDomElement e = d->doc->createElementNS("someuri", "somename");
+ TQDomElement e = d->doc->createElementNS("someuri", "somename");
if(e.hasAttributeNS("someuri", "somename"))
qt_bug_have = true;
else
@@ -758,7 +758,7 @@ void Parser::reset()
d->reset();
}
-void Parser::appendData(const QByteArray &a)
+void Parser::appendData(const TQByteArray &a)
{
d->in->appendData(a);
@@ -787,12 +787,12 @@ Parser::Event Parser::readNext()
return e;
}
-QByteArray Parser::unprocessed() const
+TQByteArray Parser::unprocessed() const
{
return d->in->unprocessed();
}
-QString Parser::encoding() const
+TQString Parser::encoding() const
{
return d->in->encoding();
}