/* * Copyright (C) 2008-2012 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" static 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(); } /// \endcond