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