phoneengine/phonemodel/src/cpeparsersimcontrolhandler.cpp
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2006 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:  implementation of CPEParserSimControlHandler class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  1.0 INCLUDE FILES
       
    20 #include "cpeparsersimcontrolhandler.h"
       
    21 #include "mpephonemodelinternal.h"
       
    22 #include <mpecontacthandling.h>
       
    23 #include <mpedatastore.h>
       
    24 #include <pepanic.pan>
       
    25 #include <secui.h>
       
    26 #include <secuimanualsecuritysettings.h>
       
    27 #include <talogger.h>
       
    28 
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 //
       
    35 CPEParserSimControlHandler::CPEParserSimControlHandler( 
       
    36         MPEPhoneModelInternal& aModel,        
       
    37         MPEContactHandling& aContactHandling
       
    38         ) : iModel( aModel ),
       
    39             iContactHandling( aContactHandling )
       
    40     {
       
    41     iSupplementaryServicesCommandInfo.action = EPESSActionUnspecified;
       
    42     iSupplementaryServicesCommandInfo.type = EPESSTypeUnspecified;
       
    43     iSupplementaryServicesCommandInfo.group = RMobilePhone::EServiceUnspecified;
       
    44     TEFLOGSTRING( KTAOBJECT,
       
    45         "PE CPEParserSimControlHandler::CPEParserSimControlHandler: complete");
       
    46     }
       
    47 
       
    48 // Destructor
       
    49 CPEParserSimControlHandler::~CPEParserSimControlHandler()
       
    50     {
       
    51     if( iSecurityModel != NULL )
       
    52         {
       
    53         iSecurityModel->CancelChangePin();
       
    54         iSecurityModel->CancelUnblockPin();
       
    55         delete iSecurityModel;
       
    56         TSecUi::UnInitializeLib();  
       
    57         }
       
    58     TEFLOGSTRING( KTAOBJECT,
       
    59         "PE CPEParserSimControlHandler::~CPEParserSimControlHandler: complete");
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CPEParserSimControlHandler::NewL
       
    64 // Two-phased constructor.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CPEParserSimControlHandler* CPEParserSimControlHandler::NewL(
       
    68         MPEPhoneModelInternal& aModel,      
       
    69         MPEContactHandling& aContactHandling )
       
    70     {
       
    71     CPEParserSimControlHandler* self = new ( ELeave ) CPEParserSimControlHandler( 
       
    72         aModel, 
       
    73         aContactHandling );
       
    74 
       
    75     TEFLOGSTRING( KTAOBJECT,
       
    76         "PE CPEParserSimControlHandler::NewL complete" );
       
    77 
       
    78     return self;
       
    79     } //NewL
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CPEExternalDataHandler::ProcessChangePin
       
    83 // Change pin code.
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CPEParserSimControlHandler::ProcessChangePinL( 
       
    87         TPinCode aType,         // It is type of pin.
       
    88         const TDesC& aOldPin,   // It is old pin.
       
    89         const TDesC& aNewPin,   // It is new pin.
       
    90         const TDesC& aVerifyNew )  // It is new pin(confirmation).
       
    91     {
       
    92     TEFLOGSTRING( KTAINT,
       
    93         "PE CPEParserSimControlHandler::ProcessChangePinL ");
       
    94     iModel.SendMessage( MEngineMonitor::EPEMessageIssuingSSRequest );
       
    95     CManualSecuritySettings::TPin pin= CManualSecuritySettings::EPin1;
       
    96 
       
    97     switch ( aType )
       
    98         {
       
    99         case EPinCode:
       
   100             pin = CManualSecuritySettings::EPin1;
       
   101             break;
       
   102         case EPin2Code:
       
   103             pin = CManualSecuritySettings::EPin2;
       
   104             break;
       
   105         default:
       
   106             // Case not handled, panic.
       
   107             User::Panic( KPEPhoneEnginePanic, EPEPanicStupidUser );
       
   108             break;
       
   109         }
       
   110         
       
   111     if( iSecurityModel == NULL )
       
   112         {
       
   113         TSecUi::InitializeLibL();
       
   114         iSecurityModel = CManualSecuritySettings::NewL();
       
   115         TEFLOGSTRING( KTAOBJECT,
       
   116             "PE CPEParserSimControlHandler::ConstructL" );
       
   117         }
       
   118         
       
   119     if( iSecurityModel->ChangePinL( pin, aOldPin, aNewPin, aVerifyNew ) )
       
   120         {
       
   121         iSupplementaryServicesCommandInfo.action = EPEPasswordOperation;
       
   122         iSupplementaryServicesCommandInfo.type = EPEPin;
       
   123         iSupplementaryServicesCommandInfo.group = RMobilePhone::EServiceUnspecified;
       
   124         iModel.DataStore()->SetSSCommandInfo( iSupplementaryServicesCommandInfo );
       
   125         TEFLOGSTRING( KTAINT,
       
   126             "PE CPEParserSimControlHandler::ProcessChangePinL: iSecurityModel->ChangePinL called ");
       
   127         }
       
   128     iModel.SendMessage( MEngineMonitor::EPEMessageIssuedSSRequest );
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CPEGsmExternalDataHandler::ProcessUnblockPin
       
   133 // Unblock pin code.
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CPEParserSimControlHandler::ProcessUnblockPinL( 
       
   137         TPinCode aType,         // It is type of pin to unblock.
       
   138         const TDesC& aPuk,      // It is unblocking code.
       
   139         const TDesC& aNewPin,   // It is new pin.
       
   140         const TDesC& aVerifyNew ) // It is new pin.
       
   141     {
       
   142        
       
   143     iModel.SendMessage( MEngineMonitor::EPEMessageIssuingSSRequest );
       
   144     CManualSecuritySettings::TPin pin= CManualSecuritySettings::EPin1;
       
   145 
       
   146     switch ( aType )
       
   147         {
       
   148         case EPinCode:
       
   149             pin = CManualSecuritySettings::EPin1;
       
   150             break;
       
   151         case EPin2Code:
       
   152             pin = CManualSecuritySettings::EPin2;
       
   153             break;
       
   154         default:
       
   155             // Case not handled, panic.
       
   156             User::Panic( KPEPhoneEnginePanic, EPEPanicStupidUser );
       
   157             break;
       
   158         }
       
   159 
       
   160     if( iSecurityModel == NULL )
       
   161         {
       
   162         TSecUi::InitializeLibL();
       
   163         iSecurityModel = CManualSecuritySettings::NewL();
       
   164         TEFLOGSTRING( KTAOBJECT,
       
   165             "PE CPEParserSimControlHandler::ConstructL" );
       
   166         }
       
   167         
       
   168     if( iSecurityModel->UnblockPinL( pin, aPuk, aNewPin, aVerifyNew ) )
       
   169         {
       
   170         iSupplementaryServicesCommandInfo.action = EPEPasswordOperation;
       
   171         iSupplementaryServicesCommandInfo.type = EPEUnblockPin;
       
   172         iSupplementaryServicesCommandInfo.group = RMobilePhone::EServiceUnspecified;
       
   173         iModel.DataStore()->SetSSCommandInfo( iSupplementaryServicesCommandInfo );
       
   174         TEFLOGSTRING( KTAINT,
       
   175             "PE CPEParserSimControlHandler::ProcessUnblockPinL: iSecurityModel->UnblockPinL called ");
       
   176         }
       
   177     iModel.SendMessage( MEngineMonitor::EPEMessageIssuedSSRequest );        
       
   178     }
       
   179 
       
   180 // End of File