securitydialogs/secuidialognotifiersrv/src/secuidialogoperbasicpinquery.cpp
author hgs
Tue, 28 Sep 2010 14:03:54 +0300
changeset 59 881d92421467
child 63 989397f9511c
permissions -rw-r--r--
201037_03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59
881d92421467 201037_03
hgs
parents:
diff changeset
     1
/*
881d92421467 201037_03
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
881d92421467 201037_03
hgs
parents:
diff changeset
     3
* All rights reserved.
881d92421467 201037_03
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
881d92421467 201037_03
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
881d92421467 201037_03
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
881d92421467 201037_03
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
881d92421467 201037_03
hgs
parents:
diff changeset
     8
*
881d92421467 201037_03
hgs
parents:
diff changeset
     9
* Initial Contributors:
881d92421467 201037_03
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
881d92421467 201037_03
hgs
parents:
diff changeset
    11
*
881d92421467 201037_03
hgs
parents:
diff changeset
    12
* Contributors:
881d92421467 201037_03
hgs
parents:
diff changeset
    13
*
881d92421467 201037_03
hgs
parents:
diff changeset
    14
* Description:  Basic PIN query operation in secui dialog
881d92421467 201037_03
hgs
parents:
diff changeset
    15
*
881d92421467 201037_03
hgs
parents:
diff changeset
    16
*/
881d92421467 201037_03
hgs
parents:
diff changeset
    17
881d92421467 201037_03
hgs
parents:
diff changeset
    18
#include "secuidialogoperbasicpinquery.h" // CBasicPinQueryOperation
881d92421467 201037_03
hgs
parents:
diff changeset
    19
#include "secuidialogoperationobserver.h" // MSecuiDialogOperationObserver
881d92421467 201037_03
hgs
parents:
diff changeset
    20
#include <hb/hbcore/hbtextresolversymbian.h> // HbTextResolverSymbian
881d92421467 201037_03
hgs
parents:
diff changeset
    21
#include "secuidialogstrace.h"       // TRACE macro
881d92421467 201037_03
hgs
parents:
diff changeset
    22
881d92421467 201037_03
hgs
parents:
diff changeset
    23
// TODO: fix this
881d92421467 201037_03
hgs
parents:
diff changeset
    24
#include "../../../securitydialogs/SecUi/Inc/SecQueryUi.h"  // CSecQueryUi
881d92421467 201037_03
hgs
parents:
diff changeset
    25
881d92421467 201037_03
hgs
parents:
diff changeset
    26
#include <secui.h>
881d92421467 201037_03
hgs
parents:
diff changeset
    27
#include <secuisecurityhandler.h>
881d92421467 201037_03
hgs
parents:
diff changeset
    28
#include <gsmerror.h>
881d92421467 201037_03
hgs
parents:
diff changeset
    29
#include <etelmm.h>
881d92421467 201037_03
hgs
parents:
diff changeset
    30
#include <rmmcustomapi.h>
881d92421467 201037_03
hgs
parents:
diff changeset
    31
#include <startupdomainpskeys.h>
881d92421467 201037_03
hgs
parents:
diff changeset
    32
#include <featmgr.h>
881d92421467 201037_03
hgs
parents:
diff changeset
    33
881d92421467 201037_03
hgs
parents:
diff changeset
    34
const TInt KPhoneIndex( 0 );
881d92421467 201037_03
hgs
parents:
diff changeset
    35
const TInt KTriesToConnectServer( 2 );
881d92421467 201037_03
hgs
parents:
diff changeset
    36
const TInt KTimeBeforeRetryingServerConnection( 50000 );
881d92421467 201037_03
hgs
parents:
diff changeset
    37
881d92421467 201037_03
hgs
parents:
diff changeset
    38
_LIT( KMmTsyModuleName, "PhoneTsy"); 
881d92421467 201037_03
hgs
parents:
diff changeset
    39
881d92421467 201037_03
hgs
parents:
diff changeset
    40
// Descriptors for different password queries
881d92421467 201037_03
hgs
parents:
diff changeset
    41
_LIT( KBasicPinQueryKeyStorePassphrase, "Key store passphrase" );
881d92421467 201037_03
hgs
parents:
diff changeset
    42
