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