|
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: |
|
15 * EAP Wizard Page: User Certificate Selection. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System includes |
|
20 #include <QGraphicsItem> |
|
21 #include <HbDocumentLoader> |
|
22 #include <HbMainWindow> |
|
23 #include <HbWidget> |
|
24 #include <HbRadioButtonList> |
|
25 #include <HbLabel> |
|
26 #include <eapqtconfiginterface.h> |
|
27 #include <eapqtcertificateinfo.h> |
|
28 |
|
29 // User includes |
|
30 #include "wlanwizardhelper.h" |
|
31 #include "eapwizardpagecertuser.h" |
|
32 #include "eapwizard_p.h" |
|
33 |
|
34 /*! |
|
35 \class EapWizardPageCertUser |
|
36 \brief Implements EAP wizard page: User Certificate selection |
|
37 */ |
|
38 |
|
39 // External function prototypes |
|
40 |
|
41 // Local constants |
|
42 |
|
43 // ======== LOCAL FUNCTIONS ======== |
|
44 |
|
45 // ======== MEMBER FUNCTIONS ======== |
|
46 |
|
47 |
|
48 /*! |
|
49 Constructor. |
|
50 |
|
51 @param [in] parent Pointer to EAP Wizard private implementation. |
|
52 */ |
|
53 |
|
54 EapWizardPageCertUser::EapWizardPageCertUser(EapWizardPrivate* parent) : |
|
55 EapWizardPage(parent), |
|
56 mWidget(NULL), |
|
57 mCertList(NULL), |
|
58 mErrorLabel(NULL), |
|
59 mDocumentLoader(NULL), |
|
60 mValid(false) |
|
61 { |
|
62 } |
|
63 |
|
64 /*! |
|
65 Destructor. |
|
66 */ |
|
67 EapWizardPageCertUser::~EapWizardPageCertUser() |
|
68 { |
|
69 } |
|
70 |
|
71 /*! |
|
72 See WlanWizardPage. |
|
73 */ |
|
74 HbWidget* EapWizardPageCertUser::initializePage() |
|
75 { |
|
76 if (!mWidget) { |
|
77 bool ok; |
|
78 mDocumentLoader.reset(new HbDocumentLoader(mWizard->wizardHelper()->mainWindow())); |
|
79 mDocumentLoader->load(":/docml/occ_eap_wizard_06.docml", &ok); |
|
80 Q_ASSERT(ok); |
|
81 loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation()); |
|
82 |
|
83 mWidget = qobject_cast<HbWidget*> (mDocumentLoader->findWidget("occ_eap_wizard_06")); |
|
84 Q_ASSERT(mWidget); |
|
85 |
|
86 mCertList = qobject_cast<HbRadioButtonList*> (mDocumentLoader->findWidget("list")); |
|
87 Q_ASSERT(mCertList); |
|
88 |
|
89 mErrorLabel = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("errorLabel")); |
|
90 Q_ASSERT(mErrorLabel); |
|
91 |
|
92 mErrorLabel->setPlainText(hbTrId("txt_occ_dialog_no_certificates_installed_wizard_c")); |
|
93 |
|
94 ok = connect( |
|
95 mWizard->wizardHelper()->mainWindow(), |
|
96 SIGNAL(orientationChanged(Qt::Orientation)), |
|
97 this, |
|
98 SLOT(loadDocmlSection(Qt::Orientation))); |
|
99 Q_ASSERT(ok); |
|
100 |
|
101 ok = connect( |
|
102 mCertList, SIGNAL(itemSelected(int)), |
|
103 this, SLOT(itemSelected(int))); |
|
104 Q_ASSERT(ok); |
|
105 } |
|
106 |
|
107 EapQtConfigInterface* confIf = mWizard->eapConfigurationInterface(); |
|
108 // ignore return value |
|
109 confIf->updateCertificates(); |
|
110 mCerts = confIf->userCertificates(); |
|
111 |
|
112 QStringList list; |
|
113 for (int i = 0; i < mCerts.count(); ++i) { |
|
114 list << mCerts.at(i).value(EapQtCertificateInfo::CertificateLabel).toString(); |
|
115 } |
|
116 |
|
117 if (list.isEmpty()) { |
|
118 mErrorLabel->setVisible(true); |
|
119 mCertList->setVisible(false); |
|
120 mValid = false; |
|
121 } else if (list != mCertList->items()){ |
|
122 // in case the user cert list has been changed, update UI |
|
123 mCertList->setItems(list); |
|
124 mErrorLabel->setVisible(false); |
|
125 mCertList->setVisible(true); |
|
126 |
|
127 if (list.count() == 1) { |
|
128 mValid = true; |
|
129 mCertList->setSelected(0); |
|
130 } else { |
|
131 mValid = false; |
|
132 } |
|
133 } |
|
134 return mWidget; |
|
135 } |
|
136 |
|
137 /*! |
|
138 Loads the required orientation of docml. |
|
139 |
|
140 @param [in] orientation Orientation to be loaded. |
|
141 */ |
|
142 void EapWizardPageCertUser::loadDocmlSection(Qt::Orientation orientation) |
|
143 { |
|
144 EapWizardPage::loadDocmlSection( |
|
145 mDocumentLoader.data(), |
|
146 orientation, |
|
147 ":/docml/occ_eap_wizard_06.docml", |
|
148 "portrait_section", |
|
149 "landscape_section"); |
|
150 } |
|
151 |
|
152 /*! |
|
153 See WlanWizardPage. |
|
154 |
|
155 @return next wizard page: EapWizardPage::PageIdentity |
|
156 */ |
|
157 int EapWizardPageCertUser::nextId() const |
|
158 { |
|
159 mWizard->setConfigurations( |
|
160 EapWizardPrivate::CertificateUser, |
|
161 qVariantFromValue( |
|
162 mCerts.at(mCertList->selected()))); |
|
163 |
|
164 return EapWizardPage::PageIdentity; |
|
165 } |
|
166 |
|
167 /*! |
|
168 See WlanWizardPage. |
|
169 |
|
170 Validates the content of the page. |
|
171 |
|
172 @return true if content is valid. |
|
173 */ |
|
174 bool EapWizardPageCertUser::showPage() |
|
175 { |
|
176 return mValid; |
|
177 } |
|
178 |
|
179 /*! |
|
180 Handler for itemsSelected() signal from HbRadioButtonList. |
|
181 |
|
182 @param [in] index NOT USED |
|
183 */ |
|
184 void EapWizardPageCertUser::itemSelected(int index) |
|
185 { |
|
186 Q_UNUSED(index); |
|
187 mValid = true; |
|
188 mWizard->wizardHelper()->enableNextButton(mValid); |
|
189 } |
|
190 |