deviceupdatesui/cpqtsp/src/CWPBioControl.cpp
author hgs
Fri, 19 Mar 2010 04:28:07 +0530
changeset 33 7464c1e21dae
permissions -rw-r--r--
201008_internal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     1
/*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     3
* All rights reserved.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     8
*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     9
* Initial Contributors:
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    11
*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    12
* Contributors:
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    13
*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    14
* Description: 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    15
*     Bio control for Provisioning documents.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    16
*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    17
*/
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    18
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    19
// INCLUDE FILES
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    20
#include "CWPBioControl.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    21
#include <msvapi.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    22
#include <bldvariant.hrh>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    23
#include <msvids.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    24
#include <featmgr.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    25
#include <sysutil.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    26
#include "CWPEngine.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    27
#include "CWPAdapter.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    28
#include "MWPPhone.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    29
#include "WPPhoneFactory.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    30
#include "CWPPushMessage.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    31
#include "ProvisioningUIDs.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    32
#include "MWPContextManager.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    33
#include "ProvisioningDebug.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    34
#include "CWPNameValue.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    35
#include <aknmessagequerydialog.h> 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    36
#include "ProvisioningInternalCRKeys.h"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    37
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    38
// CONSTANTS
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    39
/// Maximum length of PIN code
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    40
const TInt KMaxPinSize = 20;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    41
/// Number of retries for PIN
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    42
// const TInt KPinRetries = 3; // Removed, because iMtmData1 data member of TMsvEntry in CWPMessage.cpp contains Max tries, default=3.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    43
///NONE
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    44
_LIT(KNone,"");
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    45
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    46
// ============================ MEMBER FUNCTIONS ===============================
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    47
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    48
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    49
// Constructor.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    50
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    51
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    52
CWPBioControl::CWPBioControl(CMsvSession* aSession,TMsvId aId)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    53
                          
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    54
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    55
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    56
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    57
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    58
// CWPBioControl::ConstructL
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    59
// Symbian 2nd phase constructor can leave.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    60
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    61
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    62
void CWPBioControl::ConstructL(CMsvSession* aSession,TMsvId aId)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    63
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    64
    FLOG( _L( "[ProvisioningBC] CWPBioControl::ConstructL:" ) );  
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    65
    FeatureManager::InitializeLibL();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    66
    iSession = aSession;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    67
    iId = aId;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    68
    iEngine = CWPEngine::NewL();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    69
    RestoreMsgL();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    70
    FLOG( _L( "[ProvisioningBC] CWPBioControl::ConstructL: done" ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    71
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    72
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    73
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    74
// CWPBioControl::NewL
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    75
// Two-phased constructor.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    76
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    77
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    78
EXPORT_C CWPBioControl* CWPBioControl::NewL(CMsvSession* aSession,TMsvId aId)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    79
     {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    80
    CWPBioControl* self = new( ELeave ) CWPBioControl(aSession,aId);                                                       
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    81
    CleanupStack::PushL( self );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    82
    self->ConstructL(aSession,aId);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    83
    CleanupStack::Pop();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    84
    return self;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    85
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    86
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    87
// CWPBioControl::returnEngine
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    88
// Return CWPEngine pointer
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    89
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    90
//    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    91
EXPORT_C CWPEngine* CWPBioControl::returnEngine()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    92
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    93
    return iEngine;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    94
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    95
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    96
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    97
// Destructor
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    98
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    99
CWPBioControl::~CWPBioControl()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   100
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   101
    delete iEngine;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   102
    delete iMessage;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   103
    FeatureManager::UnInitializeLib();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   104
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   105
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   106
// CWPBioControl ::RestoreMsgL
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   107
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   108
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   109
void CWPBioControl::RestoreMsgL()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   110
    {                    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   111
    CMsvEntry* entry = iSession->GetEntryL(iId);   
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   112
    CleanupStack::PushL( entry );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   113
    TMsvEntry tentry( entry->Entry() );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   114
    iMessage = CWPPushMessage::NewL();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   115
    CMsvStore* readStore = entry->ReadStoreL();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   116
    CleanupStack::PushL( readStore );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   117
    iMessage->RestoreL( *readStore );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   118
    CleanupStack::PopAndDestroy(); // readStore
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   119
 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   120
    TRAPD( result, iEngine->ImportDocumentL( iMessage->Body() ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   121
    if( result == KErrCorrupt )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   122
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   123
        //result = KErrMsgBioMessageNotValid;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   124
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   125
    FTRACE(RDebug::Print(_L("[ProvisioningBC] CWPBioControl::RestoreMsgL result (%d)"), result));
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   126
    User::LeaveIfError( result );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   127
    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   128
    TBool preAuthenticated( iMessage->Authenticated() );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   129
    // If the message was not authenticated, give a warning
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   130
    AuthenticateL( *iMessage );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   131
    if( !tentry.ReadOnly() && preAuthenticated != iMessage->Authenticated() )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   132
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   133
        // If the entry can be written to, get its edit store and save
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   134
        // authentication flag. Failing is not dangerous, as the only
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   135
        // effect is that the user has to re-enter the PIN.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   136
        // FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL 4 " ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   137
        TRAPD( ignoreError, SaveMessageL() );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   138
        if ( ignoreError ) ignoreError = 0; // prevent compiler warning 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   139
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   140
    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   141
    iEngine->PopulateL();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   142
    if( iEngine->ItemCount() == 0 )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   143
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   144
        FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL 7 " ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   145
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   146
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   147
    TPtrC8 orig8( iMessage->Originator() );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   148
    HBufC* orig16 = HBufC::NewLC( orig8.Length() );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   149
    orig16->Des().Copy( orig8 );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   150
    FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL 8 " ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   151
    if( iMessage->Authenticated() 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   152
        && iEngine->ContextExistsL( *orig16 ) )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   153
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   154
        TUint32 context( iEngine->ContextL( *orig16 ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   155
        iEngine->SetCurrentContextL( context );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   156
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   157
    else
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   158
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   159
        iEngine->SetCurrentContextL( KWPMgrUidNoContext );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   160
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   161
        
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   162
    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   163
    CleanupStack::PopAndDestroy(2);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   164
    FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL done" ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   165
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   166
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   167
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   168
// CWPBioControl ::AuthenticateL
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   169
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   170
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   171
void CWPBioControl::AuthenticateL( CWPPushMessage& aMessage )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   172
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   173
    if( !aMessage.Authenticated() )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   174
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   175
         MWPPhone* phone = NULL;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   176
         TBuf<KMaxPinSize> imsi;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   177
         TRAPD(err, phone = WPPhoneFactory::CreateL());
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   178
         if(err!=KErrNone)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   179
             {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   180
             imsi = KNone;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   181
             }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   182
         else
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   183
             {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   184
             imsi = phone->SubscriberId();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   185
             }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   186
        CWPBootstrap* bootstrap = CWPBootstrap::NewL( imsi );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   187
        if(phone)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   188
        delete phone;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   189
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   190
        CleanupStack::PushL( bootstrap );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   191
        CWPBootstrap::TBootstrapResult result( bootstrap->BootstrapL(aMessage,*iEngine,KNullDesC ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   192
        if( result == CWPBootstrap::EPinRequired )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   193
         {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   194
            CMsvEntry* entry = iSession->GetEntryL(iId);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   195
            TInt count = (entry->Entry()).MtmData1();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   196
            TInt ipin = 1234;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   197
            TBuf<KMaxPinSize> pin;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   198
            pin.AppendNum(ipin);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   199
            result = bootstrap->BootstrapL( aMessage, *iEngine, pin );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   200
            CleanupStack::PopAndDestroy( bootstrap );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   201
          }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   202
      }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   203
    if (aMessage.Authenticated() )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   204
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   205
        //update Cenrep key
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   206
        TBuf8<100> orig;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   207
        orig.Copy(aMessage.Originator());
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   208
        TRAPD(err, SetCenrepKeyL(orig));
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   209
        User::LeaveIfError(err);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   210
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   211
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   212
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   213
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   214
// CWPBioControl ::SaveMessageL
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   215
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   216
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   217
void CWPBioControl::SaveMessageL()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   218
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   219
    CMsvEntry* entry = iSession->GetEntryL(iId);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   220
    CleanupStack::PushL( entry );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   221
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   222
    CMsvStore* editStore = entry->EditStoreL();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   223
    CleanupStack::PushL( editStore );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   224
    iMessage->StoreL( *editStore );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   225
    editStore->CommitL();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   226
    CleanupStack::PopAndDestroy(2); // editStore, entry
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   227
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   228
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   229
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   230
// CWPBioControl ::CollectItemsL
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   231
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   232
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   233
EXPORT_C RPointerArray<CWPNameValue>* CWPBioControl::CollectItemsLC() const
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   234
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   235
    RPointerArray<CWPNameValue>* array = new(ELeave) RPointerArray<CWPNameValue>;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   236
    CleanupStack::PushL( TCleanupItem( Cleanup, array ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   237
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   238
    TInt count( iEngine->ItemCount() );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   239
    FLOG( _L( "[ProvisioningBC] CWPBioControl::RestoreMsgL 83 " ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   240
    for( TInt index = 0; index < count; index++ )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   241
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   242
        const TDesC& text = iEngine->SummaryText( index );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   243
        const TDesC& title = iEngine->SummaryTitle( index );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   244
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   245
        CWPNameValue* pair = CWPNameValue::NewLC( title, text );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   246
        User::LeaveIfError( array->Append( pair ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   247
        CleanupStack::Pop( pair );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   248
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   249
    array->Sort( TLinearOrder<CWPNameValue>( CWPBioControl::Compare ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   250
    return array;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   251
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   252
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   253
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   254
// CWPBioControl::Cleanup
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   255
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   256
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   257
void CWPBioControl::Cleanup( TAny* aAny )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   258
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   259
    RPointerArray<CWPNameValue>* array = reinterpret_cast<RPointerArray<CWPNameValue>*>( aAny );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   260
    array->ResetAndDestroy();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   261
    array->Close();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   262
    delete array;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   263
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   264
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   265
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   266
// CWPBioControl::Compare
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   267
// -----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   268
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   269
TInt CWPBioControl::Compare( const CWPNameValue& aItem1,
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   270
                             const CWPNameValue& aItem2 )
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   271
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   272
    return aItem1.Name().Compare( aItem2.Name() );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   273
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   274
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   275
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   276
// CWPBioControl ::SetCenrepKey
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   277
// ----------------------------------------------------------------------------
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   278
//
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   279
void CWPBioControl::SetCenrepKeyL(const TDesC8& aValue)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   280
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   281
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   282
    FLOG( _L( "[ProvisioningBC] CWPBioControl::SetCenrepKeyL" ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   283
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   284
    CRepository* rep= NULL;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   285
    TInt errorStatus = KErrNone;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   286
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   287
    TRAPD( errVal, rep = CRepository::NewL( KCRUidOMAProvisioningLV ))
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   288
    ;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   289
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   290
    if (errVal == KErrNone)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   291
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   292
        errorStatus = rep->Set(KOMAProvOriginatorContent, aValue);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   293
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   294
    else
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   295
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   296
        errorStatus = errVal;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   297
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   298
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   299
    if (rep)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   300
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   301
        delete rep;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   302
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   303
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   304
    if (errorStatus != KErrNone)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   305
        {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   306
        User::Leave(errorStatus);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   307
        }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   308
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   309
    FLOG( _L( "[ProvisioningBC] CWPBioControl::SetCenrepKeyL done" ) );
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   310
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   311
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
   312
//  End of File