|
1 /* |
|
2 * Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: An array that manages shared views |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VPBKSIMSTOREIMPL_CSHAREDVIEWARRAY_H |
|
21 #define VPBKSIMSTOREIMPL_CSHAREDVIEWARRAY_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <MVPbkSimCntView.h> |
|
26 #include <VPbkSimStoreCommon.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CVPbkSimContactView; |
|
30 |
|
31 namespace VPbkSimStoreImpl { |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CSharedViewOwner; |
|
35 class CViewHandle; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * An array that manages shared views. |
|
41 */ |
|
42 NONSHARABLE_CLASS(CSharedViewArray) : public CBase |
|
43 { |
|
44 public: // Data types |
|
45 enum TViewDestructionPolicy |
|
46 { |
|
47 /// Views are destroyed when this array is destroyed |
|
48 EDestroyViewWhenArrayIsDestroyed, |
|
49 /// Views are destroyed when last handle is removed. |
|
50 EDestroyViewIfNoHandles |
|
51 }; |
|
52 |
|
53 public: // Construction and Destruction |
|
54 |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * |
|
58 * @return A new instance of this class |
|
59 */ |
|
60 static CSharedViewArray* NewL( |
|
61 TViewDestructionPolicy aDestructionPolicy ); |
|
62 |
|
63 /** |
|
64 * Destructor. |
|
65 */ |
|
66 ~CSharedViewArray(); |
|
67 |
|
68 public: // Interface |
|
69 |
|
70 /** |
|
71 * Creates a new shared view if it didn't exist and |
|
72 * a new handle to it. |
|
73 * |
|
74 * @param aSortOrder The sort order for the view. Will be ignored |
|
75 * if the shared view already exist. |
|
76 * @param aConstructionPolicy Will be ignored if the shared view |
|
77 * already exist. |
|
78 * @param aParentStore The source of contacts. |
|
79 * @param aViewName A shared view identifier |
|
80 * @return a new handle to the shared view. |
|
81 */ |
|
82 CViewHandle* CreateNewHandleL( |
|
83 const RVPbkSimFieldTypeArray& aSortOrder, |
|
84 TVPbkSimViewConstructionPolicy aConstructionPolicy, |
|
85 MVPbkSimCntStore& aParentStore, const TDesC& aViewName ); |
|
86 |
|
87 /** |
|
88 * Removes the view handle. |
|
89 * |
|
90 * @param aHandle The handle to be removed. |
|
91 */ |
|
92 void RemoveHandle( CViewHandle& aHandle ); |
|
93 |
|
94 private: // Implementation |
|
95 |
|
96 /** |
|
97 * C++ constructor. |
|
98 */ |
|
99 CSharedViewArray( TViewDestructionPolicy aDestructionPolicy ); |
|
100 /// Returns the owner or NULL |
|
101 CSharedViewOwner* FindOwner( |
|
102 const RVPbkSimFieldTypeArray& aSortOrder, |
|
103 TVPbkSimViewConstructionPolicy aConstructionPolicy, |
|
104 const TDesC& aViewName ); |
|
105 |
|
106 private: // Data |
|
107 /// Own: defines how views are destroyed |
|
108 TViewDestructionPolicy iDestructionPolicy; |
|
109 /// Own: view holders |
|
110 RPointerArray<CSharedViewOwner> iSharedViews; |
|
111 }; |
|
112 |
|
113 /** |
|
114 * A class for view handle. Forwards requests to real view. |
|
115 */ |
|
116 NONSHARABLE_CLASS(CViewHandle) : |
|
117 public CBase, |
|
118 public MVPbkSimCntView |
|
119 { |
|
120 public: // Construction and Destruction |
|
121 |
|
122 /** |
|
123 * Two-phased constructor. |
|
124 * |
|
125 * @param aSharedViewArray An array that owns shared views. |
|
126 * @param aSharedView The view this handle points to. |
|
127 * @return A new instance of this class |
|
128 */ |
|
129 CViewHandle( CSharedViewArray& aSharedViewArray, |
|
130 CVPbkSimContactView& aSharedView ); |
|
131 |
|
132 /** |
|
133 * Destructor. |
|
134 */ |
|
135 ~CViewHandle(); |
|
136 |
|
137 public: // Interface |
|
138 /** |
|
139 * @return The view this handle points to. |
|
140 */ |
|
141 CVPbkSimContactView& SharedView(); |
|
142 |
|
143 public: // From MVPbkSimCntView |
|
144 const TDesC& Name() const; |
|
145 MVPbkSimCntStore& ParentStore() const; |
|
146 void OpenL( |
|
147 MVPbkSimViewObserver& aObserver ); |
|
148 void Close( |
|
149 MVPbkSimViewObserver& aObserver ); |
|
150 TInt CountL() const; |
|
151 MVPbkSimContact& ContactAtL( |
|
152 TInt aIndex ); |
|
153 void ChangeSortOrderL( |
|
154 const RVPbkSimFieldTypeArray& aSortOrder ); |
|
155 TInt MapSimIndexToViewIndexL( |
|
156 TInt aSimIndex ); |
|
157 MVPbkSimStoreOperation* ContactMatchingPrefixL( |
|
158 const MDesCArray& aFindStrings, |
|
159 MVPbkSimViewFindObserver& aObserver ); |
|
160 const RVPbkSimFieldTypeArray& SortOrderL() const; |
|
161 |
|
162 private: // Data |
|
163 /// Own: An array of shared views. |
|
164 CSharedViewArray& iSharedViewArray; |
|
165 /// Own: The view |
|
166 CVPbkSimContactView& iSharedView; |
|
167 }; |
|
168 |
|
169 /** |
|
170 * A class for managing view handles to the one shared view. |
|
171 */ |
|
172 NONSHARABLE_CLASS(CSharedViewOwner) : public CBase |
|
173 { |
|
174 public: // Construction and Destruction |
|
175 |
|
176 /** |
|
177 * Two-phased constructor. |
|
178 * |
|
179 * @param aSharedViewArray An array that owns shared views. |
|
180 * @param aSharedView The view this handle points to. |
|
181 */ |
|
182 CSharedViewOwner( CSharedViewArray& aSharedViewArray, |
|
183 CVPbkSimContactView* aSharedView ); |
|
184 |
|
185 /** |
|
186 * Destructor. |
|
187 */ |
|
188 ~CSharedViewOwner(); |
|
189 |
|
190 public: // Interface |
|
191 |
|
192 /** |
|
193 * @return The shared view that is owned by this owner. |
|
194 */ |
|
195 CVPbkSimContactView& View() const; |
|
196 |
|
197 /** |
|
198 * Creates a new handle to the View() |
|
199 * |
|
200 * @return a new handle to the View() |
|
201 */ |
|
202 CViewHandle* CreateNewHandleL(); |
|
203 |
|
204 /** |
|
205 * Removes a handle pointing to View() |
|
206 * |
|
207 * @param aHandle The handle to be removed. |
|
208 */ |
|
209 void RemoveHandle( CViewHandle& aHandle ); |
|
210 |
|
211 /** |
|
212 * @return ETrue if View() has handles. |
|
213 */ |
|
214 TBool HasHandles() const; |
|
215 |
|
216 private: // Data |
|
217 /// Ref: The parent array of this owner |
|
218 CSharedViewArray& iSharedViewArray; |
|
219 /// Own: The shared view |
|
220 CVPbkSimContactView* iSharedView; |
|
221 /// Ref: References to view handles |
|
222 RPointerArray<CViewHandle> iViewHandles; |
|
223 }; |
|
224 } // namespace VPbkSimStoreImpl |
|
225 #endif // VPBKSIMSTOREIMPL_CSHAREDVIEWARRAY_H |
|
226 |
|
227 // End of File |