networkhandling/networkhandlingengine/NetworkHandlingSrc/CNWServiceProviderNameCommand.cpp
changeset 0 ff3b6d0fd310
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  This module contains implementation of 
       
    15 *                CNWServiceProviderNameCommand class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include    "CNWMessageHandler.h"
       
    23 #include    "CNWServiceProviderNameCommand.h"
       
    24 #include    "NWPanic.pan"
       
    25 #include    "NWLogger.h"
       
    26 
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ==============================
       
    29 
       
    30 // ----------------------------------------------------------------------------
       
    31 // CNWServiceProviderNameCommand::CNWServiceProviderNameCommand
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // ----------------------------------------------------------------------------
       
    35 //
       
    36 CNWServiceProviderNameCommand::CNWServiceProviderNameCommand
       
    37     (
       
    38     CNWMessageHandler& aOwner,                 // ref. to class owner
       
    39     RMobilePhone& aPhone,                   // ref. to mobile phone
       
    40     TNWInfo& aNetworkInfo          // ref. to network info struct
       
    41     ) : CActive( EPriorityStandard ), 
       
    42         iOwner( aOwner ),
       
    43         iPhone( aPhone ), 
       
    44         iNWNetworkInfo( aNetworkInfo ),
       
    45         iServiceProviderNamePckg( iParamServiceProviderName ),
       
    46         iAllowSending( ETrue )
       
    47     { //lint !e1403
       
    48     NWLOGSTRING(KNWOBJECT,
       
    49         "NW: CNWServiceProviderNameCommand::\
       
    50         CNWServiceProviderNameCommand() Begin");
       
    51     
       
    52     CActiveScheduler::Add( this );
       
    53 
       
    54     NWLOGSTRING(KNWOBJECT,
       
    55         "NW: CNWServiceProviderNameCommand::\
       
    56         CNWServiceProviderNameCommand() End");
       
    57     }
       
    58 
       
    59     
       
    60 // Destructor
       
    61 CNWServiceProviderNameCommand::~CNWServiceProviderNameCommand()
       
    62     {
       
    63     NWLOGSTRING(KNWOBJECT,
       
    64         "NW: CNWServiceProviderNameCommand::\
       
    65         ~CNWServiceProviderNameCommand() Begin");
       
    66     
       
    67     Cancel();
       
    68     
       
    69     NWLOGSTRING(KNWOBJECT,
       
    70         "NW: CNWServiceProviderNameCommand::\
       
    71         ~CNWServiceProviderNameCommand() End");
       
    72     }
       
    73 
       
    74 
       
    75 // ----------------------------------------------------------------------------
       
    76 // CNWServiceProviderNameCommand::DoCancel
       
    77 // Cancels the pending async. command.
       
    78 // Cancels the pending async. command. The active command is
       
    79 // resolved from iNetworkServiceRequest member.
       
    80 // ----------------------------------------------------------------------------
       
    81 //
       
    82 void CNWServiceProviderNameCommand::DoCancel()
       
    83     {
       
    84     NWLOGSTRING(KNWOBJECT,
       
    85         "NW: CNWServiceProviderNameCommand::DoCancel() Begin");
       
    86     
       
    87     iPhone.CancelAsyncRequest( EMobilePhoneGetServiceProviderName );
       
    88     
       
    89     NWLOGSTRING(KNWOBJECT,
       
    90         "NW: CNWServiceProviderNameCommand::DoCancel() End");
       
    91     }
       
    92 
       
    93 // ----------------------------------------------------------------------------
       
    94 // CNWServiceProviderNameCommand::IssueRequest
       
    95 // Starts the async. GetServiceProviderName query. 
       
    96 // The return of the query is returned the RunL function.
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 void CNWServiceProviderNameCommand::IssueRequest()
       
   100     {
       
   101     NWLOGSTRING(KNWOBJECT,
       
   102         "NW: CNWServiceProviderNameCommand::IssueRequest() Begin");
       
   103     
       
   104     if ( !IsActive() )
       
   105         {
       
   106         iPhone.GetServiceProviderName( iStatus, iServiceProviderNamePckg );
       
   107         NWLOGSTRING( KNWREQOUT, 
       
   108             "NW: CNWServiceProviderNameCommand::GetServiceProviderName: \
       
   109             Request issued");
       
   110         SetActive();
       
   111         }
       
   112     else 
       
   113         {
       
   114         NWLOGSTRING( KNWERROR, 
       
   115             "NW: CNWServiceProviderNameCommand::GetServiceProviderName: \
       
   116             Already active");
       
   117         }
       
   118     
       
   119     NWLOGSTRING(KNWOBJECT,
       
   120         "NW: CNWServiceProviderNameCommand::IssueRequest() End");
       
   121     }
       
   122 
       
   123 // ----------------------------------------------------------------------------
       
   124 // CNWServiceProviderNameCommand::UpdateNetworkInfo
       
   125 // Updates the Custom API type network info to NW type.
       
   126 // ----------------------------------------------------------------------------
       
   127 //
       
   128 void CNWServiceProviderNameCommand::UpdateNetworkInfo()
       
   129     {
       
   130     NWLOGSTRING( KNWOBJECT,
       
   131         "NW: CNWServiceProviderNameCommand::UpdateNetworkInfo() Begin" );
       
   132 
       
   133     iNWNetworkInfo.iSPName.Copy( iParamServiceProviderName.iSPName.Ptr(), 
       
   134         iParamServiceProviderName.iSPName.Length() );
       
   135     iNWNetworkInfo.iPLMNField.Copy( iParamServiceProviderName.iPLMNField.Ptr(),
       
   136         iParamServiceProviderName.iPLMNField.Length() );
       
   137     iNWNetworkInfo.iServiceProviderNameDisplayReq = 
       
   138         static_cast<TNWDisplayRequirementsFlags>( 
       
   139                 iParamServiceProviderName.iDisplayReq );
       
   140 
       
   141     NWLOGSTRING(KNWOBJECT,
       
   142         "NW: CNWServiceProviderNameCommand::UpdateNetworkInfo() End" );
       
   143     }
       
   144 
       
   145 // ----------------------------------------------------------------------------
       
   146 // CNWServiceProviderNameCommand::RunL
       
   147 // Receives the completion of the pending async. command
       
   148 // ----------------------------------------------------------------------------
       
   149 //
       
   150 
       
   151 void CNWServiceProviderNameCommand::RunL()
       
   152     {
       
   153     NWLOGSTRING2(KNWOBJECT,
       
   154         "NW: CNWServiceProviderNameCommand::RunL() Begin,\
       
   155         iStatus.Int() = %d", iStatus.Int() );
       
   156 
       
   157     if ( iStatus != KErrNone )  
       
   158         {
       
   159         NWLOGSTRING( KNWERROR,
       
   160             "NW: CNWServiceProviderNameCommand::RunL, Service Provider \
       
   161             Name not found!" );
       
   162         iOwner.SendErrorMessage( MNWMessageObserver::ENWGetServiceProviderName, iStatus.Int() );
       
   163         }
       
   164     else
       
   165         {
       
   166         UpdateNetworkInfo();
       
   167         if ( iAllowSending )
       
   168             {
       
   169             iOwner.SendMessage( MNWMessageObserver::ENWMessageServiceProviderNameChange );
       
   170             NWLOGSTRING2( KNWINT, 
       
   171                 "NW: CNWServiceProviderNameCommand::RunL: Service provider \
       
   172                 name:%S", &iNWNetworkInfo.iSPName ); 
       
   173             }
       
   174         }
       
   175     
       
   176     NWLOGSTRING(KNWOBJECT,
       
   177         "NW: CNWServiceProviderNameCommand::RunL() End" );
       
   178     }
       
   179     
       
   180 // ----------------------------------------------------------------------------
       
   181 // CNWServiceProviderNameCommand::AllowSendMessage
       
   182 // Denies or allows sending of ENWMessageServiceProviderNameChange. If Refresh
       
   183 // is ongoing this value is set EFalse. Default is ETrue. 
       
   184 // ----------------------------------------------------------------------------
       
   185 //
       
   186 void CNWServiceProviderNameCommand::SetAllowSendMessage( TBool aAllowSending )
       
   187     {
       
   188     NWLOGSTRING2( KNWOBJECT,
       
   189         "NW: CNWServiceProviderNameCommand::AllowSendMessage() Begin,\
       
   190         aAllowSending = %d", aAllowSending );
       
   191     
       
   192     iAllowSending = aAllowSending;
       
   193     
       
   194     NWLOGSTRING( KNWOBJECT,
       
   195         "NW: CNWServiceProviderNameCommand::AllowSendMessage() End" );
       
   196     }
       
   197 
       
   198 
       
   199 //  End of File