clientprovisioning/cpqtsp/src/CWPBioControl.cpp
author hgs
Tue, 13 Jul 2010 03:48:30 +0530
changeset 45 0f9fc722d255
child 52 6e38e48ee756
permissions -rw-r--r--
201021_01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     1
/*
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     3
* All rights reserved.
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     8
*
0f9fc722d255 201021_01
hgs
parents:
diff changeset
     9
* Initial Contributors:
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    11
*
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    12
* Contributors:
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    13
*
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    14
* Description: 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    15
*     Bio control for Provisioning documents.
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    16
*
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    17
*/
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    18
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    19
// INCLUDE FILES
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    20
#include "CWPBioControl.h"
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    21
#include <msvapi.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    22
#include <bldvariant.hrh>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    23
#include <msvids.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    24
#include <featmgr.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    25
#include <sysutil.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    26
#include <CWPEngine.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    27
#include <CWPAdapter.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    28
#include <MWPPhone.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    29
#include <WPPhoneFactory.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    30
#include <CWPPushMessage.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    31
#include "ProvisioningUIDs.h"
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    32
#include <MWPContextManager.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    33
#include "ProvisioningDebug.h"
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    34
#include "CWPNameValue.h"
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    35
#include <aknmessagequerydialog.h> 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    36
#include <ProvisioningInternalCRKeys.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    37
#include <HbMessageBox>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    38
#include <HbAction>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    39
#include <QVariant>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    40
#include <hbdevicedialog.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    41
#include <QObject>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    42
#include <devicedialogconsts.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    43
#include <PnpUtilLogger.h>
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    44
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    45
// CONSTANTS
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    46
_LIT(KNone,"");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    47
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    48
// ============================ MEMBER FUNCTIONS ===============================
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    49
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    50
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    51
// Constructor.
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    52
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    53
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    54
CWPBioControl::CWPBioControl(CMsvSession* /*aSession*/,TMsvId /*aId*/): CActive(EPriorityNormal)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    55
                          
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    56
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    57
		CActiveScheduler::Add( this );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    58
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    59
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    60
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    61
// CWPBioControl::ConstructL
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    62
// Symbian 2nd phase constructor can leave.
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    63
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    64
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    65
void CWPBioControl::ConstructL(CMsvSession* aSession,TMsvId aId,CpQtSp* sp)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    66
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    67
    FLOG( _L( "[ProvisioningBC] CWPBioControl::ConstructL:" ) );  
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    68
    FeatureManager::InitializeLibL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    69
    iSession = aSession;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    70
    iId = aId;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    71
    iSp = sp;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    72
    iEngine = CWPEngine::NewL();    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    73
    iDevDialog = NULL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    74
    ibootstrap = NULL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    75
    iMsg = new(ELeave)CpMessage(this);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    76
    iWait = new( ELeave ) CActiveSchedulerWait;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    77
    FLOG( _L( "[ProvisioningBC] CWPBioControl::ConstructL: done" ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    78
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    79
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    80
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    81
// CWPBioControl::NewL
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    82
// Two-phased constructor.
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    83
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    84
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    85
EXPORT_C CWPBioControl* CWPBioControl::NewL(CMsvSession* aSession,TMsvId aId,CpQtSp* sp)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    86
     {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    87
    CWPBioControl* self = new( ELeave ) CWPBioControl(aSession,aId);                                                       
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    88
    CleanupStack::PushL( self );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    89
    self->ConstructL(aSession,aId,sp);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    90
    CleanupStack::Pop();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    91
    return self;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    92
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    93
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    94
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    95
// Destructor
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    96
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    97
CWPBioControl::~CWPBioControl()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    98
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
    99
    Cancel();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   100
    delete iEngine;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   101
    delete iMessage;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   102
    FeatureManager::UnInitializeLib();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   103
    if (iDevDialog)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   104
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   105
        delete iDevDialog;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   106
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   107
    delete ibootstrap;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   108
    delete iWait;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   109
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   110
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   111
// CWPBioControl ::RestoreMsgL
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   112
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   113
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   114
void CWPBioControl::RestoreMsgL()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   115
    {                    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   116
    CMsvEntry* entry = iSession->GetEntryL(iId);   
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   117
    CleanupStack::PushL( entry );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   118
    iEntry = entry->Entry();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   119
    iMessage = CWPPushMessage::NewL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   120
    CMsvStore* readStore = entry->ReadStoreL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   121
    CleanupStack::PushL( readStore );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   122
    iMessage->RestoreL( *readStore );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   123
    CleanupStack::PopAndDestroy(); // readStore
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   124
 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   125
    TRAPD( result, iEngine->ImportDocumentL( iMessage->Body() ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   126
    if( result == KErrCorrupt )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   127
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   128
        //result = KErrMsgBioMessageNotValid;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   129
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   130
    FTRACE(RDebug::Print(_L("[ProvisioningBC] CWPBioControl::RestoreMsgL result (%d)"), result));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   131
    User::LeaveIfError( result );    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   132
	AuthenticateL( *iMessage );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   133
	CleanupStack::PopAndDestroy();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   134
	if(iAuth == KAUTENTICATIONCANCEL || iAuth == KAUTENTICATIONSUCCESS)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   135
	    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   136
        iSp->authenticationStatus();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   137
	    }	
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   138
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   139
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   140
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   141
// CWPBioControl ::postAuthetication
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   142
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   143
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   144
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   145
void CWPBioControl::postAuthetication()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   146
    {    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   147
    iMsg->senderUnknown();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   148
    }      
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   149
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   150
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   151
// CWPBioControl ::senderUnknownContinue
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   152
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   153
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   154
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   155
void CWPBioControl::senderUnknownContinue()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   156
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   157
    iAuth = KAUTENTICATIONSUCCESS;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   158
    iSp->authenticationStatus();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   159
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   160
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   161
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   162
// CWPBioControl ::senderUnknownCancel
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   163
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   164
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   165
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   166
void CWPBioControl::senderUnknownCancel()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   167
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   168
    iAuth = KAUTENTICATIONCANCEL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   169
    iSp->authenticationStatus();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   170
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   171
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   172
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   173
// CWPBioControl ::updateAuthetication
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   174
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   175
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   176
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   177
void CWPBioControl::updateAuthetication()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   178
{
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   179
    if (iMessage->Authenticated() )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   180
           {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   181
           //update Cenrep key
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   182
           TBuf8<100> orig;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   183
           orig.Copy(iMessage->Originator());
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   184
           TRAPD(err, SetCenrepKeyL(orig));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   185
           User::LeaveIfError(err);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   186
           }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   187
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   188
    TBool preAuthenticated( iMessage->Authenticated() );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   189
    if( !iEntry.ReadOnly() && preAuthenticated != iMessage->Authenticated() )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   190
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   191
        // If the entry can be written to, get its edit store and save
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   192
        // authentication flag. Failing is not dangerous, as the only
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   193
        // effect is that the user has to re-enter the PIN.
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   194
        // FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL 4 " ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   195
        TRAPD( ignoreError, SaveMessageL() );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   196
        if ( ignoreError ) ignoreError = 0; // prevent compiler warning 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   197
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   198
    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   199
    iEngine->PopulateL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   200
    if( iEngine->ItemCount() == 0 )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   201
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   202
        FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL 7 " ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   203
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   204
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   205
    TPtrC8 orig8( iMessage->Originator() );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   206
    HBufC* orig16 = HBufC::NewLC( orig8.Length() );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   207
    orig16->Des().Copy( orig8 );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   208
    FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL 8 " ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   209
    if( iMessage->Authenticated() 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   210
        && iEngine->ContextExistsL( *orig16 ) )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   211
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   212
        TUint32 context( iEngine->ContextL( *orig16 ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   213
        iEngine->SetCurrentContextL( context );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   214
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   215
    else
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   216
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   217
        iEngine->SetCurrentContextL( KWPMgrUidNoContext );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   218
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   219
        
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   220
    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   221
    CleanupStack::PopAndDestroy();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   222
    FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL done" ) );  
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   223
}
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   224
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   225
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   226
// CWPBioControl ::getAuth
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   227
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   228
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   229
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   230
TInt CWPBioControl::getAuth()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   231
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   232
    return iAuth;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   233
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   234
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   235
// CWPBioControl ::RestoreMsgL
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   236
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   237
//	
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   238
TBool CWPBioControl::AuthenticateL( CWPPushMessage& aMessage )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   239
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   240
     if (!aMessage.Authenticated())
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   241
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   242
        MWPPhone* phone = NULL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   243
        TBuf<KMaxPinSize> imsi;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   244
        TRAPD(err, phone = WPPhoneFactory::CreateL());
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   245
        if (err != KErrNone)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   246
            {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   247
            imsi = KNone;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   248
            }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   249
        else
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   250
            {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   251
            imsi = phone->SubscriberId();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   252
            }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   253
        ibootstrap = CWPBootstrap::NewL(imsi);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   254
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   255
        if (phone)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   256
            delete phone;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   257
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   258
        CWPBootstrap::TBootstrapResult result(ibootstrap->BootstrapL(aMessage,*iEngine, KNullDesC));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   259
        if (result == CWPBootstrap::EPinRequired)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   260
            {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   261
            CMsvEntry* entry = iSession->GetEntryL(iId);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   262
            TInt count = (entry->Entry()).MtmData1();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   263
            // Create a new device dialog if it is not there
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   264
            if( !iDevDialog )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   265
              {                 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   266
                iDevDialog = CHbDeviceDialogSymbian::NewL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   267
                LOGSTRING("CWPBioControl::AuthenticateL() iDevDialog is created");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   268
              }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   269
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   270
            CHbSymbianVariantMap* parameters = CHbSymbianVariantMap::NewL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   271
            CleanupStack::PushL(parameters);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   272
            for (TInt i(0); i < KPinRetries && !aMessage.Authenticated(); i++)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   273
                {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   274
                // Add dialog key and dialog type to the parameters
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   275
                const TPtrC dialog (static_cast<const TUint16*>(keydialog.utf16()), keydialog.length());
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   276
                CHbSymbianVariant* dialogvariant = NULL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   277
                const TInt dialogID = EOmaCPPinDialog;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   278
                dialogvariant = CHbSymbianVariant::NewL( &dialogID, CHbSymbianVariant::EInt );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   279
                parameters->Add(dialog, dialogvariant );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   280
                
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   281
                // Add retries value to the parameters                
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   282
                itries = i;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   283
                const TPtrC ptrkeyparam1 (static_cast<const TUint16*>(keyparam1.utf16()), keyparam1.length());
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   284
                //Retries left after this attempt
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   285
                TInt retries = KPinRetries - itries;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   286
                CHbSymbianVariant* retriesvariant = NULL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   287
                retriesvariant = CHbSymbianVariant::NewL( &retries, CHbSymbianVariant::EInt );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   288
                parameters->Add(ptrkeyparam1, retriesvariant );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   289
                
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   290
                if (iDevDialog && iIsDisplayingDialog)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   291
                    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   292
                    LOGSTRING("[CWPBioControl] CWPBioControl::AuthenticateL updating the dialog");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   293
                    iDevDialog->Update(*parameters);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   294
                    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   295
                else if (iDevDialog && !iIsDisplayingDialog)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   296
                    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   297
                    // Show the device dialog
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   298
                    iDevDialog->Show(KDeviceDialogType,*parameters, this);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   299
                    iIsDisplayingDialog = ETrue;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   300
                    // Wait for user response
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   301
                    TInt error = WaitUntilDeviceDialogClosed();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   302
                    LOGSTRING2("WaitUntilDeviceDialogClosed err is %d", error);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   303
                    User::LeaveIfError(error);                    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   304
                        if(ireturnkey == EHbRSK)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   305
                        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   306
                        iAuth = KAUTENTICATIONCANCEL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   307
                        CleanupStack::PopAndDestroy(parameters);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   308
                        return false;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   309
                        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   310
                    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   311
                
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   312
     
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   313
                }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   314
            
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   315
            CleanupStack::PopAndDestroy(parameters);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   316
            
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   317
            if (iDevDialog)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   318
                {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   319
                iDevDialog->Cancel();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   320
                delete iDevDialog;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   321
                iDevDialog = NULL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   322
                }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   323
                   
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   324
            if( !aMessage.Authenticated() && (itries == KPinRetries - 1)  )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   325
                {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   326
                 iMsg->autheticationFailure();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   327
                 return false;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   328
                }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   329
            }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   330
        }                
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   331
    if(!aMessage.Authenticated())
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   332
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   333
        postAuthetication();        
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   334
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   335
    else if(aMessage.Authenticated())
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   336
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   337
        iAuth = KAUTENTICATIONSUCCESS;   
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   338
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   339
    FLOG( _L( "[ProvisioningBC] CWPBioControl::AuthenticateL done" ) );   
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   340
    return true;    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   341
  }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   342
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   343
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   344
// CWPBioControl ::authenticationFailed
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   345
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   346
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   347
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   348
void CWPBioControl::authenticationFailed()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   349
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   350
    iAuth = KAUTENTICATIONFAILURE;    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   351
    iSp->authenticationStatus();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   352
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   353
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   354
// CWPBioControl ::SaveMessageL
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   355
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   356
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   357
void CWPBioControl::SaveMessageL()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   358
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   359
    CMsvEntry* entry = iSession->GetEntryL(iId);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   360
    CleanupStack::PushL( entry );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   361
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   362
    CMsvStore* editStore = entry->EditStoreL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   363
    CleanupStack::PushL( editStore );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   364
    iMessage->StoreL( *editStore );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   365
    editStore->CommitL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   366
    CleanupStack::PopAndDestroy(2); // editStore, entry
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   367
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   368
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   369
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   370
// CWPBioControl ::CollectItemsL
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   371
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   372
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   373
EXPORT_C RPointerArray<CWPNameValue>* CWPBioControl::CollectItemsLC() const
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   374
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   375
    RPointerArray<CWPNameValue>* array = new(ELeave) RPointerArray<CWPNameValue>;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   376
    CleanupStack::PushL( TCleanupItem( Cleanup, array ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   377
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   378
    TInt count( iEngine->ItemCount() );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   379
    FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL 83 " ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   380
    for( TInt index = 0; index < count; index++ )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   381
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   382
        const TDesC& text = iEngine->SummaryText( index );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   383
        const TDesC& title = iEngine->SummaryTitle( index );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   384
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   385
        CWPNameValue* pair = CWPNameValue::NewLC( title, text );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   386
        User::LeaveIfError( array->Append( pair ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   387
        CleanupStack::Pop( pair );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   388
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   389
    array->Sort( TLinearOrder<CWPNameValue>( CWPBioControl::Compare ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   390
    return array;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   391
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   392
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   393
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   394
// CWPBioControl::Cleanup
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   395
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   396
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   397
void CWPBioControl::Cleanup( TAny* aAny )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   398
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   399
    RPointerArray<CWPNameValue>* array = reinterpret_cast<RPointerArray<CWPNameValue>*>( aAny );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   400
    array->ResetAndDestroy();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   401
    array->Close();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   402
    delete array;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   403
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   404
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   405
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   406
// CWPBioControl::Compare
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   407
// -----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   408
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   409
TInt CWPBioControl::Compare( const CWPNameValue& aItem1,
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   410
                             const CWPNameValue& aItem2 )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   411
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   412
    return aItem1.Name().Compare( aItem2.Name() );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   413
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   414
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   415
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   416
// CWPBioControl ::SaveSettingsL
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   417
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   418
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   419
void CWPBioControl::SaveSettingsL()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   420
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   421
    if( !iMessage->Saved())
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   422
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   423
        DoSaveL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   424
        SaveSettingStatus();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   425
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   426
    else
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   427
    {    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   428
        iMsg->saveSettingMessage();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   429
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   430
   }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   431
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   432
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   433
// CWPBioControl ::SaveSettingStatus
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   434
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   435
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   436
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   437
void CWPBioControl::SaveSettingStatus()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   438
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   439
    iMessage->SetSaved( ETrue );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   440
    SaveMessageL();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   441
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   442
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   443
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   444
// CWPBioControl ::DoSaveL
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   445
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   446
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   447
void CWPBioControl::DoSaveL()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   448
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   449
    TInt numSaved( 0 );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   450
    CWPSaver* saver = new(ELeave) CWPSaver( *iEngine, EFalse );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   451
    TBufC<KLENGTH> Value;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   452
    TInt err( saver->ExecuteLD( numSaved, Value ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   453
    if( err >= 0 )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   454
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   455
        // Check if any setting can be made default
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   456
        TBool setDefault( EFalse );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   457
        TInt itemCount( iEngine->ItemCount() );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   458
        for( TInt i( 0 ); i < itemCount && !setDefault; i++ )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   459
            {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   460
            if( iEngine->CanSetAsDefault( i ) )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   461
                {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   462
                setDefault = ETrue;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   463
                }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   464
            }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   465
        
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   466
        // Ask the user if the saved settings should be 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   467
        // made default.                     
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   468
        if( setDefault )
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   469
            {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   470
            iMsg->setAsDefault();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   471
            }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   472
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   473
    else
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   474
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   475
         iMsg->settingNotSaved();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   476
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   477
    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   478
        
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   479
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   480
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   481
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   482
// CWPBioControl ::saveDefaultSetting
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   483
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   484
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   485
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   486
void CWPBioControl::saveDefaultSetting()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   487
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   488
     CWPSaver* setter = new(ELeave) CWPSaver( *iEngine, ETrue );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   489
     TInt numSet( 0 );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   490
     TBufC<KLENGTH> Value;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   491
     TInt result = KErrNone;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   492
     result = setter->ExecuteLD( numSet,Value );                            
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   493
     if (result)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   494
     {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   495
        iMsg->settingNotSaved();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   496
     }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   497
    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   498
        
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   499
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   500
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   501
// CWPBioControl ::SetCenrepKey
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   502
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   503
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   504
void CWPBioControl::SetCenrepKeyL(const TDesC8& aValue)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   505
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   506
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   507
    FLOG( _L( "[ProvisioningBC] CWPBioControl::SetCenrepKeyL" ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   508
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   509
    CRepository* rep= NULL;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   510
    TInt errorStatus = KErrNone;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   511
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   512
    TRAPD( errVal, rep = CRepository::NewL( KCRUidOMAProvisioningLV ))
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   513
    ;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   514
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   515
    if (errVal == KErrNone)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   516
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   517
        errorStatus = rep->Set(KOMAProvOriginatorContent, aValue);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   518
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   519
    else
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   520
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   521
        errorStatus = errVal;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   522
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   523
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   524
    if (rep)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   525
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   526
        delete rep;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   527
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   528
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   529
    if (errorStatus != KErrNone)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   530
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   531
        User::Leave(errorStatus);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   532
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   533
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   534
    FLOG( _L( "[ProvisioningBC] CWPBioControl::SetCenrepKeyL done" ) );
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   535
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   536
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   537
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   538
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   539
// CWPBioControl ::DataReceived
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   540
// Slot to handle the data received from the plugin
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   541
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   542
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   543
void CWPBioControl::DataReceived(CHbSymbianVariantMap& aData)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   544
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   545
    FLOG(_L("CWPBioControl::DataReceived() start"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   546
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   547
    // Get the return key
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   548
    const TPtrC ptrreturnkey(static_cast<const TUint16*> (returnkey.utf16()),
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   549
            returnkey.length());
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   550
    const CHbSymbianVariant* returnkeyvariant = aData.Get(ptrreturnkey);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   551
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   552
    if (returnkeyvariant)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   553
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   554
        TInt* returnkey = returnkeyvariant->Value<TInt> ();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   555
        if (returnkey)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   556
            {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   557
            ireturnkey = *returnkey;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   558
            FLOG(_L("CWPBioControl::DataReceived() ireturnkey"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   559
            LOGSTRING2("ireturnkey is %d", ireturnkey);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   560
            if (ireturnkey == EHbLSK)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   561
                {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   562
                // Ok key pressed 
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   563
                FLOG(_L("Ok key pressed"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   564
                LOGSTRING("CWPBioControl::DataReceived() Ok key pressed");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   565
                // Get the PIN code
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   566
                const TPtrC ptrpinquery(
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   567
                        static_cast<const TUint16*> (pinquery.utf16()),
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   568
                        pinquery.length());
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   569
                const CHbSymbianVariant* pinvariant = aData.Get(ptrpinquery);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   570
                if (pinvariant)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   571
                    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   572
                    TPtrC pin = *pinvariant->Value<TDesC> ();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   573
                    // Call BootstrapL to find out whether the PIN is correct or not
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   574
                    CWPBootstrap::TBootstrapResult result =
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   575
                            CWPBootstrap::EPinRequired;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   576
                    TInt err = KErrNone;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   577
                    TRAP( err, QT_TRYCATCH_LEAVING(result = ibootstrap->BootstrapL(*iMessage, *iEngine, pin) ));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   578
                    if (err == KErrNone && result
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   579
                            == CWPBootstrap::EAuthenticationFailed && itries
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   580
                            < KPinRetries - 1)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   581
                        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   582
                        FLOG(_L("CWPBioControl:deviceDialog:DataReceived() Authentication Failed"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   583
                        LOGSTRING("CWPBioControl::DataReceived() Authentication Failed");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   584
                        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   585
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   586
                    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   587
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   588
                }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   589
            }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   590
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   591
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   592
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   593
    FLOG(_L("CWPBioControl:deviceDialog:DataReceived() end"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   594
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   595
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   596
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   597
// CWPBioControl ::DeviceDialogClosed
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   598
// Slot to handle the deviceDialogClosed signal from the plugin
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   599
// ----------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   600
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   601
void CWPBioControl::DeviceDialogClosed(TInt aCompletionCode)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   602
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   603
    FLOG(_L("CWPBioControl::DeviceDialogClosed() start"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   604
    LOGSTRING("CWPBioControl::DeviceDialogClosed() start");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   605
    iCompletionCode = aCompletionCode;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   606
    LOGSTRING2("CWPBioControl::DeviceDialogClosed() iCompletionCode is %d", iCompletionCode);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   607
    
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   608
    iIsDisplayingDialog = EFalse;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   609
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   610
    TRequestStatus* status(&iStatus);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   611
    User::RequestComplete(status, KErrNone);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   612
    LOGSTRING("CWPBioControl::DeviceDialogClosed() end");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   613
    FLOG(_L("CWPBioControl::DeviceDialogClosed() end"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   614
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   615
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   616
// ---------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   617
// CWPBioControl::DoCancel()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   618
// ---------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   619
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   620
void CWPBioControl::DoCancel()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   621
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   622
    FLOG(_L("CWPBioControl::DoCancel() start"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   623
    LOGSTRING("CWPBioControl::DoCancel() start");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   624
    if (iWait && iWait->IsStarted() && iWait->CanStopNow())
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   625
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   626
        LOGSTRING("CWPBioControl::DoCancel() In the iWait block");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   627
        iCompletionCode = KErrCancel;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   628
        iWait->AsyncStop();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   629
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   630
    LOGSTRING("CWPBioControl::DoCancel() end");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   631
    FLOG(_L("CWPBioControl::DoCancel() end"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   632
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   633
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   634
// ---------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   635
// CWPBioControl::RunL()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   636
// ---------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   637
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   638
void CWPBioControl::RunL()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   639
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   640
    FLOG(_L("CWPBioControl::RunL() start"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   641
    LOGSTRING("CWPBioControl::RunL() start");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   642
    if (iWait)
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   643
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   644
        LOGSTRING("CWPBioControl::RunL() iWait block ");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   645
        iWait->AsyncStop();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   646
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   647
    LOGSTRING("CWPBioControl::RunL() end");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   648
    FLOG(_L("CWPBioControl::RunL() end"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   649
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   650
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   651
// ---------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   652
// CWPBioControl::WaitUntilDeviceDialogClosed()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   653
// ---------------------------------------------------------------------------
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   654
//
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   655
TInt CWPBioControl::WaitUntilDeviceDialogClosed()
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   656
    {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   657
    FLOG(_L("CWPBioControl::WaitUntilDeviceDialogClosed() start"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   658
    iCompletionCode = KErrInUse;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   659
    ireturnkey = KErrUnknown;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   660
    if (!IsActive() && iWait && !iWait->IsStarted())
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   661
        {
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   662
        FLOG(_L("CWPBioControl::WaitUntilDeviceDialogClosed() In WaitAsynch start block"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   663
        LOGSTRING("CWPBioControl::WaitUntilDeviceDialogClosed() In WaitAsynch start block");
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   664
        iStatus = KRequestPending;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   665
        SetActive();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   666
        LOGSTRING2("CWPBioControl::WaitUntilDeviceDialogClosed() iCompletionCode is %d", iCompletionCode);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   667
        iWait->Start();
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   668
        LOGSTRING2("CWPBioControl::WaitUntilDeviceDialogClosed() iCompletionCode is %d", iCompletionCode);
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   669
        }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   670
    FLOG(_L("CWPBioControl::WaitUntilDeviceDialogClosed() end"));
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   671
    return iCompletionCode;
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   672
    }
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   673
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   674
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   675
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   676
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   677
0f9fc722d255 201021_01
hgs
parents:
diff changeset
   678
//  End of File