cellular/telephonysettings/src/PsetNetwork.cpp
changeset 0 ff3b6d0fd310
child 3 a4a774cb6ea7
child 12 ae8abd0db65c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  CPsetNetwork selects network and gets network information.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  INCLUDE FILES
       
    21 #include "MPsetNetworkInfoObs.h"
       
    22 #include "PsetNetwork.h"
       
    23 #include "PsetSAObserver.h"     
       
    24 #include "PSetPanic.h"          
       
    25 #include "PsetConstants.h"
       
    26 #include "MPsetNetworkSelect.h"
       
    27 #include <etelmm.h>
       
    28 #include <mmretrieve.h>
       
    29 #include <rmmcustomapi.h>
       
    30 
       
    31 #include <e32svr.h>
       
    32 #include "PhoneSettingsLogger.h"
       
    33 
       
    34 //  LOCAL CONSTANTS AND MACROS  
       
    35 _LIT( KPSNameOfClass, "CPsetNetwork" );
       
    36 
       
    37 enum TActiveObserver
       
    38     {
       
    39     ENetSelectObserver,
       
    40     ENetModeObserver
       
    41     };
       
    42 
       
    43 //  MEMBER FUNCTIONS
       
    44 //=============================================================================
       
    45 // ---------------------------------------------------------------------------
       
    46 // 
       
    47 // 1st phase constructor.
       
    48 // 
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C CPsetNetwork* CPsetNetwork::NewL( RMobilePhone& aPhone, 
       
    52     MPsetNetworkInfoObserver& aObserver )
       
    53     {
       
    54     CPsetNetwork* self = new ( ELeave ) CPsetNetwork( aPhone );
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL( aObserver );
       
    57     CleanupStack::Pop( self );
       
    58     return self;
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // 
       
    64 // 1st phase constructor for net mode observer.
       
    65 // 
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CPsetNetwork* CPsetNetwork::NewL( RMobilePhone& aPhone, 
       
    69                        MPsetNetworkModeObserver& aModeObserver )
       
    70     {
       
    71     CPsetNetwork* self = new ( ELeave ) CPsetNetwork( aPhone );
       
    72     CleanupStack::PushL( self );
       
    73     self->ConstructL( aModeObserver );
       
    74     CleanupStack::Pop( self );
       
    75     return self;
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // 
       
    81 // Destructor.
       
    82 // 
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 EXPORT_C CPsetNetwork::~CPsetNetwork()
       
    86     {
       
    87     Cancel();
       
    88     iCustomPhone.Close();
       
    89     delete iNetworkRetrieve;
       
    90     iNetworkRetrieve = NULL;
       
    91     delete iSAObserver;
       
    92     iSAObserver = NULL;    
       
    93     } 
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // 
       
    97 // Returns available networks
       
    98 // 
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 EXPORT_C void CPsetNetwork::GetAvailableNetworksL()
       
   102     {
       
   103     __PHSLOGSTRING("[PHS]--> CPsetNetwork::GetAvailableNetworksL");
       
   104     if ( IsActive() )
       
   105         {
       
   106         User::Leave( KErrInUse );
       
   107         }
       
   108 
       
   109     if ( iNetworkRetrieve )
       
   110         {
       
   111         delete iNetworkRetrieve;
       
   112         iNetworkRetrieve = NULL;
       
   113         }
       
   114     
       
   115     // Start to request for network information.
       
   116     iNetworkRetrieve = CRetrieveMobilePhoneDetectedNetworks::NewL( iPhone );
       
   117     iNetworkRetrieve->StartV2( iStatus );    
       
   118     iServiceRequest = MPsetNetworkInfoObserver::EServiceRequestGetNetworkInfo;
       
   119     SetActive();
       
   120     
       
   121     // Show searching note.
       
   122     CleanupLeavePushL();
       
   123     iObserver->HandleSearchingNetworksL( iServiceRequest );
       
   124     CleanupStack::Pop(); // CleanupCancelPushL
       
   125     __PHSLOGSTRING("[PHS] <--CPsetNetwork::GetAvailableNetworksL");
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // 
       
   130 // Returns information of the currently selected network.
       
   131 // DEPRECATED.
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C TInt CPsetNetwork::GetCurrentNetworkInfo
       
   135                 ( MPsetNetworkSelect::TCurrentNetworkInfo& /*aInfo*/ )
       
   136     {
       
   137     return KErrNotSupported;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // 
       
   142 // Retrieve current search mode (automatic or manual)
       
   143 // 
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C TInt CPsetNetwork::GetNetworkSelectMode( TSelectMode& aMode )
       
   147     {
       
   148     /*****************************************************
       
   149     *    Series 60 Customer / ETel
       
   150     *    Series 60  ETel API
       
   151     *****************************************************/
       
   152     RMobilePhone::TMobilePhoneNetworkSelectionV1 setMode;
       
   153     RMobilePhone::TMobilePhoneNetworkSelectionV1Pckg setModePckg( setMode );
       
   154     
       
   155     __PHSLOGSTRING("[PHS]--> CPsetNetwork::GetNetworkSelectMode");
       
   156 
       
   157     TInt res( iPhone.GetNetworkSelectionSetting( setModePckg ) );
       
   158     
       
   159     if ( res == KErrNone )
       
   160         {
       
   161         if ( setMode.iMethod == RMobilePhone::ENetworkSelectionAutomatic )
       
   162             {
       
   163             aMode = ENetSelectModeAutomatic;
       
   164             }
       
   165         else
       
   166             {
       
   167             aMode = ENetSelectModeManual;
       
   168             }
       
   169         iTempNetInfo.iMode = aMode;
       
   170         }
       
   171     __PHSLOGSTRING("[PHS] <--CPsetNetwork::GetNetworkSelectMode");
       
   172     return res;
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // 
       
   177 // Starts using the indicated network.
       
   178 // 
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 EXPORT_C void CPsetNetwork::SelectNetworkL( const TNetworkInfo& aInfo )
       
   182     {
       
   183     __PHSLOGSTRING("[PHS]--> CPsetNetwork::SelectNetworkL");
       
   184     if ( IsActive() )
       
   185         {
       
   186         User::Leave( KErrInUse );
       
   187         }    
       
   188 
       
   189     //Save previous network mode.
       
   190     TBool previousModeAutomatic = EFalse;
       
   191     if ( iTempNetInfo.iMode == ENetSelectModeAutomatic )
       
   192         {
       
   193         previousModeAutomatic = ETrue;
       
   194         }
       
   195     iTempNetInfo = aInfo;
       
   196 
       
   197     /*****************************************************
       
   198     *    Series 60 Customer / ETel
       
   199     *    Series 60  ETel API
       
   200     *****************************************************/
       
   201     if ( aInfo.iMode == ENetSelectModeManual )
       
   202         {        
       
   203         //Copy data to member variables and make a request.
       
   204         iNwInfo.iCountry.Append( aInfo.iId.iCountryCode );
       
   205         __PHSLOGSTRING1("[PHS]   CPsetNetwork::SelectNetworkL: Manual - CountryCode: %S", &aInfo.iId.iCountryCode);
       
   206 
       
   207         iNwInfo.iNetwork.Append( aInfo.iId.iNetworkCode );        
       
   208         __PHSLOGSTRING1("[PHS]   CPsetNetwork::SelectNetworkL: Manual - NetworkCode: %S", &aInfo.iId.iNetworkCode);
       
   209 
       
   210         iServiceRequest = MPsetNetworkInfoObserver::EServiceRequestSetNetwork;
       
   211         iPhone.SelectNetwork( iStatus, ETrue, iNwInfo );
       
   212         }
       
   213     else
       
   214         {
       
   215         iServiceRequest = 
       
   216             MPsetNetworkInfoObserver::EServiceRequestSetNetworkAutomatic;
       
   217         //If previously automatic, and now automatic, issue request
       
   218         // to search networks.
       
   219         if ( previousModeAutomatic )
       
   220             {
       
   221             iNwInfo.iCountry.Append( aInfo.iId.iCountryCode );            
       
   222             __PHSLOGSTRING1("[PHS]   CPsetNetwork::SelectNetworkL: Auto - CountryCode: %S", &aInfo.iId.iCountryCode);
       
   223 
       
   224             iNwInfo.iNetwork.Append( aInfo.iId.iNetworkCode );
       
   225             __PHSLOGSTRING1("[PHS]   CPsetNetwork::SelectNetworkL: Auto - NetworkCode: %S", &aInfo.iId.iNetworkCode);
       
   226 
       
   227             iPhone.SelectNetwork( iStatus, EFalse, iNwInfo );
       
   228             }
       
   229         // make new selection without Network/Country code this way device 
       
   230         // connects automatically home network.
       
   231         else
       
   232             {    
       
   233             iNwInfo.iCountry = KNullDesC;
       
   234             iNwInfo.iNetwork = KNullDesC;
       
   235             __PHSLOGSTRING("[PHS]   CPsetNetwork::SelectNetworkL: Manual>Auto - CountryCode = KNullDesC");
       
   236             __PHSLOGSTRING("[PHS]   CPsetNetwork::SelectNetworkL: Manual>Auto - NetworkCode = KNullDesC");
       
   237             iPhone.SelectNetwork( iStatus, EFalse, iNwInfo );
       
   238             }
       
   239         }    
       
   240     SetActive();
       
   241     
       
   242     //Show requesting note.
       
   243     CleanupLeavePushL();    
       
   244     if ( aInfo.iMode == ENetSelectModeManual )
       
   245         {
       
   246         __PHSLOGSTRING("[PHS]--> CPsetNetwork::SelectNetworkL: Requesting Selected N/W");
       
   247         iObserver->HandleRequestingSelectedNetworkL( ETrue );
       
   248         }
       
   249     else
       
   250         {
       
   251         __PHSLOGSTRING("[PHS]--> CPsetNetwork::SelectNetworkL: Searching N/Ws");
       
   252         iObserver->HandleSearchingNetworksL( iServiceRequest );
       
   253         }    
       
   254     CleanupStack::Pop(); // CleanupCancelPushL
       
   255     __PHSLOGSTRING("[PHS] <--CPsetNetwork::SelectNetworkL");
       
   256     }
       
   257 
       
   258 // ---------------------------------------------------------------------------
       
   259 // 
       
   260 // Running the active object
       
   261 // 
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 void CPsetNetwork::RunL()
       
   265     {
       
   266     __PHSLOGSTRING1("[PHS]--> CPsetNetwork::RunL() - iStatus = %d", iStatus.Int());
       
   267 
       
   268     MPsetNetworkInfoObserver::TServiceRequest serviceRequest = iServiceRequest;
       
   269     MPsetNetworkModeObserver::TServiceRequest modeRequest = iModeRequest;
       
   270 
       
   271     // Params have to be cleared here since the observer may initiate another asynchronous operation immediately
       
   272     // after they are notified, effectively messing up the state machine which controls the logic in DoCancel()
       
   273     // resulting in a possible dead lock when CActive::Cancel()'s User::WaitForRequest( iStatus ) never gets signaled.
       
   274     ClearParams();
       
   275     
       
   276     if ( iActiveObserver == ENetSelectObserver && iObserver )
       
   277         {
       
   278         __ASSERT_ALWAYS( iObserver, Panic( KPSNameOfClass, ENetNoObserver ) );
       
   279         HideRequestNoteL();
       
   280         }
       
   281     else if ( iActiveObserver == ENetModeObserver && iNetworkModeObserver )
       
   282         {        
       
   283         __ASSERT_ALWAYS( iNetworkModeObserver, 
       
   284                      Panic( KPSNameOfClass, ENetNoNetworkObserver  ) );
       
   285         }
       
   286         
       
   287     if ( iStatus != KErrNone )
       
   288         {
       
   289         if ( modeRequest == 
       
   290               MPsetNetworkModeObserver::EServiceRequestSetSelectedNetworkMode || 
       
   291              modeRequest == 
       
   292               MPsetNetworkModeObserver::EServiceRequestGetCurrentNetworkMode )
       
   293             {
       
   294             __PHSLOGSTRING("[PHS]--> CPsetNetwork::RunL: Request is modeRequest");
       
   295             //PSetNetworkModeObs
       
   296             iNetworkModeObserver->HandleNetworkErrorL( modeRequest, iStatus.Int() );
       
   297             }
       
   298         else
       
   299             {
       
   300             __PHSLOGSTRING("[PHS]--> CPsetNetwork::RunL: Request is serviceRequest");
       
   301             //PSetNetworkInfoObs
       
   302             GetRegistrationStatusL();
       
   303             iObserver->HandleNetworkErrorL( serviceRequest, iStatus.Int() );
       
   304             }
       
   305         } 
       
   306     else // Request completed successfully.
       
   307         {
       
   308         switch ( serviceRequest )
       
   309             {
       
   310             case MPsetNetworkInfoObserver::EServiceRequestGetNetworkInfo:
       
   311                 {
       
   312                 CNetworkInfoArray* array = new ( ELeave ) 
       
   313                     CNetworkInfoArray( KPSetNetworkInfoArrayGranularity );
       
   314                 CleanupStack::PushL( array );
       
   315 
       
   316                 CMobilePhoneNetworkListV2* results = 
       
   317                     iNetworkRetrieve->RetrieveListV2L();
       
   318                 CleanupStack::PushL( results );
       
   319                 TInt amount = results->Enumerate();
       
   320                 __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: amount: %d", amount);
       
   321                 TInt i = 0;
       
   322                 /*****************************************************
       
   323                 *    Series 60 Customer / ETel
       
   324                 *    Series 60  ETel API
       
   325                 *****************************************************/
       
   326                 RMobilePhone::TMobilePhoneNetworkInfoV2 nwNames;
       
   327                 while ( amount > i ) 
       
   328                     {
       
   329                     nwNames = results->GetEntryL( i );
       
   330                     iTempNetInfo.iId.iCountryCode.Copy( nwNames.iCountryCode );
       
   331                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: CountryCode: %S", &iTempNetInfo.iId.iCountryCode);
       
   332 
       
   333                     iTempNetInfo.iId.iNetworkCode.Copy( nwNames.iNetworkId );
       
   334                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: NetworkCode: %S", &iTempNetInfo.iId.iNetworkCode);
       
   335 
       
   336                     iTempNetInfo.iLongName.Copy( nwNames.iLongName );
       
   337                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: LongName: %S", &iTempNetInfo.iLongName);
       
   338 
       
   339                     iTempNetInfo.iShortName.Copy( nwNames.iShortName );
       
   340                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: ShortName: %S", &iTempNetInfo.iShortName);
       
   341 
       
   342                     if ( nwNames.iAccess == RMobilePhone::ENetworkAccessUtran )
       
   343                         {
       
   344                         iTempNetInfo.iAccess = ENetNetworkWCDMA;
       
   345                         }
       
   346                     else
       
   347                         {
       
   348                         iTempNetInfo.iAccess = ENetNetworkGSM;
       
   349                         }
       
   350                     array->AppendL( iTempNetInfo );
       
   351                     i++;       
       
   352                     }
       
   353                 CleanupStack::PopAndDestroy( results );
       
   354                 results = NULL;
       
   355                 __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: Count: %d", array->Count());
       
   356                 iObserver->HandleNetworkInfoReceivedL( array, KErrNone );
       
   357                 CleanupStack::PopAndDestroy( array );
       
   358                 array = NULL;
       
   359                 break;        
       
   360                 }
       
   361             case MPsetNetworkInfoObserver::EServiceRequestSetNetwork:
       
   362                 {
       
   363                 __PHSLOGSTRING("[PHS]   CPsetNetwork::RunL: EServiceRequestSetNetwork");
       
   364                 GetRegistrationStatusL();
       
   365                 iObserver->HandleNetworkChangedL( iTempNetInfo,
       
   366                     iRegStatus, KErrNone );
       
   367                 break;
       
   368                 }
       
   369             default:
       
   370                 break;
       
   371             }
       
   372 
       
   373         //check if this is correct
       
   374         switch ( modeRequest )
       
   375             {
       
   376             case MPsetNetworkModeObserver::EServiceRequestSetSelectedNetworkMode:
       
   377                 __PHSLOGSTRING("[PHS]   CPsetNetwork::RunL: EServiceRequestSetSelectedNetworkMode");
       
   378                 iNetworkModeObserver->HandleNetworkSystemModeEventsL( 
       
   379                                                        modeRequest,
       
   380                                                        iNetworkModeCaps );
       
   381                 break;
       
   382             case MPsetNetworkModeObserver::EServiceRequestGetCurrentNetworkMode:
       
   383                 __PHSLOGSTRING("[PHS]   CPsetNetwork::RunL: EServiceRequestGetCurrentNetworkMode");
       
   384                 iNetworkModeObserver->HandleNetworkSystemModeEventsL( 
       
   385                                                        modeRequest,
       
   386                                                        iNetworkModeCaps );
       
   387                 break;            
       
   388             default:
       
   389                 break;
       
   390             }
       
   391         }
       
   392     __PHSLOGSTRING("[PHS] <--CPsetNetwork::RunL");
       
   393     }
       
   394 
       
   395 // ---------------------------------------------------------------------------
       
   396 // 
       
   397 // Cancels pending request
       
   398 // 
       
   399 // ---------------------------------------------------------------------------
       
   400 //
       
   401 void CPsetNetwork::DoCancel()
       
   402     {
       
   403     __PHSLOGSTRING("[PHS]--> CPsetNetwork::DoCancel");
       
   404     switch ( iServiceRequest )
       
   405         {
       
   406         case MPsetNetworkInfoObserver::EServiceRequestGetNetworkInfo:
       
   407             iNetworkRetrieve->Cancel();
       
   408             delete iNetworkRetrieve;
       
   409             iNetworkRetrieve = NULL;
       
   410             break;
       
   411         case MPsetNetworkInfoObserver::EServiceRequestSetNetwork:
       
   412         case MPsetNetworkInfoObserver::EServiceRequestSetNetworkAutomatic:
       
   413             iPhone.CancelAsyncRequest( EMobilePhoneSelectNetwork );
       
   414             break;
       
   415         default:            
       
   416             break;
       
   417         }
       
   418 
       
   419     switch ( iModeRequest )
       
   420         {
       
   421         case MPsetNetworkModeObserver::EServiceRequestSetSelectedNetworkMode:
       
   422             iCustomPhone.CancelAsyncRequest( ECustomSetSystemNetworkModeIPC );
       
   423             break;
       
   424         case MPsetNetworkModeObserver::EServiceRequestGetCurrentNetworkMode:
       
   425             __PHSLOGSTRING("[PHS]--> CPsetNetwork::EServiceRequestGetCurrentNetworkMode");
       
   426             iCustomPhone.CancelAsyncRequest( 
       
   427                 ECustomGetCurrentSystemNetworkModesIPC );
       
   428             __PHSLOGSTRING("[PHS]--> CPsetNetwork::EServiceRequestGetCurrentNetworkMode 2");
       
   429             break;
       
   430         default:
       
   431             break;
       
   432         }
       
   433 
       
   434     ClearParams();
       
   435     __PHSLOGSTRING("[PHS] <--CPsetNetwork::DoCancel");
       
   436     }
       
   437 
       
   438 // ---------------------------------------------------------------------------
       
   439 // 
       
   440 // Cancels current request
       
   441 // 
       
   442 // ---------------------------------------------------------------------------
       
   443 //
       
   444 EXPORT_C void CPsetNetwork::CancelProcess()
       
   445     {
       
   446     if ( !IsActive() )
       
   447         {
       
   448         //if not active, might mean that network list is shown, 
       
   449         // but call is incoming do not leave or raise error.
       
   450         }
       
   451     
       
   452     Cancel();
       
   453     }
       
   454 
       
   455 // ---------------------------------------------------------------------------
       
   456 // 
       
   457 // Sets observer (Observer starts to listen again if reset).
       
   458 // 
       
   459 // ---------------------------------------------------------------------------
       
   460 //
       
   461 EXPORT_C void CPsetNetwork::SetNetSAObserver( MPsetNetworkInfoObserver& aObserver )
       
   462     {
       
   463     __ASSERT_ALWAYS( iSAObserver, Panic( KPSNameOfClass, ENetNoObserver ) );
       
   464     iSAObserver->SetNetObserver( aObserver );
       
   465     }
       
   466 
       
   467 // ---------------------------------------------------------------------------
       
   468 // 
       
   469 // Adds this to scheduler
       
   470 // 
       
   471 // ---------------------------------------------------------------------------
       
   472 //
       
   473 void CPsetNetwork::ConstructL( MPsetNetworkInfoObserver& aObserver )
       
   474     {
       
   475     iObserver = &aObserver;
       
   476     iActiveObserver = ENetSelectObserver;
       
   477     /*****************************************************
       
   478     *    Series 60 Customer / ETel
       
   479     *    Series 60  ETel API
       
   480     *****************************************************/
       
   481     iRegStatus = RMobilePhone::ERegistrationUnknown;
       
   482     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
       
   483     
       
   484     iSAObserver = CPsetSAObserver::NewL();
       
   485     CActiveScheduler::Add( this );
       
   486     }
       
   487 
       
   488 // ---------------------------------------------------------------------------
       
   489 // 
       
   490 // Adds this to scheduler
       
   491 // 
       
   492 // ---------------------------------------------------------------------------
       
   493 //
       
   494 void CPsetNetwork::ConstructL( MPsetNetworkModeObserver& aModeObserver )
       
   495     {
       
   496     iNetworkModeObserver = &aModeObserver;
       
   497     iActiveObserver = ENetModeObserver;
       
   498     /*****************************************************
       
   499     *    Series 60 Customer / ETel
       
   500     *    Series 60  ETel API
       
   501     *****************************************************/
       
   502     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
       
   503     
       
   504     CActiveScheduler::Add( this );
       
   505     }
       
   506 
       
   507 // ---------------------------------------------------------------------------
       
   508 // 
       
   509 // C++ constructor.
       
   510 // 
       
   511 // ---------------------------------------------------------------------------
       
   512 //
       
   513 CPsetNetwork::CPsetNetwork
       
   514                 ( RMobilePhone& aPhone ) : CActive( EPriorityStandard ),
       
   515                                            iPhone ( aPhone )
       
   516     {
       
   517     }
       
   518 
       
   519 // ---------------------------------------------------------------------------
       
   520 // 
       
   521 // Gets registration status.
       
   522 // 
       
   523 // ---------------------------------------------------------------------------
       
   524 //
       
   525 void CPsetNetwork::GetRegistrationStatusL()
       
   526     {
       
   527     TRequestStatus status;
       
   528     iPhone.GetNetworkRegistrationStatus( status, iRegStatus );
       
   529     __PHSLOGSTRING1("[PHS]   CPsetNetwork::GetRegistrationStatusL: iRegStatus: %d", iRegStatus);
       
   530     User::WaitForRequest( status );
       
   531     User::LeaveIfError(status.Int());
       
   532     }
       
   533 
       
   534 // ---------------------------------------------------------------------------
       
   535 // 
       
   536 // Requests SAObserver to check if call is active.
       
   537 // 
       
   538 // ---------------------------------------------------------------------------
       
   539 //
       
   540 EXPORT_C TInt CPsetNetwork::IsCallActive()
       
   541     {
       
   542     return iSAObserver->IsCallActive();
       
   543     }
       
   544 
       
   545 // ---------------------------------------------------------------------------
       
   546 // 
       
   547 // Requests SAObserver to check if gprs connection is active.
       
   548 // 
       
   549 // ---------------------------------------------------------------------------
       
   550 //
       
   551 EXPORT_C TInt CPsetNetwork::IsGPRSConnected()
       
   552     {
       
   553     return iSAObserver->IsGPRSConnected();
       
   554     }
       
   555 
       
   556 // ---------------------------------------------------------------------------
       
   557 // 
       
   558 // Requests ETEL to Reset back to the previously used network.
       
   559 // 
       
   560 // ---------------------------------------------------------------------------
       
   561 //
       
   562 EXPORT_C TInt CPsetNetwork::ResetNetworkSearch()
       
   563     {
       
   564     __PHSLOGSTRING("[PHS]--> CPsetNetwork::ResetNetworkSearch");
       
   565     RMmCustomAPI customApi;
       
   566     TInt error = customApi.Open( iPhone );
       
   567     if	(error == KErrNone)
       
   568         {
       
   569         customApi.ResetNetServer();
       
   570         }
       
   571     customApi.Close();
       
   572 
       
   573     __PHSLOGSTRING("[PHS] <--CPsetNetwork::ResetNetworkSearch");
       
   574     //for compatibility reasons returns a value
       
   575     return error;
       
   576     }
       
   577 
       
   578 // ---------------------------------------------------------------------------
       
   579 // 
       
   580 // Hides requesting note (either type). Cannot leave, since only deletes notes.
       
   581 // 
       
   582 // ---------------------------------------------------------------------------
       
   583 //
       
   584 void CPsetNetwork::HideRequestNoteL()
       
   585     {
       
   586     // Hide requesting note, when interrupting a note, does not leave.
       
   587     if ( iServiceRequest == 
       
   588         MPsetNetworkInfoObserver::EServiceRequestGetNetworkInfo )
       
   589         {
       
   590         iObserver->HandleSearchingNetworksL( // Does not leave
       
   591             MPsetNetworkInfoObserver::EServiceRequestNone ); 
       
   592         }
       
   593     else //may cause unnecessary call to hide non-existing note
       
   594         {
       
   595         iObserver->HandleRequestingSelectedNetworkL( EFalse ); // Does not leave
       
   596         }
       
   597     }
       
   598 
       
   599 // ---------------------------------------------------------------------------
       
   600 // 
       
   601 // Push object into cleanupstack to catch leaving.
       
   602 // 
       
   603 // ---------------------------------------------------------------------------
       
   604 //
       
   605 void CPsetNetwork::CleanupLeavePushL()
       
   606     {
       
   607     CleanupStack::PushL( TCleanupItem( DoHandleLeave, this ) );
       
   608     }
       
   609 
       
   610 // ---------------------------------------------------------------------------
       
   611 // 
       
   612 // Object has caused a leave.
       
   613 // 
       
   614 // ---------------------------------------------------------------------------
       
   615 //
       
   616 void CPsetNetwork::DoHandleLeave( TAny* aAny )
       
   617     {
       
   618     REINTERPRET_CAST( CPsetNetwork*, aAny )->HandleLeave();
       
   619     }
       
   620 
       
   621 // ---------------------------------------------------------------------------
       
   622 // 
       
   623 // Things to do when leave occurs.
       
   624 // 
       
   625 // ---------------------------------------------------------------------------
       
   626 //
       
   627 void CPsetNetwork::HandleLeave()
       
   628     {
       
   629     CancelProcess();
       
   630     }
       
   631 
       
   632 // ---------------------------------------------------------------------------
       
   633 // 
       
   634 // Clears member variables
       
   635 // 
       
   636 // ---------------------------------------------------------------------------
       
   637 //
       
   638 void CPsetNetwork::ClearParams()
       
   639     {
       
   640     iNwInfo.iCountry = KNullDesC;
       
   641     iNwInfo.iNetwork = KNullDesC;
       
   642     iServiceRequest = MPsetNetworkInfoObserver::EServiceRequestNone;
       
   643     iModeRequest = MPsetNetworkModeObserver::EServiceRequestNone;
       
   644     }
       
   645 
       
   646 
       
   647 // ---------------------------------------------------------------------------
       
   648 // 
       
   649 // Sets the network mode observer for communication.
       
   650 // This method is called from CGSSettListNetView class.
       
   651 // 
       
   652 // ---------------------------------------------------------------------------
       
   653 //
       
   654 EXPORT_C void CPsetNetwork::SetNetworkModeObserver( MPsetNetworkModeObserver& 
       
   655                                                     aObserver )
       
   656     {
       
   657     iNetworkModeObserver = &aObserver;
       
   658     }
       
   659 
       
   660 
       
   661 // ---------------------------------------------------------------------------
       
   662 // 
       
   663 // Sets the currently selected network access mode (GSM/UMTS/DualMode).
       
   664 // 
       
   665 // ---------------------------------------------------------------------------
       
   666 //
       
   667 EXPORT_C void CPsetNetwork::SetNetworkModeSelectionL( TUint32& aNetworkMode )
       
   668     {
       
   669     __PHSLOGSTRING("[PHS]--> CPsetNetwork::SetNetworkModeSelectionL");
       
   670 
       
   671     if ( IsActive() )
       
   672         {
       
   673         User::Leave( KErrInUse );
       
   674         }
       
   675 
       
   676     iModeRequest = 
       
   677         MPsetNetworkModeObserver::EServiceRequestSetSelectedNetworkMode;
       
   678     iCustomPhone.SetSystemNetworkMode( iStatus, 
       
   679                  static_cast<RMmCustomAPI::TNetworkModeCaps>( aNetworkMode ) );
       
   680     SetActive();
       
   681 
       
   682     __PHSLOGSTRING("[PHS] <--CPsetNetwork::SetNetworkModeSelectionL");
       
   683     }
       
   684 
       
   685 
       
   686 // ---------------------------------------------------------------------------
       
   687 // 
       
   688 // Gets the currently selected network access mode (GSM/UMTS/DualMode).
       
   689 // 
       
   690 // ---------------------------------------------------------------------------
       
   691 //
       
   692 EXPORT_C void CPsetNetwork::GetCurrentNetworkModeSelectionL()
       
   693     {
       
   694     __PHSLOGSTRING("[PHS]--> CPsetNetwork::GetCurrentNetworkModeSelectionL");
       
   695 
       
   696     if ( IsActive() )
       
   697         {
       
   698         User::Leave( KErrInUse );
       
   699         }
       
   700 
       
   701     iModeRequest = 
       
   702         MPsetNetworkModeObserver::EServiceRequestGetCurrentNetworkMode;
       
   703     iCustomPhone.GetCurrentSystemNetworkModes( iStatus, iNetworkModeCaps );
       
   704     SetActive();
       
   705 
       
   706     __PHSLOGSTRING("[PHS] <--CPsetNetwork::GetCurrentNetworkModeSelectionL");
       
   707     }
       
   708 
       
   709 
       
   710 // End of file