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: Certificate Authority Selection. |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 |
|
20 #include <HbDocumentLoader> |
|
21 #include <HbMainWindow> |
|
22 #include <HbWidget> |
|
23 #include <HbRadioButtonList> |
|
24 #include <HbLabel> |
|
25 |
|
26 #include <eapqtpluginhandle.h> |
|
27 #include <eapqtplugininfo.h> |
|
28 #include <eapqtconfiginterface.h> |
|
29 #include <eapqtcertificateinfo.h> |
|
30 |
|
31 // User includes |
|
32 |
|
33 #include "wlanwizardhelper.h" |
|
34 #include "eapwizard_p.h" |
|
35 #include "eapwizardpagecertca.h" |
|
36 |
|
37 #include "OstTraceDefinitions.h" |
|
38 #ifdef OST_TRACE_COMPILER_IN_USE |
|
39 #include "eapwizardpagecertcaTraces.h" |
|
40 #endif |
|
41 |
|
42 |
|
43 /*! |
|
44 \class EapWizardPageCertCa |
|
45 \brief Implements EAP wizard page: Certificate Authority selection |
|
46 */ |
|
47 |
|
48 // External function prototypes |
|
49 |
|
50 // Local constants |
|
51 |
|
52 // ======== LOCAL FUNCTIONS ======== |
|
53 |
|
54 // ======== MEMBER FUNCTIONS ======== |
|
55 |
|
56 |
|
57 /*! |
|
58 Constructor. |
|
59 |
|
60 @param [in] parent Pointer to EAP Wizard private implementation. |
|
61 */ |
|
62 EapWizardPageCertCa::EapWizardPageCertCa(EapWizardPrivate* parent) : |
|
63 EapWizardPage(parent), |
|
64 mDocumentLoader(NULL), |
|
65 mWidget(NULL), |
|
66 mTitle(NULL), |
|
67 mCertList(NULL) |
|
68 { |
|
69 OstTraceFunctionEntry0(EAPWIZARDPAGECERTCA_EAPWIZARDPAGECERTCA_ENTRY); |
|
70 OstTraceFunctionExit0(EAPWIZARDPAGECERTCA_EAPWIZARDPAGECERTCA_EXIT); |
|
71 } |
|
72 |
|
73 /*! |
|
74 Destructor. |
|
75 */ |
|
76 EapWizardPageCertCa::~EapWizardPageCertCa() |
|
77 { |
|
78 OstTraceFunctionEntry0(DUP1_EAPWIZARDPAGECERTCA_EAPWIZARDPAGECERTCA_ENTRY); |
|
79 OstTraceFunctionExit0(DUP1_EAPWIZARDPAGECERTCA_EAPWIZARDPAGECERTCA_EXIT); |
|
80 } |
|
81 |
|
82 /*! |
|
83 See WlanWizardPage. |
|
84 */ |
|
85 HbWidget* EapWizardPageCertCa::initializePage() |
|
86 { |
|
87 OstTraceFunctionEntry0(EAPWIZARDPAGECERTCA_INITIALIZEPAGE_ENTRY); |
|
88 |
|
89 if (!mWidget) { |
|
90 mDocumentLoader.reset( new HbDocumentLoader( |
|
91 mWizard->wizardHelper()->mainWindow()) ); |
|
92 |
|
93 bool ok; |
|
94 mDocumentLoader->load(":/docml/occ_eap_wizard_01_02_04.docml", &ok); |
|
95 Q_ASSERT(ok); |
|
96 |
|
97 loadDocmlSection(mWizard->wizardHelper()->mainWindow()->orientation()); |
|
98 |
|
99 mWidget = qobject_cast<HbWidget*> ( |
|
100 mDocumentLoader->findWidget("occ_eap_wizard_01")); |
|
101 Q_ASSERT(mWidget); |
|
102 |
|
103 mCertList = qobject_cast<HbRadioButtonList*> ( |
|
104 mDocumentLoader->findWidget("list")); |
|
105 Q_ASSERT(mCertList); |
|
106 |
|
107 mTitle = qobject_cast<HbLabel*> (mDocumentLoader->findWidget("title")); |
|
108 Q_ASSERT(mTitle); |
|
109 |
|
110 mTitle->setPlainText( |
|
111 hbTrId("txt_occ_title_select_authority_certificate")); |
|
112 |
|
113 ok = connect( |
|
114 mWizard->wizardHelper()->mainWindow(), |
|
115 SIGNAL(orientationChanged(Qt::Orientation)), |
|
116 this, |
|
117 SLOT(loadDocmlSection(Qt::Orientation))); |
|
118 Q_ASSERT(ok); |
|
119 } |
|
120 |
|
121 EapQtConfigInterface* confIf = mWizard->eapConfigurationInterface(); |
|
122 // ignore return value |
|
123 confIf->updateCertificates(); |
|
124 mCerts = confIf->certificateAuthorityCertificates(); |
|
125 |
|
126 QStringList list; |
|
127 list << hbTrId("txt_occ_setlabel_val_select_automatically"); |
|
128 for (int i = 0; i < mCerts.count(); ++i) { |
|
129 list << mCerts.at(i).value(EapQtCertificateInfo::CertificateLabel).toString(); |
|
130 } |
|
131 |
|
132 // If certificate list has been changed update the content otherwise do not |
|
133 // change it |
|
134 if (list != mCertList->items()) { |
|
135 mCertList->setItems(list); |
|
136 // Automatic is selected by default |
|
137 mCertList->setSelected(IndexForAutomatic); |
|
138 } |
|
139 |
|
140 OstTraceFunctionExit0(EAPWIZARDPAGECERTCA_INITIALIZEPAGE_EXIT); |
|
141 return mWidget; |
|
142 } |
|
143 |
|
144 /*! |
|
145 Loads the required orientation of docml. |
|
146 |
|
147 @param [in] orientation Orientation to be loaded. |
|
148 */ |
|
149 void EapWizardPageCertCa::loadDocmlSection(Qt::Orientation orientation) |
|
150 { |
|
151 OstTraceFunctionEntry0(EAPWIZARDPAGECERTCA_LOADDOCMLSECTION_ENTRY); |
|
152 |
|
153 EapWizardPage::loadDocmlSection( |
|
154 mDocumentLoader.data(), |
|
155 orientation, |
|
156 ":/docml/occ_eap_wizard_01_02_04.docml", |
|
157 "portrait_section", |
|
158 "landscape_section"); |
|
159 |
|
160 OstTraceFunctionExit0(EAPWIZARDPAGECERTCA_LOADDOCMLSECTION_EXIT); |
|
161 } |
|
162 |
|
163 /*! |
|
164 See WlanWizardPage. |
|
165 |
|
166 @return next wizard page: |
|
167 - EapWizardPage::PageCertificateUser: For EAP-TLS |
|
168 - EapWizardPage::PageIdentity: For EAP-TTLS and PEAP |
|
169 */ |
|
170 int EapWizardPageCertCa::nextId() const |
|
171 { |
|
172 OstTraceFunctionEntry0(EAPWIZARDPAGECERTCA_NEXTID_ENTRY); |
|
173 |
|
174 int id = WlanWizardPage::PageNone; |
|
175 bool ok; |
|
176 int type = mWizard->configurations(EapWizardPrivate::OuterType).toInt(&ok); |
|
177 Q_ASSERT(ok); |
|
178 |
|
179 if (type == EapQtPluginHandle::PluginEapTls) { |
|
180 id = EapWizardPage::PageCertificateUser; |
|
181 } else { |
|
182 Q_ASSERT( |
|
183 type == EapQtPluginHandle::PluginEapTtls || |
|
184 type == EapQtPluginHandle::PluginPeap); |
|
185 id = EapWizardPage::PageIdentity; |
|
186 } |
|
187 |
|
188 int selected = mCertList->selected(); |
|
189 if (selected == IndexForAutomatic) { |
|
190 mWizard->setConfigurations( |
|
191 EapWizardPrivate::CertificateCa, |
|
192 QVariant()); |
|
193 } else { |
|
194 mWizard->setConfigurations( |
|
195 EapWizardPrivate::CertificateCa, |
|
196 qVariantFromValue(mCerts.at(selected - AmountOfNonCertItems))); |
|
197 } |
|
198 |
|
199 OstTraceFunctionExit0(EAPWIZARDPAGECERTCA_NEXTID_EXIT); |
|
200 return id; |
|
201 } |
|