_LIT( KBasicPinQueryNewKeyStorePassphrase, "New key store passphrase" );
881d92421467 201037_03
hgs
parents:
diff changeset
    43
_LIT( KBasicPinQueryImportedKeyFilePassphrase, "Passphrase of the imported key file" );
881d92421467 201037_03
hgs
parents:
diff changeset
    44
_LIT( KBasicPinQueryExportedKeyFilePassphrase, "Passphrase of the exported key file" );
881d92421467 201037_03
hgs
parents:
diff changeset
    45
_LIT( KBasicPinQueryPKCS12, "PKCS12");
881d92421467 201037_03
hgs
parents:
diff changeset
    46
881d92421467 201037_03
hgs
parents:
diff changeset
    47
881d92421467 201037_03
hgs
parents:
diff changeset
    48
881d92421467 201037_03
hgs
parents:
diff changeset
    49
881d92421467 201037_03
hgs
parents:
diff changeset
    50
// ======== MEMBER FUNCTIONS ========
881d92421467 201037_03
hgs
parents:
diff changeset
    51
881d92421467 201037_03
hgs
parents:
diff changeset
    52
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    53
// CBasicPinQueryOperation::NewL()
881d92421467 201037_03
hgs
parents:
diff changeset
    54
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    55
//
881d92421467 201037_03
hgs
parents:
diff changeset
    56
CBasicPinQueryOperation* CBasicPinQueryOperation::NewL(
881d92421467 201037_03
hgs
parents:
diff changeset
    57
        MSecuiDialogOperationObserver& aObserver, const RMessage2& aMessage,
881d92421467 201037_03
hgs
parents:
diff changeset
    58
        TInt aReplySlot )
881d92421467 201037_03
hgs
parents:
diff changeset
    59
    {
881d92421467 201037_03
hgs
parents:
diff changeset
    60
    TRACE( "CBasicPinQueryOperation::NewL, aMessage 0x%08x", aMessage.Handle() );
881d92421467 201037_03
hgs
parents:
diff changeset
    61
    TRACE( "CBasicPinQueryOperation::NewL, aMessage.Function = 0x%08x", aMessage.Function() );
881d92421467 201037_03
hgs
parents:
diff changeset
    62
    return new( ELeave ) CBasicPinQueryOperation( aObserver, aMessage, aReplySlot );
881d92421467 201037_03
hgs
parents:
diff changeset
    63
    }
881d92421467 201037_03
hgs
parents:
diff changeset
    64
881d92421467 201037_03
hgs
parents:
diff changeset
    65
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    66
// CBasicPinQueryOperation::~CBasicPinQueryOperation()
881d92421467 201037_03
hgs
parents:
diff changeset
    67
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    68
//
881d92421467 201037_03
hgs
parents:
diff changeset
    69
CBasicPinQueryOperation::~CBasicPinQueryOperation()
881d92421467 201037_03
hgs
parents:
diff changeset
    70
    {
881d92421467 201037_03
hgs
parents:
diff changeset
    71
    TRACE( "CBasicPinQueryOperation::~CBasicPinQueryOperation" );
881d92421467 201037_03
hgs
parents:
diff changeset
    72
    Cancel();
881d92421467 201037_03
hgs
parents:
diff changeset
    73
    iPinInput = NULL;   // not owned
881d92421467 201037_03
hgs
parents:
diff changeset
    74
    }
881d92421467 201037_03
hgs
parents:
diff changeset
    75
881d92421467 201037_03
hgs
parents:
diff changeset
    76
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    77
// CBasicPinQueryOperation::StartL()
881d92421467 201037_03
hgs
parents:
diff changeset
    78
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    79
//
881d92421467 201037_03
hgs
parents:
diff changeset
    80
void CBasicPinQueryOperation::StartL( const TDesC8& aBuffer )
881d92421467 201037_03
hgs
parents:
diff changeset
    81
    {
881d92421467 201037_03
hgs
parents:
diff changeset
    82
    TRACE( "CBasicPinQueryOperation::StartL" );
881d92421467 201037_03
hgs
parents:
diff changeset
    83
    iPinInput = reinterpret_cast< const TPINInput* >( aBuffer.Ptr() );
881d92421467 201037_03
hgs
parents:
diff changeset
    84
    ASSERT( iPinInput != NULL );
881d92421467 201037_03
hgs
parents:
diff changeset
    85
881d92421467 201037_03
hgs
parents:
diff changeset
    86
    iStatus = KRequestPending;
881d92421467 201037_03
hgs
parents:
diff changeset
    87
    TRequestStatus* status = &iStatus;
881d92421467 201037_03
hgs
parents:
diff changeset
    88
    User::RequestComplete( status, KErrNone );
881d92421467 201037_03
hgs
parents:
diff changeset
    89
    SetActive();
881d92421467 201037_03
hgs
parents:
diff changeset
    90
    }
