diff -r 7cc7d74059f9 -r 4ecbe3571b5a phonebookui/cntcommonui/contactcard/cntvcarddetailhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phonebookui/cntcommonui/contactcard/cntvcarddetailhandler.h Mon Oct 04 00:06:02 2010 +0300 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include + +#ifndef CNTVCARDDETAILHANDLER_H +#define CNTVCARDDETAILHANDLER_H + +class CntVCardDetailHandler : public QVersitContactExporterDetailHandlerV2 +{ +public: + inline CntVCardDetailHandler(){} + inline void detailProcessed(const QContact& contact, + const QContactDetail& detail, + const QSet& processedFields, + const QVersitDocument& document, + QList* toBeRemoved, + QList* toBeAdded) + { + Q_UNUSED(contact) + Q_UNUSED(detail) + Q_UNUSED(processedFields) + Q_UNUSED(document) + Q_UNUSED(toBeRemoved) + Q_UNUSED(toBeAdded) + } + + inline void contactProcessed(const QContact& contact, + QVersitDocument* document) + { + Q_UNUSED(contact) + // If there is not a FN or N value use an empty FN value. This ensures + // that the vCard created is valid. vCard standard requires a vCard to + // have atlease a name (N) of formatted name (FN) field to be valid. + bool vCardValid(false); + foreach (const QVersitProperty& property, document->properties()) { + const QString& name = property.name(); + if (name == QLatin1String("FN") || name == QLatin1String("N")) { + vCardValid = true; + break; + } + } + + if (!vCardValid) { + QVersitProperty fnProperty; + fnProperty.setName(QLatin1String("FN")); + fnProperty.setValue(QString()); + document->addProperty(fnProperty); + } + } +}; + +#endif