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