881d92421467 201037_03
hgs
parents:
diff changeset
    91
881d92421467 201037_03
hgs
parents:
diff changeset
    92
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    93
// CBasicPinQueryOperation::CancelOperation()
881d92421467 201037_03
hgs
parents:
diff changeset
    94
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
    95
//
881d92421467 201037_03
hgs
parents:
diff changeset
    96
void CBasicPinQueryOperation::CancelOperation()
881d92421467 201037_03
hgs
parents:
diff changeset
    97
    {
881d92421467 201037_03
hgs
parents:
diff changeset
    98
    TRACE( "CBasicPinQueryOperation::CancelOperation" );
881d92421467 201037_03
hgs
parents:
diff changeset
    99
    // nothing to do
881d92421467 201037_03
hgs
parents:
diff changeset
   100
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   101
881d92421467 201037_03
hgs
parents:
diff changeset
   102
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   103
// CBasicPinQueryOperation::RunL()
881d92421467 201037_03
hgs
parents:
diff changeset
   104
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   105
//
881d92421467 201037_03
hgs
parents:
diff changeset
   106
void CBasicPinQueryOperation::RunL()
881d92421467 201037_03
hgs
parents:
diff changeset
   107
    {
881d92421467 201037_03
hgs
parents:
diff changeset
   108
    TRACE( "CBasicPinQueryOperation::RunL, iStatus.Int()=%d", iStatus.Int() );
881d92421467 201037_03
hgs
parents:
diff changeset
   109
    User::LeaveIfError( iStatus.Int() );
881d92421467 201037_03
hgs
parents:
diff changeset
   110
881d92421467 201037_03
hgs
parents:
diff changeset
   111
    TBool isRetry = ( iPinInput->iOperation & EPINValueIncorrect );
881d92421467 201037_03
hgs
parents:
diff changeset
   112
    if( isRetry )
881d92421467 201037_03
hgs
parents:
diff changeset
   113
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   114
        // Show "Invalid PIN code" error note, as previous attempt was failed.
881d92421467 201037_03
hgs
parents:
diff changeset
   115
        // TODO: localized UI string needed
881d92421467 201037_03
hgs
parents:
diff changeset
   116
        _LIT( KInvalidPinCode, "Invalid PIN code" );
881d92421467 201037_03
hgs
parents:
diff changeset
   117
        ShowWarningNoteL( KInvalidPinCode );
881d92421467 201037_03
hgs
parents:
diff changeset
   118
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   119
TRACE( "CBasicPinQueryOperation::RunL, iPinInput->iOperation=%d", iPinInput->iOperation );
881d92421467 201037_03
hgs
parents:
diff changeset
   120
881d92421467 201037_03
hgs
parents:
diff changeset
   121
    HBufC* caption = NULL;
881d92421467 201037_03
hgs
parents:
diff changeset
   122
    if( iPinInput->iPIN.iPINLabel == KBasicPinQueryKeyStorePassphrase )
881d92421467 201037_03
hgs
parents:
diff changeset
   123
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   124
        	TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryKeyStorePassphrase =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   125
881d92421467 201037_03
hgs
parents:
diff changeset
   126
        // TODO: localized UI string needed
881d92421467 201037_03
hgs
parents:
diff changeset
   127
        _LIT( KText, "Keystore password:" );
881d92421467 201037_03
hgs
parents:
diff changeset
   128
        caption = KText().AllocLC();
881d92421467 201037_03
hgs
parents:
diff changeset
   129
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   130
    else if( iPinInput->iPIN.iPINLabel == KBasicPinQueryNewKeyStorePassphrase )
881d92421467 201037_03
hgs
parents:
diff changeset
   131
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   132
        	TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryNewKeyStorePassphrase =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   133
881d92421467 201037_03
hgs
parents:
diff changeset
   134
        // "Keystore password must be created for using private keys."
881d92421467 201037_03
hgs
parents:
diff changeset
   135
        // SecUi creates two input fields when caption contains two labels
881d92421467 201037_03
hgs
parents:
diff changeset
   136
        // separated with a vertical bar. SecUi verifies that user types the
881d92421467 201037_03
hgs
parents:
diff changeset
   137
        // same passphrase in both fields.
881d92421467 201037_03
hgs
parents:
diff changeset
   138
        // TODO: localized UI strings needed
881d92421467 201037_03
hgs
parents:
diff changeset
   139
        _LIT( KText, "Create keystore password:|Verify:" );
881d92421467 201037_03
hgs
parents:
diff changeset
   140
        caption = KText().AllocLC();
881d92421467 201037_03
hgs
parents:
diff changeset
   141
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   142
    else if( iPinInput->iPIN.iPINLabel == KBasicPinQueryImportedKeyFilePassphrase )
881d92421467 201037_03
hgs
parents:
diff changeset
   143
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   144
        	TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryImportedKeyFilePassphrase =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   145
881d92421467 201037_03
hgs
parents:
diff changeset
   146
        // "Enter code for imported key:"
881d92421467 201037_03
hgs
parents:
diff changeset
   147
        // TODO: localized UI strings needed
881d92421467 201037_03
hgs
parents:
diff changeset
   148
        _LIT( KText, "Enter code for imported key:|Verify:" );
881d92421467 201037_03
hgs
parents:
diff changeset
   149
        caption = KText().AllocLC();
881d92421467 201037_03
hgs
parents:
diff changeset
   150
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   151
    else if( iPinInput->iPIN.iPINLabel == KBasicPinQueryExportedKeyFilePassphrase )
881d92421467 201037_03
hgs
parents:
diff changeset
   152
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   153
        	TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryExportedKeyFilePassphrase =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   154
881d92421467 201037_03
hgs
parents:
diff changeset
   155
        // "Enter new code for exported key:"
881d92421467 201037_03
hgs
parents:
diff changeset
   156
        // TODO: localized UI strings needed
881d92421467 201037_03
hgs
parents:
diff changeset
   157
        _LIT( KText, "Enter new code for exported key:|Verify:" );
881d92421467 201037_03
hgs
parents:
diff changeset
   158
        caption = KText().AllocLC();
881d92421467 201037_03
hgs
parents:
diff changeset
   159
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   160
    else if( iPinInput->iPIN.iPINLabel == KBasicPinQueryPKCS12 )
881d92421467 201037_03
hgs
parents:
diff changeset
   161
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   162
        	TRACE( "CBasicPinQueryOperation::RunL, KBasicPinQueryPKCS12 =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   163
881d92421467 201037_03
hgs
parents:
diff changeset
   164
        // "Password for %U:", PKCS#12 password query prompt
881d92421467 201037_03
hgs
parents:
diff changeset
   165
        // TODO: localized UI string needed
881d92421467 201037_03
hgs
parents:
diff changeset
   166
        _LIT( KText, "Password for PKCS#12 file:" );
881d92421467 201037_03
hgs
parents:
diff changeset
   167
        caption = KText().AllocLC();
881d92421467 201037_03
hgs
parents:
diff changeset
   168
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   169
    else
881d92421467 201037_03
hgs
parents:
diff changeset
   170
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   171
        	TRACE( "CBasicPinQueryOperation::RunL, else =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   172
881d92421467 201037_03
hgs
parents:
diff changeset
   173
        // "Enter code for %0U in %1U"
881d92421467 201037_03
hgs
parents:
diff changeset
   174
        // Data query for PIN request in keystore where %0U is the PIN's name %1U is the keystore's name.
881d92421467 201037_03
hgs
parents:
diff changeset
   175
        // TODO: EEnterPinNR
881d92421467 201037_03
hgs
parents:
diff changeset
   176
        _LIT( KText, "86" );
881d92421467 201037_03
hgs
parents:
diff changeset
   177
        caption = KText().AllocLC();
881d92421467 201037_03
hgs
parents:
diff changeset
   178
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   179
    iPinValue.Copy(_L("0"));
881d92421467 201037_03
hgs
parents:
diff changeset
   180
		TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   181
881d92421467 201037_03
hgs
parents:
diff changeset
   182
    TInt resultVerif = KErrNone;
881d92421467 201037_03
hgs
parents:
diff changeset
   183
		TRACE( "CBasicPinQueryOperation::RunL, 1 =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   184
881d92421467 201037_03
hgs
parents:
diff changeset
   185
            {
881d92421467 201037_03
hgs
parents:
diff changeset
   186
		   					RMobilePhone	iPhone;
881d92421467 201037_03
hgs
parents:
diff changeset
   187
881d92421467 201037_03
hgs
parents:
diff changeset
   188
								TInt err( KErrGeneral);
881d92421467 201037_03
hgs
parents:
diff changeset
   189
								TRACE( "CBasicPinQueryOperation::RunL, ESecurityQueryActive =%d", ESecurityQueryActive );
881d92421467 201037_03
hgs
parents:
diff changeset
   190
								err = RProperty::Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryActive);
881d92421467 201037_03
hgs
parents:
diff changeset
   191
								TRACE( "CBasicPinQueryOperation::RunL, err =%d", err );
881d92421467 201037_03
hgs
parents:
diff changeset
   192
								
881d92421467 201037_03
hgs
parents:
diff changeset
   193
								TInt thisTry( 0);
881d92421467 201037_03
hgs
parents:
diff changeset
   194
								RTelServer iTelServer;
881d92421467 201037_03
hgs
parents:
diff changeset
   195
								RMmCustomAPI iCustomPhone;
881d92421467 201037_03
hgs
parents:
diff changeset
   196
								while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer )
881d92421467 201037_03
hgs
parents:
diff changeset
   197
								{
881d92421467 201037_03
hgs
parents:
diff changeset
   198
								User::After( KTimeBeforeRetryingServerConnection );
881d92421467 201037_03
hgs
parents:
diff changeset
   199
								}
881d92421467 201037_03
hgs
parents:
diff changeset
   200
								err = iTelServer.LoadPhoneModule( KMmTsyModuleName );
881d92421467 201037_03
hgs
parents:
diff changeset
   201
								RTelServer::TPhoneInfo PhoneInfo;
881d92421467 201037_03
hgs
parents:
diff changeset
   202
								err = iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ;
881d92421467 201037_03
hgs
parents:
diff changeset
   203
								err = iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ;
881d92421467 201037_03
hgs
parents:
diff changeset
   204
								err = iPhone.Open( iTelServer, PhoneInfo.iName ) ;
881d92421467 201037_03
hgs
parents:
diff changeset
   205
								err = iCustomPhone.Open( iPhone ) ;
881d92421467 201037_03
hgs
parents:
diff changeset
   206
								TRACE( "CBasicPinQueryOperation::RunL, err =%d", err );
881d92421467 201037_03
hgs
parents:
diff changeset
   207
						    CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone);
881d92421467 201037_03
hgs
parents:
diff changeset
   208
						    CleanupStack::PushL(handler);
881d92421467 201037_03
hgs
parents:
diff changeset
   209
						    // TSecUi::InitializeLibL(); 
881d92421467 201037_03
hgs
parents:
diff changeset
   210
								TRACE( "CBasicPinQueryOperation::RunL, TMobilePhoneSecurityEvent 1 =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   211
								RMobilePhone::TMobilePhoneSecurityEvent iEvent;
881d92421467 201037_03
hgs
parents:
diff changeset
   212
						    TInt lEvent = iPinInput->iOperation;
881d92421467 201037_03
hgs
parents:
diff changeset
   213
						    TRACE( "CBasicPinQueryOperation::RunL, lEvent =%d", lEvent );
881d92421467 201037_03
hgs
parents:
diff changeset
   214
								if( lEvent >= 0x1000 )	// flag for iStartUp
881d92421467 201037_03
hgs
parents:
diff changeset
   215
									{
881d92421467 201037_03
hgs
parents:
diff changeset
   216
									lEvent-=0x1000;
881d92421467 201037_03
hgs
parents:
diff changeset
   217
									}
881d92421467 201037_03
hgs
parents:
diff changeset
   218
						    iEvent = static_cast<RMobilePhone::TMobilePhoneSecurityEvent>(lEvent);
881d92421467 201037_03
hgs
parents:
diff changeset
   219
						    TRACE( "CBasicPinQueryOperation::RunL, iEvent =%d", iEvent );
881d92421467 201037_03
hgs
parents:
diff changeset
   220
						    TRACE( "CBasicPinQueryOperation::RunL, TBool iStartUp =%d", iStartUp );
881d92421467 201037_03
hgs
parents:
diff changeset
   221
						    TRAPD( resultHandler, handler->HandleEventL( iEvent, iStartUp, resultVerif ) );
881d92421467 201037_03
hgs
parents:
diff changeset
   222
						    TRACE( "CBasicPinQueryOperation::RunL, resultHandler =%d", resultHandler );
881d92421467 201037_03
hgs
parents:
diff changeset
   223
						    TRACE( "CBasicPinQueryOperation::RunL, resultVerif =%d", resultVerif );
881d92421467 201037_03
hgs
parents:
diff changeset
   224
   
881d92421467 201037_03
hgs
parents:
diff changeset
   225
						    // if something went wrong cancel the code request
881d92421467 201037_03
hgs
parents:
diff changeset
   226
						    if (resultHandler)
881d92421467 201037_03
hgs
parents:
diff changeset
   227
						        {
881d92421467 201037_03
hgs
parents:
diff changeset
   228
						        if(resultVerif==KErrNone)	// if the process failed, then the result shoud also indicate the failure (unless it does it already)
881d92421467 201037_03
hgs
parents:
diff changeset
   229
						        	resultVerif = resultHandler;
881d92421467 201037_03
hgs
parents:
diff changeset
   230
						    TRACE( "CBasicPinQueryOperation::RunL, iEvent =%d", iEvent );
881d92421467 201037_03
hgs
parents:
diff changeset
   231
								TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
881d92421467 201037_03
hgs
parents:
diff changeset
   232
								TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
881d92421467 201037_03
hgs
parents:
diff changeset
   233
						        switch (iEvent)
881d92421467 201037_03
hgs
parents:
diff changeset
   234
						            {
881d92421467 201037_03
hgs
parents:
diff changeset
   235
						            case RMobilePhone::EUniversalPinRequired:
881d92421467 201037_03
hgs
parents:
diff changeset
   236
						                if(wcdmaSupported || upinSupported)
881d92421467 201037_03
hgs
parents:
diff changeset
   237
						                  {
881d92421467 201037_03
hgs
parents:
diff changeset
   238
						                   iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPin);
881d92421467 201037_03
hgs
parents:
diff changeset
   239
						                  }
881d92421467 201037_03
hgs
parents:
diff changeset
   240
						                break;
881d92421467 201037_03
hgs
parents:
diff changeset
   241
						            case RMobilePhone::EUniversalPukRequired:
881d92421467 201037_03
hgs
parents:
diff changeset
   242
						                if(wcdmaSupported || upinSupported)
881d92421467 201037_03
hgs
parents:
diff changeset
   243
						                  {
881d92421467 201037_03
hgs
parents:
diff changeset
   244
						                   iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPuk);
881d92421467 201037_03
hgs
parents:
diff changeset
   245
						                  }
881d92421467 201037_03
hgs
parents:
diff changeset
   246
						                break;
881d92421467 201037_03
hgs
parents:
diff changeset
   247
									case RMobilePhone::EPin1Required:
881d92421467 201037_03
hgs
parents:
diff changeset
   248
						                iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1);
881d92421467 201037_03
hgs
parents:
diff changeset
   249
						                break;
881d92421467 201037_03
hgs
parents:
diff changeset
   250
									case RMobilePhone::EPuk1Required:
881d92421467 201037_03
hgs
parents:
diff changeset
   251
						                iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk1);
881d92421467 201037_03
hgs
parents:
diff changeset
   252
						                break;
881d92421467 201037_03
hgs
parents:
diff changeset
   253
									case RMobilePhone::EPin2Required:
881d92421467 201037_03
hgs
parents:
diff changeset
   254
						                iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2);
881d92421467 201037_03
hgs
parents:
diff changeset
   255
						                break;
881d92421467 201037_03
hgs
parents:
diff changeset
   256
									case RMobilePhone::EPuk2Required:
881d92421467 201037_03
hgs
parents:
diff changeset
   257
						                iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePuk2);
