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