|
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 |
|
18 #include <e32Property.h> |
|
19 #include <qdebug.h> |
|
20 #include <qtranslator.h> |
|
21 #include <qcoreapplication.h> |
|
22 #include <HbAction.h> |
|
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 // |
|
32 omacppinquerydialog::omacppinquerydialog(const QVariantMap ¶meters) : |
|
33 devicemanagementnotifierwidget(parameters) |
|
34 { |
|
35 qDebug("omacppinquerydialog omacppinquerydialog() start"); |
|
36 mlineedit = 0; |
|
37 mactionok = 0; |
|
38 createcppinquery(parameters); |
|
39 qDebug("omacppinquerydialog omacppinquerydialog() end"); |
|
40 } |
|
41 |
|
42 HbDialog *omacppinquerydialog::deviceDialogWidget() const |
|
43 { |
|
44 return const_cast<omacppinquerydialog*> (this); |
|
45 } |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // omacppinquerydialog ::createcppinquery |
|
49 // Create Pin query dialog from docml; Connect the signals to slots |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 void omacppinquerydialog::createcppinquery(const QVariantMap ¶meters) |
|
53 { |
|
54 qDebug("omacppinquerydialog createcppinquery() start"); |
|
55 HbDocumentLoader loader; |
|
56 bool ok = false; |
|
57 loader.load(":/xml/resources/pin.docml", &ok); |
|
58 if (!ok) |
|
59 { |
|
60 qFatal("omacppinquerydialog createcppinquery() Unable to read pin.docml"); |
|
61 |
|
62 } |
|
63 |
|
64 HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog")); |
|
65 dialog->setDismissPolicy(HbPopup::NoDismiss); |
|
66 dialog->setTimeout(HbPopup::NoTimeout); |
|
67 |
|
68 int tries = -1; |
|
69 |
|
70 //Get the reties left |
|
71 QVariantMap::const_iterator i = parameters.find(keyparam1); |
|
72 if (i != parameters.end()) |
|
73 { |
|
74 tries = i.value().toInt(); |
|
75 } |
|
76 // In the first trial, show label without tries |
|
77 HbLabel *label = qobject_cast<HbLabel *> (loader.findObject("label")); |
|
78 QString labelstring = hbTrId( |
|
79 "txt_device_update_dialog_enter_the_configuration_p"); |
|
80 |
|
81 // In the second and third trials, show label with tries left |
|
82 if ((tries >= 1) && (tries <= (KPinRetries - 1))) |
|
83 { |
|
84 labelstring = hbTrId( |
|
85 "txt_device_update_dialog_enter_the_config_trial"); |
|
86 label->setNumber(tries); |
|
87 } |
|
88 |
|
89 label->setPlainText(labelstring); |
|
90 |
|
91 mactionok = (HbAction *) dialog->actions().first(); |
|
92 QString softkeyok = hbTrId("txt_common_button_ok"); |
|
93 mactionok->setText(softkeyok); |
|
94 mactionok->setEnabled(false); |
|
95 |
|
96 HbAction *actioncancel = (HbAction *) dialog->actions().at(1); |
|
97 QString softkeyCancel = hbTrId("txt_common_button_cancel"); |
|
98 actioncancel->setText(softkeyCancel); |
|
99 |
|
100 mlineedit = qobject_cast<HbLineEdit *> (loader.findObject("lineEdit")); |
|
101 mlineedit->setEchoMode(HbLineEdit::Password); |
|
102 mlineedit->setMaxLength(KCPPinMaxLength); |
|
103 |
|
104 mlineedit->setInputMethodHints(Qt::ImhDigitsOnly); |
|
105 HbEditorInterface editorInterface(mlineedit); |
|
106 editorInterface.setMode(HbInputModeNumeric); |
|
107 editorInterface.setInputConstraints(HbEditorConstraintFixedInputMode); |
|
108 dialog->setTimeout(HbPopup::NoTimeout); |
|
109 |
|
110 bool bconnect = false; |
|
111 // Connection to the slot when PIN text is changed |
|
112 bconnect = QObject::connect(mlineedit, SIGNAL(contentsChanged()), this, |
|
113 SLOT( pintextChanged())); |
|
114 |
|
115 qDebug("omacppinquerydialog::createcppinquery() bconnect value "); |
|
116 qDebug() << bconnect; |
|
117 |
|
118 // Connections to the slot when Ok and Cancel buttons are clicked |
|
119 QObject::connect(mactionok, SIGNAL(triggered()), this, SLOT(okSelected())); |
|
120 QObject::connect(actioncancel, SIGNAL(triggered()), this, |
|
121 SLOT(cancelSelected())); |
|
122 |
|
123 if (dialog) |
|
124 dialog->show(); |
|
125 |
|
126 |
|
127 |
|
128 qDebug("omacppinquerydialog createcppinquery() end"); |
|
129 } |
|
130 |
|
131 // ---------------------------------------------------------------------------- |
|
132 // omacppinquerydialog ::pintextChanged |
|
133 // Slot to enable/disable Ok button when text is entered/deleted |
|
134 // ---------------------------------------------------------------------------- |
|
135 // |
|
136 void omacppinquerydialog::pintextChanged() |
|
137 { |
|
138 qDebug("omacppinquerydialog::pintextChanged start"); |
|
139 LOGSTRING("omacppinquerydialog::pintextChanged start"); |
|
140 int textlength = 0; |
|
141 textlength = mlineedit->text().length(); |
|
142 LOGSTRING2("omacppinquerydialog::pintextChanged start %d", textlength); |
|
143 |
|
144 if (textlength > 0) |
|
145 { |
|
146 //If text length is positive, enable Ok button |
|
147 qDebug("omacppinquerydialog::pintextChanged text is entered"); |
|
148 LOGSTRING("omacppinquerydialog::pintextChanged text is entered"); |
|
149 mactionok->setEnabled(true); |
|
150 } |
|
151 else if (textlength == 0) |
|
152 { |
|
153 //If text length is zero, disable Ok button |
|
154 qDebug("omacppinquerydialog::pintextChanged zero text"); |
|
155 LOGSTRING("omacppinquerydialog::pintextChanged zero text"); |
|
156 mactionok->setEnabled(false); |
|
157 } |
|
158 qDebug("omacppinquerydialog::pintextChanged end"); |
|
159 } |
|
160 |
|
161 // ---------------------------------------------------------------------------- |
|
162 // omacppinquerydialog ::okSelected |
|
163 // Slot to emit signals when Ok is selected |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 void omacppinquerydialog::okSelected() |
|
167 { |
|
168 qDebug("omacppinquerydialog::okSelected() start"); |
|
169 LOGSTRING("omacppinquerydialog::okSelected() start"); |
|
170 |
|
171 QString stringpin = mlineedit->text(); |
|
172 QVariantMap resultMap; |
|
173 resultMap.insert(pinquery, stringpin); |
|
174 resultMap.insert(returnkey, EHbLSK); |
|
175 |
|
176 //Emit signals with the data |
|
177 emit |
|
178 deviceDialogData(resultMap); |
|
179 emit deviceDialogClosed(); |
|
180 qDebug("omacppinquerydialog::okSelected() end"); |
|
181 LOGSTRING("omacppinquerydialog::okSelected() end"); |
|
182 } |
|
183 |
|
184 // ---------------------------------------------------------------------------- |
|
185 // omacppinquerydialog ::cancelSelected |
|
186 // Slot to emit signals when Cancel is selected |
|
187 // ---------------------------------------------------------------------------- |
|
188 // |
|
189 void omacppinquerydialog::cancelSelected() |
|
190 { |
|
191 qDebug("omacppinquerydialog::cancelSelected() start"); |
|
192 LOGSTRING("omacppinquerydialog::cancelSelected() start"); |
|
193 QVariantMap resultMap; |
|
194 resultMap.insert(returnkey, EHbRSK); |
|
195 |
|
196 //Emit signals with the data |
|
197 emit |
|
198 deviceDialogData(resultMap); |
|
199 emit deviceDialogClosed(); |
|
200 |
|
201 LOGSTRING("omacppinquerydialog::cancelSelected() end"); |
|
202 qDebug("omacppinquerydialog::cancelSelected() end"); |
|
203 } |
|
204 |
|
205 // End of File |
|
206 |