From 966a6f2f63f089624dbd50844069f2b86e13dd81 Mon Sep 17 00:00:00 2001 From: Manjeet Dahiya Date: Tue, 7 Sep 2010 06:57:12 +0000 Subject: QXmppVCard to QXmppVCardIq --- src/QXmppVCard.cpp | 353 ----------------------------------------------------- 1 file changed, 353 deletions(-) delete mode 100644 src/QXmppVCard.cpp (limited to 'src/QXmppVCard.cpp') diff --git a/src/QXmppVCard.cpp b/src/QXmppVCard.cpp deleted file mode 100644 index da4ada0a..00000000 --- a/src/QXmppVCard.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (C) 2008-2010 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 - -#ifndef QXMPP_NO_GUI -#include -#include -#endif - -#include "QXmppVCard.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"); - helperToXmlAddAttribute(writer,"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(); -} - -#ifndef QXMPP_NO_GUI -QImage QXmppVCard::photoAsImage() const -{ - QBuffer buffer; - buffer.setData(m_photo); - buffer.open(QIODevice::ReadOnly); - QImageReader imageReader(&buffer); - return imageReader.read(); -} - -void QXmppVCard::setPhoto(const QImage& image) -{ - QByteArray ba; - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - image.save(&buffer, "PNG"); - m_photo = ba; - m_photoType = "image/png"; -} -#endif - -QString QXmppVCard::getFullName() const -{ - return m_fullName; -} - -QString QXmppVCard::getNickName() const -{ - return m_nickName; -} - -const QByteArray& QXmppVCard::getPhoto() const -{ - return m_photo; -} - -#ifndef QXMPP_NO_GUI -QImage QXmppVCard::getPhotoAsImage() const -{ - return photoAsImage(); -} -#endif -- cgit v1.2.3