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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
29 #include <ecom/ecom.h>
33 class CContactViewDef;
35 class CContactTextDef;
37 class CContactItemViewDef;
38 class CContactItemFieldSet;
39 class CContactItemFieldDef;
40 class CContactActiveCompress;
41 class CContactActiveRecover;
42 class CContactDatabase;
46 class CContactItemField;
48 class CContactClientSession;
52 class CCntTemplateCache;
55 class MLplPersistenceLayerFactory;
56 class CContactOpenOperation;
57 class CDataBaseChangeObserver;
58 class CContactConverter;
61 const TInt KMaxContactTextSeperator=4;
62 const TInt KTextFieldMinimalLength=64;
63 const TInt KMaxCustomFilterableFields=4;
65 const TInt KMajorVersion=1;
66 const TInt KMinorVersion=0;
67 const TInt KBuildNumber=40;
71 // Classes used for compact
74 class MContactStorageObserver
76 Mixin used to observe low disk events
83 virtual void HandleDiskSpaceEvent(TInt aDrive) = 0;
86 class MContactUiCompactObserver
87 /** Mixin used to observe contact database compaction status
93 virtual void Step(TInt aStep)=0;
94 virtual void HandleError(TInt aError)=0;
97 class MContactUiActive
98 /** Mixin used to register the observer.
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;
110 IMPORT_C virtual void MContactUiActive_Reserved1();
113 class CContactActiveBase : public CBase, public MContactUiActive
119 ~CContactActiveBase();
120 void SetObserver(MContactUiCompactObserver *aObserver);
122 TInt StepsTogo() const;
125 void SetContactDatabase(CContactDatabase* aContactDatabase);
126 void SetFileManager(RCntModel& aCntSvr);
128 #ifndef __SYMBIAN_CNTMODEL_USE_SQLITE__
131 static TInt CompactCallBack(TAny *aThis);
133 MContactUiCompactObserver *iObserver;
138 CContactDatabase* iContactDatabase;
142 class CContactActiveCompress : public CContactActiveBase
149 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
150 void ConstructL(RDbNamedDatabase /* &aDataBase */) {};
154 class CContactActiveRecover : public CContactActiveBase
161 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
162 void ConstructL(RDbNamedDatabase /* &aDataBase */) {};
169 class TContactTextDefItem
170 /** An item in a text definition.
172 A TContactTextDefItem has a field type and an optional separator string
173 with a maximum length of 4 characters.
181 IMPORT_C TContactTextDefItem();
182 IMPORT_C TContactTextDefItem(TFieldType aFieldType);
183 IMPORT_C TContactTextDefItem(TFieldType aFieldType, const TDesC &aSeperator);
185 /** The field type. */
186 TFieldType iFieldType;
187 /** The string used to separate the fields in the text definition. */
188 TBuf<KMaxContactTextSeperator> iSeperator;
191 class CContactTextDef : public CArrayFixFlat<TContactTextDefItem>
192 /** Defines a way of grouping fields to form a string which represents
195 A text definition is implemented as an array of text definition items
196 (TContactTextDefItems).
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.
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.
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.
217 CContactTextDef is derived from CArrayFixFlat<TContactTextDefItem>, so all
218 relevant functions can be used, e.g. to add and remove elements.
224 friend class CContactDatabase;
225 friend class CContactTables;
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);
238 TFieldType iFallbackFieldType;
239 TBool iExactMatchOnly;//Default to EFalse cause ReadInTextDef to only match the chosen fields and not attempt a matchall
242 class CContactItemViewDef : public CBase
243 /** A view definition for a contact item.
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().
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.
260 /** Include or exclude specified fields. */
263 /** Include specified fields in the view. */
265 /** Exclude specified fields from the view. */
268 /** Include or exclude hidden fields.*/
271 /** Include hidden fields in the view. */
272 EIncludeHiddenFields,
273 /** Exclude hidden fields from the view. */
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;
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;
297 CContactItemViewDef(TUse aUse,TMode aMode);
299 CArrayFixFlat<TUid> iFieldTypes;
304 class CContactViewDef : public CBase
305 /** Specifies a subset of fields to be loaded when reading a contact item.
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.
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.
315 The following functions declared in class CContactViewDef have not been
316 implemented:- Groups(), AddL().
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);
339 void ConstructL(CContactItemViewDef* aItemDef);
341 CContactItemViewDef* iItemDef;
342 // CContactIdArray* iGroupIds; // unused for now
346 /** Iterates through the sorted contact items in a contact database.
348 A value of KNullContactId is returned by the iterator if a requested item cannot
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();
364 void GotoIndexL(TInt aPos);
366 CContactDatabase &iDatabase;
367 TContactItemId iCursorId;
370 class MIdleFindObserver
371 /** The interface for an asynchronous find observer.
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.
382 /** Asynchronous find observer callback.
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.
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;
395 struct SFindInTextDefWordParser
396 /** Search string parser struct.
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.
407 inline SFindInTextDefWordParser(const TDesC *aSearchString, CDesCArray *aWordArray) : iSearchString(aSearchString), iWordArray(aWordArray)
408 /** Initialises the search string and the word array.
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. */
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
419 CDesCArray *iWordArray;
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.
426 An instance of this class is returned by calls to CContactDatabase::FindAsyncL()
427 and CContactDatabase::FindInTextDefAsyncL().
435 IMPORT_C TBool IsComplete() const;
436 IMPORT_C CContactIdArray *TakeContactIds();
437 IMPORT_C TInt Error() const;
438 TInt RunError(TInt aError);
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);
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);
455 EFindInBlobFinished =0x00000001,
456 EFindInIdentityFinished =0x00000002,
457 EFindInEmailFinished =0x00000004,
458 EFindInTextDefFinished =0x00000008
461 CContactDatabase *iContactDatabase;
462 CContactIdArray *iIdsFound;
464 CDesCArray* iFindWords;
468 const CContactItemFieldDef* iFieldDef;
469 const CContactTextDef* iTextDef;
470 MIdleFindObserver *iObserver;
472 TCallBack iWordParserCallback;
476 TInt iReserved7; //was TDbColNo
477 TInt iReserved8; //was RDbView
478 TInt iReserved9; //was RDbView
479 TInt iReserved10; //was CIdentityTableColSet*
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.
491 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
492 virtual void HandleDatabaseEventL(RDbNotifier::TEvent)=0;
494 virtual void HandleDatabaseEventL(const TContactDbObserverEvent &aEvent)=0;
498 class MContactSortObserver
508 virtual void HandleSortEventL(TInt aContactsSorted, TInt aContactsTotal)=0;
511 class MConverterCallBack
513 Interface class for providing Intra-Contact Properties during a PBAP specific contacts export.
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.
523 virtual void AddIntraContactPropertiesL(const TContactItemId& aContactId, CArrayPtr<CParserProperty>* aPropertyList) = 0;
528 Specifies type of export of contact items.
529 PBAP clients should use EPBAPVCard21 and EPBAPVCard30.
541 class CContactDatabase : public CBase, public MContactDbPrivObserver, public MContactStorageObserver
542 /** A database of contact items.
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).
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.
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
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.
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
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.
574 The following functions defined in class CContactDatabase are not
575 supported. If called, they leave with KErrNotSupported.
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;
598 /** Specifies the field type and order preferences used for sorting items in the
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.
604 @see CContactDatabase::SortL()
605 @see CContactDatabase::SortArrayL()
611 /** The sort order. */
614 /** Ascending sort order. */
616 /** Descending sort order. */
621 inline TSortPref(TFieldType aFieldType,TOrder aOrder=EAsc);
622 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
623 IMPORT_C void InternalizeL(RReadStream& aStream);
625 /** Specifies whether the sort should be ascending or descending. */
627 /** The first field matching this field type is used for the text to sort on. */
628 TFieldType iFieldType;
631 /** Import and export format flags. Contacts can be imported into
632 or exported from the contact database as vCards.
634 The following options are available during import and export.
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. */
642 /** Handle Symbian's extended vCard format options. */
644 /** Support non-standard extensions requried by Symbian PC connectivity software
645 and Microsoft, amongst others. */
647 /** Don't export the contact ID (for exporting only). */
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. */
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
708 /** Specifies whether the database can be accessed from single or multiple threads. */
711 /** Allows access to the contacts database from a single thread only. */
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
724 EUsesIdentityTableOnly,
726 EIdentityTableNotUsed //Not used
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);
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();
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;
759 IMPORT_C TContactItemId AddNewContactL(CContactItem& aContact);
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);
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;
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);
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();
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);
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();
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);
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);
846 // Preferred Template
847 IMPORT_C TContactItemId PrefTemplateId() const;
848 IMPORT_C void SetPrefTemplateL(const CContactItem& aContact);
851 IMPORT_C void SetCurrentItem(const TContactItemId aContactId);
852 IMPORT_C TContactItemId GetCurrentItem() const;
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);
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();
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();
880 public: // For cnt server only
881 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
882 void HandleDatabaseEventL(RDbNotifier::TEvent) {};
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;
888 IMPORT_C void StoreSortOrderL();
889 IMPORT_C void RestoreSortOrderL();
890 IMPORT_C const CArrayFix<TSortPref>* SortOrder() const;
891 //Contact Hint Field Access
893 /** Contact view filter flags.
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).
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.
903 Filters only apply to non-hidden contact fields with content. */
904 enum TContactViewFilter
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. */
921 /** The filter excludes items without a home telephone number or email address. */
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
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();
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);
970 TInt ContactPosL(TContactItemId aContactId);
971 TInt DoGotoL(TContactItemId aContactId);
973 void DoReadContactTextDefL(const CContactItemFieldSet* aFieldSet,TDes& aResult,CContactTextDef* aTextDef);
974 CContactItem* OpenNoMergeLCX(TContactItemId aContactId);
976 void FetchGroupAndTemplateListsL();
979 void CancelNotifyRequestL();
980 TBool IsICCSynchronisedL();
983 void AddObserverL(MContactDbObserver& aChangeNotifier);
984 void RemoveObserver(const MContactDbObserver& aChangeNotifier);
986 void OpenDatabaseAsyncL(TRequestStatus& aStatus, const TDesC& aFileName = KNullDesC);
987 static void CleanupLastLockedContact(TAny *aDatabase);
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);
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);
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);
1011 /** State of database connection
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,
1030 /** Currently unused */
1031 enum TDirection {EAsc,EDesc}; //unused
1032 void SetDbConnectionState(TDbConnState aDbConnectionState);
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
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,
1051 private: // objec construction/destruction
1054 static CContactDatabase* NewLC();
1056 void CreateViewDefL();
1057 MLplPersistenceLayerFactory* FactoryL();
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);
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
1095 //These two members are accessed via the inline functions!
1096 CContactIdArray* iCardTemplateIds;
1097 CContactIdArray* iGroupIds;
1099 CCntTemplateCache* iTemplateCache; //was CContactTables* iItemTable;
1100 CContactTextDef* iTextDef; //remains
1101 CContactIdArray* iSortedItems; //remains
1102 CContactViewDef* iView; //remains
1104 // Used in SetLastSyncDateL() and GetLastSyncDateL()
1105 TTime iSyncDate; //was TInt64 iMachineUniqueId;
1106 TCollationMethod iCollateMethod; //remains: used for sorting contacts
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
1115 class CContactChangeNotifier : public CBase
1116 /** Receives events reporting changes to a contact database.
1118 After the change notifier has been created, it notifies the specified
1119 observer whenever a change takes place to the database.
1126 IMPORT_C ~CContactChangeNotifier();
1127 IMPORT_C static CContactChangeNotifier* NewL(CContactDatabase& aDatabase, MContactDbObserver *aObserver);
1129 CContactChangeNotifier(CContactDatabase& aDatabase, MContactDbObserver *aObserver);
1132 CContactDatabase &iDatabase;
1133 MContactDbObserver* iObserver;
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
1143 /** The UID of the vCard converter ECom plugin interface. */
1144 const TUid KUidEcomCntVCardConverterInterface = {0x102035F7};
1146 /** The UID of the phone number parser ECom plugin interface. */
1147 const TUid KUidEcomCntPhoneNumberParserInterface = {0x102035FA};
1149 /** The UID of PBAP vCard Converter plugin Implementation.
1153 #define KUidPBAPVCardConvImpl 0xA00015C1
1155 class TPluginParameters
1157 Class used to pack the extra arguments required for a PBAP conveter,
1158 PBAP client provides these arguments using overloaded CContactDatabase::ExportSelectedContacts.
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;
1171 MConverterCallBack* iCallback;
1172 TVCardVersion iVersion;
1176 inline TBool TPluginParameters::IsExportTel()const
1180 inline TInt64 TPluginParameters::GetFilter()const
1185 inline MConverterCallBack* TPluginParameters::GetCallback()const
1190 inline TVCardVersion TPluginParameters::GetExportVersion()const
1195 inline TPluginParameters::TPluginParameters(TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel):iFilter(aContactFieldFilter), iCallback(aCallback), iVersion(aVersion), iExportTel(aExportTel)
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.
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;
1214 class CContactEcomConverter : public CContactConverter
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.
1223 static CContactEcomConverter* NewL(TUid aImplementationUid);
1224 static CContactEcomConverter* NewL(TUid aImplementationUid, TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel);
1225 inline virtual ~CContactEcomConverter();
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. */
1236 TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
1237 _FOFF(CContactEcomConverter,
1239 return reinterpret_cast<CContactEcomConverter*>(ptr);
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. */
1251 TPluginParameters partr(aContactFieldFilter,aCallback,aVersion,aExportTel);
1253 TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
1254 _FOFF(CContactEcomConverter,
1255 iDtor_ID_Key), &partr);
1256 return reinterpret_cast<CContactEcomConverter*>(ptr);
1259 inline CContactEcomConverter::~CContactEcomConverter()
1260 /** The destruction of the interface implementation referred to by iDtor_ID_Key */
1262 REComSession::DestroyedImplementation(iDtor_ID_Key);
1266 class CContactPhoneNumberParser : public CBase
1267 /** Provides functionality to extract the real phone number from a contact's phone number field.
1273 virtual void ExtractRawNumber(const TDesC& aTextualNumber, TDes& aRawNumber)=0;
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.
1285 static CContactEcomPhoneNumberParser* NewL(TUid aImplementationUid);
1286 inline virtual ~CContactEcomPhoneNumberParser();
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. */
1296 TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
1297 _FOFF(CContactEcomPhoneNumberParser,
1299 return reinterpret_cast<CContactEcomPhoneNumberParser*>(ptr);
1302 inline CContactEcomPhoneNumberParser::~CContactEcomPhoneNumberParser()
1303 /** The destruction of the interface implementation referred to by iDtor_ID_Key */
1305 REComSession::DestroyedImplementation(iDtor_ID_Key);
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.
1313 @return The number of contact card templates that exist in the database. */
1314 { return iCardTemplateIds->Count(); }
1316 inline TInt CContactDatabase::GroupCount() const
1317 /** Gets the number of groups that exist in the database.
1319 @return The number of groups that exist in the database. */
1320 { return iGroupIds->Count(); }
1322 inline TInt CContactDatabase::NullUidValue()
1323 /** Gets the NULL contact ID value.
1325 @return KNullContactId. */
1326 { return KNullContactId; }
1328 inline TUid CContactItemViewDef::operator[](TInt aIndex) const
1329 /** Gets the field type located at a specified index position within the field type array.
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
1336 { return iFieldTypes[aIndex]; }
1338 inline TInt CContactItemViewDef::Count() const
1339 /** Gets the number of field types in the view definition.
1341 @return The number of field types in the view definition. */
1342 { return iFieldTypes.Count(); }
1344 inline void CContactItemViewDef::Reset()
1345 /** Deletes all field types from the view definition's field type array. */
1346 { iFieldTypes.Reset(); }
1348 inline CContactItemViewDef::TUse CContactItemViewDef::Use() const
1349 /** Gets the view definition's use.
1351 @return The current TUse setting. */
1354 inline void CContactItemViewDef::SetUse(CContactItemViewDef::TUse aUse)
1355 /** Sets the view definition's use.
1357 @param aUse The new TUse setting. */
1360 inline CContactItemViewDef::TMode CContactItemViewDef::Mode() const
1361 /** Gets the view definition's mode.
1363 @return The current TMode setting. */
1366 inline void CContactItemViewDef::SetMode(CContactItemViewDef::TMode aMode)
1367 /** Sets the view definition's mode.
1369 @param aMode The new TMode setting. */
1372 inline CContactDatabase::TSortPref::TSortPref()
1373 : iOrder(EAsc), iFieldType(KNullUid)
1374 /** Constructs a TSortPref object. The order is initialised to EAsc and the field
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.
1390 /** A class that manages the asynchronous open operation for a CContactDatabase.
1392 The object can be deleted before the asynchronous open completes. This will set
1393 the state of the client supplied TRequestStatus to KErrCancel.
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.
1401 @see CContactDatabase::OpenL()
1403 class CContactOpenOperation : private CActive
1406 IMPORT_C CContactDatabase* TakeDatabase();
1407 IMPORT_C ~CContactOpenOperation();
1409 static CContactOpenOperation* NewL(TRequestStatus& aPtrStatus);
1410 static CContactOpenOperation* NewL(const TDesC& aFileName, TRequestStatus& aPtrStatus);
1413 // from CActive (for BC reasons)
1415 TInt RunError(TInt aError);
1418 CContactOpenOperation (TRequestStatus& aClientStatus);
1419 void ConstructL (const TDesC& aFileName = KNullDesC);
1422 TRequestStatus* iClientStatus;
1423 CContactDatabase* iContactDatabase;
1427 #endif //__CNTDB_H__