phonebookengines/contactsmodel/inc/CNTDB.H
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __CNTDB_H__
       
    17 #define __CNTDB_H__
       
    18 
       
    19 // System includes
       
    20 #include <e32base.h>
       
    21 #include <cntdef.h>
       
    22 #include <cntdbobs.h>
       
    23 #include <cntsync.h>
       
    24 #include <s32file.h>
       
    25 #include <badesca.h>
       
    26 #include <versit.h>
       
    27 #include <collate.h>
       
    28 
       
    29 #include <ecom/ecom.h>
       
    30 
       
    31 // Classes referenced
       
    32 //
       
    33 class CContactViewDef;
       
    34 class CFoundMatches;
       
    35 class CContactTextDef;
       
    36 class CContactItem;
       
    37 class CContactItemViewDef;
       
    38 class CContactItemFieldSet;
       
    39 class CContactItemFieldDef;
       
    40 class CContactActiveCompress;
       
    41 class CContactActiveRecover;
       
    42 class CContactDatabase;
       
    43 class CContactTables;
       
    44 class CCntFilter;
       
    45 class CContentType;
       
    46 class CContactItemField;
       
    47 class CIdleFinder;
       
    48 class CContactClientSession;
       
    49 class CPrivConverter;
       
    50 class RCntModel;
       
    51 class CProxyFactory;
       
    52 class CCntTemplateCache;
       
    53 class CSortArray;
       
    54 class CCntIdleSorter;
       
    55 class MLplPersistenceLayerFactory;
       
    56 class CContactOpenOperation;
       
    57 class CDataBaseChangeObserver;
       
    58 class CContactConverter;
       
    59 
       
    60 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    61 class CContactSynchroniser;
       
    62 #endif
       
    63 
       
    64 // Constants
       
    65 
       
    66 /** 
       
    67 Maximum string length used to separate the fields in the text definition.
       
    68 @see TContactTextDefItem
       
    69 @publishedAll
       
    70 @released
       
    71 */
       
    72 const TInt KMaxContactTextSeperator=4;
       
    73 /** 
       
    74 Constant used during sorting and searching of contacts.
       
    75 @publishedAll
       
    76 @released
       
    77 */
       
    78 const TInt KTextFieldMinimalLength=64;
       
    79 /** 
       
    80 Maximum number of fields that can be set as filterable fields by licensees.
       
    81 @publishedAll
       
    82 @released
       
    83 */
       
    84 const TInt KMaxCustomFilterableFields=4;
       
    85 
       
    86 /** 
       
    87 Enables searching for best matching strategy: 
       
    88 Leading zeros are removed then shorter number must be substring of second one.
       
    89 @see CContactDatabase::MatchPhoneNumberL
       
    90 @publishedAll
       
    91 @released
       
    92 */
       
    93 const TInt KBestMatchingPhoneNumbers=0;
       
    94 
       
    95 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    96 
       
    97 /** @internalComponent */
       
    98 const TInt KMajorVersion=1;
       
    99 /** @internalComponent */
       
   100 const TInt KMinorVersion=0;
       
   101 /** @internalComponent */
       
   102 const TInt KBuildNumber=40;
       
   103 
       
   104 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
   105 
       
   106 //
       
   107 // Classes used for compact
       
   108 //
       
   109 
       
   110 class MContactStorageObserver
       
   111 /**
       
   112 Mixin used to observe low disk events
       
   113 
       
   114 @publishedAll
       
   115 @released
       
   116 */
       
   117 	{
       
   118 public:
       
   119 	virtual void HandleDiskSpaceEvent(TInt aDrive) = 0;
       
   120 	};
       
   121 
       
   122 class MContactUiCompactObserver
       
   123 /** Mixin used to observe contact database compaction status
       
   124 @publishedAll
       
   125 @released
       
   126 */
       
   127 	{
       
   128 public:
       
   129 	virtual void Step(TInt aStep)=0;
       
   130 	virtual void HandleError(TInt aError)=0;
       
   131 	};
       
   132 
       
   133 class MContactUiActive
       
   134 /**  Mixin used to register the observer.
       
   135 @publishedAll
       
   136 @released
       
   137 */
       
   138 	{
       
   139 public:
       
   140 	virtual void Cancel()=0;
       
   141 	virtual void SetObserver(MContactUiCompactObserver *aObserver)=0;
       
   142 	virtual TInt StepsTogo() const=0;
       
   143 	virtual TInt Step()=0;
       
   144 	virtual TInt Error() const=0;
       
   145 private:
       
   146 	IMPORT_C virtual void MContactUiActive_Reserved1();
       
   147 	};
       
   148 
       
   149 class CContactActiveBase : public CBase, public MContactUiActive
       
   150 /**
       
   151 @publishedAll
       
   152 @released
       
   153 */
       
   154 	{
       
   155 public:
       
   156 	~CContactActiveBase();
       
   157 	void SetObserver(MContactUiCompactObserver *aObserver);
       
   158 	void Cancel();
       
   159 	TInt StepsTogo() const;
       
   160 	TInt Step();
       
   161 	TInt Error() const;
       
   162 	void SetContactDatabase(CContactDatabase* aContactDatabase);
       
   163 	void SetFileManagerL(RCntModel& aCntSvr);
       
   164 	
       
   165 #ifndef __SYMBIAN_CNTMODEL_USE_SQLITE__ 	
       
   166 protected:
       
   167 	MContactUiCompactObserver *iObserver;
       
   168 	RCntModel* iCntSvr; 
       
   169 	CIdle *iIdle;
       
   170 	TInt iStep;
       
   171 	TInt iError;
       
   172 	CContactDatabase* iContactDatabase;
       
   173 #endif	
       
   174 	};
       
   175 	
       
   176 class CContactActiveCompress : public CContactActiveBase
       
   177 /**
       
   178 @publishedAll
       
   179 @released
       
   180 */
       
   181 	{
       
   182 public:
       
   183 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
       
   184     void ConstructL(RDbNamedDatabase /* &aDataBase */) {};
       
   185 #endif	
       
   186 	};
       
   187 
       
   188 class CContactActiveRecover : public CContactActiveBase
       
   189 /**
       
   190 @publishedAll
       
   191 @released
       
   192 */
       
   193 	{
       
   194 public:
       
   195 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
       
   196     void ConstructL(RDbNamedDatabase /* &aDataBase */) {};
       
   197 #endif	
       
   198 	};
       
   199 
       
   200 
       
   201 class TContactTextDefItem
       
   202 /** An item in a text definition.
       
   203 
       
   204 A TContactTextDefItem has a field type and an optional separator string
       
   205 with a maximum length of 4 characters.
       
   206 
       
   207 @see CContactTextDef
       
   208 @publishedAll
       
   209 @released
       
   210 */
       
   211 	{
       
   212 public:
       
   213 	IMPORT_C TContactTextDefItem();
       
   214 	IMPORT_C TContactTextDefItem(TFieldType aFieldType);
       
   215 	IMPORT_C TContactTextDefItem(TFieldType aFieldType, const TDesC &aSeperator);
       
   216 public:
       
   217 	/** The field type. */
       
   218 	TFieldType iFieldType;
       
   219 	/** The string used to separate the fields in the text definition. */
       
   220 	TBuf<KMaxContactTextSeperator> iSeperator;
       
   221 	};
       
   222 
       
   223 class CContactTextDef : public CArrayFixFlat<TContactTextDefItem>
       
   224 /** Defines a way of grouping fields to form a string which represents
       
   225 a contact item.
       
   226 
       
   227 A text definition is implemented as an array of text definition items
       
   228 (TContactTextDefItems).
       
   229 
       
   230 For example, CContactDatabase::ReadContactTextDefL() uses a text definition to
       
   231 build up a string from a contact item. When creating the string, it searches
       
   232 the item for fields whose type matches one of the fields specified in the text
       
   233 definition. The contents of the first matching field of each type found in the
       
   234 item are read into the string. These strings may be separated using a field
       
   235 separator, which is also specified in the text definition. A separator is not
       
   236 appended to the last field used to make up the string. It is only inserted when
       
   237 there is a following non-empty field.
       
   238 
       
   239 Additionally, the text definition may also contain a fallback field
       
   240 type. This is used when none of the fields specified in the text
       
   241 definition contain any text. If the item's fallback field contains no text
       
   242 either, or if the fallback field type's value is KUidContactFieldNone, the
       
   243 text is read from the first non-empty field in the item.
       
   244 
       
   245 A contact database can have a default text definition which is set using CContactDatabase::SetTextDefinitionL().
       
   246 This may be overridden using the variants of CContactDatabase::ReadContactTextDefL()
       
   247 which take a CContactTextDef* argument.
       
   248 
       
   249 CContactTextDef is derived from CArrayFixFlat<TContactTextDefItem>, so all
       
   250 relevant functions can be used, e.g. to add and remove elements.
       
   251 
       
   252 @publishedAll
       
   253 @released
       
   254 */
       
   255 	{
       
   256 	friend class CContactDatabase;
       
   257 	friend class CContactTables;
       
   258 public:
       
   259 	CContactTextDef();
       
   260 	IMPORT_C static CContactTextDef* NewL();
       
   261 	IMPORT_C static CContactTextDef* NewLC();
       
   262 	static CContactTextDef* NewLC(RReadStream& aStream);
       
   263 	IMPORT_C void SetFallbackField(TFieldType iFieldType);
       
   264 	IMPORT_C TFieldType FallbackField() const;
       
   265 	IMPORT_C TBool ExactMatchOnly();
       
   266 	IMPORT_C void SetExactMatchOnly(TBool aExactMatchOnly);
       
   267 	void ExternalizeL(RWriteStream& aStream) const;
       
   268 	void InternalizeL(RReadStream& aStream);	
       
   269 private:
       
   270 	TFieldType iFallbackFieldType;
       
   271 	TBool iExactMatchOnly;//Default to EFalse cause ReadInTextDef to only match the chosen fields and not attempt a matchall
       
   272 	};
       
   273 
       
   274 class CContactItemViewDef : public CBase
       
   275 /** A view definition for a contact item.
       
   276 
       
   277 When reading or opening a contact item using the CContactDatabase class,
       
   278 a view definition may be specified to indicate which field data should be
       
   279 retrieved. See for instance CContactDatabase::ReadContactL().
       
   280 
       
   281 A view definition for a contact item contains an array of field types, a use
       
   282 (CContactItemViewDef::TUse) and a mode (CContactItemViewDef::TMode). The use
       
   283 indicates whether the field types contained in the view definition should
       
   284 be included in or excluded from the view. The mode indicates whether fields
       
   285 with the hidden attribute should be included or excluded.
       
   286 
       
   287 @publishedAll
       
   288 @released
       
   289 */
       
   290 	{
       
   291 public:
       
   292 	/** Include or exclude specified fields. */
       
   293 	enum TUse
       
   294 			{
       
   295 			/** Include specified fields in the view. */
       
   296 			EIncludeFields,
       
   297 			/** Exclude specified fields from the view. */
       
   298 			EMaskFields
       
   299 			};
       
   300 	/** Include or exclude hidden fields.*/
       
   301 	enum TMode
       
   302 			{
       
   303 			/** Include hidden fields in the view. */
       
   304 			EIncludeHiddenFields,
       
   305 			/** Exclude hidden fields from the view. */
       
   306 			EMaskHiddenFields
       
   307 			};
       
   308 public:
       
   309 	IMPORT_C static CContactItemViewDef* NewL(TUse aUse, TMode aMode);
       
   310 	IMPORT_C static CContactItemViewDef* NewLC(TUse aUse, TMode aMode);
       
   311 	static CContactItemViewDef* NewLC(RReadStream& aStream);
       
   312     inline TUid operator[](TInt aIndex) const;
       
   313     IMPORT_C TInt Find(const CContentType &aContentType) const;
       
   314     IMPORT_C TInt Find(TFieldType aFieldType) const;
       
   315     inline TInt Count() const;
       
   316     inline void Reset();
       
   317 	IMPORT_C void AddL(TFieldType aFieldType);
       
   318 	IMPORT_C void Remove(TFieldType aFieldType);
       
   319 	IMPORT_C void Remove(TInt aIndex);
       
   320 	inline TUse Use() const;
       
   321 	inline void SetUse(TUse aUse);
       
   322 	inline TMode Mode() const;
       
   323 	inline void SetMode(TMode aMode);
       
   324 	IMPORT_C TBool Contains(const CContactItem& aItem);
       
   325 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   326 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   327 	IMPORT_C TBool MatchesAll() const;
       
   328 private:
       
   329 	CContactItemViewDef(TUse aUse,TMode aMode);
       
   330 private:
       
   331     CArrayFixFlat<TUid> iFieldTypes;
       
   332 	TUse iUse;
       
   333 	TMode iMode;
       
   334 	};
       
   335 
       
   336 class CContactViewDef : public CBase
       
   337 /** Specifies a subset of fields to be loaded when reading a contact item.
       
   338 
       
   339 A default view definition is owned by the contact database.
       
   340 It is set using CContactDatabase::SetViewDefinitionL() and is used in calls
       
   341 to CContactDatabase::ReadContactL(), ReadContactLC() and ReadContactAndAgentL()
       
   342 when no view definition is specified.
       
   343 
       
   344 The view definition owns the item view definition (see the CContactItemViewDef
       
   345 class), which stores the view definition's field types, use and mode.
       
   346 
       
   347 The following functions declared in class CContactViewDef have not been
       
   348 implemented:- Groups(), AddL().
       
   349 
       
   350 @publishedAll
       
   351 @released
       
   352 */
       
   353 	{
       
   354 public:
       
   355 	IMPORT_C static CContactViewDef* NewL();
       
   356 	IMPORT_C static CContactViewDef* NewLC();
       
   357 	IMPORT_C static CContactViewDef* NewL(CContactItemViewDef* aItemDef);
       
   358 	IMPORT_C static CContactViewDef* NewLC(CContactItemViewDef* aItemDef);
       
   359 	static CContactViewDef* NewLC(RReadStream& aStream);
       
   360 	IMPORT_C ~CContactViewDef();
       
   361 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   362 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   363 	IMPORT_C CContactItemViewDef& ItemDef() const;
       
   364 	/** This function is not implemented    */
       
   365 	IMPORT_C CContactIdArray& Groups() const;
       
   366 	/** This function is not implemented. 
       
   367 	@param aFieldType The field type to append to the array of field types. */
       
   368 	inline void AddL(TFieldType aFieldType);
       
   369 private:
       
   370 	CContactViewDef();
       
   371 	void ConstructL(CContactItemViewDef* aItemDef);
       
   372 private:
       
   373 	CContactItemViewDef* iItemDef;
       
   374 //	CContactIdArray* iGroupIds; // unused for now
       
   375 	};
       
   376 
       
   377 class TContactIter
       
   378 /** Iterates through the sorted contact items in a contact database.
       
   379 
       
   380 A value of KNullContactId is returned by the iterator if a requested item cannot
       
   381 be found.
       
   382 
       
   383 @publishedAll
       
   384 @released
       
   385 */
       
   386 	{
       
   387 public:
       
   388 	IMPORT_C TContactIter(CContactDatabase &aDatabase);
       
   389 	IMPORT_C TContactItemId FirstL();
       
   390 	IMPORT_C TContactItemId NextL();
       
   391 	IMPORT_C TContactItemId PreviousL();
       
   392 	IMPORT_C TContactItemId LastL();
       
   393 	IMPORT_C void GotoL(TContactItemId aContactId);
       
   394 	IMPORT_C void Reset();
       
   395 private:
       
   396 	void GotoIndexL(TInt aPos);
       
   397 private:
       
   398 	CContactDatabase &iDatabase;
       
   399 	TContactItemId iCursorId;
       
   400 	};
       
   401 
       
   402 class MIdleFindObserver
       
   403 /** The interface for an asynchronous find observer.
       
   404 
       
   405 An object which implements this interface is passed to the asynchronous find
       
   406 functions defined in class CContactDatabase, (FindAsyncL() and FindInTextDefAsyncL()).
       
   407 The observer would typically notify the user of the progress of the operation.
       
   408 
       
   409 @publishedAll
       
   410 @released
       
   411 */
       
   412 	{
       
   413 public:
       
   414 	/** Asynchronous find observer callback.
       
   415 
       
   416 	If an observer is supplied to CContactDatabase::FindAsyncL()
       
   417 	or FindInTextDefAsyncL(), this callback function is called by CIdle::RunL()
       
   418 	when nothing of a higher priority can be scheduled. It is called for every
       
   419 	16 items searched to give the application a chance to update its search status.
       
   420 
       
   421 	An implementation might test for and handle errors and retrieve information
       
   422 	about the progress of the search. This information may be retrieved using
       
   423 	functions provided by the CIdleFinder class. */
       
   424 	virtual void IdleFindCallback()=0;
       
   425 	};
       
   426 
       
   427 struct SFindInTextDefWordParser
       
   428 /** Search string parser struct.
       
   429 
       
   430 An object of this type is used in the callback parser function passed to
       
   431 CContactDatabase::FindInTextDefLC(). The parser function must walk
       
   432 through and parse iSearchString, adding any words found to iWordArray.
       
   433 
       
   434 @publishedAll
       
   435 @released
       
   436 */
       
   437 	{
       
   438 public:
       
   439 	inline SFindInTextDefWordParser(const TDesC *aSearchString, CDesCArray *aWordArray) : iSearchString(aSearchString), iWordArray(aWordArray)
       
   440 	/** Initialises the search string and the word array.
       
   441 
       
   442 	@param aSearchString Pointer to the input string to be parsed.
       
   443 	@param aWordArray Pointer to the array to which words parsed from the input
       
   444 	string should be added. */
       
   445 		{};
       
   446 public:
       
   447 	/** Pointer to the input string to be parsed. */
       
   448 	const TDesC *iSearchString;
       
   449 	/** Pointer to the array to which words parsed from the input string should be
       
   450 	added. */
       
   451 	CDesCArray *iWordArray;
       
   452 	};
       
   453 
       
   454 class CIdleFinder : public CIdle
       
   455 /** Provides information about the progress of an asynchronous contact database search,
       
   456 and can be used to get the results of the search.
       
   457 
       
   458 An instance of this class is returned by calls to CContactDatabase::FindAsyncL()
       
   459 and CContactDatabase::FindInTextDefAsyncL().
       
   460 
       
   461 @publishedAll
       
   462 @released
       
   463 */
       
   464 	{
       
   465 public:
       
   466 	~CIdleFinder();
       
   467 	IMPORT_C TBool IsComplete() const;
       
   468 	IMPORT_C CContactIdArray *TakeContactIds();
       
   469 	IMPORT_C TInt Error() const;
       
   470 	TInt RunError(TInt aError);
       
   471 private:
       
   472 	friend class CContactDatabase;
       
   473 	static CIdleFinder *NewL(CContactDatabase &aContactDatabase, const TDesC& aText, const CContactItemFieldDef *aFieldDef, MIdleFindObserver *aObserver);
       
   474 	static CIdleFinder *NewL(CContactDatabase &aContactDatabase, const MDesCArray* aFindWords,const CContactTextDef* aTextDef, MIdleFindObserver *aObserver, const TCallBack &aWordParserCallback);
       
   475 	void DoCancel();
       
   476 	void Start();
       
   477 	static TInt CallbackL(TAny *aSelf);
       
   478 	void ConstructL(const TDesC *aText, const MDesCArray* aFindWords, const TCallBack *aWordParserCallback);
       
   479 	TBool ScanForMatchL(const TDesC &aFieldText,const TDesC &aFindText, CFoundMatches *aFoundMatches) const;
       
   480 	TBool CheckFindL(TContactItemId aContactId) const;
       
   481 	TBool CheckFindL() const;
       
   482 	CIdleFinder(CContactDatabase &aContactDatabase, const CContactItemFieldDef *aFieldDef, const CContactTextDef* aTextDef, MIdleFindObserver *aObserver);
       
   483 	TBool doFindL();
       
   484 
       
   485 	enum TAsyncFindState
       
   486 		{
       
   487 		EFindInBlobFinished				=0x00000001,
       
   488 		EFindInIdentityFinished			=0x00000002,
       
   489 		EFindInEmailFinished			=0x00000004,
       
   490 		EFindInTextDefFinished			=0x00000008
       
   491 		};
       
   492 private:
       
   493 	CContactDatabase *iContactDatabase;
       
   494 	CContactIdArray *iIdsFound;
       
   495 	TBool iOwnsIds;
       
   496 	CDesCArray*		iFindWords;
       
   497 	TInt iReserved1;
       
   498 	TInt iReserved2;
       
   499 	TInt iReserved3;
       
   500 	const CContactItemFieldDef* iFieldDef;
       
   501 	const CContactTextDef* iTextDef;
       
   502 	MIdleFindObserver *iObserver;
       
   503 	TInt iError;
       
   504 	TCallBack iWordParserCallback;
       
   505 	TInt iReserved4;
       
   506 	TInt iReserved5;
       
   507 	TInt iReserved6;
       
   508 	TInt iReserved7; //was 	TDbColNo
       
   509 	TInt iReserved8; //was 	RDbView
       
   510 	TInt iReserved9; //was 	RDbView
       
   511 	TInt iReserved10; //was CIdentityTableColSet*
       
   512 	};
       
   513 
       
   514 class MContactDbPrivObserver
       
   515 /** Provides notification of database changes to clients. 
       
   516 * Provides information about database change event details and the type of changed event.
       
   517 @publishedAll
       
   518 @released
       
   519 */
       
   520 	{
       
   521 public:
       
   522 
       
   523 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
       
   524 	virtual void HandleDatabaseEventL(RDbNotifier::TEvent)=0;
       
   525 #endif	
       
   526 	virtual void HandleDatabaseEventL(const TContactDbObserverEvent &aEvent)=0;
       
   527 	};
       
   528 
       
   529 
       
   530 class MContactSortObserver
       
   531 /**
       
   532 @publishedAll
       
   533 @deprecated
       
   534 */
       
   535 	{
       
   536 public:
       
   537     /**
       
   538     @deprecated
       
   539     */
       
   540 	virtual void HandleSortEventL(TInt aContactsSorted, TInt aContactsTotal)=0;
       
   541 	};
       
   542 
       
   543 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   544 class MConverterCallBack
       
   545 /**
       
   546 Interface class for providing Intra-Contact Properties during a PBAP specific contacts export.
       
   547 @released
       
   548 @internalTechnology
       
   549 */
       
   550 {
       
   551 	public:
       
   552 	/**
       
   553 	PBAP clients are supposed to provide any information regarding the contact item represented by aContactId.
       
   554 	This information should be in form of standard vCard property, all such properties should be appended to the array aPropertyList.
       
   555 	*/
       
   556 	virtual	void AddIntraContactPropertiesL(const TContactItemId& aContactId, CArrayPtr<CParserProperty>* aPropertyList) = 0;
       
   557 };
       
   558 #else
       
   559 class MConverterCallBack;
       
   560 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
   561 
       
   562 enum TVCardVersion
       
   563 /**
       
   564 Specifies type of export of contact items.
       
   565 PBAP clients should use EPBAPVCard21 and EPBAPVCard30.
       
   566 @publishedAll
       
   567 @released
       
   568 */
       
   569 	{
       
   570 	EVCardUDEF = -1,
       
   571 	EVCard21 = 0,
       
   572 	EVCard30,
       
   573 	EPBAPVCard21,
       
   574 	EPBAPVCard30
       
   575 	};
       
   576 
       
   577 class CContactDatabase : public CBase, public MContactDbPrivObserver, public MContactStorageObserver
       
   578 /** A database of contact items.
       
   579 
       
   580 Contact items can be added to and removed from the database and items in the
       
   581 database can be opened or read. To edit an item, it must first be opened.
       
   582 Changes to the item can then be committed using CommitContactL()
       
   583 (committing can only take place to an open item).
       
   584 
       
   585 If the available disk space is less than 128 kilobytes then changes to the
       
   586 contact database cannot be started, and methods such as CreateL() or CommitContactL()
       
   587 will leave with a KErrDiskFull error. Less obviously OpenL() can also fail with
       
   588 KErrDiskFull when trying to update the system template.
       
   589 
       
   590 Each item has an access count. An item cannot be fully deleted unless its
       
   591 access count is zero. This is to prevent items which have been
       
   592 synchronised with another contacts application from being deleted.
       
   593 Also, if the item is a template, it cannot be deleted if other items are based
       
   594 on it.
       
   595 
       
   596 More than one contact database can exist on a phone, but there is a
       
   597 default contact database. Its filename is contacts.cdb. It
       
   598 can be moved between drives.
       
   599 
       
   600 CContactDatabase implements searching and sorting and also provides
       
   601 separate phone number matching functions. These provide a fast way of indexing
       
   602 and looking up phone numbers, e.g. for looking up caller IDs on incoming
       
   603 calls.
       
   604 
       
   605 The database owns speed dial information. This is a mapping between a single
       
   606 digit integer and a telephone number. There may be up to 9 speed dial telephone
       
   607 numbers; each of them belongs to a contact item in the database. If a
       
   608 contact item is deleted, its speed dial mapping is removed.
       
   609 
       
   610 The following functions defined in class CContactDatabase are not
       
   611 supported. If called, they leave with KErrNotSupported.
       
   612 
       
   613 - ReplacePrefL()
       
   614 
       
   615 - ReadPrefL()
       
   616 
       
   617 - CreatePrefL()
       
   618 
       
   619 @publishedAll
       
   620 @released
       
   621 */
       
   622 	{
       
   623 	friend class TContactIter;
       
   624 	friend class CIdleFinder;
       
   625 	friend class CCntIdleSorter;
       
   626 	friend class CContactLocalView;
       
   627 	friend class CContactOpenOperation;
       
   628 	friend class RContactRemoteView;
       
   629 	friend class CViewIteratorProxyManager;
       
   630 	friend class CCollectionProxy;
       
   631 	friend class CContactActiveBase;
       
   632 public:
       
   633 	class TSortPref
       
   634 	/** Specifies the field type and order preferences used for sorting items in the
       
   635 	contacts database.
       
   636 
       
   637 	The contents of the first field in a contact item matching the field type
       
   638 	is used as the data to sort on. The order can either be ascending or descending.
       
   639 
       
   640 	@see CContactDatabase::SortL()
       
   641 	@see CContactDatabase::SortArrayL()
       
   642 	@publishedAll
       
   643 	@deprecated
       
   644 	*/
       
   645 		{
       
   646 	public:
       
   647 		/** The sort order. */
       
   648 		enum TOrder
       
   649 			{
       
   650 			/** Ascending sort order. */
       
   651 			EAsc,
       
   652 			/** Descending sort order. */
       
   653 			EDesc
       
   654 			};
       
   655 	public:
       
   656 		inline TSortPref();
       
   657 		inline TSortPref(TFieldType aFieldType,TOrder aOrder=EAsc);
       
   658 		IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   659 		IMPORT_C void InternalizeL(RReadStream& aStream);
       
   660 	public:
       
   661 		/** Specifies whether the sort should be ascending or descending. */
       
   662 		TOrder iOrder;
       
   663 		/** The first field matching this field type is used for the text to sort on. */
       
   664 		TFieldType iFieldType;
       
   665 		};
       
   666 
       
   667 	/** Import and export format flags. Contacts can be imported into
       
   668 	or exported from the contact database as vCards.
       
   669 
       
   670 	The following options are available during import and export.
       
   671 
       
   672 	@deprecated This enum is deprecated. It has been replaced by the TOptions enum in
       
   673 	the plugin convertor class CContactVCardConverter, so that each plugin converter
       
   674 	can define its own options. */
       
   675 	enum TOptions
       
   676   		{
       
   677   		EDefault=0x0000,
       
   678 		/** Handle Symbian's extended vCard format options. */
       
   679 		EIncludeX =0x0001,
       
   680 		/** Support non-standard extensions requried by Symbian PC connectivity software
       
   681 		and Microsoft, amongst others. */
       
   682   		ETTFormat =0x0002,
       
   683 		/** Don't export the contact ID (for exporting only). */
       
   684 		EExcludeUid=0x0004,
       
   685 		/** Decrease the contact's access count when importing and exporting. */
       
   686 		EDecreaseAccessCount=0x0008,
       
   687 		/** Only import the first contact in the read stream (for importing only). */
       
   688 		EImportSingleContact=0x0010,
       
   689 		/** Increase the contact's access count when importing and exporting. */
       
   690 		EIncreaseAccessCount=0x0020,
       
   691 		/** Sets a contact item to the local time when importing. */
       
   692 		ELocalTime=0x0040,
       
   693 		/** Allows you to set a template to a contact item that does not exist. */
       
   694 		ENullTemplateId=0x0080,
       
   695 		/** For use by implementor of converter plug-in. */
       
   696 		EConverterDefined1=0x0100,
       
   697 		/** For use by implementor of converter plug-in. */
       
   698 		EConverterDefined2=0x0200,
       
   699 		/** For use by implementor of converter plug-in. */
       
   700 		EConverterDefined3=0x0400,
       
   701 		/** For use by implementor of converter plug-in. */
       
   702 		EConverterDefined4=0x0800,
       
   703 		/** For use by implementor of converter plug-in. */
       
   704 		EConverterDefined5=0x1000,
       
   705 		/** For use by implementor of converter plug-in. */
       
   706 		EConverterDefined6=0x2000,
       
   707 		/** For use by implementor of converter plug-in. */
       
   708 		EConverterDefined7=0x4000,
       
   709 		/** For use by implementor of converter plug-in. */
       
   710 		EConverterDefined8=0x8000,
       
   711 		/** Reserved for use by Symbian. */
       
   712 		EConverterReserved1=0x00010000, 
       
   713 		/** Reserved for use by Symbian. */
       
   714 		EConverterReserved2=0x00020000, 
       
   715 		/** Reserved for use by Symbian. */
       
   716 		EConverterReserved3=0x00040000, 
       
   717 		/** Reserved for use by Symbian. */
       
   718 		EConverterReserved4=0x00080000, 
       
   719 		/** Reserved for use by Symbian. */
       
   720 		EConverterReserved5=0x00100000, 
       
   721 		/** Reserved for use by Symbian. */
       
   722 		EConverterReserved6=0x00200000, 
       
   723 		/** Reserved for use by Symbian. */
       
   724 		EConverterReserved7=0x00400000, 
       
   725 		/** Reserved for use by Symbian. */
       
   726 		EConverterReserved8=0x00800000, 
       
   727 		/** Reserved for use by Symbian. */
       
   728 		EConverterReserved9=0x01000000, 
       
   729 		/** Reserved for use by Symbian. */
       
   730 		EConverterReserved10=0x02000000, 
       
   731 		/** Reserved for use by Symbian. */
       
   732 		EConverterReserved11=0x04000000, 
       
   733 		/** Reserved for use by Symbian. */
       
   734 		EConverterReserved12=0x08000000, 
       
   735 		/** Reserved for use by Symbian. */
       
   736 		EConverterReserved13=0x10000000, 
       
   737 		/** Reserved for use by Symbian. */
       
   738 		EConverterReserved14=0x20000000, 
       
   739 		/** Reserved for use by Symbian. */
       
   740 		EConverterReserved15=0x40000000, 
       
   741 		/** Reserved for use by Symbian. */
       
   742 		EConverterReserved16=0x80000000 
       
   743   		};
       
   744 	/** Specifies whether the database can be accessed from single or multiple threads. */
       
   745 	enum TThreadAccess
       
   746 		{
       
   747 		/** Allows access to the contacts database from a single thread only. */
       
   748 		ESingleThread,
       
   749 		/** Allows for a multi-threaded program to access the contact database from multiple
       
   750 		threads but note that the contacts model provides no synchronisation support
       
   751 		for such use. */
       
   752 		EMultiThread
       
   753 		};
       
   754 		
       
   755 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   756 /**
       
   757 @internalComponent
       
   758 */
       
   759 	enum TSortDataSource
       
   760 		{
       
   761 		ENoOrder,
       
   762 		EUsesIdentityTableOnly,
       
   763 		EUsesAllTables,
       
   764 		EIdentityTableNotUsed //Not used
       
   765 		};
       
   766 #endif
       
   767 public:
       
   768 	IMPORT_C static CContactDatabase* OpenL(TThreadAccess aAccess=ESingleThread);
       
   769 	IMPORT_C static CContactDatabase* OpenL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);
       
   770 	IMPORT_C static CContactDatabase* CreateL(TThreadAccess aAccess=ESingleThread);
       
   771 	IMPORT_C static CContactDatabase* CreateL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);
       
   772 	IMPORT_C static CContactDatabase* ReplaceL(TThreadAccess aAccess=ESingleThread);
       
   773 	IMPORT_C static CContactDatabase* ReplaceL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);
       
   774 	// asynchronous Open
       
   775 	IMPORT_C static CContactOpenOperation* Open(TRequestStatus& aStatus, TThreadAccess aAccess=ESingleThread);
       
   776 	IMPORT_C static CContactOpenOperation* Open(const TDesC& aFileName, TRequestStatus& aStatus, TThreadAccess aAccess=ESingleThread);
       
   777 	IMPORT_C static TBool DatabaseDrive(TDriveUnit &aDriveUnit);
       
   778 	inline static TInt NullUidValue();
       
   779 	IMPORT_C static void SetDatabaseDriveL(TDriveUnit aDriveUnit, TBool aCopy=ETrue);
       
   780 	IMPORT_C static void GetDefaultNameL(TDes &aDes);
       
   781 	IMPORT_C static void DeleteDefaultFileL();
       
   782 	// database file mangement
       
   783 	IMPORT_C static void DeleteDatabaseL(const TDesC& aFileName);
       
   784 	IMPORT_C static CDesCArray* ListDatabasesL();
       
   785 	IMPORT_C static CDesCArray* ListDatabasesL(TDriveUnit aDriveUnit);
       
   786 	IMPORT_C static TBool DefaultContactDatabaseExistsL();
       
   787 	IMPORT_C static TBool ContactDatabaseExistsL(const TDesC& aFileName);
       
   788 	IMPORT_C ~CContactDatabase();
       
   789 
       
   790 	IMPORT_C void SetViewDefinitionL(CContactViewDef* aView);
       
   791 	IMPORT_C void SetTextDefinitionL(CContactTextDef* aView);
       
   792 	IMPORT_C const CContactTextDef* TextDefinition() const;
       
   793 	IMPORT_C TInt CountL();
       
   794 	IMPORT_C void SetDbViewContactType(const TUid aUid);
       
   795 	IMPORT_C TUid GetDbViewContactType() const;
       
   796 
       
   797 
       
   798 	IMPORT_C TContactItemId AddNewContactL(CContactItem& aContact);
       
   799 
       
   800 	IMPORT_C CContactItem* CreateContactGroupL(TBool aInTransaction=EFalse);
       
   801 	IMPORT_C CContactItem* CreateContactGroupLC(TBool aInTransaction=EFalse);
       
   802 	IMPORT_C CContactItem* CreateContactGroupL(const TDesC& aGroupLabel,TBool aInTransaction=EFalse);
       
   803 	IMPORT_C CContactItem* CreateContactGroupLC(const TDesC& aGroupLabel,TBool aInTransaction=EFalse);
       
   804 	IMPORT_C CContactItem* CreateContactCardTemplateL(const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
       
   805 	IMPORT_C CContactItem* CreateContactCardTemplateLC(const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
       
   806 	IMPORT_C CContactItem* CreateContactCardTemplateL(const CContactItem* aTemplate,const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
       
   807 	IMPORT_C CContactItem* CreateContactCardTemplateLC(const CContactItem* aTemplate,const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
       
   808 
       
   809 	IMPORT_C CContactIdArray* GetCardTemplateIdListL() const;
       
   810 	IMPORT_C CContactIdArray* GetGroupIdListL() const;
       
   811 	IMPORT_C void AddContactToGroupL(TContactItemId aItemId, TContactItemId aGroupId);
       
   812 	IMPORT_C void AddContactToGroupL(CContactItem& aItem, CContactItem& aGroup);
       
   813 	IMPORT_C void AddContactToGroupL(TContactItemId aItemId, TContactItemId aGroupId,TBool aInTransaction);
       
   814 	IMPORT_C void RemoveContactFromGroupL(CContactItem& aItem, CContactItem& aGroup);
       
   815 	IMPORT_C void RemoveContactFromGroupL(TContactItemId aItemId, TContactItemId aGroupId);
       
   816 	inline TInt GroupCount() const;
       
   817 	inline TInt TemplateCount() const;
       
   818 
       
   819 	// speed dial functions
       
   820 	IMPORT_C void SetFieldAsSpeedDialL(CContactItem& aItem, TInt aFieldIndex, TInt aSpeedDialPosition);
       
   821 	IMPORT_C TContactItemId GetSpeedDialFieldL(TInt aSpeedDialPosition, TDes& aPhoneNumber);
       
   822 	IMPORT_C void RemoveSpeedDialFieldL(TContactItemId aContactId, TInt aSpeedDialPosition);
       
   823 
       
   824 	// reading contacts from the db
       
   825 	IMPORT_C CContactItem* ReadMinimalContactL(TContactItemId aContactId);
       
   826 	IMPORT_C CContactItem* ReadMinimalContactLC(TContactItemId aContactId);
       
   827 	IMPORT_C CContactItem* ReadContactL(TContactItemId aContactId);
       
   828 	IMPORT_C CArrayPtr<CContactItem>* ReadContactAndAgentL(TContactItemId aContactId);
       
   829 	IMPORT_C CContactItem* ReadContactL(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
       
   830 	IMPORT_C CContactItem* ReadContactLC(TContactItemId aContactId);
       
   831 	IMPORT_C CContactItem* ReadContactLC(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
       
   832 	IMPORT_C void ReadContactTextDefL(const CContactItem &aItem, TDes &aResult);
       
   833 	IMPORT_C void ReadContactTextDefL(const CContactItem &aItem, TDes &aResult,CContactTextDef* aTextDef);
       
   834 	IMPORT_C void ReadContactTextDefL(TContactItemId aContactId, TDes &aResult);
       
   835 	IMPORT_C void ReadContactTextDefL(TContactItemId aContactId, TDes &aResult,CContactTextDef* aTextDef);
       
   836 	IMPORT_C CContactItem* OpenContactL(TContactItemId aContactId);
       
   837 	IMPORT_C CContactItem* OpenContactL(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
       
   838 	IMPORT_C CContactItem* OpenContactLX(TContactItemId aContactId);
       
   839 	IMPORT_C CContactItem* OpenContactLX(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
       
   840 	IMPORT_C void CloseContactL(TContactItemId aContactId);
       
   841 	IMPORT_C void CommitContactL(const CContactItem& aContact);
       
   842 	IMPORT_C void DeleteContactL(TContactItemId aContactId);
       
   843 	IMPORT_C void DeleteContactsL(const CContactIdArray& aContactIds);
       
   844   	IMPORT_C CArrayPtr<CContactItem>* ImportContactsL(const TUid& aFormat,RReadStream& aReadStream,TBool& aImportSuccessful,TInt aOption);
       
   845   	IMPORT_C void ExportSelectedContactsL(const TUid& aFormat,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOption,TBool aExportPrivateFields=ETrue);
       
   846   	IMPORT_C void ExportSelectedContactsL(const TUid& aFormat,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOption,const Versit::TVersitCharSet aCharSet, TBool aExportPrivateFields=ETrue);
       
   847 	IMPORT_C void CompactL();
       
   848 
       
   849 	IMPORT_C CContactIdArray* FindLC(const TDesC& aText,const CContactItemFieldDef *aFieldDef);
       
   850 	IMPORT_C CIdleFinder* FindAsyncL(const TDesC& aText,const CContactItemFieldDef *aFieldDef, MIdleFindObserver *aObserver);
       
   851 	IMPORT_C CContactIdArray* FindInTextDefLC(const MDesCArray& aFindWords, const TCallBack &aWordParserCallback);
       
   852 	IMPORT_C CContactIdArray* FindInTextDefLC(const MDesCArray& aFindWords,CContactTextDef* aTextDef, const TCallBack &aWordParserCallback);
       
   853 	IMPORT_C CIdleFinder* FindInTextDefAsyncL(const MDesCArray& aFindWords, MIdleFindObserver *aObserver, const TCallBack &aWordParserCallback);
       
   854 	IMPORT_C CIdleFinder* FindInTextDefAsyncL(const MDesCArray& aFindWords,const CContactTextDef* aTextDef, MIdleFindObserver *aObserver, const TCallBack &aWordParserCallback);
       
   855 	IMPORT_C CContactIdArray* SortArrayL(const CContactIdArray* aIdArray, const CArrayFix<TSortPref>* aSortOrder);
       
   856 	IMPORT_C CContactIdArray* SortArrayLC(const CContactIdArray* aIdArray, const CArrayFix<TSortPref>* aSortOrder);
       
   857 	IMPORT_C void SortByTypeL(CArrayFix<TSortPref>* aSortOrder);
       
   858 	IMPORT_C void SortL(CArrayFix<TSortPref>* aSortOrder);
       
   859 	IMPORT_C void SortAsyncL(CArrayFix<TSortPref>* aSortOrder, TRequestStatus& aStatus);
       
   860 	IMPORT_C void CancelAsyncSort();
       
   861 	IMPORT_C void SortAsyncL(CArrayFix<TSortPref>* aSortOrder, TRequestStatus& aStatus, MContactSortObserver& aObserver);
       
   862 
       
   863 	IMPORT_C void SetOperationTimeOutL(const TInt aMicroSeconds) const;
       
   864   	IMPORT_C TPtrC FileUid();
       
   865 	IMPORT_C CContactActiveCompress* CreateCompressorLC();
       
   866 	IMPORT_C CContactActiveRecover* CreateRecoverLC();
       
   867 	IMPORT_C void RecoverL();
       
   868 	IMPORT_C TBool IsDamaged() const;
       
   869 	IMPORT_C TBool CompressRequired();
       
   870 	IMPORT_C void CloseTables();
       
   871 	IMPORT_C void OpenTablesL();
       
   872 
       
   873 	//New Phone Matching function, takes a number as a TDesc& and will match from the right of the string
       
   874 	//by the the number defined
       
   875 	//use KBestMatchingPhoneNumbers as second parameter to enable best matching number strategy
       
   876 	IMPORT_C CContactIdArray* MatchPhoneNumberL(const TDesC& aNumber, TInt aMatchLengthFromRight);
       
   877 
       
   878 
       
   879 	IMPORT_C const CContactIdArray* SortedItemsL();
       
   880 	IMPORT_C TContactItemId TemplateId() const;
       
   881 	IMPORT_C CContactItem* CreateOwnCardLC();
       
   882 	IMPORT_C CContactItem* CreateOwnCardL();
       
   883 	IMPORT_C TContactItemId OwnCardId() const;
       
   884 	IMPORT_C void SetOwnCardL(const CContactItem& aContact);
       
   885 
       
   886 //	Preferred Template
       
   887 	IMPORT_C TContactItemId PrefTemplateId() const;
       
   888 	IMPORT_C void SetPrefTemplateL(const CContactItem& aContact);
       
   889 
       
   890 //	Current item
       
   891 	IMPORT_C void SetCurrentItem(const TContactItemId aContactId);
       
   892 	IMPORT_C TContactItemId GetCurrentItem() const;
       
   893 
       
   894 //	Connectivity
       
   895 	IMPORT_C void SetDateFormatTextL(const TDesC& aFormat);
       
   896 	IMPORT_C void FilterDatabaseL(CCntFilter& aFilter);
       
   897 	IMPORT_C CContactIdArray* ContactsChangedSinceL(const TTime& aTime);
       
   898 	IMPORT_C TContactSyncId SetLastSyncDateL(const TTime& aSyncDate);
       
   899 	IMPORT_C void SetLastSyncDateL(TContactSyncId aSyncId, const TTime& aSyncDate);
       
   900 	IMPORT_C void GetLastSyncDateL(TContactSyncId aSyncId, TTime& aSyncDate);
       
   901 
       
   902 	IMPORT_C TInt FileSize() const;
       
   903 	IMPORT_C TInt WastedSpaceInBytes() const;
       
   904 	IMPORT_C TUint ConnectionId() const;
       
   905 	IMPORT_C const CContentType &TemplateContentType(const CContactItemField &aField) const;
       
   906 	IMPORT_C TVersion Version() const;
       
   907 	IMPORT_C TInt64 MachineId() const;
       
   908 	IMPORT_C TContactItemId ICCTemplateIdL();
       
   909 	IMPORT_C TContactItemId ICCTemplateIdL(TUid aPhonebookUid);
       
   910 	IMPORT_C TContactItemId PhonebookGroupIdL();
       
   911 
       
   912 public:	// For test code only
       
   913 	IMPORT_C void DamageDatabaseL(TInt aSecretCode);	// Don't use this, you don't really want to damage your database do you?
       
   914 	IMPORT_C void OverrideMachineUniqueId(TInt64 aMachineUniqueId);
       
   915 	IMPORT_C TInt CntServerResourceCount();
       
   916 	IMPORT_C void SetCntServerHeapFailure(TInt aTAllocFailType,TInt aRate);
       
   917 	IMPORT_C CContactIdArray* DeletedContactsLC();
       
   918 	IMPORT_C void ResetServerSpeedDialsL();
       
   919 
       
   920 public:	// For cnt server only
       
   921 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
       
   922 			 void HandleDatabaseEventL(RDbNotifier::TEvent) {};
       
   923 #endif
       
   924 	IMPORT_C void HandleDatabaseEventL(const TContactDbObserverEvent &aEvent);
       
   925 	IMPORT_C TInt GetCurrentDatabase(TDes& aDatabase) const;
       
   926 	IMPORT_C TInt SetCurrentDatabase(const TDesC& aDatabase) const;
       
   927 
       
   928 	IMPORT_C void StoreSortOrderL();
       
   929 	IMPORT_C void RestoreSortOrderL();
       
   930 	IMPORT_C const CArrayFix<TSortPref>* SortOrder() const;
       
   931 	//Contact Hint Field Access
       
   932 
       
   933 	/** Contact view filter flags.
       
   934 
       
   935 	These flags define the bits that can be set in filtered views (CContactFilteredView)
       
   936 	and in the filter passed to CContactDatabase::ContactMatchesHintFieldL() for
       
   937 	comparing against contact view items (CViewContact).
       
   938 
       
   939 	If the item's bit field and the view's filter have the same settings for the
       
   940 	CContactDatabase::EHome and CContactDatabase::EWork flags and any of the other
       
   941 	flags are set in both, a match occurs and the item is included in the view.
       
   942 
       
   943 	Filters only apply to non-hidden contact fields with content. */
       
   944 	enum TContactViewFilter
       
   945 		{
       
   946 		/** The view is unfiltered; it includes all contact items. */
       
   947 		EUnfiltered	=0x00000000,
       
   948 		/** The filter includes items that have an email address. */
       
   949 		EMailable	=0x00000001,
       
   950 		/** The filter includes items that have a mobile telephone number. */
       
   951 		ESmsable	=0x00000002,
       
   952 		/** The filter includes items that have a landline telephone number. */
       
   953 		ELandLine	=0x00000004,
       
   954 		/** The filter includes items that have a fax number. */
       
   955 		EFaxable	=0x00000008,
       
   956 		/** The filter includes items that are phonable. (All items with any of the above
       
   957 		three flags set also have this flag set). */
       
   958 		EPhonable   =0x00000010,
       
   959 		/** The filter excludes items without a work telephone number or email address. */
       
   960 		EWork		=0x00000020,
       
   961 		/** The filter excludes items without a home telephone number or email address. */
       
   962 		EHome		=0x00000040,
       
   963 		/** The filter includes items that have a non-empty ring tone field (a ring tone
       
   964 		that is associated with the  item). */
       
   965 		ERingTone	=0x00000080,
       
   966 		/** The filter includes items that have a non-empty voice dial field (a voice
       
   967 		recording associated with a telephone number field in the  item). */
       
   968 		EVoiceDial	=0x00000100,
       
   969 		/** The filter includes items that have any non empty instant messaging address field. */
       
   970 		EIMAddress  =0x00000200,
       
   971 		/** The filter includes items that have a non empty Wireless Village ID field.
       
   972 		An item with this flag set will also have the EIMAddress flag set. */
       
   973 		EWirelessVillage = 0x00000400,
       
   974 		/** Reserved filters for future use. */
       
   975 		ECustomFilter1	 = 0x00000800,
       
   976 		/** Reserved filters for future use. */
       
   977 		ECustomFilter2	 = 0x00001000,
       
   978 		/** Reserved filters for future use. */
       
   979 		ECustomFilter3	 = 0x00002000,
       
   980 		/** Reserved filters for future use. */
       
   981 		ECustomFilter4	 = 0x00004000
       
   982 		};
       
   983 
       
   984 	IMPORT_C TBool ContactMatchesHintFieldL(TInt aBitWiseFilter,TContactItemId aContactId);
       
   985 public: // for vCard converter only
       
   986 	IMPORT_C void DatabaseBeginLC(TBool aIsInTransaction);
       
   987 	IMPORT_C void DatabaseCommitLP(TBool aIsInTransaction);
       
   988   	IMPORT_C CContactItem *UpdateContactLC(TContactItemId aContactId,CContactItem* aNewContact);
       
   989 	IMPORT_C TContactItemId doAddNewContactL(CContactItem& aContact,TBool aIsTemplate,TBool aIsInTransaction);
       
   990 	IMPORT_C void doCommitContactL(const CContactItem& aContact,TBool aIsInTransaction, TBool aSendChangedEvent);
       
   991 	IMPORT_C TContactItemId ContactIdByGuidL(const TDesC& aGuid);
       
   992 	IMPORT_C void doDeleteContactL(TContactItemId aContactId, TBool aIsInTransaction, TBool aSendChangedEvent, TBool aDecAccessCount=EFalse);
       
   993 	IMPORT_C CContactItemViewDef* AllFieldsView();
       
   994 public: // For Symbian use only
       
   995 	IMPORT_C void DatabaseBeginL(TBool aIsInTransaction);
       
   996 	IMPORT_C void DatabaseCommitL(TBool aIsInTransaction);
       
   997 	IMPORT_C void DatabaseRollback();
       
   998 	IMPORT_C void SetSortedItemsList(CContactIdArray* aSortedItems, CArrayFix<TSortPref>* aSortOrder);
       
   999 	IMPORT_C CContactIdArray* UnfiledContactsL();
       
  1000 	IMPORT_C static void RecreateSystemTemplateL(const TDesC& aFileName);
       
  1001 public:	// For Contacts Lock Server use only
       
  1002 	IMPORT_C static CContactDatabase* LockServerConnectL(const TDesC& aFileName);
       
  1003 	IMPORT_C static CContactDatabase* LockServerConnectL(const TDesC& aFileName, TInt aOperation);
       
  1004 	IMPORT_C TInt LockServerCallBackL(TUint aServerOperation);
       
  1005 	IMPORT_C void LockServerCleanup();
       
  1006 public:
       
  1007 	IMPORT_C void ExportSelectedContactsL(const TUid& aFormat, const CContactIdArray& aSelectedContactIds, RWriteStream& aWriteStream, TInt aOption, const TInt64 aContactFieldFilter, MConverterCallBack* aCallback, const TVCardVersion aVersion, const TBool aExportTel, Versit::TVersitCharSet aCharSet = Versit::EUTF8CharSet, TBool aExportPrivateFields = ETrue);
       
  1008 private:
       
  1009 	//for cntiter
       
  1010 	TInt ContactPosL(TContactItemId aContactId); 
       
  1011 	TInt DoGotoL(TContactItemId aContactId);
       
  1012 	
       
  1013 	void DoReadContactTextDefL(const CContactItemFieldSet* aFieldSet,TDes& aResult,CContactTextDef* aTextDef);
       
  1014 	CContactItem* OpenNoMergeLCX(TContactItemId aContactId);
       
  1015 
       
  1016 	void FetchGroupAndTemplateListsL();
       
  1017 
       
  1018 public:
       
  1019 	void CancelNotifyRequestL();
       
  1020 	TBool IsICCSynchronisedL();
       
  1021 
       
  1022 	//for LocalView
       
  1023 	void AddObserverL(MContactDbObserver& aChangeNotifier);
       
  1024 	void RemoveObserver(const MContactDbObserver& aChangeNotifier);
       
  1025 
       
  1026 	void OpenDatabaseAsyncL(TRequestStatus& aStatus, const TDesC& aFileName = KNullDesC);
       
  1027 	static void CleanupLastLockedContact(TAny *aDatabase);
       
  1028 
       
  1029 private:
       
  1030 	CContactConverter& ConverterL(const TUid& aFormat);
       
  1031 	CContactConverter& ConverterL(const TUid& aFormat, const TInt64 aContactFieldFilter, MConverterCallBack* aCallback, const TVCardVersion aVersion,const TBool aExportTel);
       
  1032 	static void CleanupDatabaseRollback(TAny *aDatabase);
       
  1033 
       
  1034 	CContactIdArray* SortLC(const CArrayFix<TSortPref>* aSortOrder, const CContactIdArray* aIdArray);
       
  1035 	TBool CheckType(TUid aUid) const;
       
  1036 	void SortDuplicatesL(const CArrayFix<TSortPref>& aSortOrder,CSortArray& aList,TInt aPos);
       
  1037 	void SortDuplicatesL(const CArrayFix<TSortPref>& aSortOrder,CSortArray& aList,
       
  1038 								TInt aIndex,TInt aStartPos,TInt aEndPos);
       
  1039 	TBool AddContactToSortListL(TContactItemId aReqId, TContactItemId& aActualId,CBase* aItems, TUid& aFieldType, TBool aHasSortOrder);
       
  1040 	void RemoveFromSortArray(TContactItemId aContactId);
       
  1041 	void HandleDbObserverEventGroupDeletedL(const TContactItemId aContactId);
       
  1042 	void RemoveFromGroupIds(const TContactItemId aContactId);
       
  1043 
       
  1044 public:
       
  1045 	static void CleanupTableCancel(TAny *aTable);
       
  1046 /** A text buffer of KTextFieldMinimalLength used during sorting and searching of contacts  */
       
  1047 	typedef TBuf<KTextFieldMinimalLength> TTextFieldMinimal;
       
  1048 	static TUid SpeedDialFieldUidFromSpeedDialPosition(TInt aSpeedDialPosition);
       
  1049 	void HandleDiskSpaceEvent(TInt aDrive);
       
  1050 
       
  1051 	/** State of database connection
       
  1052 	*/
       
  1053 	enum TDbConnState
       
  1054 		{
       
  1055 		/** Database is open, connection is available for use. */
       
  1056 		EDbConnectionOpen = 0,
       
  1057 		/** Initial state. */
       
  1058 		EDbConnectionNotReady,
       
  1059 		/** Asynchronous Open failed. */
       
  1060 		EDbConnectionFailed,
       
  1061 		/** A Rollback has occurred and a Recover is required now. */
       
  1062 		EDbConnectionRecoverRequired,
       
  1063 		/** Write access is locked during backup. */
       
  1064 		EDbConnectionWriteLockedForBackup,
       
  1065 		/** The database has been closed whilst a Restore is in progress. */
       
  1066 		EDbConnectionClosedForRestore,
       
  1067 		/** Restore is in progress need to close after current transaction. */
       
  1068 		EDbConnectionNeedToCloseForRestore,
       
  1069 		};
       
  1070 	/** Currently unused    */
       
  1071 	enum TDirection {EAsc,EDesc}; //unused
       
  1072 	void SetDbConnectionState(TDbConnState aDbConnectionState);
       
  1073 private:
       
  1074 	void CheckDbConnForWriteL() const;
       
  1075 	void CheckDbConnForReadL() const;
       
  1076 	void CheckDbConnForRecoverL() const;
       
  1077 	void CheckTemplateField(CContactItem& aCnt);
       
  1078 	static void ValidateDatabaseNameL(const TParse& aParseName);
       
  1079 	void StartAsyncActivityL();
       
  1080 	void EndAsyncActivityL();
       
  1081 	TBool DatabaseReadyL() const;
       
  1082 	enum TSvrSessionType //unused
       
  1083 		{  
       
  1084 		// Server Session is persistent, for Open(L), CreateL or ReplaceL
       
  1085 		ESvrSessionPersistent,
       
  1086 		// Server Session is temporary, for a simple static API
       
  1087 		ESvrSessionTemporary,
       
  1088 		// Session is from the Contacts Lock Server
       
  1089 		ESvrSessionFromLockServer,
       
  1090 		};
       
  1091 private: // objec construction/destruction
       
  1092 
       
  1093 	CContactDatabase();
       
  1094 	static CContactDatabase* NewLC();
       
  1095 	void ConstructL();
       
  1096 	void CreateViewDefL();
       
  1097 	MLplPersistenceLayerFactory* FactoryL();
       
  1098 
       
  1099 private:
       
  1100 	CContactItem* doCreateContactGroupLC(const TDesC& aGroupLabel = KNullDesC);
       
  1101 	void AddCntToOpenedGroupL(TContactItemId aItemId, CContactItem& aGroup);
       
  1102 	void ReadTemplateIdsL();
       
  1103 	void AddToTemplateListL(const TContactItemId aNewTemplateId);
       
  1104 	void RemoveFromTemplateList(const TContactItemId aOldTemplateId);
       
  1105 	TBool SystemTemplateFieldsValid(const CContactItem& aContact);
       
  1106 	void RespondToEventL(const TContactDbObserverEventType aEventType, const TContactItemId aContactId);
       
  1107 	void HandleDbObserverEventGroupOrContactChangedL(const TContactItemId aContactId);
       
  1108 	void HandleDbObserverEventGroupOrContactAddedL(const TContactDbObserverEventType aEventType, const TContactItemId aContactId);
       
  1109    	TBool CheckSortError(TInt aError);
       
  1110    	TInt NextExistingL(TInt aIndex);
       
  1111    	TInt PreviousExistingL(TInt aIndex);
       
  1112    	void ReSortL(CArrayFix<TSortPref>* aSortOrder);
       
  1113    	void InsertInSortArray(const CContactItem& aContact);
       
  1114    	void MoveInSortArray(const CContactItem& aContact);
       
  1115    	void InsertInSortArrayL(const CContactItem& aContact);
       
  1116    	void MoveInSortArrayL(const CContactItem& aContact);
       
  1117 	TInt NewSortIndexL(const CContactItem& aContact,TInt aStartPos,TInt aEndPos);
       
  1118 	TInt CompareSortFieldsL(const CContactItem& aContact);
       
  1119    	void ConstructTableUsageFlagsFromSortOrderL(TInt& aFlags);
       
  1120    	void LoadSyncPluginL();
       
  1121    	void DeleteContactSendEventActionL(TContactItemId aContactId, TCntSendEventAction aActionType);
       
  1122 
       
  1123 private:
       
  1124 	// Member variables
       
  1125 	RCntModel*					iCntSvr;			//was RDbNamedDatabase iDatabase;
       
  1126 	CProxyFactory*				iProxyFactory;		//was RDbs iDbsSession;
       
  1127 	TDbConnState				iDbConnectionState;	//was CContactClientSession* iContactClientSession;
       
  1128 	CDataBaseChangeObserver*	iDataBaseObserver;	//was CPrivateDbChangeNotifier* iDbChangeNotifier;
       
  1129 	CCntIdleSorter*				iIdleSorter;		//was CPrivateSvrSessionManager* iServerSessionManager;
       
  1130 	CPrivConverter*				iConv;				//was TContactItemId iLastLockedContactId;
       
  1131 	TBool						iTablesOpen;		//was TContactItemId iTemplateId;
       
  1132 	CContactItemViewDef*		iAllFieldsView;		//was TContactItemId iOwnCardId;
       
  1133 	TUid						iDbViewContactType;	//used to select which contact type to sort / search on
       
  1134 	
       
  1135 	//These two members are accessed via the inline functions!
       
  1136 	CContactIdArray* iCardTemplateIds;
       
  1137 	CContactIdArray* iGroupIds;
       
  1138 
       
  1139 	CCntTemplateCache* iTemplateCache; //was CContactTables* iItemTable;
       
  1140 	CContactTextDef* iTextDef;		//remains
       
  1141 	CContactIdArray* iSortedItems;	//remains
       
  1142 	CContactViewDef* iView;			//remains
       
  1143 	
       
  1144 	// Used in SetLastSyncDateL() and GetLastSyncDateL()
       
  1145 	TTime iSyncDate;	//was TInt64 iMachineUniqueId;
       
  1146 	TCollationMethod iCollateMethod; //remains: used for sorting contacts
       
  1147 
       
  1148 	TInt iAsyncActivityCount;
       
  1149 	CContactSynchroniser* iContactSynchroniser; //a handle to the synchroniser plugin
       
  1150 	CArrayFix<TSortPref>* iSortOrder;	// holds a sort order passed into SortL(), as in cntmodelv1, 
       
  1151 										// for delayed deletion to maintain backwards compatibility
       
  1152 	};
       
  1153 
       
  1154 
       
  1155 class CContactChangeNotifier : public CBase
       
  1156 /** Receives events reporting changes to a contact database.
       
  1157 
       
  1158 After the change notifier has been created, it notifies the specified
       
  1159 observer whenever a change takes place to the database.
       
  1160 
       
  1161 @publishedAll
       
  1162 @released
       
  1163 */
       
  1164 	{
       
  1165 public:
       
  1166 	IMPORT_C ~CContactChangeNotifier();
       
  1167 	IMPORT_C static CContactChangeNotifier* NewL(CContactDatabase& aDatabase, MContactDbObserver *aObserver);
       
  1168 private:
       
  1169 	CContactChangeNotifier(CContactDatabase& aDatabase, MContactDbObserver *aObserver);
       
  1170 	void ConstructL();
       
  1171 private:
       
  1172 	CContactDatabase &iDatabase;
       
  1173 	MContactDbObserver* iObserver;
       
  1174 	};
       
  1175 
       
  1176 
       
  1177 /** The UID of the default vCard converter implemented by an ECom plugin.
       
  1178 @publishedAll
       
  1179 @released
       
  1180 */
       
  1181 #define KUidEComCntVCardConverterDefaultImplementation  0x102035F9
       
  1182 /** The UID of the default vCard converter plugin implementation. This
       
  1183 implementation is independent of the plugin framework used. 
       
  1184 @publishedAll
       
  1185 @released
       
  1186 */
       
  1187 #define KUidVCardConvDefaultImpl 	KUidEComCntVCardConverterDefaultImplementation
       
  1188 
       
  1189 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
  1190 
       
  1191 /** The UID of the vCard converter ECom plugin interface. 
       
  1192 @released
       
  1193 @internalTechnology
       
  1194 */
       
  1195 const TUid KUidEcomCntVCardConverterInterface = {0x102035F7};
       
  1196 
       
  1197 /** The UID of the phone number parser ECom plugin interface. 
       
  1198 @released
       
  1199 @internalTechnology
       
  1200 */
       
  1201 const TUid KUidEcomCntPhoneNumberParserInterface = {0x102035FA};
       
  1202 
       
  1203 /** The UID of PBAP vCard Converter plugin Implementation.
       
  1204 @internalTechnology
       
  1205 @released
       
  1206 */
       
  1207 #define KUidPBAPVCardConvImpl 0xA00015C1
       
  1208 
       
  1209 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
  1210 
       
  1211 class TPluginParameters
       
  1212 /**
       
  1213 Class used to pack the extra arguments required for a PBAP conveter,
       
  1214 PBAP client provides these arguments using overloaded CContactDatabase::ExportSelectedContacts.
       
  1215 @publishedAll
       
  1216 @released
       
  1217 */
       
  1218 {
       
  1219 public:
       
  1220 	TPluginParameters(TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel);
       
  1221 	TInt64 GetFilter()const;
       
  1222 	MConverterCallBack* GetCallback()const;
       
  1223 	TVCardVersion GetExportVersion()const;
       
  1224 	TBool IsExportTel()const;
       
  1225 private:
       
  1226 	TInt64 iFilter;
       
  1227 	MConverterCallBack* iCallback;
       
  1228 	TVCardVersion iVersion;
       
  1229 	TBool iExportTel;
       
  1230 };
       
  1231 
       
  1232 inline TBool TPluginParameters::IsExportTel()const
       
  1233 	{
       
  1234 	return iExportTel;
       
  1235 	}
       
  1236 inline TInt64 TPluginParameters::GetFilter()const
       
  1237 	{
       
  1238 	return iFilter;
       
  1239 	}
       
  1240 
       
  1241 inline MConverterCallBack* TPluginParameters::GetCallback()const
       
  1242 	{
       
  1243 	return iCallback;
       
  1244 	}
       
  1245 
       
  1246 inline TVCardVersion TPluginParameters::GetExportVersion()const
       
  1247 	{
       
  1248 	return iVersion;
       
  1249 	}
       
  1250 
       
  1251 inline	TPluginParameters::TPluginParameters(TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel):iFilter(aContactFieldFilter), iCallback(aCallback), iVersion(aVersion), iExportTel(aExportTel)
       
  1252 	{
       
  1253 	}
       
  1254 
       
  1255 class CContactConverter : public CBase
       
  1256 /** Provides functionality to import and export vCards.
       
  1257 One or more vCards can be imported from a read stream (the vCards are converted 
       
  1258 into contact items and added to the database). Also, contact items can be exported as vCards.
       
  1259 @publishedAll
       
  1260 @released
       
  1261 */
       
  1262 	{
       
  1263 public:
       
  1264 	virtual CArrayPtr<CContactItem>*  ImportL(CContactDatabase& aDb,RReadStream& aReadStream,TBool& aImportSuccessful,TInt aOptions,TBool aImportSingle)=0;
       
  1265 	virtual void ExportL(CContactDatabase& aDb,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOptions,const Versit::TVersitCharSet aCharSet,TBool aExportPrivateFields, TInt aCommitNumber=10)=0;
       
  1266 	};
       
  1267 
       
  1268 
       
  1269 class CContactEcomConverter : public CContactConverter
       
  1270 /**
       
  1271 It provides Ecom Framework based facilities to resolve and load the appropriate implementations at run-time.
       
  1272 The framework supplies a default resolver for selecting appropriate implementations.
       
  1273 @publishedAll
       
  1274 @released
       
  1275 */
       
  1276 	{
       
  1277 public:
       
  1278 	static CContactEcomConverter* NewL(TUid aImplementationUid);
       
  1279 	static CContactEcomConverter* NewL(TUid aImplementationUid, TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel);
       
  1280 	inline virtual ~CContactEcomConverter();
       
  1281 private:
       
  1282 	TUid iDtor_ID_Key;
       
  1283 	};
       
  1284 
       
  1285 inline CContactEcomConverter* CContactEcomConverter::NewL(TUid aImplementationUid)
       
  1286 /** Allocates and instantiates an interface implementation to satisfy the specified interface.
       
  1287 @param aImplementationUid Denotes the type of implemetation that needs to be loaded.
       
  1288 @return A pointer to a newly allocated and initialised object of type CContactEcomConverter.   */
       
  1289 	
       
  1290 {
       
  1291 	TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
       
  1292 													_FOFF(CContactEcomConverter,
       
  1293 														  iDtor_ID_Key));
       
  1294 	return reinterpret_cast<CContactEcomConverter*>(ptr);
       
  1295 }
       
  1296 
       
  1297 inline CContactEcomConverter* CContactEcomConverter::NewL(TUid aImplementationUid, TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel)
       
  1298 /** Allocates and instantiates an interface implementation for PBAP export.
       
  1299 @param aImplementationUid Denotes the type of implemetation that needs to be loaded.
       
  1300 @param aContactFieldFilter Specifies contact fields to be exported.
       
  1301 @param aCallback Callback to client for providing intra-contact properties.
       
  1302 @param aVersion Denotes the vCard version for contact export.
       
  1303 @return A pointer to a newly allocated and initialised object of type CContactEcomConverter.   */
       
  1304 	
       
  1305 {	
       
  1306 	TPluginParameters partr(aContactFieldFilter,aCallback,aVersion,aExportTel);
       
  1307 	
       
  1308 	TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
       
  1309 													_FOFF(CContactEcomConverter,
       
  1310 													  iDtor_ID_Key), &partr);
       
  1311 	return reinterpret_cast<CContactEcomConverter*>(ptr);
       
  1312 }
       
  1313 
       
  1314 inline CContactEcomConverter::~CContactEcomConverter()
       
  1315 /** The destruction of the interface implementation referred to by iDtor_ID_Key */
       
  1316 	{
       
  1317 	REComSession::DestroyedImplementation(iDtor_ID_Key);
       
  1318 	}
       
  1319 
       
  1320 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
  1321 class CContactPhoneNumberParser : public CBase
       
  1322 /** Provides functionality to extract the real phone number from a contact's phone number field.
       
  1323 @publishedPartner
       
  1324 @released
       
  1325 */
       
  1326 	{
       
  1327 public:
       
  1328 	virtual void ExtractRawNumber(const TDesC& aTextualNumber, TDes& aRawNumber)=0;
       
  1329 	};
       
  1330 
       
  1331 
       
  1332 class CContactEcomPhoneNumberParser : public CContactPhoneNumberParser
       
  1333 /** It provides Ecom Framework based facilities to resolve and load the appropriate implementations at run-time.
       
  1334 The framework supplies a default resolver for selecting appropriate implementations.
       
  1335 @publishedPartner
       
  1336 @released
       
  1337 */
       
  1338 	{
       
  1339 public:
       
  1340 	static CContactEcomPhoneNumberParser* NewL(TUid aImplementationUid);
       
  1341 	inline virtual ~CContactEcomPhoneNumberParser();
       
  1342 private:
       
  1343 	TUid iDtor_ID_Key;
       
  1344 	};
       
  1345 
       
  1346 inline CContactEcomPhoneNumberParser* CContactEcomPhoneNumberParser::NewL(TUid aImplementationUid)
       
  1347 /** Allocates and Instantiates an interface implementation to satisfy the specified interface. 
       
  1348 @param aImplementationUid denotes the type of implemetation that need to be loaded.
       
  1349 @return A pointer to a newly allocated and initialised object of type CContactEcomPhoneNumberParser.   */
       
  1350 	{
       
  1351 	TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
       
  1352 													_FOFF(CContactEcomPhoneNumberParser,
       
  1353 														  iDtor_ID_Key));
       
  1354 	return reinterpret_cast<CContactEcomPhoneNumberParser*>(ptr);
       
  1355 	}
       
  1356 
       
  1357 inline CContactEcomPhoneNumberParser::~CContactEcomPhoneNumberParser()
       
  1358 /** The destruction of the interface implementation referred to by iDtor_ID_Key */
       
  1359 	{
       
  1360 	REComSession::DestroyedImplementation(iDtor_ID_Key);
       
  1361 	}
       
  1362 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
  1363 
       
  1364 inline TInt CContactDatabase::TemplateCount() const
       
  1365 /** Gets the number of contact card templates that exist in the database.
       
  1366 This does not include the system template.
       
  1367 @deprecated
       
  1368 @return The number of contact card templates that exist in the database. */
       
  1369 	{ return iCardTemplateIds->Count(); }
       
  1370 
       
  1371 inline TInt CContactDatabase::GroupCount() const
       
  1372 /** Gets the number of groups that exist in the database.
       
  1373 @deprecated
       
  1374 @return The number of groups that exist in the database. */
       
  1375 	{ return iGroupIds->Count(); }
       
  1376 
       
  1377 inline TInt CContactDatabase::NullUidValue()
       
  1378 /** Gets the NULL contact ID value.
       
  1379 
       
  1380 @return KNullContactId. */
       
  1381 	{ return KNullContactId; }
       
  1382 
       
  1383 inline TUid CContactItemViewDef::operator[](TInt aIndex) const
       
  1384 /** Gets the field type located at a specified index position within the field type array.
       
  1385 
       
  1386 @param aIndex The position of the field type in the array, relative to zero. It
       
  1387 must be non-negative and less than the number of objects in the array otherwise the
       
  1388 function raises a panic.
       
  1389 @return The field type located at index aIndex within the array (this is equivalent to a
       
  1390 TFieldType). */
       
  1391     { return iFieldTypes[aIndex]; }
       
  1392 
       
  1393 inline TInt CContactItemViewDef::Count() const
       
  1394 /** Gets the number of field types in the view definition.
       
  1395 
       
  1396 @return The number of field types in the view definition. */
       
  1397     { return iFieldTypes.Count(); }
       
  1398 
       
  1399 inline void CContactItemViewDef::Reset()
       
  1400 /** Deletes all field types from the view definition's field type array. */
       
  1401     { iFieldTypes.Reset(); }
       
  1402 
       
  1403 inline CContactItemViewDef::TUse CContactItemViewDef::Use() const
       
  1404 /** Gets the view definition's use.
       
  1405 
       
  1406 @return The current TUse setting. */
       
  1407 	{ return iUse; }
       
  1408 
       
  1409 inline void CContactItemViewDef::SetUse(CContactItemViewDef::TUse aUse)
       
  1410 /** Sets the view definition's use.
       
  1411 
       
  1412 @param aUse The new TUse setting. */
       
  1413 	{ iUse=aUse; }
       
  1414 
       
  1415 inline CContactItemViewDef::TMode CContactItemViewDef::Mode() const
       
  1416 /** Gets the view definition's mode.
       
  1417 
       
  1418 @return The current TMode setting. */
       
  1419 	{ return iMode; }
       
  1420 
       
  1421 inline void CContactItemViewDef::SetMode(CContactItemViewDef::TMode aMode)
       
  1422 /** Sets the view definition's mode.
       
  1423 
       
  1424 @param aMode The new TMode setting. */
       
  1425 	{ iMode=aMode; }
       
  1426 
       
  1427 inline CContactDatabase::TSortPref::TSortPref()
       
  1428 	: iOrder(EAsc), iFieldType(KNullUid)
       
  1429 /** Constructs a TSortPref object. The order is initialised to EAsc and the field
       
  1430 type to KNullUid.
       
  1431 @deprecated
       
  1432 */
       
  1433 	{}
       
  1434 
       
  1435 inline CContactDatabase::TSortPref::TSortPref(TFieldType aFieldType,TOrder aOrder)
       
  1436 	: iOrder(aOrder), iFieldType(aFieldType)
       
  1437 /** Constructs the TSortPref object with a field type and an order.
       
  1438 @param aFieldType Specifies the field type to sort on.
       
  1439 @param aOrder Specifies the sort order.
       
  1440 @deprecated
       
  1441 */
       
  1442 	{}
       
  1443 
       
  1444 
       
  1445 /** A class that manages the asynchronous open operation for a CContactDatabase.
       
  1446 
       
  1447 The object can be deleted before the asynchronous open completes. This will set
       
  1448 the state of the client supplied TRequestStatus to KErrCancel.
       
  1449 
       
  1450 When the client supplied TRequestStatus is completed with KErrNone the TakeDatabase()
       
  1451 method is called to pass ownership of the open database to the client.
       
  1452 
       
  1453 @publishedAll
       
  1454 @released
       
  1455 
       
  1456 @see CContactDatabase::OpenL()
       
  1457 */
       
  1458 class CContactOpenOperation : private CActive
       
  1459 	{
       
  1460 public:
       
  1461 	IMPORT_C CContactDatabase* TakeDatabase();
       
  1462 	IMPORT_C ~CContactOpenOperation();
       
  1463 
       
  1464 	static CContactOpenOperation* NewL(TRequestStatus& aPtrStatus);
       
  1465 	static CContactOpenOperation* NewL(const TDesC& aFileName, TRequestStatus& aPtrStatus);
       
  1466 
       
  1467 private:
       
  1468 	// from CActive (for BC reasons)
       
  1469 	void RunL();
       
  1470 	TInt RunError(TInt aError);
       
  1471 	void DoCancel();
       
  1472 
       
  1473 	CContactOpenOperation (TRequestStatus& aClientStatus);
       
  1474 	void ConstructL		  (const TDesC& aFileName = KNullDesC);
       
  1475 
       
  1476 private:
       
  1477 	TRequestStatus*  	iClientStatus;
       
  1478 	CContactDatabase*	iContactDatabase;
       
  1479 	};
       
  1480 
       
  1481 
       
  1482 #endif //__CNTDB_H__