31
|
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 |
* WLAN Wizard Page: SSID Selection.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// System includes
|
|
20 |
#include <HbDocumentLoader>
|
|
21 |
#include <HbMainWindow>
|
|
22 |
#include <HbWidget>
|
|
23 |
#include <HbLineEdit>
|
|
24 |
#include <HbEditorInterface>
|
|
25 |
#include <HbLabel>
|
|
26 |
#include <wlanqtutils.h>
|
|
27 |
|
|
28 |
// User includes
|
|
29 |
#include "wlanwizardpagessid.h"
|
|
30 |
#include "wlanwizard_p.h"
|
|
31 |
#include "wlanwizardutils.h"
|
|
32 |
#include "OstTraceDefinitions.h"
|
|
33 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
34 |
#include "wlanwizardpagessidTraces.h"
|
|
35 |
#endif
|
|
36 |
|
|
37 |
/*!
|
|
38 |
* Constructor. Member initialization.
|
|
39 |
*/
|
|
40 |
WlanWizardPageSsid::WlanWizardPageSsid(WlanWizardPrivate* parent) :
|
|
41 |
WlanWizardPageInternal(parent),
|
|
42 |
mWidget(NULL),
|
|
43 |
mLabel(NULL),
|
|
44 |
mSsid(NULL),
|
|
45 |
mLabelError(NULL),
|
|
46 |
mLoader(NULL)
|
|
47 |
{
|
|
48 |
|
|
49 |
}
|
|
50 |
|
|
51 |
/*!
|
|
52 |
* Destructor. Loader widget is deleted.
|
|
53 |
* All document widgets are deleted by wlanwizard_p destructor.
|
|
54 |
*/
|
|
55 |
WlanWizardPageSsid::~WlanWizardPageSsid()
|
|
56 |
{
|
|
57 |
delete mLoader;
|
|
58 |
}
|
|
59 |
|
|
60 |
/*!
|
|
61 |
* Page initialization. If view is already loaded, does nothing.
|
|
62 |
*/
|
|
63 |
HbWidget* WlanWizardPageSsid::initializePage()
|
|
64 |
{
|
|
65 |
OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESSID_INITIALIZEPAGE,
|
|
66 |
"WlanWizardPageSsid::initializePage" );
|
|
67 |
|
|
68 |
if (mWidget == NULL) {
|
|
69 |
bool ok;
|
|
70 |
|
|
71 |
mLoader = new HbDocumentLoader(mWizard->mainWindow());
|
|
72 |
|
|
73 |
mLoader->load(":/docml/occ_add_wlan_01_04.docml", &ok);
|
|
74 |
Q_ASSERT_X(ok, "WlanWizardPageSsid", "Invalid docml file");
|
|
75 |
|
|
76 |
// Load orientation
|
|
77 |
loadDocml(mWizard->mainWindow()->orientation());
|
|
78 |
|
|
79 |
// Load widgets
|
|
80 |
mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
|
|
81 |
"occ_add_wlan_01"));
|
|
82 |
Q_ASSERT_X(mWidget != NULL, "WlanWizardPageSsid", "View not found");
|
|
83 |
|
|
84 |
mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog"));
|
|
85 |
Q_ASSERT_X(mLabel != NULL, "WlanWizardPageSsid", "dialog not found");
|
|
86 |
|
|
87 |
mSsid = qobject_cast<HbLineEdit*> (mLoader->findWidget("lineEditKey"));
|
|
88 |
Q_ASSERT_X(mSsid != NULL, "WlanWizardPageSsid", "lineEditKey not found");
|
|
89 |
|
|
90 |
mLabelError = qobject_cast<HbLabel*> (mLoader->findWidget(
|
|
91 |
"labelErrorNote"));
|
|
92 |
Q_ASSERT_X(mLabelError != NULL, "WlanWizardPageSsid",
|
|
93 |
"labelErrorNote not found");
|
|
94 |
|
|
95 |
mLabel->setPlainText(hbTrId(
|
|
96 |
"txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
|
|
97 |
|
|
98 |
// Connect orientation signal from the main window to orientation
|
|
99 |
// loader.
|
|
100 |
ok &= connect(mWizard->mainWindow(),
|
|
101 |
SIGNAL(orientationChanged(Qt::Orientation)), this,
|
|
102 |
SLOT(loadDocml(Qt::Orientation)));
|
|
103 |
|
|
104 |
// Connect text change-signal from input dialog to handler function
|
|
105 |
ok &= connect(mSsid, SIGNAL(textChanged(const QString &)), this,
|
|
106 |
SLOT(textChanged(const QString &)));
|
|
107 |
|
|
108 |
Q_ASSERT(ok);
|
|
109 |
|
|
110 |
HbEditorInterface editInterface(mSsid);
|
|
111 |
editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly);
|
|
112 |
|
|
113 |
|
|
114 |
editInterface.setSmileyTheme(HbSmileyTheme());
|
|
115 |
//editInterface.setEditorClass(HbInputEditorClassNetworkName);
|
|
116 |
mSsid->setInputMethodHints(
|
|
117 |
Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase);
|
|
118 |
mSsid->setMaxLength(WlanWizardUtils::SsidMaxLength);
|
|
119 |
mSsid->installEventFilter(this);
|
|
120 |
}
|
|
121 |
|
|
122 |
// Open virtual keyboard by setting focus to line edit
|
|
123 |
mSsid->setFocus();
|
|
124 |
|
|
125 |
return mWidget;
|
|
126 |
}
|
|
127 |
|
|
128 |
/*!
|
|
129 |
* Selection of the next page.
|
|
130 |
*/
|
|
131 |
int WlanWizardPageSsid::nextId(bool &removeFromStack) const
|
|
132 |
{
|
|
133 |
int pageId = WlanWizardPage::PageNone;
|
|
134 |
removeFromStack = false;
|
|
135 |
|
|
136 |
WlanWizardUtils::SsidStatus status = WlanWizardUtils::validateSsid(
|
|
137 |
mSsid->text());
|
|
138 |
|
|
139 |
if (status != WlanWizardUtils::SsidStatusOk) {
|
|
140 |
mLabelError->setPlainText(SsidStatusToErrorString(status));
|
|
141 |
}
|
|
142 |
else {
|
|
143 |
// SSID is stored into configuration
|
|
144 |
mWizard->setConfiguration(WlanWizardPrivate::ConfSsid, mSsid->text());
|
|
145 |
pageId = WlanWizardPageInternal::PageScanning;
|
|
146 |
}
|
|
147 |
|
|
148 |
return pageId;
|
|
149 |
}
|
|
150 |
|
|
151 |
/*!
|
|
152 |
* Load the document with given screen orientation.
|
|
153 |
*/
|
|
154 |
void WlanWizardPageSsid::loadDocml(Qt::Orientation orientation)
|
|
155 |
{
|
|
156 |
OstTrace1( TRACE_FLOW, WLANWIZARDPAGESSID_LOADDOCML,
|
|
157 |
"WlanWizardPageSsid::loadDocml - orientation ;orientation=%x",
|
|
158 |
( TUint )( orientation ) );
|
|
159 |
|
|
160 |
bool ok;
|
|
161 |
// Then load the orientation specific section
|
|
162 |
if (orientation == Qt::Horizontal) {
|
|
163 |
qDebug("Loading landscape section for wlan_01_04");
|
|
164 |
mLoader->load(":/docml/occ_add_wlan_01_04.docml", "landscape_section",
|
|
165 |
&ok);
|
|
166 |
Q_ASSERT(ok);
|
|
167 |
}
|
|
168 |
else {
|
|
169 |
Q_ASSERT(orientation == Qt::Vertical);
|
|
170 |
qDebug("Loading portrait section for wlan_01_04");
|
|
171 |
mLoader->load(":/docml/occ_add_wlan_01_04.docml", "portrait_section",
|
|
172 |
&ok);
|
|
173 |
Q_ASSERT(ok);
|
|
174 |
}
|
|
175 |
}
|
|
176 |
|
|
177 |
/*!
|
|
178 |
* Actions, when user makes changes to the text editor widget.
|
|
179 |
*/
|
|
180 |
void WlanWizardPageSsid::textChanged(const QString & /* text */)
|
|
181 |
{
|
|
182 |
OstTrace0( TRACE_FLOW, WLANWIZARDPAGESSID_TEXTCHANGED,
|
|
183 |
"WlanWizardPageSsid::textChanged in text edit widget" );
|
|
184 |
|
|
185 |
mWizard->enableNextButton(showPage());
|
|
186 |
}
|
|
187 |
|
|
188 |
/*!
|
|
189 |
* Returns true, if the text editor widget contains any characters.
|
|
190 |
*/
|
|
191 |
bool WlanWizardPageSsid::showPage()
|
|
192 |
{
|
|
193 |
// Initiate the scanning of public APs here.
|
|
194 |
mWizard->wlanQtUtils()->scanWlanAps();
|
|
195 |
|
|
196 |
return !(mSsid->text().isEmpty());
|
|
197 |
}
|
|
198 |
|
|
199 |
/*!
|
|
200 |
* Filter to catch focus event to the text editor widget.
|
|
201 |
*/
|
|
202 |
bool WlanWizardPageSsid::eventFilter(QObject *obj, QEvent *event)
|
|
203 |
{
|
|
204 |
if (obj == mSsid && event->type() == QEvent::FocusIn) {
|
|
205 |
OstTrace0( TRACE_BORDER, WLANWIZARDPAGESSID_EVENTFILTER,
|
|
206 |
"WlanWizardPageSsid::eventFilter text edit widget received focus" );
|
|
207 |
|
|
208 |
mLabelError->setPlainText("");
|
|
209 |
}
|
|
210 |
return false;
|
|
211 |
}
|
|
212 |
|
|
213 |
/*!
|
|
214 |
* Conversion function from SsidStatus to plain text.
|
|
215 |
*/
|
|
216 |
QString WlanWizardPageSsid::SsidStatusToErrorString(
|
|
217 |
WlanWizardUtils::SsidStatus status) const
|
|
218 |
{
|
|
219 |
QString errorString;
|
|
220 |
switch (status) {
|
|
221 |
case WlanWizardUtils::SsidStatusIllegalCharacters:
|
|
222 |
errorString = hbTrId(
|
|
223 |
"txt_occ_dialog_illegal_characters_in_key_please_c");
|
|
224 |
break;
|
|
225 |
case WlanWizardUtils::SsidStatusInvalidLength:
|
|
226 |
errorString
|
|
227 |
= hbTrId("txt_occ_dialog_key_is_of_incorrect_length_please");
|
|
228 |
break;
|
|
229 |
case WlanWizardUtils::SsidStatusOk:
|
|
230 |
default:
|
|
231 |
Q_ASSERT(WlanWizardUtils::SsidStatusOk == status);
|
|
232 |
break;
|
|
233 |
}
|
|
234 |
return errorString;
|
|
235 |
}
|
|
236 |
|