1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
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;
60 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
61 class CContactSynchroniser;
67 Maximum string length used to separate the fields in the text definition.
68 @see TContactTextDefItem
72 const TInt KMaxContactTextSeperator=4;
74 Constant used during sorting and searching of contacts.
78 const TInt KTextFieldMinimalLength=64;
80 Maximum number of fields that can be set as filterable fields by licensees.
84 const TInt KMaxCustomFilterableFields=4;
86 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
88 /** @internalComponent */
89 const TInt KMajorVersion=1;
90 /** @internalComponent */
91 const TInt KMinorVersion=0;
92 /** @internalComponent */
93 const TInt KBuildNumber=40;
95 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
98 // Classes used for compact
101 class MContactStorageObserver
103 Mixin used to observe low disk events
110 virtual void HandleDiskSpaceEvent(TInt aDrive) = 0;
113 class MContactUiCompactObserver
114 /** Mixin used to observe contact database compaction status
120 virtual void Step(TInt aStep)=0;
121 virtual void HandleError(TInt aError)=0;
124 class MContactUiActive
125 /** Mixin used to register the observer.
131 virtual void Cancel()=0;
132 virtual void SetObserver(MContactUiCompactObserver *aObserver)=0;
133 virtual TInt StepsTogo() const=0;
134 virtual TInt Step()=0;
135 virtual TInt Error() const=0;
137 IMPORT_C virtual void MContactUiActive_Reserved1();
140 class CContactActiveBase : public CBase, public MContactUiActive
147 ~CContactActiveBase();
148 void SetObserver(MContactUiCompactObserver *aObserver);
150 TInt StepsTogo() const;
153 void SetContactDatabase(CContactDatabase* aContactDatabase);
154 void SetFileManagerL(RCntModel& aCntSvr);
156 #ifndef __SYMBIAN_CNTMODEL_USE_SQLITE__
158 MContactUiCompactObserver *iObserver;
163 CContactDatabase* iContactDatabase;
167 class CContactActiveCompress : public CContactActiveBase
174 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
175 void ConstructL(RDbNamedDatabase /* &aDataBase */) {};
179 class CContactActiveRecover : public CContactActiveBase
186 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
187 void ConstructL(RDbNamedDatabase /* &aDataBase */) {};
192 class TContactTextDefItem
193 /** An item in a text definition.
195 A TContactTextDefItem has a field type and an optional separator string
196 with a maximum length of 4 characters.
204 IMPORT_C TContactTextDefItem();
205 IMPORT_C TContactTextDefItem(TFieldType aFieldType);
206 IMPORT_C TContactTextDefItem(TFieldType aFieldType, const TDesC &aSeperator);
208 /** The field type. */
209 TFieldType iFieldType;
210 /** The string used to separate the fields in the text definition. */
211 TBuf<KMaxContactTextSeperator> iSeperator;
214 class CContactTextDef : public CArrayFixFlat<TContactTextDefItem>
215 /** Defines a way of grouping fields to form a string which represents
218 A text definition is implemented as an array of text definition items
219 (TContactTextDefItems).
221 For example, CContactDatabase::ReadContactTextDefL() uses a text definition to
222 build up a string from a contact item. When creating the string, it searches
223 the item for fields whose type matches one of the fields specified in the text
224 definition. The contents of the first matching field of each type found in the
225 item are read into the string. These strings may be separated using a field
226 separator, which is also specified in the text definition. A separator is not
227 appended to the last field used to make up the string. It is only inserted when
228 there is a following non-empty field.
230 Additionally, the text definition may also contain a fallback field
231 type. This is used when none of the fields specified in the text
232 definition contain any text. If the item's fallback field contains no text
233 either, or if the fallback field type's value is KUidContactFieldNone, the
234 text is read from the first non-empty field in the item.
236 A contact database can have a default text definition which is set using CContactDatabase::SetTextDefinitionL().
237 This may be overridden using the variants of CContactDatabase::ReadContactTextDefL()
238 which take a CContactTextDef* argument.
240 CContactTextDef is derived from CArrayFixFlat<TContactTextDefItem>, so all
241 relevant functions can be used, e.g. to add and remove elements.
247 friend class CContactDatabase;
248 friend class CContactTables;
251 IMPORT_C static CContactTextDef* NewL();
252 IMPORT_C static CContactTextDef* NewLC();
253 static CContactTextDef* NewLC(RReadStream& aStream);
254 IMPORT_C void SetFallbackField(TFieldType iFieldType);
255 IMPORT_C TFieldType FallbackField() const;
256 IMPORT_C TBool ExactMatchOnly();
257 IMPORT_C void SetExactMatchOnly(TBool aExactMatchOnly);
258 void ExternalizeL(RWriteStream& aStream) const;
259 void InternalizeL(RReadStream& aStream);
261 TFieldType iFallbackFieldType;
262 TBool iExactMatchOnly;//Default to EFalse cause ReadInTextDef to only match the chosen fields and not attempt a matchall
265 class CContactItemViewDef : public CBase
266 /** A view definition for a contact item.
268 When reading or opening a contact item using the CContactDatabase class,
269 a view definition may be specified to indicate which field data should be
270 retrieved. See for instance CContactDatabase::ReadContactL().
272 A view definition for a contact item contains an array of field types, a use
273 (CContactItemViewDef::TUse) and a mode (CContactItemViewDef::TMode). The use
274 indicates whether the field types contained in the view definition should
275 be included in or excluded from the view. The mode indicates whether fields
276 with the hidden attribute should be included or excluded.
283 /** Include or exclude specified fields. */
286 /** Include specified fields in the view. */
288 /** Exclude specified fields from the view. */
291 /** Include or exclude hidden fields.*/
294 /** Include hidden fields in the view. */
295 EIncludeHiddenFields,
296 /** Exclude hidden fields from the view. */
300 IMPORT_C static CContactItemViewDef* NewL(TUse aUse, TMode aMode);
301 IMPORT_C static CContactItemViewDef* NewLC(TUse aUse, TMode aMode);
302 static CContactItemViewDef* NewLC(RReadStream& aStream);
303 inline TUid operator[](TInt aIndex) const;
304 IMPORT_C TInt Find(const CContentType &aContentType) const;
305 IMPORT_C TInt Find(TFieldType aFieldType) const;
306 inline TInt Count() const;
308 IMPORT_C void AddL(TFieldType aFieldType);
309 IMPORT_C void Remove(TFieldType aFieldType);
310 IMPORT_C void Remove(TInt aIndex);
311 inline TUse Use() const;
312 inline void SetUse(TUse aUse);
313 inline TMode Mode() const;
314 inline void SetMode(TMode aMode);
315 IMPORT_C TBool Contains(const CContactItem& aItem);
316 IMPORT_C void InternalizeL(RReadStream& aStream);
317 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
318 IMPORT_C TBool MatchesAll() const;
320 CContactItemViewDef(TUse aUse,TMode aMode);
322 CArrayFixFlat<TUid> iFieldTypes;
327 class CContactViewDef : public CBase
328 /** Specifies a subset of fields to be loaded when reading a contact item.
330 A default view definition is owned by the contact database.
331 It is set using CContactDatabase::SetViewDefinitionL() and is used in calls
332 to CContactDatabase::ReadContactL(), ReadContactLC() and ReadContactAndAgentL()
333 when no view definition is specified.
335 The view definition owns the item view definition (see the CContactItemViewDef
336 class), which stores the view definition's field types, use and mode.
338 The following functions declared in class CContactViewDef have not been
339 implemented:- Groups(), AddL().
346 IMPORT_C static CContactViewDef* NewL();
347 IMPORT_C static CContactViewDef* NewLC();
348 IMPORT_C static CContactViewDef* NewL(CContactItemViewDef* aItemDef);
349 IMPORT_C static CContactViewDef* NewLC(CContactItemViewDef* aItemDef);
350 static CContactViewDef* NewLC(RReadStream& aStream);
351 IMPORT_C ~CContactViewDef();
352 IMPORT_C void InternalizeL(RReadStream& aStream);
353 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
354 IMPORT_C CContactItemViewDef& ItemDef() const;
355 /** This function is not implemented */
356 IMPORT_C CContactIdArray& Groups() const;
357 /** This function is not implemented.
358 @param aFieldType The field type to append to the array of field types. */
359 inline void AddL(TFieldType aFieldType);
362 void ConstructL(CContactItemViewDef* aItemDef);
364 CContactItemViewDef* iItemDef;
365 // CContactIdArray* iGroupIds; // unused for now
369 /** Iterates through the sorted contact items in a contact database.
371 A value of KNullContactId is returned by the iterator if a requested item cannot
379 IMPORT_C TContactIter(CContactDatabase &aDatabase);
380 IMPORT_C TContactItemId FirstL();
381 IMPORT_C TContactItemId NextL();
382 IMPORT_C TContactItemId PreviousL();
383 IMPORT_C TContactItemId LastL();
384 IMPORT_C void GotoL(TContactItemId aContactId);
385 IMPORT_C void Reset();
387 void GotoIndexL(TInt aPos);
389 CContactDatabase &iDatabase;
390 TContactItemId iCursorId;
393 class MIdleFindObserver
394 /** The interface for an asynchronous find observer.
396 An object which implements this interface is passed to the asynchronous find
397 functions defined in class CContactDatabase, (FindAsyncL() and FindInTextDefAsyncL()).
398 The observer would typically notify the user of the progress of the operation.
405 /** Asynchronous find observer callback.
407 If an observer is supplied to CContactDatabase::FindAsyncL()
408 or FindInTextDefAsyncL(), this callback function is called by CIdle::RunL()
409 when nothing of a higher priority can be scheduled. It is called for every
410 16 items searched to give the application a chance to update its search status.
412 An implementation might test for and handle errors and retrieve information
413 about the progress of the search. This information may be retrieved using
414 functions provided by the CIdleFinder class. */
415 virtual void IdleFindCallback()=0;
418 struct SFindInTextDefWordParser
419 /** Search string parser struct.
421 An object of this type is used in the callback parser function passed to
422 CContactDatabase::FindInTextDefLC(). The parser function must walk
423 through and parse iSearchString, adding any words found to iWordArray.
430 inline SFindInTextDefWordParser(const TDesC *aSearchString, CDesCArray *aWordArray) : iSearchString(aSearchString), iWordArray(aWordArray)
431 /** Initialises the search string and the word array.
433 @param aSearchString Pointer to the input string to be parsed.
434 @param aWordArray Pointer to the array to which words parsed from the input
435 string should be added. */
438 /** Pointer to the input string to be parsed. */
439 const TDesC *iSearchString;
440 /** Pointer to the array to which words parsed from the input string should be
442 CDesCArray *iWordArray;
445 class CIdleFinder : public CIdle
446 /** Provides information about the progress of an asynchronous contact database search,
447 and can be used to get the results of the search.
449 An instance of this class is returned by calls to CContactDatabase::FindAsyncL()
450 and CContactDatabase::FindInTextDefAsyncL().
458 IMPORT_C TBool IsComplete() const;
459 IMPORT_C CContactIdArray *TakeContactIds();
460 IMPORT_C TInt Error() const;
461 TInt RunError(TInt aError);
463 friend class CContactDatabase;
464 static CIdleFinder *NewL(CContactDatabase &aContactDatabase, const TDesC& aText, const CContactItemFieldDef *aFieldDef, MIdleFindObserver *aObserver);
465 static CIdleFinder *NewL(CContactDatabase &aContactDatabase, const MDesCArray* aFindWords,const CContactTextDef* aTextDef, MIdleFindObserver *aObserver, const TCallBack &aWordParserCallback);
468 static TInt CallbackL(TAny *aSelf);
469 void ConstructL(const TDesC *aText, const MDesCArray* aFindWords, const TCallBack *aWordParserCallback);
470 TBool ScanForMatchL(const TDesC &aFieldText,const TDesC &aFindText, CFoundMatches *aFoundMatches) const;
471 TBool CheckFindL(TContactItemId aContactId) const;
472 TBool CheckFindL() const;
473 CIdleFinder(CContactDatabase &aContactDatabase, const CContactItemFieldDef *aFieldDef, const CContactTextDef* aTextDef, MIdleFindObserver *aObserver);
478 EFindInBlobFinished =0x00000001,
479 EFindInIdentityFinished =0x00000002,
480 EFindInEmailFinished =0x00000004,
481 EFindInTextDefFinished =0x00000008
484 CContactDatabase *iContactDatabase;
485 CContactIdArray *iIdsFound;
487 CDesCArray* iFindWords;
491 const CContactItemFieldDef* iFieldDef;
492 const CContactTextDef* iTextDef;
493 MIdleFindObserver *iObserver;
495 TCallBack iWordParserCallback;
499 TInt iReserved7; //was TDbColNo
500 TInt iReserved8; //was RDbView
501 TInt iReserved9; //was RDbView
502 TInt iReserved10; //was CIdentityTableColSet*
505 class MContactDbPrivObserver
506 /** Provides notification of database changes to clients.
507 * Provides information about database change event details and the type of changed event.
514 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
515 virtual void HandleDatabaseEventL(RDbNotifier::TEvent)=0;
517 virtual void HandleDatabaseEventL(const TContactDbObserverEvent &aEvent)=0;
521 class MContactSortObserver
531 virtual void HandleSortEventL(TInt aContactsSorted, TInt aContactsTotal)=0;
534 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
535 class MConverterCallBack
537 Interface class for providing Intra-Contact Properties during a PBAP specific contacts export.
544 PBAP clients are supposed to provide any information regarding the contact item represented by aContactId.
545 This information should be in form of standard vCard property, all such properties should be appended to the array aPropertyList.
547 virtual void AddIntraContactPropertiesL(const TContactItemId& aContactId, CArrayPtr<CParserProperty>* aPropertyList) = 0;
550 class MConverterCallBack;
551 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
555 Specifies type of export of contact items.
556 PBAP clients should use EPBAPVCard21 and EPBAPVCard30.
568 class CContactDatabase : public CBase, public MContactDbPrivObserver, public MContactStorageObserver
569 /** A database of contact items.
571 Contact items can be added to and removed from the database and items in the
572 database can be opened or read. To edit an item, it must first be opened.
573 Changes to the item can then be committed using CommitContactL()
574 (committing can only take place to an open item).
576 If the available disk space is less than 128 kilobytes then changes to the
577 contact database cannot be started, and methods such as CreateL() or CommitContactL()
578 will leave with a KErrDiskFull error. Less obviously OpenL() can also fail with
579 KErrDiskFull when trying to update the system template.
581 Each item has an access count. An item cannot be fully deleted unless its
582 access count is zero. This is to prevent items which have been
583 synchronised with another contacts application from being deleted.
584 Also, if the item is a template, it cannot be deleted if other items are based
587 More than one contact database can exist on a phone, but there is a
588 default contact database. Its filename is contacts.cdb. It
589 can be moved between drives.
591 CContactDatabase implements searching and sorting and also provides
592 separate phone number matching functions. These provide a fast way of indexing
593 and looking up phone numbers, e.g. for looking up caller IDs on incoming
596 The database owns speed dial information. This is a mapping between a single
597 digit integer and a telephone number. There may be up to 9 speed dial telephone
598 numbers; each of them belongs to a contact item in the database. If a
599 contact item is deleted, its speed dial mapping is removed.
601 The following functions defined in class CContactDatabase are not
602 supported. If called, they leave with KErrNotSupported.
614 friend class TContactIter;
615 friend class CIdleFinder;
616 friend class CCntIdleSorter;
617 friend class CContactLocalView;
618 friend class CContactOpenOperation;
619 friend class RContactRemoteView;
620 friend class CViewIteratorProxyManager;
621 friend class CCollectionProxy;
622 friend class CContactActiveBase;
625 /** Specifies the field type and order preferences used for sorting items in the
628 The contents of the first field in a contact item matching the field type
629 is used as the data to sort on. The order can either be ascending or descending.
631 @see CContactDatabase::SortL()
632 @see CContactDatabase::SortArrayL()
638 /** The sort order. */
641 /** Ascending sort order. */
643 /** Descending sort order. */
648 inline TSortPref(TFieldType aFieldType,TOrder aOrder=EAsc);
649 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
650 IMPORT_C void InternalizeL(RReadStream& aStream);
652 /** Specifies whether the sort should be ascending or descending. */
654 /** The first field matching this field type is used for the text to sort on. */
655 TFieldType iFieldType;
658 /** Import and export format flags. Contacts can be imported into
659 or exported from the contact database as vCards.
661 The following options are available during import and export.
663 @deprecated This enum is deprecated. It has been replaced by the TOptions enum in
664 the plugin convertor class CContactVCardConverter, so that each plugin converter
665 can define its own options. */
669 /** Handle Symbian's extended vCard format options. */
671 /** Support non-standard extensions requried by Symbian PC connectivity software
672 and Microsoft, amongst others. */
674 /** Don't export the contact ID (for exporting only). */
676 /** Decrease the contact's access count when importing and exporting. */
677 EDecreaseAccessCount=0x0008,
678 /** Only import the first contact in the read stream (for importing only). */
679 EImportSingleContact=0x0010,
680 /** Increase the contact's access count when importing and exporting. */
681 EIncreaseAccessCount=0x0020,
682 /** Sets a contact item to the local time when importing. */
684 /** Allows you to set a template to a contact item that does not exist. */
685 ENullTemplateId=0x0080,
686 /** For use by implementor of converter plug-in. */
687 EConverterDefined1=0x0100,
688 /** For use by implementor of converter plug-in. */
689 EConverterDefined2=0x0200,
690 /** For use by implementor of converter plug-in. */
691 EConverterDefined3=0x0400,
692 /** For use by implementor of converter plug-in. */
693 EConverterDefined4=0x0800,
694 /** For use by implementor of converter plug-in. */
695 EConverterDefined5=0x1000,
696 /** For use by implementor of converter plug-in. */
697 EConverterDefined6=0x2000,
698 /** For use by implementor of converter plug-in. */
699 EConverterDefined7=0x4000,
700 /** For use by implementor of converter plug-in. */
701 EConverterDefined8=0x8000,
702 /** Reserved for use by Symbian. */
703 EConverterReserved1=0x00010000,
704 /** Reserved for use by Symbian. */
705 EConverterReserved2=0x00020000,
706 /** Reserved for use by Symbian. */
707 EConverterReserved3=0x00040000,
708 /** Reserved for use by Symbian. */
709 EConverterReserved4=0x00080000,
710 /** Reserved for use by Symbian. */
711 EConverterReserved5=0x00100000,
712 /** Reserved for use by Symbian. */
713 EConverterReserved6=0x00200000,
714 /** Reserved for use by Symbian. */
715 EConverterReserved7=0x00400000,
716 /** Reserved for use by Symbian. */
717 EConverterReserved8=0x00800000,
718 /** Reserved for use by Symbian. */
719 EConverterReserved9=0x01000000,
720 /** Reserved for use by Symbian. */
721 EConverterReserved10=0x02000000,
722 /** Reserved for use by Symbian. */
723 EConverterReserved11=0x04000000,
724 /** Reserved for use by Symbian. */
725 EConverterReserved12=0x08000000,
726 /** Reserved for use by Symbian. */
727 EConverterReserved13=0x10000000,
728 /** Reserved for use by Symbian. */
729 EConverterReserved14=0x20000000,
730 /** Reserved for use by Symbian. */
731 EConverterReserved15=0x40000000,
732 /** Reserved for use by Symbian. */
733 EConverterReserved16=0x80000000
735 /** Specifies whether the database can be accessed from single or multiple threads. */
738 /** Allows access to the contacts database from a single thread only. */
740 /** Allows for a multi-threaded program to access the contact database from multiple
741 threads but note that the contacts model provides no synchronisation support
746 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
753 EUsesIdentityTableOnly,
755 EIdentityTableNotUsed //Not used
759 IMPORT_C static CContactDatabase* OpenL(TThreadAccess aAccess=ESingleThread);
760 IMPORT_C static CContactDatabase* OpenL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);
761 IMPORT_C static CContactDatabase* CreateL(TThreadAccess aAccess=ESingleThread);
762 IMPORT_C static CContactDatabase* CreateL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);
763 IMPORT_C static CContactDatabase* ReplaceL(TThreadAccess aAccess=ESingleThread);
764 IMPORT_C static CContactDatabase* ReplaceL(const TDesC& aFileName,TThreadAccess aAccess=ESingleThread);
766 IMPORT_C static CContactOpenOperation* Open(TRequestStatus& aStatus, TThreadAccess aAccess=ESingleThread);
767 IMPORT_C static CContactOpenOperation* Open(const TDesC& aFileName, TRequestStatus& aStatus, TThreadAccess aAccess=ESingleThread);
768 IMPORT_C static TBool DatabaseDrive(TDriveUnit &aDriveUnit);
769 inline static TInt NullUidValue();
770 IMPORT_C static void SetDatabaseDriveL(TDriveUnit aDriveUnit, TBool aCopy=ETrue);
771 IMPORT_C static void GetDefaultNameL(TDes &aDes);
772 IMPORT_C static void DeleteDefaultFileL();
773 // database file mangement
774 IMPORT_C static void DeleteDatabaseL(const TDesC& aFileName);
775 IMPORT_C static CDesCArray* ListDatabasesL();
776 IMPORT_C static CDesCArray* ListDatabasesL(TDriveUnit aDriveUnit);
777 IMPORT_C static TBool DefaultContactDatabaseExistsL();
778 IMPORT_C static TBool ContactDatabaseExistsL(const TDesC& aFileName);
779 IMPORT_C ~CContactDatabase();
781 IMPORT_C void SetViewDefinitionL(CContactViewDef* aView);
782 IMPORT_C void SetTextDefinitionL(CContactTextDef* aView);
783 IMPORT_C const CContactTextDef* TextDefinition() const;
784 IMPORT_C TInt CountL();
785 IMPORT_C void SetDbViewContactType(const TUid aUid);
786 IMPORT_C TUid GetDbViewContactType() const;
789 IMPORT_C TContactItemId AddNewContactL(CContactItem& aContact);
791 IMPORT_C CContactItem* CreateContactGroupL(TBool aInTransaction=EFalse);
792 IMPORT_C CContactItem* CreateContactGroupLC(TBool aInTransaction=EFalse);
793 IMPORT_C CContactItem* CreateContactGroupL(const TDesC& aGroupLabel,TBool aInTransaction=EFalse);
794 IMPORT_C CContactItem* CreateContactGroupLC(const TDesC& aGroupLabel,TBool aInTransaction=EFalse);
795 IMPORT_C CContactItem* CreateContactCardTemplateL(const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
796 IMPORT_C CContactItem* CreateContactCardTemplateLC(const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
797 IMPORT_C CContactItem* CreateContactCardTemplateL(const CContactItem* aTemplate,const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
798 IMPORT_C CContactItem* CreateContactCardTemplateLC(const CContactItem* aTemplate,const TDesC& aTemplateLabel,TBool aInTransaction=EFalse);
800 IMPORT_C CContactIdArray* GetCardTemplateIdListL() const;
801 IMPORT_C CContactIdArray* GetGroupIdListL() const;
802 IMPORT_C void AddContactToGroupL(TContactItemId aItemId, TContactItemId aGroupId);
803 IMPORT_C void AddContactToGroupL(CContactItem& aItem, CContactItem& aGroup);
804 IMPORT_C void AddContactToGroupL(TContactItemId aItemId, TContactItemId aGroupId,TBool aInTransaction);
805 IMPORT_C void RemoveContactFromGroupL(CContactItem& aItem, CContactItem& aGroup);
806 IMPORT_C void RemoveContactFromGroupL(TContactItemId aItemId, TContactItemId aGroupId);
807 inline TInt GroupCount() const;
808 inline TInt TemplateCount() const;
810 // speed dial functions
811 IMPORT_C void SetFieldAsSpeedDialL(CContactItem& aItem, TInt aFieldIndex, TInt aSpeedDialPosition);
812 IMPORT_C TContactItemId GetSpeedDialFieldL(TInt aSpeedDialPosition, TDes& aPhoneNumber);
813 IMPORT_C void RemoveSpeedDialFieldL(TContactItemId aContactId, TInt aSpeedDialPosition);
815 // reading contacts from the db
816 IMPORT_C CContactItem* ReadMinimalContactL(TContactItemId aContactId);
817 IMPORT_C CContactItem* ReadMinimalContactLC(TContactItemId aContactId);
818 IMPORT_C CContactItem* ReadContactL(TContactItemId aContactId);
819 IMPORT_C CArrayPtr<CContactItem>* ReadContactAndAgentL(TContactItemId aContactId);
820 IMPORT_C CContactItem* ReadContactL(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
821 IMPORT_C CContactItem* ReadContactLC(TContactItemId aContactId);
822 IMPORT_C CContactItem* ReadContactLC(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
823 IMPORT_C void ReadContactTextDefL(const CContactItem &aItem, TDes &aResult);
824 IMPORT_C void ReadContactTextDefL(const CContactItem &aItem, TDes &aResult,CContactTextDef* aTextDef);
825 IMPORT_C void ReadContactTextDefL(TContactItemId aContactId, TDes &aResult);
826 IMPORT_C void ReadContactTextDefL(TContactItemId aContactId, TDes &aResult,CContactTextDef* aTextDef);
827 IMPORT_C CContactItem* OpenContactL(TContactItemId aContactId);
828 IMPORT_C CContactItem* OpenContactL(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
829 IMPORT_C CContactItem* OpenContactLX(TContactItemId aContactId);
830 IMPORT_C CContactItem* OpenContactLX(TContactItemId aContactId,const CContactItemViewDef& aViewDef);
831 IMPORT_C void CloseContactL(TContactItemId aContactId);
832 IMPORT_C void CommitContactL(const CContactItem& aContact);
833 IMPORT_C void DeleteContactL(TContactItemId aContactId);
834 IMPORT_C void DeleteContactsL(const CContactIdArray& aContactIds);
835 IMPORT_C CArrayPtr<CContactItem>* ImportContactsL(const TUid& aFormat,RReadStream& aReadStream,TBool& aImportSuccessful,TInt aOption);
836 IMPORT_C void ExportSelectedContactsL(const TUid& aFormat,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOption,TBool aExportPrivateFields=ETrue);
837 IMPORT_C void ExportSelectedContactsL(const TUid& aFormat,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOption,const Versit::TVersitCharSet aCharSet, TBool aExportPrivateFields=ETrue);
838 IMPORT_C void CompactL();
840 IMPORT_C CContactIdArray* FindLC(const TDesC& aText,const CContactItemFieldDef *aFieldDef);
841 IMPORT_C CIdleFinder* FindAsyncL(const TDesC& aText,const CContactItemFieldDef *aFieldDef, MIdleFindObserver *aObserver);
842 IMPORT_C CContactIdArray* FindInTextDefLC(const MDesCArray& aFindWords, const TCallBack &aWordParserCallback);
843 IMPORT_C CContactIdArray* FindInTextDefLC(const MDesCArray& aFindWords,CContactTextDef* aTextDef, const TCallBack &aWordParserCallback);
844 IMPORT_C CIdleFinder* FindInTextDefAsyncL(const MDesCArray& aFindWords, MIdleFindObserver *aObserver, const TCallBack &aWordParserCallback);
845 IMPORT_C CIdleFinder* FindInTextDefAsyncL(const MDesCArray& aFindWords,const CContactTextDef* aTextDef, MIdleFindObserver *aObserver, const TCallBack &aWordParserCallback);
846 IMPORT_C CContactIdArray* SortArrayL(const CContactIdArray* aIdArray, const CArrayFix<TSortPref>* aSortOrder);
847 IMPORT_C CContactIdArray* SortArrayLC(const CContactIdArray* aIdArray, const CArrayFix<TSortPref>* aSortOrder);
848 IMPORT_C void SortByTypeL(CArrayFix<TSortPref>* aSortOrder);
849 IMPORT_C void SortL(CArrayFix<TSortPref>* aSortOrder);
850 IMPORT_C void SortAsyncL(CArrayFix<TSortPref>* aSortOrder, TRequestStatus& aStatus);
851 IMPORT_C void CancelAsyncSort();
852 IMPORT_C void SortAsyncL(CArrayFix<TSortPref>* aSortOrder, TRequestStatus& aStatus, MContactSortObserver& aObserver);
854 IMPORT_C void SetOperationTimeOutL(const TInt aMicroSeconds) const;
855 IMPORT_C TPtrC FileUid();
856 IMPORT_C CContactActiveCompress* CreateCompressorLC();
857 IMPORT_C CContactActiveRecover* CreateRecoverLC();
858 IMPORT_C void RecoverL();
859 IMPORT_C TBool IsDamaged() const;
860 IMPORT_C TBool CompressRequired();
861 IMPORT_C void CloseTables();
862 IMPORT_C void OpenTablesL();
864 //New Phone Matching function, takes a number as a TDesc& and will match from the right of the string
865 //by the the number defined
866 IMPORT_C CContactIdArray* MatchPhoneNumberL(const TDesC& aNumber, TInt aMatchLengthFromRight);
869 IMPORT_C const CContactIdArray* SortedItemsL();
870 IMPORT_C TContactItemId TemplateId() const;
871 IMPORT_C CContactItem* CreateOwnCardLC();
872 IMPORT_C CContactItem* CreateOwnCardL();
873 IMPORT_C TContactItemId OwnCardId() const;
874 IMPORT_C void SetOwnCardL(const CContactItem& aContact);
876 // Preferred Template
877 IMPORT_C TContactItemId PrefTemplateId() const;
878 IMPORT_C void SetPrefTemplateL(const CContactItem& aContact);
881 IMPORT_C void SetCurrentItem(const TContactItemId aContactId);
882 IMPORT_C TContactItemId GetCurrentItem() const;
885 IMPORT_C void SetDateFormatTextL(const TDesC& aFormat);
886 IMPORT_C void FilterDatabaseL(CCntFilter& aFilter);
887 IMPORT_C CContactIdArray* ContactsChangedSinceL(const TTime& aTime);
888 IMPORT_C TContactSyncId SetLastSyncDateL(const TTime& aSyncDate);
889 IMPORT_C void SetLastSyncDateL(TContactSyncId aSyncId, const TTime& aSyncDate);
890 IMPORT_C void GetLastSyncDateL(TContactSyncId aSyncId, TTime& aSyncDate);
892 IMPORT_C TInt FileSize() const;
893 IMPORT_C TInt WastedSpaceInBytes() const;
894 IMPORT_C TUint ConnectionId() const;
895 IMPORT_C const CContentType &TemplateContentType(const CContactItemField &aField) const;
896 IMPORT_C TVersion Version() const;
897 IMPORT_C TInt64 MachineId() const;
898 IMPORT_C TContactItemId ICCTemplateIdL();
899 IMPORT_C TContactItemId ICCTemplateIdL(TUid aPhonebookUid);
900 IMPORT_C TContactItemId PhonebookGroupIdL();
902 public: // For test code only
903 IMPORT_C void DamageDatabaseL(TInt aSecretCode); // Don't use this, you don't really want to damage your database do you?
904 IMPORT_C void OverrideMachineUniqueId(TInt64 aMachineUniqueId);
905 IMPORT_C TInt CntServerResourceCount();
906 IMPORT_C void SetCntServerHeapFailure(TInt aTAllocFailType,TInt aRate);
907 IMPORT_C CContactIdArray* DeletedContactsLC();
908 IMPORT_C void ResetServerSpeedDialsL();
910 public: // For cnt server only
911 #if !( defined __SYMBIAN_CNTMODEL_HIDE_DBMS__ && defined __SYMBIAN_CNTMODEL_USE_SQLITE__ )
912 void HandleDatabaseEventL(RDbNotifier::TEvent) {};
914 IMPORT_C void HandleDatabaseEventL(const TContactDbObserverEvent &aEvent);
915 IMPORT_C TInt GetCurrentDatabase(TDes& aDatabase) const;
916 IMPORT_C TInt SetCurrentDatabase(const TDesC& aDatabase) const;
918 IMPORT_C void StoreSortOrderL();
919 IMPORT_C void RestoreSortOrderL();
920 IMPORT_C const CArrayFix<TSortPref>* SortOrder() const;
921 //Contact Hint Field Access
923 /** Contact view filter flags.
925 These flags define the bits that can be set in filtered views (CContactFilteredView)
926 and in the filter passed to CContactDatabase::ContactMatchesHintFieldL() for
927 comparing against contact view items (CViewContact).
929 If the item's bit field and the view's filter have the same settings for the
930 CContactDatabase::EHome and CContactDatabase::EWork flags and any of the other
931 flags are set in both, a match occurs and the item is included in the view.
933 Filters only apply to non-hidden contact fields with content. */
934 enum TContactViewFilter
936 /** The view is unfiltered; it includes all contact items. */
937 EUnfiltered =0x00000000,
938 /** The filter includes items that have an email address. */
939 EMailable =0x00000001,
940 /** The filter includes items that have a mobile telephone number. */
941 ESmsable =0x00000002,
942 /** The filter includes items that have a landline telephone number. */
943 ELandLine =0x00000004,
944 /** The filter includes items that have a fax number. */
945 EFaxable =0x00000008,
946 /** The filter includes items that are phonable. (All items with any of the above
947 three flags set also have this flag set). */
948 EPhonable =0x00000010,
949 /** The filter excludes items without a work telephone number or email address. */
951 /** The filter excludes items without a home telephone number or email address. */
953 /** The filter includes items that have a non-empty ring tone field (a ring tone
954 that is associated with the item). */
955 ERingTone =0x00000080,
956 /** The filter includes items that have a non-empty voice dial field (a voice
957 recording associated with a telephone number field in the item). */
958 EVoiceDial =0x00000100,
959 /** The filter includes items that have any non empty instant messaging address field. */
960 EIMAddress =0x00000200,
961 /** The filter includes items that have a non empty Wireless Village ID field.
962 An item with this flag set will also have the EIMAddress flag set. */
963 EWirelessVillage = 0x00000400,
964 /** Reserved filters for future use. */
965 ECustomFilter1 = 0x00000800,
966 /** Reserved filters for future use. */
967 ECustomFilter2 = 0x00001000,
968 /** Reserved filters for future use. */
969 ECustomFilter3 = 0x00002000,
970 /** Reserved filters for future use. */
971 ECustomFilter4 = 0x00004000
974 IMPORT_C TBool ContactMatchesHintFieldL(TInt aBitWiseFilter,TContactItemId aContactId);
975 public: // for vCard converter only
976 IMPORT_C void DatabaseBeginLC(TBool aIsInTransaction);
977 IMPORT_C void DatabaseCommitLP(TBool aIsInTransaction);
978 IMPORT_C CContactItem *UpdateContactLC(TContactItemId aContactId,CContactItem* aNewContact);
979 IMPORT_C TContactItemId doAddNewContactL(CContactItem& aContact,TBool aIsTemplate,TBool aIsInTransaction);
980 IMPORT_C void doCommitContactL(const CContactItem& aContact,TBool aIsInTransaction, TBool aSendChangedEvent);
981 IMPORT_C TContactItemId ContactIdByGuidL(const TDesC& aGuid);
982 IMPORT_C void doDeleteContactL(TContactItemId aContactId, TBool aIsInTransaction, TBool aSendChangedEvent, TBool aDecAccessCount=EFalse);
983 IMPORT_C CContactItemViewDef* AllFieldsView();
984 public: // For Symbian use only
985 IMPORT_C void DatabaseBeginL(TBool aIsInTransaction);
986 IMPORT_C void DatabaseCommitL(TBool aIsInTransaction);
987 IMPORT_C void DatabaseRollback();
988 IMPORT_C void SetSortedItemsList(CContactIdArray* aSortedItems, CArrayFix<TSortPref>* aSortOrder);
989 IMPORT_C CContactIdArray* UnfiledContactsL();
990 IMPORT_C static void RecreateSystemTemplateL(const TDesC& aFileName);
991 public: // For Contacts Lock Server use only
992 IMPORT_C static CContactDatabase* LockServerConnectL(const TDesC& aFileName);
993 IMPORT_C static CContactDatabase* LockServerConnectL(const TDesC& aFileName, TInt aOperation);
994 IMPORT_C TInt LockServerCallBackL(TUint aServerOperation);
995 IMPORT_C void LockServerCleanup();
997 IMPORT_C void ExportSelectedContactsL(const TUid& aFormat, const CContactIdArray& aSelectedContactIds, RWriteStream& aWriteStream, TInt aOption, const TInt64 aContactFieldFilter, MConverterCallBack* aCallback, const TVCardVersion aVersion, const TBool aExportTel, Versit::TVersitCharSet aCharSet = Versit::EUTF8CharSet, TBool aExportPrivateFields = ETrue);
1000 TInt ContactPosL(TContactItemId aContactId);
1001 TInt DoGotoL(TContactItemId aContactId);
1003 void DoReadContactTextDefL(const CContactItemFieldSet* aFieldSet,TDes& aResult,CContactTextDef* aTextDef);
1004 CContactItem* OpenNoMergeLCX(TContactItemId aContactId);
1006 void FetchGroupAndTemplateListsL();
1009 void CancelNotifyRequestL();
1010 TBool IsICCSynchronisedL();
1013 void AddObserverL(MContactDbObserver& aChangeNotifier);
1014 void RemoveObserver(const MContactDbObserver& aChangeNotifier);
1016 void OpenDatabaseAsyncL(TRequestStatus& aStatus, const TDesC& aFileName = KNullDesC);
1017 static void CleanupLastLockedContact(TAny *aDatabase);
1020 CContactConverter& ConverterL(const TUid& aFormat);
1021 CContactConverter& ConverterL(const TUid& aFormat, const TInt64 aContactFieldFilter, MConverterCallBack* aCallback, const TVCardVersion aVersion,const TBool aExportTel);
1022 static void CleanupDatabaseRollback(TAny *aDatabase);
1024 CContactIdArray* SortLC(const CArrayFix<TSortPref>* aSortOrder, const CContactIdArray* aIdArray);
1025 TBool CheckType(TUid aUid) const;
1026 void SortDuplicatesL(const CArrayFix<TSortPref>& aSortOrder,CSortArray& aList,TInt aPos);
1027 void SortDuplicatesL(const CArrayFix<TSortPref>& aSortOrder,CSortArray& aList,
1028 TInt aIndex,TInt aStartPos,TInt aEndPos);
1029 TBool AddContactToSortListL(TContactItemId aReqId, TContactItemId& aActualId,CBase* aItems, TUid& aFieldType, TBool aHasSortOrder);
1030 void RemoveFromSortArray(TContactItemId aContactId);
1031 void HandleDbObserverEventGroupDeletedL(const TContactItemId aContactId);
1032 void RemoveFromGroupIds(const TContactItemId aContactId);
1035 static void CleanupTableCancel(TAny *aTable);
1036 /** A text buffer of KTextFieldMinimalLength used during sorting and searching of contacts */
1037 typedef TBuf<KTextFieldMinimalLength> TTextFieldMinimal;
1038 static TUid SpeedDialFieldUidFromSpeedDialPosition(TInt aSpeedDialPosition);
1039 void HandleDiskSpaceEvent(TInt aDrive);
1041 /** State of database connection
1045 /** Database is open, connection is available for use. */
1046 EDbConnectionOpen = 0,
1047 /** Initial state. */
1048 EDbConnectionNotReady,
1049 /** Asynchronous Open failed. */
1050 EDbConnectionFailed,
1051 /** A Rollback has occurred and a Recover is required now. */
1052 EDbConnectionRecoverRequired,
1053 /** Write access is locked during backup. */
1054 EDbConnectionWriteLockedForBackup,
1055 /** The database has been closed whilst a Restore is in progress. */
1056 EDbConnectionClosedForRestore,
1057 /** Restore is in progress need to close after current transaction. */
1058 EDbConnectionNeedToCloseForRestore,
1060 /** Currently unused */
1061 enum TDirection {EAsc,EDesc}; //unused
1062 void SetDbConnectionState(TDbConnState aDbConnectionState);
1064 void CheckDbConnForWriteL() const;
1065 void CheckDbConnForReadL() const;
1066 void CheckDbConnForRecoverL() const;
1067 void CheckTemplateField(CContactItem& aCnt);
1068 static void ValidateDatabaseNameL(const TParse& aParseName);
1069 void StartAsyncActivityL();
1070 void EndAsyncActivityL();
1071 TBool DatabaseReadyL() const;
1072 enum TSvrSessionType //unused
1074 // Server Session is persistent, for Open(L), CreateL or ReplaceL
1075 ESvrSessionPersistent,
1076 // Server Session is temporary, for a simple static API
1077 ESvrSessionTemporary,
1078 // Session is from the Contacts Lock Server
1079 ESvrSessionFromLockServer,
1081 private: // objec construction/destruction
1084 static CContactDatabase* NewLC();
1086 void CreateViewDefL();
1087 MLplPersistenceLayerFactory* FactoryL();
1090 CContactItem* doCreateContactGroupLC(const TDesC& aGroupLabel = KNullDesC);
1091 void AddCntToOpenedGroupL(TContactItemId aItemId, CContactItem& aGroup);
1092 void ReadTemplateIdsL();
1093 void AddToTemplateListL(const TContactItemId aNewTemplateId);
1094 void RemoveFromTemplateList(const TContactItemId aOldTemplateId);
1095 TBool SystemTemplateFieldsValid(const CContactItem& aContact);
1096 void RespondToEventL(const TContactDbObserverEventType aEventType, const TContactItemId aContactId);
1097 void HandleDbObserverEventGroupOrContactChangedL(const TContactItemId aContactId);
1098 void HandleDbObserverEventGroupOrContactAddedL(const TContactDbObserverEventType aEventType, const TContactItemId aContactId);
1099 TBool CheckSortError(TInt aError);
1100 TInt NextExistingL(TInt aIndex);
1101 TInt PreviousExistingL(TInt aIndex);
1102 void ReSortL(CArrayFix<TSortPref>* aSortOrder);
1103 void InsertInSortArray(const CContactItem& aContact);
1104 void MoveInSortArray(const CContactItem& aContact);
1105 void InsertInSortArrayL(const CContactItem& aContact);
1106 void MoveInSortArrayL(const CContactItem& aContact);
1107 TInt NewSortIndexL(const CContactItem& aContact,TInt aStartPos,TInt aEndPos);
1108 TInt CompareSortFieldsL(const CContactItem& aContact);
1109 void ConstructTableUsageFlagsFromSortOrderL(TInt& aFlags);
1110 void LoadSyncPluginL();
1111 void DeleteContactSendEventActionL(TContactItemId aContactId, TCntSendEventAction aActionType);
1115 RCntModel* iCntSvr; //was RDbNamedDatabase iDatabase;
1116 CProxyFactory* iProxyFactory; //was RDbs iDbsSession;
1117 TDbConnState iDbConnectionState; //was CContactClientSession* iContactClientSession;
1118 CDataBaseChangeObserver* iDataBaseObserver; //was CPrivateDbChangeNotifier* iDbChangeNotifier;
1119 CCntIdleSorter* iIdleSorter; //was CPrivateSvrSessionManager* iServerSessionManager;
1120 CPrivConverter* iConv; //was TContactItemId iLastLockedContactId;
1121 TBool iTablesOpen; //was TContactItemId iTemplateId;
1122 CContactItemViewDef* iAllFieldsView; //was TContactItemId iOwnCardId;
1123 TUid iDbViewContactType; //used to select which contact type to sort / search on
1125 //These two members are accessed via the inline functions!
1126 CContactIdArray* iCardTemplateIds;
1127 CContactIdArray* iGroupIds;
1129 CCntTemplateCache* iTemplateCache; //was CContactTables* iItemTable;
1130 CContactTextDef* iTextDef; //remains
1131 CContactIdArray* iSortedItems; //remains
1132 CContactViewDef* iView; //remains
1134 // Used in SetLastSyncDateL() and GetLastSyncDateL()
1135 TTime iSyncDate; //was TInt64 iMachineUniqueId;
1136 TCollationMethod iCollateMethod; //remains: used for sorting contacts
1138 TInt iAsyncActivityCount;
1139 CContactSynchroniser* iContactSynchroniser; //a handle to the synchroniser plugin
1140 CArrayFix<TSortPref>* iSortOrder; // holds a sort order passed into SortL(), as in cntmodelv1,
1141 // for delayed deletion to maintain backwards compatibility
1145 class CContactChangeNotifier : public CBase
1146 /** Receives events reporting changes to a contact database.
1148 After the change notifier has been created, it notifies the specified
1149 observer whenever a change takes place to the database.
1156 IMPORT_C ~CContactChangeNotifier();
1157 IMPORT_C static CContactChangeNotifier* NewL(CContactDatabase& aDatabase, MContactDbObserver *aObserver);
1159 CContactChangeNotifier(CContactDatabase& aDatabase, MContactDbObserver *aObserver);
1162 CContactDatabase &iDatabase;
1163 MContactDbObserver* iObserver;
1167 /** The UID of the default vCard converter implemented by an ECom plugin.
1171 #define KUidEComCntVCardConverterDefaultImplementation 0x102035F9
1172 /** The UID of the default vCard converter plugin implementation. This
1173 implementation is independent of the plugin framework used.
1177 #define KUidVCardConvDefaultImpl KUidEComCntVCardConverterDefaultImplementation
1179 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
1181 /** The UID of the vCard converter ECom plugin interface.
1185 const TUid KUidEcomCntVCardConverterInterface = {0x102035F7};
1187 /** The UID of the phone number parser ECom plugin interface.
1191 const TUid KUidEcomCntPhoneNumberParserInterface = {0x102035FA};
1193 /** The UID of PBAP vCard Converter plugin Implementation.
1197 #define KUidPBAPVCardConvImpl 0xA00015C1
1199 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
1201 class TPluginParameters
1203 Class used to pack the extra arguments required for a PBAP conveter,
1204 PBAP client provides these arguments using overloaded CContactDatabase::ExportSelectedContacts.
1210 TPluginParameters(TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel);
1211 TInt64 GetFilter()const;
1212 MConverterCallBack* GetCallback()const;
1213 TVCardVersion GetExportVersion()const;
1214 TBool IsExportTel()const;
1217 MConverterCallBack* iCallback;
1218 TVCardVersion iVersion;
1222 inline TBool TPluginParameters::IsExportTel()const
1226 inline TInt64 TPluginParameters::GetFilter()const
1231 inline MConverterCallBack* TPluginParameters::GetCallback()const
1236 inline TVCardVersion TPluginParameters::GetExportVersion()const
1241 inline TPluginParameters::TPluginParameters(TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel):iFilter(aContactFieldFilter), iCallback(aCallback), iVersion(aVersion), iExportTel(aExportTel)
1245 class CContactConverter : public CBase
1246 /** Provides functionality to import and export vCards.
1247 One or more vCards can be imported from a read stream (the vCards are converted
1248 into contact items and added to the database). Also, contact items can be exported as vCards.
1254 virtual CArrayPtr<CContactItem>* ImportL(CContactDatabase& aDb,RReadStream& aReadStream,TBool& aImportSuccessful,TInt aOptions,TBool aImportSingle)=0;
1255 virtual void ExportL(CContactDatabase& aDb,const CContactIdArray& aSelectedContactIds,RWriteStream& aWriteStream,TInt aOptions,const Versit::TVersitCharSet aCharSet,TBool aExportPrivateFields, TInt aCommitNumber=10)=0;
1259 class CContactEcomConverter : public CContactConverter
1261 It provides Ecom Framework based facilities to resolve and load the appropriate implementations at run-time.
1262 The framework supplies a default resolver for selecting appropriate implementations.
1268 static CContactEcomConverter* NewL(TUid aImplementationUid);
1269 static CContactEcomConverter* NewL(TUid aImplementationUid, TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel);
1270 inline virtual ~CContactEcomConverter();
1275 inline CContactEcomConverter* CContactEcomConverter::NewL(TUid aImplementationUid)
1276 /** Allocates and instantiates an interface implementation to satisfy the specified interface.
1277 @param aImplementationUid Denotes the type of implemetation that needs to be loaded.
1278 @return A pointer to a newly allocated and initialised object of type CContactEcomConverter. */
1281 TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
1282 _FOFF(CContactEcomConverter,
1284 return reinterpret_cast<CContactEcomConverter*>(ptr);
1287 inline CContactEcomConverter* CContactEcomConverter::NewL(TUid aImplementationUid, TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel)
1288 /** Allocates and instantiates an interface implementation for PBAP export.
1289 @param aImplementationUid Denotes the type of implemetation that needs to be loaded.
1290 @param aContactFieldFilter Specifies contact fields to be exported.
1291 @param aCallback Callback to client for providing intra-contact properties.
1292 @param aVersion Denotes the vCard version for contact export.
1293 @return A pointer to a newly allocated and initialised object of type CContactEcomConverter. */
1296 TPluginParameters partr(aContactFieldFilter,aCallback,aVersion,aExportTel);
1298 TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
1299 _FOFF(CContactEcomConverter,
1300 iDtor_ID_Key), &partr);
1301 return reinterpret_cast<CContactEcomConverter*>(ptr);
1304 inline CContactEcomConverter::~CContactEcomConverter()
1305 /** The destruction of the interface implementation referred to by iDtor_ID_Key */
1307 REComSession::DestroyedImplementation(iDtor_ID_Key);
1310 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
1311 class CContactPhoneNumberParser : public CBase
1312 /** Provides functionality to extract the real phone number from a contact's phone number field.
1318 virtual void ExtractRawNumber(const TDesC& aTextualNumber, TDes& aRawNumber)=0;
1322 class CContactEcomPhoneNumberParser : public CContactPhoneNumberParser
1323 /** It provides Ecom Framework based facilities to resolve and load the appropriate implementations at run-time.
1324 The framework supplies a default resolver for selecting appropriate implementations.
1330 static CContactEcomPhoneNumberParser* NewL(TUid aImplementationUid);
1331 inline virtual ~CContactEcomPhoneNumberParser();
1336 inline CContactEcomPhoneNumberParser* CContactEcomPhoneNumberParser::NewL(TUid aImplementationUid)
1337 /** Allocates and Instantiates an interface implementation to satisfy the specified interface.
1338 @param aImplementationUid denotes the type of implemetation that need to be loaded.
1339 @return A pointer to a newly allocated and initialised object of type CContactEcomPhoneNumberParser. */
1341 TAny* ptr = REComSession::CreateImplementationL(aImplementationUid,
1342 _FOFF(CContactEcomPhoneNumberParser,
1344 return reinterpret_cast<CContactEcomPhoneNumberParser*>(ptr);
1347 inline CContactEcomPhoneNumberParser::~CContactEcomPhoneNumberParser()
1348 /** The destruction of the interface implementation referred to by iDtor_ID_Key */
1350 REComSession::DestroyedImplementation(iDtor_ID_Key);
1352 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
1354 inline TInt CContactDatabase::TemplateCount() const
1355 /** Gets the number of contact card templates that exist in the database.
1356 This does not include the system template.
1358 @return The number of contact card templates that exist in the database. */
1359 { return iCardTemplateIds->Count(); }
1361 inline TInt CContactDatabase::GroupCount() const
1362 /** Gets the number of groups that exist in the database.
1364 @return The number of groups that exist in the database. */
1365 { return iGroupIds->Count(); }
1367 inline TInt CContactDatabase::NullUidValue()
1368 /** Gets the NULL contact ID value.
1370 @return KNullContactId. */
1371 { return KNullContactId; }
1373 inline TUid CContactItemViewDef::operator[](TInt aIndex) const
1374 /** Gets the field type located at a specified index position within the field type array.
1376 @param aIndex The position of the field type in the array, relative to zero. It
1377 must be non-negative and less than the number of objects in the array otherwise the
1378 function raises a panic.
1379 @return The field type located at index aIndex within the array (this is equivalent to a
1381 { return iFieldTypes[aIndex]; }
1383 inline TInt CContactItemViewDef::Count() const
1384 /** Gets the number of field types in the view definition.
1386 @return The number of field types in the view definition. */
1387 { return iFieldTypes.Count(); }
1389 inline void CContactItemViewDef::Reset()
1390 /** Deletes all field types from the view definition's field type array. */
1391 { iFieldTypes.Reset(); }
1393 inline CContactItemViewDef::TUse CContactItemViewDef::Use() const
1394 /** Gets the view definition's use.
1396 @return The current TUse setting. */
1399 inline void CContactItemViewDef::SetUse(CContactItemViewDef::TUse aUse)
1400 /** Sets the view definition's use.
1402 @param aUse The new TUse setting. */
1405 inline CContactItemViewDef::TMode CContactItemViewDef::Mode() const
1406 /** Gets the view definition's mode.
1408 @return The current TMode setting. */
1411 inline void CContactItemViewDef::SetMode(CContactItemViewDef::TMode aMode)
1412 /** Sets the view definition's mode.
1414 @param aMode The new TMode setting. */
1417 inline CContactDatabase::TSortPref::TSortPref()
1418 : iOrder(EAsc), iFieldType(KNullUid)
1419 /** Constructs a TSortPref object. The order is initialised to EAsc and the field
1425 inline CContactDatabase::TSortPref::TSortPref(TFieldType aFieldType,TOrder aOrder)
1426 : iOrder(aOrder), iFieldType(aFieldType)
1427 /** Constructs the TSortPref object with a field type and an order.
1428 @param aFieldType Specifies the field type to sort on.
1429 @param aOrder Specifies the sort order.
1435 /** A class that manages the asynchronous open operation for a CContactDatabase.
1437 The object can be deleted before the asynchronous open completes. This will set
1438 the state of the client supplied TRequestStatus to KErrCancel.
1440 When the client supplied TRequestStatus is completed with KErrNone the TakeDatabase()
1441 method is called to pass ownership of the open database to the client.
1446 @see CContactDatabase::OpenL()
1448 class CContactOpenOperation : private CActive
1451 IMPORT_C CContactDatabase* TakeDatabase();
1452 IMPORT_C ~CContactOpenOperation();
1454 static CContactOpenOperation* NewL(TRequestStatus& aPtrStatus);
1455 static CContactOpenOperation* NewL(const TDesC& aFileName, TRequestStatus& aPtrStatus);
1458 // from CActive (for BC reasons)
1460 TInt RunError(TInt aError);
1463 CContactOpenOperation (TRequestStatus& aClientStatus);
1464 void ConstructL (const TDesC& aFileName = KNullDesC);
1467 TRequestStatus* iClientStatus;
1468 CContactDatabase* iContactDatabase;
1472 #endif //__CNTDB_H__