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