networkhandling/networkhandlingengine/NetworkHandlingSrc/CNWSubscriberIdCommand.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 *                CNWSubscriberIdCommand class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include    "CNWSubscriberIdCommand.h"
       
    23 #include    "CNWMessageHandler.h"
       
    24 #include    "NWLogger.h"
       
    25 
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ==============================
       
    28 
       
    29 // ----------------------------------------------------------------------------
       
    30 // CNWSubscriberIdCommand::CNWSubscriberIdCommand
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // ----------------------------------------------------------------------------
       
    34 //
       
    35 CNWSubscriberIdCommand::CNWSubscriberIdCommand(
       
    36             CNWMessageHandler& aOwner,
       
    37             RMobilePhone& aPhone,
       
    38             TNWInterInfo& aInterNetworkInfo )
       
    39             : CActive( EPriorityStandard ),
       
    40               iOwner( aOwner ),
       
    41               iPhone( aPhone ),
       
    42               iInterNetworkInfo( aInterNetworkInfo ),
       
    43               iSubscriberIdCounter( 0 )
       
    44     {
       
    45     NWLOGSTRING( KNWOBJECT,
       
    46         "NW: CNWSubscriberIdCommand::CNWSubscriberIdCommand() Begin" );
       
    47     
       
    48     CActiveScheduler::Add( this );
       
    49 
       
    50     NWLOGSTRING( KNWOBJECT,
       
    51         "NW: CNWSubscriberIdCommand::CNWSubscriberIdCommand() End" );
       
    52     }
       
    53 
       
    54     
       
    55 // Destructor
       
    56 CNWSubscriberIdCommand::~CNWSubscriberIdCommand()
       
    57     {
       
    58     NWLOGSTRING( KNWOBJECT,
       
    59         "NW: CNWSubscriberIdCommand::~CNWSubscriberIdCommand() Begin" );
       
    60     
       
    61     Cancel();
       
    62 
       
    63     NWLOGSTRING( KNWOBJECT, 
       
    64         "NW: CNWSubscriberIdCommand::~CNWSubscriberIdCommand() End");
       
    65     }
       
    66 
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // CNWSubscriberIdCommand::NewL
       
    70 // Two-phased constructor.
       
    71 // ----------------------------------------------------------------------------
       
    72 //
       
    73 CNWSubscriberIdCommand* CNWSubscriberIdCommand::NewL(
       
    74                                         CNWMessageHandler& aOwner,
       
    75                                         RMobilePhone& aPhone,
       
    76                                         TNWInterInfo& aInterNetworkInfo )
       
    77     {
       
    78     NWLOGSTRING( KNWOBJECT,
       
    79         "NW: CNWSubscriberIdCommand::NewL() Begin" );
       
    80     
       
    81     CNWSubscriberIdCommand* self = new( ELeave ) CNWSubscriberIdCommand(
       
    82                                         aOwner,
       
    83                                         aPhone,
       
    84                                         aInterNetworkInfo );
       
    85 
       
    86     NWLOGSTRING( KNWOBJECT,
       
    87         "NW: CNWSubscriberIdCommand::NewL() Begin" );
       
    88     return self;
       
    89     }
       
    90 
       
    91 // ----------------------------------------------------------------------------
       
    92 // CNWSubscriberIdCommand::DoCancel
       
    93 // Cancels the pending async. command.
       
    94 // ----------------------------------------------------------------------------
       
    95 //
       
    96 void CNWSubscriberIdCommand::DoCancel()
       
    97     {
       
    98     NWLOGSTRING( KNWOBJECT,
       
    99         "NW: CNWSubscriberIdCommand::DoCancel() Begin" );
       
   100     
       
   101     iPhone.CancelAsyncRequest( EMobilePhoneGetSubscriberId );
       
   102     
       
   103     NWLOGSTRING( KNWREQEND,
       
   104         "NW: CNWSubscriberIdCommand::DoCancel() End" );
       
   105     }
       
   106 
       
   107 // ----------------------------------------------------------------------------
       
   108 // CNWSubscriberIdCommand::RunL
       
   109 // Receives the completion of the pending async. command
       
   110 // ----------------------------------------------------------------------------
       
   111 //
       
   112 void CNWSubscriberIdCommand::RunL()
       
   113     {
       
   114     NWLOGSTRING2( KNWOBJECT,
       
   115         "NW: CNWSubscriberIdCommand::RunL() Begin, iStatus.Int() = \
       
   116         %d", iStatus.Int() );
       
   117     
       
   118     if ( iStatus != KErrNone )
       
   119         {
       
   120         NWLOGSTRING2( KNWERROR,
       
   121             "NW: CNWSubscriberIdCommand::RunL, Unknown error situation, \
       
   122             iStatus = %d", iStatus.Int() );
       
   123             // Subscriber Id is NOT necessary available when system is 
       
   124             // registered to network (= SIM State OK). (This might happen 
       
   125             // when PIN query is ON).Therefore we try to get subscriber 
       
   126             // id several times.
       
   127         if ( iSubscriberIdCounter < KMaxSubscriberIdRequests )
       
   128             {
       
   129             NWLOGSTRING2( KNWERROR, 
       
   130                 "NW:CNWMessageHandler::SendMessage: New subscriber id\
       
   131                 request. counter = %d", iSubscriberIdCounter );
       
   132             IssueRequest();
       
   133             iSubscriberIdCounter++;
       
   134             return;
       
   135             }
       
   136         }
       
   137     else
       
   138         {
       
   139         iOwner.HandleSubscriberIdChange();
       
   140         }
       
   141     
       
   142     NWLOGSTRING( KNWOBJECT,
       
   143         "NW: CNWSubscriberIdCommand::RunL() End" );
       
   144     }
       
   145 
       
   146 // ----------------------------------------------------------------------------
       
   147 // CNWSubscriberIdCommand::IssueRequest
       
   148 // Starts the async. subscriber ID query. The return of the query is returned 
       
   149 // the RunL function.
       
   150 // ----------------------------------------------------------------------------
       
   151 //
       
   152 void CNWSubscriberIdCommand::IssueRequest()
       
   153     {
       
   154     NWLOGSTRING( KNWOBJECT,
       
   155         "NW: CNWSubscriberIdCommand::IssueRequest() Begin" );
       
   156     
       
   157     if ( !IsActive() )
       
   158         {
       
   159         NWLOGSTRING( KNWREQOUT,
       
   160             "NW: CNWSubscriberIdCommand::GetSubscriberId: Request \
       
   161             RMmCustomAPI::GetSubscriberId" );
       
   162         iPhone.GetSubscriberId( iStatus, iInterNetworkInfo.iSubscriberId );
       
   163         SetActive();
       
   164         }
       
   165     else 
       
   166         {
       
   167         NWLOGSTRING( KNWERROR, 
       
   168             "NW: CNWSubscriberIdCommand::GetSubscriberId: Already active" );
       
   169         }
       
   170     
       
   171     NWLOGSTRING( KNWOBJECT,
       
   172         "NW: CNWSubscriberIdCommand::IssueRequest() End" );
       
   173     }
       
   174 
       
   175 
       
   176 //  End of File