From e2be03e254a956024c9d67b19b8a809c9692b6f1 Mon Sep 17 00:00:00 2001 From: Manjeet Dahiya Date: Tue, 20 Oct 2009 11:43:45 +0000 Subject: Using QXmlStreamWriter for directly writing to the socket. This will avoid string concatenations and problems with XML escaping rules. and Fix for Issue 19: XMPP Version < 1.0 send NonSASL Auth query --- source/QXmppVCard.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'source/QXmppVCard.cpp') diff --git a/source/QXmppVCard.cpp b/source/QXmppVCard.cpp index caf47ef8..8a5f4b0f 100644 --- a/source/QXmppVCard.cpp +++ b/source/QXmppVCard.cpp @@ -26,7 +26,7 @@ #include "QXmppUtils.h" #include "QXmppConstants.h" -#include +#include #include #include @@ -85,27 +85,21 @@ void QXmppVCard::parse(const QDomElement& nodeRecv) setPhoto(QByteArray::fromBase64(base64data)); } -QByteArray QXmppVCard::toXmlElementFromChild() const +void QXmppVCard::toXmlElementFromChild(QXmlStreamWriter *writer) const { - QString data; - QTextStream stream(&data); - - stream << ""; - helperToXmlAddElement(stream, "FN", getFullName()); + writer->writeStartElement("vCard"); + helperToXmlAddAttribute(writer,"xmlns", ns_vcard); + helperToXmlAddTextElement(writer, "FN", getFullName()); if(!getPhoto().isEmpty()) { - stream << ""; - helperToXmlAddElement(stream, "TYPE", getImageType(getPhoto())); - helperToXmlAddElement(stream, "BINVAL", getPhoto().toBase64()); - stream << ""; + writer->writeStartElement("PHOTO"); + helperToXmlAddTextElement(writer, "TYPE", getImageType(getPhoto())); + helperToXmlAddTextElement(writer, "BINVAL", getPhoto().toBase64()); + writer->writeEndElement(); } - stream << ""; - - return data.toAscii(); + writer->writeEndElement(); } QImage QXmppVCard::getPhotoAsImage() const -- cgit v1.2.3