|
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( const TDesC& aViewName ); |
|
102 |
|
103 private: // Data |
|
104 /// Own: defines how views are destroyed |
|
105 TViewDestructionPolicy iDestructionPolicy; |
|
106 /// Own: view holders |
|
107 RPointerArray<CSharedViewOwner> iSharedViews; |
|
108 }; |
|
109 |
|
110 /** |
|
111 * A class for view handle. Forwards requests to real view. |
|
112 */ |
|
113 NONSHARABLE_CLASS(CViewHandle) : |
|
114 public CBase, |
|
115 public MVPbkSimCntView |
|
116 { |
|
117 public: // Construction and Destruction |
|
118 |
|
119 /** |
|
120 * Two-phased constructor. |
|
121 * |
|
122 * @param aSharedViewArray An array that owns shared views. |
|
123 * @param aSharedView The view this handle points to. |
|
124 * @return A new instance of this class |
|
125 */ |
|
126 CViewHandle( CSharedViewArray& aSharedViewArray, |
|
127 CVPbkSimContactView& aSharedView ); |
|
128 |
|
129 /** |
|
130 * Destructor. |
|
131 */ |
|
132 ~CViewHandle(); |
|
133 |
|
134 public: // Interface |
|
135 /** |
|
136 * @return The view this handle points to. |
|
137 */ |
|
138 CVPbkSimContactView& SharedView(); |
|
139 |
|
140 public: // From MVPbkSimCntView |
|
141 const TDesC& Name() const; |
|
142 MVPbkSimCntStore& ParentStore() const; |
|
143 void OpenL( |
|
144 MVPbkSimViewObserver& aObserver ); |
|
145 void Close( |
|
146 MVPbkSimViewObserver& aObserver ); |
|
147 TInt CountL() const; |
|
148 MVPbkSimContact& ContactAtL( |
|
149 TInt aIndex ); |
|
150 void ChangeSortOrderL( |
|
151 const RVPbkSimFieldTypeArray& aSortOrder ); |
|
152 TInt MapSimIndexToViewIndexL( |
|
153 TInt aSimIndex ); |
|
154 MVPbkSimStoreOperation* ContactMatchingPrefixL( |
|
155 const MDesCArray& aFindStrings, |
|
156 MVPbkSimViewFindObserver& aObserver ); |
|
157 const RVPbkSimFieldTypeArray& SortOrderL() const; |
|
158 |
|
159 private: // Data |
|
160 /// Own: An array of shared views. |
|
161 CSharedViewArray& iSharedViewArray; |
|
162 /// Own: The view |
|
163 CVPbkSimContactView& iSharedView; |
|
164 }; |
|
165 |
|
166 /** |
|
167 * A class for managing view handles to the one shared view. |
|
168 */ |
|
169 NONSHARABLE_CLASS(CSharedViewOwner) : public CBase |
|
170 { |
|
171 public: // Construction and Destruction |
|
172 |
|
173 /** |
|
174 * Two-phased constructor. |
|
175 * |
|
176 * @param aSharedViewArray An array that owns shared views. |
|
177 * @param aSharedView The view this handle points to. |
|
178 */ |
|
179 CSharedViewOwner( CSharedViewArray& aSharedViewArray, |
|
180 CVPbkSimContactView* aSharedView ); |
|
181 |
|
182 /** |
|
183 * Destructor. |
|
184 */ |
|
185 ~CSharedViewOwner(); |
|
186 |
|
187 public: // Interface |
|
188 |
|
189 /** |
|
190 * @return The shared view that is owned by this owner. |
|
191 */ |
|
192 CVPbkSimContactView& View() const; |
|
193 |
|
194 /** |
|
195 * Creates a new handle to the View() |
|
196 * |
|
197 * @return a new handle to the View() |
|
198 */ |
|
199 CViewHandle* CreateNewHandleL(); |
|
200 |
|
201 /** |
|
202 * Removes a handle pointing to View() |
|
203 * |
|
204 * @param aHandle The handle to be removed. |
|
205 */ |
|
206 void RemoveHandle( CViewHandle& aHandle ); |
|
207 |
|
208 /** |
|
209 * @return ETrue if View() has handles. |
|
210 */ |
|
211 TBool HasHandles() const; |
|
212 |
|
213 private: // Data |
|
214 /// Ref: The parent array of this owner |
|
215 CSharedViewArray& iSharedViewArray; |
|
216 /// Own: The shared view |
|
217 CVPbkSimContactView* iSharedView; |
|
218 /// Ref: References to view handles |
|
219 RPointerArray<CViewHandle> iViewHandles; |
|
220 }; |
|
221 } // namespace VPbkSimStoreImpl |
|
222 #endif // VPBKSIMSTOREIMPL_CSHAREDVIEWARRAY_H |
|
223 |
|
224 // End of File |