gssettingsuis/Gs/GSNetworkPlugin/Src/GSNetworkPlugin.cpp
changeset 18 e3554c9069b6
parent 4 3f8368f032cf
child 19 30540fccecae
equal deleted inserted replaced
4:3f8368f032cf 18:e3554c9069b6
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  Call submenu in General Settings.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "GSNetworkPlugin.h"         //for CGSCallPlugin
       
    21 #include "GSNetworkPluginContainer.h"    //for CGSCallPluginContainer
       
    22 #include "GsLogger.h"
       
    23 #include "GSNetworkPlugin.h"             //for pluginUID
       
    24 
       
    25 #include <coeaui.h>
       
    26 #include <hlplch.h>                     // For HlpLauncher
       
    27 
       
    28 //AVKON headers
       
    29 #include <aknnotewrappers.h>            //for Note Wrappers
       
    30 #include <aknPopup.h>                   //for Popup menus
       
    31 #include <aknradiobuttonsettingpage.h>  //for Radio Button Setting Pages
       
    32 #include <aknViewAppUi.h>               //for viewappui
       
    33 #include <AknWaitDialog.h>              //for CAknWaitDialog
       
    34 #include <AknIconArray.h>               //for AknIconArray
       
    35 #include <StringLoader.h>               //for StringLoader
       
    36 #include <apparc.h>
       
    37 
       
    38 #include <gscommon.hrh>
       
    39 
       
    40 //Phonesettings and TSY headers
       
    41 #include <PsetContainer.h>              //for CPsetContainer
       
    42 #include <PsetNetwork.h>                //for CPsetNetwork
       
    43 #include <PsetSAObserver.h>             //for CPsetSAObserver
       
    44 #include <gsmerror.h>                   //for GSM-specific error messages
       
    45 #include <exterror.h>
       
    46 #include <featmgr.h>
       
    47 #include <MSSSettingsRefreshObserver.h> //for SAT refresh
       
    48 #include <gslistbox.h>                  //for radiobutton class
       
    49 
       
    50 #include <e32property.h>
       
    51 #include <PSVariables.h>
       
    52 
       
    53 #include <GsNetworkPluginRsc.rsg>           //for resource IDs
       
    54 #include <gsfwviewuids.h>
       
    55 #include <gslistbox.h>                  //for CGSListBoxItemTextArray
       
    56 
       
    57 #include <e32property.h>
       
    58 #include <PSVariables.h>
       
    59 #include <gsprivatepluginproviderids.h>
       
    60 #include <gsnetworkplugin.mbg>
       
    61 #include <BTSapInternalPSKeys.h>
       
    62 #include <CoreApplicationUIsSDKCRKeys.h> // KCRUidCoreApplicationUIs, TCoreAppUIsNetworkConnectionAllowed
       
    63 #include <activeidle2domainpskeys.h>
       
    64 
       
    65 #include <CNWSession.h>
       
    66 #include <NetworkHandlingProxy.h>
       
    67 #include <gsparentplugin.h>
       
    68 #include "GSNetworkDebugHelper.h"
       
    69 
       
    70 #ifdef FF_POWER_SAVE
       
    71     #include "GSNetworkPluginAO.h"
       
    72 #endif // FF_POWER_SAVE
       
    73 
       
    74 // LOCAL CONSTANTS
       
    75 _LIT( KGSNetWCDMAIcon, "0\t" );
       
    76 _LIT( KGSNetGSMIcon, "1\t" );
       
    77 _LIT( KEmptyStr, "" );
       
    78 
       
    79 // Warning disabled as this constant is used inside __ASSERT_DEBUG
       
    80 #pragma diag_suppress 177
       
    81 _LIT( KGSNetworkPluginAssertName, "CGSNetworkPlugin" );
       
    82 
       
    83 
       
    84 // Middle Softkey control ID.
       
    85 const TInt KGSMSKControlID = 3;
       
    86 
       
    87 const TInt KGSNetIconAdditionalChars = 5;
       
    88 
       
    89 
       
    90 // ========================= MEMBER FUNCTIONS ================================
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 // Constructor.
       
    94 //
       
    95 // ---------------------------------------------------------------------------
       
    96 CGSNetworkPlugin::CGSNetworkPlugin()
       
    97     :iMskCommandFlag( ETrue ) , iPsmActive( NULL )
       
    98     {
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 // Symbian OS two-phased constructor (second phase)
       
   104 //
       
   105 // ---------------------------------------------------------------------------
       
   106 void CGSNetworkPlugin::ConstructL()
       
   107     {
       
   108     __GSLOGSTRING("[CGSNetworkPlugin]--> CGSNetworkPlugin::ConstructL");
       
   109     FeatureManager::InitializeLibL();
       
   110     OpenLocalizedResourceFileL( KGSNetworkPluginResourceFileName,
       
   111                                 iResourceLoader );
       
   112 
       
   113     //PS listener initialization
       
   114     iBtSapListener = CGSPubSubsListener::NewL(
       
   115                      KPSUidBluetoothSapConnectionState,
       
   116                      KBTSapConnectionState, this );
       
   117 
       
   118     BaseConstructL( R_GS_NET_VIEW );
       
   119 
       
   120     iSettingsContainer = CPsetContainer::NewL();
       
   121     iPSRefreshHandler = iSettingsContainer->CreateRefreshHandlerL();
       
   122     iPSRefreshHandler->NotifyFileChangeL(
       
   123             *this,
       
   124             KCspEf,
       
   125             EFileChangeNotification );
       
   126     iPhoneSettingsEngine = iSettingsContainer->CreateNetworkObjectL( *this );
       
   127     iApprovedNetwork = EFalse;
       
   128     CheckAndCreateDlgL( EFalse );
       
   129     iSearchForNetworksActive = EFalse;
       
   130 
       
   131     iNetworkText = HBufC::NewL( KNWShortNameLength );
       
   132     UpdateNetworkTextL();
       
   133     
       
   134 #ifdef FF_POWER_SAVE    
       
   135     iPsmActive = CGSNetworkPluginAO::NewL();
       
   136     iPsmActive->SetView( this );
       
   137 #endif // FF_POWER_SAVE   
       
   138 
       
   139     __GSLOGSTRING("[CGSNetworkPlugin] <--CGSNetworkPlugin::ConstructL");
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 // Symbian OS two-phased constructor (first phase)
       
   145 //
       
   146 // ---------------------------------------------------------------------------
       
   147 CGSNetworkPlugin* CGSNetworkPlugin::NewLC()
       
   148     {
       
   149     CGSNetworkPlugin* self = new ( ELeave ) CGSNetworkPlugin;
       
   150     CleanupStack::PushL( self );
       
   151     self->ConstructL();
       
   152     return self;
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // CGSNetworkPlugin::NewL()
       
   157 // Static constructor
       
   158 //
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 CGSNetworkPlugin* CGSNetworkPlugin::NewL( TAny* /*aInitParams*/ )
       
   162     {
       
   163     CGSNetworkPlugin* self = new ( ELeave ) CGSNetworkPlugin();
       
   164     CleanupStack::PushL( self );
       
   165     self->ConstructL();
       
   166     CleanupStack::Pop( self );
       
   167     return self;
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 //
       
   172 // Destructor
       
   173 //
       
   174 // ---------------------------------------------------------------------------
       
   175 CGSNetworkPlugin::~CGSNetworkPlugin()
       
   176     {
       
   177     __GSLOGSTRING("[CGSNetworkPlugin] ~CGSNetworkPlugin()|->");
       
   178     FeatureManager::UnInitializeLib();
       
   179 
       
   180     if( iNWSession )
       
   181         {
       
   182         delete iNWSession;
       
   183         iNWSession = NULL;
       
   184         }
       
   185     if ( iBtSapListener )
       
   186         {
       
   187         delete iBtSapListener;
       
   188         iBtSapListener = NULL;
       
   189         }
       
   190 
       
   191     if ( iPhoneSettingsEngine )
       
   192         {
       
   193         if( iSearchForNetworksActive )
       
   194             {
       
   195             //Reset back to previously used network
       
   196             iPhoneSettingsEngine->ResetNetworkSearch();
       
   197             }
       
   198         delete iPhoneSettingsEngine;
       
   199         iPhoneSettingsEngine = NULL;
       
   200         }
       
   201 
       
   202     if ( iNetworkArray )
       
   203         {
       
   204         iNetworkArray->Reset();
       
   205         delete iNetworkArray;
       
   206         iNetworkArray = NULL;
       
   207         }
       
   208 
       
   209     if ( iDlg )
       
   210         {
       
   211         delete iDlg;
       
   212         iDlg = NULL;
       
   213         }
       
   214     if ( iNetworkPopupList )
       
   215         {
       
   216         iNetworkPopupList->CancelPopup();
       
   217         }
       
   218 
       
   219     CloseDialog();
       
   220     
       
   221     //Cancel any outstanding SAT notifications
       
   222     if ( iPSRefreshHandler )
       
   223         {
       
   224         iPSRefreshHandler->CancelNotify();
       
   225         delete iPSRefreshHandler;
       
   226         iPSRefreshHandler = NULL;
       
   227         }
       
   228 
       
   229     if( iSettingsContainer )
       
   230         {
       
   231         delete iSettingsContainer;
       
   232         iSettingsContainer = NULL;
       
   233         }
       
   234 
       
   235     delete iNetworkText;
       
   236     iNetworkText = NULL;
       
   237     
       
   238 #ifdef FF_POWER_SAVE
       
   239     delete iPsmActive;
       
   240     iPsmActive = NULL;
       
   241 #endif // FF_POWER_SAVE
       
   242 
       
   243     __GSLOGSTRING("[CGSNetworkPlugin] ~CGSNetworkPlugin()-|");
       
   244     }
       
   245 
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 // Returns Id of the Network submenu
       
   249 //
       
   250 // ---------------------------------------------------------------------------
       
   251 TUid CGSNetworkPlugin::Id() const
       
   252     {
       
   253     return KGSNetworkPluginUid;
       
   254     }
       
   255 
       
   256 // ----------------------------------------------------------------------------
       
   257 // CGSNetworkPlugin::Visible
       
   258 //
       
   259 // Provides the visibility status of self to framework.
       
   260 // ----------------------------------------------------------------------------
       
   261 //
       
   262 TBool CGSNetworkPlugin::Visible() const
       
   263     {
       
   264     TBool result( EFalse );
       
   265     TInt value = 0;
       
   266     iBtSapListener->Get( value );
       
   267     if ( value == EBTSapNotConnected || value == EBTSapConnecting )
       
   268         {
       
   269         result = ETrue;
       
   270         }
       
   271     else
       
   272         {
       
   273         result = EFalse;
       
   274         }
       
   275     return result;
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 //
       
   280 // Handles network info
       
   281 //
       
   282 // ---------------------------------------------------------------------------
       
   283 void CGSNetworkPlugin::HandleNetworkInfoReceivedL(
       
   284         const CNetworkInfoArray* aInfoArray, const TInt /* aResult */ )
       
   285     {
       
   286     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::HandleNetworkInfoReceivedL");
       
   287     const TInt itemsCount = aInfoArray->Count();
       
   288 
       
   289     //first delete old ones
       
   290     iNetworkArray->Delete( 0, iNetworkArray->Count() );
       
   291 
       
   292     //then insert found networks
       
   293     for ( TInt i = 0; i < itemsCount; i++ )
       
   294         {
       
   295         MPsetNetworkSelect::TNetworkInfo info = aInfoArray->At( i );
       
   296         iNetworkArray->InsertL( i, info );
       
   297         }
       
   298     NetworkListL(); //after search complete, show results
       
   299     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::HandleNetworkInfoReceivedL");
       
   300     }
       
   301 
       
   302 // ---------------------------------------------------------------------------
       
   303 //
       
   304 // Creates list of Network providers
       
   305 //
       
   306 // ---------------------------------------------------------------------------
       
   307 void CGSNetworkPlugin::NetworkListL()
       
   308     {
       
   309     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::NetworkListL");
       
   310 
       
   311     //check if the graphical list is needed... set in local variation
       
   312     TBool showGraphicalList =
       
   313         Container()->NetPluginModel()->GraphicalNetworkListSupportedL();
       
   314     __GSLOGSTRING1("[GS]    NetworkListL: showGraphicalList: %d", showGraphicalList);
       
   315 
       
   316     //if no net items were found, do not show list
       
   317     if ( iNetworkArray->Count() > 0 )
       
   318         {
       
   319         while ( !iApprovedNetwork )
       
   320             {
       
   321             AknPopupListEmpty<CEikFormattedCellListBox>* list;
       
   322             if ( showGraphicalList &&
       
   323                  FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ) )
       
   324                 {
       
   325                 list = new ( ELeave ) CAknSingleGraphicPopupMenuStyleListBox;
       
   326                 }
       
   327             else
       
   328                 {
       
   329                 list = new ( ELeave ) CAknSinglePopupMenuStyleListBox;
       
   330                 }
       
   331 
       
   332             CleanupStack::PushL( list );
       
   333             if ( iNetworkPopupList )
       
   334                 {
       
   335                 iNetworkPopupList->CancelPopup();
       
   336                 iNetworkPopupList = NULL;
       
   337                 }
       
   338             iNetworkPopupList =
       
   339                 CAknPopupList::NewL( list, R_AVKON_SOFTKEYS_OK_CANCEL );
       
   340 
       
   341             list->ConstructL( iNetworkPopupList,
       
   342                               CEikListBox::ELeftDownInViewRect );
       
   343             list->CreateScrollBarFrameL( ETrue );
       
   344             list->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   345                 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   346 
       
   347             //Fill in the list texts
       
   348             CDesCArrayFlat* items =
       
   349                 new ( ELeave ) CDesCArrayFlat( KGSNetPopupMenuItems );
       
   350             CleanupStack::PushL( items );
       
   351             const TInt itemsCount = iNetworkArray->Count();
       
   352             __GSLOGSTRING1("[GS]    NetworkListL: itemsCount: %d", itemsCount);
       
   353 
       
   354             for ( TInt loop = 0; loop < itemsCount; loop++ )
       
   355                 {
       
   356                 HBufC* insertString =
       
   357                     HBufC::NewLC(
       
   358                         KGSNwLongNameLength + KGSNetIconAdditionalChars );
       
   359                 MPsetNetworkSelect::TNetworkInfo info =
       
   360                     iNetworkArray->At( loop );
       
   361 
       
   362                 if ( info.iLongName.Length() <= 0 ||
       
   363                      info.iLongName.Length() > KGSNwLongNameLength )
       
   364                     {
       
   365                     //no names received, use IDs
       
   366                     if ( info.iShortName.Length() <= 0 ||
       
   367                         info.iShortName.Length() > KGSNwShortNameLength )
       
   368                         {
       
   369                         TNetworkID ids;
       
   370                         TNetworkID networkCode;
       
   371                         ids = info.iId.iCountryCode;
       
   372                         ids.Append( KGSEmptySpace );
       
   373                         networkCode = info.iId.iNetworkCode;
       
   374                         ids.Append( networkCode );
       
   375                         insertString->Des().Append( ids );
       
   376                         __GSLOGSTRING1("[GS]    NetworkListL: Network ID: %S", insertString);
       
   377                         }
       
   378                     //short name received
       
   379                     else
       
   380                         {
       
   381                         insertString->Des().Append( info.iShortName );
       
   382                         __GSLOGSTRING1("[GS]    NetworkListL: Network Shortname: %S", insertString);
       
   383                         }
       
   384                     }
       
   385                 //long name received
       
   386                 else
       
   387                     {
       
   388                     insertString->Des().Append( info.iLongName );
       
   389                     __GSLOGSTRING1("[GS]    NetworkListL: Network Longname: %S", insertString);
       
   390                     }
       
   391 
       
   392                 //set icon for network
       
   393                 if ( showGraphicalList )
       
   394                     {
       
   395                     if ( FeatureManager::FeatureSupported(
       
   396                                                   KFeatureIdProtocolWcdma ) )
       
   397                         {
       
   398                         if ( info.iAccess !=
       
   399                              MPsetNetworkSelect::ENetNetworkGSM )
       
   400                             {
       
   401                             insertString->Des().Insert( 0, KGSNetWCDMAIcon );
       
   402                             }
       
   403                         else
       
   404                             {
       
   405                             insertString->Des().Insert( 0, KGSNetGSMIcon );
       
   406                             }
       
   407                         }
       
   408                     }
       
   409                 items->AppendL( *insertString );
       
   410                 CleanupStack::PopAndDestroy();
       
   411                 }
       
   412 
       
   413             // For Testing purpuses ONLY
       
   414             for ( TInt k=0; k<items->Count(); k++ )
       
   415                 {
       
   416                 TPtrC itemText( (*items)[k] );
       
   417                 __GSLOGSTRING2("[GS]    NetworkListL: POS: %d, VALUE: %S", k, &itemText);
       
   418                 }
       
   419 
       
   420             CTextListBoxModel* model = list->Model();
       
   421             model->SetItemTextArray( items );
       
   422             model->SetOwnershipType( ELbmOwnsItemArray );
       
   423             CleanupStack::Pop( items ); //listbox model now owns this
       
   424 
       
   425             //Set title for list
       
   426             SetTitleToPopupL( *iNetworkPopupList, R_NETSL_FOUNDOPERATORS );
       
   427 
       
   428             // Setup graphic items list for dual mode nw selection listbox
       
   429             // based on the local variation
       
   430             if ( showGraphicalList )
       
   431                 {
       
   432                 CAknIconArray* iconList = new (ELeave) CAknIconArray( 10 );
       
   433                 CleanupStack::PushL( iconList );
       
   434                 iconList->ConstructFromResourceL( R_NET_DUALMODE_ICONS );
       
   435                 list->ItemDrawer()->ColumnData()->SetIconArray( iconList );
       
   436                 CleanupStack::Pop( iconList ); //listbox model now owns this
       
   437                 }
       
   438 
       
   439             TInt res = 0;
       
   440             if( items->Count() )
       
   441                 {
       
   442                 res = iNetworkPopupList->ExecuteLD();
       
   443                 }
       
   444             iNetworkPopupList = NULL;
       
   445 
       
   446             iApprovedNetwork = ETrue; //not perhaps, but user might want to quit
       
   447             TInt selection = list->CurrentItemIndex();
       
   448             __GSLOGSTRING1("[GS]    NetworkListL: selection: %d", selection);
       
   449 
       
   450             CleanupStack::PopAndDestroy( list );
       
   451 
       
   452             if ( res )
       
   453                 {
       
   454                 MPsetNetworkSelect::TNetworkInfo info =
       
   455                     iNetworkArray->At( selection );
       
   456                 info.iMode = MPsetNetworkSelect::ENetSelectModeManual;
       
   457                 iPhoneSettingsEngine->SelectNetworkL( info );
       
   458                 }
       
   459             else // user selected "Cancel"
       
   460                 {
       
   461                 //After list has been used, clear it.
       
   462                 PurgeNetworkList();
       
   463                 if ( iPhoneSettingsEngine->IsCallActive() !=
       
   464                      CPsetSAObserver::EPSetCallActive )
       
   465                     {
       
   466                     ShowSettingPageL( EGSNetworkModeSelectionItemId );
       
   467                     }
       
   468                 }
       
   469             }
       
   470         }
       
   471     iApprovedNetwork = EFalse; //initialize before new search
       
   472     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::NetworkListL");
       
   473     }
       
   474 
       
   475 // ---------------------------------------------------------------------------
       
   476 //
       
   477 // Handles requests to change network
       
   478 //
       
   479 // ---------------------------------------------------------------------------
       
   480 void CGSNetworkPlugin::HandleNetworkChangedL(
       
   481     const MPsetNetworkSelect::TNetworkInfo& /*aCurrentInfo*/,
       
   482     const MPsetNetworkSelect::TCurrentNetworkStatus /*aStatus*/,
       
   483     const TInt /*aResult*/ )
       
   484     {
       
   485     //DEPRECATED
       
   486     }
       
   487 
       
   488 // ---------------------------------------------------------------------------
       
   489 //
       
   490 // Handles requests to change network
       
   491 //
       
   492 // ---------------------------------------------------------------------------
       
   493 void CGSNetworkPlugin::HandleNetworkChangedL(
       
   494     const MPsetNetworkSelect::TNetworkInfo& aCurrentInfo,
       
   495     const RMobilePhone::TMobilePhoneRegistrationStatus& aStatus,
       
   496     const TInt /* aResult */ )
       
   497     {
       
   498     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::HandleNetworkChangedL");
       
   499     switch ( aStatus )
       
   500         {
       
   501         case RMobilePhone::ERegisteredOnHomeNetwork:
       
   502             ShowNoteL( R_HOME_NETWORK_SELECTED, KGSConfirmationNote );
       
   503             PurgeNetworkList();
       
   504             break;
       
   505         case RMobilePhone::ERegisteredRoaming:
       
   506             {
       
   507             HBufC* stringholder;
       
   508             if ( aCurrentInfo.iLongName.Length() > 0 &&
       
   509                 aCurrentInfo.iLongName.Length() <=
       
   510                 MPsetNetworkSelect::ENetLongNameSize )
       
   511                 {
       
   512                 stringholder = StringLoader::LoadLC( R_NETSL_NETWORKSELECTED,
       
   513                                                      aCurrentInfo.iLongName );
       
   514                 }
       
   515             else if (aCurrentInfo.iShortName.Length() > 0 &&
       
   516                 aCurrentInfo.iShortName.Length() <=
       
   517                 MPsetNetworkSelect::ENetShortNameSize )
       
   518                 {
       
   519                 stringholder = StringLoader::LoadLC( R_NETSL_NETWORKSELECTED,
       
   520                                                      aCurrentInfo.iShortName );
       
   521                 }
       
   522             else //network returned only ids
       
   523                 {
       
   524                 // construct whole "id-string"
       
   525                 // e.g. for Finland Nokia's test network "244 7"
       
   526                 TNetworkID ids;
       
   527                 TNetworkID networkCode;
       
   528                 ids = aCurrentInfo.iId.iCountryCode;
       
   529                 __GSLOGSTRING1("[GS]    HandleNetworkChangedL: iCountryCode: %S", &aCurrentInfo.iId.iCountryCode);
       
   530 
       
   531                 ids.Append( KGSEmptySpace );
       
   532                 networkCode = aCurrentInfo.iId.iNetworkCode;
       
   533                 __GSLOGSTRING1("[GS]    HandleNetworkChangedL: iNetworkCode: %S", &aCurrentInfo.iId.iNetworkCode);
       
   534 
       
   535                 ids.Append( networkCode );
       
   536                 stringholder =
       
   537                     StringLoader::LoadLC( R_NETSL_NETWORKSELECTED, ids );
       
   538                 }
       
   539             CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue );
       
   540             note->ExecuteLD( *stringholder );
       
   541             CleanupStack::PopAndDestroy( stringholder );
       
   542             //After list has been used, clear it.
       
   543             PurgeNetworkList();
       
   544             break;
       
   545             }
       
   546         case RMobilePhone::ERegistrationUnknown:
       
   547         case RMobilePhone::ENotRegisteredNoService:
       
   548         case RMobilePhone::ENotRegisteredEmergencyOnly:
       
   549         case RMobilePhone::ENotRegisteredSearching:
       
   550         case RMobilePhone::ERegisteredBusy:
       
   551         case RMobilePhone::ERegistrationDenied:
       
   552         default:
       
   553             break;
       
   554         }
       
   555     PhoneIdle();
       
   556     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::HandleNetworkChangedL");
       
   557     }
       
   558 
       
   559 
       
   560 // ---------------------------------------------------------------------------
       
   561 //
       
   562 // Handles user inputs in Options menu
       
   563 //
       
   564 // ---------------------------------------------------------------------------
       
   565 void CGSNetworkPlugin::HandleCommandL( TInt aCommand )
       
   566     {
       
   567     __GSLOGSTRING1("[CGSNetworkPlugin] HandleCommandL(%d)|->", aCommand );
       
   568     switch ( aCommand )
       
   569         {
       
   570         case EGSMSKCmdAppChange:
       
   571              HandleListBoxSelectionL();
       
   572              break;
       
   573         case EGSCmdAppChange:
       
   574             {
       
   575             const TInt currentFeatureId = Container()->CurrentFeatureId();
       
   576 
       
   577             if ( currentFeatureId == EGSMCNItemId )
       
   578                 {
       
   579                 ShowSettingPageL( EGSMCNItemId );
       
   580                 }
       
   581             else if ( currentFeatureId == EGSNetworkModeItemId )
       
   582                 {
       
   583                 CheckCallActiveL( EGSNetworkModeItemId );
       
   584                 }
       
   585             else
       
   586                 {
       
   587                 HandleListBoxEventL( NULL, EEventEnterKeyPressed );
       
   588                 }
       
   589             }
       
   590             break;
       
   591         case EAknSoftkeyBack:
       
   592             {
       
   593             if (!iPhoneSettingsEngine->IsActive())
       
   594                 {
       
   595                 iAppUi->ActivateLocalViewL( KGSConPluginUid /*KGSTelPluginUid*/ );                
       
   596                 }
       
   597             break;
       
   598             }
       
   599         case EAknCmdHelp:
       
   600             {
       
   601             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   602                 {
       
   603                 HlpLauncher::LaunchHelpApplicationL(
       
   604                     iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
       
   605                 }
       
   606             break;
       
   607             }
       
   608         default:
       
   609             iAppUi->HandleCommandL( aCommand );
       
   610             break;
       
   611         }
       
   612     __GSLOGSTRING("[CGSNetworkPlugin] HandleCommandL()-|");
       
   613     }
       
   614 
       
   615 
       
   616 // ---------------------------------------------------------------------------
       
   617 //
       
   618 // Handles user inputs in Options menu
       
   619 //
       
   620 // ---------------------------------------------------------------------------
       
   621 void CGSNetworkPlugin::ProcessCommandL( TInt aCommand )
       
   622     {
       
   623     // Network base class
       
   624     CAknView::ProcessCommandL( aCommand );
       
   625     }
       
   626 
       
   627 // ---------------------------------------------------------------------------
       
   628 //
       
   629 // While request to find networks is processed
       
   630 //
       
   631 // ---------------------------------------------------------------------------
       
   632 void CGSNetworkPlugin::HandleSearchingNetworksL(
       
   633                          MPsetNetworkInfoObserver::TServiceRequest aRequest )
       
   634     {
       
   635     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::HandleSearchingNetworksL");
       
   636     if ( !iNetworkArray )
       
   637         {
       
   638         iNetworkArray = new ( ELeave )
       
   639             CNetworkInfoArray( KGSNetworkInfoArrayGranularity );
       
   640         }
       
   641 
       
   642     if ( aRequest != MPsetNetworkInfoObserver::EServiceRequestNone )
       
   643         {
       
   644         CheckAndCreateDlgL( EFalse );
       
   645         if ( aRequest ==
       
   646              MPsetNetworkInfoObserver::EServiceRequestSetNetworkAutomatic )
       
   647             {
       
   648             UpdateListBoxL( EGSNetworkModeSelectionItemId,
       
   649                             EGSAutomaticSelectMode );
       
   650             }
       
   651         else
       
   652             {
       
   653             UpdateListBoxL( EGSNetworkModeSelectionItemId,
       
   654                             EGSManualSelectMode );
       
   655             }
       
   656 
       
   657         iSearchForNetworksActive = ETrue;
       
   658         TInt res = iDlg->ExecuteLD( R_SEARCHING_NOTE );
       
   659 
       
   660         if ( res == EGSSoftkeyQuit )
       
   661             {
       
   662             iPhoneSettingsEngine->CancelProcess();
       
   663             
       
   664             ShowSettingPageL( EGSNetworkModeSelectionItemId );
       
   665             }
       
   666         else
       
   667             {
       
   668             if ( aRequest ==
       
   669                  MPsetNetworkInfoObserver::EServiceRequestSetNetworkAutomatic )
       
   670                 {
       
   671                 PhoneIdle();
       
   672                 iAppUi->HandleCommandL( EEikCmdExit );
       
   673                 }
       
   674             }
       
   675         }
       
   676     else
       
   677         {
       
   678         delete iDlg;
       
   679         iDlg = NULL;
       
   680         }
       
   681 
       
   682     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::HandleSearchingNetworksL");
       
   683     }
       
   684 
       
   685 // ---------------------------------------------------------------------------
       
   686 //
       
   687 // While request to change network is processed, a note is shown
       
   688 //
       
   689 // ---------------------------------------------------------------------------
       
   690 void CGSNetworkPlugin::HandleRequestingSelectedNetworkL( TBool aOngoing )
       
   691     {
       
   692     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::HandleRequestingSelectedNetworkL");
       
   693     if ( aOngoing )
       
   694         {
       
   695         CheckAndCreateDlgL( ETrue );
       
   696 
       
   697         if ( iDlg->ExecuteLD( R_REQUESTING_NOTE ) == EGSSoftkeyQuit )
       
   698             {
       
   699             iPhoneSettingsEngine->CancelProcess();
       
   700 
       
   701             CAknNoteDialog* dlg = new ( ELeave ) CAknNoteDialog(
       
   702                 CAknNoteDialog::EConfirmationTone,
       
   703                 CAknNoteDialog::EShortTimeout );
       
   704             dlg->ExecuteLD( R_REGISTRATION_INTERRUPTED );
       
   705             iApprovedNetwork = EFalse;
       
   706             }
       
   707         }
       
   708     else
       
   709         {
       
   710         delete iDlg;
       
   711         iDlg = NULL;
       
   712         }
       
   713 
       
   714     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::HandleRequestingSelectedNetworkL");
       
   715     }
       
   716 
       
   717 
       
   718 // ---------------------------------------------------------------------------
       
   719 //
       
   720 // Activates the view
       
   721 //
       
   722 // ---------------------------------------------------------------------------
       
   723 void CGSNetworkPlugin::DoActivateL( const TVwsViewId&  aPrevViewId ,
       
   724                                        TUid  aCustomMessageId,
       
   725                                        const TDesC8&  aCustomMessage  )
       
   726     {
       
   727     __GSLOGSTRING( "[CGSNetworkPlugin] DoActivateL()|->" );
       
   728     CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   729     Container()->SetMiddleSoftkeyObserver( this );
       
   730     SetMiddleSoftKeyLabelL( R_CALL_MSK_CHANGE, EGSMSKCmdAppChange );
       
   731     // This way we set which command is set for MSK
       
   732     iMskCommandFlag = ETrue;
       
   733     iContainer->iListBox->SetTopItemIndex( iTopItemIndex );
       
   734 
       
   735     if ( iCurrentItem >= 0 &&
       
   736          iCurrentItem < iContainer->iListBox->Model()->NumberOfItems() )
       
   737         {
       
   738         iContainer->iListBox->SetCurrentItemIndexAndDraw( iCurrentItem );
       
   739         }
       
   740     if ( aCustomMessageId == TUid::Uid( KGSCustomActivateNetView ) )
       
   741        {
       
   742        UpdateListBoxL( EGSNetworkModeSelectionItemId, EGSManualSelectMode );
       
   743        iSearchForNetworksActive = ETrue;
       
   744        iPhoneSettingsEngine->GetAvailableNetworksL();
       
   745        }
       
   746     CheckMiddleSoftkeyLabelL();
       
   747     __GSLOGSTRING( "[CGSNetworkPlugin] DoActivateL()-|" );
       
   748     }
       
   749 
       
   750 // ---------------------------------------------------------------------------
       
   751 //
       
   752 // Deactivates the view
       
   753 //
       
   754 // ---------------------------------------------------------------------------
       
   755 void CGSNetworkPlugin::DoDeactivate()
       
   756     {
       
   757     __GSLOGSTRING("[CGSNetworkPlugin]--> DoDeactivate");
       
   758     if ( Container() )
       
   759         {
       
   760         if ( Container()->iListBox && iContainer->iListBox->View() )
       
   761             {
       
   762             iTopItemIndex = iContainer->iListBox->TopItemIndex();
       
   763             iCurrentItem = iContainer->iListBox->CurrentItemIndex();
       
   764             }
       
   765         iAppUi->RemoveFromViewStack( *this, Container() );
       
   766         delete iContainer;
       
   767         iContainer = NULL;
       
   768         }
       
   769     __GSLOGSTRING("[CGSNetworkPlugin] <--DoDeactivate");
       
   770     }
       
   771 
       
   772 // ---------------------------------------------------------------------------
       
   773 //
       
   774 // Shows setting page - for ON/OFF setting items
       
   775 //
       
   776 // ---------------------------------------------------------------------------
       
   777 void CGSNetworkPlugin::ShowSettingPageL( TGSNetworkItemIds aPage )
       
   778     {
       
   779     __GSLOGSTRING( "[CGSNetworkPlugin::ShowSettingPageL]" );
       
   780     TInt resourceId = 0;
       
   781     TInt currentItem = KGSSettingOff;
       
   782     HBufC* settingPageTitle = NULL;
       
   783 
       
   784     switch( aPage )
       
   785         {
       
   786         case EGSNetworkModeSelectionItemId:
       
   787             resourceId = R_NETSL_NETSELECTMODE_LBX;
       
   788             settingPageTitle = StringLoader::LoadLC( R_NETSL_NETSELECTMODE );
       
   789             currentItem = Container()->GetSelectionMode();
       
   790             break;
       
   791         case EGSMCNItemId:
       
   792             resourceId = R_MCN_CELL_INFO_DISP_MODE_LBX;
       
   793             settingPageTitle = StringLoader::LoadLC( R_MCN_CELL_INFO_DISP_MODE );
       
   794             Container()->GetMcnValue( iMCN );
       
   795             //for MCN, values need to be switched since Off = 0 in shared data, 1 on screen
       
   796             SwitchOnOffValue( iMCN );
       
   797             currentItem = iMCN;
       
   798             break;
       
   799         case EGSNetworkModeItemId:
       
   800             resourceId = R_NET_NETWORK_MODE_LBX;
       
   801             settingPageTitle = StringLoader::LoadLC( R_NET_NETWORK_MODE );
       
   802             currentItem = Container()->GetCurrentNetworkModeSelectionL();
       
   803             break;
       
   804         default:
       
   805             break;
       
   806         }
       
   807 
       
   808     
       
   809 
       
   810     //Checking if the phone is in offline mode
       
   811     const TBool iOfflineMode = IsPhoneOfflineL();
       
   812 
       
   813     // If it is in offline mode, then we dont launch the NW mode setting page at all
       
   814     if (  iOfflineMode /*&& aPage == EGSNetworkModeItemId*/ )
       
   815         {
       
   816         HBufC* string = StringLoader::LoadLC( R_OFFLINE_MODE );
       
   817         CAknErrorNote* note = new ( ELeave ) CAknErrorNote ( ETrue );
       
   818         note->ExecuteLD( *string );
       
   819         CleanupStack::PopAndDestroy( string );
       
   820         }
       
   821     else // if not offline mode we show the setting page
       
   822         {
       
   823         
       
   824         CGSRadioButtonSettingPageItemTextArray* itemArray =
       
   825                 CGSRadioButtonSettingPageItemTextArray::NewL( resourceId, *iCoeEnv, NULL );
       
   826 
       
   827         // network mode requires special handling as items in the settings page
       
   828         // are variated. The method below checks which items to display & hide.
       
   829         if ( aPage == EGSNetworkModeItemId )
       
   830             {
       
   831             Container()->CheckAndAlterContentsL( *itemArray );
       
   832             }
       
   833 
       
   834         CleanupStack::PushL( itemArray );
       
   835 
       
   836         TInt currentIndex = itemArray->IndexForFeatureIdL( currentItem );
       
   837 
       
   838         // no editor resource given
       
   839         iSettingDlg = new ( ELeave ) CAknRadioButtonSettingPage(
       
   840                 settingPageTitle, EAknSettingPageNoOrdinalDisplayed, 0, 0,
       
   841                 R_SETTING_PAGE, currentIndex, itemArray );
       
   842         itemArray->SetRadioButtonSettingPage( *iSettingDlg );
       
   843 
       
   844         const TInt prevSelection = currentIndex;
       
   845         if ( settingPageTitle )
       
   846         	{
       
   847         	iSettingDlg->SetSettingTextL( *settingPageTitle );	
       
   848         	}
       
   849 
       
   850         //Start listening if call occurs
       
   851         iPhoneSettingsEngine->SetNetSAObserver( *this );
       
   852         
       
   853         __GSLOGSTRING( "[CGSNetworkPlugin::ShowSettingPageL] Executing dialog" );
       
   854         const TInt res =
       
   855             iSettingDlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
   856         __GSLOGSTRING( "[CGSNetworkPlugin::ShowSettingPageL] Dialog closed" );
       
   857         iSettingDlg = NULL;
       
   858         // Get the feature id corresponding to array index
       
   859         const TGSNetworkModeItems currentFeature = IntToEnum( currentIndex );
       
   860 
       
   861         if ( res )
       
   862             {
       
   863             //not required for network mode UI item.
       
   864             //other items require calling this method.
       
   865             if ( aPage != EGSNetworkModeItemId )
       
   866                 {
       
   867                 CreateNetworkSsCallL( currentFeature, aPage );
       
   868                 }
       
   869             else if ( prevSelection != currentIndex )
       
   870                 {
       
   871                 // Show the confirmation query. Uses TGSNetworkModeItems.
       
   872                 Container()->SetCurrentNetworkModeSelectionL( currentFeature );
       
   873                 }
       
   874             }
       
   875         CleanupStack::PopAndDestroy( itemArray );
       
   876         }
       
   877     //We'll update listbox for Network Mode when we're sure that phone is not
       
   878     //in Offline mode
       
   879     if ( aPage != EGSNetworkModeItemId )
       
   880         {
       
   881         UpdateListBoxL( aPage );
       
   882         }
       
   883 
       
   884     CleanupStack::PopAndDestroy( settingPageTitle );
       
   885 
       
   886     __GSLOGSTRING( "[CGSNetworkPlugin::ShowSettingPageL] End" );
       
   887     }
       
   888 
       
   889 // ---------------------------------------------------------------------------
       
   890 //
       
   891 // utility for converting TInt to TGSNetworkModes enum.
       
   892 //
       
   893 // ---------------------------------------------------------------------------
       
   894 TGSNetworkModeItems CGSNetworkPlugin::IntToEnum( TInt aFeatureId )
       
   895     {
       
   896     TGSNetworkModeItems mode = EGSNetworkModeDualmode;
       
   897     TInt supportedNetworks = Container()->NetPluginModel()->GetSupportedNetworksL();
       
   898     TInt value = 0;
       
   899     
       
   900     switch( aFeatureId )
       
   901         {
       
   902         case EGSNetworkModeDualmode:
       
   903             mode = EGSNetworkModeDualmode;
       
   904             break;
       
   905         case EGSNetworkModeUMTS:
       
   906             value = supportedNetworks & CGSNetworkPluginContainer::ENetFirstBit;           
       
   907             if ( value ) 
       
   908                  {
       
   909                  mode = EGSNetworkModeUMTS;
       
   910                  }
       
   911              else
       
   912             //assume that only dual mode and gsm are possible.
       
   913                  {
       
   914                  mode = EGSNetworkModeGSM;
       
   915                  }
       
   916             break;
       
   917         case EGSNetworkModeGSM:
       
   918             mode = EGSNetworkModeGSM;
       
   919             break;
       
   920         default:
       
   921             // This should not happen as items should always have matching id.
       
   922             __ASSERT_DEBUG( EFalse, User::Panic( KGSNetworkPluginAssertName, KErrArgument ) );
       
   923         }
       
   924     return mode;
       
   925     }
       
   926 
       
   927 
       
   928 // ---------------------------------------------------------------------------
       
   929 //
       
   930 // If calls are started when in Network Setting Page, it is closed.
       
   931 //
       
   932 // ---------------------------------------------------------------------------
       
   933 void CGSNetworkPlugin::HandleCallActivatedL()
       
   934     {
       
   935     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::HandleCallActivatedL");
       
   936 
       
   937     CGSNetworkPluginContainer* container = Container();
       
   938     if ( container )
       
   939         {
       
   940         const TInt currentFeatureId = container->CurrentFeatureId();
       
   941 
       
   942 		    if ( currentFeatureId != EGSNetworkModeSelectionItemId )
       
   943 		        {
       
   944 		        iPhoneSettingsEngine->CancelProcess();
       
   945 		        return;
       
   946 		        }
       
   947 		    iPhoneSettingsEngine->CancelProcess();
       
   948 		    //Close requesting notes
       
   949 		    if ( iDlg )
       
   950 		        {
       
   951 		        HandleSearchingNetworksL( MPsetNetworkInfoObserver::EServiceRequestNone );
       
   952 		        HandleRequestingSelectedNetworkL( EFalse );
       
   953 		        }
       
   954 
       
   955 		    //Close available network's list
       
   956 		    if ( iNetworkPopupList )
       
   957 		        {
       
   958 		        iNetworkPopupList->CancelPopup();
       
   959 		        iNetworkPopupList = NULL;
       
   960 		        }
       
   961 		    
       
   962 		    CloseDialog();
       
   963 		    
       
   964         }
       
   965     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::HandleCallActivatedL");
       
   966     }
       
   967 
       
   968 // ---------------------------------------------------------------------------
       
   969 //
       
   970 // Handles errors.
       
   971 // From MPsetNetworkInfoObserver.
       
   972 // ---------------------------------------------------------------------------
       
   973 void CGSNetworkPlugin::HandleNetworkErrorL(
       
   974     const MPsetNetworkInfoObserver::TServiceRequest aRequest,
       
   975     const TInt aError )
       
   976     {
       
   977 
       
   978 #ifdef _DEBUG
       
   979     TBuf<KGSNetworkModeDebugStrLen> requestBuf;
       
   980     GSNetworkDebugHelper::NetworkInfoRequestToDes( aRequest, requestBuf );
       
   981     __GSLOGSTRING2( "[CGSNetworkPlugin::HandleNetworkErrorL] %S error:%d",
       
   982                     &requestBuf, aError );
       
   983 #endif // _DEBUG
       
   984 
       
   985     TInt resourceTxt = KErrNone;
       
   986     switch ( aRequest )
       
   987         {
       
   988         case MPsetNetworkInfoObserver::EServiceRequestGetNetworkInfo:
       
   989             iPhoneSettingsEngine->CancelProcess();
       
   990             iApprovedNetwork = EFalse;
       
   991             break;
       
   992         case MPsetNetworkInfoObserver::EServiceRequestSetNetworkAutomatic:
       
   993         case MPsetNetworkInfoObserver::EServiceRequestSetNetwork:
       
   994         default:
       
   995             break;
       
   996         }
       
   997 
       
   998     TBool ignore = EFalse;
       
   999 
       
  1000     switch ( aError )
       
  1001         {
       
  1002         case KErrGsmNetCauseCallActive:
       
  1003             ignore = ETrue; //do not show an error
       
  1004             break;
       
  1005         case KErrGsm0707NoNetworkService:
       
  1006             resourceTxt = R_NO_NETWORK_FOUND;
       
  1007             break;
       
  1008         case KErrGsmOfflineOpNotAllowed:
       
  1009             resourceTxt = R_OFFLINE_MODE;
       
  1010             break;
       
  1011         default:
       
  1012             resourceTxt = R_NO_NETWORK_ACCESS;
       
  1013             break;
       
  1014         }
       
  1015     if ( !ignore )
       
  1016         {
       
  1017         ShowNoteL( resourceTxt, KGSErrorNote );
       
  1018         iApprovedNetwork = EFalse;
       
  1019         }
       
  1020     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::HandleNetworkErrorL");
       
  1021     }
       
  1022 
       
  1023 // ---------------------------------------------------------------------------
       
  1024 //
       
  1025 // Check if calls are active and show note if Nw-menu is tried to be opened
       
  1026 //
       
  1027 // ---------------------------------------------------------------------------
       
  1028 void CGSNetworkPlugin::CheckCallActiveL( TGSNetworkItemIds aItemId )
       
  1029     {
       
  1030     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::CheckCallActiveL");
       
  1031     if ( iPhoneSettingsEngine->IsCallActive() == CPsetSAObserver::EPSetCallActive )
       
  1032         {
       
  1033         ShowNoteL( R_ONGOING_CALL, KGSErrorNote );
       
  1034         return;
       
  1035         }
       
  1036 
       
  1037     // Show network mode selection only if the mode value is already available!
       
  1038     if ( aItemId == EGSNetworkModeItemId && !iSettingDlg
       
  1039          && Container()->NetPluginModel()->GetNetworkMode()
       
  1040          != KGSNetworkModeCapsNotUpdated
       
  1041          )
       
  1042         {
       
  1043 #ifdef FF_POWER_SAVE            
       
  1044             if ( iPsmActive->Mode() == EPsmsrvModePowerSave )
       
  1045                 {
       
  1046                 // If PSM is on, block setting:
       
  1047                 DisplayBlockNoteL();
       
  1048                 }
       
  1049             else
       
  1050                 {
       
  1051 #endif // FF_POWER_SAVE                    
       
  1052                 ShowSettingPageL( EGSNetworkModeItemId );
       
  1053 #ifdef FF_POWER_SAVE
       
  1054                 }
       
  1055 #endif // FF_POWER_SAVE 
       
  1056         }
       
  1057     else if( !iSettingDlg         
       
  1058     	    //&& Container()->NetPluginModel()->GetNetworkMode()
       
  1059             /*!= KGSNetworkModeCapsNotUpdated*/ )
       
  1060         {
       
  1061         ShowSettingPageL( EGSNetworkModeSelectionItemId );
       
  1062         }
       
  1063     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::CheckCallActiveL");
       
  1064     }
       
  1065 
       
  1066 // ---------------------------------------------------------------------------
       
  1067 //
       
  1068 // Sets a title to a given popup list.
       
  1069 //
       
  1070 // ---------------------------------------------------------------------------
       
  1071 void CGSNetworkPlugin::SetTitleToPopupL( CAknPopupList& aList, TInt aTitleID )
       
  1072     {
       
  1073     HBufC* text = StringLoader::LoadLC( aTitleID );
       
  1074     aList.SetTitleL( *text );
       
  1075     CleanupStack::PopAndDestroy( text );
       
  1076     text = NULL;
       
  1077     }
       
  1078 
       
  1079 // ---------------------------------------------------------------------------
       
  1080 //
       
  1081 // Sets a title to a settings page.
       
  1082 //
       
  1083 // ---------------------------------------------------------------------------
       
  1084 void CGSNetworkPlugin::SetTitleToSettingsL( CAknRadioButtonSettingPage& aDlg,
       
  1085                                               TInt aTitleID )
       
  1086     {
       
  1087     HBufC* title = StringLoader::LoadLC( aTitleID );
       
  1088     aDlg.SetSettingTextL( *title );
       
  1089     CleanupStack::PopAndDestroy( title );
       
  1090     title = NULL;
       
  1091     }
       
  1092 
       
  1093 // ---------------------------------------------------------------------------
       
  1094 //
       
  1095 // Appends given item to given list
       
  1096 //
       
  1097 // ---------------------------------------------------------------------------
       
  1098 void CGSNetworkPlugin::AppendItemL( CDesCArrayFlat& aList, TInt aItem )
       
  1099     {
       
  1100     HBufC* string = StringLoader::LoadLC( aItem );
       
  1101     aList.AppendL( *string );
       
  1102     CleanupStack::PopAndDestroy( string );
       
  1103     }
       
  1104 
       
  1105 // ---------------------------------------------------------------------------
       
  1106 //
       
  1107 // Shows a note if GPRS is active, when MCN is turned on.
       
  1108 //
       
  1109 // ---------------------------------------------------------------------------
       
  1110 void CGSNetworkPlugin::CheckGPRSConnectionL( TInt aCurrentItem )
       
  1111     {
       
  1112     if ( ( iPhoneSettingsEngine->IsGPRSConnected() ==
       
  1113                      CPsetSAObserver::EPSetGPRSConnectionActive )
       
  1114         && ( aCurrentItem == KGSSettingOff ) ) //if trying to set On...
       
  1115         {
       
  1116         ShowNoteL( R_ACTIVE_GPRS_CONN_NOTE, KGSInformationNote );
       
  1117         }
       
  1118     }
       
  1119 
       
  1120 // ---------------------------------------------------------------------------
       
  1121 //
       
  1122 // Set MCN value: off => on, on => off.
       
  1123 //
       
  1124 // ---------------------------------------------------------------------------
       
  1125 void CGSNetworkPlugin::SwitchOnOffValue( TInt& aValue )
       
  1126     {
       
  1127     if ( aValue == EGSMcnSetOn )
       
  1128         {
       
  1129         aValue = EGSMcnSetOff;
       
  1130         }
       
  1131     else
       
  1132         {
       
  1133         aValue = EGSMcnSetOn;
       
  1134         }
       
  1135     }
       
  1136 
       
  1137 // ---------------------------------------------------------------------------
       
  1138 //
       
  1139 // Create new Net container.
       
  1140 //
       
  1141 // ---------------------------------------------------------------------------
       
  1142 //
       
  1143 void CGSNetworkPlugin::NewContainerL()
       
  1144     {
       
  1145     iContainer = new ( ELeave ) CGSNetworkPluginContainer( this );
       
  1146     }
       
  1147 
       
  1148 
       
  1149 // ---------------------------------------------------------------------------
       
  1150 // CGSNetworkPlugin::HandleListBoxSelectionL
       
  1151 //
       
  1152 // Handle user selection in the listbox to perform an associated action
       
  1153 // ---------------------------------------------------------------------------
       
  1154 void CGSNetworkPlugin::HandleListBoxSelectionL()
       
  1155     {
       
  1156     CEikMenuBar* menuBar = this->MenuBar();
       
  1157 
       
  1158     const TInt currentFeatureId = Container()->CurrentFeatureId();
       
  1159 
       
  1160     switch ( currentFeatureId )
       
  1161         {
       
  1162          case EGSNetworkModeSelectionItemId:
       
  1163             CheckCallActiveL( EGSNetworkModeSelectionItemId );
       
  1164             return;
       
  1165         case EGSMCNItemId:
       
  1166             if ( IsPhoneOfflineL() )
       
  1167                 {
       
  1168                 HBufC* string = StringLoader::LoadLC( R_OFFLINE_MODE );
       
  1169                 CAknErrorNote* note = new ( ELeave ) CAknErrorNote ( ETrue );
       
  1170                 note->ExecuteLD( *string );
       
  1171                 CleanupStack::PopAndDestroy( string );
       
  1172                 }
       
  1173             else
       
  1174                 {
       
  1175                 Container()->GetMcnValue( iMCN );
       
  1176                 CheckGPRSConnectionL( iMCN );
       
  1177                 SwitchOnOffValue( iMCN );
       
  1178                 Container()->SetMcnValue( iMCN );
       
  1179                 }
       
  1180             break;
       
  1181         case EGSNetworkModeItemId:
       
  1182             CheckCallActiveL( EGSNetworkModeItemId );
       
  1183             return;
       
  1184         default:
       
  1185             break;
       
  1186         }
       
  1187 
       
  1188     UpdateListBoxL( currentFeatureId );
       
  1189     }
       
  1190 
       
  1191 
       
  1192 // ---------------------------------------------------------------------------
       
  1193 //
       
  1194 // Makes a Network/MCN Ss operation.
       
  1195 //
       
  1196 // ---------------------------------------------------------------------------
       
  1197 void CGSNetworkPlugin::CreateNetworkSsCallL( TInt aIndex,
       
  1198                                              TGSNetworkItemIds aPage  )
       
  1199     {
       
  1200     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::CreateNetworkSsCallL");
       
  1201     if ( aPage == EGSNetworkModeSelectionItemId )
       
  1202         {
       
  1203         if ( aIndex == CGSNetworkPlugin::EAutomaticMode )
       
  1204             {
       
  1205             MPsetNetworkSelect::TNetworkInfo info;
       
  1206             MPsetNetworkSelect::TSelectMode mode =
       
  1207                 MPsetNetworkSelect::ENetSelectModeAutomatic;
       
  1208             iSearchForNetworksActive = ETrue;
       
  1209             iPhoneSettingsEngine->GetNetworkSelectMode( mode );
       
  1210             if ( mode == MPsetNetworkSelect::ENetSelectModeAutomatic )
       
  1211                 {
       
  1212                 iPreviousState = ETrue;
       
  1213                 }
       
  1214 
       
  1215             //get the local variation status for auto-auto net search support
       
  1216             //the flag is negative... so 1 means "no search allowed".
       
  1217             TBool autoNetSearchOff =
       
  1218              Container()->NetPluginModel()->AutomaticNetworkSearchSupportedL();
       
  1219 
       
  1220             //autoNetSearch is defaulted to 0
       
  1221             if ( iPreviousState && autoNetSearchOff )
       
  1222                 {
       
  1223                 PhoneIdle();
       
  1224                 }
       
  1225             else
       
  1226                 {
       
  1227                 info.iMode = MPsetNetworkSelect::ENetSelectModeAutomatic;
       
  1228                 iSearchForNetworksActive = ETrue;
       
  1229                 iPhoneSettingsEngine->SelectNetworkL( info );
       
  1230                 }
       
  1231             }
       
  1232         else //manual mode
       
  1233             {
       
  1234             iSearchForNetworksActive = ETrue;
       
  1235             iPhoneSettingsEngine->GetAvailableNetworksL();
       
  1236             }
       
  1237         }
       
  1238     else // MCN Setting page
       
  1239         {
       
  1240         iMCN = aIndex;
       
  1241         CheckGPRSConnectionL( iMCN );
       
  1242         SwitchOnOffValue( iMCN );
       
  1243         Container()->SetMcnValue( iMCN );
       
  1244         }
       
  1245     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::CreateNetworkSsCallL");
       
  1246     }
       
  1247 
       
  1248 // ---------------------------------------------------------------------------
       
  1249 //
       
  1250 // Shows note.
       
  1251 //
       
  1252 // ---------------------------------------------------------------------------
       
  1253 //
       
  1254 void CGSNetworkPlugin::ShowNoteL( TInt aResourceId, TInt aType )
       
  1255     {
       
  1256     HBufC* string = StringLoader::LoadLC( aResourceId );
       
  1257     switch ( aType )
       
  1258         {
       
  1259         case KGSErrorNote:
       
  1260             {
       
  1261             CAknErrorNote* note = new ( ELeave ) CAknErrorNote ( ETrue );
       
  1262             note->ExecuteLD( *string );
       
  1263             break;
       
  1264             }
       
  1265         case KGSConfirmationNote:
       
  1266             {
       
  1267             CAknConfirmationNote* note =
       
  1268                 new ( ELeave ) CAknConfirmationNote( ETrue );
       
  1269             note->ExecuteLD( *string );
       
  1270             break;
       
  1271             }
       
  1272         case KGSInformationNote:
       
  1273             {
       
  1274             CAknInformationNote* note =
       
  1275                 new ( ELeave ) CAknInformationNote( ETrue );
       
  1276             note->ExecuteLD( *string );
       
  1277             break;
       
  1278             }
       
  1279         default:
       
  1280             break;
       
  1281         }
       
  1282     CleanupStack::PopAndDestroy( string );
       
  1283     }
       
  1284 
       
  1285 // ---------------------------------------------------------------------------
       
  1286 //
       
  1287 // Creates dialog, if it is does not exist yet.
       
  1288 //
       
  1289 // ---------------------------------------------------------------------------
       
  1290 //
       
  1291 void CGSNetworkPlugin::CheckAndCreateDlgL( TBool aDelayOff )
       
  1292     {
       
  1293     if ( !iDlg )
       
  1294         {
       
  1295         iDlg = new ( ELeave ) CAknWaitDialog(
       
  1296             reinterpret_cast<CEikDialog**> ( &iDlg ), aDelayOff );
       
  1297         }
       
  1298     }
       
  1299 
       
  1300 // ---------------------------------------------------------------------------
       
  1301 //
       
  1302 // Empties fetched network provider's list
       
  1303 //
       
  1304 // ---------------------------------------------------------------------------
       
  1305 //
       
  1306 void CGSNetworkPlugin::PurgeNetworkList()
       
  1307     {
       
  1308     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::PurgeNetworkList");
       
  1309     if ( iNetworkArray )
       
  1310         {
       
  1311         iNetworkArray->Reset();
       
  1312         delete iNetworkArray;
       
  1313         iNetworkArray = NULL;
       
  1314         }
       
  1315     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::PurgeNetworkList");
       
  1316     }
       
  1317 
       
  1318 
       
  1319 // ---------------------------------------------------------------------------
       
  1320 // CGSNetworkPlugin::Container
       
  1321 //
       
  1322 // Returns Network container item
       
  1323 // ---------------------------------------------------------------------------
       
  1324 //
       
  1325 CGSNetworkPluginContainer* CGSNetworkPlugin::Container()
       
  1326     {
       
  1327     return static_cast <CGSNetworkPluginContainer*> ( iContainer );
       
  1328     }
       
  1329 
       
  1330 // ---------------------------------------------------------------------------
       
  1331 // @@see MSSSettingsRefreshObserver::AllowRefresh
       
  1332 //
       
  1333 // Notification to allow refresh from SAT
       
  1334 // ---------------------------------------------------------------------------
       
  1335 //
       
  1336 TBool CGSNetworkPlugin::AllowRefresh(
       
  1337                 const TSatRefreshType aType,
       
  1338                 const TSatElementaryFiles aFiles )
       
  1339     {
       
  1340     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::AllowRefresh");
       
  1341     TBool allowRefresh = ETrue;
       
  1342     if ( iPhoneSettingsEngine->IsCallActive() == CPsetSAObserver::EPSetCallActive )
       
  1343         {
       
  1344         allowRefresh = EFalse;
       
  1345         }
       
  1346 
       
  1347     //check that aFiles has a value before issuing a refresh command
       
  1348     //no need to check for a specific file...
       
  1349     if ( ( aType != EFileChangeNotification ) ||
       
  1350          ( aType == EFileChangeNotification ) &&
       
  1351          ( aFiles & KCsp1Ef ||  aFiles & KCsp2Ef ) )
       
  1352         {
       
  1353         if ( iNetworkPopupList )
       
  1354             {
       
  1355             allowRefresh = EFalse;
       
  1356             }
       
  1357         }
       
  1358 
       
  1359     __GSLOGSTRING1("[GS]    AllowRefresh: allowRefresh: %d", allowRefresh);
       
  1360     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::AllowRefresh");
       
  1361     return allowRefresh;
       
  1362     }
       
  1363 
       
  1364 
       
  1365 
       
  1366 // ---------------------------------------------------------------------------
       
  1367 // @@see MSSSettingsRefreshObserver::Refresh
       
  1368 //
       
  1369 // Do the actual refresh of the UI for CSP file updation
       
  1370 // ---------------------------------------------------------------------------
       
  1371 //
       
  1372 void CGSNetworkPlugin::Refresh(
       
  1373                 const TSatRefreshType aType,
       
  1374                 const TSatElementaryFiles aFiles )
       
  1375     {
       
  1376     __GSLOGSTRING("[GS]--> CGSNetworkPlugin::Refresh");
       
  1377     // for a file change notification to be handled, aFiles must always
       
  1378     // contain a value
       
  1379     if ( ( aType != EFileChangeNotification ) ||
       
  1380          ( aType == EFileChangeNotification ) &&
       
  1381          ( aFiles & KCsp1Ef ||  aFiles & KCsp2Ef  ) )
       
  1382         {
       
  1383         //check if this check is required, as it is visible in the UI
       
  1384         if ( iNetworkPopupList )
       
  1385             {
       
  1386             iNetworkPopupList->CancelPopup();
       
  1387             iNetworkPopupList = NULL;
       
  1388             }
       
  1389 
       
  1390         //Change the network mode to Automatic.
       
  1391         MPsetNetworkSelect::TNetworkInfo info;
       
  1392         info.iMode = MPsetNetworkSelect::ENetSelectModeAutomatic;
       
  1393         iSearchForNetworksActive = ETrue;
       
  1394         TRAP_IGNORE( iPhoneSettingsEngine->SelectNetworkL( info ) );
       
  1395         __GSLOGSTRING("[GS]    Refresh: before Updating the listbox");
       
  1396         TRAP_IGNORE( UpdateListBoxL( EGSNetworkModeSelectionItemId ) );
       
  1397         __GSLOGSTRING("[GS]    Refresh: after Updating the listbox");
       
  1398         }
       
  1399 
       
  1400     __GSLOGSTRING("[GS] <--CGSNetworkPlugin::Refresh");
       
  1401     }
       
  1402 
       
  1403 
       
  1404 // ---------------------------------------------------------------------------
       
  1405 // CGSNetworkPlugin::PhoneIdle
       
  1406 //
       
  1407 // Switch to Phone Idle view. GS is running at the background.
       
  1408 // ---------------------------------------------------------------------------
       
  1409 //
       
  1410 void CGSNetworkPlugin::PhoneIdle()
       
  1411     {
       
  1412     // Fetching the current Idle id
       
  1413     TInt idleApp;
       
  1414     RProperty::Get( KPSUidAiInformation, KActiveIdleUid, idleApp );
       
  1415     TUid idleAppUid = { idleApp } ;
       
  1416     TApaTaskList taskList( iEikonEnv->WsSession() );
       
  1417     TApaTask task = taskList.FindApp( idleAppUid );
       
  1418 
       
  1419     // Expecting that idle application is open always
       
  1420     // if not we dont do anything
       
  1421     if( task.Exists() )  // App open
       
  1422     	{
       
  1423         task.BringToForeground();
       
  1424         }
       
  1425 
       
  1426     //No need to reset network search on exit
       
  1427     iSearchForNetworksActive = EFalse;
       
  1428     }
       
  1429 
       
  1430 
       
  1431 // -----------------------------------------------------------------------------
       
  1432 // When this method is called, view checks based on highlight focus, if the MSK
       
  1433 // label is correct.
       
  1434 // -----------------------------------------------------------------------------
       
  1435 //
       
  1436 void CGSNetworkPlugin::CheckMiddleSoftkeyLabelL()
       
  1437     {
       
  1438     }
       
  1439 
       
  1440 
       
  1441 // -----------------------------------------------------------------------------
       
  1442 // Remove unnecessary commands from Middle softkey.
       
  1443 // @flag = ETrue means presently MSK value is "Change" so we remove that
       
  1444 // @flag = EFalse means presently MSK value is "Context Options" so we remove that
       
  1445 // -----------------------------------------------------------------------------
       
  1446 //
       
  1447 void CGSNetworkPlugin::RemoveCommandFromMSK(const TBool flag )
       
  1448     {
       
  1449     CEikButtonGroupContainer* cbaGroup = Cba();
       
  1450     if ( cbaGroup )
       
  1451         {
       
  1452         if ( flag )
       
  1453             {
       
  1454             cbaGroup->RemoveCommandFromStack(
       
  1455                                 KGSMSKControlID, EGSMSKCmdAppChange );
       
  1456             }
       
  1457         else
       
  1458             {
       
  1459             cbaGroup->RemoveCommandFromStack(
       
  1460                                 KGSMSKControlID, EAknSoftkeyContextOptions );
       
  1461             }
       
  1462         }
       
  1463     }
       
  1464 
       
  1465 // ---------------------------------------------------------------------------
       
  1466 // Sets middle softkey label.
       
  1467 // ---------------------------------------------------------------------------
       
  1468 //
       
  1469 void CGSNetworkPlugin::SetMiddleSoftKeyLabelL(
       
  1470     const TInt aResourceId, const TInt aCommandId )
       
  1471     {
       
  1472     CEikButtonGroupContainer* cbaGroup = Cba();
       
  1473     if ( cbaGroup )
       
  1474         {
       
  1475         HBufC* middleSKText = StringLoader::LoadLC( aResourceId );
       
  1476         TPtr mskPtr = middleSKText->Des();
       
  1477         cbaGroup->AddCommandToStackL(
       
  1478             KGSMSKControlID,
       
  1479             aCommandId,
       
  1480             mskPtr );
       
  1481         CleanupStack::PopAndDestroy( middleSKText );
       
  1482         }
       
  1483     }
       
  1484 
       
  1485 // -----------------------------------------------------------------------------
       
  1486 // CGSNetworkPlugin::HandleClientRectChange
       
  1487 //
       
  1488 //
       
  1489 // -----------------------------------------------------------------------------
       
  1490 //
       
  1491 void CGSNetworkPlugin::HandleClientRectChange()
       
  1492     {
       
  1493     if ( iContainer )
       
  1494         {
       
  1495         iContainer->SetRect( ClientRect() );
       
  1496         }
       
  1497     }
       
  1498 
       
  1499 // ========================= From CGSPluginInterface ==================
       
  1500 
       
  1501 // -----------------------------------------------------------------------------
       
  1502 // CGSNetworkPlugin::GetCaptionL
       
  1503 //
       
  1504 //
       
  1505 // -----------------------------------------------------------------------------
       
  1506 //
       
  1507 void CGSNetworkPlugin::GetCaptionL( TDes& aCaption ) const
       
  1508     {
       
  1509     HBufC* result = StringLoader::LoadL( R_GS_NET_VIEW_CAPTION );
       
  1510     aCaption.Copy( *result );
       
  1511     delete result;
       
  1512     }
       
  1513 
       
  1514 
       
  1515 // -----------------------------------------------------------------------------
       
  1516 // CGSNetworkPlugin::PluginProviderCategory
       
  1517 //
       
  1518 //
       
  1519 // -----------------------------------------------------------------------------
       
  1520 //
       
  1521 TInt CGSNetworkPlugin::PluginProviderCategory() const
       
  1522     {
       
  1523     //This plugin is created by 3rd party.
       
  1524     return KGSPluginProviderInternal;
       
  1525     }
       
  1526 
       
  1527 // ---------------------------------------------------------------------------
       
  1528 //
       
  1529 // Updates specific value to container.
       
  1530 //
       
  1531 // ---------------------------------------------------------------------------
       
  1532 //
       
  1533 void CGSNetworkPlugin::UpdateListBoxL( const TInt& aListItem,
       
  1534                                        const TInt aNewValue )
       
  1535     {
       
  1536     if ( iContainer && iContainer->iListBox )
       
  1537         {
       
  1538         Container()->UpdateListBoxL( aListItem, aNewValue );
       
  1539         }
       
  1540     CheckMiddleSoftkeyLabelL();
       
  1541     }
       
  1542 
       
  1543 // -----------------------------------------------------------------------------
       
  1544 // CGSNetworkPlugin::CreateIconL()
       
  1545 //
       
  1546 //
       
  1547 // -----------------------------------------------------------------------------
       
  1548 //
       
  1549 CGulIcon* CGSNetworkPlugin::CreateIconL( const TUid aIconType )
       
  1550     {
       
  1551     //EMbm<Mbm_file_name><Bitmap_name>
       
  1552     CGulIcon* icon;
       
  1553     TParse* fp = new( ELeave ) TParse();
       
  1554     CleanupStack::PushL( fp );
       
  1555     fp->Set( KGSNetworkPluginIconDirAndName, &KDC_BITMAP_DIR, NULL );
       
  1556 
       
  1557     if( aIconType == KGSIconTypeLbxItem && PhoneOnline() )
       
  1558         {
       
  1559         icon = AknsUtils::CreateGulIconL(
       
  1560             AknsUtils::SkinInstance(),
       
  1561             KAknsIIDQgnPropSetNetworkSub,
       
  1562             fp->FullName(),
       
  1563             EMbmGsnetworkpluginQgn_prop_set_network_sub,
       
  1564             EMbmGsnetworkpluginQgn_prop_set_network_sub_mask );
       
  1565         }
       
  1566     else if( aIconType == KGSIconTypeLbxItem /*->phone offline*/ )
       
  1567         {
       
  1568         icon = AknsUtils::CreateGulIconL(
       
  1569             AknsUtils::SkinInstance(),
       
  1570             KAknsIIDQgnPropSetNetworkSub,
       
  1571             fp->FullName(),
       
  1572             EMbmGsnetworkpluginQgn_prop_set_network_sub_offline,
       
  1573             EMbmGsnetworkpluginQgn_prop_set_network_sub_offline_mask );
       
  1574         }
       
  1575     else
       
  1576         {
       
  1577         icon = CGSPluginInterface::CreateIconL( aIconType );
       
  1578         }
       
  1579     CleanupStack::PopAndDestroy( fp );
       
  1580     return icon;
       
  1581     }
       
  1582 
       
  1583 // ---------------------------------------------------------------------------
       
  1584 // CGSNetworkPlugin::HandleNotifyPSL
       
  1585 //
       
  1586 // Handling PS keys change
       
  1587 // ---------------------------------------------------------------------------
       
  1588 //
       
  1589 void CGSNetworkPlugin::HandleNotifyPSL( const TUid aUid, const TInt& aKey,
       
  1590                                         const TRequestStatus& /* aStatus */ )
       
  1591     {
       
  1592     if ( aUid == KPSUidBluetoothSapConnectionState &&
       
  1593          aKey == KBTSapConnectionState )
       
  1594         {
       
  1595         Visible();
       
  1596         }
       
  1597     }
       
  1598 
       
  1599 // ---------------------------------------------------------
       
  1600 // CGSNetworkPlugin::IsPhoneOfflineL
       
  1601 //
       
  1602 // Checks if phone is in offline mode or not.
       
  1603 // Return ETrue if phone is in offline mode.
       
  1604 // Return EFalse if phone is not in offline mode.
       
  1605 // ---------------------------------------------------------
       
  1606 //
       
  1607 TBool CGSNetworkPlugin::IsPhoneOfflineL() const
       
  1608     {
       
  1609     if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
       
  1610         {
       
  1611         CRepository* repository = CRepository::NewLC( KCRUidCoreApplicationUIs );
       
  1612         TInt connAllowed = 1;
       
  1613         repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
       
  1614         CleanupStack::PopAndDestroy();  // repository
       
  1615         if ( !connAllowed )
       
  1616             {
       
  1617             return ETrue;
       
  1618             }
       
  1619         }
       
  1620     return EFalse;
       
  1621     }
       
  1622 
       
  1623 
       
  1624 // ----------------------------------------------------------------------------
       
  1625 // CGSNetworkPlugin::DynInitMenuPaneL()
       
  1626 //
       
  1627 // Display the dynamic menu
       
  1628 // ----------------------------------------------------------------------------
       
  1629 void CGSNetworkPlugin::DynInitMenuPaneL( TInt aResourceId,
       
  1630                                          CEikMenuPane* aMenuPane )
       
  1631     {
       
  1632     // show or hide the 'help' menu item when supported
       
  1633     if( aResourceId == R_GS_MENU_ITEM_HELP )
       
  1634         {
       
  1635         User::LeaveIfNull( aMenuPane );
       
  1636 
       
  1637         if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
  1638             {
       
  1639             aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
       
  1640             }
       
  1641         else
       
  1642             {
       
  1643             aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
  1644             }
       
  1645         }
       
  1646     }
       
  1647 
       
  1648 
       
  1649 //Disabling warning caused by err variable used inside macros
       
  1650 #pragma diag_suppress 550
       
  1651 // -----------------------------------------------------------------------------
       
  1652 // CGSNetworkPlugin::GetValue()
       
  1653 //
       
  1654 // -----------------------------------------------------------------------------
       
  1655 //
       
  1656 void CGSNetworkPlugin::GetValue( const TGSPluginValueKeys aKey,
       
  1657                                  TDes& aValue )
       
  1658     {
       
  1659     switch( aKey )
       
  1660         {
       
  1661         case EGSPluginKeySettingsItemValueString:
       
  1662             // Operator name is async function but GetValue is synchronous.
       
  1663             // As a result the first GetValue call might not contain updated
       
  1664             // operator name. A callback will however ask to update parent plugin
       
  1665             // which will then call GetValue a second time and the operator name
       
  1666             // will then be updated.
       
  1667             if( !iNWSession )
       
  1668                 {
       
  1669                 __GSLOGSTRING(" [CGSNetworkPlugin::GetValue] Opening iNWSession..." );
       
  1670 
       
  1671                 // Create network handling engine session.
       
  1672                 // Question: is this callback one-shot or constant observer?
       
  1673                 TRAPD( err, iNWSession = CreateL( *this, iNWInfo ) );
       
  1674                 __GSLOGSTRING1(" [CGSNetworkPlugin::GetValue] Done. Err:%d", err );
       
  1675                 }
       
  1676             aValue.Copy( iNetworkText->Des() );
       
  1677             break;
       
  1678         default:
       
  1679             aValue.Append( KEmptyStr );
       
  1680             break;
       
  1681         }
       
  1682     }
       
  1683 
       
  1684 //Enabling warnings
       
  1685 #pragma diag_default 550
       
  1686 // -----------------------------------------------------------------------------
       
  1687 // CGSNetworkPlugin::GetNetworkValues()
       
  1688 // Get network status
       
  1689 // qtn.cp.detail.cellular.operational / qtn.cp.detail.cellular.offline
       
  1690 // qtn_cp_detail_cellular_operational / qtn_cp_detail_cellular_offline
       
  1691 // and operator name.
       
  1692 // -----------------------------------------------------------------------------
       
  1693 //
       
  1694 void CGSNetworkPlugin::UpdateNetworkTextL()
       
  1695     {
       
  1696     // On default text is 'off-line', if online status is received use,
       
  1697     // 'operational'.
       
  1698     TInt networkStatusRscId = R_CELLULAR_OFFLINE;
       
  1699 
       
  1700     if( iNetworkText )
       
  1701         {
       
  1702         delete iNetworkText;
       
  1703         iNetworkText = NULL;
       
  1704         }
       
  1705 
       
  1706     if( PhoneOnline() )
       
  1707         {
       
  1708         __GSLOGSTRING(" [CGSNetworkPlugin::UpdateNetworkTextL] Loading operational-text" );
       
  1709         iNetworkText = iNWInfo.iLongName.AllocL();      
       
  1710         }
       
  1711     else
       
  1712         {
       
  1713         __GSLOGSTRING(" [CGSNetworkPlugin::UpdateNetworkTextL] Loading offline-text" );
       
  1714         networkStatusRscId = R_CELLULAR_OFFLINE;
       
  1715         iNetworkText = StringLoader::LoadL( networkStatusRscId );
       
  1716         }
       
  1717     __GSLOGSTRING1( "[CGSNetworkPlugin::UpdateNetworkTextL] iNetworkText:%S ", iNetworkText );
       
  1718     }
       
  1719 
       
  1720 
       
  1721 //Disabling warning caused by err variable used inside macros
       
  1722 #pragma diag_suppress 550
       
  1723 // -----------------------------------------------------------------------------
       
  1724 // CGSNetworkPlugin::HandleNetworkMessage
       
  1725 // From MNWMessageObserver.
       
  1726 //
       
  1727 // -----------------------------------------------------------------------------
       
  1728 //
       
  1729 void CGSNetworkPlugin::HandleNetworkMessage( const TNWMessages aMessage )
       
  1730     {
       
  1731 #ifdef _DEBUG
       
  1732     TBuf<KGSNetworkModeDebugStrLen> messageBuf;
       
  1733     GSNetworkDebugHelper::NetworkMessageToDes( aMessage, messageBuf );
       
  1734     __GSLOGSTRING1( "[CGSNetworkPlugin::HandleNetworkMessage] %S",
       
  1735                     &messageBuf );
       
  1736 #endif // _DEBUG
       
  1737 
       
  1738     switch( aMessage )
       
  1739         {
       
  1740         case ENWMessageNetworkInfoChange:
       
  1741             TRAPD
       
  1742                 (
       
  1743                 err,
       
  1744                 UpdateNetworkTextL();
       
  1745                 )
       
  1746             __GSLOGSTRING1(
       
  1747                     "[CGSNetworkPlugin::HandleNetworkMessage] Update network text error:%d.",
       
  1748                     err );
       
  1749             TRAPD
       
  1750                 (
       
  1751                 err2,
       
  1752                 UpdateNetworkSettingPageL();
       
  1753                 )
       
  1754             __GSLOGSTRING1(
       
  1755                     "[CGSNetworkPlugin::HandleNetworkMessage] Update network setting page error:%d.",
       
  1756                     err2 );
       
  1757             Parent()->UpdateView();
       
  1758             break;
       
  1759         default:
       
  1760             break;
       
  1761         }
       
  1762     }
       
  1763 
       
  1764 
       
  1765 // -----------------------------------------------------------------------------
       
  1766 // CGSNetworkPlugin::UpdateNetworkSettingPageL
       
  1767 //
       
  1768 //
       
  1769 // -----------------------------------------------------------------------------
       
  1770 //
       
  1771 void CGSNetworkPlugin::UpdateNetworkSettingPageL()
       
  1772     {
       
  1773     // If network mode setting page is open, close it and open
       
  1774     // again so it will update the selected value correctly.
       
  1775     // Whoopee! Who said setting dialogs are dumb?
       
  1776     if( iSettingDlg && Container()->CurrentFeatureId() ==  EGSNetworkModeItemId )
       
  1777         {
       
  1778         __GSLOGSTRING( "[CGSNetworkPlugin::UpdateNetworkSettingPageL] Closing and reopening dialog..." );
       
  1779         CloseDialog();
       
  1780         ShowSettingPageL( EGSNetworkModeItemId );
       
  1781         }
       
  1782     }
       
  1783 
       
  1784 //Enabling warnings
       
  1785 #pragma diag_default 550
       
  1786 
       
  1787 // -----------------------------------------------------------------------------
       
  1788 // CGSNetworkPlugin::HandleNetworkError
       
  1789 // From MNWMessageObserver.
       
  1790 //
       
  1791 // -----------------------------------------------------------------------------
       
  1792 //
       
  1793 void CGSNetworkPlugin::HandleNetworkError( const TNWOperation aOperation,
       
  1794                                            TInt aErrorCode )
       
  1795     {
       
  1796     // Probably no need to do anything as default assumption is off-line unless
       
  1797     // iNWInfo.iRegistrationStatus defines otherwise. Question is, does
       
  1798     // iNWSession update iNWInfo values to anything sensible in case of error.
       
  1799 #ifdef _DEBUG
       
  1800     TBuf<KGSNetworkModeDebugStrLen> operationBuf;
       
  1801     GSNetworkDebugHelper::NetworkOperationToDes( aOperation, operationBuf );
       
  1802     __GSLOGSTRING2( "[CGSNetworkPlugin::HandleNetworkError] %S error:%d",
       
  1803                     &operationBuf, aErrorCode );
       
  1804 #endif // _DEBUG
       
  1805 
       
  1806     // Later network operator name seems to be updated after HandleNetworkError
       
  1807     // so we probably want to update the name also in UI as soon as possible.
       
  1808     TRAP_IGNORE( UpdateNetworkTextL(); );
       
  1809 
       
  1810     // CGSParentPlugin::DoDeactivate() will delete it's container so calling
       
  1811     // CGSParentPlugin::UpdateView() should not cause unnecessary container
       
  1812     // updates.
       
  1813     Parent()->UpdateView();
       
  1814     }
       
  1815 
       
  1816 
       
  1817 // -----------------------------------------------------------------------------
       
  1818 // CGSNetworkPlugin::Parent
       
  1819 //
       
  1820 //
       
  1821 // -----------------------------------------------------------------------------
       
  1822 //
       
  1823 CGSParentPlugin* CGSNetworkPlugin::Parent()
       
  1824     {
       
  1825     CGSParentPlugin* parent = static_cast<CGSParentPlugin*>(
       
  1826             AppUi()->View( KGSConPluginUid ) );
       
  1827     return parent;
       
  1828     }
       
  1829 
       
  1830 
       
  1831 // -----------------------------------------------------------------------------
       
  1832 // CGSNetworkPlugin::PhoneOnline
       
  1833 //
       
  1834 //
       
  1835 // -----------------------------------------------------------------------------
       
  1836 //
       
  1837 TBool CGSNetworkPlugin::PhoneOnline()
       
  1838     {
       
  1839 #ifdef _DEBUG
       
  1840     TBuf<KGSNetworkModeDebugStrLen> statusBuf;
       
  1841     GSNetworkDebugHelper::NetworkStatusToDes( iNWInfo.iRegistrationStatus, statusBuf );
       
  1842     __GSLOGSTRING1( "[CGSNetworkPlugin::PhoneOnline] %S", &statusBuf );
       
  1843 #endif // _DEBUG
       
  1844 
       
  1845     TBool online = EFalse;
       
  1846     switch( iNWInfo.iRegistrationStatus )
       
  1847         {
       
  1848         case ENWRegisteredOnHomeNetwork: // Same functionality as below
       
  1849         case ENWRegisteredRoaming:
       
  1850             {
       
  1851             online = ETrue;
       
  1852             break;
       
  1853             }
       
  1854         default:
       
  1855             {
       
  1856             online = EFalse;
       
  1857             break;
       
  1858             }
       
  1859         }
       
  1860     return online;
       
  1861     }
       
  1862 
       
  1863 
       
  1864 // -----------------------------------------------------------------------------
       
  1865 // CGSNetworkPlugin::CloseDialog
       
  1866 //
       
  1867 //
       
  1868 // -----------------------------------------------------------------------------
       
  1869 //
       
  1870 void CGSNetworkPlugin::CloseDialog()
       
  1871     {
       
  1872     //Send ESC key sequence to setting dialog, so that it closes itself.
       
  1873     if ( iSettingDlg )
       
  1874         {
       
  1875         TKeyEvent event;
       
  1876         event.iCode = EKeyEscape;
       
  1877         event.iScanCode = EStdKeyEscape;
       
  1878         event.iRepeats = 0;
       
  1879         TRAP_IGNORE( iCoeEnv->SimulateKeyEventL( event, EEventKeyDown );
       
  1880                      iCoeEnv->SimulateKeyEventL( event, EEventKey );
       
  1881                      iCoeEnv->SimulateKeyEventL( event, EEventKeyUp ); );
       
  1882         }
       
  1883     }
       
  1884 
       
  1885 #ifdef FF_POWER_SAVE
       
  1886 // ----------------------------------------------------------------------------------
       
  1887 // CGSDisplayPlugin::DisplayBlockNoteL()
       
  1888 // ----------------------------------------------------------------------------------
       
  1889 void CGSNetworkPlugin::DisplayBlockNoteL()
       
  1890     {
       
  1891     HBufC* prompt = iCoeEnv->AllocReadResourceLC(
       
  1892             R_GS_POWER_SAVING_PROTECTED_SETTINGS_INFONOTE );
       
  1893     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
  1894     note->ExecuteLD( *prompt );
       
  1895     CleanupStack::PopAndDestroy( prompt );
       
  1896     }
       
  1897 
       
  1898 // ----------------------------------------------------------------------------------
       
  1899 // CGSDisplayPlugin::UpdateOnPsmChanged()
       
  1900 // ----------------------------------------------------------------------------------
       
  1901 void CGSNetworkPlugin::UpdateOnPsmChanged() 
       
  1902     {
       
  1903     __GSLOGSTRING( "[CGSNetworkPlugin::UpdateOnPsmChanged]" );
       
  1904     
       
  1905     if ( Container() && Container()->NetPluginModel() )
       
  1906         {
       
  1907         Container()->NetPluginModel()->StartAsynGetCurrentNetworkModeSelectionL();
       
  1908         }
       
  1909     }
       
  1910 
       
  1911 #endif // FF_POWER_SAVE
       
  1912 
       
  1913 //End of File