cellular/telephonysettings/src/PsetNetwork.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
parent 18 594d59766373
child 20 987c9837762f
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 //  INCLUDE FILES
    20 //  INCLUDE FILES
    21 #include "CNetworkResetHandler.h"
    21 #include "mpsetnetworkinfoobs.h" 
    22 #include "MPsetNetworkInfoObs.h"
    22 #include "psetnetwork.h" 
    23 #include "MPsetNetworkSelect.h"
    23 #include "psetsaobserver.h" 
    24 #include "PsetNetwork.h"
    24 #include "psetpanic.h" 
    25 #include "PsetSAObserver.h"     
    25 #include "psetconstants.h" 
    26 #include "PSetPanic.h"          
    26 #include "mpsetnetworkselect.h" 
    27 #include "PsetConstants.h"
       
    28 #include "PhoneSettingsLogger.h"
       
    29 
       
    30 #include <etelmm.h>
    27 #include <etelmm.h>
    31 #include <mmretrieve.h>
    28 #include <mmretrieve.h>
    32 #include <rmmcustomapi.h>
    29 #include <rmmcustomapi.h>
    33 
    30 
    34 #include <e32svr.h>
    31 #include <e32svr.h>
       
    32 #include "phonesettingslogger.h" 
    35 
    33 
    36 //  LOCAL CONSTANTS AND MACROS  
    34 //  LOCAL CONSTANTS AND MACROS  
    37 _LIT( KPSNameOfClass, "CPsetNetwork" );
    35 _LIT( KPSNameOfClass, "CPsetNetwork" );
    38 
    36 
    39 enum TActiveObserver
    37 enum TActiveObserver
    89     Cancel();
    87     Cancel();
    90     iCustomPhone.Close();
    88     iCustomPhone.Close();
    91     delete iNetworkRetrieve;
    89     delete iNetworkRetrieve;
    92     iNetworkRetrieve = NULL;
    90     iNetworkRetrieve = NULL;
    93     delete iSAObserver;
    91     delete iSAObserver;
    94     iSAObserver = NULL;
    92     iSAObserver = NULL;    
    95     delete iResetNetworkSearch;
       
    96     iResetNetworkSearch = NULL;    
       
    97     } 
    93     } 
    98 
    94 
    99 // ---------------------------------------------------------------------------
    95 // ---------------------------------------------------------------------------
   100 // 
    96 // 
   101 // Returns available networks
    97 // Returns available networks
   147 // 
   143 // 
   148 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   149 //
   145 //
   150 EXPORT_C TInt CPsetNetwork::GetNetworkSelectMode( TSelectMode& aMode )
   146 EXPORT_C TInt CPsetNetwork::GetNetworkSelectMode( TSelectMode& aMode )
   151     {
   147     {
       
   148     /*****************************************************
       
   149     *    Series 60 Customer / ETel
       
   150     *    Series 60  ETel API
       
   151     *****************************************************/
   152     RMobilePhone::TMobilePhoneNetworkSelectionV1 setMode;
   152     RMobilePhone::TMobilePhoneNetworkSelectionV1 setMode;
   153     RMobilePhone::TMobilePhoneNetworkSelectionV1Pckg setModePckg( setMode );
   153     RMobilePhone::TMobilePhoneNetworkSelectionV1Pckg setModePckg( setMode );
   154     
   154     
   155     __PHSLOGSTRING("[PHS]--> CPsetNetwork::GetNetworkSelectMode");
   155     __PHSLOGSTRING("[PHS]--> CPsetNetwork::GetNetworkSelectMode");
   156 
   156 
   192         {
   192         {
   193         previousModeAutomatic = ETrue;
   193         previousModeAutomatic = ETrue;
   194         }
   194         }
   195     iTempNetInfo = aInfo;
   195     iTempNetInfo = aInfo;
   196 
   196 
       
   197     /*****************************************************
       
   198     *    Series 60 Customer / ETel
       
   199     *    Series 60  ETel API
       
   200     *****************************************************/
   197     if ( aInfo.iMode == ENetSelectModeManual )
   201     if ( aInfo.iMode == ENetSelectModeManual )
   198         {        
   202         {        
   199         //Copy data to member variables and make a request.
   203         //Copy data to member variables and make a request.
   200         iNwInfo.iCountry.Append( aInfo.iId.iCountryCode );
   204         iNwInfo.iCountry.Append( aInfo.iId.iCountryCode );
   201         __PHSLOGSTRING1("[PHS]   CPsetNetwork::SelectNetworkL: Manual - CountryCode: %S", &aInfo.iId.iCountryCode);
   205         __PHSLOGSTRING1("[PHS]   CPsetNetwork::SelectNetworkL: Manual - CountryCode: %S", &aInfo.iId.iCountryCode);
   267     // Params have to be cleared here since the observer may initiate another asynchronous operation immediately
   271     // Params have to be cleared here since the observer may initiate another asynchronous operation immediately
   268     // after they are notified, effectively messing up the state machine which controls the logic in DoCancel()
   272     // after they are notified, effectively messing up the state machine which controls the logic in DoCancel()
   269     // resulting in a possible dead lock when CActive::Cancel()'s User::WaitForRequest( iStatus ) never gets signaled.
   273     // resulting in a possible dead lock when CActive::Cancel()'s User::WaitForRequest( iStatus ) never gets signaled.
   270     ClearParams();
   274     ClearParams();
   271     
   275     
   272     if ( iActiveObserver == ENetSelectObserver )
   276     if ( iActiveObserver == ENetSelectObserver && iObserver )
   273         {
   277         {
   274         __ASSERT_ALWAYS( iObserver, Panic( KPSNameOfClass, ENetNoObserver ) );
   278         __ASSERT_ALWAYS( iObserver, Panic( KPSNameOfClass, ENetNoObserver ) );
   275         HideRequestNoteL();
   279         HideRequestNoteL();
   276         }
   280         }
   277     else if ( iActiveObserver == ENetModeObserver )
   281     else if ( iActiveObserver == ENetModeObserver && iNetworkModeObserver )
   278         {        
   282         {        
   279         __ASSERT_ALWAYS( iNetworkModeObserver, 
   283         __ASSERT_ALWAYS( iNetworkModeObserver, 
   280                      Panic( KPSNameOfClass, ENetNoNetworkObserver  ) );
   284                      Panic( KPSNameOfClass, ENetNoNetworkObserver  ) );
   281         }
   285         }
   282         
   286         
   313                     iNetworkRetrieve->RetrieveListV2L();
   317                     iNetworkRetrieve->RetrieveListV2L();
   314                 CleanupStack::PushL( results );
   318                 CleanupStack::PushL( results );
   315                 TInt amount = results->Enumerate();
   319                 TInt amount = results->Enumerate();
   316                 __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: amount: %d", amount);
   320                 __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: amount: %d", amount);
   317                 TInt i = 0;
   321                 TInt i = 0;
   318  
   322                 /*****************************************************
       
   323                 *    Series 60 Customer / ETel
       
   324                 *    Series 60  ETel API
       
   325                 *****************************************************/
   319                 RMobilePhone::TMobilePhoneNetworkInfoV2 nwNames;
   326                 RMobilePhone::TMobilePhoneNetworkInfoV2 nwNames;
   320                 while ( amount > i ) 
   327                 while ( amount > i ) 
   321                     {
   328                     {
   322                     nwNames = results->GetEntryL( i );
   329                     nwNames = results->GetEntryL( i );
   323                     iTempNetInfo.iId.iCountryCode.Copy( nwNames.iCountryCode );
   330                     iTempNetInfo.iId.iCountryCode.Copy( nwNames.iCountryCode );
   324                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: CountryCode: %S", &iTempNetInfo.iId.iCountryCode);
   331                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: CountryCode: %S", &iTempNetInfo.iId.iCountryCode);
   325 
   332 
   326                     iTempNetInfo.iId.iNetworkCode.Copy( nwNames.iNetworkId );
   333                     iTempNetInfo.iId.iNetworkCode.Copy( nwNames.iNetworkId );
   327                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: NetworkCode: %S", &iTempNetInfo.iId.iNetworkCode);
   334                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: NetworkCode: %S", &iTempNetInfo.iId.iNetworkCode);
       
   335                     
       
   336                     iTempNetInfo.iStatus = (MPsetNetworkSelect::TNetworkStatus)nwNames.iStatus;
       
   337                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: Status: %d", &iTempNetInfo.iStatus);
   328 
   338 
   329                     iTempNetInfo.iLongName.Copy( nwNames.iLongName );
   339                     iTempNetInfo.iLongName.Copy( nwNames.iLongName );
   330                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: LongName: %S", &iTempNetInfo.iLongName);
   340                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: LongName: %S", &iTempNetInfo.iLongName);
   331 
   341 
   332                     iTempNetInfo.iShortName.Copy( nwNames.iShortName );
   342                     iTempNetInfo.iShortName.Copy( nwNames.iShortName );
   333                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: ShortName: %S", &iTempNetInfo.iShortName);
   343                     __PHSLOGSTRING1("[PHS]   CPsetNetwork::RunL: ShortName: %S", &iTempNetInfo.iShortName);
   334 
   344 
   335                     if ( nwNames.iAccess == RMobilePhone::ENetworkAccessUtran )
   345                     if ( nwNames.iAccess == RMobilePhone::ENetworkAccessUtran )
   336                         {
   346                         {
   337                         iTempNetInfo.iAccess = ENetNetworkWCDMA;
   347                         iTempNetInfo.iAccess = ENetNetworkWCDMA;
       
   348                         }
       
   349                     else if ( nwNames.iAccess == RMobilePhone::ENetworkAccessGsmAndUtran )
       
   350                         {
       
   351                         iTempNetInfo.iAccess = ENetNetworkGSMandWCDMA;
   338                         }
   352                         }
   339                     else
   353                     else
   340                         {
   354                         {
   341                         iTempNetInfo.iAccess = ENetNetworkGSM;
   355                         iTempNetInfo.iAccess = ENetNetworkGSM;
   342                         }
   356                         }
   343 
       
   344                     /** Implementation of forbidden operator icon begins */
       
   345                     // Set network status for displaying forbidden operator icon
       
   346                     iTempNetInfo.iStatus = static_cast<MPsetNetworkSelect::TNetworkStatus>( nwNames.iStatus );
       
   347                     /** Implementation of forbidden operator icon ends */
       
   348                         
       
   349                     array->AppendL( iTempNetInfo );
   357                     array->AppendL( iTempNetInfo );
   350                     i++;       
   358                     i++;       
   351                     }
   359                     }
   352                 CleanupStack::PopAndDestroy( results );
   360                 CleanupStack::PopAndDestroy( results );
   353                 results = NULL;
   361                 results = NULL;
   471 //
   479 //
   472 void CPsetNetwork::ConstructL( MPsetNetworkInfoObserver& aObserver )
   480 void CPsetNetwork::ConstructL( MPsetNetworkInfoObserver& aObserver )
   473     {
   481     {
   474     iObserver = &aObserver;
   482     iObserver = &aObserver;
   475     iActiveObserver = ENetSelectObserver;
   483     iActiveObserver = ENetSelectObserver;
   476 
   484     /*****************************************************
       
   485     *    Series 60 Customer / ETel
       
   486     *    Series 60  ETel API
       
   487     *****************************************************/
   477     iRegStatus = RMobilePhone::ERegistrationUnknown;
   488     iRegStatus = RMobilePhone::ERegistrationUnknown;
   478     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
   489     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
   479     
   490     
   480     iSAObserver = CPsetSAObserver::NewL();
   491     iSAObserver = CPsetSAObserver::NewL();
   481     CActiveScheduler::Add( this );
   492     CActiveScheduler::Add( this );
   482     iResetNetworkSearch = CNetworkResetHandler::NewL( iPhone );
       
   483     }
   493     }
   484 
   494 
   485 // ---------------------------------------------------------------------------
   495 // ---------------------------------------------------------------------------
   486 // 
   496 // 
   487 // Adds this to scheduler
   497 // Adds this to scheduler
   490 //
   500 //
   491 void CPsetNetwork::ConstructL( MPsetNetworkModeObserver& aModeObserver )
   501 void CPsetNetwork::ConstructL( MPsetNetworkModeObserver& aModeObserver )
   492     {
   502     {
   493     iNetworkModeObserver = &aModeObserver;
   503     iNetworkModeObserver = &aModeObserver;
   494     iActiveObserver = ENetModeObserver;
   504     iActiveObserver = ENetModeObserver;
   495 
   505     /*****************************************************
       
   506     *    Series 60 Customer / ETel
       
   507     *    Series 60  ETel API
       
   508     *****************************************************/
   496     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
   509     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
   497     
   510     
   498     CActiveScheduler::Add( this );
   511     CActiveScheduler::Add( this );
   499     iResetNetworkSearch = CNetworkResetHandler::NewL( iPhone );
       
   500     }
   512     }
   501 
   513 
   502 // ---------------------------------------------------------------------------
   514 // ---------------------------------------------------------------------------
   503 // 
   515 // 
   504 // C++ constructor.
   516 // C++ constructor.
   555 // ---------------------------------------------------------------------------
   567 // ---------------------------------------------------------------------------
   556 //
   568 //
   557 EXPORT_C TInt CPsetNetwork::ResetNetworkSearch()
   569 EXPORT_C TInt CPsetNetwork::ResetNetworkSearch()
   558     {
   570     {
   559     __PHSLOGSTRING("[PHS]--> CPsetNetwork::ResetNetworkSearch");
   571     __PHSLOGSTRING("[PHS]--> CPsetNetwork::ResetNetworkSearch");
   560 	
   572     RMmCustomAPI customApi;
   561     TInt error = iResetNetworkSearch->ResetNetworkSearch();
   573     TInt error = customApi.Open( iPhone );
   562 	
   574     if  (error == KErrNone)
   563     __PHSLOGSTRING1("[PHS] <--CPsetNetwork::ResetNetworkSearch: error: %d", error);
   575         {
   564 	
   576         customApi.ResetNetServer();
       
   577         }
       
   578     customApi.Close();
       
   579 
       
   580     __PHSLOGSTRING("[PHS] <--CPsetNetwork::ResetNetworkSearch");
   565     //for compatibility reasons returns a value
   581     //for compatibility reasons returns a value
   566     return error;
   582     return error;
   567     }
   583     }
   568 
   584 
   569 // ---------------------------------------------------------------------------
   585 // ---------------------------------------------------------------------------