1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * Model/Engine for Network Settings Plugin |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "GSNetworkPluginModel.h" |
|
22 #include "GSNetworkPlugin.h" |
|
23 #include "GsNetworkPlugin.hrh" |
|
24 #include "GsLogger.h" //for logging traces |
|
25 #include <featmgr.h> |
|
26 #include <barsc.h> |
|
27 #include <barsread.h> |
|
28 #include <coecntrl.h> |
|
29 #include <f32file.h> |
|
30 #include <AknQueryDialog.h> |
|
31 #include <s32file.h> |
|
32 #include <featmgr.h> |
|
33 #include <PsetCSP.h> |
|
34 #include <generalsettingsvariant.hrh> |
|
35 #include <PSVariables.h> //PubSub |
|
36 #include <settingsinternalcrkeys.h> |
|
37 #include "SettingsPrivateCRKeys.h" |
|
38 #include <LogsDomainCRKeys.h> |
|
39 #include <PsetContainer.h> |
|
40 #include <PsetSAObserver.h> //ongoing call check |
|
41 #include "GSNetworkDebugHelper.h" |
|
42 #include <gsnetworkpluginrsc.rsg> //for resource IDs |
|
43 #include <mmtsy_names.h> |
|
44 //CONSTANTS |
|
45 // default value for autolock period |
|
46 // default value for Sat operations |
|
47 |
|
48 |
|
49 _LIT( KGSNameOfClass, "CGSNetworkPluginModel" ); |
|
50 |
|
51 // Warning disabled as this constant is used inside __ASSERT_DEBUG |
|
52 #pragma diag_suppress 177 |
|
53 _LIT( KGSNetworkPluginModelAssertName, "CGSNetworkPluginModel::CheckState" ); |
|
54 |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================= |
|
57 |
|
58 // ---------------------------------------------------------------------------- |
|
59 // CGSNetworkPluginModel::NewL |
|
60 // |
|
61 // Symbian OS two-phased constructor, overloaded version |
|
62 // ---------------------------------------------------------------------------- |
|
63 // |
|
64 CGSNetworkPluginModel* CGSNetworkPluginModel::NewL( |
|
65 CGSNetworkPluginContainer* aContainer, |
|
66 CGSNetworkPlugin* aPlugin ) |
|
67 { |
|
68 CGSNetworkPluginModel* self = new( ELeave ) CGSNetworkPluginModel( |
|
69 aContainer, |
|
70 aPlugin ); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 CleanupStack::Pop( self ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // ---------------------------------------------------------------------------- |
|
79 // CGSNetworkPluginModel::CGSNetworkPluginModel |
|
80 // |
|
81 // C++ default constructor can NOT contain any code, that |
|
82 // might leave. |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CGSNetworkPluginModel::CGSNetworkPluginModel( |
|
86 CGSNetworkPluginContainer* aContainer, |
|
87 CGSNetworkPlugin* aPlugin ) |
|
88 : iNetworkMode( KGSNetworkModeCapsNotUpdated ), |
|
89 iContainer( aContainer ), |
|
90 iPlugin( aPlugin ) |
|
91 { |
|
92 } |
|
93 |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // CGSNetworkPluginModel::ConstructL |
|
97 // |
|
98 // EPOC default constructor can leave. |
|
99 // ---------------------------------------------------------------------------- |
|
100 // |
|
101 void CGSNetworkPluginModel::ConstructL() |
|
102 { |
|
103 ConstructBaseItemsL(); |
|
104 } |
|
105 |
|
106 // ---------------------------------------------------------------------------- |
|
107 // CGSNetworkPluginModel::ConstructBaseItemsL |
|
108 // |
|
109 // Constructing base items |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 void CGSNetworkPluginModel::ConstructBaseItemsL() |
|
113 { |
|
114 FeatureManager::InitializeLibL(); |
|
115 InitializeCentralRepositoryL(); |
|
116 SetCSPActiveL( ETrue ); |
|
117 iSettingsContainer = CPsetContainer::NewL(); |
|
118 User::LeaveIfError( iGSVariationRepository->Get( |
|
119 KSettingsVariationFlags, iLocalVariationValues ) ); |
|
120 #ifndef __WINS__ |
|
121 //This is currently not supported by emulator |
|
122 CreatePhoneSettingsEngineL(); |
|
123 #endif //__WINS__ |
|
124 } |
|
125 |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CGSNetworkPluginModel::~CGSNetworkPluginModel |
|
129 // |
|
130 // Destructor |
|
131 // ---------------------------------------------------------------------------- |
|
132 // |
|
133 CGSNetworkPluginModel::~CGSNetworkPluginModel() |
|
134 { |
|
135 UninitializeCentralRepository(); |
|
136 |
|
137 if ( GetCSPStatus() ) |
|
138 { |
|
139 TRAP_IGNORE( SetCSPActiveL( EFalse ) ); |
|
140 } |
|
141 |
|
142 if ( iPhoneSettingsEngine ) |
|
143 { |
|
144 delete iPhoneSettingsEngine; |
|
145 } |
|
146 |
|
147 if( iSettingsContainer ) |
|
148 { |
|
149 delete iSettingsContainer; |
|
150 } |
|
151 |
|
152 FeatureManager::UnInitializeLib(); |
|
153 |
|
154 if ( iContainer ) |
|
155 { |
|
156 iContainer = NULL; |
|
157 } |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // CGSNetworkPluginModel::InitializeCentralRepositoryL |
|
162 // |
|
163 // Creating and setting keys for the Central Repository |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 void CGSNetworkPluginModel::InitializeCentralRepositoryL() |
|
167 { |
|
168 iNetworkRepository = CRepository::NewL( KCRUidNetworkSettings ); |
|
169 iGSVariationRepository = CRepository::NewL( KCRUidSettingsVariation ); |
|
170 } |
|
171 |
|
172 // ---------------------------------------------------------------------------- |
|
173 // CGSNetworkPluginModel::UninitializeCentralRepositoryL |
|
174 // |
|
175 // Removes Central Repository objects |
|
176 // ---------------------------------------------------------------------------- |
|
177 // |
|
178 void CGSNetworkPluginModel::UninitializeCentralRepository() |
|
179 { |
|
180 if ( iNetworkRepository ) |
|
181 { |
|
182 delete iNetworkRepository; |
|
183 iNetworkRepository = NULL; |
|
184 } |
|
185 if ( iGSVariationRepository ) |
|
186 { |
|
187 delete iGSVariationRepository; |
|
188 iGSVariationRepository = NULL; |
|
189 } |
|
190 } |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // CGSNetworkPluginModel::GetCSPStatus |
|
194 // |
|
195 // Get Customer Service Profile status |
|
196 // ---------------------------------------------------------------------------- |
|
197 // |
|
198 TBool CGSNetworkPluginModel::GetCSPStatus() |
|
199 { |
|
200 if ( iCSP ) |
|
201 { |
|
202 return ETrue; |
|
203 } |
|
204 else |
|
205 { |
|
206 return EFalse; |
|
207 } |
|
208 } |
|
209 |
|
210 // ---------------------------------------------------------------------------- |
|
211 // CGSNetworkPluginModel::SetCSPActiveL |
|
212 // |
|
213 // Set Customer Service Profile active |
|
214 // ---------------------------------------------------------------------------- |
|
215 // |
|
216 void CGSNetworkPluginModel::SetCSPActiveL( TBool aValue ) |
|
217 { |
|
218 if ( aValue ) |
|
219 { |
|
220 iCSP = CPsetCustomerServiceProfile::NewL(); |
|
221 User::LeaveIfError( iCSP->OpenCSProfileL() ); |
|
222 } |
|
223 else |
|
224 { |
|
225 delete iCSP; |
|
226 iCSP = NULL; |
|
227 } |
|
228 } |
|
229 |
|
230 // ---------------------------------------------------------------------------- |
|
231 // CGSNetworkPluginModel::IsNetworkModeVisible |
|
232 // |
|
233 // Get network mode status value from shared data. |
|
234 // ---------------------------------------------------------------------------- |
|
235 // |
|
236 TBool CGSNetworkPluginModel::IsNetworkModeVisible() |
|
237 { |
|
238 TBool nwModeAvailable = EFalse; |
|
239 TInt value; |
|
240 |
|
241 iNetworkRepository->Get( KSettingsNetworkMode, value ); |
|
242 |
|
243 switch ( value ) |
|
244 { |
|
245 case 1: |
|
246 nwModeAvailable = ETrue; |
|
247 break; |
|
248 case 0: |
|
249 nwModeAvailable = EFalse; |
|
250 break; |
|
251 default: |
|
252 break; |
|
253 } |
|
254 |
|
255 return nwModeAvailable; |
|
256 |
|
257 } |
|
258 |
|
259 // ---------------------------------------------------------------------------- |
|
260 // CGSNetworkPluginModel::IsSettingSupported |
|
261 // |
|
262 // Check if a given setting is supported |
|
263 // ---------------------------------------------------------------------------- |
|
264 // |
|
265 TBool CGSNetworkPluginModel::IsSettingSupported( TInt aSettingNumber ) |
|
266 { |
|
267 __ASSERT_ALWAYS( iCSP != NULL, User::Panic( KGSNameOfClass, |
|
268 EGSTelPluinModelPanicNullPtr ) ); |
|
269 TBool settingSupported = EFalse; |
|
270 TInt retVal = KErrNone; |
|
271 switch ( aSettingNumber ) |
|
272 { |
|
273 case EGSCSPCallForward: |
|
274 retVal = iCSP->IsCFSupported( settingSupported ); |
|
275 break; |
|
276 case EGSCSPCallBarring: |
|
277 retVal = iCSP->IsCBSupported( settingSupported ); |
|
278 break; |
|
279 case EGSCSPCallWaiting: |
|
280 retVal = iCSP->IsCWSupported( settingSupported ); |
|
281 break; |
|
282 case EGSCSPAlternateLine: |
|
283 retVal = iCSP->IsALSSupported( settingSupported ); |
|
284 break; |
|
285 case EGSCSPManualNetworkSelection: |
|
286 retVal = iCSP->IsNetworkSelectionSupported( settingSupported ); |
|
287 break; |
|
288 default: |
|
289 break; |
|
290 } |
|
291 |
|
292 if ( retVal != KErrNone ) |
|
293 { |
|
294 //if a CSP error occurs, by default service is available |
|
295 settingSupported = ETrue; |
|
296 } |
|
297 |
|
298 return settingSupported; |
|
299 } |
|
300 |
|
301 // ---------------------------------------------------------------------------- |
|
302 // CGSNetworkPluginModel::GetMCNSettingValue |
|
303 // Gets MCN setting value |
|
304 // |
|
305 // ---------------------------------------------------------------------------- |
|
306 // |
|
307 TBool CGSNetworkPluginModel::GetMCNSettingValue( TInt& aId ) |
|
308 { |
|
309 TInt ret = KErrNone; |
|
310 ret = iNetworkRepository->Get( KSettingsMcnDisplay, aId ); |
|
311 return ret; |
|
312 } |
|
313 |
|
314 // ---------------------------------------------------------------------------- |
|
315 // CGSNetworkPluginModel::SetMCNSettingValue |
|
316 // Sets MCN setting value |
|
317 // |
|
318 // ---------------------------------------------------------------------------- |
|
319 // |
|
320 TBool CGSNetworkPluginModel::SetMCNSettingValue( TInt& aId ) |
|
321 { |
|
322 TInt ret = KErrNone; |
|
323 ret = iNetworkRepository->Set( KSettingsMcnDisplay, aId ); |
|
324 return ret; |
|
325 } |
|
326 |
|
327 // ---------------------------------------------------------------------------- |
|
328 // CGSNetworkPluginModel::GetSupportedNetworksL |
|
329 // |
|
330 // Get supported network mode list |
|
331 // ---------------------------------------------------------------------------- |
|
332 // |
|
333 TInt CGSNetworkPluginModel::GetSupportedNetworksL() |
|
334 { |
|
335 TInt supportedNetworks = KGSSettingOff; |
|
336 User::LeaveIfError( iNetworkRepository-> |
|
337 Get( KSettingsNetworkModeList, supportedNetworks ) ); |
|
338 |
|
339 return supportedNetworks; |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------- |
|
343 // CGSNetworkPluginModel::GraphicalNetworkListSupportedL |
|
344 // |
|
345 // Check if graphical network list is supported. |
|
346 // --------------------------------------------------------- |
|
347 // |
|
348 TBool CGSNetworkPluginModel::GraphicalNetworkListSupportedL() |
|
349 { |
|
350 TBool supported = EFalse; |
|
351 |
|
352 if ( iLocalVariationValues & EGSConfig2G3GNetworkIcon ) |
|
353 { |
|
354 supported = ETrue; |
|
355 } |
|
356 |
|
357 return supported; |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------- |
|
361 // CGSTelPluginModel::AutomaticNetworkSearchSupportedL |
|
362 // |
|
363 // Check if automatic to automatic network search is supported. |
|
364 // --------------------------------------------------------- |
|
365 // |
|
366 TBool CGSNetworkPluginModel::AutomaticNetworkSearchSupportedL() |
|
367 { |
|
368 TBool supported = EFalse; |
|
369 |
|
370 if ( iLocalVariationValues & EGSConfigNoAutoToAutoNetworkSearch ) |
|
371 { |
|
372 supported = ETrue; |
|
373 } |
|
374 return supported; |
|
375 } |
|
376 |
|
377 |
|
378 // --------------------------------------------------------------------------- |
|
379 // |
|
380 // Sets network mode to member variable. |
|
381 // |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 void CGSNetworkPluginModel::CreatePhoneSettingsEngineL() |
|
385 { |
|
386 __GSLOGSTRING("[GS]--> CGSNetworkPluginModel::CreatePhoneSettingsEngineL"); |
|
387 //initialize the phone settings object for network mode |
|
388 if ( !iPhoneSettingsEngine ) |
|
389 { |
|
390 iPhoneSettingsEngine = iSettingsContainer->CreateNetworkModeObjectL( *this ); |
|
391 } |
|
392 iPhoneSettingsEngine->SetNetworkModeObserver( *this ); |
|
393 //CPSMNetworkPlugin will init iPlugin NULL. |
|
394 if ( iPlugin == NULL ) |
|
395 { |
|
396 // get the current net mode synchronously |
|
397 StartSynGetCurrentNetworkModeSelectionL(); |
|
398 } |
|
399 else |
|
400 { |
|
401 // get the current net mode asynchronously |
|
402 StartAsynGetCurrentNetworkModeSelectionL(); |
|
403 } |
|
404 |
|
405 __GSLOGSTRING("[GS] <--CGSNetworkPluginModel::CreatePhoneSettingsEngineL"); |
|
406 } |
|
407 |
|
408 |
|
409 // --------------------------------------------------------------------------- |
|
410 // CGSNetworkPluginModel::HandleNetworkSystemModeEventsL |
|
411 // |
|
412 // Handles Network system mode list fetching from CustomAPI. |
|
413 // Handles Network system mode setting to CustomAPI. |
|
414 // Handles current network system mode fetching from CustomAPI. |
|
415 // |
|
416 // --------------------------------------------------------------------------- |
|
417 // |
|
418 void CGSNetworkPluginModel::HandleNetworkSystemModeEventsL( |
|
419 const MPsetNetworkModeObserver::TServiceRequest aRequest, |
|
420 const TUint32 aNetworkModeCaps ) |
|
421 { |
|
422 #ifdef _DEBUG |
|
423 TBuf<KGSNetworkModeDebugStrLen> requestBuf; |
|
424 GSNetworkDebugHelper::NetworkModeRequestToDes( aRequest, requestBuf ); |
|
425 __GSLOGSTRING1( "[CGSNetworkPluginModel::HandleNetworkSystemModeEventsL] %S ", |
|
426 &requestBuf ); |
|
427 #endif // _DEBUG |
|
428 |
|
429 PrintState(); |
|
430 |
|
431 switch ( aRequest ) |
|
432 { |
|
433 case MPsetNetworkModeObserver::EServiceRequestGetCurrentNetworkMode: |
|
434 { |
|
435 TBool networkModeChanged = EFalse; |
|
436 if( iNetworkMode != aNetworkModeCaps ) |
|
437 { |
|
438 networkModeChanged = ETrue; |
|
439 iNetworkMode = aNetworkModeCaps; |
|
440 } |
|
441 if( networkModeChanged ) |
|
442 { |
|
443 if ( iContainer ) |
|
444 { |
|
445 iContainer->UpdateListBoxL( EGSNetworkModeItemId, 0 ); |
|
446 } |
|
447 // Will update nw setting page in case it is open. |
|
448 if ( iPlugin ) |
|
449 { |
|
450 iPlugin->UpdateNetworkSettingPageL(); |
|
451 } |
|
452 } |
|
453 } |
|
454 break; |
|
455 case MPsetNetworkModeObserver::EServiceRequestSetSelectedNetworkMode: |
|
456 { |
|
457 |
|
458 /** |
|
459 * Setting network mode succeeded: update actual mode: |
|
460 */ |
|
461 iNetworkMode = iRequestedNetworkMode; |
|
462 |
|
463 /** |
|
464 * iNetworkMode should not be updated in case of error. |
|
465 * ->update only in this success case. |
|
466 * |
|
467 * Problem: Currently unclear if aNetworkModeCaps contains |
|
468 * valid cata in this EServiceRequestSetSelectedNetworkMode case. |
|
469 * So, cannot update iNetworkMode from aNetworkModeCaps here. |
|
470 * Instead use iRequestedNetworkMode manually. |
|
471 */ |
|
472 |
|
473 if( iContainer ) |
|
474 { |
|
475 iContainer->HandleNetworkModeChangeL(); |
|
476 } |
|
477 break; |
|
478 } |
|
479 default: |
|
480 break; |
|
481 } |
|
482 PrintState(); |
|
483 } |
|
484 |
|
485 |
|
486 // --------------------------------------------------------------------------- |
|
487 // CGSNetworkPluginModel::HandleNetworkErrorL |
|
488 // |
|
489 // From MPsetNetworkModeObserver. This is called if |
|
490 // EServiceRequestSetSelectedNetworkMode fails. No need to handle other cases. |
|
491 // --------------------------------------------------------------------------- |
|
492 // |
|
493 void CGSNetworkPluginModel::HandleNetworkErrorL( |
|
494 const MPsetNetworkModeObserver::TServiceRequest aRequest, |
|
495 const TInt aError ) |
|
496 { |
|
497 #ifdef _DEBUG |
|
498 TBuf<KGSNetworkModeDebugStrLen> requestBuf; |
|
499 GSNetworkDebugHelper::NetworkModeRequestToDes( aRequest, requestBuf ); |
|
500 __GSLOGSTRING2( "[CGSNetworkPluginModel::HandleNetworkErrorL] %S error:%d", |
|
501 &requestBuf, aError ); |
|
502 #endif // _DEBUG |
|
503 |
|
504 /** |
|
505 * Handles failing when setting network mode. |
|
506 * Requested mode is stored into a member and actual network mode is updated only |
|
507 * when success is reported in HandleNetworkSystemModeEventsL/ |
|
508 * EServiceRequestSetSelectedNetworkMode. |
|
509 */ |
|
510 switch( aRequest ) |
|
511 { |
|
512 case MPsetNetworkModeObserver::EServiceRequestGetCurrentNetworkMode: |
|
513 break; |
|
514 case MPsetNetworkModeObserver::EServiceRequestSetSelectedNetworkMode: |
|
515 // Hould display error note, iNetworkMode value is still correct as |
|
516 // it is not updated in case request failed. |
|
517 if ( iPlugin ) |
|
518 { |
|
519 iPlugin->ShowNoteL( R_NO_NETWORK_ACCESS, KGSErrorNote ); |
|
520 } |
|
521 break; |
|
522 default: |
|
523 break; |
|
524 } |
|
525 } |
|
526 |
|
527 // --------------------------------------------------------------------------- |
|
528 // CGSNetworkPluginModel::GetNetworkSelectionMode |
|
529 // |
|
530 // Gets network selection mode (automatic/manual) |
|
531 // --------------------------------------------------------------------------- |
|
532 // |
|
533 MPsetNetworkSelect::TSelectMode CGSNetworkPluginModel::GetNetworkSelectionMode() |
|
534 { |
|
535 MPsetNetworkSelect::TSelectMode mode = |
|
536 MPsetNetworkSelect::ENetSelectModeAutomatic; |
|
537 #ifndef __WINS__ |
|
538 iPhoneSettingsEngine->GetNetworkSelectMode( mode ); |
|
539 #endif //__WINS__ |
|
540 |
|
541 return mode; |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 // CGSNetworkPluginModel::StartAsynGetCurrentNetworkModeSelectionL |
|
546 // |
|
547 // --------------------------------------------------------------------------- |
|
548 // |
|
549 void CGSNetworkPluginModel::StartAsynGetCurrentNetworkModeSelectionL() |
|
550 { |
|
551 if ( iPhoneSettingsEngine ) |
|
552 { |
|
553 iPhoneSettingsEngine->GetCurrentNetworkModeSelectionL(); |
|
554 } |
|
555 } |
|
556 |
|
557 // --------------------------------------------------------------------------- |
|
558 // CGSNetworkPluginModel::StartSynGetCurrentNetworkModeSelectionL |
|
559 // |
|
560 // --------------------------------------------------------------------------- |
|
561 // |
|
562 void CGSNetworkPluginModel::StartSynGetCurrentNetworkModeSelectionL() |
|
563 { |
|
564 // Connects to Etel and loads Tsy module |
|
565 RMobilePhone phone; |
|
566 RTelServer server; |
|
567 // Custom phone. |
|
568 RMmCustomAPI customPhone; |
|
569 |
|
570 TInt err = KErrNone; |
|
571 for ( TInt a = 0; a < KPSetRetryCount; a++ ) |
|
572 { |
|
573 err = server.Connect(); |
|
574 |
|
575 if ( err == KErrNone ) |
|
576 { |
|
577 break; |
|
578 } |
|
579 |
|
580 User::After( KPSetRetryTimeout ); |
|
581 } |
|
582 |
|
583 if ( err != KErrNone ) |
|
584 { |
|
585 User::Leave( err ); |
|
586 } |
|
587 else |
|
588 { |
|
589 server.LoadPhoneModule( KMmTsyModuleName ); |
|
590 } |
|
591 User::LeaveIfError( server.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ); |
|
592 |
|
593 TInt numPhones; |
|
594 |
|
595 User::LeaveIfError( server.EnumeratePhones( numPhones ) ); |
|
596 if ( !numPhones ) |
|
597 { |
|
598 User::Leave( KErrGeneral ); |
|
599 } |
|
600 |
|
601 //match phone name to correct one |
|
602 RTelServer::TPhoneInfo phoneInfo; |
|
603 TName matchTsyName; |
|
604 TInt i = 0; |
|
605 for (; i < numPhones; i++) |
|
606 { |
|
607 User::LeaveIfError(server.GetTsyName(i, matchTsyName)); |
|
608 if (matchTsyName.CompareF(KMmTsyModuleName) == 0) |
|
609 { |
|
610 User::LeaveIfError(server.GetPhoneInfo(i, phoneInfo)); |
|
611 break; |
|
612 } |
|
613 } |
|
614 if (i == numPhones) |
|
615 { |
|
616 User::Leave(KErrGeneral); |
|
617 } |
|
618 |
|
619 //open phone subsession |
|
620 User::LeaveIfError( phone.Open( server, phoneInfo.iName ) ); |
|
621 User::LeaveIfError( customPhone.Open( phone ) ); |
|
622 TUint32 currentNetworkModes; |
|
623 customPhone.GetCurrentSystemNetworkModes( currentNetworkModes ); |
|
624 iNetworkMode = (TInt)currentNetworkModes; |
|
625 customPhone.Close(); |
|
626 phone.Close(); |
|
627 server.Close(); |
|
628 } |
|
629 |
|
630 // --------------------------------------------------------------------------- |
|
631 // CGSNetworkPluginModel::GetNetworkMode |
|
632 // |
|
633 // --------------------------------------------------------------------------- |
|
634 // |
|
635 TUint32 CGSNetworkPluginModel::GetNetworkMode() |
|
636 { |
|
637 /* |
|
638 * This does not actually ask for the mode from phone engine as |
|
639 * iPhoneSettingsEngine->GetCurrentNetworkModeSelectionL(); |
|
640 * Has allready been called in constructor and afterwards we will receive |
|
641 * notifications if mode changes. |
|
642 */ |
|
643 return iNetworkMode; |
|
644 } |
|
645 |
|
646 |
|
647 void CGSNetworkPluginModel::SetNetworkModeL( TUint32 aNetworkMode ) |
|
648 { |
|
649 __GSLOGSTRING1( "[GS]--> [CGSNetworkPluginModel::SetNetworkModeL]:%d", aNetworkMode ); |
|
650 |
|
651 // Store requested mode but iNetworkMode should not updated unless request |
|
652 // succeeds. |
|
653 iRequestedNetworkMode = aNetworkMode; |
|
654 if( iPhoneSettingsEngine ) |
|
655 { |
|
656 // Cancel the ongoing operation, otherwise, the set network mode operation will |
|
657 // leave with error code: KErrInUse. |
|
658 if ( iPhoneSettingsEngine->IsActive() ) |
|
659 { |
|
660 iPhoneSettingsEngine->Cancel(); |
|
661 } |
|
662 iPhoneSettingsEngine->SetNetworkModeSelectionL( aNetworkMode ); |
|
663 } |
|
664 |
|
665 __GSLOGSTRING1( "[GS]<-- [CGSNetworkPluginModel::SetNetworkModeL]:%d", aNetworkMode ); |
|
666 } |
|
667 |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // CGSNetworkPluginModel::PrintState |
|
671 // |
|
672 // --------------------------------------------------------------------------- |
|
673 void CGSNetworkPluginModel::PrintState() |
|
674 { |
|
675 #ifdef _DEBUG |
|
676 TBuf<KGSNetworkModeDebugStrLen> networkModeCaps; |
|
677 GSNetworkDebugHelper::NwCapsToDes( iNetworkMode, networkModeCaps ); |
|
678 __GSLOGSTRING1( "[CGSNetworkPluginModel::PrintState] iNetworkMode: %S ", |
|
679 &networkModeCaps ); |
|
680 #endif // _DEBUG |
|
681 } |
|
682 |
|
683 // --------------------------------------------------------------------------- |
|
684 // CGSNetworkPluginModel::CheckState |
|
685 // For debugging |
|
686 // --------------------------------------------------------------------------- |
|
687 void CGSNetworkPluginModel::CheckState( TGSNetworkModeItems aMode ) |
|
688 { |
|
689 #ifdef _DEBUG |
|
690 TBuf<KGSNetworkModeDebugStrLen> networkModeCaps; |
|
691 GSNetworkDebugHelper::NwCapsToDes( iNetworkMode, networkModeCaps ); |
|
692 TBuf<KGSNetworkModeDebugStrLen> networkMode; |
|
693 GSNetworkDebugHelper::NwToDes( aMode, networkMode ); |
|
694 |
|
695 __GSLOGSTRING2( "[CGSNetworkPluginModel::CheckState] %S <-> %S", |
|
696 &networkModeCaps, &networkMode ); |
|
697 |
|
698 switch ( iNetworkMode ) |
|
699 { |
|
700 case RMmCustomAPI::KCapsNetworkModeDual: |
|
701 __ASSERT_DEBUG( |
|
702 aMode == EGSNetworkModeDualmode, |
|
703 User::Panic( KGSNetworkPluginModelAssertName, KErrArgument ) ); |
|
704 break; |
|
705 case RMmCustomAPI::KCapsNetworkModeUmts: |
|
706 __ASSERT_DEBUG( |
|
707 aMode == EGSNetworkModeUMTS, |
|
708 User::Panic( KGSNetworkPluginModelAssertName, KErrArgument ) ); |
|
709 break; |
|
710 case RMmCustomAPI::KCapsNetworkModeGsm: |
|
711 __ASSERT_DEBUG( |
|
712 aMode == EGSNetworkModeGSM, |
|
713 User::Panic( KGSNetworkPluginModelAssertName, KErrArgument ) ); |
|
714 break; |
|
715 case KGSNetworkModeCapsNotUpdated: |
|
716 // Not updated yet so cannot check state. |
|
717 break; |
|
718 default: |
|
719 __ASSERT_DEBUG( |
|
720 EFalse, |
|
721 User::Panic( KGSNetworkPluginModelAssertName, KErrArgument ) ); |
|
722 break; |
|
723 } |
|
724 |
|
725 #endif // _DEBUG |
|
726 } |
|
727 |
|
728 |
|
729 |
|
730 TBool CGSNetworkPluginModel::IsCallActive() |
|
731 { |
|
732 TBool callActive = EFalse; |
|
733 |
|
734 #ifndef __WINS__ |
|
735 //This is currently not supported by emulator |
|
736 |
|
737 if ( iPhoneSettingsEngine->IsCallActive() != CPsetSAObserver::EPSetNoCallsActive ) |
|
738 { |
|
739 callActive = ETrue; |
|
740 } |
|
741 |
|
742 #endif //__WINS__ |
|
743 |
|
744 return callActive; |
|
745 } |
|
746 |
|
747 // End of File |
|