|
1 /* |
|
2 * Copyright (c) 2009 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: Implementation of the CVmbxCsVoiceEngine class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <cvoicemailboxentry.h> |
|
21 |
|
22 #include "vmbxenginebase.h" |
|
23 #include "vmbxutilities.h" |
|
24 |
|
25 #include "vmbxlogger.h" |
|
26 #include "vmbxcenrephandler.h" |
|
27 #include "vmbxsimhandler.h" |
|
28 #include "vmbxuiutilities.h" |
|
29 |
|
30 #include "vmbxcsvoiceengine.h" |
|
31 |
|
32 // CONSTANTS |
|
33 _LIT (KVmbxIllegalSimCharacter, "w"); |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS ============================== |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // CVmbxCsVoiceEngine::CVmbxCsVoiceEngine |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ---------------------------------------------------------------------------- |
|
42 // |
|
43 CVmbxCsVoiceEngine::CVmbxCsVoiceEngine( MVmbxResourceProvider& aProvider ) |
|
44 : CVmbxEngineBase( aProvider ) |
|
45 { |
|
46 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::CVmbxCsVoiceEngine =>" ); |
|
47 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::CVmbxCsVoiceEngine <=" ); |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CVmbxCsVoiceEngine::~CVmbxCsVoiceEngine |
|
52 // Destructor. |
|
53 // ---------------------------------------------------------------------------- |
|
54 // |
|
55 CVmbxCsVoiceEngine::~CVmbxCsVoiceEngine() |
|
56 { |
|
57 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::~CVmbxCsVoiceEngine =>" ); |
|
58 delete iSimHandler; |
|
59 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::~CVmbxCsVoiceEngine <=" ); |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CVmbxCsVoiceEngine::NewL |
|
64 // Two-phased constructor. |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CVmbxCsVoiceEngine* CVmbxCsVoiceEngine::NewL( MVmbxResourceProvider& aProvider ) |
|
68 { |
|
69 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::NewL =>" ); |
|
70 CVmbxCsVoiceEngine* self = |
|
71 new( ELeave ) CVmbxCsVoiceEngine( aProvider ); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::NewL <=" ); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CVmbxCsVoiceEngine::ConstructL |
|
81 // Symbian 2nd phase constructor can leave. |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 void CVmbxCsVoiceEngine::ConstructL() |
|
85 { |
|
86 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::ConstructL =>" ); |
|
87 TVmbxMemoryLocation storeType( EVmbxPhoneMemory ); |
|
88 storeType = iProvider.VmbxCenRepHandler().StoreType(); |
|
89 if ( EVmbxSimMemory == storeType ) |
|
90 { |
|
91 // create SimHandler |
|
92 TRAPD( err, iSimHandler = CVmbxSimHandler::NewL() ); |
|
93 // for avoid warning for compiling |
|
94 err = err; |
|
95 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::ConstructL:\ |
|
96 Create SimHandler %I" , err); |
|
97 } |
|
98 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::ConstructL <=" ); |
|
99 } |
|
100 |
|
101 // ---------------------------------------------------------------------------- |
|
102 // CVmbxCsVoiceEngine::GetL |
|
103 // Gets voice mailbox number |
|
104 // ---------------------------------------------------------------------------- |
|
105 // |
|
106 void CVmbxCsVoiceEngine::GetL( CVoiceMailboxEntry*& aEntry ) |
|
107 { |
|
108 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::GetL =>" ); |
|
109 TInt result( KErrNotFound ); |
|
110 |
|
111 CVoiceMailboxEntry* vmbxEntry = CVoiceMailboxEntry::NewLC(); |
|
112 // get als line info |
|
113 vmbxEntry->SetVmbxAlsLineType( VmbxUtilities::AlsLine() ); |
|
114 |
|
115 vmbxEntry->SetVoiceMailboxType( EVmbxVoice ); |
|
116 vmbxEntry->SetServiceId( KVmbxServiceVideo ); |
|
117 // get store type from CenRep |
|
118 TVmbxMemoryLocation storeType = iProvider.VmbxCenRepHandler().StoreType(); |
|
119 |
|
120 if ( EVmbxSimMemory == storeType && iSimHandler ) |
|
121 { |
|
122 // read from sim if it is available and active |
|
123 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::GetL:\ |
|
124 SIM available and active"); |
|
125 TRAP( result, iSimHandler->GetL( *vmbxEntry ) ); |
|
126 |
|
127 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::GetL :Sim res=%d", result ); |
|
128 TPtrC vmbxNumber( KNullDesC ); |
|
129 vmbxEntry->GetVmbxNumber( vmbxNumber ); |
|
130 |
|
131 // if no number from sim(both MBDN file and VMBX file) |
|
132 if ( KErrNone != result || !vmbxNumber.Length() ) |
|
133 { |
|
134 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::GetL:\ |
|
135 no number from sim, both MBDN file and VMBX file"); |
|
136 // Get CS number from phone memory |
|
137 result = iProvider.VmbxCenRepHandler().GetVmbxNumber( *vmbxEntry ); |
|
138 vmbxEntry->SetUsingMemoryLocation( EVmbxPhoneMemory ); |
|
139 } |
|
140 else |
|
141 { |
|
142 vmbxEntry->SetUsingMemoryLocation( EVmbxSimMemory ); |
|
143 } |
|
144 } |
|
145 // EVmbxPhoneMemory or sim not available |
|
146 else |
|
147 { |
|
148 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::GetL:\ |
|
149 EVmbxPhoneMemory or sim not available " ); |
|
150 // Get CS number from phone memory |
|
151 result = iProvider.VmbxCenRepHandler().GetVmbxNumber( *vmbxEntry ); |
|
152 vmbxEntry->SetUsingMemoryLocation( EVmbxPhoneMemory ); |
|
153 } |
|
154 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::GetL: res=%d", result ); |
|
155 |
|
156 User::LeaveIfError( result ); |
|
157 CleanupStack::Pop( vmbxEntry ); |
|
158 aEntry = vmbxEntry; |
|
159 vmbxEntry = NULL; |
|
160 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::GetL <=" ); |
|
161 } |
|
162 |
|
163 // ---------------------------------------------------------------------------- |
|
164 // CVmbxCsVoiceEngine::SaveL |
|
165 // Saves voice mailbox number |
|
166 // ---------------------------------------------------------------------------- |
|
167 // |
|
168 void CVmbxCsVoiceEngine::SaveL( const CVoiceMailboxEntry& aEntry ) |
|
169 { |
|
170 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL =>" ); |
|
171 |
|
172 TPtrC vmbxNumber( KNullDesC ); |
|
173 aEntry.GetVmbxNumber( vmbxNumber ); |
|
174 |
|
175 if ( vmbxNumber.Length() |
|
176 && ( !VmbxUtilities::IsValidPhoneNumber( vmbxNumber ) |
|
177 || VmbxUtilities::IsEmergencyNumber( vmbxNumber ) ) ) |
|
178 { |
|
179 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL: number invalid <=" ); |
|
180 User::Leave( KErrArgument ); |
|
181 } |
|
182 |
|
183 TVoiceMailboxParams params; |
|
184 if ( IsWritable( params ) ) |
|
185 { |
|
186 TVmbxMemoryLocation storeType = |
|
187 iProvider.VmbxCenRepHandler().StoreType(); |
|
188 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::SaveL: storeType=%I", |
|
189 storeType ); |
|
190 if ( EVmbxSimMemory == storeType && iSimHandler ) |
|
191 { |
|
192 // Save to sim |
|
193 SaveEntryToSimL( aEntry ); |
|
194 } |
|
195 else |
|
196 { |
|
197 // Save to cenrep |
|
198 SaveEntryToPhoneL( aEntry ); |
|
199 } |
|
200 } |
|
201 else |
|
202 { |
|
203 // sim files not exist, its may need by forcing save, eg, OMA. |
|
204 if ( !iSimHandler ) |
|
205 { |
|
206 SaveEntryToPhoneL( aEntry ); |
|
207 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL: \ |
|
208 sim files not exist then save to phone" ); |
|
209 } |
|
210 else |
|
211 { |
|
212 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL: \ |
|
213 sim files unwritable<=" ); |
|
214 User::Leave( KErrNotSupported ); |
|
215 } |
|
216 } |
|
217 |
|
218 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL <=" ); |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CVmbxCsVoiceEngine::SaveProvisionedEntryL |
|
223 // Saves Provisioned voice mailbox number |
|
224 // ---------------------------------------------------------------------------- |
|
225 // |
|
226 void CVmbxCsVoiceEngine::SaveProvisionedEntryL( |
|
227 const CVoiceMailboxEntry& aEntry ) |
|
228 { |
|
229 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveProvisionedEntryL =>" ); |
|
230 SaveL( aEntry ); |
|
231 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveProvisionedEntryL <=" ); |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // CVmbxCsVoiceEngine::CheckConfiguration |
|
236 // |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 TBool CVmbxCsVoiceEngine::CheckConfiguration( const TVoiceMailboxParams& aParams, |
|
240 const TInt aFlags ) |
|
241 { |
|
242 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::CheckConfiguration =>" ); |
|
243 TBool configuration( EFalse ); |
|
244 // check thr property whether allow user to edit number |
|
245 if ( EVmbxChangeNbrNotAllowedOnUi & aFlags ) |
|
246 { |
|
247 configuration = iProvider.VmbxCenRepHandler().IsAllowedUserEdit(); |
|
248 if ( configuration ) |
|
249 { |
|
250 configuration = IsWritable( aParams ); |
|
251 } |
|
252 } |
|
253 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::CheckConfiguration: conf%I <=", |
|
254 configuration ); |
|
255 return configuration; |
|
256 } |
|
257 |
|
258 // ---------------------------------------------------------------------------- |
|
259 // CVmbxCsVoiceEngine::SaveEntryToPhone |
|
260 // Saves number to storage that user selects from the offered list |
|
261 // ---------------------------------------------------------------------------- |
|
262 // |
|
263 void CVmbxCsVoiceEngine::SaveEntryToPhoneL( const CVoiceMailboxEntry& aEntry ) |
|
264 { |
|
265 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveEntryToPhoneL: =>" ); |
|
266 TInt result( KErrArgument ); |
|
267 |
|
268 result = iProvider.VmbxCenRepHandler().Save( aEntry ); |
|
269 |
|
270 if ( KErrNone == result ) |
|
271 { |
|
272 // observer to change vmbx number |
|
273 TPtrC vmbxNumber( KNullDesC ); |
|
274 aEntry.GetVmbxNumber( vmbxNumber ); |
|
275 if ( vmbxNumber.Length() ) |
|
276 { |
|
277 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::\ |
|
278 SaveEntryToPhone Number Length" ) |
|
279 iProvider.VmbxUiUtilities().ShowSaveToPhoneNote(); |
|
280 } |
|
281 else |
|
282 { |
|
283 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::\ |
|
284 SaveEntryToPhone Number Length zero" ) |
|
285 iProvider.VmbxUiUtilities().ShowSaveEmptyNoteL( |
|
286 aEntry.VoiceMailboxType() ); |
|
287 } |
|
288 } |
|
289 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::SaveEntryToPhoneL: result=%I <=", |
|
290 result ); |
|
291 User::LeaveIfError( result ); |
|
292 } |
|
293 |
|
294 // ---------------------------------------------------------------------------- |
|
295 // CVmbxCsVoiceEngine::SaveEntryToSim |
|
296 // For saving to place that user selects |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 void CVmbxCsVoiceEngine::SaveEntryToSimL( const CVoiceMailboxEntry& aEntry ) |
|
300 { |
|
301 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveEntryToSimL: =>" ); |
|
302 TInt result( KErrGeneral ); |
|
303 |
|
304 // number containing "w"-character is not allowed to save to sim |
|
305 TPtrC ptrNumber( KNullDesC ); |
|
306 TInt numError = aEntry.GetVmbxNumber( ptrNumber ); |
|
307 if ( KErrNotFound != ptrNumber.Find( KVmbxIllegalSimCharacter ) ) |
|
308 { |
|
309 result = KErrArgument; |
|
310 } |
|
311 |
|
312 if ( iSimHandler ) |
|
313 { |
|
314 result = iSimHandler->Save( aEntry ); |
|
315 if ( KErrNone == result ) |
|
316 { |
|
317 if ( ptrNumber.Length() ) |
|
318 { |
|
319 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::\ |
|
320 SaveEntryToSim Number Length" ) |
|
321 iProvider.VmbxUiUtilities().ShowSaveToSimNote(); |
|
322 } |
|
323 else |
|
324 { |
|
325 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::\ |
|
326 SaveEntryToPhone Number Length zero" ) |
|
327 TRAP_IGNORE( iProvider.VmbxUiUtilities(). |
|
328 ShowSaveEmptyNoteL( aEntry.VoiceMailboxType() ) ); |
|
329 } |
|
330 } |
|
331 } |
|
332 |
|
333 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::\ |
|
334 SaveEntryToSimL: result=%I <=", result ); |
|
335 |
|
336 User::LeaveIfError( result ); |
|
337 } |
|
338 |
|
339 // ---------------------------------------------------------------------------- |
|
340 // CVmbxCsVoiceEngine::IsSimWritable |
|
341 // ETrue if Sim is allowed to be writable |
|
342 // ---------------------------------------------------------------------------- |
|
343 TBool CVmbxCsVoiceEngine::IsSimWritable() |
|
344 { |
|
345 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::IsSimWritable: =>" ); |
|
346 TBool result( EFalse ); |
|
347 if ( iSimHandler && iSimHandler->IsWritable() |
|
348 && !( iProvider.VmbxCenRepHandler().IsSimReadOnly() ) ) |
|
349 { |
|
350 result = ETrue; |
|
351 } |
|
352 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::IsSimWritable:\ |
|
353 result=%I <=", result ); |
|
354 return result; |
|
355 } |
|
356 |
|
357 // ---------------------------------------------------------------------------- |
|
358 // CVmbxCsVoiceEngine::IsWritable |
|
359 // ETrue if Sim is allowed to be writable |
|
360 // ---------------------------------------------------------------------------- |
|
361 TBool CVmbxCsVoiceEngine::IsWritable( const TVoiceMailboxParams& /*aParams*/ ) |
|
362 { |
|
363 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::IsWritable =>" ); |
|
364 TBool result( EFalse ); |
|
365 TVmbxMemoryLocation storeType = |
|
366 iProvider.VmbxCenRepHandler().StoreType(); |
|
367 |
|
368 if ( EVmbxPhoneMemory == storeType ) |
|
369 { |
|
370 result = ETrue; |
|
371 } |
|
372 else |
|
373 { |
|
374 if ( iSimHandler ) |
|
375 { |
|
376 #ifdef __WINS__ |
|
377 result = ETrue; |
|
378 #else |
|
379 result = IsSimWritable(); |
|
380 #endif |
|
381 } |
|
382 else |
|
383 { |
|
384 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::IsWritable: \ |
|
385 sim files not exist then use phone memory" ); |
|
386 result = ETrue; |
|
387 } |
|
388 } |
|
389 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::IsWritable:\ |
|
390 result=%I <=", result ); |
|
391 return result; |
|
392 } |
|
393 |
|
394 // End of file |