|
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: This module contains the implementation of CPEContactHandling class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cpecontacthandling.h" |
|
21 #include "cpecontactmatch.h" |
|
22 #include <mpedatastore.h> |
|
23 #include <e32std.h> |
|
24 #include <mpephonemodelinternal.h> |
|
25 #include <pepanic.pan> |
|
26 #include <barsc.h> |
|
27 #include <barsread.h> |
|
28 #include <talogger.h> |
|
29 #include <bldvariant.hrh> |
|
30 #include <featmgr.h> |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================================= |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CPEContactHandling::CPEContactHandling |
|
36 // C++ constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CPEContactHandling::CPEContactHandling |
|
41 ( |
|
42 MPEPhoneModelInternal& aModel, |
|
43 RFs& aFsSession |
|
44 ) : iModel( aModel ), |
|
45 iFsSession( aFsSession ) |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CPEContactHandling::ConstructL |
|
51 // Symbian 2nd phase constructor can leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CPEContactHandling::ConstructL() |
|
55 { |
|
56 TEFLOGSTRING( KTAOBJECT, "CNT CPEContactHandling::ConstructL > CPEContactMatch::NewL" ); |
|
57 iContactMatcher = CPEContactMatch::NewL( *this, *iModel.DataStore() ); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CPEContactHandling::NewL |
|
62 // Two-phased constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CPEContactHandling* CPEContactHandling::NewL |
|
66 ( |
|
67 MPEPhoneModelInternal& aModel, // Phone Model |
|
68 RFs& aFsSession |
|
69 ) |
|
70 { |
|
71 TEFLOGSTRING(KTAOBJECT, "CNT CPEContactHandling::NewL start."); |
|
72 CPEContactHandling* self = new ( ELeave ) CPEContactHandling( aModel, aFsSession ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop( self ); |
|
76 TEFLOGSTRING(KTAOBJECT, "CNT CPEContactHandling::NewL Complete."); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // Destructor |
|
81 CPEContactHandling::~CPEContactHandling |
|
82 ( |
|
83 // None. |
|
84 ) |
|
85 { |
|
86 delete iContactMatcher; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CPEContactHandling::FindContactInfoSyncL |
|
91 // Synchronous method for searching contact information with the key defined |
|
92 // |
|
93 // Supported synchronous searching keys are searching with phone number, |
|
94 // name, contact id and voice tag (actually uses contact id) |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CPEContactHandling::FindContactInfoSyncL |
|
98 ( |
|
99 TInt aCallId, // call id from phone engine |
|
100 TPEFindContactKey aFindKey // search key |
|
101 ) |
|
102 { |
|
103 TPEPhoneNumber line1 = iModel.DataStore()->VoiceMailBoxNumberLine1(); |
|
104 TPEPhoneNumber line2 = iModel.DataStore()->VoiceMailBoxNumberLine2(); |
|
105 TPEPhoneNumber remoteNumber = iModel.DataStore()->RemotePhoneNumber( aCallId ); |
|
106 |
|
107 if( remoteNumber.Length() < 3 ) //according to UI spec numbers less than 3 digits are not matched. |
|
108 { |
|
109 return; |
|
110 } |
|
111 |
|
112 if ( remoteNumber == line1 ) |
|
113 { |
|
114 TEFLOGSTRING( KTAINT, "CNT CPEContactHandling::FindContactInfoSyncL, number matched to vmbx line 1" ); |
|
115 iModel.DataStore()->SetRemotePhoneNumberType( EPEVmbxNumberLine1, aCallId ); |
|
116 } |
|
117 else if ( remoteNumber == line2 ) |
|
118 { |
|
119 TEFLOGSTRING( KTAINT, "CNT CPEContactHandling::FindContactInfoSyncL, number matched to vmbx line 2" ); |
|
120 iModel.DataStore()->SetRemotePhoneNumberType( EPEVmbxNumberLine2, aCallId ); |
|
121 } |
|
122 else // If number was not voicemailboxnumber, check number from contacts. |
|
123 { |
|
124 TEFLOGSTRING( KTAINT, "CNT CPEContactHandling::FindContactInfoSyncL, number did not match vmbx" ); |
|
125 FindContactInfoSyncFromContactDbL( aCallId, aFindKey ); |
|
126 } |
|
127 } |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CPEContactHandling::FindContactInfoSync |
|
130 // Calls method FindContactInfoSyncL which can leave. This leave is trapped in |
|
131 // this function. |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TInt CPEContactHandling::FindContactInfoSync |
|
135 ( |
|
136 const TInt aCallId, |
|
137 const TPEFindContactKey aFindKey |
|
138 ) |
|
139 { |
|
140 TRAPD( error, FindContactInfoSyncL( aCallId, aFindKey ) ); |
|
141 TEFLOGSTRING2( KTAMESOUT, "CNT CPEContactHandling::FindContactInfoSync, error code: %d", error ); |
|
142 return (error); |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CPEContactHandling::SendErrorMessage |
|
147 // Method reroutes error messages to the CPhoneModel object |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CPEContactHandling::SendErrorMessage |
|
151 ( |
|
152 TInt aErrorCode |
|
153 ) |
|
154 { |
|
155 iModel.DataStore()->SetErrorCode( aErrorCode ); |
|
156 iModel.SendMessage( MEngineMonitor::EPEMessageContactHandlingError ); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CPEContactHandling::SendMessage |
|
161 // Method reroutes error messages to the CPhoneModel object |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void CPEContactHandling::SendMessage |
|
165 ( |
|
166 MEngineMonitor::TPEMessagesFromPhoneEngine aMessage, |
|
167 const TInt aCallId |
|
168 ) |
|
169 { |
|
170 if ( aMessage == MEngineMonitor::EPEMessageThumbnailLoadingCompleted ) |
|
171 { |
|
172 CFbsBitmap* thumbnailData = iContactMatcher->ContactThumbnail(); |
|
173 if ( thumbnailData ) |
|
174 { |
|
175 iModel.DataStore()->SetCallerThumbnail( thumbnailData, aCallId ); |
|
176 } |
|
177 } |
|
178 |
|
179 iModel.SendMessage( aMessage, aCallId ); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CPEContactHandling::FindContactInfoSyncFromContactDb |
|
184 // Synchronous method for searching contact information from |
|
185 // contact database with the key defined. |
|
186 // |
|
187 // Supported synchronous searching keys are searching with phone number and |
|
188 // contact id. |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CPEContactHandling::FindContactInfoSyncFromContactDbL |
|
192 ( |
|
193 const TInt aCallId, |
|
194 const TPEFindContactKey aFindKey |
|
195 ) const |
|
196 { |
|
197 ASSERT( iContactMatcher ); |
|
198 |
|
199 // Check validity of the search key |
|
200 switch ( aFindKey ) |
|
201 { |
|
202 case EPEFindWithPhoneNumber: |
|
203 iContactMatcher->MatchWithNumberL( aCallId ); |
|
204 break; |
|
205 case EPEFindWithContactId: |
|
206 iContactMatcher->MatchWithContactIdL( aCallId ); |
|
207 break; |
|
208 default: |
|
209 break; |
|
210 } |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CPEContactHandling::GetSpeedDialLocation |
|
215 // Get's phone number and contact id from given location. |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 TInt CPEContactHandling::GetSpeedDialLocation( |
|
219 TInt aLocationIndex, |
|
220 TPEPhoneNumber& aNumber ) |
|
221 { |
|
222 TInt error = KErrLocked; |
|
223 ASSERT( iContactMatcher ); |
|
224 TRAP( error, iContactMatcher->GetSpeedDialLocationL( aLocationIndex, |
|
225 aNumber ) ); |
|
226 return error; |
|
227 } |
|
228 |
|
229 // ================= OTHER EXPORTED FUNCTIONS =============================== |
|
230 |
|
231 // End of File |