|
1 /* |
|
2 * Copyright (c) 2006 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: Matches contact |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <talogger.h> |
|
19 |
|
20 #include <MVPbkContactLinkArray.h> |
|
21 |
|
22 #include "cphcntmatchcontact.h" |
|
23 #include "mphcntcontactmatchstrategy.h" |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Constructor |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CPhCntMatchContact::CPhCntMatchContact( ) |
|
30 { |
|
31 } |
|
32 |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // Secondphase constructor |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 void CPhCntMatchContact::ConstructL() |
|
39 { |
|
40 BaseConstructL(); |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Static constructor |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CPhCntMatchContact* CPhCntMatchContact::NewL() |
|
48 { |
|
49 CPhCntMatchContact* self = CPhCntMatchContact::NewLC(); |
|
50 CleanupStack::Pop( self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Static constructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CPhCntMatchContact* CPhCntMatchContact::NewLC() |
|
60 { |
|
61 CPhCntMatchContact* self = new( ELeave ) CPhCntMatchContact; |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // Destructor |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CPhCntMatchContact::~CPhCntMatchContact() |
|
73 { |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Matches the contact. |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 TInt CPhCntMatchContact::MatchContact( |
|
82 const MVPbkContactLinkArray*& aContactLinkArray, |
|
83 const TDesC& aTelNumber, |
|
84 MPhCntContactMatchStrategy& aMatchStrategy ) |
|
85 { |
|
86 TEFLOGSTRING( KTAOBJECT, "CNT CPhCntMatchContact::MatchContact" ); |
|
87 |
|
88 iMatchStrategy = &aMatchStrategy; |
|
89 iPhoneNumber.Set( aTelNumber ); |
|
90 TInt error = MakeAsyncRequest(); |
|
91 |
|
92 if( !error ) |
|
93 { |
|
94 if( iFetchedContactLinks ) |
|
95 { |
|
96 const TInt numberOfFoundContactLinks( |
|
97 iFetchedContactLinks->Count() ); |
|
98 if( numberOfFoundContactLinks == 0 ) |
|
99 { |
|
100 error = KErrNotFound; |
|
101 } |
|
102 else |
|
103 { |
|
104 aContactLinkArray = iFetchedContactLinks; |
|
105 } |
|
106 } |
|
107 else |
|
108 { |
|
109 error = KErrNotFound; |
|
110 } |
|
111 } |
|
112 |
|
113 if( error ) |
|
114 { |
|
115 delete iFetchedContactLinks; |
|
116 iFetchedContactLinks = NULL; |
|
117 } |
|
118 |
|
119 return error; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // From class CPhCntAsynctToSync. |
|
124 // Makes the asynchronous request to find matches for phone number. |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 void CPhCntMatchContact::DoMakeAsyncRequestL() |
|
128 { |
|
129 iMatchStrategy->FindMatchesL( iPhoneNumber ); |
|
130 } |