881d92421467 201037_03
hgs
parents:
diff changeset
   258
						                break;
881d92421467 201037_03
hgs
parents:
diff changeset
   259
									case RMobilePhone::EPhonePasswordRequired:
881d92421467 201037_03
hgs
parents:
diff changeset
   260
						                iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword);
881d92421467 201037_03
hgs
parents:
diff changeset
   261
						                break;
881d92421467 201037_03
hgs
parents:
diff changeset
   262
						            default:
881d92421467 201037_03
hgs
parents:
diff changeset
   263
         								    TRACE( "CBasicPinQueryOperation::RunL, default iEvent =%d", iEvent );
881d92421467 201037_03
hgs
parents:
diff changeset
   264
						                break;
881d92421467 201037_03
hgs
parents:
diff changeset
   265
						            }
881d92421467 201037_03
hgs
parents:
diff changeset
   266
						        }
881d92421467 201037_03
hgs
parents:
diff changeset
   267
						
881d92421467 201037_03
hgs
parents:
diff changeset
   268
						    // uninitialize security ui
881d92421467 201037_03
hgs
parents:
diff changeset
   269
						    TRACE( "CBasicPinQueryOperation::RunL, PopAndDestroy(handler) =%d", 0 );
881d92421467 201037_03
hgs
parents:
diff changeset
   270
						    CleanupStack::PopAndDestroy(handler); // handler
