21 // #include <hbpopupbase.h> // HbPopupBase::NoTimeout |
21 // #include <hbpopupbase.h> // HbPopupBase::NoTimeout |
22 #include <hblabel.h> |
22 #include <hblabel.h> |
23 #include <hbaction.h> |
23 #include <hbaction.h> |
24 #include <QDebug> |
24 #include <QDebug> |
25 #include <e32debug.h> |
25 #include <e32debug.h> |
26 #include <CPhCltEmergencyCall.h> |
26 #include <cphcltemergencycall.h> |
27 #include <SCPServerInterface.h> // for TARM error codes while validating new lock code |
27 #include <SCPServerInterface.h> // for TARM error codes while validating new lock code |
28 #include <QString> |
28 #include <QString> |
29 #include <QDialogButtonBox> |
29 #include <QDialogButtonBox> |
|
30 #include <e32property.h> |
|
31 |
|
32 QTM_USE_NAMESPACE |
|
33 |
|
34 #include <qvaluespacesubscriber.h> |
|
35 #include <qvaluespacepublisher.h> |
30 |
36 |
31 #define ESecUiCancelSupported 0x1000000 |
37 #define ESecUiCancelSupported 0x1000000 |
32 #define ESecUiCancelNotSupported 0x0000000 |
38 #define ESecUiCancelNotSupported 0x0000000 |
33 |
39 |
34 #define ESecUiEmergencySupported 0x2000000 |
40 #define ESecUiEmergencySupported 0x2000000 |
48 #define ESecUiTypeClock 0x00300000 |
54 #define ESecUiTypeClock 0x00300000 |
49 #define ESecUiTypeScreensaver 0x00400000 |
55 #define ESecUiTypeScreensaver 0x00400000 |
50 |
56 |
51 #define ESecUiTypeMaskLock 0x00F00000 |
57 #define ESecUiTypeMaskLock 0x00F00000 |
52 |
58 |
|
59 const TUid KPSUidSecurityUIs = { 0x100059b5 }; |
|
60 const TUint32 KSecurityUIsDismissDialog = 0x00000309; |
|
61 |
53 // ---------------------------------------------------------------------------- |
62 // ---------------------------------------------------------------------------- |
54 // SecUiNotificationDialog::SecUiNotificationDialog() |
63 // SecUiNotificationDialog::SecUiNotificationDialog() |
55 // ---------------------------------------------------------------------------- |
64 // ---------------------------------------------------------------------------- |
56 // |
65 // |
57 SecUiNotificationDialog::SecUiNotificationDialog( |
66 SecUiNotificationDialog::SecUiNotificationDialog( |
95 // ---------------------------------------------------------------------------- |
104 // ---------------------------------------------------------------------------- |
96 // |
105 // |
97 void SecUiNotificationDialog::closeDeviceDialog(bool byClient) |
106 void SecUiNotificationDialog::closeDeviceDialog(bool byClient) |
98 { |
107 { |
99 Q_UNUSED(byClient); |
108 Q_UNUSED(byClient); |
|
109 qDebug() << "SecUiNotificationDialog::closeDeviceDialog 0"; |
100 close(); |
110 close(); |
101 qDebug() << "SecUiNotificationDialog::closeDeviceDialog"; |
111 qDebug() << "SecUiNotificationDialog::closeDeviceDialog 1"; |
102 |
112 |
103 // If show event has been received, close is signalled from hide event. |
113 // If show event has been received, close is signalled from hide event. |
104 // If not, hide event does not come and close is signalled from here. |
114 // If not, hide event does not come and close is signalled from here. |
105 if (!mShowEventReceived) { |
115 if (!mShowEventReceived) { |
106 emit deviceDialogClosed(); |
116 emit deviceDialogClosed(); |
133 // |
143 // |
134 void SecUiNotificationDialog::showEvent(QShowEvent *event) |
144 void SecUiNotificationDialog::showEvent(QShowEvent *event) |
135 { |
145 { |
136 qDebug() << "SecUiNotificationDialog::showEvent"; |
146 qDebug() << "SecUiNotificationDialog::showEvent"; |
137 HbDialog::showEvent(event); |
147 HbDialog::showEvent(event); |
|
148 |
|
149 if(!(queryType & ESecUiTypeMaskLock)) |
|
150 { // not for the "lock icon" |
|
151 qDebug() << "SecUiNotificationDialog::showEvent check default"; |
|
152 if(codeTop->text().length()>0) // there's a default value. Verify it and (might) enable OK |
|
153 { |
|
154 qDebug() << "SecUiNotificationDialog::showEvent checked default"; |
|
155 handleCodeTopChanged(codeTop->text()); |
|
156 } |
|
157 // for automated testing, read a P&S and use this value as if the user typed it |
|
158 const TUint32 KSecurityUIsTestCode = 0x00000307; |
|
159 TInt value = 0; |
|
160 TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsTestCode, value ); |
|
161 qDebug() << "SecUiNotificationDialog::faking KSecurityUIsTestCode err=" << err; |
|
162 qDebug() << "SecUiNotificationDialog::faking value=" << value; |
|
163 if(value>0 && mShowEventReceived==false) // show happens 2 times. Dialog can be closed only the second. |
|
164 { |
|
165 QString myString = ""; |
|
166 myString += QString("%1").arg(value); |
|
167 qDebug() << "SecUiNotificationDialog::faking myString=" << myString; |
|
168 codeTop->setText( myString ); |
|
169 TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsTestCode, 0 ); // clear after using it |
|
170 qDebug() << "SecUiNotificationDialog::calling handleAccepted=" << myString; |
|
171 emit handleAccepted(); |
|
172 emit closeDeviceDialog(false); // false means "not by client", although it's not really used |
|
173 } |
|
174 } |
138 mShowEventReceived = true; |
175 mShowEventReceived = true; |
139 } |
176 } |
140 |
177 |
141 // ---------------------------------------------------------------------------- |
178 // ---------------------------------------------------------------------------- |
142 // SecUiNotificationDialog::constructDialog() |
179 // SecUiNotificationDialog::constructDialog() |
146 { |
183 { |
147 qDebug() << "SecUiNotificationDialog::constructDialog"; |
184 qDebug() << "SecUiNotificationDialog::constructDialog"; |
148 setTimeout(HbPopup::NoTimeout); |
185 setTimeout(HbPopup::NoTimeout); |
149 setDismissPolicy(HbPopup::NoDismiss); |
186 setDismissPolicy(HbPopup::NoDismiss); |
150 setModal(true); |
187 setModal(true); |
|
188 mShowEventReceived = false; |
151 |
189 |
152 // Title |
190 // Title |
153 if (parameters.contains(KDialogTitle)) { |
191 if (parameters.contains(KDialogTitle)) { |
154 QString titleText = parameters.value(KDialogTitle).toString(); |
192 QString titleText = parameters.value(KDialogTitle).toString(); |
155 QString titleAttempts = ""; |
193 QString titleAttempts = ""; |
205 if(invalidNumber<0) |
243 if(invalidNumber<0) |
206 { |
244 { |
207 qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???"; |
245 qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode ???"; |
208 // nothing to do |
246 // nothing to do |
209 } |
247 } |
210 /* |
248 if(invalidNumber==EDeviceLockAutolockperiod) |
211 if(invalidNumber==EDeviceLockAutolockperiod) |
|
212 { |
249 { |
213 qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod"; |
250 qDebug() << "SecUiNotificationDialog::KInvalidNewLockCode EDeviceLockAutolockperiod"; |
214 title->setPlainText("EDeviceLockAutolockperiod"); |
251 title->setPlainText("EDeviceLockAutolockperiod"); |
215 } |
252 } |
216 if(invalidNumber==EDeviceLockMaxAutolockPeriod) |
253 if(invalidNumber==EDeviceLockMaxAutolockPeriod) |
341 cancelAction = new HbAction(tr("Cancel")); // qtTrId("txt_common_button_cancel") |
377 cancelAction = new HbAction(tr("Cancel")); // qtTrId("txt_common_button_cancel") |
342 connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled())); |
378 connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancelled())); |
343 // setAction(cancelAction, QDialogButtonBox::RejectRole); // it's supposed to use this, when deprecated |
379 // setAction(cancelAction, QDialogButtonBox::RejectRole); // it's supposed to use this, when deprecated |
344 setSecondaryAction(cancelAction); |
380 setSecondaryAction(cancelAction); |
345 |
381 |
|
382 // this should had been set by Autolock, but just to be sure |
|
383 TInt ret = RProperty::Define(KPSUidSecurityUIs, KSecurityUIsDismissDialog, |
|
384 RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass), |
|
385 TSecurityPolicy(TSecurityPolicy::EAlwaysPass)); |
|
386 RDEBUG("defined KSecurityUIsDismissDialog", ret); |
|
387 subscriberKSecurityUIsDismissDialog = new QValueSpaceSubscriber( |
|
388 "/KPSUidSecurityUIs/KSecurityUIsDismissDialog", this); |
|
389 connect(subscriberKSecurityUIsDismissDialog, SIGNAL(contentsChanged()), this, |
|
390 SLOT(subscriberKSecurityUIsDismissDialogChanged())); |
|
391 qDebug() << "subscribed to KSecurityUIsDismissDialog"; |
|
392 |
346 qDebug() << "SecUiNotificationDialog check Cancel"; |
393 qDebug() << "SecUiNotificationDialog check Cancel"; |
347 if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported) |
394 if ((queryType & ESecUiCancelSupported)==ESecUiCancelSupported) |
348 { |
395 { |
349 // nothing to do. Cancel is enabled by default |
396 // nothing to do. Cancel is enabled by default |
350 } |
397 } |
545 // SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*) |
592 // SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*) |
546 // ---------------------------------------------------------------------------- |
593 // ---------------------------------------------------------------------------- |
547 // |
594 // |
548 void SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*) |
595 void SecUiNotificationDialog::saveFocusWidget(QWidget*,QWidget*) |
549 { |
596 { |
550 qDebug() << "SecUiNotificationDialog::saveFocusWidget"; |
597 RDEBUG("0", 0); |
551 } |
598 } |
|
599 |
|
600 // ---------------------------------------------------------------------------- |
|
601 // SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged() |
|
602 // A way for Autolock to dismiss any possible PIN dialog |
|
603 // ---------------------------------------------------------------------------- |
|
604 // |
|
605 void SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged() |
|
606 { |
|
607 enum TSecurityUIsDismissDialogValues |
|
608 { |
|
609 ESecurityUIsDismissDialogUninitialized = 0, |
|
610 ESecurityUIsDismissDialogOn, |
|
611 ESecurityUIsDismissDialogProcessing, |
|
612 ESecurityUIsDismissDialogDone, |
|
613 ESecurityUIsDismissDialogLastValue |
|
614 }; |
|
615 |
|
616 TInt ret; |
|
617 RDEBUG("0", 0); |
|
618 TInt aDismissDialog = ESecurityUIsDismissDialogUninitialized; |
|
619 TInt err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsDismissDialog, aDismissDialog ); |
|
620 RDEBUG("err", err); |
|
621 RDEBUG("aDismissDialog", aDismissDialog); |
|
622 if( aDismissDialog == ESecurityUIsDismissDialogOn ) |
|
623 { |
|
624 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogProcessing ); |
|
625 RDEBUG("err", err); |
|
626 // TODO perhaps do this only if Cancel is allowed? |
|
627 RDEBUG("sendResult(KErrDied)", 0); |
|
628 sendResult(KErrDied); // similar to emit handleCancelled(); |
|
629 RDEBUG("emit closeDeviceDialog", 0); |
|
630 emit closeDeviceDialog(false); // false means "not by client", although it's not really used |
|
631 RDEBUG("all emited", 0); |
|
632 err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogDone ); // clear after using it |
|
633 RDEBUG("err", err); |
|
634 } |
|
635 } |