|
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 parallel matching. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CVPbkPhoneNumberParallelMatchStrategy.h" |
|
20 |
|
21 #include <MVPbkContactStore.h> |
|
22 #include <CVPbkContactFindOperation.h> |
|
23 |
|
24 CVPbkPhoneNumberParallelMatchStrategy::CVPbkPhoneNumberParallelMatchStrategy() |
|
25 { |
|
26 } |
|
27 |
|
28 inline void CVPbkPhoneNumberParallelMatchStrategy::ConstructL( |
|
29 const TConfig& aConfig, |
|
30 CVPbkContactManager& aContactManager, |
|
31 MVPbkContactFindObserver& aObserver) |
|
32 { |
|
33 BaseConstructL(aConfig, aContactManager, aObserver); |
|
34 } |
|
35 |
|
36 CVPbkPhoneNumberParallelMatchStrategy* CVPbkPhoneNumberParallelMatchStrategy::NewL( |
|
37 const TConfig& aConfig, |
|
38 CVPbkContactManager& aContactManager, |
|
39 MVPbkContactFindObserver& aObserver) |
|
40 { |
|
41 CVPbkPhoneNumberParallelMatchStrategy* self = |
|
42 new(ELeave) CVPbkPhoneNumberParallelMatchStrategy; |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(aConfig, aContactManager, aObserver); |
|
45 CleanupStack::Pop(self); |
|
46 return self; |
|
47 } |
|
48 |
|
49 CVPbkPhoneNumberParallelMatchStrategy::~CVPbkPhoneNumberParallelMatchStrategy() |
|
50 { |
|
51 } |
|
52 |
|
53 MVPbkContactOperation* CVPbkPhoneNumberParallelMatchStrategy::CreateFindOperationLC( |
|
54 const TDesC& aPhoneNumber) |
|
55 { |
|
56 CVPbkContactFindOperation* operation = NULL; |
|
57 |
|
58 if (!iMatchingStarted) |
|
59 { |
|
60 operation = CVPbkContactFindOperation::NewLC(FindObserver()); |
|
61 const TInt storeCount = StoresToMatch().Count(); |
|
62 for (TInt i = 0; i < storeCount; ++i) |
|
63 { |
|
64 MVPbkContactOperation* subOperation = |
|
65 StoresToMatch()[i]->CreateMatchPhoneNumberOperationL( |
|
66 aPhoneNumber, MaxMatchDigits(), *operation); |
|
67 if (subOperation) |
|
68 { |
|
69 CleanupDeletePushL(subOperation); |
|
70 operation->AddSubOperationL(subOperation); |
|
71 CleanupStack::Pop(); // subOperation |
|
72 } |
|
73 } |
|
74 |
|
75 if (operation->SubOperationCount() == 0) |
|
76 { |
|
77 CleanupStack::PopAndDestroy(); // operation |
|
78 operation = NULL; |
|
79 } |
|
80 iMatchingStarted = ETrue; |
|
81 } |
|
82 |
|
83 return operation; |
|
84 } |
|
85 |
|
86 void CVPbkPhoneNumberParallelMatchStrategy::InitMatchingL() |
|
87 { |
|
88 iMatchingStarted = EFalse; |
|
89 } |
|
90 |
|
91 // End of File |