Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 // Copyright (c) 2001-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.
16 #ifndef __CNTVIEWBASE_H__
17 #define __CNTVIEWBASE_H__
26 class CViewContactExtension;
27 class CContactViewBase;
28 class CContactRemoteViewNotifier;
29 class CIdleContactSorter;
30 class CContactViewFindConfigInterface;
31 class CViewContactSortPlugin;
32 class TSortPluginViewParams;
34 /** View preferences for sorted contact views.
36 This is used to specify the types of contact item that should be sorted and
37 included in the view and the behaviour for items that cannot be sorted because
38 they do not have content in any of the fields specified in the view's sort
41 The default behaviour is to include contact cards only and to sort contact
42 cards without content in any of the sort order fields using the first available
43 field containing any text.
45 The view preferences for all concrete contact view classes can be retrieved
46 using their implementation of CContactViewBase::ContactViewPreferences().
47 The view preferences are set during construction of a CContactLocalView.
52 enum TContactViewPreferences
54 /** Only contact cards (of type KUidContactCard or KUidContactOwnCard) are included
55 in the view. This is the default. */
56 EContactsOnly =0x00000000,
57 /** Only contact groups (of type KUidContactGroup) are included in the view. */
58 EGroupsOnly =0x00000001,
59 /** Contact groups and contact cards (of type KUidContactGroup, KUidContactCard
60 or KUidContactOwnCard) are included in the view. */
61 EContactAndGroups =0x00000002,
62 /** Excludes contact items from the view which don't have content in any of the
63 fields specified in the sort order. */
64 EIgnoreUnSorted =0x00000004,
65 /** Includes contacts in the view which don't have content in any of the fields
66 specified in the sort order. These contacts are placed in an unsorted contact
67 list which is located before the sorted list. */
68 EUnSortedAtBeginning =0x00000008,
69 /** Includes contacts in the view which don't have content in any of the fields
70 specified in the sort order. These contacts are placed in an unsorted contact
71 list which is located after the sorted list. */
72 EUnSortedAtEnd =0x00000010,
73 /** Fields containing a single white space only are treated as empty, and therefore
75 ESingleWhiteSpaceIsEmptyField =0x00000020,
76 /** Only ICC entries (of type KUidContactICCEntry) are included in the view. */
77 EICCEntriesOnly =0x00000040,
78 /** Only contact cards and ICC entries (of type KUidContactCard, KUidContactOwnCard
79 or KUidContactICCEntry) are included in the view. */
80 EICCEntriesAndContacts =0x00000080
84 class TContactViewEvent
85 /** Identifies a contact view event.
87 Sent by contact views when notifying their observers of an event.
89 @see MContactViewObserver::HandleContactViewEvent()
95 /** Identifies the event's type. */
98 /** The observed view's state has changed from EReady to either ENotReady or EInitializing,
99 so is not available for use. */
101 /** The observed view's state has changed from ENotReady or EInitializing to EReady
102 so is available for use. */
104 /** The observed view's sort order has changed, so observer views need to update
107 /** An error occurred when sorting the observed view or when appending an observer
108 to its observer array.
110 The error code is provided in iInt. */
112 /** An error occurred in the contacts server.
114 The error code is provided in iInt. */
116 /** An error occurred when setting the range for a CContactSubView.
118 The error code is provided in iInt. */
120 /** An item has been added to the observed view.
122 The ID of the added item is provided in iContactId and the index into the
123 observed view of the added item is provided in iInt.
124 Exception from this are the first version of CContactFindView, CContactSubView and
125 CContactGroupView classes.
126 For these classes, iInt has KErrNone value */
129 /** An item has been removed from the observed view.
131 The ID of the removed item is provided in iContactId and the index into the
132 observed view of the item is provided in iInt.
133 Exception from this are the first version of CContactFindView and CContactSubView classes.
134 For these classes, iInt has KErrNone value */
137 /** A change has occurred in a contact group, for instance a contact item has been
138 moved into or out of the group.
140 The ID of the group affected is provided in iContactId. */
144 inline TContactViewEvent();
145 inline TContactViewEvent(TEventType aEventType,TInt aInt = KErrUnknown,TContactItemId aContactId = KErrUnknown);
147 /** The type of event. */
148 TEventType iEventType;
149 /** The error code (where relevant) or the index of the contact item added to/removed
150 from the underlying view. */
152 /** The ID of the contact item that has been added or removed or the group ID, where
154 TContactItemId iContactId;//ContactId that has been added / removed if relevant.
158 struct TContactIdWithMapping
159 /** A struct used internally by filtered and group views to pair a contact item
160 ID and its index into the underlying view.
165 /** The contact item's ID. */
167 /** The index of the item into the view's underlying view. */
172 class MContactViewObserver
173 /** The interface for a contact view observer.
175 Objects that need to observe a contact view should implement this interface.
176 The view observer should be passed to the observed view's OpenL() or Open()
177 function. This adds the observer to the view's observer array: a view can
178 have more than one observer. The observers receive notifications when the
179 observed view becomes ready for use and when changes occur in it.
181 Many contact view classes implement this interface to observe an underlying
182 view. They in turn send notification to any objects observing them.
184 @see CContactViewBase::NotifyObservers()
185 @see CContactViewBase::NotifyObserverAsync()
191 /** Handles an event in an observed contact view.
193 @param aView The contact view causing the notification.
194 @param aEvent The event. */
195 virtual void HandleContactViewEvent(const CContactViewBase& aView,const TContactViewEvent& aEvent)=0;
199 class RContactViewSortOrder
200 /** Specifies the sort order for a contact view.
202 It is implemented as an array of TFieldType UIDs, which define the fields
203 whose contents are used to sort on, and their order.
205 The sort order for all concrete contact view classes can be retrieved using
206 their implementation of CContactViewBase::SortOrderL(). The sort order is
207 set during construction of local and remote views.
213 IMPORT_C RContactViewSortOrder();
214 IMPORT_C void Close();
215 IMPORT_C void CopyL(const RContactViewSortOrder& aSortOrder);
216 IMPORT_C void InternalizeL(RReadStream& aStream);
217 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
218 IMPORT_C TInt ExternalizedSize() const;
219 IMPORT_C TBool operator==(const RContactViewSortOrder& aSortOrder) const;
220 inline void AppendL(TFieldType aField);
221 inline TFieldType operator[](TInt aIndex) const;
222 inline TInt Count() const;
224 RArray<TFieldType> iFields;
232 Wrapper around RArray, to container TTextFieldMinimal buffers.
234 Features: minimum size 1, easy resize of array, persistent last counted total.
239 class RFieldBufferArray : public RArray<CContactDatabase::TTextFieldMinimal>
242 explicit RFieldBufferArray();
244 void ResizeL(TInt aNewSize);
247 TInt LastTotal() const;
255 class CViewContact : public CBase
256 /** The representation of a contact item used in contact views.
258 It stores the contact item ID and other information. This includes a buffer
259 holding the contents of all the item's fields, an array of indexes into the
260 buffer indicating the start position of each field and a hint bit field (a
261 combination of CContactDatabase::TContactViewFilter values) which is used
264 The fields are defined by the view's sort order (RContactViewSortOrder).
270 /** Defines whether the contact view item is a contact group. */
271 enum TViewContactType
273 /** The contact view item is not a contact group. */
275 /** The contact view item is a contact group (CContactGroup). */
278 IMPORT_C CViewContact(TContactItemId aId);
279 IMPORT_C static CViewContact* NewL(const CViewContact& aContact);
280 IMPORT_C static CViewContact* NewLC(TContactItemId aId);
281 IMPORT_C static CViewContact* NewL(TContactItemId aId, TInt aLength);
282 static CViewContact* NewLC(RReadStream& aStream);
284 IMPORT_C ~CViewContact();
285 IMPORT_C void InternalizeL(RReadStream& aStream);
286 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
287 IMPORT_C TInt ExternalizedSize() const;
288 IMPORT_C TInt FieldCount() const;
289 IMPORT_C TPtrC Field(TInt aPosition) const;
290 IMPORT_C TBool ContactMatchesFilter(TInt aFilter) const;
291 IMPORT_C void AddFieldL(const TDesC& aField);
292 IMPORT_C TBool IsSortable() const;
293 IMPORT_C void SetFirstFieldForBlankContactL(const TDesC& aFirstField);
294 IMPORT_C void Reset();
295 IMPORT_C TInt ContactHint() const;
296 IMPORT_C void SetContactHint(TInt aHint);
297 IMPORT_C TUid ContactTypeUid() const;
298 IMPORT_C void SetContactTypeUid(TUid aUid);
300 inline TContactItemId Id() const;
301 inline TViewContactType ContactType() const;
303 inline void SetId(TContactItemId aId);
304 inline void SetContactType(CViewContact::TViewContactType aContactType);
305 static TBool HintFieldMatchesFilter(TInt aHintField, TInt aFilter);
306 TPtrC FindFirstPopulatedField(TInt aOffset, TInt& aFoundPosition) const;
308 #ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__
309 IMPORT_C void ChangeToLightweightObject();
310 TBool IsLightweightObject() const;
311 void CopyL(const CViewContact& aContact);
312 #endif //__SYMBIAN_CNTMODEL_USE_SQLITE__
315 void ConstructL(TInt aLength = 0);
316 void ConstructL(const CViewContact& aContact);
317 friend class CContactViewBase;
320 TViewContactType iContactType;
321 CViewContactExtension* iExtension;
322 RArray<TInt> iTextIndexes;
327 * A view can be named or un-named. An un-named view has a fixed sort order - the
328 * only way to change this is by closing the object and creating a new one with a
329 * different order. Named views may have their sort order changed. When this is
330 * done, first all observers will be informed that the view is 'unavailable'. This
331 * notification will be followed by 'sort order changed' and 'ready'. Only once
332 * the 'ready' notification has been received may the view be used again.
334 class CContactViewBase : public CBase
335 /** The abstract base class for all contact view classes.
337 All contact views operate asynchronously, so users of the view must observe
338 it, by implementing the MContactViewObserver interface. Immediately after
339 construction, views are not in a usable state (the underlying data may be
340 being sorted, for instance). Only after the user has received a TContactViewEvent::EReady
341 event may the view be used.
343 View observers are also notified when changes occur, for instance when the
344 view's state changes (see TState), when an error occurs, or when an item is
351 class CContactViewBaseExtension : public CBase
352 /** An extension class that holds member data added in v7.0s.
354 It was created for binary compatibility purposes.
359 static CContactViewBaseExtension* NewL();
360 ~CContactViewBaseExtension();
363 CContactViewBaseExtension();
367 /** A standard error code that is passed to view observers by NotifyObservers()
368 (unless its value is KErrNone). */
370 /** The UID of the view's find configuration plug-in.
372 On construction, this is initialised to KNullUid.
374 The plug-in is loaded when ContactsMatchingCriteriaL(), ContactsMatchingPrefixL()
375 or MatchesCriteriaL() is called. */
377 /** The UID of the view's sort plug-in. */
380 CContactViewFindConfigInterface* iFindPluginImpl;
381 CViewContactSortPlugin* iSortPluginImpl;
382 TCollationMethod iCollationMethod;
383 friend class CContactViewBase;
385 class TVirtualFunction1Params
386 /** Holds the two parameters passed to the helper method GetContactIdsL() from
387 the reserved function CContactViewBase_Reserved_1(). It has an inline constructor
388 to initialise the data members.
393 /** Inline constructor to initialize member data
394 @param aIndexes Pointer to an array of indexes in a view
395 @param aIdArray Pointer to array of contact IDs */
396 inline TVirtualFunction1Params(const CArrayFix<TInt>* aIndexes, CContactIdArray* aIdArray) :iIndexes(aIndexes), iIdArray(aIdArray){};
397 /** Pointer to an array of indexes in a view */
398 const CArrayFix<TInt>* iIndexes;
399 /** Pointer to array of contact IDs */
400 CContactIdArray* iIdArray;
402 class TVirtualFunction2Params
403 /** Holds the two parameters passed to the method GetContactsMatchingFilterL()
404 from the reserved function CContactViewBase_Reserved_1(). It has an inline
405 constructor to initialise the data members.
409 /** Inline constructor to initialize member data.
410 @param aFilter Filter for the contacts
411 @param aMatchingContacts Contacts matching a particular criterion */
412 inline TVirtualFunction2Params(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts) : iFilter(aFilter), iMatchingContacts(aMatchingContacts){};
414 /** Filter for the contacts. */
416 /** List of contacts matching the criteria. */
417 RArray<TContactIdWithMapping>& iMatchingContacts;
419 class TVirtualFunction3Params
420 /** Holds the two parameters passed to the method InsertContactInView() from the
421 reserved function CContactViewBase_Reserved_1(). It has an inline
422 constructor to initialise the data members.
427 inline TVirtualFunction3Params(RPointerArray<CViewContact>& aContacts, const CViewContact* aNewContact) :iContacts(aContacts), iNewContact(aNewContact){};
428 RPointerArray<CViewContact>& iContacts;
429 const CViewContact* iNewContact;
433 This controls whether a search term can occur anywhere in a contact item field,
434 or just at the beginning of the field. */
437 /** The search uses full wildcard matching so that the search string can occur anywhere
438 in the item's fields. */
440 /** The search uses partial wildcard matching so that the search string can only
441 occur at the beginning of the item's fields. */
444 /** Identifies the functions that have been added to CContactViewBase, or that
445 may be added in the future. This identifier is passed to the reserved virtual
446 function CContactViewBase_Reserved_1() and enables the addition of new virtual
447 methods without breaking binary compatibility. */
450 /** Identifies the function CContactViewBase::GetContactIdsL(). */
451 ECContactViewBaseVirtualFunction1,
452 /** Identifies the function CContactViewBase::GetContactsMatchingFilterL(). */
453 ECContactViewBaseVirtualFunction2,
454 // communication with Sort Plug-in
455 /** Identifies the function CContactViewBase::InsertContactInView(). */
456 ECContactViewBaseVirtualFunction3,
459 /** Defines the contact view states. */
462 /** The view is initialising.
464 This is the view's state immediately after construction or after a significant change
465 (e.g CurrentDatabaseChanged or UnknownChanges), indicating that it can't be used yet. */
467 /** The view is ready to be used. */
469 /** The view is not ready to be used, for instance immediately after the sort order
470 has changed, or after an error has occurred. */
474 IMPORT_C void OpenL(MContactViewObserver& aObserver);
475 IMPORT_C TInt Open(MContactViewObserver& aObserver);
476 IMPORT_C TBool Close(const MContactViewObserver& aObserver);
477 /** Returns the contact item ID at the specified index into the view.
479 @capability ReadUserData
480 @param aIndex Index of the contact item ID into the view.
481 @return The contact item ID. */
482 virtual TContactItemId AtL(TInt aIndex) const=0;
483 /** Returns the contact item at the specified index into the view.
485 @capability ReadUserData
486 @param aIndex Index of the contact item into the view.
487 @return The contact item. */
488 virtual const CViewContact& ContactAtL(TInt aIndex) const =0;
489 /** Returns the number of contact items in the view.
491 @capability ReadUserData
492 @return The number of contact items in the view. */
493 virtual TInt CountL() const=0;
494 /** Returns the index into the view of the specified contact item.
496 @capability ReadUserData
497 @param aId The contact item ID to search for.
498 @return The index into the view of the contact item ID, or KErrNotFound if
499 no matching ID can be found. */
500 virtual TInt FindL(TContactItemId aId) const=0;
501 /** Returns a descriptor containing the contents of all fields for an item in the view.
503 The field separator is used to separate the contents of each field. It is
504 not appended to the last field.
506 @capability ReadUserData
507 @param aIndex The index of the contact item into the view.
508 @param aSeparator The string to use to separate the fields.
509 @return Pointer to the contact item descriptor. */
510 virtual HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const=0;
511 IMPORT_C virtual void ContactsMatchingCriteriaL(const MDesCArray& aFindWords,RPointerArray<CViewContact>& aMatchedContacts);
512 /** Gets the view preferences.
514 @capability ReadUserData
515 @return The view preferences. */
516 virtual TContactViewPreferences ContactViewPreferences()=0;
517 /** Gets the view's sort order.
519 @capability ReadUserData
520 @return The sort order. */
521 virtual const RContactViewSortOrder& SortOrderL() const = 0;
522 IMPORT_C virtual void ContactsMatchingPrefixL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts);
523 //This is a reserved virtual exported function that is used for BC proofing against present
524 //and future additions of new exported virtual functions. Existing exported virtual methods
525 //that broke BC are now non-virtual exported helper functions called from this method.
526 //All derived classes of CContactViewBase that are public must mandatorily
527 //implement this reserved exported virtual method.
528 IMPORT_C virtual TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
529 //New exported method to set the ECOM plug-in to be used
530 IMPORT_C void SetViewFindConfigPlugin(TUid aUid);
531 IMPORT_C TUid GetViewFindConfigPlugin();
532 IMPORT_C virtual void GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds);
533 IMPORT_C TInt Error() const;
534 IMPORT_C TUid GetViewSortPluginImplUid() const;
537 IMPORT_C ~CContactViewBase();
538 IMPORT_C void ConstructL();
540 IMPORT_C CContactViewBase(const CContactDatabase& aDb);
541 IMPORT_C void NotifyObservers(const TContactViewEvent& aEvent);
542 IMPORT_C TInt NotifyObserverAsync(MContactViewObserver& aObserver,const TContactViewEvent& aEvent);
543 IMPORT_C static TBool IdsMatch(const CViewContact& aFirst,const CViewContact& aSecond);
544 IMPORT_C HBufC* FieldsWithSeparatorLC(const RPointerArray<CViewContact>& aContacts,TInt aIndex,const TDesC& aSeparator) const;
545 //Find helper functions
546 IMPORT_C virtual TBool MatchesCriteriaL(const CViewContact& aContact,const MDesCArray& aFindWords);
547 IMPORT_C static TBool MatchesCriteriaL(const CViewContact& aContact,const MDesCArray& aFindWords, TSearchType aSearchType);
548 IMPORT_C static TBool MatchesCriteriaL(const CViewContact& aContact,const MDesCArray& aFindWords, TSearchType aSearchType,CContactViewBase::CContactViewBaseExtension* aExtension);
549 IMPORT_C static TBool IdsEqual(const TContactIdWithMapping& aFirst,const TContactIdWithMapping& aSecond);
550 IMPORT_C static TBool IndexesEqual(const TContactIdWithMapping& aFirst,const TContactIdWithMapping& aSecond);
551 IMPORT_C static TInt CompareFieldsL(const CViewContact& aFirst, const CViewContact& aSecond);
552 // View Sort Plugin changes
553 IMPORT_C static TInt CompareContactIds(const CViewContact& aFirst, const CViewContact& aSecond);
554 IMPORT_C static TBool ContactIsSortable(const CViewContact& aContact);
555 IMPORT_C TInt CompareContactsAndIdsL(const CViewContact& aFirst, const CViewContact& aSecond) const;
556 protected: // these are needed by CContactLocalView only
557 TInt InsertContactInView(RPointerArray<CViewContact>& aContacts, const CViewContact* aNewContact, TBool aSortByIdOnly, TInt* aIndex) const;
558 TBool IsContactSortable(const CViewContact& aContact, TContactViewPreferences& aViewPreferences) const;
559 CViewContactSortPlugin* SortPluginImpl() const;
560 TUid FindSortPluginImplL (const TDesC8& aSortPluginName,TBool aWildCard=EFalse) const;
561 TUid FindDefaultViewSortPluginImplL () const;
562 void LoadViewSortPluginL (TUid aSortPluginUid,TContactViewPreferences& aViewPreferences);
565 static TInt AsyncNotifyCallBack(TAny* aSelf);
566 static CDesCArrayFlat* CreateFindWordArrayLC(const MDesCArray& aFindWords, TSearchType aSearchType);
567 static TBool ContactMatchesCriteriaL(const CViewContact& aContact,const MDesCArray& aFindWords,CContactViewBase::CContactViewBaseExtension* aExtension);
568 void MatchContactsL(const MDesCArray& aFindWords,RPointerArray<CViewContact>& aMatchedContacts, TSearchType aSearchType);
569 static TInt CompareFieldsWithCollationLevel(const CViewContact& aFirst, const CViewContact& aSecond,
570 TInt aCollationLevel, TCollationMethod* aCollateMethod);
571 TInt GetErrorValueFromExtensionClass();
572 void GetContactsMatchingFilterL(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts);
573 TInt TextCompareFieldsL(const CViewContact& aFirst, const CViewContact& aSecond) const;
577 struct TObserverAndEvent
579 TContactViewEvent iAsyncEvent;
580 MContactViewObserver* iObserverToNotify;
583 // Reference to CContactDatabase class.
584 const CContactDatabase& iDb;
585 // Different Contacts view states.
587 // The pointer to the ContactViewBase BC extension class.
588 CContactViewBaseExtension* iExtension;
590 RPointerArray<MContactViewObserver> iObserverArray;
591 CIdle* iAsyncNotifier;
592 RArray<TObserverAndEvent> iOutstandingNotifications;
595 inline TInt CContactViewBase::GetErrorValueFromExtensionClass()
597 return iExtension->iError;
600 class MLplPersistenceLayerFactory;
602 #ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__
604 class CViewContactManager;
606 #else //__SYMBIAN_CNTMODEL_USE_SQLITE__
610 #endif //__SYMBIAN_CNTMODEL_USE_SQLITE__
612 class CContactLocalView : public CContactViewBase, public MContactDbObserver
613 /** An instantiable base class for contact views.
615 The data associated with a local view is allocated within the client's memory
616 space; CContactRemoteView should be used in preference if the view is likely
617 to be shared between multiple clients. It is kept up to date by receiving
618 change events from the underlying CContactDatabase object which it observes.
619 The view preferences and sort order are specified on construction.
625 IMPORT_C static CContactLocalView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
626 IMPORT_C static CContactLocalView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,
627 const TDesC8& aSortPluginName);
628 IMPORT_C static CContactLocalView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,
629 MLplPersistenceLayerFactory* aFactory,const TDesC8& aSortPluginName);
631 IMPORT_C const RContactViewSortOrder& SortOrder() const;
632 public: // From CContactViewBase.
633 TContactItemId AtL(TInt aIndex) const;
635 TInt FindL(TContactItemId aId) const;
636 HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const;
637 const CViewContact& ContactAtL(TInt aIndex) const;
638 TContactViewPreferences ContactViewPreferences();
639 const RContactViewSortOrder& SortOrderL() const;
640 void NotifySortError(TInt aError);
641 //All derived classes of CContactViewBase that are public should mandatorily
642 //implement this reserved exported virtual method.
643 IMPORT_C TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
645 IMPORT_C ~CContactLocalView();
646 IMPORT_C CContactLocalView(const CContactDatabase& aDb,TContactViewPreferences aContactTypes);
647 CContactLocalView(const CContactDatabase& aDb,TContactViewPreferences aContactTypes,MLplPersistenceLayerFactory* aIterFactory);
648 IMPORT_C void ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder);
649 void ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder, const TBool aUseNamedPlugin, const TDesC8& aSortPluginName);
650 IMPORT_C virtual void SortL(const RContactViewSortOrder& aSortOrder);
651 IMPORT_C virtual TInt InsertL(TContactItemId aId);
652 IMPORT_C virtual TInt RemoveL(TContactItemId aId);
654 void SetState(TState aState);
655 private: // From MContactDbObserver.
656 virtual void HandleDatabaseEventL(TContactDbObserverEvent aEvent);
660 #ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__
661 void SortComplete(TInt aSortErr);
662 void SetSortOrderL(const RContactViewSortOrder& aSortOrder);
665 friend class CViewContactManager;
666 #else //__SYMBIAN_CNTMODEL_USE_SQLITE__
668 TInt DoReadIncrementL();
670 void InitialiseSortL(const RContactViewSortOrder& aSortOrder, TBool aChangingSortOrder);
673 void ContactsArraySortL();
674 TBool ContactCorrectType(TUid aType,TContactViewPreferences aTypeToInclude);
675 #endif //__SYMBIAN_CNTMODEL_USE_SQLITE__
677 private: // Metheds for event handling
678 void HandleOutstandingEvents();
679 void HandleOutstandingEventL();
680 friend class CIdleContactSorter;
683 This is set during construction or when SortL() is called. */
684 RContactViewSortOrder iSortOrder ;
686 IMPORT_C virtual void CContactLocalView_Reserved_1();
687 IMPORT_C virtual void CContactLocalView_Reserved_2();
690 MLplPersistenceLayerFactory* iFactory;
691 RPointerArray<CViewContact> iContacts;
692 RPointerArray<CViewContact> iUnSortedContacts;
693 RArray<TContactDbObserverEvent> iOutstandingEvents;
694 CIdleContactSorter* iAsyncSorter;
696 #ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__
697 CViewContactManager* iViewCntMgr;
698 #else //__SYMBIAN_CNTMODEL_USE_SQLITE__
699 CViewIterator* iViewIterator;
700 #endif //__SYMBIAN_CNTMODEL_USE_SQLITE__
702 CContactTextDef* iTextDef;
703 TContactViewPreferences iViewPreferences;
708 class RContactRemoteView : public RSubSessionBase
709 /** This class is used internally by remote contact views as the handle to the
710 server side view object.
712 @see CContactRemoteViewBase
718 void OpenL(const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName);
719 void OpenL(const CContactDatabase& aDb,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName);
721 public: // From CContactViewBase
722 TContactItemId AtL(TInt aIndex) const;
723 CViewContact* ContactAtL(TInt aIndex);
725 TInt FindL(TContactItemId aId) const;
726 HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const;
727 const RContactViewSortOrder& SortOrderL();
729 void ContactsMatchingCriteriaL(const MDesCArray& aFindWords,RPointerArray<CViewContact>& aMatchedContacts, TBool aPrefixSearch,TUid aUid);
730 void ChangeSortOrderL(const RContactViewSortOrder& aSortOrder);
731 void GetSortOrderL(RContactViewSortOrder& aSortOrder);
732 TContactViewPreferences ContactViewPreferencesL();
734 void RequestViewEvent(TPckgBuf<TContactViewEvent>& aEvent,TRequestStatus& aStatus);
735 TInt CancelRequestViewEvent();
736 void GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds);
737 void GetContactsMatchingFilterL(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts);
738 TUid GetViewSortPluginImplUidL() const;
740 HBufC8* PackageSortOrderLC(const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes) const;
741 HBufC8* PackageSortOrderAndPluginDetailsLC(const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,const TUid& aSortPluginImplUid,const TDesC8& aSortPluginName) const;
743 CViewContact* iContact;
744 RContactViewSortOrder iSortOrder ;
748 NONSHARABLE_CLASS(CContactRemoteViewBase) : public CContactViewBase
749 /** Base class for all remote contact view classes.
751 It implements all the pure virtual functions in CContactViewBase and additionally
752 it handles remote view notifications. The data associated with remote views
753 is allocated within the memory space of the contacts server. This means that
754 multiple clients can share the same server side view object, thereby reducing
755 the overhead associated with initial sorting of the view data and keeping
756 it in sync with the underlying data. Remote views should therefore be used
757 when the same view is likely to be needed by more than one client.
762 public: // From CContactViewBase.
763 TContactItemId AtL(TInt aIndex) const;
765 TInt FindL(TContactItemId aId) const;
766 HBufC* AllFieldsLC(TInt aIndex,const TDesC& aSeparator) const;
767 const CViewContact& ContactAtL(TInt aIndex) const;
768 TContactViewPreferences ContactViewPreferences();
769 void ContactsMatchingCriteriaL(const MDesCArray& aFindWords,RPointerArray<CViewContact>& aMatchedContacts);
770 void ContactsMatchingPrefixL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts);
771 const RContactViewSortOrder& SortOrderL() const;
772 //All derived classes of CContactViewBase that are public should mandatorily
773 //implement this reserved exported virtual method.
774 TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
775 //This function was virtual in a previous release, if you still need to use it
776 //in a virtual way then you can call it via the Reserved function.
777 //The functionality of this function ,however,remains the same.
778 void GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds);
779 void GetContactsMatchingFilterL(TInt aFilter, RArray<TContactIdWithMapping>& aMatchingContacts);
781 ~CContactRemoteViewBase();
782 CContactRemoteViewBase(const CContactDatabase& aDb);
783 void ConstructL(MContactViewObserver& aObserver);
785 static TInt NotifierCallBack(TAny* aSelf);
786 void HandleContactViewEvent(const TContactViewEvent& aEvent);
788 /** A handle to the server side view. */
789 RContactRemoteView iView;
791 CContactRemoteViewNotifier* iNotifier;
792 /** Cached copy of the count of the local view in the contacts server.
793 If this is KCachedItemCountInvalid then next time CountL is called
794 the current count is retrieved from the contacts server. */
799 class CContactRemoteView : public CContactRemoteViewBase
800 /** An instantiable remote contact view class.
802 Remote views are associated with a CContactLocalView object held in the contacts
803 server. They provide an efficient means for multiple clients to share the
804 same underlying view.
806 The view preferences and sort order are specified on construction.
812 IMPORT_C static CContactRemoteView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
813 IMPORT_C static CContactRemoteView* NewL(MContactViewObserver& aObserver,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,
814 const TDesC8& aSortPluginName);
815 IMPORT_C void GetSortOrderL(RContactViewSortOrder& aSortOrder);
816 //All derived classes of CContactViewBase that are public should mandatorily
817 //implement this reserved exported virtual method.
818 TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
820 ~CContactRemoteView();
821 CContactRemoteView(const CContactDatabase& aDb);
823 void ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
824 void ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypesconst, const TDesC8& aSortPluginName);
828 class CContactNamedRemoteView : public CContactRemoteView
829 /** A named remote contact view.
831 This class enables multiple clients to share a named server side view. It
832 also provides a function to change the sort order. If the sort order is changed,
833 a notification is sent to all users of the named view.
839 IMPORT_C static CContactNamedRemoteView* NewL(MContactViewObserver& aObserver,const TDesC& aName,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
840 IMPORT_C static CContactNamedRemoteView* NewL(MContactViewObserver& aObserver,const TDesC& aName,const CContactDatabase& aDb,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes,
841 const TDesC8& aSortPluginName);
842 IMPORT_C void ChangeSortOrderL(const RContactViewSortOrder& aSortOrder);
843 //All derived classes of CContactViewBase that are public should mandatorily
844 //implement this reserved exported virtual method.
845 TAny* CContactViewBase_Reserved_1(TFunction aFunction,TAny* aParams);
847 ~CContactNamedRemoteView();
848 CContactNamedRemoteView(const CContactDatabase& aDb);
849 void ConstructL(MContactViewObserver& aObserver,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes);
850 void ConstructL(MContactViewObserver& aObserver,const TDesC& aName,const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes, const TDesC8& aSortPluginName);
853 inline TContactViewEvent::TContactViewEvent()
854 /** Empty default constructor. */
857 inline TContactViewEvent::TContactViewEvent(TEventType aEventType,TInt aInt,TContactItemId aContactId) : iEventType(aEventType),iInt(aInt),iContactId(aContactId)
858 /** Constructor with an event type and an optional error code and contact item ID.
860 @param aEventType The event type.
861 @param aInt Optional standard error code.
862 @param aContactId Optional contact item ID. */
865 inline void RContactViewSortOrder::AppendL(TFieldType aField)
866 /** Appends a field type to the sort order object.
868 @param aField The field type to append. */
869 { User::LeaveIfError(iFields.Append(aField)); }
871 inline TFieldType RContactViewSortOrder::operator[](TInt aIndex) const
872 /** Gets an indexed field type.
874 @param aIndex Index of the required field type. A panic occurs if this is
876 @return The field type located at the indexed position in the array. */
877 { return iFields[aIndex]; }
879 inline TInt RContactViewSortOrder::Count() const
880 /** Gets the number of field types in the sort order array.
882 @return The number of field types in the array. */
883 { return iFields.Count(); }
885 inline TContactItemId CViewContact::Id() const
886 /** Gets the view item's ID.
888 @return The view item's ID. */
891 inline CViewContact::TViewContactType CViewContact::ContactType() const
892 /** Gets the view item's type.
894 @return The view item's type. */
895 {return iContactType;}
897 inline void CViewContact::SetId(TContactItemId aId)
898 /** Sets the view item's ID.
900 @param aId The contact item ID. */
903 inline void CViewContact::SetContactType(CViewContact::TViewContactType aContactType)
904 /** Sets the view item's type.
906 @param aContactType The view item's type. */
907 {iContactType=aContactType;}