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