securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp
author hgs
Thu, 08 Jul 2010 20:04:36 +0300
changeset 35 f1030a78d563
parent 30 cc1cea6aabaf
child 39 61986511a9c8
permissions -rw-r--r--
201027_01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
     2
 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
     3
 * All rights reserved.
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
     4
 * This component and the accompanying materials are made available
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
     6
 * which accompanies this distribution, and is available
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
     8
 *
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
     9
 * Initial Contributors:
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    10
 * Nokia Corporation - initial contribution.
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    11
 *
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    12
 * Contributors:
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    13
 *
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    14
 * Description:  Provides api for handling security events.
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    15
 *
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    16
 *
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    17
 */
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
    18
#include <e32notif.h>
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <aknnotedialog.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <etelmm.h>
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
    21
// #include <SecUi.rsg>
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <exterror.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <textresolver.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#ifdef __COVER_DISPLAY
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <aknmediatorfacade.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#endif //__COVER_DISPLAY
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <centralrepository.h> 
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <e32property.h>
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
    30
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include <PSVariables.h>   // Property values
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include <coreapplicationuisdomainpskeys.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include <startupdomainpskeys.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include <uikon/eiksrvui.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include <settingsinternalcrkeys.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include <securityuisprivatepskeys.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include <AknNotiferAppServerApplication.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include <SCPClient.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include <securitynotification.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include "secui.hrh"
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
    42
#include "SecUi.h"
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#include "secuisecurityhandler.h"
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#include "secuicodequerydialog.h"
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
#include "secuisecuritysettings.h"
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include "SecUiWait.h"
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
    47
// #include "SecUiLockObserver.h"
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#include <RemoteLockSettings.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
#include <StringLoader.h>
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
#include <featmgr.h>
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    51
#include <hb/hbcore/hbtextresolversymbian.h>
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    52
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    53
#include "SecQueryUi.h"
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    54
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
//  LOCAL CONSTANTS AND MACROS
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
const TInt KMaxNumberOfPUKAttempts(10);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
const TInt KMaxNumberOfPINAttempts(3);
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    58
// not used
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    59
// const TInt KLastRemainingInputAttempt(1);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    61
const TInt KTriesToConnectServer(2);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    62
const TInt KTimeBeforeRetryingRequest(50000);
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    63
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
// ================= MEMBER FUNCTIONS =======================
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
// CSecurityHandler::CSecurityHandler()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
// C++ constructor
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    70
// qtdone
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    71
EXPORT_C CSecurityHandler::CSecurityHandler(RMobilePhone& aPhone) :
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    72
    iPhone(aPhone), iQueryCanceled(ETrue), iSecurityDlg(NULL), iNoteDlg(NULL)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
    {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    74
    RDEBUG("0", 0);
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    75
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    76
    TInt result = iCustomPhone.Open(aPhone);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    77
    RDEBUG("result", result);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    78
    TRAP_IGNORE(FeatureManager::InitializeLibL()); //Shouldn't this panic if FM does not initialise??
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    79
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    80
    _LIT(KFileName, "secui_");
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    81
    _LIT(KPath, "z:/resource/qt/translations/");
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    82
    RDEBUG("HbTextResolverSymbian", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    83
    result = HbTextResolverSymbian::Init(KFileName, KPath);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
    84
    RDEBUG("result", result);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
// CSecurityHandler::~CSecurityHandler()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
// Destructor
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
    92
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
EXPORT_C CSecurityHandler::~CSecurityHandler()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    95
    RDEBUG("0", 0);
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    96
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
    97
    if (iDestroyedPtr)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
        {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
        *iDestroyedPtr = ETrue;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
        iDestroyedPtr = NULL;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
        }
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   102
    RDEBUG("calling CancelOpenQuery", 0);
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   103
    TInt err = CancelOpenQuery(-1);
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   104
    RDEBUG("err", err);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
    iCustomPhone.Close();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    FeatureManager::UnInitializeLib();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   107
    RDEBUG("1", 1);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
// CSecurityHandler::HandleEventL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
// Handles different security events
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   114
// qtdone
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   115
EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   117
    RDEBUG("0", 0);
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   118
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    TInt result = KErrNone;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   120
    HandleEventL(aEvent, result);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   121
    }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   122
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   123
//
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   124
// ----------------------------------------------------------
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   125
// CSecurityHandler::HandleEventL()
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   126
// Handles different security events
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   127
// ----------------------------------------------------------
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   128
// qtdone
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   129
EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent, TBool aStartup, TInt& aResult)
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   130
    {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   131
    RDEBUG("0", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   132
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   133
    iStartup = aStartup;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   134
    HandleEventL(aEvent, aResult);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
// CSecurityHandler::HandleEventL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
// Handles different security events
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   142
// qtdone
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   143
EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent, TInt& aResult)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   145
    RDEBUG("0", 0);
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   146
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   148
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   149
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   150
     *****************************************************/
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   151
    TBool wcdmaSupported(FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   152
    TBool upinSupported(FeatureManager::FeatureSupported(KFeatureIdUpin));
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   153
    RDEBUG("aEvent", aEvent);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   154
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   155
    switch (aEvent)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   156
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   157
        case RMobilePhone::EPin1Required:
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   158
            RDEBUG("RMobilePhone::EPin1Required", 0)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   159
            ;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   160
            aResult = Pin1RequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   161
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   162
        case RMobilePhone::EPuk1Required:
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   163
            RDEBUG("RMobilePhone::EPuk1Required", 0)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   164
            ;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   165
            Puk1RequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   166
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   167
        case RMobilePhone::EPin2Required:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   168
            Pin2RequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   169
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   170
        case RMobilePhone::EPuk2Required:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   171
            Puk2RequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   172
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   173
        case RMobilePhone::EUniversalPinRequired:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   174
            if (wcdmaSupported || upinSupported)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   175
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   176
                aResult = UPinRequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   177
                }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   178
            else
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   179
                aResult = KErrNotSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   180
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   181
        case RMobilePhone::EUniversalPukRequired:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   182
            if (wcdmaSupported || upinSupported)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   183
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   184
                aResult = UPukRequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   185
                }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   186
            else
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   187
                aResult = KErrNotSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   188
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   189
        case RMobilePhone::EPhonePasswordRequired:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   190
            aResult = PassPhraseRequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   191
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   192
        case RMobilePhone::EICCTerminated:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   193
            SimLockEventL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   194
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   195
        default:
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   196
            RDEBUG("default", aEvent)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   197
            ;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   198
            break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   199
        }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   200
    RDEBUG("aResult", aResult);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
