author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 68 | 9da50d567e3c |
parent 63 | f4a778e096c2 |
child 85 | 38bb213f60ba |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2002-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: Contacts Model store filtered contact view implementation. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDES |
|
20 |
#include "CFilteredGroupView.h" |
|
21 |
||
22 |
// VPbkCntModel |
|
23 |
#include "CContactStore.h" |
|
24 |
#include "CFieldFactory.h" |
|
25 |
#include "CCustomFilteredGroupView.h" |
|
68
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
26 |
#include <vpbkcntmodelres.rsg> |
63 | 27 |
#include "VPbkCntModelRemoteViewPreferences.h" |
28 |
#include "NamedRemoteViewViewDefinitionStoreUtility.h" |
|
29 |
||
30 |
||
31 |
// VPbkEng |
|
32 |
#include <CVPbkFieldTypeSelector.h> |
|
33 |
#include <VPbkDataCaging.hrh> |
|
34 |
#include <CVPbkFieldType.h> |
|
35 |
#include <CVPbkFieldTypeList.h> |
|
36 |
#include <CVPbkContactViewDefinition.h> |
|
37 |
#include <TVPbkFieldVersitProperty.h> |
|
38 |
#include <VPbkSendEventUtility.h> |
|
39 |
#include <CVPbkSortOrder.h> |
|
40 |
||
41 |
// VPbkEngUtils |
|
42 |
#include <RLocalizedResourceFile.h> |
|
43 |
||
44 |
// System includes |
|
45 |
#include <cntview.h> |
|
46 |
#include <barsread.h> |
|
47 |
||
48 |
// Debugging headers |
|
49 |
#include <VPbkDebug.h> |
|
50 |
||
51 |
namespace VPbkCntModel { |
|
52 |
||
53 |
// -------------------------------------------------------------------------- |
|
54 |
// CFilteredGroupView::CFilteredGroupView |
|
55 |
// -------------------------------------------------------------------------- |
|
56 |
// |
|
57 |
inline CFilteredGroupView::CFilteredGroupView |
|
58 |
( CContactStore& aParentStore ) : |
|
59 |
CViewBase( aParentStore ) |
|
60 |
{ |
|
61 |
} |
|
62 |
||
63 |
// -------------------------------------------------------------------------- |
|
64 |
// CFilteredGroupView::~CFilteredGroupView |
|
65 |
// -------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
CFilteredGroupView::~CFilteredGroupView() |
|
68 |
{ |
|
69 |
// Customically filtered view has to be destructed first |
|
70 |
delete iCustomFilteredView; |
|
71 |
delete iFilter; |
|
72 |
||
73 |
// Set iView to NULL, so that CViewBase does not close it |
|
74 |
iView = NULL; |
|
75 |
||
76 |
if ( iBaseView ) |
|
77 |
{ |
|
78 |
iBaseView->Close( *iNativeObserver ); |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
// -------------------------------------------------------------------------- |
|
83 |
// CFilteredGroupView::NewLC |
|
84 |
// -------------------------------------------------------------------------- |
|
85 |
// |
|
86 |
CFilteredGroupView* CFilteredGroupView::NewLC( |
|
87 |
const CVPbkContactViewDefinition& aViewDefinition, |
|
88 |
MVPbkContactViewObserver& aObserver, |
|
89 |
CContactStore& aParentStore, |
|
90 |
const MVPbkFieldTypeList& aSortOrder, |
|
91 |
RFs& aFs ) |
|
92 |
{ |
|
93 |
CFilteredGroupView* self = |
|
94 |
new ( ELeave ) CFilteredGroupView( aParentStore ); |
|
95 |
CleanupStack::PushL( self ); |
|
96 |
self->ConstructL( aViewDefinition, aObserver, aSortOrder, aFs ); |
|
97 |
return self; |
|
98 |
} |
|
99 |
||
100 |
// -------------------------------------------------------------------------- |
|
101 |
// CFilteredGroupView::ConstructL |
|
102 |
// -------------------------------------------------------------------------- |
|
103 |
// |
|
104 |
void CFilteredGroupView::ConstructL( |
|
105 |
const CVPbkContactViewDefinition& aViewDefinition, |
|
106 |
MVPbkContactViewObserver& aObserver, |
|
107 |
const MVPbkFieldTypeList& aSortOrder, |
|
108 |
RFs& /*aFs*/ ) |
|
109 |
{ |
|
110 |
const CFieldFactory& fieldFactory = Store().FieldFactory(); |
|
111 |
||
112 |
// Construct the native filter |
|
113 |
if ( aViewDefinition.FieldTypeFilter() ) |
|
114 |
{ |
|
115 |
// Copy construct the filter |
|
116 |
iFilter = CVPbkFieldTypeSelector::NewL( |
|
117 |
*aViewDefinition.FieldTypeFilter() ); |
|
118 |
} |
|
119 |
||
120 |
CViewBase::ConstructL( aViewDefinition, aObserver, aSortOrder ); |
|
121 |
} |
|
122 |
||
123 |
// -------------------------------------------------------------------------- |
|
124 |
// CFilteredGroupView::Type |
|
125 |
// -------------------------------------------------------------------------- |
|
126 |
// |
|
127 |
TVPbkContactViewType CFilteredGroupView::Type() const |
|
128 |
{ |
|
129 |
return EVPbkGroupsView; |
|
130 |
} |
|
131 |
||
132 |
// -------------------------------------------------------------------------- |
|
133 |
// CFilteredGroupView::DoInitializeViewL |
|
134 |
// -------------------------------------------------------------------------- |
|
135 |
// |
|
136 |
void CFilteredGroupView::DoInitializeViewL( |
|
137 |
const CVPbkContactViewDefinition& aViewDefinition, |
|
138 |
RContactViewSortOrder& aViewSortOrder ) |
|
139 |
{ |
|
140 |
// Stop observing the base view, the custom view |
|
141 |
// will observe it and report back |
|
142 |
// Construction of the iCustomFilteredView should be done in two |
|
143 |
// phases. Due to that there is dependencies between views in this |
|
144 |
// and iCustomFilteredView class. |
|
145 |
CCustomFilteredGroupView* customFilteredView = |
|
146 |
new (ELeave) CCustomFilteredGroupView( Store(), iFilter, |
|
147 |
*this ); |
|
148 |
||
149 |
if ( iCustomFilteredView ) |
|
150 |
{ |
|
151 |
delete iCustomFilteredView; |
|
152 |
iCustomFilteredView = NULL; |
|
153 |
} |
|
154 |
iCustomFilteredView = customFilteredView; |
|
155 |
customFilteredView = NULL; |
|
156 |
||
157 |
ConstructBaseViewsL( aViewDefinition, *iCustomFilteredView, |
|
158 |
aViewSortOrder ); |
|
159 |
||
160 |
iCustomFilteredView->ConstructL |
|
161 |
( aViewDefinition, *this, *iSortOrder, *iView ); |
|
162 |
||
163 |
iView = &iCustomFilteredView->ContactViewBase(); |
|
164 |
} |
|
165 |
||
166 |
// -------------------------------------------------------------------------- |
|
167 |
// CFilteredGroupView::DoTeardownView |
|
168 |
// -------------------------------------------------------------------------- |
|
169 |
// |
|
170 |
void CFilteredGroupView::DoTeardownView() |
|
171 |
{ |
|
172 |
} |
|
173 |
||
174 |
// -------------------------------------------------------------------------- |
|
175 |
// CFilteredGroupView::DoChangeSortOrderL |
|
176 |
// -------------------------------------------------------------------------- |
|
177 |
// |
|
178 |
TBool CFilteredGroupView::DoChangeSortOrderL( |
|
179 |
const CVPbkContactViewDefinition& aViewDefinition, |
|
180 |
RContactViewSortOrder& aSortOrder ) |
|
181 |
{ |
|
182 |
TBool canBeChanged = ETrue; |
|
183 |
if ( iRemoteView ) |
|
184 |
{ |
|
185 |
if ( RemoteViewName( aViewDefinition ).Compare( |
|
186 |
KVPbkAllGroupsViewName ) == 0 ) |
|
187 |
{ |
|
188 |
// Set Contacts Model default view setting only if client |
|
189 |
// is using KVPbkAllGroupsViewName shared view |
|
190 |
NamedRemoteViewViewDefinitionStoreUtility:: |
|
191 |
SetNamedRemoteViewViewDefinitionL( |
|
192 |
KVPbkAllContactsViewName, aSortOrder, |
|
193 |
KVPbkDefaultContactViewPrefs); |
|
194 |
} |
|
195 |
iRemoteView->ChangeSortOrderL( aSortOrder ); |
|
196 |
} |
|
197 |
else |
|
198 |
{ |
|
199 |
// CContactLocalView doesn't support ChangeSortOrderL |
|
200 |
canBeChanged = EFalse; |
|
201 |
} |
|
202 |
||
203 |
return canBeChanged; |
|
204 |
} |
|
205 |
||
206 |
// -------------------------------------------------------------------------- |
|
207 |
// CFilteredGroupView::ContactViewReady |
|
208 |
// -------------------------------------------------------------------------- |
|
209 |
// |
|
210 |
void CFilteredGroupView::ContactViewReady( |
|
211 |
MVPbkContactViewBase& aView ) |
|
212 |
{ |
|
213 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
|
214 |
("CFilteredGroupView::ContactViewReady(0x%x)"), &aView); |
|
215 |
||
216 |
VPbkEng::SendViewEventToObservers( *this, iFilteringObservers, |
|
217 |
&MFilteredViewSupportObserver::ContactViewReadyForFiltering, |
|
218 |
&MVPbkContactViewObserver::ContactViewError ); |
|
219 |
VPbkEng::SendViewEventToObservers( *this, iObservers, |
|
220 |
&MVPbkContactViewObserver::ContactViewReady, |
|
221 |
&MVPbkContactViewObserver::ContactViewError ); |
|
222 |
VPbkEng::SendViewEventToObservers( *this, iFilteringObservers, |
|
223 |
&MVPbkContactViewObserver::ContactViewReady, |
|
224 |
&MVPbkContactViewObserver::ContactViewError ); |
|
225 |
} |
|
226 |
||
227 |
// -------------------------------------------------------------------------- |
|
228 |
// CFilteredGroupView::ContactViewUnavailable |
|
229 |
// -------------------------------------------------------------------------- |
|
230 |
// |
|
231 |
void CFilteredGroupView::ContactViewUnavailable( |
|
232 |
MVPbkContactViewBase& aView ) |
|
233 |
{ |
|
234 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
|
235 |
("CFilteredGroupView::ContactViewUnavailable(0x%x)"), &aView); |
|
236 |
||
237 |
VPbkEng::SendViewEventToObservers( *this, iFilteringObservers, |
|
238 |
&MFilteredViewSupportObserver::ContactViewUnavailableForFiltering, |
|
239 |
&MVPbkContactViewObserver::ContactViewError ); |
|
240 |
VPbkEng::SendViewEventToObservers( *this, iObservers, |
|
241 |
&MVPbkContactViewObserver::ContactViewUnavailable, |
|
242 |
&MVPbkContactViewObserver::ContactViewError ); |
|
243 |
VPbkEng::SendViewEventToObservers( *this, iFilteringObservers, |
|
244 |
&MVPbkContactViewObserver::ContactViewUnavailable, |
|
245 |
&MVPbkContactViewObserver::ContactViewError ); |
|
246 |
} |
|
247 |
||
248 |
// -------------------------------------------------------------------------- |
|
249 |
// CFilteredGroupView::ContactAddedToView |
|
250 |
// -------------------------------------------------------------------------- |
|
251 |
// |
|
252 |
void CFilteredGroupView::ContactAddedToView( |
|
253 |
MVPbkContactViewBase& aView, |
|
254 |
TInt aIndex, const MVPbkContactLink& aContactLink ) |
|
255 |
{ |
|
256 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
|
257 |
("CFilteredGroupView::ContactAddedToView(0x%x)"), &aView); |
|
258 |
||
259 |
VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
|
260 |
iObservers, |
|
261 |
&MVPbkContactViewObserver::ContactAddedToView, |
|
262 |
&MVPbkContactViewObserver::ContactViewError ); |
|
263 |
VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
|
264 |
iFilteringObservers, |
|
265 |
&MVPbkContactViewObserver::ContactAddedToView, |
|
266 |
&MVPbkContactViewObserver::ContactViewError ); |
|
267 |
} |
|
268 |
||
269 |
// -------------------------------------------------------------------------- |
|
270 |
// CFilteredGroupView::ContactRemovedFromView |
|
271 |
// -------------------------------------------------------------------------- |
|
272 |
// |
|
273 |
void CFilteredGroupView::ContactRemovedFromView( |
|
274 |
MVPbkContactViewBase& aView, |
|
275 |
TInt aIndex, const MVPbkContactLink& aContactLink ) |
|
276 |
{ |
|
277 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
|
278 |
("CFilteredGroupView::ContactRemovedFromView(0x%x)"), &aView); |
|
279 |
||
280 |
VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
|
281 |
iObservers, |
|
282 |
&MVPbkContactViewObserver::ContactRemovedFromView, |
|
283 |
&MVPbkContactViewObserver::ContactViewError ); |
|
284 |
VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, |
|
285 |
iFilteringObservers, |
|
286 |
&MVPbkContactViewObserver::ContactRemovedFromView, |
|
287 |
&MVPbkContactViewObserver::ContactViewError ); |
|
288 |
} |
|
289 |
||
290 |
// -------------------------------------------------------------------------- |
|
291 |
// CFilteredGroupView::ContactViewError |
|
292 |
// -------------------------------------------------------------------------- |
|
293 |
// |
|
294 |
void CFilteredGroupView::ContactViewError( |
|
295 |
MVPbkContactViewBase& aView, |
|
296 |
TInt aError, TBool aErrorNotified ) |
|
297 |
{ |
|
298 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING |
|
299 |
("CFilteredGroupView::ContactViewError(0x%x)"), &aView); |
|
300 |
||
301 |
VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, iObservers, |
|
302 |
&MVPbkContactViewObserver::ContactViewError ); |
|
303 |
VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, |
|
304 |
iFilteringObservers, &MVPbkContactViewObserver::ContactViewError ); |
|
305 |
} |
|
306 |
||
307 |
// -------------------------------------------------------------------------- |
|
308 |
// CFilteredGroupView::ConstructBaseViewsL |
|
309 |
// -------------------------------------------------------------------------- |
|
310 |
// |
|
311 |
void CFilteredGroupView::ConstructBaseViewsL |
|
312 |
( const CVPbkContactViewDefinition& aViewDefinition, |
|
313 |
MContactViewObserver& aObserver, |
|
314 |
RContactViewSortOrder& aViewSortOrder ) |
|
315 |
{ |
|
316 |
iNativeObserver = &aObserver; |
|
317 |
||
318 |
// Construct the all contacts view first |
|
319 |
if ( RemoteViewDefinition( aViewDefinition ) ) |
|
320 |
{ |
|
321 |
iRemoteView = CContactNamedRemoteView::NewL( |
|
322 |
*iNativeObserver, RemoteViewName( aViewDefinition ), |
|
323 |
Store().NativeDatabase(), aViewSortOrder, |
|
324 |
KVPbkDefaultGroupsViewPrefs ); |
|
325 |
||
326 |
iBaseView = iRemoteView; |
|
327 |
} |
|
328 |
else |
|
329 |
{ |
|
330 |
iBaseView = CContactLocalView::NewL( *iNativeObserver, |
|
331 |
Store().NativeDatabase(), aViewSortOrder, |
|
332 |
KVPbkDefaultGroupsViewPrefs ); |
|
333 |
} |
|
334 |
||
335 |
// Set base class view pointer |
|
336 |
iView = iBaseView; |
|
337 |
} |
|
338 |
||
339 |
} // namespace VPbkCntModel |
|
340 |
||
341 |
// End of File |