|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef PBAPCONTACTDBVIEWS_H |
|
17 #define PBAPCONTACTDBVIEWS_H |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <badesca.h> |
|
21 #include <cntdb.h> |
|
22 #include <cntdef.h> |
|
23 #include <cntdbobs.h> |
|
24 #include <cntviewbase.h> |
|
25 #include <cntview.h> |
|
26 |
|
27 #include "pbaprequest.h" |
|
28 |
|
29 |
|
30 class MPbapContactDbViewsCallback |
|
31 { |
|
32 public: |
|
33 virtual void HandleSearchAndSortComplete(TInt aError)=0; |
|
34 }; |
|
35 |
|
36 |
|
37 /** |
|
38 Provides API to search database and sort the results into name or pronunciation |
|
39 field order using contact database views |
|
40 */ |
|
41 class CPbapContactDbViews : public CBase, public MContactViewObserver, public MIdleFindObserver |
|
42 { |
|
43 public: |
|
44 static CPbapContactDbViews* NewL(CContactDatabase& aDatabase); |
|
45 ~CPbapContactDbViews(); |
|
46 |
|
47 public: |
|
48 HBufC* GetContactNameFromIdL(TContactItemId aContactId) const; |
|
49 void GetContactIdsMatchingCriteriaL(SymbianPBAP::TOrder aOrder, SymbianPBAP::TSearchAttribute aSearchAttribute, const TDesC& aSearchValue, CContactIdArray& aResults, MPbapContactDbViewsCallback& aCallback); |
|
50 void CancelSearchAndSortRequest(); |
|
51 |
|
52 void CloseAllViews(); |
|
53 |
|
54 private: |
|
55 CPbapContactDbViews(CContactDatabase& aDatabase); |
|
56 |
|
57 void CreateNameViewL(); |
|
58 void CreatePhoneticViewL(); |
|
59 |
|
60 void AppendField(HBufC* aBuf, TUid aUid, const CContactItemFieldSet& aFieldSet, TBool aLast = EFalse) const; |
|
61 |
|
62 CContactIdArray* GetContactIdsInViewL(CContactViewBase& aView); |
|
63 TBool IsPhoneticViewRequired() const; |
|
64 |
|
65 static TInt SearchAndSortCallback(TAny* aAny); |
|
66 void DoSearchAndSortL(); |
|
67 void DoSortL(); |
|
68 void DoSearchAndSortCallback(); |
|
69 |
|
70 void FindInViewL(CContactViewBase& aView); |
|
71 void FindInPhoneFieldsL(); |
|
72 |
|
73 void HandleIdleFindCompleteL(); |
|
74 void HandleFindInViewCompleteL(); |
|
75 |
|
76 void DoSortSearchResultsL(CContactIdArray& aContactIds); |
|
77 void ResortIdsInViewOrderL(CContactIdArray& aContactIds, CContactViewBase& aView); |
|
78 void CopyToResultsArrayL(const CContactIdArray& aContactIds); |
|
79 |
|
80 void NotifySearchAndSortComplete(TInt aError); |
|
81 void CancelAndCleanup(); |
|
82 |
|
83 private: |
|
84 //from MContactViewObserver |
|
85 void HandleContactViewEvent(const CContactViewBase &aView, const TContactViewEvent &aEvent); |
|
86 |
|
87 //from MIdleFindObserver |
|
88 void IdleFindCallback(); |
|
89 |
|
90 private: |
|
91 enum TSearchAndSortOpState |
|
92 { |
|
93 EIdle, |
|
94 EPendingSearch, |
|
95 ESearching, |
|
96 ESorting |
|
97 }; |
|
98 private: |
|
99 CContactDatabase& iDatabase; |
|
100 |
|
101 CContactLocalView* iNameView; |
|
102 CContactLocalView* iPhoneticView; |
|
103 TBool iNameViewReady; |
|
104 TBool iPhoneticViewReady; |
|
105 |
|
106 TSearchAndSortOpState iOpState; |
|
107 SymbianPBAP::TOrder iOrder; |
|
108 SymbianPBAP::TSearchAttribute iSearchAttribute; |
|
109 HBufC* iSearchValue; |
|
110 |
|
111 CContactFindView* iFindView; |
|
112 CPtrCArray* iSearchValueArray; |
|
113 |
|
114 CIdleFinder* iIdleFinder; |
|
115 CContactItemFieldDef* iFindFieldDef; |
|
116 |
|
117 CAsyncCallBack* iAsyncCallback; |
|
118 |
|
119 private: |
|
120 MPbapContactDbViewsCallback* iCallback; // not owned |
|
121 CContactIdArray* iResults; // not owned |
|
122 }; |
|
123 |
|
124 #endif //PBAPCONTACTDBVIEWS_H |