1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "seccodesettings.h" |
|
19 #include "seccodemodel.h" |
|
20 #include "seccodeuiutility.h" |
|
21 |
|
22 class SecCodeSettingsPrivate |
|
23 { |
|
24 public: |
|
25 SecCodeSettingsPrivate() |
|
26 { |
|
27 mSecCodeModel = new SecCodeModel(); |
|
28 } |
|
29 |
|
30 ~SecCodeSettingsPrivate() |
|
31 { |
|
32 delete mSecCodeModel; |
|
33 } |
|
34 |
|
35 SecCodeModel *mSecCodeModel; |
|
36 }; |
|
37 |
|
38 SecCodeSettings::SecCodeSettings(QObject * parent /*= 0*/) |
|
39 : QObject(parent), d_ptr(new SecCodeSettingsPrivate()) |
|
40 { |
|
41 |
|
42 } |
|
43 |
|
44 SecCodeSettings::~SecCodeSettings() |
|
45 { |
|
46 delete d_ptr; |
|
47 } |
|
48 |
|
49 bool SecCodeSettings::pinCodeRequest() const |
|
50 { |
|
51 // return d_ptr->mSecCodeModel->pinCodeRequest(); |
|
52 return true; |
|
53 } |
|
54 |
|
55 void SecCodeSettings::setPinCodeRequest(bool on) |
|
56 { |
|
57 Q_UNUSED(on); |
|
58 } |
|
59 |
|
60 void SecCodeSettings::changePinCode() |
|
61 { |
|
62 if (d_ptr->mSecCodeModel->simCardRemoved()) { |
|
63 SecCodeUiUtility::showErrorMessage(tr("SIM removed.")); |
|
64 return; |
|
65 } |
|
66 |
|
67 if (!pinCodeRequest()) { |
|
68 SecCodeUiUtility::showErrorMessage(tr("Set PIN code request ON.")); |
|
69 return; |
|
70 } |
|
71 |
|
72 QString title = SecCodeUiUtility::getPinRemainingAttemptsMessage( |
|
73 d_ptr->mSecCodeModel->pinRemainingAttempts()); |
|
74 |
|
75 QString oldPassword = SecCodeUiUtility::getPassword(title); |
|
76 if (oldPassword.isEmpty()) { |
|
77 return; |
|
78 } |
|
79 |
|
80 QString newPassword; |
|
81 QString verifyPassword; |
|
82 bool firstTry (true); |
|
83 |
|
84 do { |
|
85 if (firstTry) { |
|
86 firstTry = false; |
|
87 } |
|
88 else { |
|
89 newPassword.clear(); |
|
90 verifyPassword.clear(); |
|
91 SecCodeUiUtility::showErrorMessage(tr("PIN does not match.")); |
|
92 } |
|
93 |
|
94 newPassword = SecCodeUiUtility::getPassword(tr("New PIN:")); |
|
95 if (newPassword.isEmpty()) { |
|
96 return; |
|
97 } |
|
98 |
|
99 verifyPassword = SecCodeUiUtility::getPassword(tr("Verify PIN:"));; |
|
100 if (verifyPassword.isEmpty()) { |
|
101 return; |
|
102 } |
|
103 } while (verifyPassword != newPassword); |
|
104 |
|
105 int err = d_ptr->mSecCodeModel->changePinCode(oldPassword,newPassword,verifyPassword); |
|
106 switch (err) { |
|
107 case SecCode::ErrNone: |
|
108 SecCodeUiUtility::showInformationMessage(tr("Code changed.")); |
|
109 break; |
|
110 default: |
|
111 break; |
|
112 } |
|
113 } |
|
114 |
|
115 |
|
116 void SecCodeSettings::changePin2Code() |
|
117 { |
|
118 if (d_ptr->mSecCodeModel->simCardRemoved()) { |
|
119 SecCodeUiUtility::showErrorMessage(tr("SIM removed.")); |
|
120 return; |
|
121 } |
|
122 |
|
123 if (!pinCodeRequest()) { |
|
124 SecCodeUiUtility::showErrorMessage(tr("Set PIN code request ON.")); |
|
125 return; |
|
126 } |
|
127 |
|
128 QString title = SecCodeUiUtility::getPin2RemainingAttemptsMessage( |
|
129 d_ptr->mSecCodeModel->pin2RemainingAttempts()); |
|
130 |
|
131 QString oldPassword = SecCodeUiUtility::getPassword(title); |
|
132 if (oldPassword.isEmpty()) { |
|
133 return; |
|
134 } |
|
135 |
|
136 QString newPassword; |
|
137 QString verifyPassword; |
|
138 bool firstTry (true); |
|
139 |
|
140 do { |
|
141 if (firstTry) { |
|
142 firstTry = false; |
|
143 } |
|
144 else { |
|
145 newPassword.clear(); |
|
146 verifyPassword.clear(); |
|
147 SecCodeUiUtility::showErrorMessage(tr("PIN2 does not match.")); |
|
148 } |
|
149 |
|
150 newPassword = SecCodeUiUtility::getPassword(tr("New PIN2:")); |
|
151 if (newPassword.isEmpty()) { |
|
152 return; |
|
153 } |
|
154 |
|
155 verifyPassword = SecCodeUiUtility::getPassword(tr("Verify PIN2:"));; |
|
156 if (verifyPassword.isEmpty()) { |
|
157 return; |
|
158 } |
|
159 } while (verifyPassword != newPassword); |
|
160 |
|
161 int err = d_ptr->mSecCodeModel->changePin2Code(oldPassword,newPassword,verifyPassword); |
|
162 switch (err) { |
|
163 case SecCode::ErrNone: |
|
164 SecCodeUiUtility::showInformationMessage(tr("Code changed.")); |
|
165 break; |
|
166 default: |
|
167 break; |
|
168 } |
|
169 } |
|