1 /*! |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements simcontrol key sequence handling. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <qsysteminfo.h> |
|
19 #include <qmobilityglobal.h> |
|
20 #include <secui.h> |
|
21 #include <secuimanualsecuritysettings.h> |
|
22 #include "keysequencerecognitionservicedefs.h" |
|
23 #include "keysequencerecognitionservicelog.h" |
|
24 #include "simcontrolkeysequencehandler.h" |
|
25 |
|
26 |
|
27 //QTM_USE_NAMESPACE |
|
28 |
|
29 /*! |
|
30 SimControlKeySequenceHandler::SimControlKeySequenceHandler. |
|
31 */ |
|
32 SimControlKeySequenceHandler::SimControlKeySequenceHandler( |
|
33 QObject* parent) |
|
34 : |
|
35 KeySequenceHandler(parent), |
|
36 m_securityModel(0) |
|
37 { |
|
38 DPRINT_METHODENTRYEXIT; |
|
39 |
|
40 setKeySequenceValidator(KCodeChangePin1 + "|" + |
|
41 KCodeChangePin2 + "|" + |
|
42 KCodeUnblockPin1 + "|" + |
|
43 KCodeUnblockPin2); |
|
44 |
|
45 QT_TRAP_THROWING(TSecUi::InitializeLibL()); |
|
46 QT_TRAP_THROWING( m_securityModel = CManualSecuritySettings::NewL() ); |
|
47 } |
|
48 |
|
49 |
|
50 /*! |
|
51 SimControlKeySequenceHandler::~SimControlKeySequenceHandler. |
|
52 */ |
|
53 SimControlKeySequenceHandler::~SimControlKeySequenceHandler() |
|
54 { |
|
55 DPRINT_METHODENTRYEXIT; |
|
56 |
|
57 delete m_securityModel; |
|
58 TSecUi::UnInitializeLib(); |
|
59 } |
|
60 |
|
61 |
|
62 /*! |
|
63 SimControlKeySequenceHandler::executeKeySequence. |
|
64 */ |
|
65 bool SimControlKeySequenceHandler::executeKeySequence( |
|
66 const QString &keySequence) |
|
67 { |
|
68 DPRINT_METHODENTRYEXIT; |
|
69 |
|
70 bool handled = parseString( keySequence ); |
|
71 |
|
72 return handled; |
|
73 } |
|
74 |
|
75 |
|
76 /*! |
|
77 SimControlKeySequenceHandler::parseString. |
|
78 */ |
|
79 bool SimControlKeySequenceHandler::parseString(const QString &keySequence) |
|
80 { |
|
81 DPRINT_METHODENTRYEXIT; |
|
82 |
|
83 const QString KChangePin1("**04*"); |
|
84 const QString KChangePin2("**042"); |
|
85 const QString KUnblockPin1("**05*"); |
|
86 const QString KUnblockPin2("**052"); |
|
87 |
|
88 QString oldPin; |
|
89 QString newPin; |
|
90 QString verifyNewPin; |
|
91 QString puk; |
|
92 |
|
93 SimOperation operation = None; |
|
94 bool handled = false; |
|
95 |
|
96 QString keySequencePrefix (keySequence); |
|
97 |
|
98 //Get first 5 chars from keysequence string |
|
99 keySequencePrefix.chop(keySequencePrefix.length()-5); |
|
100 QRegExp expression(QRegExp::escape(keySequencePrefix)); |
|
101 |
|
102 QString parsedKeySequence(keySequence); |
|
103 |
|
104 //remove '#' from end |
|
105 parsedKeySequence.chop(1); |
|
106 |
|
107 QStringList pins; |
|
108 |
|
109 if (expression.exactMatch(KChangePin1) || expression.exactMatch(KChangePin2)) |
|
110 { |
|
111 if (expression.exactMatch(KChangePin1)) |
|
112 { |
|
113 parsedKeySequence.remove(0, 5); |
|
114 operation = Pin1; |
|
115 } |
|
116 |
|
117 if (expression.exactMatch(KChangePin2)) |
|
118 { |
|
119 parsedKeySequence.remove(0, 6); |
|
120 operation = Pin2; |
|
121 } |
|
122 pins = parsedKeySequence.split("*"); |
|
123 oldPin= pins.value(0); |
|
124 newPin = pins.value(1); |
|
125 verifyNewPin = pins.value(2); |
|
126 handled = true; |
|
127 processChangePin(operation, oldPin, newPin, verifyNewPin); |
|
128 } |
|
129 |
|
130 if (expression.exactMatch(KUnblockPin1) || expression.exactMatch(KUnblockPin2)) |
|
131 { |
|
132 if ( expression.exactMatch(KUnblockPin1)) |
|
133 { |
|
134 parsedKeySequence.remove(0, 5); |
|
135 operation = Pin1; |
|
136 } |
|
137 |
|
138 if (expression.exactMatch(KUnblockPin2)) |
|
139 { |
|
140 parsedKeySequence.remove(0, 6); |
|
141 operation = Pin2; |
|
142 } |
|
143 |
|
144 pins = parsedKeySequence.split("*"); |
|
145 puk = pins.value(0); |
|
146 newPin = pins.value(1); |
|
147 verifyNewPin = pins.value(2); |
|
148 handled = true; |
|
149 processUnblockPin(operation, puk, newPin, verifyNewPin); |
|
150 } |
|
151 |
|
152 return handled; |
|
153 } |
|
154 |
|
155 /*! |
|
156 SimControlKeySequenceHandler::processChangePin. |
|
157 */ |
|
158 void SimControlKeySequenceHandler::processChangePin(SimOperation operation, const QString &oldPin, |
|
159 const QString &newPin, const QString &verifyNew) |
|
160 { |
|
161 CManualSecuritySettings::TPin pin; |
|
162 |
|
163 if(operation == Pin1) |
|
164 { |
|
165 pin = CManualSecuritySettings::EPin1; |
|
166 } |
|
167 else |
|
168 { |
|
169 pin = CManualSecuritySettings::EPin2; |
|
170 } |
|
171 |
|
172 TBuf<200> oldPinBuf(oldPin.utf16()); |
|
173 TBuf<200> newPinBuf(newPin.utf16()); |
|
174 TBuf<200> verifyNewBuf(verifyNew.utf16()); |
|
175 |
|
176 QT_TRAP_THROWING(m_securityModel->ChangePinL(pin, oldPinBuf, newPinBuf, verifyNewBuf)); |
|
177 } |
|
178 |
|
179 /*! |
|
180 SimControlKeySequenceHandler::processUnblockPin. |
|
181 */ |
|
182 void SimControlKeySequenceHandler::processUnblockPin(SimOperation operation, const QString &puk, |
|
183 const QString &newPin, const QString &verifyNew) |
|
184 { |
|
185 CManualSecuritySettings::TPin pin; |
|
186 |
|
187 if(operation == Pin1) |
|
188 { |
|
189 pin = CManualSecuritySettings::EPin1; |
|
190 } |
|
191 else |
|
192 { |
|
193 pin= CManualSecuritySettings::EPin2; |
|
194 } |
|
195 |
|
196 TBuf<200> pukBuf(puk.utf16()); |
|
197 TBuf<200> newPinBuf(newPin.utf16()); |
|
198 TBuf<200> verifyNewBuf(verifyNew.utf16()); |
|
199 |
|
200 |
|
201 QT_TRAP_THROWING(m_securityModel->UnblockPinL(pin, pukBuf, newPinBuf, verifyNewBuf)); |
|
202 } |
|