From deb9d6cb53057ca8b90d10d6a3bdc5dcfd1b3ee4 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Wed, 8 Feb 2012 12:51:15 +0000 Subject: move files common to client/server into "base" --- src/base/QXmppVCardIq.cpp | 310 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 310 insertions(+) create mode 100644 src/base/QXmppVCardIq.cpp (limited to 'src/base/QXmppVCardIq.cpp') diff --git a/src/base/QXmppVCardIq.cpp b/src/base/QXmppVCardIq.cpp new file mode 100644 index 00000000..aaaf4554 --- /dev/null +++ b/src/base/QXmppVCardIq.cpp @@ -0,0 +1,310 @@ +/* + * Copyright (C) 2008-2011 The QXmpp developers + * + * Author: + * Manjeet Dahiya + * + * Source: + * http://code.google.com/p/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + + +#include +#include + +#include "QXmppVCardIq.h" +#include "QXmppUtils.h" +#include "QXmppConstants.h" + +QString getImageType(const QByteArray &contents) +{ + if (contents.startsWith("\x89PNG\x0d\x0a\x1a\x0a")) + return "image/png"; + else if (contents.startsWith("\x8aMNG")) + return "video/x-mng"; + else if (contents.startsWith("GIF8")) + return "image/gif"; + else if (contents.startsWith("BM")) + return "image/bmp"; + else if (contents.contains("/* XPM */")) + return "image/x-xpm"; + else if (contents.contains("writeStartElement("vCard"); + writer->writeAttribute("xmlns", ns_vcard); + if (m_birthday.isValid()) + helperToXmlAddTextElement(writer, "BDAY", m_birthday.toString("yyyy-MM-dd")); + if (!m_email.isEmpty()) + { + writer->writeStartElement("EMAIL"); + writer->writeEmptyElement("INTERNET"); + helperToXmlAddTextElement(writer, "USERID", m_email); + writer->writeEndElement(); + } + if (!m_fullName.isEmpty()) + helperToXmlAddTextElement(writer, "FN", m_fullName); + if(!m_nickName.isEmpty()) + helperToXmlAddTextElement(writer, "NICKNAME", m_nickName); + if (!m_firstName.isEmpty() || + !m_lastName.isEmpty() || + !m_middleName.isEmpty()) + { + writer->writeStartElement("N"); + if (!m_firstName.isEmpty()) + helperToXmlAddTextElement(writer, "GIVEN", m_firstName); + if (!m_lastName.isEmpty()) + helperToXmlAddTextElement(writer, "FAMILY", m_lastName); + if (!m_middleName.isEmpty()) + helperToXmlAddTextElement(writer, "MIDDLE", m_middleName); + writer->writeEndElement(); + } + if (!m_url.isEmpty()) + helperToXmlAddTextElement(writer, "URL", m_url); + + if(!photo().isEmpty()) + { + writer->writeStartElement("PHOTO"); + QString photoType = m_photoType; + if (photoType.isEmpty()) + photoType = getImageType(m_photo); + helperToXmlAddTextElement(writer, "TYPE", photoType); + helperToXmlAddTextElement(writer, "BINVAL", m_photo.toBase64()); + writer->writeEndElement(); + } + + writer->writeEndElement(); +} + -- cgit v1.2.3