|
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: The contact view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <CVPbkSimContactView.h> |
|
22 |
|
23 #include "CStoreBase.h" |
|
24 #include "CContactArray.h" |
|
25 #include "CSimCntSortUtil.h" |
|
26 #include "CContactArray.h" |
|
27 #include "VPbkSimStoreImplError.h" |
|
28 |
|
29 #include <CVPbkSimContactBuf.h> |
|
30 #include <CVPbkSimContact.h> |
|
31 #include <CVPbkSimCntField.h> |
|
32 #include <CVPbkAsyncOperation.h> |
|
33 #include <CVPbkAsyncCallback.h> |
|
34 #include <CVPbkSimFieldTypeFilter.h> |
|
35 #include <CVPbkContactFindPolicy.h> |
|
36 #include <MVPbkSimViewObserver.h> |
|
37 #include <MVPbkSimViewFindObserver.h> |
|
38 #include <MVPbkSimStoreOperation.h> |
|
39 #include <RVPbkStreamedIntArray.h> |
|
40 #include <TVPbkSimStoreProperty.h> |
|
41 #include <VPbkSimStoreTemplateFunctions.h> |
|
42 #include <VPbkDebug.h> |
|
43 |
|
44 // CONSTANTS |
|
45 |
|
46 enum TVPbkSimViewState |
|
47 { |
|
48 /// View has no clients. It doesn' listen to store/contact array events |
|
49 ENotReady, |
|
50 /// View has clients but the store is not available or the view is resorting. |
|
51 /// It listens to store events but not contact array events. |
|
52 EUnvavailable, |
|
53 /// View has clients and it's ready to use. |
|
54 EReady |
|
55 }; |
|
56 |
|
57 namespace VPbkSimStoreImpl { |
|
58 |
|
59 /** |
|
60 * An active object for contact matching |
|
61 */ |
|
62 NONSHARABLE_CLASS(CContactMatchingOperation) : |
|
63 public CActive, |
|
64 public MVPbkSimStoreOperation |
|
65 { |
|
66 public: // Construction and destruction |
|
67 static CContactMatchingOperation* NewL( |
|
68 const MDesCArray& aFindStrings, |
|
69 MVPbkSimViewFindObserver& aObserver, |
|
70 MVPbkSimCntView& aSimCntView ); |
|
71 ~CContactMatchingOperation(); |
|
72 |
|
73 public: // New functions |
|
74 void Activate(); |
|
75 |
|
76 public: // Functions from CActive |
|
77 void RunL(); |
|
78 void DoCancel(); |
|
79 TInt RunError( TInt aError ); |
|
80 |
|
81 private: |
|
82 /** |
|
83 * C++ constructor |
|
84 */ |
|
85 CContactMatchingOperation( |
|
86 const MDesCArray& aFindStrings, |
|
87 MVPbkSimViewFindObserver& aObserver, |
|
88 MVPbkSimCntView& aSimCntView ); |
|
89 |
|
90 /** |
|
91 * By default Symbian 2nd phase constructor is private. |
|
92 */ |
|
93 void ConstructL(); |
|
94 |
|
95 /** |
|
96 * Contact matched |
|
97 * |
|
98 * @param aSimContact SIM contact to be matched |
|
99 * @param aType SIM contact field to be matched with find string |
|
100 * @return ETrue, if contact matched, EFalse if not |
|
101 */ |
|
102 TBool ContactMatchedL( |
|
103 MVPbkSimContact& aSimContact, |
|
104 TVPbkSimCntFieldType aType ); |
|
105 |
|
106 private: |
|
107 /// Ref: strings used in find |
|
108 const MDesCArray& iFindStrings; |
|
109 /// Ref: Observer that is interested in the result of the find |
|
110 MVPbkSimViewFindObserver& iObserver; |
|
111 /// Ref: View of SimStore to existing contacts |
|
112 MVPbkSimCntView& iSimCntView; |
|
113 /// Own: The result of the find |
|
114 RVPbkStreamedIntArray iMatchingResults; |
|
115 /// Own: Makes a string comparison |
|
116 CVPbkContactFindPolicy* iContactFindPolicy; |
|
117 }; |
|
118 |
|
119 // ============================ MEMBER FUNCTIONS ============================ |
|
120 // -------------------------------------------------------------------------- |
|
121 // CContactMatchingOperation::CContactMatchingOperation |
|
122 // C++ default constructor can NOT contain any code, that |
|
123 // might leave. |
|
124 // -------------------------------------------------------------------------- |
|
125 // |
|
126 CContactMatchingOperation::CContactMatchingOperation( |
|
127 const MDesCArray& aFindStrings, |
|
128 MVPbkSimViewFindObserver& aObserver, |
|
129 MVPbkSimCntView& aSimCntView ) |
|
130 : CActive( EPriorityStandard ), |
|
131 iFindStrings( aFindStrings ), |
|
132 iObserver( aObserver ), |
|
133 iSimCntView( aSimCntView ) |
|
134 { |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CContactMatchingOperation::ConstructL |
|
139 // Symbian 2nd phase constructor can leave. |
|
140 // -------------------------------------------------------------------------- |
|
141 // |
|
142 void CContactMatchingOperation::ConstructL() |
|
143 { |
|
144 CActiveScheduler::Add( this ); |
|
145 |
|
146 //Create contact find policy |
|
147 iContactFindPolicy = CVPbkContactFindPolicy::NewL(); |
|
148 } |
|
149 |
|
150 // -------------------------------------------------------------------------- |
|
151 // CVPbkSimContactViewFindOperation::NewL |
|
152 // Two-phased constructor. |
|
153 // -------------------------------------------------------------------------- |
|
154 // |
|
155 CContactMatchingOperation* CContactMatchingOperation::NewL( |
|
156 const MDesCArray& aFindStrings, |
|
157 MVPbkSimViewFindObserver& aObserver, |
|
158 MVPbkSimCntView& aSimCntView ) |
|
159 { |
|
160 CContactMatchingOperation* self = |
|
161 new( ELeave ) CContactMatchingOperation( aFindStrings, aObserver, |
|
162 aSimCntView ); |
|
163 CleanupStack::PushL( self ); |
|
164 self->ConstructL(); |
|
165 CleanupStack::Pop( self ); |
|
166 return self; |
|
167 } |
|
168 |
|
169 // Destructor |
|
170 CContactMatchingOperation::~CContactMatchingOperation() |
|
171 { |
|
172 delete iContactFindPolicy; |
|
173 iMatchingResults.Close(); |
|
174 Cancel(); |
|
175 // iContactFindPolicy is an ECOM plugin so call FinalClose after delete. |
|
176 REComSession::FinalClose(); |
|
177 } |
|
178 |
|
179 // -------------------------------------------------------------------------- |
|
180 // CContactMatchingOperation::Activate |
|
181 // -------------------------------------------------------------------------- |
|
182 // |
|
183 void CContactMatchingOperation::Activate() |
|
184 { |
|
185 SetActive(); |
|
186 TRequestStatus* status = &iStatus; |
|
187 User::RequestComplete( status, KErrNone ); |
|
188 } |
|
189 |
|
190 // -------------------------------------------------------------------------- |
|
191 // CContactMatchingOperation::ContactMatchedL |
|
192 // -------------------------------------------------------------------------- |
|
193 // |
|
194 TBool CContactMatchingOperation::ContactMatchedL( |
|
195 MVPbkSimContact& aSimContact, |
|
196 TVPbkSimCntFieldType aType ) |
|
197 { |
|
198 TBool result( EFalse ); |
|
199 MVPbkSimContact::TFieldLookup lookup = |
|
200 aSimContact.FindField( aType ); |
|
201 |
|
202 if ( !lookup.EndOfLookup() ) |
|
203 { |
|
204 const TDesC& data = |
|
205 aSimContact.ConstFieldAt( lookup.Index() ).Data(); |
|
206 |
|
207 const TInt findCount( iFindStrings.MdcaCount() ); |
|
208 for ( TInt i(0); i < findCount; ++i ) |
|
209 { |
|
210 // Match refine |
|
211 if ( iContactFindPolicy->MatchRefineL( |
|
212 data, iFindStrings.MdcaPoint( i ) ) ) |
|
213 { |
|
214 iMatchingResults.AppendIntL( aSimContact.SimIndex() ); |
|
215 result = ETrue; |
|
216 break; |
|
217 } |
|
218 } |
|
219 } |
|
220 |
|
221 return result; |
|
222 } |
|
223 |
|
224 // -------------------------------------------------------------------------- |
|
225 // CContactMatchingOperation::RunL |
|
226 // -------------------------------------------------------------------------- |
|
227 // |
|
228 void CContactMatchingOperation::RunL() |
|
229 { |
|
230 const TInt count( iSimCntView.CountL() ); |
|
231 for ( TInt i(0); i < count; ++i ) |
|
232 { |
|
233 MVPbkSimContact& simContact = iSimCntView.ContactAtL( i ); |
|
234 MVPbkSimContact::TFieldLookup lookupSimName = simContact.FindField( EVPbkSimName ); |
|
235 //try to fetch contact with EVPbkSimName |
|
236 if ( !lookupSimName.EndOfLookup() ) |
|
237 { |
|
238 ContactMatchedL( simContact, EVPbkSimName ); |
|
239 } |
|
240 //if contact without name, then try to fetch it with EVPbkSimGsmNumber |
|
241 else |
|
242 { |
|
243 MVPbkSimContact::TFieldLookup lookupGsmNum = simContact.FindField( EVPbkSimGsmNumber ); |
|
244 if ( !lookupGsmNum.EndOfLookup() ) |
|
245 { |
|
246 ContactMatchedL( simContact, EVPbkSimGsmNumber ); |
|
247 } |
|
248 } |
|
249 } |
|
250 iObserver.ViewFindCompleted( iSimCntView, iMatchingResults ); |
|
251 } |
|
252 |
|
253 // -------------------------------------------------------------------------- |
|
254 // CContactMatchingOperation::DoCancel |
|
255 // -------------------------------------------------------------------------- |
|
256 // |
|
257 void CContactMatchingOperation::DoCancel() |
|
258 { |
|
259 // Operation has no handles to any services -> do nothing |
|
260 } |
|
261 |
|
262 // -------------------------------------------------------------------------- |
|
263 // CContactMatchingOperation::RunError |
|
264 // -------------------------------------------------------------------------- |
|
265 // |
|
266 TInt CContactMatchingOperation::RunError( TInt aError ) |
|
267 { |
|
268 iObserver.ViewFindError( iSimCntView, aError ); |
|
269 return KErrNone; |
|
270 } |
|
271 |
|
272 } // namespace VPbkSimStoreImpl |
|
273 |
|
274 |
|
275 // -------------------------------------------------------------------------- |
|
276 // CVPbkSimContactView::CVPbkSimContactView |
|
277 // C++ default constructor can NOT contain any code, that |
|
278 // might leave. |
|
279 // -------------------------------------------------------------------------- |
|
280 // |
|
281 CVPbkSimContactView::CVPbkSimContactView( MVPbkSimCntStore& aParentStore, |
|
282 TVPbkSimViewConstructionPolicy aConstructionPolicy ) |
|
283 : iParentStore( aParentStore ), |
|
284 iConstructionPolicy( aConstructionPolicy ), |
|
285 iViewState( ENotReady ) |
|
286 { |
|
287 } |
|
288 |
|
289 // -------------------------------------------------------------------------- |
|
290 // CVPbkSimContactView::~CVPbkSimContactView |
|
291 // -------------------------------------------------------------------------- |
|
292 // |
|
293 CVPbkSimContactView::~CVPbkSimContactView() |
|
294 { |
|
295 delete iIdleSort; |
|
296 SetToNotReadyState(); |
|
297 delete iAsyncOperation; |
|
298 iObservers.Close(); |
|
299 iSortOrder.Close(); |
|
300 delete iViewName; |
|
301 delete iSortUtil; |
|
302 delete iCurrentContact; |
|
303 delete iTempContactForSorting; |
|
304 delete iFilter; |
|
305 } |
|
306 |
|
307 // -------------------------------------------------------------------------- |
|
308 // CVPbkSimContactView::NewLC |
|
309 // Two-phased constructor. |
|
310 // -------------------------------------------------------------------------- |
|
311 // |
|
312 EXPORT_C CVPbkSimContactView* CVPbkSimContactView::NewLC( |
|
313 const RVPbkSimFieldTypeArray& aSortOrder, |
|
314 TVPbkSimViewConstructionPolicy aConstructionPolicy, |
|
315 MVPbkSimCntStore& aParentStore, const TDesC& aViewName, |
|
316 CVPbkSimFieldTypeFilter* aFilter ) |
|
317 { |
|
318 CVPbkSimContactView* self = |
|
319 new ( ELeave ) CVPbkSimContactView( aParentStore, |
|
320 aConstructionPolicy ); |
|
321 CleanupStack::PushL( self ); |
|
322 self->ConstructL( aSortOrder, aViewName ); |
|
323 self->iFilter = aFilter; |
|
324 return self; |
|
325 } |
|
326 |
|
327 // -------------------------------------------------------------------------- |
|
328 // CVPbkSimContactView::ConstructL |
|
329 // Symbian 2nd phase constructor can leave. |
|
330 // -------------------------------------------------------------------------- |
|
331 // |
|
332 void CVPbkSimContactView::ConstructL( const RVPbkSimFieldTypeArray& aSortOrder, |
|
333 const TDesC& aViewName ) |
|
334 { |
|
335 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
336 "VPbkSimStoreImpl: CVPbkSimContactView(0x%x)::ConstructL name=%S"), |
|
337 this, &aViewName ); |
|
338 |
|
339 iIdleSort = CIdle::NewL( CActive::EPriorityStandard ); |
|
340 ResetAndCopySortOrderL( aSortOrder ); |
|
341 iViewName = aViewName.AllocL(); |
|
342 iAsyncOperation = |
|
343 CVPbkAsyncObjectOperation<MVPbkSimViewObserver>::NewL(); |
|
344 iCurrentContact = CVPbkSimContactBuf::NewL( iParentStore ); |
|
345 iTempContactForSorting = CVPbkSimContactBuf::NewL( iParentStore ); |
|
346 } |
|
347 |
|
348 // -------------------------------------------------------------------------- |
|
349 // CVPbkSimContactView::Name |
|
350 // -------------------------------------------------------------------------- |
|
351 // |
|
352 const TDesC& CVPbkSimContactView::Name() const |
|
353 { |
|
354 return *iViewName; |
|
355 } |
|
356 |
|
357 // -------------------------------------------------------------------------- |
|
358 // CVPbkSimContactView::ParentStore |
|
359 // -------------------------------------------------------------------------- |
|
360 // |
|
361 MVPbkSimCntStore& CVPbkSimContactView::ParentStore() const |
|
362 { |
|
363 return iParentStore; |
|
364 } |
|
365 |
|
366 // -------------------------------------------------------------------------- |
|
367 // CVPbkSimContactView::OpenL |
|
368 // -------------------------------------------------------------------------- |
|
369 // |
|
370 void CVPbkSimContactView::OpenL( MVPbkSimViewObserver& aObserver ) |
|
371 { |
|
372 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
373 "VPbkSimStoreImpl: CVPbkSimContactView(0x%x)::OpenL name=%S,aObserver=0x%x,state=%d"), |
|
374 this, iViewName, &aObserver, iViewState ); |
|
375 |
|
376 if ( ViewStateNotReady() ) |
|
377 { |
|
378 // Call close first to ensure store is not opened many times |
|
379 iParentStore.Close( *this ); |
|
380 // Open a store asynchronously. |
|
381 iParentStore.OpenL( *this ); |
|
382 } |
|
383 else |
|
384 { |
|
385 void( CVPbkSimContactView::* notifyFuncPtr)( MVPbkSimViewObserver& ) = |
|
386 &CVPbkSimContactView::DoViewOpenCallbackL; |
|
387 if ( ViewStateUnavailable() ) |
|
388 { |
|
389 notifyFuncPtr = &CVPbkSimContactView::DoViewUnavailableCallbackL; |
|
390 } |
|
391 |
|
392 CVPbkAsyncObjectCallback<MVPbkSimViewObserver>* callback = |
|
393 VPbkEngUtils::CreateAsyncObjectCallbackLC( |
|
394 *this, |
|
395 notifyFuncPtr, |
|
396 &CVPbkSimContactView::DoViewErrorCallback, |
|
397 aObserver ); |
|
398 iAsyncOperation->CallbackL(callback); |
|
399 CleanupStack::Pop(); // callBack |
|
400 } |
|
401 |
|
402 if ( iObservers.Find( &aObserver ) == KErrNotFound ) |
|
403 { |
|
404 iObservers.AppendL( &aObserver ); |
|
405 } |
|
406 } |
|
407 |
|
408 // -------------------------------------------------------------------------- |
|
409 // CVPbkSimContactView::Close |
|
410 // -------------------------------------------------------------------------- |
|
411 // |
|
412 void CVPbkSimContactView::Close( MVPbkSimViewObserver& aObserver ) |
|
413 { |
|
414 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
415 "VPbkSimStoreImpl: CVPbkSimContactView::Close name=%S,aObserver=0x%x,state=%d"), |
|
416 iViewName, &aObserver, iViewState ); |
|
417 |
|
418 iAsyncOperation->CancelCallback( &aObserver ); |
|
419 |
|
420 TInt index = iObservers.Find( &aObserver ); |
|
421 if ( index >= 0 ) |
|
422 { |
|
423 iObservers.Remove( index ); |
|
424 if ( iObservers.Count() == 0 ) |
|
425 { |
|
426 SetToNotReadyState(); |
|
427 } |
|
428 } |
|
429 } |
|
430 |
|
431 // -------------------------------------------------------------------------- |
|
432 // CVPbkSimContactView::CountL |
|
433 // -------------------------------------------------------------------------- |
|
434 // |
|
435 TInt CVPbkSimContactView::CountL() const |
|
436 { |
|
437 return iViewContacts.Count(); |
|
438 } |
|
439 |
|
440 // -------------------------------------------------------------------------- |
|
441 // CVPbkSimContactView::ContactAtL |
|
442 // -------------------------------------------------------------------------- |
|
443 // |
|
444 MVPbkSimContact& CVPbkSimContactView::ContactAtL( TInt aIndex ) |
|
445 { |
|
446 if ( aIndex < 0 || aIndex >= iViewContacts.Count() ) |
|
447 { |
|
448 User::Leave( KErrArgument ); |
|
449 } |
|
450 |
|
451 const MVPbkSimContact* fullContact = |
|
452 iParentStore.ContactAtL( iViewContacts[aIndex].iSimIndex ); |
|
453 |
|
454 // Check that view is up to date |
|
455 __ASSERT_DEBUG( fullContact, |
|
456 Panic( VPbkSimStoreImpl::EViewArrayNotUpToDate ) ); |
|
457 if ( !fullContact ) |
|
458 { |
|
459 User::Leave( KErrNotFound ); |
|
460 } |
|
461 |
|
462 CVPbkSimContact* cnt = |
|
463 CVPbkSimContact::NewLC( iParentStore ); |
|
464 // Copy fields that have same type as in the sortorder |
|
465 TInt count = iSortOrder.Count(); |
|
466 for ( TInt i = 0; i < count; ++i ) |
|
467 { |
|
468 MVPbkSimContact::TFieldLookup lookup = |
|
469 fullContact->FindField( iSortOrder[i] ); |
|
470 if ( !lookup.EndOfLookup() ) |
|
471 { |
|
472 CVPbkSimCntField* field = cnt->CreateFieldLC( iSortOrder[i] ); |
|
473 field->SetDataL( fullContact->ConstFieldAt( lookup.Index() ).Data() ); |
|
474 cnt->AddFieldL( field ); |
|
475 CleanupStack::Pop( field ); |
|
476 } |
|
477 } |
|
478 |
|
479 cnt->SetSimIndex( fullContact->SimIndex() ); |
|
480 iCurrentContact->SetL( cnt->ETelContactL() ); |
|
481 CleanupStack::PopAndDestroy( cnt ); |
|
482 return *iCurrentContact; |
|
483 } |
|
484 |
|
485 // -------------------------------------------------------------------------- |
|
486 // CVPbkSimContactView::ChangeSortOrderL |
|
487 // -------------------------------------------------------------------------- |
|
488 // |
|
489 void CVPbkSimContactView::ChangeSortOrderL( const RVPbkSimFieldTypeArray& aSortOrder ) |
|
490 { |
|
491 // Copy the new sort order to the view |
|
492 ResetAndCopySortOrderL( aSortOrder ); |
|
493 |
|
494 // Change state only if the view is currently ready, Otherwise |
|
495 // the view is already waiting sorting or store event. |
|
496 if ( ViewStateReady() ) |
|
497 { |
|
498 // Change to unavailable: view will be ready after sorting. |
|
499 SetToUnavailableState(); |
|
500 // Resort view. |
|
501 StartSorting(); |
|
502 } |
|
503 } |
|
504 |
|
505 // -------------------------------------------------------------------------- |
|
506 // CVPbkSimContactView::MapSimIndexToViewIndexL |
|
507 // -------------------------------------------------------------------------- |
|
508 // |
|
509 TInt CVPbkSimContactView::MapSimIndexToViewIndexL( TInt aSimIndex ) |
|
510 { |
|
511 TViewContact cnt( aSimIndex ); |
|
512 return iViewContacts.Find( cnt, |
|
513 TIdentityRelation<TViewContact>( &CVPbkSimContactView::CompareViewContactSimIndex ) ); |
|
514 } |
|
515 |
|
516 // -------------------------------------------------------------------------- |
|
517 // CVPbkSimContactView::ContactMatchingPrefixL |
|
518 // -------------------------------------------------------------------------- |
|
519 // |
|
520 MVPbkSimStoreOperation* CVPbkSimContactView::ContactMatchingPrefixL( |
|
521 const MDesCArray& aFindStrings, |
|
522 MVPbkSimViewFindObserver& aObserver ) |
|
523 { |
|
524 VPbkSimStoreImpl::CContactMatchingOperation* operation = |
|
525 VPbkSimStoreImpl::CContactMatchingOperation::NewL( aFindStrings, |
|
526 aObserver, *this ); |
|
527 operation->Activate(); |
|
528 return operation; |
|
529 } |
|
530 |
|
531 // -------------------------------------------------------------------------- |
|
532 // CVPbkSimContactView::SortOrderL |
|
533 // -------------------------------------------------------------------------- |
|
534 // |
|
535 const RVPbkSimFieldTypeArray& CVPbkSimContactView::SortOrderL() const |
|
536 { |
|
537 return iSortOrder; |
|
538 } |
|
539 |
|
540 // -------------------------------------------------------------------------- |
|
541 // CVPbkSimContactView::StoreReady |
|
542 // -------------------------------------------------------------------------- |
|
543 // |
|
544 void CVPbkSimContactView::StoreReady( MVPbkSimCntStore& /*aStore*/ ) |
|
545 { |
|
546 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
547 "VPbkSimStoreImpl: CVPbkSimContactView::StoreReady")); |
|
548 |
|
549 // Store has become ready or has been updated. Update the view too. |
|
550 StartSorting(); |
|
551 } |
|
552 |
|
553 // -------------------------------------------------------------------------- |
|
554 // CVPbkSimContactView::StoreReady |
|
555 // -------------------------------------------------------------------------- |
|
556 // |
|
557 void CVPbkSimContactView::StoreError( MVPbkSimCntStore& /*aStore*/, TInt aError ) |
|
558 { |
|
559 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
560 "VPbkSimStoreImpl: CVPbkSimContactView::StoreError %d"), aError); |
|
561 |
|
562 SetToUnavailableState(); |
|
563 VPbkSimStoreImpl::SendObserverMessageRV( iObservers, |
|
564 &MVPbkSimViewObserver::ViewError, *this, aError ); |
|
565 } |
|
566 |
|
567 // -------------------------------------------------------------------------- |
|
568 // CVPbkSimContactView::StoreNotAvailable |
|
569 // -------------------------------------------------------------------------- |
|
570 // |
|
571 void CVPbkSimContactView::StoreNotAvailable( MVPbkSimCntStore& /*aStore*/ ) |
|
572 { |
|
573 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
574 "VPbkSimStoreImpl: CVPbkSimContactView::StoreNotAvailable")); |
|
575 |
|
576 // Reset view until StoreReady is called again |
|
577 SetToUnavailableState(); |
|
578 } |
|
579 |
|
580 // -------------------------------------------------------------------------- |
|
581 // CVPbkSimContactView::StoreContactEvent |
|
582 // -------------------------------------------------------------------------- |
|
583 // |
|
584 void CVPbkSimContactView::StoreContactEvent( TEvent aEvent, TInt aSimIndex ) |
|
585 { |
|
586 TRAPD( res, HandleStoreContactEventL( aEvent, aSimIndex ) ); |
|
587 if ( res != KErrNone ) |
|
588 { |
|
589 // The view is not up to date any more. |
|
590 SetToUnavailableState(); |
|
591 VPbkSimStoreImpl::SendObserverMessageRV( iObservers, |
|
592 &MVPbkSimViewObserver::ViewError, *this, res ); |
|
593 } |
|
594 } |
|
595 |
|
596 // -------------------------------------------------------------------------- |
|
597 // CVPbkSimContactView::Sort |
|
598 // -------------------------------------------------------------------------- |
|
599 // |
|
600 void CVPbkSimContactView::Sort() |
|
601 { |
|
602 TRAPD( res, SortL() ); |
|
603 if ( res != KErrNone ) |
|
604 { |
|
605 SortError( res ); |
|
606 } |
|
607 } |
|
608 |
|
609 // -------------------------------------------------------------------------- |
|
610 // CVPbkSimContactView::SortL |
|
611 // -------------------------------------------------------------------------- |
|
612 // |
|
613 void CVPbkSimContactView::SortL() |
|
614 { |
|
615 // Get the size of the store |
|
616 TVPbkGsmStoreProperty properties; |
|
617 User::LeaveIfError( iParentStore. GetGsmStoreProperties( properties ) ); |
|
618 TInt lastIndex = properties.iTotalEntries; |
|
619 |
|
620 // Loop all contacts of the store. |
|
621 for ( TInt i = KVPbkSimStoreFirstETelIndex; i <= lastIndex; ++i ) |
|
622 { |
|
623 const MVPbkSimContact* cnt = iParentStore.ContactAtL( i ); |
|
624 if ( cnt ) |
|
625 { |
|
626 InsertViewContactL( *cnt ); |
|
627 } |
|
628 } |
|
629 |
|
630 // All contacts have been sorted and the view is ready |
|
631 SetToReadyState(); |
|
632 } |
|
633 |
|
634 // -------------------------------------------------------------------------- |
|
635 // CVPbkSimContactView::SortError |
|
636 // -------------------------------------------------------------------------- |
|
637 // |
|
638 TInt CVPbkSimContactView::SortError( TInt aError ) |
|
639 { |
|
640 iAsyncOperation->Purge(); |
|
641 VPbkSimStoreImpl::SendObserverMessageRV( iObservers, |
|
642 &MVPbkSimViewObserver::ViewError, *this, aError ); |
|
643 return KErrNone; |
|
644 } |
|
645 |
|
646 |
|
647 // -------------------------------------------------------------------------- |
|
648 // CVPbkSimContactView::IsSorting |
|
649 // -------------------------------------------------------------------------- |
|
650 // |
|
651 TBool CVPbkSimContactView::IsSorting() const |
|
652 { |
|
653 return iIdleSort->IsActive(); |
|
654 } |
|
655 |
|
656 // -------------------------------------------------------------------------- |
|
657 // CVPbkSimContactView::StartSorting |
|
658 // -------------------------------------------------------------------------- |
|
659 // |
|
660 void CVPbkSimContactView::StartSorting() |
|
661 { |
|
662 iIdleSort->Cancel(); |
|
663 iIdleSort->Start( |
|
664 TCallBack( CVPbkSimContactView::IdleSortCallback, this ) ); |
|
665 } |
|
666 |
|
667 // -------------------------------------------------------------------------- |
|
668 // CVPbkSimContactView::HandleStoreContactEventL |
|
669 // -------------------------------------------------------------------------- |
|
670 // |
|
671 void CVPbkSimContactView::HandleStoreContactEventL( TEvent aEvent, TInt aSimIndex ) |
|
672 { |
|
673 switch( aEvent ) |
|
674 { |
|
675 case EContactAdded: |
|
676 { |
|
677 HandleContactAddedL( aSimIndex ); |
|
678 break; |
|
679 } |
|
680 case EContactDeleted: |
|
681 { |
|
682 HandleContactRemoved( aSimIndex ); |
|
683 break; |
|
684 } |
|
685 case EContactChanged: |
|
686 { |
|
687 HandleContactChangedL( aSimIndex ); |
|
688 break; |
|
689 } |
|
690 default: |
|
691 { |
|
692 break; |
|
693 } |
|
694 } |
|
695 } |
|
696 |
|
697 // -------------------------------------------------------------------------- |
|
698 // CVPbkSimContactView::HandleContactAddedL |
|
699 // -------------------------------------------------------------------------- |
|
700 // |
|
701 void CVPbkSimContactView::HandleContactAddedL( TInt aSimIndex ) |
|
702 { |
|
703 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
704 "VPbkSimStoreImpl: CVPbkSimContactView::HandleContactAdded: simIndex %d"), |
|
705 aSimIndex ); |
|
706 |
|
707 const MVPbkSimContact* addedCnt = iParentStore.ContactAtL( aSimIndex ); |
|
708 if ( addedCnt ) |
|
709 { |
|
710 TInt viewIndex = InsertViewContactL( *addedCnt ); |
|
711 VPbkSimStoreImpl::SendObserverMessageVVV( iObservers, |
|
712 &MVPbkSimViewObserver::ViewContactEvent, |
|
713 MVPbkSimViewObserver::EContactAdded, viewIndex, aSimIndex ); |
|
714 } |
|
715 } |
|
716 |
|
717 // -------------------------------------------------------------------------- |
|
718 // CVPbkSimContactView::HandleContactRemoved |
|
719 // -------------------------------------------------------------------------- |
|
720 // |
|
721 void CVPbkSimContactView::HandleContactRemoved( TInt aSimIndex ) |
|
722 { |
|
723 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
724 "VPbkSimStoreImpl: CVPbkSimContactView::HandleContactRemoved: simIndex %d"), |
|
725 aSimIndex ); |
|
726 |
|
727 TInt removedIndex = RemoveViewContact( aSimIndex ); |
|
728 VPbkSimStoreImpl::SendObserverMessageVVV( iObservers, |
|
729 &MVPbkSimViewObserver::ViewContactEvent, |
|
730 MVPbkSimViewObserver::EContactDeleted, removedIndex, aSimIndex ); |
|
731 } |
|
732 |
|
733 // -------------------------------------------------------------------------- |
|
734 // CVPbkSimContactView::HandleContactChangedL |
|
735 // -------------------------------------------------------------------------- |
|
736 // |
|
737 void CVPbkSimContactView::HandleContactChangedL( TInt aSimIndex ) |
|
738 { |
|
739 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
740 "VPbkSimStoreImpl: CVPbkSimContactView::HandleContactChanged: simIndex %d"), |
|
741 aSimIndex ); |
|
742 |
|
743 // Changed contact is a bit complicated from the view point of view |
|
744 // due to case of contacts that have same name |
|
745 // E.g the view has following contacts |
|
746 // index 0: Jill |
|
747 // index 1: Jill |
|
748 // index 2: Jill |
|
749 // Then editing any of them must not change the position of the |
|
750 // contact in the view if the name remains same. |
|
751 |
|
752 // Get the changed contact |
|
753 const MVPbkSimContact* changedCnt = iParentStore.ContactAtL( aSimIndex ); |
|
754 |
|
755 if ( changedCnt ) |
|
756 { |
|
757 // Get current position of the changed contact |
|
758 TInt curIndex = iViewContacts.Find( aSimIndex, |
|
759 TIdentityRelation<TViewContact>( CompareViewContactSimIndex ) ); |
|
760 |
|
761 // Remove the contact from the view |
|
762 TInt nextContactIndex = curIndex + 1; |
|
763 |
|
764 // Investigate if we can ignore the event from view point of i.e if |
|
765 // the position of the contacts is still same. |
|
766 TBool keepInSamePos = EFalse; |
|
767 const TInt viewCntCount = iViewContacts.Count(); |
|
768 if ( PassesFilter( *changedCnt, iFilter ) && |
|
769 nextContactIndex >= 0 && nextContactIndex < viewCntCount ) |
|
770 { |
|
771 // Create a temp copy of changedCnt becuase next ContactAtL will |
|
772 // overwrite the reference. |
|
773 CVPbkSimContactBuf* temp = CVPbkSimContactBuf::NewLC( |
|
774 changedCnt->ETelContactL(), iParentStore ); |
|
775 // Get the next contact |
|
776 const MVPbkSimContact* nextCnt = iParentStore.ContactAtL( |
|
777 iViewContacts[nextContactIndex].iSimIndex ); |
|
778 // Compare names of the changed contact and the next contact |
|
779 if ( iSortUtil->Compare( *temp, *nextCnt ) == 0 ) |
|
780 { |
|
781 // Next contact has a same name. This means that we don't |
|
782 // need to modify the view at all. |
|
783 keepInSamePos = ETrue; |
|
784 } |
|
785 CleanupStack::PopAndDestroy( temp ); |
|
786 } |
|
787 |
|
788 if ( keepInSamePos ) |
|
789 { |
|
790 // Though there was no need to change anything the events must still |
|
791 // be sent to observers. |
|
792 VPbkSimStoreImpl::SendObserverMessageVVV( iObservers, |
|
793 &MVPbkSimViewObserver::ViewContactEvent, |
|
794 MVPbkSimViewObserver::EContactDeleted, curIndex, aSimIndex ); |
|
795 VPbkSimStoreImpl::SendObserverMessageVVV( iObservers, |
|
796 &MVPbkSimViewObserver::ViewContactEvent, |
|
797 MVPbkSimViewObserver::EContactAdded, curIndex, aSimIndex ); |
|
798 } |
|
799 else |
|
800 { |
|
801 HandleContactRemoved( aSimIndex ); |
|
802 HandleContactAddedL( aSimIndex ); |
|
803 } |
|
804 } |
|
805 } |
|
806 |
|
807 |
|
808 // -------------------------------------------------------------------------- |
|
809 // CVPbkSimContactView::InsertViewContactL |
|
810 // -------------------------------------------------------------------------- |
|
811 // |
|
812 TInt CVPbkSimContactView::InsertViewContactL( |
|
813 const MVPbkSimContact& aContact ) |
|
814 { |
|
815 TInt index = KErrNotFound; |
|
816 if ( PassesFilter( aContact, iFilter ) ) |
|
817 { |
|
818 // Use temp contact because Sorting uses ContactAtL |
|
819 iTempContactForSorting->SetL( aContact.ETelContactL() ); |
|
820 if ( iConstructionPolicy == EVPbkSortedSimView ) |
|
821 { |
|
822 index = SortedIndexL( *iTempContactForSorting ); |
|
823 } |
|
824 else |
|
825 { |
|
826 index = UnsortedIndex( *iTempContactForSorting ); |
|
827 } |
|
828 TViewContact cnt( iTempContactForSorting->SimIndex() ); |
|
829 iViewContacts.InsertL( cnt, index ); |
|
830 } |
|
831 return index; |
|
832 } |
|
833 |
|
834 // -------------------------------------------------------------------------- |
|
835 // CVPbkSimContactView::SortedIndexL |
|
836 // -------------------------------------------------------------------------- |
|
837 // |
|
838 TInt CVPbkSimContactView::SortedIndexL( const MVPbkSimContact& aLeft ) |
|
839 { |
|
840 TInt first = 0; |
|
841 TInt len = iViewContacts.Count(); |
|
842 |
|
843 while ( len > 0 ) |
|
844 { |
|
845 TInt half = len / 2; |
|
846 TInt middle = first + half; |
|
847 TInt simIndex = iViewContacts[middle].iSimIndex; |
|
848 const MVPbkSimContact* right = |
|
849 iParentStore.ContactAtL( simIndex ); |
|
850 if ( iSortUtil->Compare( aLeft, *right ) < 0 ) |
|
851 { |
|
852 len = half; |
|
853 } |
|
854 else |
|
855 { |
|
856 first = middle + 1; |
|
857 len = len - half - 1; |
|
858 } |
|
859 } |
|
860 |
|
861 len = iViewContacts.Count(); |
|
862 if ( first < len ) |
|
863 { |
|
864 TInt simIndex = iViewContacts[first].iSimIndex; |
|
865 if ( iSortUtil->Compare( aLeft, |
|
866 *iParentStore.ContactAtL( simIndex ) ) == 0 ) |
|
867 { |
|
868 ++first; |
|
869 } |
|
870 } |
|
871 |
|
872 __ASSERT_DEBUG( first <= len, |
|
873 Panic( VPbkSimStoreImpl::EInvalidSortedIndex ) ); |
|
874 if ( first > len ) |
|
875 { |
|
876 first = len; |
|
877 } |
|
878 |
|
879 return first; |
|
880 } |
|
881 |
|
882 // -------------------------------------------------------------------------- |
|
883 // CVPbkSimContactView::UnsortedIndex |
|
884 // -------------------------------------------------------------------------- |
|
885 // |
|
886 TInt CVPbkSimContactView::UnsortedIndex( const MVPbkSimContact& aLeft ) |
|
887 { |
|
888 const TInt count = iViewContacts.Count(); |
|
889 for ( TInt i = 0; i < count; ++i ) |
|
890 { |
|
891 if ( aLeft.SimIndex() < iViewContacts[i].iSimIndex ) |
|
892 { |
|
893 return i; |
|
894 } |
|
895 } |
|
896 return count; |
|
897 } |
|
898 |
|
899 // -------------------------------------------------------------------------- |
|
900 // CVPbkSimContactView::RemoveViewContact |
|
901 // -------------------------------------------------------------------------- |
|
902 // |
|
903 TInt CVPbkSimContactView::RemoveViewContact( TInt aSimIndex ) |
|
904 { |
|
905 TInt index = iViewContacts.Find( aSimIndex, |
|
906 TIdentityRelation<TViewContact>( CompareViewContactSimIndex ) ); |
|
907 |
|
908 if ( index != KErrNotFound ) |
|
909 { |
|
910 iViewContacts.Remove( index ); |
|
911 } |
|
912 |
|
913 return index; |
|
914 } |
|
915 |
|
916 // -------------------------------------------------------------------------- |
|
917 // CVPbkSimContactView::ResetAndCopySortOrderL |
|
918 // -------------------------------------------------------------------------- |
|
919 // |
|
920 void CVPbkSimContactView::ResetAndCopySortOrderL( const RVPbkSimFieldTypeArray& aSource ) |
|
921 { |
|
922 // Reset old sort order |
|
923 iSortOrder.Reset(); |
|
924 // Copy the new one |
|
925 TInt count = aSource.Count(); |
|
926 for ( TInt i = 0; i < count; ++i ) |
|
927 { |
|
928 iSortOrder.AppendL( aSource[i] ); |
|
929 } |
|
930 // Recreate sort util with new sort order |
|
931 VPbkSimStoreImpl::CSimCntSortUtil* sortUtil = |
|
932 VPbkSimStoreImpl::CSimCntSortUtil::NewL( iSortOrder ); |
|
933 delete iSortUtil; |
|
934 iSortUtil = sortUtil; |
|
935 } |
|
936 |
|
937 // -------------------------------------------------------------------------- |
|
938 // CVPbkSimContactView::Reset |
|
939 // -------------------------------------------------------------------------- |
|
940 // |
|
941 void CVPbkSimContactView::Reset() |
|
942 { |
|
943 iViewContacts.Reset(); |
|
944 } |
|
945 |
|
946 // -------------------------------------------------------------------------- |
|
947 // CVPbkSimContactView::PassesFilter |
|
948 // -------------------------------------------------------------------------- |
|
949 // |
|
950 inline TBool CVPbkSimContactView::PassesFilter( const MVPbkSimContact& aContact, |
|
951 const CVPbkSimFieldTypeFilter* aFilter ) const |
|
952 { |
|
953 // Initialize to 'fail' |
|
954 TBool ret = EFalse; |
|
955 |
|
956 if ( aFilter ) |
|
957 { |
|
958 // Get filtering criteria |
|
959 TUint16 criteria = aFilter->FilteringCriteria(); |
|
960 |
|
961 if ( criteria & |
|
962 CVPbkSimFieldTypeFilter::ESimFilterCriteriaGsmNumber ) |
|
963 { |
|
964 MVPbkSimContact::TFieldLookup lookup = |
|
965 aContact.FindField( EVPbkSimGsmNumber ); |
|
966 ret = !lookup.EndOfLookup(); |
|
967 } |
|
968 |
|
969 if ( !ret && criteria & |
|
970 CVPbkSimFieldTypeFilter::ESimFilterCriteriaAdditionalNumber ) |
|
971 { |
|
972 MVPbkSimContact::TFieldLookup lookup = |
|
973 aContact.FindField( EVPbkSimAdditionalNumber ); |
|
974 ret = !lookup.EndOfLookup(); |
|
975 } |
|
976 |
|
977 if ( !ret && criteria & |
|
978 CVPbkSimFieldTypeFilter::ESimFilterCriteriaEmailAddress ) |
|
979 { |
|
980 MVPbkSimContact::TFieldLookup lookup = |
|
981 aContact.FindField( EVPbkSimEMailAddress ); |
|
982 ret = !lookup.EndOfLookup(); |
|
983 } |
|
984 |
|
985 if ( !ret && criteria & |
|
986 CVPbkSimFieldTypeFilter::ESimFilterCriteriaName ) |
|
987 { |
|
988 MVPbkSimContact::TFieldLookup lookup = |
|
989 aContact.FindField( EVPbkSimName ); |
|
990 ret = !lookup.EndOfLookup(); |
|
991 } |
|
992 |
|
993 if ( !ret && criteria & |
|
994 CVPbkSimFieldTypeFilter::ESimFilterCriteriaSecondName ) |
|
995 { |
|
996 MVPbkSimContact::TFieldLookup lookup = |
|
997 aContact.FindField( EVPbkSimNickName ); |
|
998 ret = !lookup.EndOfLookup(); |
|
999 } |
|
1000 |
|
1001 if ( !ret && criteria == 0 ) |
|
1002 { |
|
1003 ret = ETrue; |
|
1004 } |
|
1005 } |
|
1006 else |
|
1007 { |
|
1008 ret = ETrue; |
|
1009 } |
|
1010 |
|
1011 return ret; |
|
1012 } |
|
1013 |
|
1014 // -------------------------------------------------------------------------- |
|
1015 // CVPbkSimContactView::SetToReadyState |
|
1016 // -------------------------------------------------------------------------- |
|
1017 // |
|
1018 void CVPbkSimContactView::SetToReadyState() |
|
1019 { |
|
1020 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
1021 "VPbkSimStoreImpl: CVPbkSimContactView::SetToReadyState")); |
|
1022 // Cancel any async callback because event is sent to all observer |
|
1023 iAsyncOperation->Purge(); |
|
1024 |
|
1025 iViewState = EReady; |
|
1026 VPbkSimStoreImpl::SendObserverMessageR( iObservers, |
|
1027 &MVPbkSimViewObserver::ViewReady, *this ); |
|
1028 } |
|
1029 |
|
1030 // -------------------------------------------------------------------------- |
|
1031 // CVPbkSimContactView::SetToNotReadyState |
|
1032 // In Not Ready State the view doesn't have observer and it |
|
1033 // doesn't listen to any events. It waits that a client calls OpenL. |
|
1034 // -------------------------------------------------------------------------- |
|
1035 // |
|
1036 void CVPbkSimContactView::SetToNotReadyState() |
|
1037 { |
|
1038 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
1039 "VPbkSimStoreImpl: CVPbkSimContactView::SetToNotReadyState")); |
|
1040 |
|
1041 Reset(); |
|
1042 iParentStore.Close( *this ); |
|
1043 iViewState = ENotReady; |
|
1044 } |
|
1045 |
|
1046 // -------------------------------------------------------------------------- |
|
1047 // CVPbkSimContactView::SetToUnavailableState |
|
1048 // In Unavailable state the view doesn' listen to contact events. It listens |
|
1049 // to store event to get Store Ready event. |
|
1050 // -------------------------------------------------------------------------- |
|
1051 // |
|
1052 void CVPbkSimContactView::SetToUnavailableState() |
|
1053 { |
|
1054 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
1055 "VPbkSimStoreImpl: CVPbkSimContactView::SetToUnavailableState")); |
|
1056 |
|
1057 Reset(); |
|
1058 iAsyncOperation->Purge(); |
|
1059 iViewState = EUnvavailable; |
|
1060 VPbkSimStoreImpl::SendObserverMessageR( iObservers, |
|
1061 &MVPbkSimViewObserver::ViewNotAvailable, *this ); |
|
1062 } |
|
1063 |
|
1064 // -------------------------------------------------------------------------- |
|
1065 // CVPbkSimContactView::ViewStateReady |
|
1066 // -------------------------------------------------------------------------- |
|
1067 // |
|
1068 TBool CVPbkSimContactView::ViewStateReady() const |
|
1069 { |
|
1070 return iViewState == EReady; |
|
1071 } |
|
1072 |
|
1073 // -------------------------------------------------------------------------- |
|
1074 // CVPbkSimContactView::ViewStateUnavailable |
|
1075 // -------------------------------------------------------------------------- |
|
1076 // |
|
1077 TBool CVPbkSimContactView::ViewStateUnavailable() const |
|
1078 { |
|
1079 return iViewState == EUnvavailable; |
|
1080 } |
|
1081 |
|
1082 // -------------------------------------------------------------------------- |
|
1083 // CVPbkSimContactView::ViewStateNotReady |
|
1084 // -------------------------------------------------------------------------- |
|
1085 // |
|
1086 TBool CVPbkSimContactView::ViewStateNotReady() const |
|
1087 { |
|
1088 return iViewState == ENotReady; |
|
1089 } |
|
1090 |
|
1091 // -------------------------------------------------------------------------- |
|
1092 // CVPbkSimContactView::DoViewOpenCallbackL |
|
1093 // -------------------------------------------------------------------------- |
|
1094 // |
|
1095 void CVPbkSimContactView::DoViewOpenCallbackL( MVPbkSimViewObserver& aObserver ) |
|
1096 { |
|
1097 aObserver.ViewReady( *this ); |
|
1098 } |
|
1099 |
|
1100 // -------------------------------------------------------------------------- |
|
1101 // CVPbkSimContactView::DoViewUnavailableCallbackL |
|
1102 // -------------------------------------------------------------------------- |
|
1103 // |
|
1104 void CVPbkSimContactView::DoViewUnavailableCallbackL( MVPbkSimViewObserver& aObserver ) |
|
1105 { |
|
1106 aObserver.ViewNotAvailable( *this ); |
|
1107 } |
|
1108 |
|
1109 // -------------------------------------------------------------------------- |
|
1110 // CVPbkSimContactView::DoViewErrorCallback |
|
1111 // -------------------------------------------------------------------------- |
|
1112 // |
|
1113 void CVPbkSimContactView::DoViewErrorCallback( MVPbkSimViewObserver& aObserver, |
|
1114 TInt aError ) |
|
1115 { |
|
1116 aObserver.ViewError( *this, aError ); |
|
1117 } |
|
1118 |
|
1119 // -------------------------------------------------------------------------- |
|
1120 // CVPbkSimContactView::CompareViewContactSimIndex |
|
1121 // -------------------------------------------------------------------------- |
|
1122 // |
|
1123 TBool CVPbkSimContactView::CompareViewContactSimIndex( const TViewContact& aLeft, |
|
1124 const TViewContact& aRight ) |
|
1125 { |
|
1126 return aLeft.iSimIndex == aRight.iSimIndex; |
|
1127 } |
|
1128 |
|
1129 // -------------------------------------------------------------------------- |
|
1130 // CVPbkSimContactView::IdleSortCallback |
|
1131 // -------------------------------------------------------------------------- |
|
1132 // |
|
1133 TInt CVPbkSimContactView::IdleSortCallback( TAny* aThis ) |
|
1134 { |
|
1135 static_cast<CVPbkSimContactView*>( aThis )->Sort(); |
|
1136 // Don't continue idle i.e return false value |
|
1137 return 0; |
|
1138 } |
|
1139 |
|
1140 // -------------------------------------------------------------------------- |
|
1141 // CVPbkSimContactView::IsMatch |
|
1142 // -------------------------------------------------------------------------- |
|
1143 // |
|
1144 TBool CVPbkSimContactView::IsMatch( |
|
1145 const RVPbkSimFieldTypeArray& aSortOrder, |
|
1146 TVPbkSimViewConstructionPolicy aConstructionPolicy, |
|
1147 const TDesC& aViewName ) |
|
1148 { |
|
1149 TBool result = EFalse; |
|
1150 if ( ( iViewName->CompareC( aViewName ) == 0 ) && |
|
1151 ( aConstructionPolicy == iConstructionPolicy ) ) |
|
1152 { |
|
1153 if ( EVPbkUnsortedSimView == aConstructionPolicy ) |
|
1154 { |
|
1155 result = ETrue; |
|
1156 } |
|
1157 else if ( iSortOrder.Count() == aSortOrder.Count() ) |
|
1158 { |
|
1159 result = ETrue; |
|
1160 for ( TInt i=0; i<aSortOrder.Count(); i++ ) |
|
1161 { |
|
1162 if ( aSortOrder[i] != iSortOrder[i] ) |
|
1163 { |
|
1164 result = EFalse; |
|
1165 break; |
|
1166 } |
|
1167 } |
|
1168 } |
|
1169 } |
|
1170 |
|
1171 return result; |
|
1172 } |
|
1173 |
|
1174 |
|
1175 // End of File |