terminalsecurity/SCP/SCPClient/src/SCPClient.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 14 Sep 2010 22:54:36 +0300
branchRCL_3
changeset 65 5cc2995847ea
parent 62 19bba8228ff0
child 76 3cdbd92ee07b
permissions -rw-r--r--
Revision: 201033 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description: Implementation of terminalsecurity components
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
// INCLUDE FILES
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <e32svr.h>
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    22
#include <bautils.h>
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <e32math.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <e32uid.h>
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    25
#include <barsc.h>
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <AknGlobalNote.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <aknnotewrappers.h> 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <AknQueryDialog.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <AknGlobalConfirmationQuery.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "SCPClient.h"
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    32
#include "SCPQueryDialog.h"
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "SCPParamObject.h"
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
65
5cc2995847ea Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 62
diff changeset
    35
#include <scpnotifier.rsg>
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include "SCP_IDs.h"
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#include <centralrepository.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "SCPLockCode.h"
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
//#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include <TerminalControl3rdPartyAPI.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include <SCPServerInterface.h>
65
5cc2995847ea Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 62
diff changeset
    43
#include <secui.rsg>
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    44
#include <scptimestamppluginlang.rsg>
9
57a65a3a658c Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 5
diff changeset
    45
#include <secui.hrh>
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include <StringLoader.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#include <bautils.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
//#endif // DEVICE_LOCK_ENHANCEMENTS
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    49
#include <DevManInternalCRKeys.h>
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
#include <featmgr.h>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
#include "SCPDebug.h"
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
#include <e32property.h>
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    54
#include <SCPPServerPluginDefs.hrh>
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    55
#include <apgtask.h>
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    56
#include    <e32property.h>
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    57
#include    <PSVariables.h>
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    58
#include    <coreapplicationuisdomainpskeys.h>
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    59
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
/*#ifdef _DEBUG
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
#define __SCP_DEBUG
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
#endif // _DEBUG
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
// Define this so the precompiler in CW 3.1 won't complain about token pasting,
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
// the warnings are not valid
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
#pragma warn_illtokenpasting off
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
#ifdef __SCP_DEBUG
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
#define Dprint(a) RDebug::Print##a
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
#else
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
#define Dprint(a)
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
#endif // _DEBUG*/
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
static const TUint KDefaultMessageSlots = 3;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
static const TInt KSCPConnectRetries( 2 );
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    76
const TInt KLockedbyLawmo (30);
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
//#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
_LIT( KDriveZ, "Z:" );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
_LIT( KSCPResourceFilename, "\\Resource\\SCPNotifier.RSC" );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
_LIT( KSCPSecUIResourceFilename, "\\Resource\\SecUi.RSC" );
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
    82
