|
1 /* |
|
2 * Copyright (c) 2009-2010 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( KVmbxServiceVoice ); |
|
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 TBool aShowNotesAllowed ) |
|
170 { |
|
171 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL =>" ); |
|
172 |
|
173 TPtrC vmbxNumber( KNullDesC ); |
|
174 aEntry.GetVmbxNumber( vmbxNumber ); |
|
175 |
|
176 if ( vmbxNumber.Length() |
|
177 && ( !VmbxUtilities::IsValidPhoneNumber( vmbxNumber ) |
|
178 || VmbxUtilities::IsEmergencyNumber( vmbxNumber ) ) ) |
|
179 { |
|
180 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL: number invalid <=" ); |
|
181 User::Leave( KErrArgument ); |
|
182 } |
|
183 |
|
184 TVoiceMailboxParams params; |
|
185 if ( IsWritable( params ) ) |
|
186 { |
|
187 TVmbxMemoryLocation storeType = |
|
188 iProvider.VmbxCenRepHandler().StoreType(); |
|
189 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::SaveL: storeType=%I", |
|
190 storeType ); |
|
191 if ( EVmbxSimMemory == storeType && iSimHandler ) |
|
192 { |
|
193 // Save to sim |
|
194 SaveEntryToSimL( aEntry, aShowNotesAllowed ); |
|
195 } |
|
196 else |
|
197 { |
|
198 // Save to cenrep |
|
199 SaveEntryToPhoneL( aEntry, aShowNotesAllowed ); |
|
200 } |
|
201 } |
|
202 else |
|
203 { |
|
204 // sim files not exist, its may need by forcing save, eg, OMA. |
|
205 if ( !iSimHandler ) |
|
206 { |
|
207 SaveEntryToPhoneL( aEntry, aShowNotesAllowed ); |
|
208 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL: \ |
|
209 sim files not exist then save to phone" ); |
|
210 } |
|
211 else |
|
212 { |
|
213 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL: \ |
|
214 sim files unwritable<=" ); |
|
215 User::Leave( KErrNotSupported ); |
|
216 } |
|
217 } |
|
218 |
|
219 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveL <=" ); |
|
220 } |
|
221 |
|
222 // ---------------------------------------------------------------------------- |
|
223 // CVmbxCsVoiceEngine::SaveProvisionedEntryL |
|
224 // Saves Provisioned voice mailbox number |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CVmbxCsVoiceEngine::SaveProvisionedEntryL( |
|
228 const CVoiceMailboxEntry& aEntry ) |
|
229 { |
|
230 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveProvisionedEntryL =>" ); |
|
231 SaveL( aEntry, EFalse ); |
|
232 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveProvisionedEntryL <=" ); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // CVmbxCsVoiceEngine::CheckConfiguration |
|
237 // |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 TBool CVmbxCsVoiceEngine::CheckConfiguration( const TVoiceMailboxParams& aParams, |
|
241 const TInt aFlags ) |
|
242 { |
|
243 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::CheckConfiguration =>" ); |
|
244 TBool configuration( EFalse ); |
|
245 // check thr property whether allow user to edit number |
|
246 if ( EVmbxChangeNbrAllowedOnUi & aFlags ) |
|
247 { |
|
248 configuration = iProvider.VmbxCenRepHandler().IsAllowedUserEdit(); |
|
249 if ( configuration ) |
|
250 { |
|
251 configuration = IsWritable( aParams ); |
|
252 } |
|
253 } |
|
254 else |
|
255 { |
|
256 configuration = CVmbxEngineBase::CheckConfiguration(aParams, aFlags); |
|
257 } |
|
258 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::CheckConfiguration: conf%I <=", |
|
259 configuration ); |
|
260 return configuration; |
|
261 } |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // CVmbxCsVoiceEngine::SaveEntryToPhone |
|
265 // Saves number to storage that user selects from the offered list |
|
266 // ---------------------------------------------------------------------------- |
|
267 // |
|
268 void CVmbxCsVoiceEngine::SaveEntryToPhoneL( const CVoiceMailboxEntry& aEntry, |
|
269 TBool aShowNotesAllowed ) |
|
270 { |
|
271 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveEntryToPhoneL: =>" ); |
|
272 TInt result( KErrArgument ); |
|
273 |
|
274 result = iProvider.VmbxCenRepHandler().Save( aEntry ); |
|
275 |
|
276 if ( KErrNone == result && aShowNotesAllowed ) |
|
277 { |
|
278 iProvider.VmbxUiUtilities().ShowInformationdNoteL( ESavedToPhoneMemory ); |
|
279 } |
|
280 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::SaveEntryToPhoneL: result=%I <=", |
|
281 result ); |
|
282 User::LeaveIfError( result ); |
|
283 } |
|
284 |
|
285 // ---------------------------------------------------------------------------- |
|
286 // CVmbxCsVoiceEngine::SaveEntryToSim |
|
287 // For saving to place that user selects |
|
288 // ---------------------------------------------------------------------------- |
|
289 // |
|
290 void CVmbxCsVoiceEngine::SaveEntryToSimL( const CVoiceMailboxEntry& aEntry, |
|
291 TBool aShowNotesAllowed ) |
|
292 { |
|
293 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::SaveEntryToSimL: =>" ); |
|
294 TInt result( KErrGeneral ); |
|
295 |
|
296 // number containing "w"-character is not allowed to save to sim |
|
297 TPtrC ptrNumber( KNullDesC ); |
|
298 TInt numError = aEntry.GetVmbxNumber( ptrNumber ); |
|
299 if ( KErrNotFound != ptrNumber.Find( KVmbxIllegalSimCharacter ) ) |
|
300 { |
|
301 result = KErrArgument; |
|
302 } |
|
303 |
|
304 if ( iSimHandler ) |
|
305 { |
|
306 result = iSimHandler->Save( aEntry ); |
|
307 if ( KErrNone == result && aShowNotesAllowed ) |
|
308 { |
|
309 iProvider.VmbxUiUtilities().ShowInformationdNoteL( ESavedToSimMemory ); |
|
310 } |
|
311 } |
|
312 |
|
313 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::\ |
|
314 SaveEntryToSimL: result=%I <=", result ); |
|
315 |
|
316 User::LeaveIfError( result ); |
|
317 } |
|
318 |
|
319 // ---------------------------------------------------------------------------- |
|
320 // CVmbxCsVoiceEngine::IsSimWritable |
|
321 // ETrue if Sim is allowed to be writable |
|
322 // ---------------------------------------------------------------------------- |
|
323 TBool CVmbxCsVoiceEngine::IsSimWritable() |
|
324 { |
|
325 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::IsSimWritable: =>" ); |
|
326 TBool result( EFalse ); |
|
327 if ( !( iProvider.VmbxCenRepHandler().IsSimReadOnly() ) |
|
328 && iSimHandler && iSimHandler->IsWritable() ) |
|
329 { |
|
330 result = ETrue; |
|
331 } |
|
332 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::IsSimWritable:\ |
|
333 result=%I <=", result ); |
|
334 return result; |
|
335 } |
|
336 |
|
337 // ---------------------------------------------------------------------------- |
|
338 // CVmbxCsVoiceEngine::IsWritable |
|
339 // ETrue if Sim is allowed to be writable |
|
340 // ---------------------------------------------------------------------------- |
|
341 TBool CVmbxCsVoiceEngine::IsWritable( const TVoiceMailboxParams& /*aParams*/ ) |
|
342 { |
|
343 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::IsWritable =>" ); |
|
344 TBool result( EFalse ); |
|
345 TVmbxMemoryLocation storeType = |
|
346 iProvider.VmbxCenRepHandler().StoreType(); |
|
347 |
|
348 if ( EVmbxPhoneMemory == storeType ) |
|
349 { |
|
350 result = ETrue; |
|
351 } |
|
352 else |
|
353 { |
|
354 if ( iSimHandler ) |
|
355 { |
|
356 #ifdef __WINS__ |
|
357 result = ETrue; |
|
358 #else |
|
359 result = IsSimWritable(); |
|
360 #endif |
|
361 } |
|
362 else |
|
363 { |
|
364 VMBLOGSTRING( "VMBX: CVmbxCsVoiceEngine::IsWritable: \ |
|
365 sim files not exist then use phone memory" ); |
|
366 result = ETrue; |
|
367 } |
|
368 } |
|
369 VMBLOGSTRING2( "VMBX: CVmbxCsVoiceEngine::IsWritable:\ |
|
370 result=%I <=", result ); |
|
371 return result; |
|
372 } |
|
373 |
|
374 // End of file |