|
1 /* |
|
2 * Copyright (c) 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: Voice mailbox handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikenv.h> |
|
21 #include <e32property.h> |
|
22 #include <featmgr.h> |
|
23 #include <exterror.h> |
|
24 #include <NetworkHandlingDomainPSKeys.h> |
|
25 #include <telvmbxsettingscrkeys.h> |
|
26 #include <vmnumber.h> |
|
27 #include <voicemailboxdomaincrkeys.h> |
|
28 |
|
29 #include "cphonecenrepproxy.h" |
|
30 #include "cphonevmbxhandler.h" |
|
31 #include "phoneconstants.h" |
|
32 #include "phonelogger.h" |
|
33 #include "phoneui.pan" |
|
34 // CONSTANTS |
|
35 |
|
36 const TInt KVideoMbxVariabilityFeatureOn = 2; |
|
37 |
|
38 #ifdef _DEBUG |
|
39 const TInt KPhoneSpeedDialMaxLocation = 9; |
|
40 #endif // _DEBUG |
|
41 |
|
42 // ============================ MEMBER FUNCTIONS =============================== |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CPhoneVmbxHandler::CPhoneVmbxHandler |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CPhoneVmbxHandler::CPhoneVmbxHandler() |
|
49 { |
|
50 iCsVideoTelFeature = FeatureManager::FeatureSupported |
|
51 ( KFeatureIdCsVideoTelephony ); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CPhoneVmbxHandler::NewL |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CPhoneVmbxHandler* CPhoneVmbxHandler::NewL() |
|
59 { |
|
60 CPhoneVmbxHandler* self = |
|
61 new (ELeave) CPhoneVmbxHandler(); |
|
62 |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop( self ); |
|
66 |
|
67 return self; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CPhoneVmbxHandler::~CPhoneVmbxHandler |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CPhoneVmbxHandler::~CPhoneVmbxHandler() |
|
75 { |
|
76 if ( iVmbx ) |
|
77 { |
|
78 iVmbx->Close(); |
|
79 delete iVmbx; |
|
80 } |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CPhoneVmbxHandler::ConstructL |
|
85 // Symbian 2nd phase constructor can leave. |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CPhoneVmbxHandler::ConstructL() |
|
89 { |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CPhoneVmbxHandler::IsStraightCallToVideoMailBox() |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TBool CPhoneVmbxHandler::IsStraightCallToVideoMailBox() const |
|
97 { |
|
98 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::IsStraightCallToVideoMailBox()" ); |
|
99 |
|
100 TInt callStraightToVideoMailBox = KErrNone; |
|
101 TInt err = CPhoneCenRepProxy::Instance()->GetInt( |
|
102 KCRUidTelVideoMailbox, |
|
103 KTelVideoMbxKey, |
|
104 callStraightToVideoMailBox ); |
|
105 |
|
106 if ( err == KErrNone ) |
|
107 { |
|
108 return ( callStraightToVideoMailBox == KVideoMbxVariabilityFeatureOn ); |
|
109 } |
|
110 |
|
111 __PHONELOG1( EBasic, |
|
112 EPhoneUIView, |
|
113 "CPhoneVmbxHandler::IsStraightCallToVideoMailBox -> err = (%d)", |
|
114 err ); |
|
115 |
|
116 return EFalse; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CPhoneVmbxHandler::IsVideoMailBoxConfigured() |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TBool CPhoneVmbxHandler::IsVideoMailBoxConfigured() const |
|
124 { |
|
125 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::IsVideoMailBoxConfigured()" ); |
|
126 |
|
127 TInt videoMbxConfigured = KErrNone; |
|
128 TInt err = CPhoneCenRepProxy::Instance()->GetInt( |
|
129 KCRUidVideoMailbox, |
|
130 KVideoMbxSupport, |
|
131 videoMbxConfigured ); |
|
132 |
|
133 if ( err == KErrNone ) |
|
134 { |
|
135 return videoMbxConfigured; |
|
136 } |
|
137 |
|
138 __PHONELOG1( EBasic, |
|
139 EPhoneUIView, |
|
140 "CPhoneVmbxHandler::IsVideoMailBoxConfigured -> err = (%d)", |
|
141 err ); |
|
142 |
|
143 return EFalse; |
|
144 } |
|
145 |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CPhoneVmbxHandler::IsVideoMbxLocationAndConfigured |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 TBool CPhoneVmbxHandler::IsVideoMbxLocationAndConfigured( |
|
152 TInt aSpdLocation ) const |
|
153 { |
|
154 return ( aSpdLocation == KPhoneVideoMbxLocation && |
|
155 IsVideoMailBoxConfigured() ); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CPhoneVmbxHandler::GetStraightSpeedDialNumber |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 TInt CPhoneVmbxHandler::GetStraightSpeedDialNumber( |
|
163 TInt aSpdLocation, |
|
164 TDes& aNumber ) |
|
165 { |
|
166 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::GetStraightSpeedDialNumber()" ); |
|
167 |
|
168 __ASSERT_DEBUG( ( aSpdLocation >=KPhoneVoiceMailBoxLocation && |
|
169 aSpdLocation <= KPhoneSpeedDialMaxLocation), |
|
170 Panic( EPhoneViewIndexOutOfBounds ) ); |
|
171 |
|
172 TInt retVal( KErrNone ); |
|
173 |
|
174 TBool straightCallToVideoMbx = IsStraightCallToVideoMailBox(); |
|
175 |
|
176 /****************************************************** |
|
177 * -Separated Voice / Video |
|
178 * - Key '1' to VoiceMbx and Key '2' to VideoMbx, |
|
179 * if Video mailbox configured. |
|
180 ******************************************************/ |
|
181 if ( IsCsVideoTelFeature() && |
|
182 straightCallToVideoMbx && |
|
183 ( IsVideoMbxLocationAndConfigured( aSpdLocation ) || |
|
184 aSpdLocation == KPhoneVoiceMailBoxLocation ) ) |
|
185 { |
|
186 |
|
187 TRAPD( error, CreateVmbxL() ); |
|
188 if ( !error ) |
|
189 { |
|
190 if ( aSpdLocation == KPhoneVoiceMailBoxLocation ) |
|
191 { |
|
192 // Get to voice mailbox number |
|
193 retVal = LaunchMbx( EVmbx, aNumber ); |
|
194 } |
|
195 else |
|
196 { |
|
197 // Get to video mailbox number |
|
198 retVal = LaunchMbx( EVmbxVideo, aNumber ); |
|
199 } |
|
200 } |
|
201 else |
|
202 { |
|
203 retVal = error; |
|
204 } |
|
205 } |
|
206 __PHONELOG1( EBasic, |
|
207 EPhoneUIView,"CPhoneVmbxHandler::GetStraightSpeedDialNumber -> retval = (%d)", |
|
208 retVal ); |
|
209 |
|
210 return retVal; |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CPhoneVmbxHandler::IsCsVideoTelFeature |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 TBool CPhoneVmbxHandler::IsCsVideoTelFeature() |
|
218 { |
|
219 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::IsCsVideoTelFeature()" ); |
|
220 return iCsVideoTelFeature; |
|
221 } |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CPhoneVmbxHandler::LaunchMbx |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 TInt CPhoneVmbxHandler::LaunchMbx( TInt aMailboxType, TDes& aNumber ) |
|
227 { |
|
228 TInt retVal( KErrNone ); |
|
229 iMailboxType = aMailboxType; |
|
230 |
|
231 switch ( aMailboxType ) |
|
232 { |
|
233 case EVmbx: |
|
234 { |
|
235 TRAPD( error, retVal = CSVmbxL( aNumber ) ); |
|
236 if ( error ) |
|
237 { |
|
238 retVal = error; |
|
239 } |
|
240 } |
|
241 break; |
|
242 case EVmbxIP: |
|
243 { |
|
244 TRAPD( error,retVal = IPVmbxL( aNumber ) ); |
|
245 if ( error ) |
|
246 { |
|
247 retVal = error; |
|
248 } |
|
249 } |
|
250 break; |
|
251 case EVmbxVideo: |
|
252 { |
|
253 TRAPD( error, retVal = VideoVmbxL( aNumber ) ); |
|
254 if ( error ) |
|
255 { |
|
256 retVal = error; |
|
257 } |
|
258 } |
|
259 break; |
|
260 |
|
261 default: |
|
262 break; |
|
263 } |
|
264 |
|
265 __PHONELOG1( EBasic, |
|
266 EPhoneUIView,"CPhoneVmbxHandler::LaunchMbx -> retval = (%d)", |
|
267 retVal ); |
|
268 return retVal; |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CPhoneVmbxHandler::CSVmbxL |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 TInt CPhoneVmbxHandler::CSVmbxL( TDes& aNumber ) |
|
276 { |
|
277 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::CSVmbxL()" ); |
|
278 CreateVmbxL(); |
|
279 TInt err ( KErrNone ); |
|
280 err = iVmbx->GetVmbxNumber( aNumber ); |
|
281 |
|
282 //check error code |
|
283 if ( err != KErrNone && err != KErrNotFound ) |
|
284 { |
|
285 User::Leave( err ); |
|
286 } |
|
287 |
|
288 //If not assigned |
|
289 if ( err == KErrNotFound ) |
|
290 { |
|
291 aNumber.Zero(); |
|
292 if ( !( iVmbx->QueryNumberL( EVmbxNotDefinedQuery, aNumber ) ) ) |
|
293 { |
|
294 err = KErrNotFound; |
|
295 } |
|
296 else |
|
297 { |
|
298 if ( aNumber.Length() != 0 ) |
|
299 { |
|
300 err = KErrNone; |
|
301 } |
|
302 else |
|
303 { |
|
304 err = KErrNotFound; |
|
305 } |
|
306 } |
|
307 } |
|
308 return err; |
|
309 } |
|
310 // ----------------------------------------------------------------------------- |
|
311 // CPhoneVmbxHandler::IPVmbxL |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 TInt CPhoneVmbxHandler::IPVmbxL( TDes& aNumber ) |
|
315 { |
|
316 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::IPVmbxL()" ); |
|
317 CreateVmbxL(); |
|
318 |
|
319 TInt err = iVmbx->GetVmbxAddress( aNumber, iServiceId ); |
|
320 |
|
321 return err; |
|
322 } |
|
323 // ----------------------------------------------------------------------------- |
|
324 // CPhoneVmbxHandler::VideoVmbxL |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 TInt CPhoneVmbxHandler::VideoVmbxL( TDes& aNumber ) |
|
328 { |
|
329 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::VideoVmbxL()" ); |
|
330 CreateVmbxL(); |
|
331 TInt err = iVmbx->GetVideoMbxNumber( aNumber ); |
|
332 //check error code |
|
333 if ( err != KErrNone && err != KErrNotFound ) |
|
334 { |
|
335 User::Leave( err ); |
|
336 } |
|
337 //If not assigned |
|
338 if ( err == KErrNotFound ) |
|
339 { |
|
340 aNumber.Zero(); |
|
341 if ( !( iVmbx->QueryVideoMbxNumberL( EVmbxNotDefinedQuery, aNumber ) ) ) |
|
342 { |
|
343 err = KErrNotFound; |
|
344 } |
|
345 else |
|
346 { |
|
347 if ( aNumber.Length() != 0 ) |
|
348 { |
|
349 err = KErrNone; |
|
350 } |
|
351 else |
|
352 { |
|
353 err = KErrNotFound; |
|
354 } |
|
355 } |
|
356 } |
|
357 |
|
358 __PHONELOG1( EBasic, |
|
359 EPhoneUIView,"CPhoneVmbxHandler::VideoVmbxL -> err = (%d)", |
|
360 err ); |
|
361 return err; |
|
362 } |
|
363 |
|
364 |
|
365 // ----------------------------------------------------------------------------- |
|
366 // CPhoneVmbxHandler::NetworkMode |
|
367 // ----------------------------------------------------------------------------- |
|
368 // |
|
369 TInt CPhoneVmbxHandler::NetworkMode() |
|
370 |
|
371 { |
|
372 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::NetworkMode()" ); |
|
373 TInt networkMode = ENWNetworkModeUnknown; |
|
374 |
|
375 RProperty::Get( KPSUidNetworkInfo, |
|
376 KNWTelephonyNetworkMode, |
|
377 networkMode ); |
|
378 __PHONELOG1( EBasic, |
|
379 EPhoneUIView,"CPhoneVmbxHandler::NetworkMode -> NWMode = (%d)", |
|
380 networkMode ); |
|
381 return networkMode; |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------- |
|
385 // CPhoneVmbxHandler::CreateVmbxL |
|
386 // --------------------------------------------------------- |
|
387 // |
|
388 void CPhoneVmbxHandler::CreateVmbxL() |
|
389 { |
|
390 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::CreateVmbxL()" ); |
|
391 if ( !iVmbx ) |
|
392 { |
|
393 RVmbxNumber* vmbx = new ( ELeave ) RVmbxNumber; |
|
394 CleanupStack::PushL( vmbx ); |
|
395 User::LeaveIfError( vmbx->Open() ); |
|
396 CleanupStack::Pop( vmbx ); |
|
397 iVmbx = vmbx; |
|
398 } |
|
399 } |
|
400 |
|
401 // --------------------------------------------------------- |
|
402 // CPhoneVmbxHandler::GetMailboxType |
|
403 // --------------------------------------------------------- |
|
404 // |
|
405 TInt CPhoneVmbxHandler::GetMailboxType() |
|
406 { |
|
407 return iMailboxType; |
|
408 } |
|
409 |
|
410 // --------------------------------------------------------- |
|
411 // CPhoneVmbxHandler::SelectMailboxTypeL |
|
412 // --------------------------------------------------------- |
|
413 // |
|
414 TInt CPhoneVmbxHandler::SelectMailboxTypeL( TUint& aServiceId ) |
|
415 { |
|
416 __LOGMETHODSTARTEND( EPhoneUIView, "CPhoneVmbxHandler::SelectMailboxTypeL()" ); |
|
417 CreateVmbxL(); |
|
418 |
|
419 TInt err( KErrNotFound ); |
|
420 TInt err2( KErrNotFound ); |
|
421 TInt err3( KErrNotFound ); |
|
422 TInt type( EVmbxNone ); |
|
423 |
|
424 TBuf<KPhoneNumberEntryBufferSize> number; |
|
425 number.Zero(); // empty the string |
|
426 // Voice mbx number |
|
427 err = iVmbx->GetVmbxNumber( number ); |
|
428 |
|
429 // Video mbx number |
|
430 if( IsCsVideoTelFeature() ) |
|
431 { |
|
432 err2 = iVmbx->GetVideoMbxNumber( number ); |
|
433 } |
|
434 |
|
435 if ( iVmbx->IsIpVoiceMailboxServices() ) |
|
436 { |
|
437 err3 = KErrNone; |
|
438 } |
|
439 |
|
440 if ( ( err == KErrNotFound || err == KErrNotSupported ) && |
|
441 ( err2 == KErrNotFound || err2 == KErrNotSupported ) && |
|
442 ( err3 == KErrNotFound || err3 == KErrNotSupported ) ) |
|
443 { |
|
444 type = iVmbx->SelectTypeL( EVmbxDefine ); |
|
445 } |
|
446 else |
|
447 { |
|
448 type =iVmbx->SelectTypeL( EVmbxCall, iServiceId ); |
|
449 aServiceId = iServiceId; |
|
450 } |
|
451 |
|
452 return type; |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------- |
|
456 // CPhoneVmbxHandler::CancelVmbx |
|
457 // --------------------------------------------------------- |
|
458 // |
|
459 void CPhoneVmbxHandler::CancelVmbx() |
|
460 { |
|
461 if ( iVmbx ) |
|
462 { |
|
463 iVmbx->Close(); |
|
464 delete iVmbx; |
|
465 iVmbx = NULL; |
|
466 } |
|
467 } |
|
468 |
|
469 // End of File |
|
470 |