63
|
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 |
#include <cntdb.h>
|
|
24 |
|
|
25 |
CVPbkPhoneNumberParallelMatchStrategy::CVPbkPhoneNumberParallelMatchStrategy()
|
|
26 |
{
|
|
27 |
}
|
|
28 |
|
|
29 |
inline void CVPbkPhoneNumberParallelMatchStrategy::ConstructL(
|
|
30 |
const TConfig& aConfig,
|
|
31 |
CVPbkContactManager& aContactManager,
|
|
32 |
MVPbkContactFindObserver& aObserver)
|
|
33 |
{
|
|
34 |
BaseConstructL(aConfig, aContactManager, aObserver);
|
|
35 |
}
|
|
36 |
|
|
37 |
CVPbkPhoneNumberParallelMatchStrategy* CVPbkPhoneNumberParallelMatchStrategy::NewL(
|
|
38 |
const TConfig& aConfig,
|
|
39 |
CVPbkContactManager& aContactManager,
|
|
40 |
MVPbkContactFindObserver& aObserver)
|
|
41 |
{
|
|
42 |
CVPbkPhoneNumberParallelMatchStrategy* self =
|
|
43 |
new(ELeave) CVPbkPhoneNumberParallelMatchStrategy;
|
|
44 |
CleanupStack::PushL(self);
|
|
45 |
self->ConstructL(aConfig, aContactManager, aObserver);
|
|
46 |
CleanupStack::Pop(self);
|
|
47 |
return self;
|
|
48 |
}
|
|
49 |
|
|
50 |
CVPbkPhoneNumberParallelMatchStrategy::~CVPbkPhoneNumberParallelMatchStrategy()
|
|
51 |
{
|
|
52 |
}
|
|
53 |
|
|
54 |
MVPbkContactOperation* CVPbkPhoneNumberParallelMatchStrategy::CreateFindOperationLC(
|
|
55 |
const TDesC& aPhoneNumber)
|
|
56 |
{
|
|
57 |
CVPbkContactFindOperation* operation = NULL;
|
|
58 |
|
|
59 |
if (!iMatchingStarted)
|
|
60 |
{
|
|
61 |
operation = CVPbkContactFindOperation::NewLC(FindObserver());
|
|
62 |
const TInt storeCount = StoresToMatch().Count();
|
|
63 |
TInt maxDigits = MaxMatchDigits();
|
|
64 |
|
|
65 |
for (TInt i = 0; i < storeCount; ++i)
|
|
66 |
{
|
|
67 |
MVPbkContactOperation* subOperation = NULL;
|
|
68 |
|
|
69 |
if ( maxDigits == KBestMatchingPhoneNumbers &&
|
|
70 |
IsSimStore( *( StoresToMatch()[i] ) ) )
|
|
71 |
{
|
|
72 |
// KBestMatchingPhoneNumbers enables best matching strategy
|
|
73 |
// on store level only for phone memory stores, for sim store
|
|
74 |
// MaxDigits parameter should be set to 7 or greater
|
|
75 |
const TInt KMaxDigitsForSimStore = 7;
|
|
76 |
subOperation = StoresToMatch()[i]->CreateMatchPhoneNumberOperationL(
|
|
77 |
aPhoneNumber, KMaxDigitsForSimStore, *operation);
|
|
78 |
}
|
|
79 |
else
|
|
80 |
{
|
|
81 |
subOperation = StoresToMatch()[i]->CreateMatchPhoneNumberOperationL(
|
|
82 |
aPhoneNumber, maxDigits, *operation);
|
|
83 |
}
|
|
84 |
|
|
85 |
if (subOperation)
|
|
86 |
{
|
|
87 |
CleanupDeletePushL(subOperation);
|
|
88 |
operation->AddSubOperationL(subOperation);
|
|
89 |
CleanupStack::Pop(); // subOperation
|
|
90 |
}
|
|
91 |
}
|
|
92 |
|
|
93 |
if (operation->SubOperationCount() == 0)
|
|
94 |
{
|
|
95 |
CleanupStack::PopAndDestroy(); // operation
|
|
96 |
operation = NULL;
|
|
97 |
}
|
|
98 |
iMatchingStarted = ETrue;
|
|
99 |
}
|
|
100 |
|
|
101 |
return operation;
|
|
102 |
}
|
|
103 |
|
|
104 |
void CVPbkPhoneNumberParallelMatchStrategy::InitMatchingL()
|
|
105 |
{
|
|
106 |
iMatchingStarted = EFalse;
|
|
107 |
}
|
|
108 |
|
|
109 |
// End of File
|