// CSecurityHandler::AskSecCodeL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
// For asking security code e.g in settings
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   207
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
EXPORT_C TBool CSecurityHandler::AskSecCodeL()
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   209
    {
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   211
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   212
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   213
     *****************************************************/
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   214
    RDEBUG("0", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   215
    // if code is still not initialized, then there's no need to ask it. This fixes the error when the RFS requests the code.
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   216
    const TUid KCRUidSCPLockCode =
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   217
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   218
        0x2002677B
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   219
        };
1
d5423fbb4f29 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   220
    const TUint32 KSCPLockCodeDefaultLockCode = 0x00000001;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   221
1
d5423fbb4f29 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   222
    CRepository* repository = CRepository::NewL(KCRUidSCPLockCode);
d5423fbb4f29 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   223
    TInt currentLockStatus = -1;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   224
    TInt res = -1;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   225
    TInt lAlphaSupported = 0;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   226
    TInt lCancelSupported = 0;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   227
    RMobilePhone::TMobilePassword iSecUi_password;
1
d5423fbb4f29 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   228
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   229
    res = repository->Get(KSCPLockCodeDefaultLockCode, currentLockStatus);	// 0x3039 = 12345
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   230
    RDEBUG("res", res);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   231
    RDEBUG("currentLockStatus", currentLockStatus);
1
d5423fbb4f29 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   232
    delete repository;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   233
    if (res == 0 && (currentLockStatus == 1 || currentLockStatus == 12345) )
1
d5423fbb4f29 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   234
        {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   235
        // code is the default one
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   236
        RDEBUG("code is the default one; supply as default", 1);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   237
        iSecUi_password.Copy(_L("12345"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   238
        // RDEBUG("code is the default one; no need to request it", 1);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   239
        // return ETrue;
1
d5423fbb4f29 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   240
        }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   241
    // end check for default code
1
d5423fbb4f29 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   242
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    RMobilePhone::TMobilePassword required_fourth;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   244
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
    TInt ret = KErrNone;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    TInt status = KErrNone;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   247
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   248
    TInt queryAccepted = KErrCancel;
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   249
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   250
    while (queryAccepted != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   251
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   252
        RMobilePhone::TMobilePhoneSecurityCode secCodeType;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   253
        secCodeType = RMobilePhone::ESecurityCodePhonePassword;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   255
        /* request PIN using QT */
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   256
        CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   257
        RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   258
        iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   259
        iQueryCanceled = EFalse;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   260
        lAlphaSupported = ESecUiAlphaSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   261
        lCancelSupported = ESecUiCancelSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   262
        TBuf<0x100> title;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   263
        title.Zero();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   264
        HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("AskSecCodeL"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   265
        title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   266
        CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   267
        title.Append(_L("$"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   268
        title.AppendNum(-1);	// Don't know the number of remaining attempts
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   269
        queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, SEC_C_SECURITY_CODE_MAX_LENGTH, ESecUiSecretSupported | lAlphaSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   270
                | lCancelSupported | secCodeType);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   271
        RDEBUG("iSecUi_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   272
        RDEBUGSTR(iSecUi_password);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   273
        RDEBUG("delete", 0);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   274
        iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   275
        delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   276
        RDEBUG("queryAccepted", queryAccepted);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   277
        /* end request PIN using QT */
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   278
        if (queryAccepted != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   279
            {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   280
            ret = EFalse;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   281
            return ret;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   282
            }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   283
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   284
        CWait* wait = CWait::NewL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   285
        RDEBUG("VerifySecurityCode", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   286
        iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   287
        RDEBUG("WaitForRequestL", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   288
        status = wait->WaitForRequestL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   289
        RDEBUG("status", status);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   290
        delete wait;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   291
#ifdef __WINS__
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   292
        if (status == KErrNotSupported || status == KErrTimedOut)
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   293
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   294
            RDEBUG("status", status);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   295
            status = KErrNone;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   296
            }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   297
#endif
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   298
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   299
        ret = ETrue;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   300
        queryAccepted = KErrCancel; // because it's not yet validated
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   301
        switch (status)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   302
            {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   303
            case KErrNone:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   304
                {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   305
                if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw) && !(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
                    {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   307
                    RDEBUG("calling RSCPClient", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   308
                    RSCPClient scpClient;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   309
                    User::LeaveIfError(scpClient.Connect());
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   310
                    CleanupClosePushL(scpClient);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   312
                    TSCPSecCode newCode;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   313
                    RDEBUG("iSecUi_password", 1);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   314
                    RDEBUGSTR(iSecUi_password);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   315
                    newCode.Copy(iSecUi_password);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   316
                    RDEBUG(
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   317
                            "!!!!!!! ***** deprecated **** !!!!! scpClient.StoreCode",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   318
                            0);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   319
                    scpClient.StoreCode(newCode);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   320
                    RDEBUG("called StoreCode", 1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   321
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   322
                    CleanupStack::PopAndDestroy(); //scpClient
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   323
                    queryAccepted = KErrNone;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   324
                    }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   326
                iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   327
                return ETrue;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   328
                }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   329
            case KErrGsmSSPasswordAttemptsViolation:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   330
            case KErrLocked:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   331
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   332
                // security code blocked! 
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   333
                CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   334
                break;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   335
                }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   336
            case KErrGsm0707IncorrectPassword:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   337
            case KErrAccessDenied:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   338
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   339
                // code was entered erroneusly
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   340
                CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   341
                break;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   342
                }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   343
            default:
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   344
                {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   345
                CSecuritySettings::ShowResultNoteL(status, CAknNoteDialog::EErrorTone);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   346
                }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   347
            }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
        } // while
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
    iQueryCanceled = ETrue;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
    return ret;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   353
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
// ----------------------------------------------------------
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   355
// Cancels all security code queries
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   356
// aStatus = -1     from destructor
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   357
// aStatus =  1     from API. Will kill all dialogs through signal P&S
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   358
// ----------------------------------------------------------
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   359
// qtdone
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   360
TInt CSecurityHandler::CancelOpenQuery(TInt aStatus)
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   361
    {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   362
    RDEBUG("aStatus", aStatus);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   363
    RDEBUG("iQueryCanceled", iQueryCanceled);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   364
    TInt res = 0;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   365
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   366
    if (aStatus == 1) // also signal all other dialogs
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   367
        {
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   368
        RDEBUG(
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   369
                "set KSecurityUIsDismissDialog to ESecurityUIsDismissDialogOn",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   370
                ESecurityUIsDismissDialogOn);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   371
        TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   372
        RDEBUG("err", err);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   373
        res += 1;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   374
        }
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   375
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   376
    if (!iQueryCanceled)
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   377
        {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   378
        // notify all dialogs, in particular SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   379
        // this will cancel only the dialog which was opened by same client.
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   380
        res += 0x10;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   381
        iQueryCanceled = ETrue;
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   382
        if (iSecurityDlg != NULL)
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   383
            {
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   384
            RDEBUG("deleting iSecurityDlg", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   385
            res += 0x100;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   386
            delete iSecurityDlg;
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   387
            }
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   388
        if (iNoteDlg != NULL)
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   389
            {
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   390
            RDEBUG("deleting iNoteDlg", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   391
            res += 0x1000;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   392
            delete iNoteDlg;
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   393
            }
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   394
        iNoteDlg = NULL;
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   395
        iSecurityDlg = NULL;
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   396
        }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   397
    res += 0x10000;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   398
    RDEBUG("res", res);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   399
    return res;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   400
    }
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   401
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   402
//
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   403
// ----------------------------------------------------------
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
// CSecurityHandler::CancelSecCodeQuery()    
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
// Cancels PIN2 and security code queries
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   406
// this is used by rfsHandler
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   408
// qtdone
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   409
EXPORT_C void CSecurityHandler::CancelSecCodeQuery()
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
    {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   411
    RDEBUG("0", 0);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   412
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   413
    TInt err = CancelOpenQuery(1);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   414
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   415
    RDEBUG("err", err);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
// CSecurityHandler::AskSecCodeInAutoLock()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
// for asking security code in autolock
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   422
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
EXPORT_C TBool CSecurityHandler::AskSecCodeInAutoLockL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   426
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   427
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   428
     *****************************************************/
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   429
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   430
    RDEBUG("0", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
    TInt res;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    CWait* wait;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   433
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   434
    RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
    RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   436
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
    // get autolock period from Central Repository.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    CRepository* repository = CRepository::NewL(KCRUidSecuritySettings);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
    TInt period = 0;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    res = repository->Get(KSettingsAutoLockTime, period);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
    delete repository;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   443
    RDEBUG("res", res);
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   444
    RDEBUG("period", period);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   445
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    if (res == KErrNone)
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
        {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
        // disable autolock in Domestic OS side too if autolock period is 0.
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   449
        if (period == 0)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   451
            RDEBUG("period", period);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
            // If remote lock is enabled, don't disable the domestic OS device lock
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
            // since that would render the RemoteLock useless.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
            // Instead just re-set the DOS lock to enabled which as a side effect
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
            // requests the security code from the user.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   458
            TBool remoteLockStatus(EFalse);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
            CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   461
            if (remoteLockSettings->GetEnabled(remoteLockStatus))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
                {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   463
                RDEBUG("0", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   464
                if (remoteLockStatus)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
                    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
                    // Remote lock is enabled
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
                    lockChange = RMobilePhone::ELockSetEnabled;
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   468
                    RDEBUG("lockChange", lockChange);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
                    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
                else
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
                    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
                    // Remote lock is disabled
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
                    lockChange = RMobilePhone::ELockSetDisabled;
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   474
                    RDEBUG("lockChange", lockChange);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
                    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
                }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
            else
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
                {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
                // Failed to get remote lock status
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   480
                RDEBUG("Failed", lockChange);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
                }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
            delete remoteLockSettings;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
            remoteLockSettings = NULL;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   486
            RDEBUG("lockChange", lockChange);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   487
            wait = CWait::NewL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   488
            RDEBUG("0", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   489
            // this also calls PassPhraseRequiredL ???
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   490
            RDEBUG("SetLockSetting", 1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   491
            iPhone.SetLockSetting(wait->iStatus, lockType, lockChange);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   492
            res = KErrNone;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   493
            RDEBUG("WaitForRequestL", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   494
            res = wait->WaitForRequestL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   495
            RDEBUG("res", res);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   496
            delete wait;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   497
            } // from   period == 0
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
        else
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   499
            { // ask security code
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   500
            RDEBUG("codeQueryNotifier 0", 0);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   501
            RNotifier codeQueryNotifier;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   502
            User::LeaveIfError(codeQueryNotifier.Connect());
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   503
            CWait* wait = CWait::NewL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   504
            CleanupStack::PushL(wait);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   505
            TInt queryResponse = 0;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   506
            TPckg<TInt> response(queryResponse);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   507
            RDEBUG("0", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   508
            TSecurityNotificationPckg params;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   509
            params().iEvent = static_cast<TInt> (RMobilePhone::EPhonePasswordRequired);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   510
            params().iStartup = EFalse;
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   511
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   512
            RDEBUG("StartNotifierAndGetResponse", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   513
            codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus, KSecurityNotifierUid, params, response);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   514
            // this will eventually call PassPhraseRequiredL
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   515
            RDEBUG("WaitForRequestL", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   516
            res = wait->WaitForRequestL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   517
            RDEBUG("WaitForRequestL", 1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   518
            RDEBUG("res", res);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   519
            CleanupStack::PopAndDestroy(); // wait
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   520
            if (res == KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   521
                res = queryResponse;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   522
            } // from   else period == 0
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   523
        RDEBUG("0", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
    else
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   526
        { // can't read repository for KSettingsAutoLockTime
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   527
        RDEBUG("KERRSOMETHING:Call SetLockSetting", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
        // If remote lock is enabled, don't disable the domestic OS device lock
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
        // since that would render the RemoteLock useless.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        // Instead just re-set the DOS lock to enabled which as a side effect
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
        // requests the security code from the user.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   534
        TBool remoteLockStatus(EFalse);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
        CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   537
        if (remoteLockSettings->GetEnabled(remoteLockStatus))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   539
            if (remoteLockStatus)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
                {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
                // Remote lock is enabled
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
                lockChange = RMobilePhone::ELockSetEnabled;
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   543
                RDEBUG("lockChange", lockChange);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
                }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
            else
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
                {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
                // Remote lock is disabled
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
                lockChange = RMobilePhone::ELockSetDisabled;
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   549
                RDEBUG("lockChange", lockChange);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
                }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
            }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
        else
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
            {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
            // Failed to get remote lock status
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   555
            RDEBUG("Failed", lockChange);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
            }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
        delete remoteLockSettings;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
        remoteLockSettings = NULL;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   561
        RDEBUG("0", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
        wait = CWait::NewL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   563
        RDEBUG("SetLockSetting", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   564
        iPhone.SetLockSetting(wait->iStatus, lockType, lockChange);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   565
        RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
        res = wait->WaitForRequestL();
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   567
        RDEBUG("WaitForRequestL res", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
        delete wait;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
        }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   570
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   571
    RDEBUG("res", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
    switch (res)
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
        {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
        case KErrNone:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
            {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   576
            return ETrue;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
            }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
        case KErrGsmSSPasswordAttemptsViolation:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
        case KErrLocked:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
        case KErrGsm0707IncorrectPassword:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
        case KErrAccessDenied:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
            {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   583
            RDEBUG("KErrAccessDenied", KErrAccessDenied);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   584
            return AskSecCodeInAutoLockL();
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
            }
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   586
        case KErrInUse:
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   587
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   588
            RDEBUG("KErrInUse", KErrInUse);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   589
            return EFalse;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   590
            }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   591
        case KErrDied:
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   592
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   593
            RDEBUG("KErrDied ", KErrDied);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   594
            return EFalse;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   595
            }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   596
        case KErrServerTerminated:
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   597
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   598
            RDEBUG("KErrServerTerminated ", KErrServerTerminated);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   599
            return EFalse;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   600
            }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   601
        case KErrServerBusy:
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   602
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   603
            RDEBUG("KErrServerBusy ", KErrServerBusy);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   604
            return EFalse;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   605
            }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
        case KErrAbort:
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   607
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   608
            RDEBUG("KErrAbort", KErrAbort);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   609
            return EFalse;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   610
            }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
        case KErrCancel:
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   612
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   613
            RDEBUG("KErrCancel", KErrCancel);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
            // user pressed "cancel"
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
            return EFalse;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   616
            }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
        default:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
            {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   619
            RDEBUG("default", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
            return AskSecCodeInAutoLockL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
            }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
// CSecurityHandler::PassPhraseRequired()    
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
// Handles PassPhraseRequired event
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   629
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
TInt CSecurityHandler::PassPhraseRequiredL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   633
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   634
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   635
     *****************************************************/
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   636
    RDEBUG("0", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
    TBool StartUp = iStartup;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   639
    RMobilePhone::TMobilePassword iSecUi_password;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
    RMobilePhone::TMobilePassword required_fourth;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   641
    TInt queryAccepted = KErrCancel;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   642
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   643
    TInt autolockState = 0;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   644
    TInt lCancelSupported = 0;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   645
    TInt lEmergencySupported = 0;
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   646
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   647
    TInt err(KErrGeneral);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   648
    err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   649
    RDEBUG("StartUp", StartUp);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   650
    RDEBUG("err", err);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   651
    if (!StartUp)
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   652
        {
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   653
        RDebug::Printf("%s %s (%u) might leave if StartUp=0 and err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   654
        User::LeaveIfError(err);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   655
        }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   656
    TBool isConditionSatisfied = EFalse;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   657
    TInt tarmFlag = 0;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   658
    if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
        {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   660
        TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   661
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   662
        if (tRet != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   663
            {
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   664
            RDEBUG("Warning: failed to get TARM Admin Flag state", tRet);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   665
            }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   666
        else
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   667
            {
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   668
            RDEBUG("TARM flag", tarmFlag);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   669
            }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   670
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   671
        if ((StartUp) || (tarmFlag & KSCPFlagResyncQuery))
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   672
            isConditionSatisfied = ETrue;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
    else
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
        {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   676
        if (StartUp)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   677
            isConditionSatisfied = ETrue;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   678
        }
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   679
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   680
    // Security code at bootup: No "cancel" softkey; Emergency calls enabled.
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   681
    RMobilePhone::TMobilePhoneSecurityCode secCodeTypeToAsk = RMobilePhone::ESecurityCodePhonePassword;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   682
    RDEBUG("isConditionSatisfied", isConditionSatisfied);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   683
    if (isConditionSatisfied)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   684
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   685
        // starter or special TARM. NoCancel+Emergency
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   686
        lCancelSupported = ESecUiCancelNotSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   687
        lEmergencySupported = ESecUiEmergencySupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   688
        }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   689
    else if (autolockState > EAutolockOff)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   690
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   691
        // from unlock. Cancel+Emergency
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   692
        lCancelSupported = ESecUiCancelSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   693
        lEmergencySupported = ESecUiEmergencySupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   694
        }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   695
    else
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   696
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   697
        // from settings. Cancel+NoEmergency
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   698
        lCancelSupported = ESecUiCancelSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   699
        lEmergencySupported = ESecUiEmergencyNotSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   700
        }
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   701
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   702
    CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   703
    iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   704
    iQueryCanceled = EFalse;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   705
    TInt lType = ESecUiSecretSupported | ESecUiAlphaSupported | lCancelSupported | lEmergencySupported | secCodeTypeToAsk;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   706
    RDEBUG("lType", lType);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   707
    TBuf<0x100> title;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   708
    title.Zero();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   709
    HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("PassPhraseRequiredL"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   710
    title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   711
    CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   712
    queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, SEC_C_SECURITY_CODE_MAX_LENGTH, lType);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   713
    RDEBUG("iSecUi_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   714
    RDEBUGSTR(iSecUi_password);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   715
    RDEBUG("queryAccepted", queryAccepted);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
   716
    iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   717
    delete iSecQueryUi;
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   718
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   719
    TBool wasCancelledOrEmergency = EFalse;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   720
    RDEBUG("KFeatureIdSapDeviceLockEnhancements",
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   721
            KFeatureIdSapDeviceLockEnhancements);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   722
    if ((queryAccepted == KErrAbort /* =emergency */) || (queryAccepted == KErrCancel))
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   723
        wasCancelledOrEmergency = ETrue;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   724
    RDEBUG("wasCancelledOrEmergency", wasCancelledOrEmergency);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   725
    if (wasCancelledOrEmergency)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
        {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   727
        RDEBUG("StartUp", StartUp);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
        if (!StartUp)
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
            {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   730
            RDEBUG("AbortSecurityCode", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
            iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   732
            RDEBUG("AbortSecurityCode", 1);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
            }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
        return KErrCancel;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   737
    RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   738
    CWait* wait = NULL;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   739
    TInt status = KErrNone;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   740
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   741
		// Validate the code using SCP. This is needed to check expiration
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   742
    RDEBUG("AbortSecurityCode", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   743
    RSCPClient scpClient;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   744
    RDEBUG("scpClient.Connect", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   745
    TInt tRet = scpClient.Connect();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   746
    RDEBUG("tRet", tRet);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   747
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   748
    CleanupClosePushL(scpClient);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   749
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   750
    RArray<TDevicelockPolicies> aFailedPolicies;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   751
    TDevicelockPolicies failedPolicy;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   752
    TInt retLockcode = KErrNone;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   753
    RMobilePhone::TMobilePassword aISACode;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   754
    TInt aFlags = 0;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   755
    RDEBUG("scpClient.VerifyCurrentLockcode", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   756
    // this validate on ISA . No need to do iPhone.VerifySecurityCode
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   757
    retLockcode = scpClient.VerifyCurrentLockcode(iSecUi_password, aISACode, aFailedPolicies, aFlags);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   758
    RDEBUG("retLockcode", retLockcode);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   759
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   760
    RDEBUG("aISACode", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   761
    RDEBUGSTR(aISACode);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   762
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   763
    RDEBUG("aFailedPolicies.Count()", aFailedPolicies.Count());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   764
    RDEBUG("EDeviceLockPasscodeExpiration", EDeviceLockPasscodeExpiration); // 8
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   765
    TInt failedEDeviceLockPasscodeExpiration = 0;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   766
    for (TInt i = 0; i < aFailedPolicies.Count(); i++)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   767
        {
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   768
        failedPolicy = aFailedPolicies[i];
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   769
        RDEBUG("failedPolicy", failedPolicy);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   770
        if (failedPolicy == EDeviceLockPasscodeExpiration)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   771
            failedEDeviceLockPasscodeExpiration = EDeviceLockPasscodeExpiration;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   772
        }
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   773
    RDEBUG("Close", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   774
    scpClient.Close();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   775
    RDEBUG("PopAndDestroy", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   776
    CleanupStack::PopAndDestroy(); //scpClient
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   777
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   778
		RDEBUG("failedEDeviceLockPasscodeExpiration", failedEDeviceLockPasscodeExpiration);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   779
    if (failedEDeviceLockPasscodeExpiration > 0)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   780
        {
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   781
    		// the password has expired. Note that it has NOT been validated. It will be revalidated inside ChangeSecCodeParamsL
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   782
        RMobilePhone::TMobilePassword iNewPassword;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   783
        TInt iFlags = 0;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   784
        iNewPassword.Copy(_L(""));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   785
        TBuf<0x80> iCaption;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   786
        iCaption.Copy(_L("ChangeSecCodeL")); // no need to translate because it's not used
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   787
        TInt iShowError = 1;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   788
        CSecuritySettings* iSecSettings;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   789
        iSecSettings = CSecuritySettings::NewL();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   790
        TSecUi::InitializeLibL();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   791
        RDEBUG("calling ChangeSecCodeParamsL", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   792
        status = iSecSettings->ChangeSecCodeParamsL(iSecUi_password, iNewPassword, iFlags, iCaption, iShowError);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   793
        // note that it might have been aborted. The error KErrAbort is shown in this method, not inside ChangeSecCodeParamsL
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   794
        if(status==KErrAccessDenied || status==KErrGsm0707IncorrectPassword)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   795
        	{
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   796
        	// the password expired, but the user typed wrongly. The error was already displayed.
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   797
        	RDEBUG("SCP returned ", KErrAccessDenied);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   798
        	status=R_CODES_DONT_MATCH;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   799
        	RDEBUG("SCP changed to R_CODES_DONT_MATCH", R_CODES_DONT_MATCH);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   800
        	}
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   801
        RDEBUG("status", status);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   802
        RDEBUG("iNewPassword", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   803
        RDEBUGSTR(iNewPassword);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   804
        TSecUi::UnInitializeLib();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   805
        RDEBUG("deleting iSecSettings", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   806
        delete iSecSettings;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   807
        RDEBUG("deleted iSecSettings", 1);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   808
        }
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   809
    else
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   810
        {
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   811
        RDEBUG( "wait", 0 );
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   812
        wait = CWait::NewL();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   813
        RDEBUG("VerifySecurityCode", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   814
        iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   815
        RDEBUG("WaitForRequestL",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   816
                0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   817
        status = wait->WaitForRequestL();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   818
        RDEBUG("WaitForRequestL status",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   819
                status);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   820
        delete wait;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   821
#ifdef __WINS__
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   822
        if (status == KErrNotSupported || status == KErrTimedOut)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   823
            {
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   824
            RDEBUG( "status", status );
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   825
            status = KErrNone;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   826
            }
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   827
#endif
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   828
        }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   829
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
    TInt returnValue = status;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   831
    RDEBUG("tarmFlag", tarmFlag);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   832
    RDEBUG("StartUp", StartUp);
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   833
    RDEBUG("status", status);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   834
    switch (status)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
        {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   836
        case KErrNone:
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   837
            // code approved
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   838
            {
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   839
            RDEBUG("KErrNone", KErrNone);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   840
            if( failedEDeviceLockPasscodeExpiration > 0)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   841
            	{
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   842
            	RDEBUG("code has just been changed. No need to show Confirmation note. failedEDeviceLockPasscodeExpiration", failedEDeviceLockPasscodeExpiration);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   843
            	}
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   844
            else
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   845
            	{
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   846
            	CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   847
            	}
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   848
            RDEBUG("R_CONFIRMATION_NOTE", R_CONFIRMATION_NOTE);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   849
            if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw))
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   850
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   851
                RDEBUG("KFeatureIdSapTerminalControlFw",
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   852
                        KFeatureIdSapTerminalControlFw);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
                // Unset the admin flag if set
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   854
                if (tarmFlag & KSCPFlagResyncQuery)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
                    {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   856
                    TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   857
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   858
                    if (tRet == KErrNone)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
                        {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   860
                        tarmFlag &= ~KSCPFlagResyncQuery;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   861
                        tRet = RProperty::Set(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   862
                        }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   863
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   864
                    if (tRet != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   865
                        {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   866
                        RDEBUG(
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   867
                                "FAILED to unset TARM Admin Flag tRet=",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   868
                                tRet);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   869
                        }
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   870
                    }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   871
                if (!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   872
                    {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   873
                    RDEBUG("KFeatureIdSapDeviceLockEnhancements", KFeatureIdSapDeviceLockEnhancements);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   874
                    RSCPClient scpClient;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   875
                    RDEBUG("scpClient.Connect", 0);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   876
                    TInt tRet = scpClient.Connect();
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   877
                    RDEBUG("tRet", tRet);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   878
                    User::LeaveIfError(tRet);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   879
                    RDEBUG("scpClient.Connect", 1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   880
                    CleanupClosePushL(scpClient);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   881
                    TSCPSecCode newCode;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   882
                    newCode.Copy(iSecUi_password);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   883
                    RDEBUG(
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   884
                            "!!!!!!! ***** TODO deprecated **** !!!!! scpClient.StoreCode",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   885
                            0);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   886
                    scpClient.StoreCode(newCode);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   887
                    RDEBUG("scpClient.StoreCode", 1);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   888
                    // TODO check whether code is expired.
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   889
                    // This should be done by TARM, and they should ask to change the code
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   890
                    CleanupStack::PopAndDestroy(); //scpClient
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   891
                    }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   892
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
                }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   894
            RDEBUG("StartUp", StartUp);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
            if (StartUp)
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
                {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
                // get autolock period from Central Repository.
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   898
                CRepository* repository = CRepository::NewL(KCRUidSecuritySettings);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
                TInt period = 0;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
                TInt res = repository->Get(KSettingsAutoLockTime, period);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
                delete repository;
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   902
                RDEBUG("res", res);
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   903
                RDEBUG("period", period);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   904
                _LIT_SECURITY_POLICY_PASS( KReadPolicy);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   905
                _LIT_SECURITY_POLICY_C1(KWritePolicy,
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   906
                        ECapabilityWriteDeviceData);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   907
                RProperty::Define(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   908
                RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   909
                RDEBUG("KCoreAppUIsAutolockStatus",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   910
                        KCoreAppUIsAutolockStatus);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
                if (res == KErrNone)
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
                    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
                    // disable autolock in Domestic OS side too if autolock period is 0.
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   915
                    if (period == 0)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
                        {
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   917
                        // Don't disable the domestic OS device lock
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
                        // since that would render the RemoteLock useless.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   920
                        TBool remoteLockStatus(EFalse);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
                        CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   923
                        if (remoteLockSettings->GetEnabled(remoteLockStatus))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
                            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   925
                            if (!remoteLockStatus)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   926
                                {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   927
                                // Remote lock is disabled
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   928
                                RDEBUG(
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   929
                                        "Autolock and RemoteLock are disabled -> disable DOS device lock",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   930
                                        0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
                                // Disable DOS device lock setting
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   932
                                RDEBUG(
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   933
                                        "iCustomPhone.DisablePhoneLock",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   934
                                        0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   935
                                wait = CWait::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   936
                                iCustomPhone.DisablePhoneLock(wait->iStatus, iSecUi_password);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   937
                                RDEBUG("WaitForRequestL", 0);
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
   938
                                status = wait->WaitForRequestL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   939
                                RDEBUG("WaitForRequestL", status);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   940
                                delete wait;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   941
                                }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   942
                            }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   943
                        else
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   944
                            {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   945
                            // Failed to get remote lock status
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   946
                            RDEBUG(
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   947
                                    "Autolock is disabled, but failed to get RemoteLock status, so do nothing",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   948
                                    0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   949
                            }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   950
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   951
                        delete remoteLockSettings;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
                        remoteLockSettings = NULL;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   954
                        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   955
                    }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   956
                else // error getting repository
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
                    {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   958
                    RDEBUG("error getting repository", 0);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
   959
                    // Don't disable the domestic OS device lock
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
                    // since that would render the RemoteLock useless.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   962
                    TBool remoteLockStatus(EFalse);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   963
                    CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   965
                    if (remoteLockSettings->GetEnabled(remoteLockStatus))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   966
                        {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   967
                        if (!remoteLockStatus)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
                            {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   969
                            // Remote lock is disabled
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   970
                            RDEBUG("iCustomPhone.DisablePhoneLock", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   971
                            wait = CWait::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   972
                            iCustomPhone.DisablePhoneLock(wait->iStatus, iSecUi_password);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   973
                            RDEBUG("WaitForRequestL", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   974
                            status = wait->WaitForRequestL();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   975
                            RDEBUG("WaitForRequestL status", status);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   976
                            delete wait;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   977
                            }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   978
                        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   979
                    else
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   980
                        {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   981
                        // Failed to get remote lock status
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   982
                        RDEBUG(
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   983
                                "Failed to get Autolock period and RemoteLock status, so do nothing",
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   984
                                0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   985
                        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   987
                    delete remoteLockSettings;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
                    remoteLockSettings = NULL;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   990
                    }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   991
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
   992
                } // no Startup
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   993
            }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
   994
            break;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   995
        case KErrGsmSSPasswordAttemptsViolation:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   996
        case KErrLocked:
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   997
        		{
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   998
            // security code blocked!
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
   999
            RDEBUG("KErrLocked", KErrLocked)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1000
            ;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1001
            CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1002
          	}
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1003
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1004
        case KErrGsm0707IncorrectPassword:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1005
        case KErrAccessDenied:
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1006
        		{
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1007
            RDEBUG("KErrAccessDenied", KErrAccessDenied);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1008
            // The Settings caller might retry
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1009
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1010
          	}
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1011
            break;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1012
        case R_CODES_DONT_MATCH:	// if password was supposed to be changed, but it failed (the initial verification)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1013
        		{
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1014
            RDEBUG("R_CODES_DONT_MATCH", R_CODES_DONT_MATCH);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1015
            // Error was already displayed
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1016
            returnValue = KErrAccessDenied;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1017
          	}
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1018
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1019
        default:
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1020
        		{
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1021
            RDEBUG("default", status);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1022
            CSecuritySettings::ShowErrorNoteL(status);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1023
            // The Settings caller might retry
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1024
          	}
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1025
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1026
        }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1027
    RDEBUG("returnValue", returnValue);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1028
    return returnValue;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1029
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1030
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1031
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
// CSecurityHandler::Pin1Required()    
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1033
// Handles Pin1Required event
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1034
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1035
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1036
TInt CSecurityHandler::Pin1RequiredL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1037
    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1038
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1039
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1040
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1041
     *****************************************************/
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1042
    RDEBUG("0", 0);
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
  1043
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1044
    RMobilePhone::TMobilePassword iSecUi_password;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1045
    TInt lCancelSupported = ESecUiCancelNotSupported;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1046
    TInt queryAccepted = KErrCancel;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1047
    TInt lAlphaSupported = 0;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1048
    RMobilePhone::TMobilePassword required_fourth;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1049
    RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePin1;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1050
    RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1051
    RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1052
    TBool StartUp = ETrue;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1053
    TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1054
    TInt err = KErrNone;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1055
    TInt res = KErrGeneral;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1056
    CWait* wait = CWait::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1057
    CleanupStack::PushL(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1058
    RDEBUG("0", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1059
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1060
    StartUp = iStartup;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1061
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1062
    RDEBUG("StartUp", StartUp);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1063
    if (!StartUp)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1064
        {
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
  1065
        // read a flag to see whether the query is SecUi originated. For example, from CSecuritySettings::ChangePinRequestParamsL
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1066
        err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1067
        if (err != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1068
            {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1069
            RDEBUG("FAILED to get the SECUI query Flag err", err);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1070
            }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1071
        }
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1072
    RDEBUG("err", err);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1073
    RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1074
    RDEBUG("ESecurityUIsSecUIOriginated", ESecurityUIsSecUIOriginated);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1075
    if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1076
        {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1077
        RDEBUG("0", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1078
        lCancelSupported = ESecUiCancelNotSupported;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1079
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
    else
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1081
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1082
        lCancelSupported = ESecUiCancelSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1083
        // it will be RMobilePhone::ESecurityCodePin1 , equivalent to ESecUiNone
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1084
        }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1085
    wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1086
    RDEBUG("GetSecurityCodeInfo", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1087
    iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1088
    res = wait->WaitForRequestL();
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1089
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1090
    RDEBUG("res", res);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1091
#ifdef __WINS__
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1092
    RDEBUG("emulator can't read PIN attempts", res);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1093
    res = KErrNone;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1094
    codeInfo.iRemainingEntryAttempts = 3;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1095
#endif
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1096
    User::LeaveIfError(res);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1097
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1098
    RDEBUG("codeInfo.iRemainingEntryAttempts",
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1099
            codeInfo.iRemainingEntryAttempts);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1100
    if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1101
        codeInfo.iRemainingEntryAttempts = -1;
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
  1102
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1103
    /* request PIN using QT */
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1104
    CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1105
    RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1106
    iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1107
    iQueryCanceled = EFalse;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1108
    RDEBUG("SecQueryDialog", 1);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1109
    // ESecUiCodeEtelReqest/ESecUiNone might be useful
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1110
    lAlphaSupported = ESecUiAlphaNotSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1111
    TBuf<0x100> title;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1112
    title.Zero();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1113
    HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_pin_code"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1114
    title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1115
    CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1116
    title.Append(_L("$"));
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1117
    title.AppendNum(codeInfo.iRemainingEntryAttempts);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1118
    TInt amode = ESecUiSecretSupported | lAlphaSupported | lCancelSupported | ESecUiEmergencySupported | secCodeType;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1119
    RDEBUG("amode", amode);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1120
    queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, amode);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1121
    RDEBUG("iSecUi_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1122
    RDEBUGSTR(iSecUi_password);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1123
    iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1124
    delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1125
    RDEBUG("queryAccepted", queryAccepted);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1126
    /* end request PIN using QT */
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
  1127
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1128
    if (queryAccepted == KErrAbort) // emergency call
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1129
        {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1130
        RDEBUG("queryAccepted", queryAccepted);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1131
        CleanupStack::PopAndDestroy(wait); // this is needed
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1132
        return KErrCancel;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1133
        }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1134
    if (lCancelSupported && (queryAccepted == KErrCancel))
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1135
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1136
        // cancel code request
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1137
        RDEBUG("AbortSecurityCode", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1138
        iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1139
        RDEBUG("AbortSecurityCode", 1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1140
        CleanupStack::PopAndDestroy(wait); // this is needed
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1141
        return KErrCancel;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1142
        }
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
  1143
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1144
    RDEBUG("iSecUi_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1145
    RDEBUGSTR(iSecUi_password);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1146
    RDEBUG("VerifySecurityCode", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1147
    iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1148
    RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
    res = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1150
    RDEBUG("WaitForRequestL res", res);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1151
    CleanupStack::PopAndDestroy(wait);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1152
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
    TInt returnValue = res;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1154
    switch (res)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1155
        {
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
        case KErrNone:
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1157
            // code approved
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1158
            RDEBUG("code approved", res)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1159
            ;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1160
            if (lCancelSupported == ESecUiCancelNotSupported)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1161
                { // OK note is not displayed in boot-up, to make things faster
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1162
                CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1163
                }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1164
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1165
        case KErrGsm0707IncorrectPassword:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
        case KErrAccessDenied:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1167
            // code was entered erroneously
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1168
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1169
            if (StartUp)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1170
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1171
                returnValue = Pin1RequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1172
                }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1173
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1174
        case KErrGsmSSPasswordAttemptsViolation:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
        case KErrLocked:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1176
            // code blocked; show error note and terminate.
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1177
            // what if not during Startup? Probably it's Ok since the SIM would had also failed at StartUp
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1178
            if (StartUp)
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1179
                CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1181
        case KErrGsm0707SimWrong:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1182
            // sim lock active
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1183
            // no error? This is strange
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1184
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1185
        default:
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1186
        		{
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1187
            CSecuritySettings::ShowErrorNoteL(res);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1188
            if (StartUp)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1189
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1190
                returnValue = Pin1RequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1191
                }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1192
            }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1193
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1194
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1195
    return returnValue;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1196
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1197
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1198
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1199
// CSecurityHandler::Puk1Required()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1200
// Handles Puk1Required event
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1201
// First asks the PUK1, then verifies, then the newPIN + re-type , and then writes . This is odd, but the API needs the PUK and newPIN in same step.
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1202
// Afterwards, the PIN1 might be asked (because the initial program still needs it)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1203
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1204
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1205
TInt CSecurityHandler::Puk1RequiredL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1206
    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1207
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1208
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1209
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1210
     *****************************************************/
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1211
    RDEBUG("0", 0);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1212
    TInt queryAccepted = KErrCancel;
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1213
    RMobilePhone::TMobilePassword puk1_password;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1214
    RMobilePhone::TMobilePassword aNewPinPassword;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1215
    RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1216
    RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1217
    RMobilePhone::TMobilePhoneSecurityCode blockCodeType;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1218
    blockCodeType = RMobilePhone::ESecurityCodePuk1;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1219
    CWait* wait = CWait::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1220
    CleanupStack::PushL(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1221
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1222
    TBool StartUp(ETrue);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1223
    StartUp = iStartup;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1224
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1225
    TInt res(KErrCancel); // for the first try
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1226
    wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1227
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1228
    TInt thisTry = 0;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1229
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1230
    // If there was a problem (as there might be in case we're dropping off SIM Access Profile); try again a couple of times.
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1231
    while (res != KErrNone && (thisTry++) <= KTriesToConnectServer)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1232
        {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1233
        if (thisTry > 0)
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1234
            User::After(KTimeBeforeRetryingRequest);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1235
        RDEBUG("GetSecurityCodeInfo", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1236
        iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1237
        RDEBUG("WaitForRequestL", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1238
        res = wait->WaitForRequestL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1239
        RDEBUG("WaitForRequestL res", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1240
        }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1241
    RDEBUG("res", res);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1242
    // If there's still an error we're doomed. Bail out.
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1243
    User::LeaveIfError(res);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1244
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1245
    RDEBUG("StartUp", StartUp);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1246
    RDEBUG("codeInfo.iRemainingEntryAttempts",
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1247
            codeInfo.iRemainingEntryAttempts);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1248
    TInt attempts(codeInfo.iRemainingEntryAttempts);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1249
    RDEBUG("attempts", attempts);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1250
    // show the last "Code Error" note of PIN verify result here so it won't be left under the PUK1 dialog
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1251
    if (!StartUp && (attempts == KMaxNumberOfPUKAttempts))
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1252
        CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1253
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1254
    if (attempts == KMaxNumberOfPINAttempts)
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1255
        attempts = -1;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1256
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1257
    CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1258
    RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1259
    iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1260
    iQueryCanceled = EFalse;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1261
    RDEBUG("SecQueryDialog", 1);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1262
    // ESecUiCodeEtelReqest/ESecUiNone might be useful
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1263
    TBuf<0x100> title;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1264
    title.Zero();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1265
    HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_puk_code"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1266
    title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1267
    CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1268
    title.Append(_L("$"));
22
6b63ca65093a Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
  1269
    title.AppendNum(attempts);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1270
    TInt lSecUiCancelSupported = ESecUiCancelSupported | ESecUiEmergencyNotSupported;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1271
    if (StartUp) // how to know whether PUK comes from failing at Starter, or failing at any other PIN (i.e. changing PIN, or changing PIN-request) ???
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1272
        lSecUiCancelSupported = ESecUiCancelNotSupported | ESecUiEmergencySupported;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1273
    queryAccepted = iSecQueryUi->SecQueryDialog(title, puk1_password, SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1274
            | lSecUiCancelSupported | ESecUiPukRequired);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1275
    RDEBUG("puk1_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1276
    RDEBUGSTR(puk1_password);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1277
    iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1278
    delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1279
    RDEBUG("queryAccepted", queryAccepted);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1280
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1281
    if ((queryAccepted == KErrAbort) || (queryAccepted == KErrCancel))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1282
        {
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1283
        CleanupStack::PopAndDestroy(wait); // this is needed
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1284
        return KErrCancel;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1285
        }
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1286
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1287
    // send code
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1288
    // first we verify the puk. For this, we reset the PIN to the same as the PUK
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1289
    // Hopefully this will never fail in the case "new PIN too long"
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1290
    RDEBUG("VerifySecurityCode", 0);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1291
    iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, puk1_password, puk1_password);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1292
    RDEBUG("WaitForRequestL", 0);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1293
    res = wait->WaitForRequestL();
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1294
    RDEBUG("WaitForRequestL res", res);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1295
    CleanupStack::PopAndDestroy(wait);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1296
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1297
    TInt returnValue = res;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1298
    switch (res)
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1299
        {
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1300
        case KErrNone:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1301
            // code approved -> note . The process continue and new-pin is requested
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1302
            CSecuritySettings::ShowResultNoteL(res, CAknNoteDialog::EConfirmationTone);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1303
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1304
        case KErrGsm0707IncorrectPassword:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1305
        case KErrAccessDenied:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1306
            // wrong PUK code -> note -> ask PUK code again        
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1307
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1308
            returnValue = Puk1RequiredL();
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1309
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1310
        case KErrGsm0707SimWrong:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1311
            // sim lock active
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1312
            // no message ?
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1313
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1314
        case KErrGsmSSPasswordAttemptsViolation:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1315
        case KErrLocked:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1316
            // sim card rejected.
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1317
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1318
        default:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1319
            CSecuritySettings::ShowErrorNoteL(res);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1320
            returnValue = Puk1RequiredL();
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1321
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1322
        }
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1323
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1324
    // Now the PUK1 is validated. It's time for asking the new PIN1
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1325
    RDEBUG("new wait", 0);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1326
    wait = CWait::NewL();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1327
    CleanupStack::PushL(wait);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1328
        {
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1329
        // new-pin query
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1330
        CSecQueryUi * iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1331
        RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1332
        iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1333
        iQueryCanceled = EFalse;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1334
        RDEBUG("SecQueryDialog", 1);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1335
        TBuf<0x100> title;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1336
        title.Zero();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1337
        HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_new_pin_code"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1338
        title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1339
        CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1340
        title.Append(_L("|"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1341
        HBufC* stringHolder2 = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_verify_new_pin_code"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1342
        title.Append(stringHolder2->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1343
        CleanupStack::PopAndDestroy(stringHolder2);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1344
        queryAccepted = iSecQueryUi->SecQueryDialog(title, aNewPinPassword, SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1345
                | ESecUiPukRequired);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1346
        RDEBUG("aNewPinPassword", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1347
        RDEBUGSTR(aNewPinPassword);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1348
        iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1349
        delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1350
        RDEBUG("queryAccepted", queryAccepted);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1351
        }
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1352
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1353
    if ((queryAccepted == KErrAbort) || (queryAccepted == KErrCancel))
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1354
        {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1355
        CleanupStack::PopAndDestroy(wait);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1356
        return KErrCancel;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1357
        }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1358
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1359
    // send code again, now with the user pin
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1360
    RDEBUG("VerifySecurityCode", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1361
    iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPinPassword, puk1_password);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1362
    RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1363
    res = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1364
    RDEBUG("WaitForRequestL res", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1365
    CleanupStack::PopAndDestroy(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1366
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1367
    returnValue = res;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1368
    switch (res)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1369
        {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1370
        case KErrNone:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1371
            // code approved -> note
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1372
            CSecuritySettings::ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1373
            break;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1374
        case KErrGsm0707IncorrectPassword:
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1375
        case KErrAccessDenied:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1376
            // wrong PUK code -> note -> ask PUK code again        
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1377
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1378
            returnValue = Puk1RequiredL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1379
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1380
        case KErrGsm0707SimWrong:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1381
            // sim lock active
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1382
            // no message ?
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1383
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1384
        case KErrGsmSSPasswordAttemptsViolation:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1385
        case KErrLocked:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1386
            // sim card rejected.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1387
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1388
        default:
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1389
            CSecuritySettings::ShowErrorNoteL(res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1390
            returnValue = Puk1RequiredL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1391
            break;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1392
        }
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1393
    RDEBUG("returnValue", returnValue);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1394
    return returnValue;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1395
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1396
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1397
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1398
// CSecurityHandler::Pin2Required()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1399
// Handles Pin2Required event
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1400
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1401
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1402
void CSecurityHandler::Pin2RequiredL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1403
    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1404
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1405
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1406
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1407
     *****************************************************/
15
318c4eab2439 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
  1408
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1409
    RDEBUG("0", 0);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1410
    TInt queryAccepted = KErrCancel;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1411
    RMobilePhone::TMobilePassword iSecUi_password;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1412
    RMobilePhone::TMobilePassword required_fourth;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1413
    RMobilePhone::TMobilePhoneSecurityCode secCodeType(RMobilePhone::ESecurityCodePin2);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1414
    RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1415
    RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1416
    CWait* wait = CWait::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1417
    CleanupStack::PushL(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1418
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1419
    wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1420
    RDEBUG("GetSecurityCodeInfo", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1421
    iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1422
    RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1423
    TInt ret = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1424
    RDEBUG("WaitForRequestL ret", ret);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1425
    User::LeaveIfError(ret);
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1426
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1427
    RDEBUG("codeInfo.iRemainingEntryAttempts",
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1428
            codeInfo.iRemainingEntryAttempts);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1429
    if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1430
        codeInfo.iRemainingEntryAttempts = -1;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1431
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1432
    /* request PIN using QT */
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1433
    CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1434
    RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1435
    iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1436
    iQueryCanceled = EFalse;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1437
    RDEBUG("SecQueryDialog", 1);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1438
    // ESecUiCodeEtelReqest/ESecUiNone might be useful against KLastRemainingInputAttempt
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1439
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1440
    TBuf<0x100> title;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1441
    title.Zero();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1442
    HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_pin2_code"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1443
    title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1444
    CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1445
    title.Append(_L("$"));
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1446
    title.AppendNum(codeInfo.iRemainingEntryAttempts);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1447
    queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1448
            | ESecUiCancelSupported | secCodeType);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1449
    RDEBUG("iSecUi_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1450
    RDEBUGSTR(iSecUi_password);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1451
    RDEBUG("queryAccepted", queryAccepted);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1452
    iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1453
    delete iSecQueryUi;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1454
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1455
    // If failed or device became locked, any pending request should be cancelled.
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1456
    if (queryAccepted != KErrNone)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1457
        {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1458
        RDEBUG("AbortSecurityCode", 0);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1459
        iPhone.AbortSecurityCode(secCodeType);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1460
        RDEBUG("AbortSecurityCode", 1);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1461
        CleanupStack::PopAndDestroy(wait);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1462
        return;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1463
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1464
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1465
    RDEBUG("VerifySecurityCode", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1466
    iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1467
    RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1468
    TInt status = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1469
    RDEBUG("WaitForRequestL status", status);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1470
    CleanupStack::PopAndDestroy(wait);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1471
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1472
    switch (status)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1473
        {
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1474
        case KErrNone:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1475
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1476
        case KErrGsm0707IncorrectPassword:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1477
        case KErrAccessDenied:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1478
            // code was entered erroneously
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1479
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1480
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1481
        case KErrGsmSSPasswordAttemptsViolation:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1482
        case KErrLocked:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1483
            // blocked
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1484
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1485
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1486
        default:
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1487
            CSecuritySettings::ShowErrorNoteL(status);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1488
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1489
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1490
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1491
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1492
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1493
// CSecurityHandler::Puk2Required()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1494
// Handles Puk2Required event
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1495
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1496
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1497
void CSecurityHandler::Puk2RequiredL()
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1498
    {
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1499
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1500
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1501
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1502
     *****************************************************/
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1503
    RDEBUG("0", 0);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1504
    TInt queryAccepted = KErrCancel;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1505
    RMobilePhone::TMobilePassword iSecUi_password;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1506
    RMobilePhone::TMobilePassword aNewPassword;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1507
    RMobilePhone::TMobilePassword verifcationPassword;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1508
    RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1509
    RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1510
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1511
    RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePuk2;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1512
    CWait* wait = CWait::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1513
    CleanupStack::PushL(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1514
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1515
    // ask PUK2
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1516
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1517
    TInt ret(KErrNone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1518
    wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1519
    RDEBUG("GetSecurityCodeInfo", 0);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1520
    iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1521
    RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1522
    ret = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1523
    RDEBUG("WaitForRequestL ret", ret);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1524
    User::LeaveIfError(ret);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1525
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1526
    /* request PIN using QT */
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1527
    CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1528
    RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1529
    iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1530
    iQueryCanceled = EFalse;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1531
    RDEBUG("SecQueryDialog", 1);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1532
    // ESecUiCodeEtelReqest/ESecUiNone might be useful
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1533
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1534
    RDEBUG("codeInfo.iRemainingEntryAttempts",
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1535
            codeInfo.iRemainingEntryAttempts);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1536
    if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) // TODO this might be 10 ?
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1537
        codeInfo.iRemainingEntryAttempts = -1;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1538
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1539
    TBuf<0x100> title;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1540
    title.Zero();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1541
    HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("Puk2RequiredL"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1542
    title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1543
    CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1544
    title.Append(_L("$"));
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1545
    title.AppendNum(codeInfo.iRemainingEntryAttempts);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1546
    queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PUK2_CODE_MIN_LENGTH, SEC_C_PUK2_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1547
            | ESecUiCancelSupported | secCodeType);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1548
    RDEBUG("iSecUi_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1549
    RDEBUGSTR(iSecUi_password);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1550
    iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1551
    delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1552
    RDEBUG("queryAccepted", queryAccepted);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1553
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1554
    if (queryAccepted != KErrNone)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1555
        {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1556
        // cancel "get security unblock code" request
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1557
        RDEBUG("AbortSecurityCode", 0);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1558
        iPhone.AbortSecurityCode(secCodeType);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1559
        RDEBUG("AbortSecurityCode", 1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1560
        CleanupStack::PopAndDestroy(1); //wait
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1561
        return;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1562
        }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1563
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1564
    RDEBUG("VerifySecurityCode", 0);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1565
    iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, iSecUi_password);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1566
    // this writes the newPIN2 with the value of PUK2. It's ok, since the user forgot it
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1567
    RDEBUG("WaitForRequestL", 0);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1568
    TInt res = wait->WaitForRequestL();
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1569
    RDEBUG("WaitForRequestL res", res);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1570
    CleanupStack::PopAndDestroy(wait);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1571
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1572
    switch (res)
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1573
        {
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1574
        case KErrNone:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1575
            // code approved -> note
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1576
            CSecuritySettings::ShowResultNoteL(res, CAknNoteDialog::EConfirmationTone);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1577
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1578
        case KErrGsm0707IncorrectPassword:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1579
        case KErrAccessDenied:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1580
            // wrong PUK2 code -> note -> ask PUK2 code again        
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1581
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1582
            Puk2RequiredL();
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1583
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1584
        case KErrGsmSSPasswordAttemptsViolation:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1585
        case KErrLocked:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1586
            // Pin2 features blocked permanently!
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1587
            CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, CAknNoteDialog::EConfirmationTone);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1588
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1589
        default:
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1590
            CSecuritySettings::ShowErrorNoteL(res);
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1591
            Puk2RequiredL();
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1592
            break;
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1593
        }
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1594
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1595
    // now the PUK2 is valid. Time to get the new PIN2
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1596
    wait = CWait::NewL();
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1597
    CleanupStack::PushL(wait);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1598
        {
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1599
        // new pin2 code query
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1600
        CSecQueryUi * iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1601
        RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1602
        iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1603
        iQueryCanceled = EFalse;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1604
        TBuf<0x100> title;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1605
        title.Zero();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1606
        HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("PIN2-New|PIN2-Verif"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1607
        title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1608
        CleanupStack::PopAndDestroy(stringHolder);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1609
        // ESecUiCodeEtelReqest/ESecUiNone might be useful
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1610
        queryAccepted = iSecQueryUi->SecQueryDialog(title, aNewPassword, SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1611
                | secCodeType);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1612
        RDEBUG("aNewPassword", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1613
        RDEBUGSTR(aNewPassword);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1614
        iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1615
        delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1616
        RDEBUG("queryAccepted", queryAccepted);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1617
        if (queryAccepted != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1618
            {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1619
            // cancel "get security unblock code" request
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1620
            RDEBUG("AbortSecurityCode", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1621
            iPhone.AbortSecurityCode(secCodeType);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1622
            RDEBUG("AbortSecurityCode", 1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1623
            CleanupStack::PopAndDestroy(1); //wait
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1624
            return;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1625
            }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1626
        }
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1627
    // send code. The code was temporarilly changed before. Thus, this really done to set the new-new one
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1628
    RDEBUG("VerifySecurityCode", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1629
    iPhone.VerifySecurityCode(wait->iStatus, secCodeType, aNewPassword, iSecUi_password);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1630
    RDEBUG("WaitForRequestL", 0);
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1631
    res = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1632
    RDEBUG("WaitForRequestL res", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1633
    CleanupStack::PopAndDestroy(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1634
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1635
    switch (res)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1636
        {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1637
        case KErrNone:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1638
            // code approved -> note
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1639
            CSecuritySettings::ShowResultNoteL(R_PIN2_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1640
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1641
        case KErrGsm0707IncorrectPassword:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1642
        case KErrAccessDenied:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1643
            // wrong PUK2 code -> note -> ask PUK2 code again        
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1644
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1645
            Puk2RequiredL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1646
            break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1647
        case KErrGsmSSPasswordAttemptsViolation:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1648
        case KErrLocked:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1649
            // Pin2 features blocked permanently!
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1650
            CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, CAknNoteDialog::EConfirmationTone);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1651
            break;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1652
        default:
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1653
            CSecuritySettings::ShowErrorNoteL(res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1654
            Puk2RequiredL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1655
            break;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1656
        }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1657
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1658
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1659
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1660
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1661
// CSecurityHandler::UPinRequiredL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1662
// Hendles UniversalPinRequired event
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1663
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1664
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1665
TInt CSecurityHandler::UPinRequiredL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1666
    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1667
    /*****************************************************
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1668
     *    Series 60 Customer / ETel
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1669
     *    Series 60  ETel API
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1670
     *****************************************************/
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1671
    TBool wcdmaSupported(FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1672
    TBool upinSupported(FeatureManager::FeatureSupported(KFeatureIdUpin));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1673
    RDEBUG("wcdmaSupported", wcdmaSupported);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1674
    RDEBUG("upinSupported", upinSupported);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1675
    if (wcdmaSupported || upinSupported)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1676
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1677
        TInt queryAccepted = KErrCancel;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1678
        TInt lCancelSupported = ESecUiCancelNotSupported;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1679
        RMobilePhone::TMobilePassword iSecUi_password;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1680
        RMobilePhone::TMobilePassword required_fourth;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1681
        RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1682
        RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1683
        RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityUniversalPin;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1684
        CWait* wait = CWait::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1685
        CleanupStack::PushL(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1686
        TBool StartUp = ETrue;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1687
        TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1688
        TInt err = KErrNone;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1689
        TInt res = KErrGeneral;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1690
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1691
        StartUp = iStartup;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1692
        RDEBUG("StartUp", StartUp);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1693
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1694
        wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1695
        RDEBUG("GetSecurityCodeInfo", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1696
        iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1697
        RDEBUG("WaitForRequestL", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1698
        res = wait->WaitForRequestL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1699
        RDEBUG("WaitForRequestL res", res);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1700
        User::LeaveIfError(res);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1701
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1702
        if (!StartUp)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1703
            {
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1704
            // read a flag to see whether the query is SecUi originated. 
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1705
            err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1706
            }
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1707
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1708
        /* request PIN using QT */
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1709
        CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1710
        RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1711
        iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1712
        iQueryCanceled = EFalse;
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1713
        // ESecUiCodeEtelReqest/ESecUiNone might be useful
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1714
        // TODO also support Emergency
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1715
        if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone))
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1716
            lCancelSupported = ESecUiCancelNotSupported;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1717
        else
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1718
            lCancelSupported = ESecUiCancelSupported;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1719
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1720
        TBuf<0x100> title;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1721
        title.Zero();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1722
        HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_upin_code"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1723
        title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1724
        CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1725
        title.Append(_L("$"));
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1726
        title.AppendNum(codeInfo.iRemainingEntryAttempts);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1727
        queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, ESecUiSecretSupported | ESecUiAlphaNotSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1728
                | lCancelSupported | ESecUiCodeEtelReqest);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1729
        RDEBUG("iSecUi_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1730
        RDEBUGSTR(iSecUi_password);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1731
        iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1732
        delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1733
        RDEBUG("queryAccepted", queryAccepted);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1734
        if (queryAccepted != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1735
            {
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1736
            CleanupStack::PopAndDestroy(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1737
            RDEBUG("AbortSecurityCode", 0);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1738
            iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPin);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1739
            RDEBUG("AbortSecurityCode", 1);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1740
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1741
            return KErrCancel;
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1742
            }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1743
        RDEBUG("VerifySecurityCode", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1744
        iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1745
        RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1746
        res = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1747
        RDEBUG("WaitForRequestL res", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1748
        CleanupStack::PopAndDestroy(wait);
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1749
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1750
        TInt returnValue = res;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1751
        switch (res)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1752
            {
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1753
            case KErrNone:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1754
                // code approved 
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1755
                RDEBUG("code approved ", 0)
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1756
                ;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1757
                CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1758
                break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1759
            case KErrGsm0707IncorrectPassword:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1760
            case KErrAccessDenied:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1761
                // code was entered erroneously
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1762
                CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1763
                if (StartUp)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1764
                    {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1765
                    returnValue = UPinRequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1766
                    }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1767
                break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1768
            case KErrGsmSSPasswordAttemptsViolation:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1769
            case KErrLocked:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1770
                // code blocked; show error note and terminate.
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1771
                if (StartUp)
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1772
                    CSecuritySettings::ShowResultNoteL(res, CAknNoteDialog::EErrorTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1773
                break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1774
            case KErrGsm0707SimWrong:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1775
                // sim lock active
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1776
                break;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1777
            default: // for example, KErrArgument
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1778
                CSecuritySettings::ShowErrorNoteL(res);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1779
                if (StartUp)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1780
                    {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1781
                    returnValue = UPinRequiredL();
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1782
                    }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1783
                break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1784
            }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1785
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1786
        return returnValue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1787
        }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1788
    else
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1789
        return KErrNone;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1790
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1791
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1792
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1793
// CSecurityHandler::UPukRequiredL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1794
// Handles UPukRequired event
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1795
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1796
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1797
TInt CSecurityHandler::UPukRequiredL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1798
    {
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1799
    TBool wcdmaSupported(FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1800
    TBool upinSupported(FeatureManager::FeatureSupported(KFeatureIdUpin));
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1801
    if (wcdmaSupported || upinSupported)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1802
        {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1803
        RDEBUG("0", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1804
        TInt queryAccepted = KErrCancel;
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1805
        RMobilePhone::TMobilePassword iSecUi_password;
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1806
        RMobilePhone::TMobilePassword aNewPassword;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1807
        RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1808
        RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1809
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1810
        RMobilePhone::TMobilePhoneSecurityCode blockCodeType;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1811
        blockCodeType = RMobilePhone::ESecurityUniversalPuk;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1812
        CWait* wait = CWait::NewL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1813
        CleanupStack::PushL(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1814
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1815
        TBool StartUp(ETrue);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1816
        StartUp = iStartup;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1817
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1818
        TInt res(KErrNone);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1819
        wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1820
        RDEBUG("GetSecurityCodeInfo", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1821
        iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1822
        RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1823
        res = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1824
        RDEBUG("WaitForRequestL res", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1825
        User::LeaveIfError(res);
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1826
        //show last "Code Error" note for UPIN verify result so it won't be left under the PUK1 dialog
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1827
        if (!StartUp && (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts))
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1828
            CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1829
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1830
        // ask UPUK code
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1831
        /* request PIN using QT */
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1832
            {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1833
            CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1834
            RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1835
            iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1836
            iQueryCanceled = EFalse;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1837
            // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1838
            // TODO also support Emergency
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1839
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1840
            TBuf<0x100> title;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1841
            title.Zero();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1842
            HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("UPuk1RequiredL"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1843
            title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1844
            CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1845
            title.Append(_L("$"));
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1846
            title.AppendNum(codeInfo.iRemainingEntryAttempts);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1847
            queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, ESecUiAlphaNotSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1848
                    | ESecUiCancelSupported | ESecUiPukRequired);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1849
            RDEBUG("iSecUi_password", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1850
            RDEBUGSTR(iSecUi_password);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1851
            iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1852
            delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1853
            RDEBUG("queryAccepted", queryAccepted);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1854
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1855
            if (queryAccepted != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1856
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1857
                CleanupStack::PopAndDestroy(wait);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1858
                return KErrCancel;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1859
                }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1860
            }
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1861
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1862
            {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1863
            /* request PIN using QT */
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1864
            CSecQueryUi *iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1865
            RDEBUG("CSecQueryUi", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1866
            iSecQueryUi = CSecQueryUi::NewL();
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1867
            iQueryCanceled = EFalse;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1868
            // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1869
            // TODO also support Emergency
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1870
            TBuf<0x100> title;
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1871
            title.Zero();
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1872
            HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_new_upin_code"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1873
            title.Append(stringHolder->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1874
            CleanupStack::PopAndDestroy(stringHolder);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1875
            title.Append(_L("|"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1876
            HBufC* stringHolder2 = HbTextResolverSymbian::LoadLC(_L("Verify"));
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1877
            title.Append(stringHolder2->Des());
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1878
            CleanupStack::PopAndDestroy(stringHolder2);
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1879
            queryAccepted = iSecQueryUi->SecQueryDialog(title, aNewPassword, SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1880
                    | ESecUiPukRequired);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1881
            RDEBUG("aNewPassword", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1882
            RDEBUGSTR(aNewPassword);
30
cc1cea6aabaf 201025_01
hgs
parents: 26
diff changeset
  1883
            iQueryCanceled = ETrue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1884
            delete iSecQueryUi;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1885
            RDEBUG("queryAccepted", queryAccepted);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1886
            if (queryAccepted != KErrNone)
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1887
                {
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1888
                CleanupStack::PopAndDestroy(wait);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1889
                return KErrCancel;
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1890
                }
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1891
            }
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1892
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1893
        // send code
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1894
        RDEBUG("VerifySecurityCode", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1895
        iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPassword, iSecUi_password);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1896
        RDEBUG("WaitForRequestL", 0);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1897
        res = wait->WaitForRequestL();
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1898
        RDEBUG("WaitForRequestL res", res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1899
        CleanupStack::PopAndDestroy(wait);
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1900
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1901
        TInt returnValue = res;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1902
        switch (res)
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1903
            {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1904
            case KErrNone:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1905
                // code approved -> note
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1906
                CSecuritySettings::ShowResultNoteL(R_UPIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1907
                break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1908
            case KErrGsm0707IncorrectPassword:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1909
            case KErrAccessDenied:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1910
                // wrong PUK code -> note -> ask UPUK code again        
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1911
                CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1912
                returnValue = UPukRequiredL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1913
                break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1914
            case KErrGsm0707SimWrong:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1915
                // sim lock active
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1916
                break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1917
            case KErrGsmSSPasswordAttemptsViolation:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1918
            case KErrLocked:
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1919
                // sim card rejected.
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1920
                break;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1921
            default:
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1922
                CSecuritySettings::ShowErrorNoteL(res);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1923
                returnValue = UPukRequiredL();
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1924
                break;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1925
            }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1926
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1927
        return returnValue;
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1928
        }
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1929
    else
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1930
        // not wcdmaSupported || upinSupported
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1931
        return KErrNone;
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1932
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1933
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1934
//
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1935
// ----------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1936
// CSecurityHandler::SimLockEventL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1937
// Shows "SIM restriction on" note
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1938
// ----------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1939
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1940
void CSecurityHandler::SimLockEventL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1941
    {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1942
    RDEBUG("0", 0);
35
f1030a78d563 201027_01
hgs
parents: 30
diff changeset
  1943
    CSecuritySettings::ShowResultNoteL(R_SIM_ON, CAknNoteDialog::EConfirmationTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1944
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1945
// ---------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1946
// CSecurityHandler::RemoveSplashScreenL()
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1947
// Removes splash screen
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1948
// ---------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1949
void CSecurityHandler::RemoveSplashScreenL() const
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1950
    {
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1951
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1952
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1953
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1954
// ---------------------------------------------------------
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1955
// CSecurityHandler::ShowGenericErrorNoteL(TInt aStatus)
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1956
// Shows a generic error note
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1957
// ---------------------------------------------------------
17
8957df7b0072 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 15
diff changeset
  1958
// qtdone
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1959
void CSecurityHandler::ShowGenericErrorNoteL(TInt aStatus)
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1960
    {
19
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1961
    // Let's create TextResolver instance for error resolving...
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1962
    RDEBUG("aStatus", aStatus);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1963
    RDEBUG("!!!!! this should never be called !!!!", 0);
098e361762d2 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  1964
26
aad866c37519 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 22
diff changeset
  1965
    CSecuritySettings::ShowResultNoteL(aStatus, CAknNoteDialog::EErrorTone);
0
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1966
    }
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1967
164170e6151a Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1968
// End of file