|
1 /* |
|
2 * Copyright (c) 2005-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: Phone number matching strategy for sequential matching. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CVPbkPhoneNumberSequentialMatchStrategy.h" |
|
20 |
|
21 #include <MVPbkContactStore.h> |
|
22 #include <MVPbkContactOperation.h> |
|
23 #include <cntdb.h> |
|
24 |
|
25 CVPbkPhoneNumberSequentialMatchStrategy::CVPbkPhoneNumberSequentialMatchStrategy() |
|
26 { |
|
27 } |
|
28 |
|
29 inline void CVPbkPhoneNumberSequentialMatchStrategy::ConstructL( |
|
30 const TConfig& aConfig, |
|
31 CVPbkContactManager& aContactManager, |
|
32 MVPbkContactFindObserver& aObserver) |
|
33 { |
|
34 BaseConstructL(aConfig, aContactManager, aObserver); |
|
35 } |
|
36 |
|
37 CVPbkPhoneNumberSequentialMatchStrategy* CVPbkPhoneNumberSequentialMatchStrategy::NewL( |
|
38 const TConfig& aConfig, |
|
39 CVPbkContactManager& aContactManager, |
|
40 MVPbkContactFindObserver& aObserver) |
|
41 { |
|
42 CVPbkPhoneNumberSequentialMatchStrategy* self = |
|
43 new(ELeave) CVPbkPhoneNumberSequentialMatchStrategy; |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(aConfig, aContactManager, aObserver); |
|
46 CleanupStack::Pop(self); |
|
47 return self; |
|
48 } |
|
49 |
|
50 CVPbkPhoneNumberSequentialMatchStrategy::~CVPbkPhoneNumberSequentialMatchStrategy() |
|
51 { |
|
52 } |
|
53 |
|
54 MVPbkContactOperation* CVPbkPhoneNumberSequentialMatchStrategy::CreateFindOperationLC( |
|
55 const TDesC& aPhoneNumber) |
|
56 { |
|
57 MVPbkContactOperation* operation = NULL; |
|
58 TInt maxDigits = MaxMatchDigits(); |
|
59 // Get the next store's operation if it not null |
|
60 while ( iCurrentOperation < StoresToMatch().Count() && !operation ) |
|
61 { |
|
62 if ( maxDigits == KBestMatchingPhoneNumbers && |
|
63 IsSimStore( *( StoresToMatch()[iCurrentOperation] ) ) ) |
|
64 { |
|
65 // KBestMatchingPhoneNumbers enables best matching strategy |
|
66 // on store level only for phone memory stores, for sim store |
|
67 // MaxDigits parameter should be set to 7 or greater |
|
68 const TInt KMaxDigitsForSimStore = 7; |
|
69 operation = StoresToMatch()[iCurrentOperation]->CreateMatchPhoneNumberOperationL( |
|
70 aPhoneNumber, KMaxDigitsForSimStore, FindObserver()); |
|
71 } |
|
72 else |
|
73 { |
|
74 operation = StoresToMatch()[iCurrentOperation]->CreateMatchPhoneNumberOperationL( |
|
75 aPhoneNumber, maxDigits, FindObserver()); |
|
76 } |
|
77 |
|
78 if ( operation ) |
|
79 { |
|
80 CleanupDeletePushL(operation); |
|
81 // Go to next operation |
|
82 } |
|
83 ++iCurrentOperation; |
|
84 } |
|
85 |
|
86 return operation; |
|
87 } |
|
88 |
|
89 void CVPbkPhoneNumberSequentialMatchStrategy::InitMatchingL() |
|
90 { |
|
91 iCurrentOperation = 0; |
|
92 } |
|
93 |
|
94 // End of File |