881d92421467 201037_03
hgs
parents:
diff changeset
   271
								TRACE( "CBasicPinQueryOperation::RunL, UnInitializeLib =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   272
						    TSecUi::UnInitializeLib();  
881d92421467 201037_03
hgs
parents:
diff changeset
   273
								TRACE( "CBasicPinQueryOperation::RunL, ESecurityQueryNotActive =%d", ESecurityQueryNotActive );
881d92421467 201037_03
hgs
parents:
diff changeset
   274
								err = RProperty::Set(KPSUidStartup, KStartupSecurityCodeQueryStatus, ESecurityQueryNotActive);
881d92421467 201037_03
hgs
parents:
diff changeset
   275
								TRACE( "CBasicPinQueryOperation::RunL, err =%d", err );
881d92421467 201037_03
hgs
parents:
diff changeset
   276
						    //close ETel connection
881d92421467 201037_03
hgs
parents:
diff changeset
   277
						    if (iTelServer.Handle())
881d92421467 201037_03
hgs
parents:
diff changeset
   278
						        {
881d92421467 201037_03
hgs
parents:
diff changeset
   279
						        TRACE( "CBasicPinQueryOperation::RunL, iPhone.Close =%d", 0 );
881d92421467 201037_03
hgs
parents:
diff changeset
   280
						        iPhone.Close();
881d92421467 201037_03
hgs
parents:
diff changeset
   281
						        iTelServer.UnloadPhoneModule(KMmTsyModuleName);
881d92421467 201037_03
hgs
parents:
diff changeset
   282
						        iTelServer.Close();
881d92421467 201037_03
hgs
parents:
diff changeset
   283
						        TRACE( "CBasicPinQueryOperation::RunL, iTelServer.Close =%d", 1 );
881d92421467 201037_03
hgs
parents:
diff changeset
   284
						        }
881d92421467 201037_03
hgs
parents:
diff changeset
   285
            }