_LIT( KSCPTimestampPluginResFilename, "\\Resource\\SCPTimestampPluginLang.rsc");
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
//#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
// Uid for the application; this should match the mmp file
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
const TUid KServerUid3 = {0x10207836};
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
#ifdef __WINS__
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
static const TUint KServerMinHeapSize =  0x1000;  //  4K
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
static const TUint KServerMaxHeapSize = 0x10000;  // 64K
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
#endif
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
static TInt StartServer();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
static TInt CreateServerProcess();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
// LOCAL FUNCTION PROTOTYPES
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
// ==================== LOCAL FUNCTIONS ====================
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
// StartServer() Server starter check
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
// Determines if the server is running, if not, calls the starter function
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
// Returns: TInt: Operation status, a standard error code
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
static TInt StartServer()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    Dprint( (_L("--> SCPClient::StartServer()") ));        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    TInt result;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    TFindServer findSCPServer( KSCPServerName );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    TFullName name;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    result = findSCPServer.Next( name );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    if ( result != KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
        // The server is not running, try to create the server process
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
        result = CreateServerProcess();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
        } 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
    Dprint( (_L("<-- SCPClient::StartServer(): Exit code: %d"), result ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
    return result;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
// CreateServerProcess() Server starter function
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
// Starts the SCP server
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
// Returns: TInt: Operation status, a standard error code
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
static TInt CreateServerProcess()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
    Dprint( (_L("--> SCPClient::CreateServerProcess()") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
    TInt result;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    const TUidType serverUid( KNullUid, KNullUid, KServerUid3 );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    RProcess server;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    _LIT( KEmpty, "");   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
    result = server.Create( KSCPServerFileName, KEmpty );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
    if ( result != KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
        Dprint( (_L("<-- SCPClient::CreateServerProcess(), process creation error!") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
        return result;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
        }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    TRequestStatus stat;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    server.Rendezvous(stat);
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    if ( stat != KRequestPending )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
        server.Kill(0);    // abort startup
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
        }    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    else
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
        server.Resume(); // logon OK - start the server
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
        }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
    User::WaitForRequest(stat); // wait for start or death
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
    // we can't use the 'exit reason' if the server panicked as this
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    // is the panic 'reason' and may be '0' which cannot be distinguished
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    // from KErrNone
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    result = ( server.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    server.Close();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    Dprint( (_L("<-- SCPClient::CreateServerProcess(): %d"), result ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    return result;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
//#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   185
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   186
// RunDialog() Dialog execution wrapper
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   187
// Initialize and run the query dialog
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   188
// Returns: TInt: The return code from the dialog.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   189
//          Can leave with a generic error code.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   190
//
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   191
// Status : Approved
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   192
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   193
//
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   194
TInt RunDialogL( TDes& aReplyBuf,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   195
                RSCPClient::TSCPButtonConfig aButtonsShown,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   196
                TInt aMinLen,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   197
                TInt aMaxLen,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   198
                TUint aResId = 0,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   199
                TDesC* aPrompt = NULL,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   200
                TBool aECSSupport = EFalse,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   201
                CSCPQueryDialog :: TKeypadContext aContext = CSCPQueryDialog :: ENumeric
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   202
              )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   203
    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   204
    Dprint(_L("[RSCPClient]-> RunDialogL() >>> "));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   205
    Dprint(_L("[RSCPClient]-> RunDialogL() aContext = %d "), aContext);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   206
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   207
    FeatureManager::InitializeLibL();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   208
    if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   209
	{
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   210
			FeatureManager::UnInitializeLib();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   211
		return KErrNotSupported;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   212
	}
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   213
		FeatureManager::UnInitializeLib();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   214
    if ( ( aPrompt == NULL ) && ( aResId == 0 ) )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   215
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   216
        return KErrArgument;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   217
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   218
    Dprint((_L("--> SCPClient::RunDialogL() start the dialog")));    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   219
    CSCPQueryDialog* dialog = new (ELeave) CSCPQueryDialog( 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   220
        aReplyBuf,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   221
        aButtonsShown,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   222
        aMinLen,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   223
        aMaxLen,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   224
        aECSSupport,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   225
        aContext
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   226
        ); 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   227
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   228
    CleanupStack::PushL( dialog );            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   229
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   230
    if ( aResId != 0 )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   231
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   232
        // Load and set the prompt from a resource ID
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   233
        HBufC* prompt;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   234
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   235
        prompt = StringLoader::LoadLC( aResId );   
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   236
        dialog->SetPromptL( *prompt ); 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   237
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   238
        CleanupStack::PopAndDestroy( prompt );       
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   239
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   240
    else
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   241
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   242
        // Set the given prompt
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   243
        dialog->SetPromptL( *aPrompt );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   244
        }        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   245
    Dprint((_L("-- SCPClient::RunDialogL() dialog->ExecuteLD")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   246
    TInt ret = dialog->ExecuteLD( R_SCP_CODE_QUERY );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   247
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   248
    CleanupStack::Pop( dialog );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   249
    Dprint( (_L("-- SCPClient::RunDialogL(): ret val %d"), ret));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   250
    return ret;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   251
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   252
    
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
// LoadResources() Resource loader
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
// Load the resources for the library
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
// Returns: TInt: A generic error code.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
TInt LoadResources( TInt& aRes1, TInt& aRes2 )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
   TRAPD ( err, FeatureManager::InitializeLibL() );   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
   if ( err == KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
   {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
	{
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
			FeatureManager::UnInitializeLib();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
		return KErrNotSupported;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
	}
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
		FeatureManager::UnInitializeLib();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    // Load the resource files for this DLL
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
    TInt err = KErrNone;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    TInt err2 = KErrNone;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
       
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
    // Localize the file name, and load the SCP resources
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
    TFileName resFile;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
    resFile.Copy( KDriveZ );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
    resFile.Append( KSCPResourceFilename );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
    BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resFile );    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
    TRAP( err, aRes1 = CCoeEnv::Static()->AddResourceFileL( resFile ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
    if ( err == KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
        // Localize the file name, and load the SecUi resources
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
        resFile.Copy( KDriveZ );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
        resFile.Append( KSCPSecUIResourceFilename );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
        BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resFile );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
        TRAP( err2, aRes2 = CCoeEnv::Static()->AddResourceFileL( resFile ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
        }   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
             
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
    if ( ( err != KErrNone ) || ( err2 != KErrNone ) )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
        {        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
        if ( err == KErrNone )             
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
            {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
            // First resource was loaded OK, remove it
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
            CCoeEnv::Static()->DeleteResourceFile( aRes1 );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
            err = err2;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
            }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
        } 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    }        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    return err;           
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    }     
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
//#endif //  __SAP_DEVICE_LOCK_ENHANCEMENTS
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
// ================= MEMBER FUNCTIONS =======================
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
// C++ default constructor can NOT contain any code, that
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
// might leave.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
EXPORT_C RSCPClient::RSCPClient()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
:   RSessionBase()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
    // No implementation required
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
// TInt RSCPClient::Connect()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
// Creates a new session, and starts the server, if required.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
EXPORT_C TInt RSCPClient::Connect()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
    Dprint( (_L("--> RSCPClient::Connect()") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
    // Use a mutex-object so that two processes cannot start the server at the same time
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
    RMutex startMutex;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
    TRAPD( errf, FeatureManager::InitializeLibL() );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
	if( errf != KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
		{
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
		return errf;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
		}
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
		if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
		{
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
			isFlagEnabled = ETrue;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
		}
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
		else
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
		{
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
			isFlagEnabled = EFalse;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
		}
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
		FeatureManager::UnInitializeLib();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
    TInt mRet = startMutex.OpenGlobal( KSCPServerName );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
    if ( mRet == KErrNotFound )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
        mRet = startMutex.CreateGlobal( KSCPServerName );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
        }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
    if ( mRet != KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
        {        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
        return mRet;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   357
        }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   359
    // Acquire the mutex
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
    startMutex.Wait();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    TInt retry = KSCPConnectRetries;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
    TInt r;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    for (;;)
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
        {        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
        r = CreateSession( KSCPServerName, Version(), KDefaultMessageSlots );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
        if ( ( r != KErrNotFound ) && ( r != KErrServerTerminated  ) )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
            {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
            break;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
            }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
        if ( --retry == 0 )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
            {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
            break;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
            }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
      
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
        r = StartServer();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
        if ( ( r != KErrNone ) && ( r != KErrAlreadyExists ) )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
            {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
            break;   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
            }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
        }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
    Dprint( (_L("<-- RSCPClient::Connect(), exiting: %d"), r ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
    // Release the mutex
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
    startMutex.Signal();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
    startMutex.Close();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
    return r;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
// TVersion RSCPClient::Version()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
// Constructs a TVersion object containing the defined version
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
// numbers, and returns it
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
EXPORT_C TVersion RSCPClient::Version() const
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
    Dprint( (_L("<--> RSCPClient::Version()") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
    return( TVersion( KSCPServMajorVersionNumber,
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
                      KSCPServMinorVersionNumber,
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
                      KSCPServBuildVersionNumber ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
// TInt RSCPClient::GetCode( TSCPSecCode& aCode )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
// Requests the stored ISA code.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
EXPORT_C TInt RSCPClient::GetCode( TSCPSecCode& aCode )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    Dprint( (_L("--> RSCPClient::GetCode()") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    TInt ret = SendReceive(ESCPServGetCode, TIpcArgs( &aCode ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
    Dprint( (_L("<-- RSCPClient::GetCode(): %d"), ret ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    return ret;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
// TInt RSCPClient::StoreCode( TSCPSecCode& aCode )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
// Propagates the store code -request to the server along
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
// with the buffer parameter.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
EXPORT_C TInt RSCPClient::StoreCode( TSCPSecCode& aCode )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
    Dprint( (_L("--> RSCPClient::StoreCode()") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
    TInt ret = SendReceive(ESCPServSetCode, TIpcArgs( &aCode ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
    Dprint( (_L("<-- RSCPClient::StoreCode(): %d"), ret ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    return ret;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    }   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
// TInt RSCPClient::ChangeCode( TDes& aNewCode )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
// Propagates the change code -request to the server, along with
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
// the code parameter.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
EXPORT_C TInt RSCPClient::ChangeCode( TDes& aNewCode )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
    Dprint( (_L("--> RSCPClient::ChangeCode()") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
    TInt ret = SendReceive(ESCPServChangeCode, TIpcArgs( &aNewCode ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
    Dprint( (_L("<-- RSCPClient::ChangeCode(): %d"), ret ));  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
    return ret;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
    }   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
// TInt RSCPClient::SetPhoneLock()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
// Propagates the lock/unlock phone -request to the server
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
EXPORT_C TInt RSCPClient::SetPhoneLock( TBool aLocked )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
    Dprint( (_L("--> RSCPClient::SetPhoneLock( %d)"), aLocked ));
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   479
    TInt autolockState = -1;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   480
    RProperty aProperty;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   481
    aProperty.Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   482
    Dprint( (_L("RSCPClient::SetPhoneLock()Autolock state before %d"), autolockState ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   483
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   484
    if((aLocked==0)&&(autolockState != EAutolockStatusUninitialized))
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   485
    InformAutolockTask();            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   486
    Dprint( (_L("RSCPClient sendreceive") ));
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
    TInt ret = SendReceive(ESCPServSetPhoneLock, TIpcArgs( aLocked ) );
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   488
    Dprint( (_L("RSCPClient sendreceive done") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   489
    aProperty.Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   490
    Dprint( (_L("RSCPClient::SetPhoneLock()Autolock state after %d"), autolockState ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   491
    // Put it here because, we cant change autolock status before sendreceive 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   492
    // Uninitialised state is Only at Bootup.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   493
    if((autolockState == EAutolockStatusUninitialized)&&(aLocked==0)&&(ret==KErrNone))
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   494
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   495
        Dprint( (_L("RSCPClient::SetPhoneLock()setting autolock status") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   496
        aProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   497
        // This is startup and we are done with ISA unlock
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   498
        // So set the Startup cenrep key so tht it is used in SeccodeQuery
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   499
        CRepository* lRepository = NULL; 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   500
        TInt returnv;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   501
        TRAP(returnv, lRepository = CRepository :: NewL(KCRUidSCPLockCode));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   502
        returnv = lRepository->Set(KSCPStartupQuery, 1);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   503
        if(returnv==KErrNone)
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   504
        Dprint( (_L("RSCPClient::SetPhoneLock()setting KSCPStartupQuery") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   505
        delete lRepository;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   506
        }
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
    Dprint( (_L("<-- RSCPClient::SetPhoneLock(): %d"), ret ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
    return ret;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
    }   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   511
void RSCPClient::InformAutolockTask()
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   512
    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   513
    Dprint( (_L("RSCPClient::InformAutolockTask") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   514
    // Deactivation call, send the deactivation message to Autolock
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   515
        RWsSession wsSession;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   516
        if ( wsSession.Connect() != KErrNone )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   517
           {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   518
           Dprint( (_L("RSCPClient::InformAutolockTask():\
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   519
               WsSession connection failed") ));        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   520
           User::Leave( KErrGeneral );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   521
           }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   522
        CleanupClosePushL( wsSession );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   523
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   524
        TApaTaskList taskList( wsSession );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   525
        TApaTask task = taskList.FindApp( TUid::Uid( 0x100059B5 ) ); // Autolock
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   526
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   527
        if ( task.Exists() )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   528
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   529
            Dprint( (_L("RSCPClient::InformAutolockTask():\
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   530
               Autolock task found, sending msg") ));        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   531
            // No parameters, just a dummy buffer
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   532
            TBuf8<8> buf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   533
            buf.Zero();            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   534
            const TPtrC8& message = buf;                      
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   535
            User::LeaveIfError( 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   536
               task.SendMessage( TUid::Uid( SCP_CMDUID_UNLOCK+1 ), message ) 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   537
               );           
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   538
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   539
        else
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   540
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   541
            Dprint( (_L("RSCPClient::InformAutolockTask():\
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   542
               Autolock task not found") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   543
            User::Leave( KErrNotFound );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   544
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   545
                  
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   546
        CleanupStack::PopAndDestroy(); // wsSession
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   547
    }   
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   548
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
// TBool RSCPClient::QueryAdminCmd( TSCPAdminCommand aCommand )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
// Packs the command parameter into a buffer, and propagates
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
// the call to the server, the response is received in the
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
// same buffer.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
EXPORT_C TBool RSCPClient::QueryAdminCmd( TSCPAdminCommand aCommand )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
    Dprint( (_L("--> RSCPClient::QueryAdminCmd()") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
    TInt status = 0;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
    TPckg<TInt> retPackage(status);
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
    TInt ret = SendReceive( ESCPServQueryAdminCmd, TIpcArgs( aCommand, &retPackage ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
    Dprint( (_L("<-- RSCPClient::QueryAdminCmd(): %d"), retPackage() ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
    return static_cast<TBool>( status );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
    }   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
// TInt RSCPClient::GetLockState( TBool& aState )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
// Package the parameter, and send it to the server.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
EXPORT_C TInt RSCPClient::GetLockState( TBool& aState )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
    Dprint( (_L("--> RSCPClient::GetLockState()") )); 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
      
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
    TPckg<TBool> retPackage(aState);
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
    TInt ret = SendReceive( ESCPServGetLockState, TIpcArgs( &retPackage ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
     
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
    Dprint( (_L("<-- RSCPClient::GetLockState(): %d"), retPackage() ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
    return ret;            
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
// TInt RSCPClient::GetParamValue( TInt aParamID, TDes& aValue )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
// The server contains all the logic for the parameters, just 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
// propagate the call.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
EXPORT_C TInt RSCPClient::GetParamValue( TInt aParamID, TDes& aValue )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
    Dprint( (_L("--> RSCPClient::GetParamValue()") ));  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
    TInt ret = SendReceive( ESCPServGetParam, TIpcArgs( aParamID, &aValue ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
     
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
    Dprint( (_L("<-- RSCPClient::GetParamValue(): %d"), ret));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
    return ret;            
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
// TInt RSCPClient::SetParamValue( TInt aParamID, TDes& aValue )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
// The server contains all the logic for the parameters, just 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
// propagate the call.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
EXPORT_C TInt RSCPClient::SetParamValue( TInt aParamID, TDes& aValue )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
    Dprint( (_L("--> RSCPClient::SetParamValue()") ));  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
    TInt ret = SendReceive( ESCPServSetParam, TIpcArgs( aParamID, &aValue ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
     
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
    Dprint( (_L("<-- RSCPClient::SetParamValue(): %d"), ret ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
    return ret;            
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
    }    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
// *********** Device lock new features ************* -->>
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   631
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   632
// RSCPClient::SecCodeQuery()
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   633
// Request the security code from the user and authenticate
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   634
// through the server.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   635
// 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   636
// Status : Approved
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   637
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   638
//
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   639
EXPORT_C TInt RSCPClient::SecCodeQuery( RMobilePhone::TMobilePassword& aPassword, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   640
                                        TSCPButtonConfig aButtonsShown, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   641
                                        TBool aECSSupport,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   642
                                        TInt aFlags )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   643
    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   644
    TInt lErr = KErrNone;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   645
    TInt lStatus = KErrNone;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   646
    TInt lResFileSCP = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   647
    TInt lResFileSecUi = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   648
    Dprint( (_L("--> RSCPClient::SecCodeQuery(%d, %d"), aButtonsShown, aECSSupport ));  
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   649
    TRAP(lErr, lStatus = SetSecurityCodeL(aPassword, aButtonsShown, aECSSupport, aFlags, lResFileSCP, lResFileSecUi));    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   650
   
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   651
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   652
    if(lResFileSCP) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   653
        CCoeEnv :: Static()->DeleteResourceFile(lResFileSCP);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   654
	}
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   655
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   656
    if(lResFileSecUi) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   657
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   658
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   659
        CCoeEnv :: Static()->DeleteResourceFile(lResFileSecUi);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   660
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   661
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   662
    Dprint((_L("<-- RSCPClient::SecCodeQuery(): lStatus= %d, lErr= %d"), lStatus, lErr));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   663
    CRepository* lRepository = NULL;  
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   664
    TInt startup = 0;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   665
    TInt returnv;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   666
    TRAP(returnv, lRepository = CRepository :: NewL(KCRUidSCPLockCode));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   667
    returnv = lRepository->Get(KSCPStartupQuery, startup);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   668
    if(returnv == KErrNone)
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   669
    Dprint( (_L("RSCPClient::SecCodeQuery()KSCPStartupQuery get done")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   670
    lRepository->Set(KSCPStartupQuery, 0);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   671
    delete lRepository;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   672
    Dprint((_L("RSCPClient::SecCodeQuery(): startup ? %d"), startup ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   673
    //Check if this is Startup Query and tht device is remote unlocked now ?
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   674
    if(startup)
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   675
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   676
        Dprint((_L("[RSCPClient] SecCodeQuery() startup remote Unlocked")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   677
        return KErrNone;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   678
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   679
    else
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   680
    return (lErr != KErrNone) ? lErr : lStatus;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   681
}
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   682
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   683
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   684
// RSCPClient::ChangeCodeRequest()
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   685
// Show the current code query dialog and continue in GetNew
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   686
// CodeAndChange.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   687
// 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   688
// Status : Approved
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   689
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   690
//
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   691
EXPORT_C TInt RSCPClient::ChangeCodeRequest()
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   692
    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   693
    Dprint((_L("[RSCPClient] ChangeCodeRequest() >>>")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   694
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   695
    if(EFalse == isFlagEnabled) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   696
        Dprint((_L("[RSCPClient]-> ChangeCodeRequest(): ERROR: Function not supported in this variant")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   697
        User :: Invariant();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   698
        return KErrNotSupported;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   699
	}
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   700
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   701
    TInt lRet(KErrNone);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   702
    TInt lErr(KErrNone);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   703
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   704
    TInt resourceFileSCP(NULL);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   705
    TInt resourceFileSecUi(NULL);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   706
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   707
    // Check if the code change is allowed
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   708
    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   709
        HBufC8* addParamsHBuf = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   710
        TRAP(lErr, addParamsHBuf = HBufC8 :: NewL(KSCPMaxTARMNotifParamLen));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   711
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   712
        if(lErr != KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   713
            return lErr;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   714
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   715
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   716
        TPtr8 addParams = addParamsHBuf->Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   717
        addParams.Zero();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   718
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   719
        TInt status(KErrNone);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   720
        TPckg<TInt> retPackage(status);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   721
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   722
        TInt ret = SendReceive(ESCPServCodeChangeQuery, TIpcArgs(&retPackage, &addParams));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   723
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   724
        if((ret == KErrNone) && (addParams.Length() > 0)) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   725
            // The server has sent additional parameters, ignore errors in processing
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   726
            TRAP_IGNORE(ProcessServerCommandsL(addParams));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   727
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   728
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   729
        delete addParamsHBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   730
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   731
        if((ret != KErrNone) || (status != KErrNone)) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   732
            // Password cannot be changed now
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   733
            return KErrAbort;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   734
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   735
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   736
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   737
    // Load the required resource files into this process
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   738
    lRet = LoadResources(resourceFileSCP, resourceFileSecUi);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   739
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   740
    if(lRet != KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   741
        return lRet;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   742
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   743
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   744
    HBufC* codeHBuf = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   745
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   746
    TRAP(lErr, codeHBuf = HBufC :: NewL(KSCPPasscodeMaxLength + 1));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   747
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   748
    if(lErr != KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   749
        // Remove the resource files
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   750
        CCoeEnv :: Static()->DeleteResourceFile(resourceFileSCP);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   751
        CCoeEnv :: Static()->DeleteResourceFile(resourceFileSecUi);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   752
        return lErr;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   753
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   754
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   755
    TPtr codeBuffer = codeHBuf->Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   756
    codeBuffer.Zero();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   757
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   758
    TInt def_code = -1;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   759
    CRepository* lRepository = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   760
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   761
    TRAP(lErr, lRepository = CRepository :: NewL(KCRUidSCPLockCode));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   762
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   763
    if(KErrNone == lErr) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   764
        lErr = lRepository->Get(KSCPLockCodeDefaultLockCode, def_code);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   765
       
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   766
        if(def_code == 0) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   767
            TRAP(lErr, lRet = RunDialogL(codeBuffer, SCP_OK_CANCEL, KSCPPasscodeMinLength,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   768
                                     KSCPPasscodeMaxLength, R_SECUI_TEXT_ENTER_SEC_CODE));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   769
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   770
            if((lRet) && (lErr == KErrNone) && (lRet != ESecUiEmergencyCall)) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   771
                lErr = GetNewCodeAndChange(codeBuffer, KSCPNormalChange);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   772
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   773
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   774
            if(lErr != KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   775
                Dprint((_L("RSCPClient::ChangeCodeRequest(): Code change FAILED: %d"), lErr));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   776
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   777
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   778
            if(((!lRet) && (lErr == KErrNone)) || (lRet == ESecUiEmergencyCall)) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   779
                // Cancelled by user
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   780
                lErr = KErrAbort;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   781
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   782
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   783
        else if(def_code != -1) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   784
            _LIT(KText, "12345");
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   785
            TBufC<10> NBuf (KText);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   786
            TPtr codeBuf = NBuf.Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   787
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   788
            lErr = GetNewCodeAndChange(codeBuf, KSCPNormalChange);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   789
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   790
            if(lErr == KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   791
                lRepository->Set(KSCPLockCodeDefaultLockCode, 0);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   792
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   793
            else {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   794
                Dprint((_L("RSCPClient::ChangeCodeRequest(): Code change FAILED automatic: %d"), lErr));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   795
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   796
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   797
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   798
        delete lRepository;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   799
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   800
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   801
    Dprint((_L("<-- RSCPClient::ChangeCodeRequest(): %d"), lErr ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   802
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   803
    // Remove the resource files
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   804
    CCoeEnv :: Static()->DeleteResourceFile(resourceFileSCP);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   805
    CCoeEnv :: Static()->DeleteResourceFile(resourceFileSecUi);    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   806
    delete codeHBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   807
    return lErr;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   808
}
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
// RSCPClient::CheckConfiguration()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
// Ask the server if the configuration is OK
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   817
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
EXPORT_C TInt RSCPClient::CheckConfiguration( TInt aMode )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
    {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   820
    Dprint( (_L("--> RSCPClient::CheckConfiguration()") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   821
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   822
    TInt status = 0;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   823
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
    TPckg<TInt> retPackage(status);    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
    TInt ret = SendReceive(ESCPServCheckConfig, TIpcArgs( aMode, &retPackage ) );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   828
    if ( ret == KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   829
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
        ret = status;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   832
        if ( status == KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   833
            {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   834
            Dprint( (_L("RSCPClient::CheckConfiguration(): Configuration OK") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
            }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
        else if ( status == KErrAccessDenied )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
            {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
            if ( aMode == KSCPInitial )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
                {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
                Dprint( (_L("RSCPClient::CheckConfiguration(): Initial check failed") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
                }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
            else
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
                {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
                Dprint( (_L("RSCPClient::CheckConfiguration(): WARNING:\
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
                   Configuration Out of sync") ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
                }            
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
            }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
        }                
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
    Dprint( (_L("<-- RSCPClient::CheckConfiguration(): %d"), status ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
    return ret;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   854
EXPORT_C TInt RSCPClient :: PerformCleanupL(RArray<TUid>& aAppIDs) {
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   855
    Dprint((_L("RSCPClient::PerformCleanupL() >>>")));
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
    TInt lCount = aAppIDs.Count();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
    if(lCount < 1) {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
        return KErrNone; 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   861
        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
    HBufC8* lBuff = HBufC8 :: NewLC(lCount * sizeof(TInt32));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
    TPtr8 lBufPtr = lBuff->Des();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
    RDesWriteStream lWriteStream(lBufPtr);
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
    CleanupClosePushL(lWriteStream);
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
    for(TInt i=0; i < lCount; i++) {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
        Dprint((_L("[RSCPClient]-> Marking %d for cleanup"), aAppIDs[i].iUid ));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
        lWriteStream.WriteInt32L(aAppIDs[i].iUid);
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
    }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
    lWriteStream.CommitL();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
    TInt lStatus = SendReceive(ESCPApplicationUninstalled, TIpcArgs(ESCPApplicationUninstalled, &lBuff->Des()));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
    CleanupStack :: PopAndDestroy(2); // lBuff, lWriteStream
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   874
    Dprint((_L("RSCPClient::PerformCleanupL() <<<")));
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
    return lStatus;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
}
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
// The server contains all the logic for the parameters, just
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
// propagate the call.
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
EXPORT_C TInt RSCPClient :: SetParamValue(TInt aParamID, TDes& aValue, TUint32 aCallerSID) {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
    Dprint((_L("RSCPClient::SetParamValue() >>>")));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
    TPckgBuf<TUint32> lCallerID(aCallerSID);
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
    TInt ret = SendReceive(ESCPServSetParam, TIpcArgs(aParamID, &aValue, &lCallerID));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
    Dprint((_L("RSCPClient::SetParamValue(): %d <<<"), ret));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
    return ret;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
}
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   890
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   891
/* ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
 * Alternative function that can be used to set the Auto Lock period
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
 * Caller should have AllFiles access level
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   894
 * Primarily called from the general settings components
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
*/
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
EXPORT_C TInt RSCPClient :: SetAutoLockPeriod( TInt aValue ) {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   898
    Dprint((_L("[RSCPClient]-> SetAutoLockPeriod() >>>")));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
    TPckgBuf<TInt> lAutoLockPeriod(aValue);
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
    TInt ret = SendReceive(ESCPServUISetAutoLock, TIpcArgs(&lAutoLockPeriod));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
    Dprint((_L("[RSCPClient]-> SetAutoLockPeriod(): %d <<<"), ret));
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
    return ret;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   903
}
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
//#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   906
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   907
// RSCPClient::GetNewCodeAndChange()
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   908
// Show the new code request and verification dialogs and
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   909
// send the change request to the server.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   910
// 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   911
// Status : Approved
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   912
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   913
//  
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   914
TInt RSCPClient::GetNewCodeAndChange( TDes& aOldCode, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   915
                                      TInt aMode,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   916
                                      TSCPSecCode* aNewDOSCode /*=NULL*/, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   917
                                      HBufC** aNewCodePptr/* = NULL*/)
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   918
    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   919
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   920
    Dprint(_L("[RSCPClient]-> GetNewCodeAndChange() >>>"));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   921
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   922
    if(!isFlagEnabled)
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   923
	{
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   924
		return KErrNotSupported;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   925
	}
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   926
    TInt err = KErrNone;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   927
    TInt ret = KErrNone;            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   928
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   929
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   930
    TInt maxLen = KSCPPasscodeMaxLength;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   931
    TInt minLen = 1;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   932
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   933
    // Fetch the minimum and maximum lengths for the code, if available.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   934
    // This feature is commented out for correction to BU error ID: BNIN-6LC3AP.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   935
    // Left in the code for possible inclusion in the future.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   936
    //FetchLimits( minLen, maxLen );        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   937
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   938
    // Request the new code and verify it. Repeat this until the codes match.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   939
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   940
    // Create the buffers on the heap
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   941
    HBufC* newCodeHBuf = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   942
    HBufC* verifyCodeHBuf = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   943
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   944
    TRAP( err, newCodeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 ) );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   945
    if ( err == KErrNone )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   946
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   947
        TRAP( err, verifyCodeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 ) );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   948
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   949
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   950
    if ( err != KErrNone )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   951
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   952
        if ( newCodeHBuf != NULL )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   953
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   954
            delete newCodeHBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   955
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   956
        return err; 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   957
        }    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   958
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   959
    TPtr newCodeBuffer = newCodeHBuf->Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   960
    TPtr verifyCodeBuffer = verifyCodeHBuf->Des();  
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   961
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   962
    // Configure the buttons according to the mode
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   963
    TSCPButtonConfig bConfig;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   964
    TBool ecSupport;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   965
    if ( aMode == KSCPForcedChange )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   966
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   967
        bConfig = SCP_OK_ETEL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   968
        ecSupport = ETrue;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   969
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   970
    else
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   971
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   972
        bConfig = SCP_OK_CANCEL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   973
        ecSupport = EFalse;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   974
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   975
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   976
    TBool isMismatch = EFalse;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   977
    do // Repeat loop BEGIN
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   978
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   979
        isMismatch = EFalse;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   980
                
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   981
        if ( err == KErrSCPInvalidCode )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   982
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   983
            err = KErrNone; // "reset"
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   984
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   985
                          
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   986
        newCodeBuffer.Zero(); 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   987
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   988
        TRAP( err, ret = RunDialogL( newCodeBuffer, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   989
                                 bConfig, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   990
                                 minLen,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   991
                                 maxLen,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   992
                                 R_SECUI_TEXT_ENTER_NEW_SEC_CODE,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   993
                                 NULL,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   994
                                 ecSupport) );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   995
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   996
        if ( ( ret ) && ( ret != ESecUiEmergencyCall ) && ( err == KErrNone ) )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   997
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   998
            verifyCodeBuffer.Zero();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
   999
            /*TChar ch = static_cast<TChar>(newCodeBuffer[0]);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1000
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1001
            CSCPQueryDialog :: TKeypadContext lKPContext =
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1002
                    (ch.IsDigit() ? CSCPQueryDialog :: ENumeric : CSCPQueryDialog :: EAlphaNumeric);*/
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1003
                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1004
            TRAP( err, ret = RunDialogL( verifyCodeBuffer, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1005
                                 bConfig, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1006
                                 minLen,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1007
                                 maxLen,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1008
                                 R_SECUI_TEXT_VERIFY_NEW_SEC_CODE,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1009
                                 NULL,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1010
                                 ecSupport));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1011
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1012
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1013
        if ( ( !ret ) || ( err != KErrNone ) || ( ret == ESecUiEmergencyCall ) )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1014
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1015
            break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1016
            }            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1017
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1018
        if  ( verifyCodeBuffer.Compare( newCodeBuffer ) != 0 )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1019
            {                        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1020
            // Ignore the errors from showing the note, it's better to continue if it fails
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1021
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1022
            TRAP_IGNORE(
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1023
                // Show an error note, the entered codes don't match             
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1024
                CAknNoteDialog* noteDlg = 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1025
                    new (ELeave) CAknNoteDialog(reinterpret_cast<CEikDialog**>( &noteDlg ) );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1026
                noteDlg->SetTimeout( CAknNoteDialog::ELongTimeout );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1027
                noteDlg->SetTone( CAknNoteDialog::EErrorTone );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1028
                noteDlg->ExecuteLD( R_CODES_DONT_MATCH );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1029
            );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1030
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1031
            isMismatch = ETrue; // Repeat code query
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1032
            }        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1033
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1034
        if ( !isMismatch )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1035
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1036
            HBufC8* addParamsHBuf = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1037
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1038
            TRAP( err, addParamsHBuf = HBufC8::NewL( KSCPMaxTARMNotifParamLen ) );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1039
            if ( err != KErrNone )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1040
                {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1041
                delete verifyCodeHBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1042
                delete newCodeHBuf;             
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1043
                return err;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1044
                }      
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1045
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1046
            TPtr8 addParams = addParamsHBuf->Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1047
            addParams.Zero();                                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1048
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1049
            if ( !isMismatch )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1050
                {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1051
                // Try to change the code
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1052
                TSCPSecCode newDOSCode;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1053
                newDOSCode.Zero();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1054
                
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1055
                err = SendReceive(  ESCPServChangeEnhCode, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1056
                            TIpcArgs( &aOldCode, &verifyCodeBuffer, &addParams, &newDOSCode ) 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1057
                         );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1058
                
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1059
                if ( addParams.Length() > 0 )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1060
                    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1061
                    // The server has sent additional parameters
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1062
                    TRAPD( err, ProcessServerCommandsL( addParams ) );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1063
                    if ( err != KErrNone )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1064
                        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1065
                        Dprint( (_L("RSCPClient::GetNewCodeAndChange():\
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1066
                            Process cmds FAILED: %d"), err ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1067
                        }                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1068
                    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1069
                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1070
                if ( aNewDOSCode != NULL )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1071
                    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1072
                    (*aNewDOSCode).Copy( newDOSCode );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1073
                    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1074
                }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1075
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1076
            delete addParamsHBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1077
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1078
                            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1079
        } while ( ( isMismatch ) || ( err == KErrSCPInvalidCode ) ); // Loop END
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1080
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1081
    if ( ( ( !ret ) && ( err == KErrNone ) ) || ( ret == ESecUiEmergencyCall ) )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1082
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1083
        // Cancelled by user
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1084
        err = KErrAbort;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1085
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1086
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1087
    if((KErrNone == err) && (aNewCodePptr != 0)) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1088
        Dprint(_L("[RSCPClient]-> INFO: Updating new lock code to aNewCodePptr"));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1089
        TRAP(err, *aNewCodePptr = HBufC :: NewL(verifyCodeHBuf->Des().Length()));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1090
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1091
        if(*aNewCodePptr != NULL) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1092
            (*aNewCodePptr)->Des().Copy(verifyCodeHBuf->Des());
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1093
            Dprint(_L("[RSCPClient]-> INFO: Updated new lock code to aNewCodePptr"));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1094
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1095
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1096
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1097
    delete verifyCodeHBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1098
    delete newCodeHBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1099
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1100
    Dprint(_L("[RSCPClient]-> GetNewCodeAndChange() <<<"));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1101
    return err;        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1102
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1103
       
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1104
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1105
        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1106
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1107
// RSCPClient::ProcessServerCommandsL()
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1108
// Handle the commands in the server's param-buffer
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1109
// 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1110
// Status : Approved
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1111
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1112
//
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1113
void RSCPClient::ProcessServerCommandsL( TDes8& aInParams, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1114
                                         CSCPParamObject** aOutParams,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1115
                                         TBool isNotifierEvent )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1116
    {    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1117
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1118
    if(!isFlagEnabled)
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1119
	{
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1120
		User::Leave(KErrNotSupported);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1121
	}
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1122
    Dprint( (_L("--> RSCPClient::ProcessServerCommandsL()") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1123
    (void)aOutParams;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1124
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1125
    CSCPParamObject* theParams = CSCPParamObject::NewL();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1126
    CleanupStack::PushL( theParams );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1127
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1128
    theParams->Parse( aInParams );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1129
    TInt actionID;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1130
    TInt ret = theParams->Get( KSCPParamAction, actionID );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1131
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1132
    Dprint( (_L("RSCPClient::ProcessServerCommandsL():Params parsed") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1133
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1134
    if ( ret != KErrNone )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1135
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1136
        Dprint( (_L("RSCPClient::ProcessServerCommands(): Can't get action ID: %d"), ret )); 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1137
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1138
    else
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1139
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1140
        switch ( actionID )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1141
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1142
            case ( KSCPActionShowUI ):
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1143
                {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1144
                TRAP( ret, ShowUIL( *theParams ) );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1145
                break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1146
                }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1147
                
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1148
            case ( KSCPActionForceChange ):
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1149
                {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1150
                if ( isNotifierEvent )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1151
                    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1152
                    break; // Calling this through the notifier would jam the system
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1153
                    // since the server is busy.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1154
                    }                                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1155
                
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1156
                HBufC* codeHBuf = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1157
                codeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 );    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1158
                CleanupStack::PushL( codeHBuf );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1159
                   
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1160
                TPtr codeBuf = codeHBuf->Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1161
                codeBuf.Zero(); 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1162
                
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1163
                ret = theParams->Get( KSCPParamPassword, codeBuf );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1164
				
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1165
                if ( ret == KErrNone )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1166
                    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1167
                    TInt lResFile = 0;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1168
                    TFileName resFile;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1169
                    resFile.Copy( KDriveZ );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1170
                    resFile.Append( KSCPTimestampPluginResFilename );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1171
                    BaflUtils :: NearestLanguageFile( CCoeEnv :: Static()->FsSession(), resFile );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1172
                    lResFile = CCoeEnv :: Static()->AddResourceFileL(resFile);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1173
					
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1174
                    CAknNoteDialog* lNoteDlg = new (ELeave) CAknNoteDialog(CAknNoteDialog :: ENoTone, CAknNoteDialog :: ELongTimeout);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1175
                    CleanupStack :: PushL(lNoteDlg);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1176
					
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1177
                    HBufC* lExpNoteMsg = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE_AGING);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1178
                    lNoteDlg->SetTextL(lExpNoteMsg->Des());
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1179
					
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1180
                    lNoteDlg->ExecuteLD(R_DIALOG_WARNING);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1181
                    CleanupStack :: PopAndDestroy(1); //lExpNoteMsg
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1182
                    CleanupStack :: Pop(1); //lNoteDlg
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1183
					
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1184
                    CCoeEnv :: Static()->DeleteResourceFile( lResFile );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1185
					
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1186
                    TSCPSecCode newDOSCode;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1187
                    ret = GetNewCodeAndChange( codeBuf, KSCPForcedChange, &newDOSCode );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1188
                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1189
                    // If aOutParams is defined, return the new code
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1190
                    if ( aOutParams != NULL )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1191
                        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1192
                        (*aOutParams) = CSCPParamObject::NewL();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1193
                        (*aOutParams)->Set( KSCPParamPassword, newDOSCode );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1194
                        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1195
                    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1196
                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1197
                CleanupStack::PopAndDestroy( codeHBuf );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1198
                                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1199
                break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1200
                }                            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1201
            }                
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1202
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1203
                       
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1204
    CleanupStack::PopAndDestroy( theParams );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1205
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1206
    Dprint( (_L("<-- RSCPClient::ProcessServerCommandsL()") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1207
    User::LeaveIfError( ret );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1208
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1209
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1210
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1211
// RSCPClient::ShowUI()
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1212
// Show the requested UI through AVKON
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1213
// 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1214
// Status : Approved
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1215
// ---------------------------------------------------------
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1216
//
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1217
void RSCPClient::ShowUIL( CSCPParamObject& aContext )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1218
    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1219
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1220
    if(!isFlagEnabled)
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1221
	{
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1222
		User::Leave(KErrNotSupported);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1223
	}
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1224
    Dprint( (_L("--> RSCPClient::ShowUIL()") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1225
    TInt mode;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1226
    User::LeaveIfError( aContext.Get( KSCPParamUIMode, mode ) );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1227
    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1228
    switch ( mode )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1229
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1230
        case ( KSCPUINote ):
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1231
            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1232
            // Get prompt
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1233
            TBuf<KSCPMaxPromptTextLen> promptText;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1234
            aContext.Get( KSCPParamPromptText, promptText );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1235
                        
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1236
            // Try to get note icon, default is to use "error"
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1237
            TInt noteType = KSCPUINoteError;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1238
            Dprint( (_L("RSCPClient::ShowUIL(): Creating note object") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1239
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1240
            CAknResourceNoteDialog* note = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1241
            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1242
            if ( aContext.Get( KSCPParamNoteIcon, noteType ) != KErrNone )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1243
                {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1244
                noteType = KSCPUINoteError;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1245
                }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1246
                
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1247
            switch ( noteType )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1248
                {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1249
                case ( KSCPUINoteWarning ):
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1250
                    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1251
                    note = new (ELeave) CAknWarningNote( ETrue );    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1252
                    break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1253
                    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1254
                    
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1255
                case ( KSCPUINoteError ):
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1256
                default: // default to error
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1257
                    {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1258
                    note = new (ELeave) CAknErrorNote( ETrue ); 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1259
                    break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1260
                    }                         
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1261
                }                                          
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1262
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1263
            if ( note != NULL )
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1264
                {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1265
                Dprint( (_L("RSCPClient::ShowUIL(): Showing note") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1266
                note->ExecuteLD( promptText );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1267
                }            
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1268
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1269
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1270
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1271
    Dprint( (_L("<-- RSCPClient::ShowUIL()") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1272
    } 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1273
       
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1274
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1275
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1276
// RSCPClient::FetchLimits()
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1277
// Retrieve the limit-parameter values if available
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1278
// 
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1279
// Status : Approved
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1280
// ---------------------------------------------------------
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1281
//
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1282
void RSCPClient::FetchLimits( TInt& aMin, TInt& aMax )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1283
    {        
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1284
    if(!isFlagEnabled)
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1285
	{
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1286
		return;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1287
	}      
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1288
    TInt maxLenID = RTerminalControl3rdPartySession::EPasscodeMaxLength;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1289
    TInt minLenID = RTerminalControl3rdPartySession::EPasscodeMinLength;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1290
    TBuf<KSCPMaxIntLength> intBuf;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1291
   
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1292
    intBuf.Zero();    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1293
    if ( GetParamValue( minLenID, intBuf ) != KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1294
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1295
        aMin = KSCPPasscodeMinLength;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1296
        }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1297
    else
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1298
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1299
        TLex lex( intBuf );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1300
        if ( ( lex.Val( aMin ) != KErrNone ) || ( aMin <= 0 ) )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1301
            {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1302
            aMin = KSCPPasscodeMinLength;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1303
            }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1304
        }                
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1305
    
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1306
    intBuf.Zero();
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1307
    if ( GetParamValue( maxLenID, intBuf ) != KErrNone )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1308
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1309
        aMax = KSCPPasscodeMaxLength;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1310
        }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1311
    else
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1312
        {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1313
        TLex lex( intBuf );
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1314
        if ( ( lex.Val( aMax ) != KErrNone ) || ( aMax <= 0 ) )
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1315
            {
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1316
            aMax = KSCPPasscodeMaxLength;
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1317
            }
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1318
        }
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1319
    }              
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1320
TInt RSCPClient :: SetSecurityCodeL(RMobilePhone :: TMobilePassword& aPassword, 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1321
            TSCPButtonConfig aButtonsShown, TBool aECSSupport, TInt aFlags, TInt& aResFileSCP, TInt& aResFileSecUi) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1322
    Dprint((_L("[RSCPClient]-> SetSecurityCodeL() >>>")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1323
    Dprint((_L("[RSCPClient]-> input params - aButtonsShown=%d, aECSSupport=%d"), aButtonsShown, aECSSupport));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1324
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1325
    if(EFalse == isFlagEnabled) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1326
        (void)aPassword;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1327
        Dprint((_L("[RSCPClient]-> ERROR: Function not supported in this variant")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1328
        User :: Invariant();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1329
        return KErrNotSupported;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1330
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1331
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1332
    TInt lRet = LoadResources(aResFileSCP, aResFileSecUi);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1333
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1334
    if(lRet != KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1335
        return lRet;
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1336
    }
1
a9c0ce913924 Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1337
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1338
    TInt lDefCode = 0;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1339
    CRepository* lRepository = CRepository :: NewLC(KCRUidSCPLockCode);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1340
    lRet = lRepository->Get(KSCPLockCodeDefaultLockCode, lDefCode);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1341
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1342
    if(lRet != KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1343
        Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1344
        CleanupStack :: PopAndDestroy(lRepository);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1345
        return lRet;
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1346
    }
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1347
    TInt currentLawmoState(0); 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1348
    Dprint( (_L("CSCPClient::lawmo cenrep") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1349
    CRepository* crep = CRepository::NewLC( KCRUidDeviceManagementInternalKeys );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1350
    TInt reterr = crep->Get( KLAWMOPhoneLock, currentLawmoState ); 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1351
    Dprint( (_L("CSCPClient::lawmo cenrep done") ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1352
    if(reterr != KErrNone) 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1353
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1354
        Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep lawmo, lErr=%d"), lRet);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1355
        CleanupStack :: PopAndDestroy(crep);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1356
        return reterr;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1357
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1358
    HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1359
    HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1360
    TPtr codeBuffer = codeHBuf->Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1361
    TPtr8 addParams = addParamsHBuf->Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1362
    if(currentLawmoState!=KLockedbyLawmo)
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1363
        {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1364
        // rundialog with a new resource file
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1365
        Dprint((_L("[RSCPClient]-> lawmo current state !=30")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1366
        TBuf<255> serverId;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1367
        serverId.Zero();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1368
        reterr = crep->Get( KLAWMOfactoryDmServerName, serverId );
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1369
        Dprint( (_L("RSCPClient::SetSecurityCode serverid: %s"), serverId.PtrZ() ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1370
        HBufC* prompt = StringLoader::LoadLC(R_SCP_LAWMO_LOCKED, serverId);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1371
        Dprint( (_L("RSCPClient::SetSecurityCode stringval: %s"), (prompt->Des()).PtrZ() ));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1372
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1373
        lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1374
                        0, prompt, aECSSupport);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1375
		if((lRet) && (lRet != ESecUiEmergencyCall) && (lRet != EAknSoftkeyEmergencyCall)) 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1376
			{
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1377
			Dprint(_L("[RSCPClient]-> INFO: LL User has updated the lock code..."));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1378
			
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1379
			lRet = SendReceive( ESCPServAuthenticateS60, TIpcArgs( &codeBuffer, &aPassword, &addParams, aFlags));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1380
			
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1381
			Dprint((_L("[RSCPClient]-> INFO: LL addParams.Length()=%d")), addParams.Length());
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1382
			Dprint((_L("[RSCPClient]-> INFO: LL lRet=%d")), lRet);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1383
			}
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1384
		else
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1385
			{
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1386
	        switch(lRet) 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1387
	            {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1388
	            case 0:
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1389
	                lRet = KErrCancel;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1390
	                break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1391
	            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1392
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1393
        CleanupStack::PopAndDestroy(1);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1394
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1395
    else if(lDefCode == 0) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1396
        Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user..."));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1397
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1398
        lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength,
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1399
                R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1400
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1401
        if((lRet) && (lRet != ESecUiEmergencyCall) && (lRet != EAknSoftkeyEmergencyCall)) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1402
            Dprint(_L("[RSCPClient]-> INFO: User has updated the lock code..."));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1403
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1404
            lRet = SendReceive( ESCPServAuthenticateS60, TIpcArgs( &codeBuffer, &aPassword, &addParams, aFlags));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1405
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1406
            Dprint((_L("[RSCPClient]-> INFO: addParams.Length()=%d")), addParams.Length());
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1407
            Dprint((_L("[RSCPClient]-> INFO: lRet=%d")), lRet);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1408
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1409
        else {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1410
            switch(lRet) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1411
            case 0:
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1412
				lRet = KErrCancel;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1413
				break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1414
            case EAknSoftkeyEmergencyCall:
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1415
                //lRet = KErrCancel;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1416
                break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1417
            case ESecUiEmergencyCall:
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1418
                lRet = ESecUiEmergencyCall;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1419
                break;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1420
            /*default:
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1421
                break;*/
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1422
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1423
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1424
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1425
    else {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1426
        TRequestStatus statusSave;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1427
        Dprint(_L("[RSCPClient]-> INFO: Default lock code not set by the user, requesting for the same"));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1428
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1429
        HBufC* msgConfirmSave = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1430
        CAknGlobalConfirmationQuery* query = CAknGlobalConfirmationQuery :: NewLC();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1431
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1432
        if(aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1433
            //msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1434
             msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE_SETTING_QUERY_SERVER);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1435
            query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_OK_EMPTY__OK, R_QGN_NOTE_INFO_ANIM);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1436
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1437
        else {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1438
            msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1439
        	query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_YES_NO__YES, R_QGN_NOTE_QUERY_ANIM);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1440
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1441
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1442
        User :: WaitForRequest(statusSave);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1443
        CleanupStack :: PopAndDestroy(2); // msgConfirmSave query
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1444
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1445
        if((statusSave == EAknSoftkeyYes) || (statusSave == EAknSoftkeyOk)) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1446
            Dprint(_L("[RSCPClient]-> INFO: calling GetNewCodeAndChange() ..."));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1447
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1448
            TBufC<10> NBuf(KSCPDefaultEnchSecCode);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1449
            TPtr codeBuf = NBuf.Des();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1450
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1451
            TSCPSecCode lNewSecCode;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1452
            TInt lButtonCfg = (aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) ? KSCPForcedChange : KSCPNormalChange;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1453
            HBufC* lNewLkCodeBuf = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1454
            lRet = GetNewCodeAndChange(codeBuf, lButtonCfg, &lNewSecCode, &lNewLkCodeBuf);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1455
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1456
            Dprint(_L("[RSCPClient]-> INFO: GetNewCodeAndChange() complete, err=%d"), lRet);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1457
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1458
            if(KErrNone == lRet) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1459
                /* This is being called as a workaround for a freezing issue with SecUI. This is in place
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1460
                 * as a temporary measure until the source is identified.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1461
                */
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1462
                TInt lTmpRet = SendReceive(ESCPServAuthenticateS60, TIpcArgs(&lNewLkCodeBuf->Des(), &aPassword, &addParams, aFlags));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1463
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1464
                Dprint(_L("[RSCPClient]-> INFO: lTmpRet from SendReceive()=%d"), lTmpRet);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1465
                if(KErrNone == lRet) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1466
                    Dprint(_L("[RSCPClient]-> INFO: updating CenRep ..."));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1467
                    lRepository->Set(KSCPLockCodeDefaultLockCode, 0);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1468
                    Dprint(_L("[RSCPClient]-> INFO: User updated lock code for the first time...err= %d"), lRet);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1469
                }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1470
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1471
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1472
            if(lNewLkCodeBuf) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1473
                delete lNewLkCodeBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1474
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1475
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1476
        else {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1477
            Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel"));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1478
            lRet = KErrCancel;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1479
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1480
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1481
        if(KErrAbort == lRet) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1482
            Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel"));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1483
            lRet = KErrCancel;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1484
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1485
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1486
    }
1
a9c0ce913924 Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
  1487
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1488
    if(addParams.Length() > 0) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1489
        CSCPParamObject* tmp = CSCPParamObject :: NewLC();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1490
        TInt lTempRet = tmp->Parse(addParams);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1491
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1492
        if(lTempRet == KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1493
            lTempRet = tmp->Set(KSCPParamPassword, codeBuffer);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1494
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1495
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1496
        if(lTempRet == KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1497
            addParams.Zero();
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1498
            HBufC8* tmpBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1499
            lTempRet = tmp->GetBuffer(tmpBuf);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1500
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1501
            if(lTempRet == KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1502
                addParams.Copy(tmpBuf->Des());
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1503
                delete tmpBuf;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1504
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1505
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1506
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1507
        if(lTempRet == KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1508
            CSCPParamObject* outParams = NULL;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1509
            /*
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1510
             * aECSSupport when passed to ProcessServerCommandsL decides if the expiry note and subsequently change device lock
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1511
             * code has to be shown or not. Normally if the lock code has expired, the same has to be prompted from the user and 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1512
             * has to be done only during device unlock. aECSSupport value is being passed to ensure that new lock code is prompted
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1513
             * only during device unlock.
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1514
             */
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1515
            ProcessServerCommandsL(addParams, &outParams, !aECSSupport);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1516
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1517
            if(outParams != NULL) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1518
                TSCPSecCode newSecCode;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1519
                if(outParams->Get(KSCPParamPassword, newSecCode) == KErrNone) {
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1520
                    Dprint((_L("[RSCPClient]-> INFO: Updating encoded password received from the server into aPassword...")));
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1521
                    aPassword.Copy(newSecCode);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1522
                }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1523
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1524
                delete outParams;
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1525
            }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1526
        }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1527
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1528
        CleanupStack :: PopAndDestroy(tmp);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1529
    }
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1530
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1531
    CleanupStack :: PopAndDestroy(4); // repository * 2, addParamsHBuf, codeHBuf 
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1532
    Dprint(_L("[RSCPClient]-> SetSecurityCodeL() <<< lRet=%d"), lRet);
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1533
    return lRet;
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1534
}
62
19bba8228ff0 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 61
diff changeset
  1535
0
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1536
//#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1537
// <<-- *********** Device lock new features *************
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1538
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1539
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1540
// ================= OTHER EXPORTED FUNCTIONS ==============
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1541
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1542
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1543
//  End of File  
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1544
b497e44ab2fc Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1545