williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __CNTVCARD_H__ williamr@2: #define __CNTVCARD_H__ williamr@2: williamr@2: // System includes williamr@2: #include williamr@2: #include williamr@2: williamr@2: // Classes referenced williamr@2: class CVCardAddress; williamr@2: class CVCardItemAndLabel; williamr@2: class CVCardToContactsAppConverter; williamr@2: williamr@2: // Enumerations williamr@2: /** williamr@4: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TCntVCardImportType williamr@2: { williamr@2: ECntVCardImportTypeFirstSync, williamr@2: ECntVCardImportTypeMerge williamr@2: }; williamr@2: williamr@2: class CContactVCardConverter : public CContactEcomConverter williamr@2: /** williamr@2: Plug-in vCard to CContactItem converter. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: // Ideally each converter should be able to define its own flags relevant williamr@2: // to its own mode of operation. Due to the legacy design (defining flags williamr@2: // in CContactDatabase) they have to be redeclared here. Long term we hope williamr@2: // to deprecate the CContactDatabase flags and rely on those declared in williamr@2: // the converter implementation. williamr@2: /** Import and export format flags. Contacts can be imported into williamr@2: or exported from the contact database as vCards. williamr@2: williamr@2: The following options are available during import and export. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TOptions williamr@2: { williamr@2: EDefault = CContactDatabase::EDefault, williamr@2: /** Handle Symbian's extended vCard format options. */ williamr@2: EIncludeX = CContactDatabase::EIncludeX, williamr@2: /** Support non-standard extensions requried by Symbian PC connectivity software williamr@2: and Microsoft, amongst others. */ williamr@2: ETTFormat = CContactDatabase::ETTFormat , williamr@2: /** Don't export the contact ID (for exporting only). */ williamr@2: EExcludeUid = CContactDatabase::EExcludeUid, williamr@2: /** Decrease the contact's access count when importing and exporting. */ williamr@2: EDecreaseAccessCount = CContactDatabase::EDecreaseAccessCount, williamr@2: /** Only import the first contact in the read stream (for importing only). */ williamr@2: EImportSingleContact = CContactDatabase::EImportSingleContact, williamr@2: /** Increase the contact's access count when importing and exporting. */ williamr@2: EIncreaseAccessCount = CContactDatabase::EIncreaseAccessCount, williamr@2: /** Sets a contact item to the local time when importing. */ williamr@2: ELocalTime = CContactDatabase::ELocalTime, williamr@2: /** Allows to set a template to a contact item that does not exist. */ williamr@2: ENullTemplateId = CContactDatabase::ENullTemplateId, williamr@2: /** Allows to set white spaces as value for an empty field. */ williamr@2: EConnectWhitespace=0x0100, // Used to correctly manage the TimeIS protocol for syncing. williamr@2: /** williamr@2: During import ignore the UID property value of the vCard. By ignoring williamr@2: the UID the client is indicating that it knows that the contact does not williamr@2: already exist in the database (i.e. the contact is being added rather williamr@2: than being updated). Within the CContactVCardConverter::ImportL() williamr@2: method no attempt to search for the UID in the database will be made. williamr@2: For a series of addition of vCards with UIDs use of this option will williamr@2: give a performance improvement since the search for the UID in the williamr@2: Contacts database can become very costly as the number of contacts williamr@2: grows. williamr@2: */ williamr@2: EIgnoreUid = CContactDatabase::EConverterReserved1, williamr@2: /** williamr@2: During import, if it is determined that the contact item being imported williamr@2: already exists in the database then the contact item in the database will williamr@2: be deleted before being replaced by the vCard being imported. This option williamr@2: should be used when the client does not want a merge type behaviour for williamr@2: existing contact items. This option will typically be used in a sync use case williamr@2: where the vCard data that the client is provided with has already been through a process williamr@2: of conflict resolution and so the existing contact item should be replaced not merged. williamr@2: */ williamr@2: EReplaceIfExists = CContactDatabase::EConverterReserved2, williamr@2: }; williamr@2: williamr@2: /** williamr@4: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TVersitPropertyType williamr@2: { williamr@2: EPropertyValueSingle, williamr@2: EPropertyValueComposite, williamr@2: EPropertyValueHandlingNotImplemented williamr@2: }; williamr@2: public: // from CContactConverter williamr@2: static CContactVCardConverter* NewL(); williamr@2: CArrayPtr* ImportL(CContactDatabase& aDb,RReadStream& aReadStream,TBool& aImportSuccessful,TInt aOptions,TBool aImportSingle); williamr@2: void ExportL(CContactDatabase& aDb,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOptions,const Versit::TVersitCharSet aCharSet, TBool aExportPrivateFields, TInt aCommitNumber); williamr@2: public: // Utility williamr@2: static TBool ContainsExportableData(const TDesC& aText); williamr@2: static TBool ContainsImportableData(const TDesC& aText, TVersitPropertyType aType, TCntVCardImportType aImportType); williamr@2: private: williamr@2: static TBool ContainsData(const TDesC& aText); williamr@2: void doImportL(CVCardToContactsAppConverter& aConverter, CParserVCard& aVCard, CContactDatabase& aDb, TInt aOption, TBool aIncAccessCount, TBool aDecAccessCount, TBool& aImportSuccessful, CArrayPtr* aContactItems, TBool aIsInTransaction, TContactItemId aIdForUpdate); williamr@2: TContactItemId IsVCardMergeNeededL(CVCardToContactsAppConverter& aConverter, CParserVCard& aVCard, CContactDatabase& aDb, TInt aOption); williamr@2: void ModifyAccessCountL(CContactItem& aContact, TBool aIncAccessCount, TBool aDecAccessCount); williamr@2: void HandleAgentsInVCardL(CVCardToContactsAppConverter& aConverter, CArrayPtr* aAgentProperties, CContactItem& aContact, CContactDatabase& aDb, TInt aOption, TBool aIncAccessCount, TBool aDecAccessCount, CArrayPtr* aContactItemArray, TBool aMerge); williamr@2: }; williamr@2: williamr@2: #endif williamr@4: