63
|
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: Security module view in advanced security settings.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "advsecsettingssecuritymoduleview.h"
|
|
19 |
#include "advsecsettingssecuritymodulemodel.h"
|
|
20 |
#include <QGraphicsLinearLayout>
|
|
21 |
#include <HbGroupBox>
|
|
22 |
#include <HbDataForm>
|
|
23 |
#include <HbDataFormModel>
|
|
24 |
#include <HbLineEdit>
|
|
25 |
#include <QDebug>
|
|
26 |
|
|
27 |
const QString KEchoModeProperty = "echoMode";
|
|
28 |
const QString KTextProperty = "text";
|
|
29 |
const QString KAdditionalTextProperty = "additionalText";
|
|
30 |
const QString KReadOnlyProperty = "readOnly";
|
|
31 |
const QString KPasswordValue = "****";
|
|
32 |
|
|
33 |
|
|
34 |
// ======== MEMBER FUNCTIONS ========
|
|
35 |
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
// AdvSecSettingsSecurityModuleView::AdvSecSettingsSecurityModuleView()
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
AdvSecSettingsSecurityModuleView::AdvSecSettingsSecurityModuleView(
|
|
41 |
AdvSecSettingsSecurityModuleModel &model, QGraphicsItem *parent) :
|
|
42 |
AdvSecSettingsViewBase(0, parent), mModel(model), mViewLabel(0),
|
|
43 |
mModulePin(0), mModulePinRequested(0), mModuleStatus(0), mSigningPin(0),
|
|
44 |
mModelIndex(0)
|
|
45 |
{
|
|
46 |
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
|
|
47 |
|
|
48 |
// View title
|
|
49 |
mViewLabel = new HbGroupBox;
|
|
50 |
layout->addItem(mViewLabel);
|
|
51 |
|
|
52 |
HbDataForm *dataForm = new HbDataForm;
|
|
53 |
mDataFormModel = new HbDataFormModel;
|
|
54 |
HbDataFormModelItem *rootItem = mDataFormModel->invisibleRootItem();
|
|
55 |
|
|
56 |
// Module PIN
|
|
57 |
// TODO: localized UI strings needed
|
|
58 |
HbDataFormModelItem *moduleGroup = 0;
|
|
59 |
moduleGroup = mDataFormModel->appendDataFormGroup(tr("Module PIN"), rootItem);
|
|
60 |
mModulePin = mDataFormModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
61 |
tr("PIN code"), moduleGroup);
|
|
62 |
mModulePin->setContentWidgetData(KEchoModeProperty, HbLineEdit::Password);
|
|
63 |
mModulePin->setContentWidgetData(KTextProperty, KPasswordValue);
|
|
64 |
mModulePin->setContentWidgetData(KReadOnlyProperty, true);
|
|
65 |
|
|
66 |
// Module PIN Request
|
|
67 |
mModulePinRequested = mDataFormModel->appendDataFormItem(
|
|
68 |
HbDataFormModelItem::ToggleValueItem, tr("PIN code required"), moduleGroup);
|
|
69 |
mModulePinRequested->setContentWidgetData(KTextProperty, tr("On"));
|
|
70 |
//mModulePinRequested->setContentWidgetData(KAdditionalTextProperty, tr("Changing..."));
|
|
71 |
// TODO: remove
|
|
72 |
mModulePinRequested->setEnabled(false);
|
|
73 |
|
|
74 |
// Module Status
|
|
75 |
mModuleStatus = mDataFormModel->appendDataFormItem(
|
|
76 |
HbDataFormModelItem::ToggleValueItem, tr("Status"), moduleGroup);
|
|
77 |
mModuleStatus->setContentWidgetData(KTextProperty, tr("Closed"));
|
|
78 |
mModuleStatus->setEnabled(false);
|
|
79 |
|
|
80 |
dataForm->setModel(mDataFormModel);
|
|
81 |
layout->addItem(dataForm);
|
|
82 |
setLayout(layout);
|
|
83 |
|
|
84 |
connect(dataForm, SIGNAL(activated(const QModelIndex &)),
|
|
85 |
this, SLOT(itemActivated(const QModelIndex &)));
|
|
86 |
connect(&mModel, SIGNAL(statusCompleted(int)), this, SLOT(moduleStatusChanged(int)));
|
|
87 |
connect(&mModel, SIGNAL(statusChanged(int)), this, SLOT(moduleStatusChanged(int)));
|
|
88 |
connect(&mModel, SIGNAL(pinCodeRequestStateCompleted()), this, SLOT(updateModuleStatus()));
|
|
89 |
connect(&mModel, SIGNAL(pinCodeChangeCompleted()), this, SLOT(updateModuleStatus()));
|
|
90 |
connect(&mModel, SIGNAL(closeCompleted()), this, SLOT(updateModuleStatus()));
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
// AdvSecSettingsSecurityModuleView::~AdvSecSettingsSecurityModuleView()
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
AdvSecSettingsSecurityModuleView::~AdvSecSettingsSecurityModuleView()
|
|
98 |
{
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// AdvSecSettingsSecurityModuleView::setSecurityModule()
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
void AdvSecSettingsSecurityModuleView::setSecurityModule(const QString &moduleTitle,
|
|
106 |
int modelIndex)
|
|
107 |
{
|
|
108 |
mViewLabel->setHeading(moduleTitle);
|
|
109 |
mModelIndex = modelIndex;
|
|
110 |
|
|
111 |
// Signing PIN
|
|
112 |
if (mModel.isSigningPinSupported(mModelIndex)) {
|
|
113 |
if (!mSigningPin) {
|
|
114 |
HbDataFormModelItem *rootItem = mDataFormModel->invisibleRootItem();
|
|
115 |
HbDataFormModelItem *signingGroup = 0;
|
|
116 |
signingGroup = mDataFormModel->appendDataFormGroup(tr("Signing PIN"), rootItem);
|
|
117 |
mSigningPin = mDataFormModel->appendDataFormItem(HbDataFormModelItem::TextItem,
|
|
118 |
tr("PIN code"), signingGroup);
|
|
119 |
mSigningPin->setContentWidgetData(KEchoModeProperty, HbLineEdit::Password);
|
|
120 |
mSigningPin->setContentWidgetData(KTextProperty, KPasswordValue);
|
|
121 |
mSigningPin->setContentWidgetData(KReadOnlyProperty, true);
|
|
122 |
}
|
|
123 |
} else {
|
|
124 |
if (mSigningPin) {
|
|
125 |
mDataFormModel->removeItem(mSigningPin);
|
|
126 |
mSigningPin = 0;
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
updateModuleStatus();
|
|
131 |
}
|
|
132 |
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
// AdvSecSettingsSecurityModuleView::updateModuleStatus()
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
void AdvSecSettingsSecurityModuleView::updateModuleStatus()
|
|
138 |
{
|
|
139 |
mModel.getModuleStatus(mModelIndex);
|
|
140 |
}
|
|
141 |
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
// AdvSecSettingsSecurityModuleView::moduleStatusChanged()
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void AdvSecSettingsSecurityModuleView::moduleStatusChanged(int status)
|
|
147 |
{
|
|
148 |
// TODO: localized UI strings needed
|
|
149 |
if (status & AdvSecSettingsSecurityModuleModel::EBlockedPermanently) {
|
|
150 |
mModulePinRequested->setContentWidgetData(KTextProperty, tr("Blocked"));
|
|
151 |
mModulePinRequested->setEnabled(false);
|
|
152 |
} else if (status & AdvSecSettingsSecurityModuleModel::EPinBlocked) {
|
|
153 |
mModulePinRequested->setContentWidgetData(KTextProperty, tr("Blocked"));
|
|
154 |
// TODO: mModulePinRequested->setEnabled(true);
|
|
155 |
mModulePinRequested->setEnabled(false);
|
|
156 |
} else {
|
|
157 |
if (status & AdvSecSettingsSecurityModuleModel::EPinRequested) {
|
|
158 |
mModulePinRequested->setContentWidgetData(KTextProperty, tr("On"));
|
|
159 |
} else {
|
|
160 |
mModulePinRequested->setContentWidgetData(KTextProperty, tr("Off"));
|
|
161 |
}
|
|
162 |
if (status & AdvSecSettingsSecurityModuleModel::EPinChangeAllowed) {
|
|
163 |
// TODO:
|
|
164 |
//mModulePinRequested->setContentWidgetData(KAdditionalTextProperty, tr("Changing..."));
|
|
165 |
//mModulePinRequested->setEnabled(true);
|
|
166 |
mModulePinRequested->setEnabled(false);
|
|
167 |
} else {
|
|
168 |
mModulePinRequested->setContentWidgetData(KAdditionalTextProperty, QString());
|
|
169 |
mModulePinRequested->setEnabled(false);
|
|
170 |
}
|
|
171 |
}
|
|
172 |
if (status & AdvSecSettingsSecurityModuleModel::EPinEntered) {
|
|
173 |
mModuleStatus->setContentWidgetData(KTextProperty, tr("Open"));
|
|
174 |
// TODO:
|
|
175 |
//mModuleStatus->setContentWidgetData(KAdditionalTextProperty, tr("Closing..."));
|
|
176 |
//mModuleStatus->setEnabled(true);
|
|
177 |
mModuleStatus->setEnabled(false);
|
|
178 |
} else {
|
|
179 |
mModuleStatus->setContentWidgetData(KTextProperty, tr("Closed"));
|
|
180 |
mModuleStatus->setContentWidgetData(KAdditionalTextProperty, QString());
|
|
181 |
mModuleStatus->setEnabled(false);
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
// AdvSecSettingsSecurityModuleView::itemActivated()
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void AdvSecSettingsSecurityModuleView::itemActivated(const QModelIndex &/*itemIndex*/)
|
|
190 |
{
|
|
191 |
// TODO: this does not work yet
|
|
192 |
#if 0
|
|
193 |
bool isOperationStarted = false;
|
|
194 |
HbDataFormModelItem *item = mDataFormModel->itemFromIndex(itemIndex);
|
|
195 |
if (item == mModulePin) {
|
|
196 |
mModel.changePinCode(mModelIndex);
|
|
197 |
isOperationStarted = true;
|
|
198 |
} else if (item == mModulePinRequested) {
|
|
199 |
QString contentData = mModulePinRequested->contentWidgetData(KTextProperty).toString();
|
|
200 |
bool enable = (contentData != tr("On"));
|
|
201 |
mModel.setPinCodeRequestState(mModelIndex, enable);
|
|
202 |
isOperationStarted = true;
|
|
203 |
} else if (item == mModuleStatus) {
|
|
204 |
QString contentData = mModulePinRequested->contentWidgetData(KTextProperty).toString();
|
|
205 |
bool isClosed = (contentData == tr("Closed"));
|
|
206 |
if (!isClosed) {
|
|
207 |
mModel.closeModule(mModelIndex);
|
|
208 |
isOperationStarted = true;
|
|
209 |
}
|
|
210 |
} else if (item == mSigningPin) {
|
|
211 |
mModel.changeSigningPinCode(mModelIndex);
|
|
212 |
isOperationStarted = true;
|
|
213 |
} else {
|
|
214 |
// ignored, one of the group titles
|
|
215 |
}
|
|
216 |
if (isOperationStarted) {
|
|
217 |
mModulePin->setEnabled(false);
|
|
218 |
mModulePinRequested->setEnabled(false);
|
|
219 |
mModuleStatus->setEnabled(false);
|
|
220 |
if (mSigningPin) {
|
|
221 |
mSigningPin->setEnabled(false);
|
|
222 |
}
|
|
223 |
}
|
|
224 |
#endif
|
|
225 |
}
|
|
226 |
|