epoc32/include/app/cntvcard.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/cntvcard.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __CNTVCARD_H__
    17 #define __CNTVCARD_H__
    18 
    19 // System includes
    20 #include <cntdb.h>
    21 #include <vcard.h>
    22 
    23 // Classes referenced
    24 class CVCardAddress;
    25 class CVCardItemAndLabel;
    26 class CVCardToContactsAppConverter;
    27 
    28 // Enumerations
    29 /**
    30 @internalComponent
    31 @released
    32 */
    33 enum TCntVCardImportType
    34 	{
    35 	ECntVCardImportTypeFirstSync,
    36 	ECntVCardImportTypeMerge
    37 	};
    38 		
    39 class CContactVCardConverter : public CContactEcomConverter
    40 /**
    41 Plug-in vCard to CContactItem converter.
    42 @publishedAll
    43 @released
    44 */
    45 	{
    46 public:
    47 	// Ideally each converter should be able to define its own flags relevant 
    48 	// to its own mode of operation. Due to the legacy design (defining flags 
    49 	// in CContactDatabase) they have to be redeclared here. Long term we hope 
    50 	// to deprecate the CContactDatabase flags and rely on those declared in 
    51 	// the converter implementation.
    52 	/** Import and export format flags. Contacts can be imported into
    53 	or exported from the contact database as vCards.
    54 
    55 	The following options are available during import and export.
    56                
    57 	@publishedAll
    58 	@released
    59 	*/
    60 	enum TOptions 
    61 	   	{
    62   		EDefault = CContactDatabase::EDefault,
    63         /** Handle Symbian's extended vCard format options. */
    64 		EIncludeX = CContactDatabase::EIncludeX,
    65 		/** Support non-standard extensions requried by Symbian PC connectivity software
    66 		and Microsoft, amongst others. */
    67   		ETTFormat = CContactDatabase::ETTFormat ,
    68 		/** Don't export the contact ID (for exporting only). */
    69 		EExcludeUid = CContactDatabase::EExcludeUid,
    70 		/** Decrease the contact's access count when importing and exporting. */
    71 		EDecreaseAccessCount = CContactDatabase::EDecreaseAccessCount,
    72 		/** Only import the first contact in the read stream (for importing only). */
    73 		EImportSingleContact = CContactDatabase::EImportSingleContact,
    74 		/** Increase the contact's access count when importing and exporting. */
    75 		EIncreaseAccessCount = CContactDatabase::EIncreaseAccessCount,
    76 		/** Sets a contact item to the local time when importing. */
    77 		ELocalTime = CContactDatabase::ELocalTime,
    78 		/** Allows to set a template to a contact item that does not exist. */
    79 		ENullTemplateId = CContactDatabase::ENullTemplateId,
    80 		/** Allows to set white spaces as value for an empty field.  */
    81 		EConnectWhitespace=0x0100,		// Used to correctly manage the TimeIS protocol for syncing.
    82 		/**
    83 		During import ignore the UID property value of the vCard.  By ignoring
    84 		the UID the client is indicating that it knows that the contact does not
    85 		already exist in the database (i.e. the contact is being added rather
    86 		than being updated).  Within the CContactVCardConverter::ImportL()
    87 		method no attempt to search for the UID in the database will be made.
    88 		For a series of addition of vCards with UIDs use of this option will
    89 		give a performance improvement since the search for the UID in the
    90 		Contacts database can become very costly as the number of contacts
    91 		grows.
    92 		*/
    93 		EIgnoreUid = CContactDatabase::EConverterReserved1,		
    94 		/**
    95 		During import, if it is determined that the contact item being imported 
    96 		already exists in the database then the contact item in the database will 
    97 		be deleted before being replaced by the vCard being imported. This option
    98 		should be used when the client does not want a merge type behaviour for
    99 		existing contact items. This option will typically be used in a sync use case
   100 		where the vCard data that the client is provided with has already been through a process 
   101 		of conflict resolution and so the existing contact item should be replaced not merged.
   102 		*/		
   103 		EReplaceIfExists = CContactDatabase::EConverterReserved2,
   104   		};
   105   		
   106 	/**
   107 	@internalComponent
   108 	@released
   109 	*/
   110 	enum TVersitPropertyType
   111 		{
   112 		EPropertyValueSingle,
   113 		EPropertyValueComposite,
   114 		EPropertyValueHandlingNotImplemented
   115 		};
   116 public: // from CContactConverter
   117 	static CContactVCardConverter* NewL();
   118 	CArrayPtr<CContactItem>* ImportL(CContactDatabase& aDb,RReadStream& aReadStream,TBool& aImportSuccessful,TInt aOptions,TBool aImportSingle);
   119 	void ExportL(CContactDatabase& aDb,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOptions,const Versit::TVersitCharSet aCharSet, TBool aExportPrivateFields, TInt aCommitNumber);
   120 public: // Utility
   121 	static TBool ContainsExportableData(const TDesC& aText);
   122 	static TBool ContainsImportableData(const TDesC& aText, TVersitPropertyType aType, TCntVCardImportType aImportType);
   123 private:
   124 	static TBool ContainsData(const TDesC& aText);
   125 	void doImportL(CVCardToContactsAppConverter& aConverter, CParserVCard& aVCard, CContactDatabase& aDb, TInt aOption, TBool aIncAccessCount, TBool aDecAccessCount, TBool& aImportSuccessful, CArrayPtr<CContactItem>* aContactItems, TBool aIsInTransaction, TContactItemId aIdForUpdate);
   126 	TContactItemId IsVCardMergeNeededL(CVCardToContactsAppConverter& aConverter, CParserVCard& aVCard, CContactDatabase& aDb, TInt aOption);
   127 	void ModifyAccessCountL(CContactItem& aContact,  TBool aIncAccessCount, TBool aDecAccessCount);
   128 	void HandleAgentsInVCardL(CVCardToContactsAppConverter& aConverter, CArrayPtr<CParserProperty>* aAgentProperties, CContactItem& aContact, CContactDatabase& aDb, TInt aOption, TBool aIncAccessCount, TBool aDecAccessCount, CArrayPtr<CContactItem>* aContactItemArray, TBool aMerge);
   129  	};
   130 
   131 #endif