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 "CFilteredContactView.h"
|
|
21 |
|
|
22 |
// VPbkCntModel
|
|
23 |
#include "CContactStore.h"
|
|
24 |
#include "CFieldFactory.h"
|
|
25 |
#include "CCustomFilteredContactView.h"
|
|
26 |
#include <VPbkCntModelRes.rsg>
|
|
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 <VPbkPrivateUid.h> // KFindPluingUID
|
|
40 |
#include <CVPbkSortOrder.h>
|
|
41 |
|
|
42 |
// VPbkEngUtils
|
|
43 |
#include <RLocalizedResourceFile.h>
|
|
44 |
|
|
45 |
// System includes
|
|
46 |
#include <cntview.h>
|
|
47 |
#include <barsread.h>
|
|
48 |
|
|
49 |
// Debugging headers
|
|
50 |
#include <VPbkDebug.h>
|
|
51 |
|
|
52 |
namespace VPbkCntModel {
|
|
53 |
|
|
54 |
// CONSTANTS
|
|
55 |
|
|
56 |
_LIT( KResourceFile, "VPbkCntModelRes.rsc" );
|
|
57 |
|
|
58 |
/// Field type filter mapping structure
|
|
59 |
struct TVPbkFieldTypeFilterMapping
|
|
60 |
{
|
|
61 |
/// Virtual Phonebook field type resource id
|
|
62 |
TUint iFieldTypeResourceId;
|
|
63 |
/// Contacst Model native filter matching the field type
|
|
64 |
TUint iNativeFilter;
|
|
65 |
};
|
|
66 |
|
|
67 |
/// Last element marker
|
|
68 |
const TUint KLastElement = 0;
|
|
69 |
|
|
70 |
/// Array of field type filter mappings
|
|
71 |
static const TVPbkFieldTypeFilterMapping FilterMapping[] =
|
|
72 |
{
|
|
73 |
{ R_CNTMODEL_NATIVE_FILTER_EMAIL_ADDRESS,
|
|
74 |
CContactDatabase::EMailable },
|
|
75 |
|
|
76 |
{ R_CNTMODEL_NATIVE_FILTER_PHONE_NUMBER,
|
|
77 |
CContactDatabase::EPhonable },
|
|
78 |
|
|
79 |
{ R_CNTMODEL_NATIVE_FILTER_SMS_ADDRESS,
|
|
80 |
CContactDatabase::ESmsable },
|
|
81 |
|
|
82 |
{ R_CNTMODEL_NATIVE_FILTER_FAX_NUMBER,
|
|
83 |
CContactDatabase::EFaxable },
|
|
84 |
|
|
85 |
{ R_CNTMODEL_NATIVE_FILTER_RINGING_TONE,
|
|
86 |
CContactDatabase::ERingTone },
|
|
87 |
|
|
88 |
{ R_CNTMODEL_NATIVE_FILTER_ASSISTANT_PHONE_NUMBER,
|
|
89 |
CContactDatabase::EPhonable },
|
|
90 |
|
|
91 |
{ R_CNTMODEL_NATIVE_FILTER_TOP_CONTACT,
|
|
92 |
CContactDatabase::ECustomFilter2 },
|
|
93 |
|
|
94 |
/// This has to be the last
|
|
95 |
{ KLastElement,
|
|
96 |
CContactDatabase::EUnfiltered }
|
|
97 |
};
|
|
98 |
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Appends native filter aFilter based on the given field type resource id.
|
|
102 |
*
|
|
103 |
* @param aFieldTypeResourceId Field type resource id.
|
|
104 |
* @param aFilter Native Contacts Model filter.
|
|
105 |
*/
|
|
106 |
inline void BuildNativeFilter( const TInt aFieldTypeResourceId,
|
|
107 |
TUint& aFilter )
|
|
108 |
{
|
|
109 |
for ( TInt i=0;
|
|
110 |
FilterMapping[i].iFieldTypeResourceId != KLastElement; ++i )
|
|
111 |
{
|
|
112 |
if ( aFieldTypeResourceId == FilterMapping[i].iFieldTypeResourceId )
|
|
113 |
{
|
|
114 |
aFilter |= FilterMapping[i].iNativeFilter;
|
|
115 |
break;
|
|
116 |
}
|
|
117 |
}
|
|
118 |
}
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Checks wheter custom filtering is needed. This is the case
|
|
122 |
* when the native filters cannot provide all the necessary filtering.
|
|
123 |
*
|
|
124 |
* @param aFieldType The field type which matched selectors field type
|
|
125 |
* collection.
|
|
126 |
* @param aFilterType The filter type which matched aFieldType, or NULL.
|
|
127 |
* @param aSelector The field type selector, the filtering criteria.
|
|
128 |
* @return ETrue if custom filtering is needed.
|
|
129 |
*/
|
|
130 |
TBool RequiresCustomFiltering(
|
|
131 |
const MVPbkFieldType& aFieldType,
|
|
132 |
const MVPbkFieldType* aFilterType,
|
|
133 |
const CVPbkFieldTypeSelector& aSelector )
|
|
134 |
{
|
|
135 |
TBool ret = ETrue;
|
|
136 |
|
|
137 |
if ( aFilterType )
|
|
138 |
{
|
|
139 |
const TVPbkFieldVersitProperty* matchingProperty =
|
|
140 |
aSelector.MatchingVersitProperty( aFieldType );
|
|
141 |
if ( matchingProperty )
|
|
142 |
{
|
|
143 |
const TInt maxMatchPriority =
|
|
144 |
aFilterType->VersitProperties().Count() - 1;
|
|
145 |
for ( TInt matchPriority = 0;
|
|
146 |
matchPriority <= maxMatchPriority; ++matchPriority )
|
|
147 |
{
|
|
148 |
if ( matchingProperty->Matches(
|
|
149 |
aFilterType->VersitProperties()[matchPriority]) )
|
|
150 |
{
|
|
151 |
ret = EFalse;
|
|
152 |
break;
|
|
153 |
}
|
|
154 |
}
|
|
155 |
}
|
|
156 |
else
|
|
157 |
{
|
|
158 |
TVPbkNonVersitFieldType matchingType =
|
|
159 |
aSelector.MatchingNonVersitType( aFieldType );
|
|
160 |
if ( aFieldType.NonVersitType() == matchingType )
|
|
161 |
{
|
|
162 |
ret = EFalse;
|
|
163 |
}
|
|
164 |
}
|
|
165 |
}
|
|
166 |
|
|
167 |
return ret;
|
|
168 |
}
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Checks does the given field type match any of the native filter types.
|
|
172 |
*
|
|
173 |
* @param aFieldType The field type to inspect.
|
|
174 |
* @param aSupportedFilterTypes Field types which are supported
|
|
175 |
* by the native filters.
|
|
176 |
* @return Native filter field type which matched aFieldType,
|
|
177 |
* or NULL if no matches.
|
|
178 |
*/
|
|
179 |
inline const MVPbkFieldType* MatchesNativeFilter
|
|
180 |
( const MVPbkFieldType& aFieldType,
|
|
181 |
const CVPbkFieldTypeList& aSupportedFilterTypes )
|
|
182 |
|
|
183 |
{
|
|
184 |
const MVPbkFieldType* matchingType = NULL;
|
|
185 |
|
|
186 |
const TInt maxMatchPriority =
|
|
187 |
aFieldType.VersitProperties().Count() - 1;
|
|
188 |
|
|
189 |
for ( TInt matchPriority = 0;
|
|
190 |
matchPriority <= maxMatchPriority && !matchingType; ++matchPriority )
|
|
191 |
{
|
|
192 |
matchingType = aSupportedFilterTypes.FindMatch(
|
|
193 |
aFieldType.VersitProperties()[matchPriority],
|
|
194 |
matchPriority );
|
|
195 |
}
|
|
196 |
|
|
197 |
if ( !matchingType && aFieldType.NonVersitType() != EVPbkNonVersitTypeNone )
|
|
198 |
{
|
|
199 |
matchingType = aSupportedFilterTypes.FindMatch
|
|
200 |
( aFieldType.NonVersitType() );
|
|
201 |
}
|
|
202 |
|
|
203 |
return matchingType;
|
|
204 |
}
|
|
205 |
|
|
206 |
/**
|
|
207 |
* Converts VPbk field type filter to a native filter.
|
|
208 |
*
|
|
209 |
* @param aSource Field type filter to convert.
|
|
210 |
* @param aFieldTypeList List of supported field types
|
|
211 |
* of the store.
|
|
212 |
* @param aFs File server session.
|
|
213 |
* @param aCustomFilteringNeeded Indicates whether the native filters
|
|
214 |
* are enough, or do we have to do custom
|
|
215 |
* filtering.
|
|
216 |
* @return Native Contacts model contact view filter.
|
|
217 |
*/
|
|
218 |
TUint ConvertFieldTypeFilterL
|
|
219 |
( const CVPbkFieldTypeSelector& aSource,
|
|
220 |
const MVPbkFieldTypeList& aFieldTypeList,
|
|
221 |
RFs& aFs, TBool& aCustomFilteringNeeded )
|
|
222 |
{
|
|
223 |
TUint ret = CContactDatabase::EUnfiltered;
|
|
224 |
|
|
225 |
// Build own field type list containing field types supported
|
|
226 |
// by native filters
|
|
227 |
VPbkEngUtils::RLocalizedResourceFile resFile;
|
|
228 |
resFile.OpenLC( aFs,
|
|
229 |
KVPbkRomFileDrive, KDC_RESOURCE_FILES_DIR, KResourceFile );
|
|
230 |
|
|
231 |
TResourceReader reader;
|
|
232 |
reader.SetBuffer( resFile.AllocReadLC
|
|
233 |
( R_CNTMODEL_NATIVE_FILTER_FIELD_TYPES ) );
|
|
234 |
|
|
235 |
CVPbkFieldTypeList* supportedFilterTypes =
|
|
236 |
CVPbkFieldTypeList::NewL( resFile, reader );
|
|
237 |
CleanupStack::PushL( supportedFilterTypes );
|
|
238 |
|
|
239 |
// Go through the store's field type list
|
|
240 |
TInt typeCount = aFieldTypeList.FieldTypeCount();
|
|
241 |
for ( TInt i=0; i < typeCount; ++i )
|
|
242 |
{
|
|
243 |
const MVPbkFieldType& fieldType =
|
|
244 |
aFieldTypeList.FieldTypeAt( i );
|
|
245 |
|
|
246 |
if ( aSource.IsFieldTypeIncluded( fieldType ) )
|
|
247 |
{
|
|
248 |
// We have a match. Now lets inspect does it match
|
|
249 |
// any of the native filter field types
|
|
250 |
const MVPbkFieldType* matchingType =
|
|
251 |
MatchesNativeFilter( fieldType, *supportedFilterTypes );
|
|
252 |
|
|
253 |
if ( matchingType )
|
|
254 |
{
|
|
255 |
// We found a match to a native filter, lets build
|
|
256 |
// the native filter
|
|
257 |
BuildNativeFilter( matchingType->FieldTypeResId(), ret );
|
|
258 |
}
|
|
259 |
|
|
260 |
// Then, find out do we need to custom filtering
|
|
261 |
TBool customFilteringRequired = RequiresCustomFiltering
|
|
262 |
( fieldType, matchingType, aSource );
|
|
263 |
aCustomFilteringNeeded = customFilteringRequired;
|
|
264 |
|
|
265 |
if ( !matchingType && customFilteringRequired )
|
|
266 |
{
|
|
267 |
// Custom filtering is required and there is no appropriate
|
|
268 |
// native filter which could be used as a base filter.
|
|
269 |
// In this case the custom filter has to handle all
|
|
270 |
// the filtering. So reset the native filter and break out.
|
|
271 |
ret = CContactDatabase::EUnfiltered;
|
|
272 |
break;
|
|
273 |
}
|
|
274 |
}
|
|
275 |
}
|
|
276 |
|
|
277 |
CleanupStack::PopAndDestroy( 3 ); // supportedFilterTypes,
|
|
278 |
// reader, resFile
|
|
279 |
|
|
280 |
return ret;
|
|
281 |
}
|
|
282 |
|
|
283 |
// --------------------------------------------------------------------------
|
|
284 |
// CFilteredContactView::CFilteredContactView
|
|
285 |
// --------------------------------------------------------------------------
|
|
286 |
//
|
|
287 |
inline CFilteredContactView::CFilteredContactView
|
|
288 |
( CContactStore& aParentStore,
|
|
289 |
RFs& aFs ) :
|
|
290 |
CViewBase( aParentStore ),
|
|
291 |
iFs( aFs )
|
|
292 |
{
|
|
293 |
}
|
|
294 |
|
|
295 |
// --------------------------------------------------------------------------
|
|
296 |
// CFilteredContactView::~CFilteredContactView
|
|
297 |
// --------------------------------------------------------------------------
|
|
298 |
//
|
|
299 |
CFilteredContactView::~CFilteredContactView()
|
|
300 |
{
|
|
301 |
// Customically filtered view has to be destructed first
|
|
302 |
delete iCustomFilteredView;
|
|
303 |
delete iFilter;
|
|
304 |
|
|
305 |
// Set iView to NULL, so that CViewBase does not close it
|
|
306 |
iView = NULL;
|
|
307 |
|
|
308 |
if ( iFilteredView )
|
|
309 |
{
|
|
310 |
//after iFilteredView->Close( *iNativeObserver )
|
|
311 |
//both iFilteredView and iBaseView are deleted
|
|
312 |
iFilteredView->Close( *iNativeObserver );
|
|
313 |
}
|
|
314 |
else if ( iBaseView )
|
|
315 |
{
|
|
316 |
//but iBaseView's pointer is still not NULL
|
|
317 |
//make sure iBaseView is unable to call its member function
|
|
318 |
iBaseView->Close( *iNativeObserver );
|
|
319 |
}
|
|
320 |
}
|
|
321 |
|
|
322 |
// --------------------------------------------------------------------------
|
|
323 |
// CFilteredContactView::NewLC
|
|
324 |
// --------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
CFilteredContactView* CFilteredContactView::NewLC(
|
|
327 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
328 |
MVPbkContactViewObserver& aObserver,
|
|
329 |
CContactStore& aParentStore,
|
|
330 |
const MVPbkFieldTypeList& aSortOrder,
|
|
331 |
RFs& aFs )
|
|
332 |
{
|
|
333 |
CFilteredContactView* self = new ( ELeave ) CFilteredContactView
|
|
334 |
( aParentStore, aFs );
|
|
335 |
CleanupStack::PushL( self );
|
|
336 |
self->ConstructL( aViewDefinition, aObserver, aSortOrder );
|
|
337 |
return self;
|
|
338 |
}
|
|
339 |
|
|
340 |
// --------------------------------------------------------------------------
|
|
341 |
// CFilteredContactView::ConstructL
|
|
342 |
// --------------------------------------------------------------------------
|
|
343 |
//
|
|
344 |
void CFilteredContactView::ConstructL(
|
|
345 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
346 |
MVPbkContactViewObserver& aObserver,
|
|
347 |
const MVPbkFieldTypeList& aSortOrder )
|
|
348 |
{
|
|
349 |
CViewBase::ConstructL( aViewDefinition, aObserver, aSortOrder );
|
|
350 |
}
|
|
351 |
|
|
352 |
// --------------------------------------------------------------------------
|
|
353 |
// CFilteredContactView::Type
|
|
354 |
// --------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
TVPbkContactViewType CFilteredContactView::Type() const
|
|
357 |
{
|
|
358 |
return EVPbkContactsView;
|
|
359 |
}
|
|
360 |
|
|
361 |
// --------------------------------------------------------------------------
|
|
362 |
// CFilteredContactView::DoInitializeViewL
|
|
363 |
// --------------------------------------------------------------------------
|
|
364 |
//
|
|
365 |
void CFilteredContactView::DoInitializeViewL(
|
|
366 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
367 |
RContactViewSortOrder& aViewSortOrder )
|
|
368 |
{
|
|
369 |
// Construct the native filter
|
|
370 |
if ( aViewDefinition.FieldTypeFilter() )
|
|
371 |
{
|
|
372 |
const CFieldFactory& fieldFactory = Store().FieldFactory();
|
|
373 |
|
|
374 |
// Copy construct the filter
|
|
375 |
CVPbkFieldTypeSelector* filter = CVPbkFieldTypeSelector::NewL(
|
|
376 |
*aViewDefinition.FieldTypeFilter() );
|
|
377 |
if ( iFilter )
|
|
378 |
{
|
|
379 |
delete iFilter;
|
|
380 |
iFilter = NULL;
|
|
381 |
}
|
|
382 |
|
|
383 |
iFilter = filter;
|
|
384 |
filter = NULL;
|
|
385 |
|
|
386 |
// whenever a new iFilter created, set it as new fieldTypeSelector
|
|
387 |
// iCustomFilteredView, to avoid such case that new iFilter created
|
|
388 |
// but iCustomFilteredView is still the old one using the old iFilter,
|
|
389 |
// it will panic since the old iFilter is deleted.
|
|
390 |
if ( iCustomFilteredView )
|
|
391 |
{
|
|
392 |
iCustomFilteredView->SetFieldTypeSelector( iFilter );
|
|
393 |
}
|
|
394 |
|
|
395 |
iNativeFilter = ConvertFieldTypeFilterL
|
|
396 |
( *iFilter, fieldFactory, iFs, iCustomFilteringNeeded );
|
|
397 |
}
|
|
398 |
if ( aViewDefinition.ContactSelector() )
|
|
399 |
{
|
|
400 |
iCustomFilteringNeeded = ETrue;
|
|
401 |
// Custom filtering and MVPbkContactSelector filtering cannot be used at the same time.
|
|
402 |
iNativeFilter = 0; // no filter
|
|
403 |
}
|
|
404 |
if ( iCustomFilteringNeeded )
|
|
405 |
{
|
|
406 |
// Stop observing the base view, the custom view
|
|
407 |
// will observe it and report back
|
|
408 |
// Construction of the iCustomFilteredView should be done in two
|
|
409 |
// phases. Due to that there is dependencies between views in this
|
|
410 |
// and iCustomFilteredView class.
|
|
411 |
|
|
412 |
CCustomFilteredContactView* customFilteredView = new (ELeave) CCustomFilteredContactView( Store(), iFilter,
|
|
413 |
*this, aViewDefinition.ContactSelector() );
|
|
414 |
|
|
415 |
if ( iCustomFilteredView )
|
|
416 |
{
|
|
417 |
delete iCustomFilteredView;
|
|
418 |
iCustomFilteredView = NULL;
|
|
419 |
}
|
|
420 |
iCustomFilteredView = customFilteredView;
|
|
421 |
customFilteredView = NULL;
|
|
422 |
|
|
423 |
ConstructBaseViewsL( aViewDefinition, *iCustomFilteredView,
|
|
424 |
aViewSortOrder );
|
|
425 |
|
|
426 |
if ( iFilteredView )
|
|
427 |
{
|
|
428 |
iBaseView->Close( *iCustomFilteredView );
|
|
429 |
}
|
|
430 |
|
|
431 |
iCustomFilteredView->ConstructL
|
|
432 |
( aViewDefinition, *this, *iSortOrder, *iView );
|
|
433 |
|
|
434 |
iView = &iCustomFilteredView->ContactViewBase();
|
|
435 |
}
|
|
436 |
else
|
|
437 |
{
|
|
438 |
ConstructBaseViewsL( aViewDefinition, *this, aViewSortOrder );
|
|
439 |
|
|
440 |
// If we built Contact's Model's native filtered view we must
|
|
441 |
// stop observing the base view since otherwise we get double
|
|
442 |
// view events and VPbk composite view does not tolerate double
|
|
443 |
// events
|
|
444 |
if ( iFilteredView )
|
|
445 |
{
|
|
446 |
iBaseView->Close( *this );
|
|
447 |
}
|
|
448 |
}
|
|
449 |
}
|
|
450 |
|
|
451 |
// --------------------------------------------------------------------------
|
|
452 |
// CFilteredContactView::DoTeardownView
|
|
453 |
// --------------------------------------------------------------------------
|
|
454 |
//
|
|
455 |
void CFilteredContactView::DoTeardownView()
|
|
456 |
{
|
|
457 |
}
|
|
458 |
|
|
459 |
// --------------------------------------------------------------------------
|
|
460 |
// CFilteredContactView::DoChangeSortOrderL
|
|
461 |
// --------------------------------------------------------------------------
|
|
462 |
//
|
|
463 |
TBool CFilteredContactView::DoChangeSortOrderL(
|
|
464 |
const CVPbkContactViewDefinition& aViewDefinition,
|
|
465 |
RContactViewSortOrder& aSortOrder )
|
|
466 |
{
|
|
467 |
TBool canBeChanged = ETrue;
|
|
468 |
if ( iRemoteView )
|
|
469 |
{
|
|
470 |
if ( RemoteViewName( aViewDefinition ).Compare(
|
|
471 |
KVPbkAllContactsViewName ) == 0 )
|
|
472 |
{
|
|
473 |
// Set Contacts Model default view setting only if client
|
|
474 |
// is using KVPbkAllContactsViewName shared view.
|
|
475 |
NamedRemoteViewViewDefinitionStoreUtility::
|
|
476 |
SetNamedRemoteViewViewDefinitionL(
|
|
477 |
KVPbkAllContactsViewName, aSortOrder,
|
|
478 |
KVPbkDefaultContactViewPrefs);
|
|
479 |
}
|
|
480 |
iRemoteView->ChangeSortOrderL( aSortOrder );
|
|
481 |
}
|
|
482 |
else
|
|
483 |
{
|
|
484 |
// CContactLocalView doesn't support ChangeSortOrderL
|
|
485 |
canBeChanged = EFalse;
|
|
486 |
}
|
|
487 |
|
|
488 |
return canBeChanged;
|
|
489 |
}
|
|
490 |
|
|
491 |
// --------------------------------------------------------------------------
|
|
492 |
// CFilteredContactView::ContactViewReady
|
|
493 |
// --------------------------------------------------------------------------
|
|
494 |
//
|
|
495 |
void CFilteredContactView::ContactViewReady(
|
|
496 |
MVPbkContactViewBase& aView )
|
|
497 |
{
|
|
498 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
|
|
499 |
("CFilteredContactView::ContactViewReady(0x%x)"), &aView);
|
|
500 |
|
|
501 |
/* when custom filtering view is used, MVPbkContactViewObserver doesn't support
|
|
502 |
* sortOrder changed notification, CViewBase will send viewReady instead,
|
|
503 |
* use it to keep sort order up to date */
|
|
504 |
if ( iCustomFilteringNeeded )
|
|
505 |
{
|
|
506 |
DoUpdateTypeListL();
|
|
507 |
}
|
|
508 |
|
|
509 |
VPbkEng::SendViewEventToObservers( *this, iFilteringObservers,
|
|
510 |
&MFilteredViewSupportObserver::ContactViewReadyForFiltering,
|
|
511 |
&MVPbkContactViewObserver::ContactViewError );
|
|
512 |
VPbkEng::SendViewEventToObservers( *this, iObservers,
|
|
513 |
&MVPbkContactViewObserver::ContactViewReady,
|
|
514 |
&MVPbkContactViewObserver::ContactViewError );
|
|
515 |
VPbkEng::SendViewEventToObservers( *this, iFilteringObservers,
|
|
516 |
&MVPbkContactViewObserver::ContactViewReady,
|
|
517 |
&MVPbkContactViewObserver::ContactViewError );
|
|
518 |
}
|
|
519 |
|
|
520 |
// --------------------------------------------------------------------------
|
|
521 |
// CFilteredContactView::ContactViewUnavailable
|
|
522 |
// --------------------------------------------------------------------------
|
|
523 |
//
|
|
524 |
void CFilteredContactView::ContactViewUnavailable(
|
|
525 |
MVPbkContactViewBase& aView )
|
|
526 |
{
|
|
527 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
|
|
528 |
("CFilteredContactView::ContactViewUnavailable(0x%x)"), &aView);
|
|
529 |
|
|
530 |
VPbkEng::SendViewEventToObservers( *this, iFilteringObservers,
|
|
531 |
&MFilteredViewSupportObserver::ContactViewUnavailableForFiltering,
|
|
532 |
&MVPbkContactViewObserver::ContactViewError );
|
|
533 |
VPbkEng::SendViewEventToObservers( *this, iObservers,
|
|
534 |
&MVPbkContactViewObserver::ContactViewUnavailable,
|
|
535 |
&MVPbkContactViewObserver::ContactViewError );
|
|
536 |
VPbkEng::SendViewEventToObservers( *this, iFilteringObservers,
|
|
537 |
&MVPbkContactViewObserver::ContactViewUnavailable,
|
|
538 |
&MVPbkContactViewObserver::ContactViewError );
|
|
539 |
}
|
|
540 |
|
|
541 |
// --------------------------------------------------------------------------
|
|
542 |
// CFilteredContactView::ContactAddedToView
|
|
543 |
// --------------------------------------------------------------------------
|
|
544 |
//
|
|
545 |
void CFilteredContactView::ContactAddedToView(
|
|
546 |
MVPbkContactViewBase& aView,
|
|
547 |
TInt aIndex, const MVPbkContactLink& aContactLink )
|
|
548 |
{
|
|
549 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
|
|
550 |
("CFilteredContactView::ContactAddedToView(0x%x)"), &aView);
|
|
551 |
|
|
552 |
VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink,
|
|
553 |
iObservers,
|
|
554 |
&MVPbkContactViewObserver::ContactAddedToView,
|
|
555 |
&MVPbkContactViewObserver::ContactViewError );
|
|
556 |
VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink,
|
|
557 |
iFilteringObservers,
|
|
558 |
&MVPbkContactViewObserver::ContactAddedToView,
|
|
559 |
&MVPbkContactViewObserver::ContactViewError );
|
|
560 |
}
|
|
561 |
|
|
562 |
// --------------------------------------------------------------------------
|
|
563 |
// CFilteredContactView::ContactRemovedFromView
|
|
564 |
// --------------------------------------------------------------------------
|
|
565 |
//
|
|
566 |
void CFilteredContactView::ContactRemovedFromView(
|
|
567 |
MVPbkContactViewBase& aView,
|
|
568 |
TInt aIndex, const MVPbkContactLink& aContactLink )
|
|
569 |
{
|
|
570 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
|
|
571 |
("CFilteredContactView::ContactRemovedFromView(0x%x)"), &aView);
|
|
572 |
|
|
573 |
VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink,
|
|
574 |
iObservers,
|
|
575 |
&MVPbkContactViewObserver::ContactRemovedFromView,
|
|
576 |
&MVPbkContactViewObserver::ContactViewError );
|
|
577 |
VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink,
|
|
578 |
iFilteringObservers,
|
|
579 |
&MVPbkContactViewObserver::ContactRemovedFromView,
|
|
580 |
&MVPbkContactViewObserver::ContactViewError );
|
|
581 |
}
|
|
582 |
|
|
583 |
// --------------------------------------------------------------------------
|
|
584 |
// CFilteredContactView::ContactViewError
|
|
585 |
// --------------------------------------------------------------------------
|
|
586 |
//
|
|
587 |
void CFilteredContactView::ContactViewError(
|
|
588 |
MVPbkContactViewBase& aView,
|
|
589 |
TInt aError, TBool aErrorNotified )
|
|
590 |
{
|
|
591 |
VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
|
|
592 |
("CFilteredContactView::ContactViewError(0x%x)"), &aView);
|
|
593 |
|
|
594 |
VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, iObservers,
|
|
595 |
&MVPbkContactViewObserver::ContactViewError );
|
|
596 |
VPbkEng::SendEventToObservers( *this, aError, aErrorNotified,
|
|
597 |
iFilteringObservers, &MVPbkContactViewObserver::ContactViewError );
|
|
598 |
}
|
|
599 |
|
|
600 |
// --------------------------------------------------------------------------
|
|
601 |
// CFilteredContactView::ContactViewObserverExtension
|
|
602 |
// --------------------------------------------------------------------------
|
|
603 |
//
|
|
604 |
TAny* CFilteredContactView::ContactViewObserverExtension( TUid aExtensionUid )
|
|
605 |
{
|
|
606 |
if( aExtensionUid == KVPbkContactViewObserverExtension2Uid )
|
|
607 |
{
|
|
608 |
return static_cast<MVPbkContactViewObserverExtension*>( this );
|
|
609 |
}
|
|
610 |
return NULL;
|
|
611 |
}
|
|
612 |
|
|
613 |
// --------------------------------------------------------------------------
|
|
614 |
// CFilteredContactView::FilteredContactRemovedFromView
|
|
615 |
// --------------------------------------------------------------------------
|
|
616 |
//
|
|
617 |
void CFilteredContactView::FilteredContactRemovedFromView(
|
|
618 |
MVPbkContactViewBase& aView )
|
|
619 |
{
|
|
620 |
const TInt count = iObservers.Count();
|
|
621 |
|
|
622 |
for( TInt i = 0; i < count; i++ )
|
|
623 |
{
|
|
624 |
MVPbkContactViewObserver* observer = iObservers[i];
|
|
625 |
|
|
626 |
TAny* extension = observer->ContactViewObserverExtension(
|
|
627 |
KVPbkContactViewObserverExtension2Uid );
|
|
628 |
|
|
629 |
if( extension )
|
|
630 |
{
|
|
631 |
MVPbkContactViewObserverExtension* contactViewExtension =
|
|
632 |
static_cast<MVPbkContactViewObserverExtension*>( extension );
|
|
633 |
|
|
634 |
if( contactViewExtension )
|
|
635 |
{
|
|
636 |
contactViewExtension->FilteredContactRemovedFromView( aView );
|
|
637 |
}
|
|
638 |
}
|
|
639 |
}
|
|
640 |
}
|
|
641 |
|
|
642 |
// --------------------------------------------------------------------------
|
|
643 |
// CFilteredContactView::ConstructBaseViewsL
|
|
644 |
// --------------------------------------------------------------------------
|
|
645 |
//
|
|
646 |
void CFilteredContactView::ConstructBaseViewsL
|
|
647 |
( const CVPbkContactViewDefinition& aViewDefinition,
|
|
648 |
MContactViewObserver& aObserver,
|
|
649 |
RContactViewSortOrder& aViewSortOrder )
|
|
650 |
{
|
|
651 |
iNativeObserver = &aObserver;
|
|
652 |
|
|
653 |
// Construct the all contacts view first
|
|
654 |
if ( RemoteViewDefinition( aViewDefinition ) )
|
|
655 |
{
|
|
656 |
iRemoteView = CContactNamedRemoteView::NewL(
|
|
657 |
*iNativeObserver, RemoteViewName( aViewDefinition ),
|
|
658 |
Store().NativeDatabase(), aViewSortOrder,
|
|
659 |
KVPbkDefaultContactViewPrefs );
|
|
660 |
|
|
661 |
iBaseView = iRemoteView;
|
|
662 |
}
|
|
663 |
else
|
|
664 |
{
|
|
665 |
|
|
666 |
iBaseView = CContactLocalView::NewL( *iNativeObserver,
|
|
667 |
Store().NativeDatabase(), aViewSortOrder,
|
|
668 |
KVPbkDefaultContactViewPrefs );
|
|
669 |
}
|
|
670 |
|
|
671 |
// Set base class view pointer
|
|
672 |
iView = iBaseView;
|
|
673 |
|
|
674 |
// If there is a native filter, construct a native filtered view
|
|
675 |
if ( iNativeFilter > 0 )
|
|
676 |
{
|
|
677 |
iFilteredView = CContactFilteredView::NewL
|
|
678 |
( *iNativeObserver, Store().NativeDatabase(),
|
|
679 |
*iBaseView, iNativeFilter );
|
|
680 |
// Set find plugin also for BaseView, otherwise searching doesn't
|
|
681 |
// work properly with other languages in other clients.
|
|
682 |
iView->SetViewFindConfigPlugin( TUid::Uid( KFindPluginUID ) );
|
|
683 |
iView = iFilteredView;
|
|
684 |
}
|
|
685 |
}
|
|
686 |
|
|
687 |
} // namespace VPbkCntModel
|
|
688 |
|
|
689 |
// End of File
|