45
|
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: omacppinquerydialog class implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
52
|
18 |
#include <e32property.h>
|
45
|
19 |
#include <qdebug.h>
|
|
20 |
#include <qtranslator.h>
|
|
21 |
#include <qcoreapplication.h>
|
52
|
22 |
#include <hbaction.h>
|
45
|
23 |
#include <devicedialogconsts.h>
|
|
24 |
#include "omacppinquerydialog.h"
|
|
25 |
#include "pnputillogger.h"
|
|
26 |
|
|
27 |
// ----------------------------------------------------------------------------
|
|
28 |
// omacppinquerydialog ::omacppinquerydialog
|
|
29 |
// Initialization of member variables; Create Pin query
|
|
30 |
// ----------------------------------------------------------------------------
|
|
31 |
//
|
67
|
32 |
omacppinquerydialog::omacppinquerydialog(const QVariantMap ¶meters)
|
45
|
33 |
{
|
|
34 |
qDebug("omacppinquerydialog omacppinquerydialog() start");
|
67
|
35 |
|
|
36 |
// Do translation
|
|
37 |
QTranslator *translator = new QTranslator();
|
|
38 |
QString lang = QLocale::system().name();
|
|
39 |
QString path = "Z:/resource/qt/translations/";
|
|
40 |
bool fine = translator->load("deviceupdates_en.qm", path);
|
|
41 |
if (fine)
|
|
42 |
qApp->installTranslator(translator);
|
|
43 |
|
|
44 |
QTranslator *commontranslator = new QTranslator();
|
|
45 |
|
|
46 |
fine = commontranslator->load("common_" + lang, path);
|
|
47 |
if (fine)
|
|
48 |
qApp->installTranslator(commontranslator);
|
|
49 |
|
45
|
50 |
mlineedit = 0;
|
|
51 |
mactionok = 0;
|
67
|
52 |
mDialog = 0;
|
45
|
53 |
createcppinquery(parameters);
|
|
54 |
qDebug("omacppinquerydialog omacppinquerydialog() end");
|
|
55 |
}
|
|
56 |
|
67
|
57 |
|
|
58 |
// Set parameters
|
|
59 |
bool omacppinquerydialog::setDeviceDialogParameters(
|
|
60 |
const QVariantMap ¶meters)
|
|
61 |
{
|
|
62 |
|
|
63 |
return true;
|
|
64 |
}
|
|
65 |
|
|
66 |
// Get error
|
|
67 |
int omacppinquerydialog::deviceDialogError() const
|
|
68 |
{
|
|
69 |
|
|
70 |
return 0;
|
|
71 |
}
|
|
72 |
|
45
|
73 |
HbDialog *omacppinquerydialog::deviceDialogWidget() const
|
|
74 |
{
|
67
|
75 |
return mDialog;
|
45
|
76 |
}
|
|
77 |
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
// omacppinquerydialog ::createcppinquery
|
|
80 |
// Create Pin query dialog from docml; Connect the signals to slots
|
|
81 |
// ----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void omacppinquerydialog::createcppinquery(const QVariantMap ¶meters)
|
|
84 |
{
|
|
85 |
qDebug("omacppinquerydialog createcppinquery() start");
|
|
86 |
HbDocumentLoader loader;
|
|
87 |
bool ok = false;
|
|
88 |
loader.load(":/xml/resources/pin.docml", &ok);
|
|
89 |
if (!ok)
|
|
90 |
{
|
46
|
91 |
qFatal("omacppinquerydialog createcppinquery() Unable to read pin.docml");
|
|
92 |
|
45
|
93 |
}
|
|
94 |
|
67
|
95 |
|
|
96 |
mDialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
|
|
97 |
mDialog->setDismissPolicy(HbPopup::NoDismiss);
|
|
98 |
mDialog->setTimeout(HbPopup::NoTimeout);
|
45
|
99 |
|
|
100 |
int tries = -1;
|
|
101 |
|
|
102 |
//Get the reties left
|
|
103 |
QVariantMap::const_iterator i = parameters.find(keyparam1);
|
|
104 |
if (i != parameters.end())
|
|
105 |
{
|
|
106 |
tries = i.value().toInt();
|
|
107 |
}
|
|
108 |
// In the first trial, show label without tries
|
|
109 |
HbLabel *label = qobject_cast<HbLabel *> (loader.findObject("label"));
|
|
110 |
QString labelstring = hbTrId(
|
|
111 |
"txt_device_update_dialog_enter_the_configuration_p");
|
|
112 |
|
|
113 |
// In the second and third trials, show label with tries left
|
|
114 |
if ((tries >= 1) && (tries <= (KPinRetries - 1)))
|
|
115 |
{
|
|
116 |
labelstring = hbTrId(
|
|
117 |
"txt_device_update_dialog_enter_the_config_trial");
|
|
118 |
label->setNumber(tries);
|
|
119 |
}
|
|
120 |
|
|
121 |
label->setPlainText(labelstring);
|
|
122 |
|
67
|
123 |
mactionok = (HbAction *) mDialog->actions().first();
|
45
|
124 |
QString softkeyok = hbTrId("txt_common_button_ok");
|
|
125 |
mactionok->setText(softkeyok);
|
|
126 |
mactionok->setEnabled(false);
|
|
127 |
|
67
|
128 |
HbAction *actioncancel = (HbAction *) mDialog->actions().at(1);
|
45
|
129 |
QString softkeyCancel = hbTrId("txt_common_button_cancel");
|
|
130 |
actioncancel->setText(softkeyCancel);
|
|
131 |
|
|
132 |
mlineedit = qobject_cast<HbLineEdit *> (loader.findObject("lineEdit"));
|
|
133 |
mlineedit->setEchoMode(HbLineEdit::Password);
|
|
134 |
mlineedit->setMaxLength(KCPPinMaxLength);
|
|
135 |
|
|
136 |
mlineedit->setInputMethodHints(Qt::ImhDigitsOnly);
|
|
137 |
HbEditorInterface editorInterface(mlineedit);
|
|
138 |
editorInterface.setMode(HbInputModeNumeric);
|
|
139 |
editorInterface.setInputConstraints(HbEditorConstraintFixedInputMode);
|
67
|
140 |
mDialog->setTimeout(HbPopup::NoTimeout);
|
45
|
141 |
|
|
142 |
bool bconnect = false;
|
|
143 |
// Connection to the slot when PIN text is changed
|
|
144 |
bconnect = QObject::connect(mlineedit, SIGNAL(contentsChanged()), this,
|
|
145 |
SLOT( pintextChanged()));
|
|
146 |
|
|
147 |
qDebug("omacppinquerydialog::createcppinquery() bconnect value ");
|
|
148 |
qDebug() << bconnect;
|
|
149 |
|
|
150 |
// Connections to the slot when Ok and Cancel buttons are clicked
|
|
151 |
QObject::connect(mactionok, SIGNAL(triggered()), this, SLOT(okSelected()));
|
|
152 |
QObject::connect(actioncancel, SIGNAL(triggered()), this,
|
|
153 |
SLOT(cancelSelected()));
|
|
154 |
|
67
|
155 |
|
45
|
156 |
|
|
157 |
|
|
158 |
qDebug("omacppinquerydialog createcppinquery() end");
|
|
159 |
}
|
|
160 |
|
|
161 |
// ----------------------------------------------------------------------------
|
|
162 |
// omacppinquerydialog ::pintextChanged
|
|
163 |
// Slot to enable/disable Ok button when text is entered/deleted
|
|
164 |
// ----------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
void omacppinquerydialog::pintextChanged()
|
|
167 |
{
|
|
168 |
qDebug("omacppinquerydialog::pintextChanged start");
|
|
169 |
LOGSTRING("omacppinquerydialog::pintextChanged start");
|
|
170 |
int textlength = 0;
|
|
171 |
textlength = mlineedit->text().length();
|
|
172 |
LOGSTRING2("omacppinquerydialog::pintextChanged start %d", textlength);
|
|
173 |
|
|
174 |
if (textlength > 0)
|
|
175 |
{
|
|
176 |
//If text length is positive, enable Ok button
|
|
177 |
qDebug("omacppinquerydialog::pintextChanged text is entered");
|
|
178 |
LOGSTRING("omacppinquerydialog::pintextChanged text is entered");
|
|
179 |
mactionok->setEnabled(true);
|
|
180 |
}
|
|
181 |
else if (textlength == 0)
|
|
182 |
{
|
|
183 |
//If text length is zero, disable Ok button
|
|
184 |
qDebug("omacppinquerydialog::pintextChanged zero text");
|
|
185 |
LOGSTRING("omacppinquerydialog::pintextChanged zero text");
|
|
186 |
mactionok->setEnabled(false);
|
|
187 |
}
|
|
188 |
qDebug("omacppinquerydialog::pintextChanged end");
|
|
189 |
}
|
|
190 |
|
|
191 |
// ----------------------------------------------------------------------------
|
|
192 |
// omacppinquerydialog ::okSelected
|
|
193 |
// Slot to emit signals when Ok is selected
|
|
194 |
// ----------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
void omacppinquerydialog::okSelected()
|
|
197 |
{
|
|
198 |
qDebug("omacppinquerydialog::okSelected() start");
|
|
199 |
LOGSTRING("omacppinquerydialog::okSelected() start");
|
|
200 |
|
|
201 |
QString stringpin = mlineedit->text();
|
|
202 |
QVariantMap resultMap;
|
|
203 |
resultMap.insert(pinquery, stringpin);
|
|
204 |
resultMap.insert(returnkey, EHbLSK);
|
|
205 |
|
|
206 |
//Emit signals with the data
|
|
207 |
emit
|
|
208 |
deviceDialogData(resultMap);
|
|
209 |
emit deviceDialogClosed();
|
|
210 |
qDebug("omacppinquerydialog::okSelected() end");
|
|
211 |
LOGSTRING("omacppinquerydialog::okSelected() end");
|
|
212 |
}
|
|
213 |
|
|
214 |
// ----------------------------------------------------------------------------
|
|
215 |
// omacppinquerydialog ::cancelSelected
|
|
216 |
// Slot to emit signals when Cancel is selected
|
|
217 |
// ----------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
void omacppinquerydialog::cancelSelected()
|
|
220 |
{
|
|
221 |
qDebug("omacppinquerydialog::cancelSelected() start");
|
|
222 |
LOGSTRING("omacppinquerydialog::cancelSelected() start");
|
|
223 |
QVariantMap resultMap;
|
|
224 |
resultMap.insert(returnkey, EHbRSK);
|
|
225 |
|
|
226 |
//Emit signals with the data
|
|
227 |
emit
|
|
228 |
deviceDialogData(resultMap);
|
|
229 |
emit deviceDialogClosed();
|
|
230 |
|
|
231 |
LOGSTRING("omacppinquerydialog::cancelSelected() end");
|
|
232 |
qDebug("omacppinquerydialog::cancelSelected() end");
|
|
233 |
}
|
|
234 |
|
67
|
235 |
// Close device dialog
|
|
236 |
void omacppinquerydialog::closeDeviceDialog(bool byClient)
|
|
237 |
{
|
|
238 |
Q_UNUSED(byClient);
|
|
239 |
mDialog->close();
|
|
240 |
emit deviceDialogClosed();
|
|
241 |
}
|
|
242 |
|
|
243 |
// Return signal source (container) for the dialog
|
|
244 |
QObject *omacppinquerydialog::signalSender() const
|
|
245 |
{
|
|
246 |
return const_cast<omacppinquerydialog*>(this);
|
|
247 |
}
|
|
248 |
|
45
|
249 |
// End of File
|
|
250 |
|