881d92421467 201037_03
hgs
parents:
diff changeset
   286
881d92421467 201037_03
hgs
parents:
diff changeset
   287
881d92421467 201037_03
hgs
parents:
diff changeset
   288
    ReturnResultL( resultVerif );
881d92421467 201037_03
hgs
parents:
diff changeset
   289
881d92421467 201037_03
hgs
parents:
diff changeset
   290
    if( caption )
881d92421467 201037_03
hgs
parents:
diff changeset
   291
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   292
        CleanupStack::PopAndDestroy( caption );
881d92421467 201037_03
hgs
parents:
diff changeset
   293
        caption = NULL;
881d92421467 201037_03
hgs
parents:
diff changeset
   294
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   295
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   296
881d92421467 201037_03
hgs
parents:
diff changeset
   297
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   298
// CBasicPinQueryOperation::DoCancel()
881d92421467 201037_03
hgs
parents:
diff changeset
   299
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   300
//
881d92421467 201037_03
hgs
parents:
diff changeset
   301
void CBasicPinQueryOperation::DoCancel()
881d92421467 201037_03
hgs
parents:
diff changeset
   302
    {
881d92421467 201037_03
hgs
parents:
diff changeset
   303
    TRACE( "CBasicPinQueryOperation::DoCancel" );
881d92421467 201037_03
hgs
parents:
diff changeset
   304
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   305
881d92421467 201037_03
hgs
parents:
diff changeset
   306
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   307
// CBasicPinQueryOperation::CBasicPinQueryOperation()
881d92421467 201037_03
hgs
parents:
diff changeset
   308
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   309
//
881d92421467 201037_03
hgs
parents:
diff changeset
   310
CBasicPinQueryOperation::CBasicPinQueryOperation(
881d92421467 201037_03
hgs
parents:
diff changeset
   311
        MSecuiDialogOperationObserver& aObserver, const RMessage2& aMessage,
881d92421467 201037_03
hgs
parents:
diff changeset
   312
        TInt aReplySlot ) : CSecuiDialogOperation( aObserver, aMessage, aReplySlot )
881d92421467 201037_03
hgs
parents:
diff changeset
   313
    {
881d92421467 201037_03
hgs
parents:
diff changeset
   314
    TRACE( "CBasicPinQueryOperation::CBasicPinQueryOperation, aMessage 0x%08x", aMessage.Handle() );
881d92421467 201037_03
hgs
parents:
diff changeset
   315
    TRACE( "CBasicPinQueryOperation::CBasicPinQueryOperation, aMessage.Function = 0x%08x", aMessage.Function() );
881d92421467 201037_03
hgs
parents:
diff changeset
   316
    iStartUp=EFalse;
881d92421467 201037_03
hgs
parents:
diff changeset
   317
    if(aMessage.Function()>=0x1000)
881d92421467 201037_03
hgs
parents:
diff changeset
   318
    	iStartUp=ETrue;
881d92421467 201037_03
hgs
parents:
diff changeset
   319
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   320
881d92421467 201037_03
hgs
parents:
diff changeset
   321
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   322
// CBasicPinQueryOperation::ReturnResultL()
881d92421467 201037_03
hgs
parents:
diff changeset
   323
// ---------------------------------------------------------------------------
881d92421467 201037_03
hgs
parents:
diff changeset
   324
//
881d92421467 201037_03
hgs
parents:
diff changeset
   325
void CBasicPinQueryOperation::ReturnResultL( TInt aErrorCode )
881d92421467 201037_03
hgs
parents:
diff changeset
   326
    {
881d92421467 201037_03
hgs
parents:
diff changeset
   327
    TRACE( "CBasicPinQueryOperation::ReturnResultL, begin, aErrorCode=%d", aErrorCode );
881d92421467 201037_03
hgs
parents:
diff changeset
   328
    if( aErrorCode <= KErrNone )	// TODO should skip WriteL is error?
881d92421467 201037_03
hgs
parents:
diff changeset
   329
        {
881d92421467 201037_03
hgs
parents:
diff changeset
   330
        TPINValueBuf output( iPinValue );
881d92421467 201037_03
hgs
parents:
diff changeset
   331
        iMessage.WriteL( iReplySlot, output );
881d92421467 201037_03
hgs
parents:
diff changeset
   332
        }
881d92421467 201037_03
hgs
parents:
diff changeset
   333
    TRACE( "CBasicPinQueryOperation::ReturnResultL, completing msg 0x%08x", iMessage.Handle() );
881d92421467 201037_03
hgs
parents:
diff changeset
   334
    iMessage.Complete( aErrorCode );
881d92421467 201037_03
hgs
parents:
diff changeset
   335
    TRACE( "CBasicPinQueryOperation::ReturnResultL, informing observer" );
881d92421467 201037_03
hgs
parents:
diff changeset
   336
    iObserver.OperationComplete();
881d92421467 201037_03
hgs
parents:
diff changeset
   337
    TRACE( "CBasicPinQueryOperation::ReturnResultL, end" );
881d92421467 201037_03
hgs
parents:
diff changeset
   338
    }
881d92421467 201037_03
hgs
parents:
diff changeset
   339