--- a/pkiutilities/untrustedcertificatedialog/src/untrustedcertificatedialog.cpp Fri Jun 11 14:28:40 2010 +0300
+++ b/pkiutilities/untrustedcertificatedialog/src/untrustedcertificatedialog.cpp Thu Jun 24 12:46:20 2010 +0300
@@ -21,17 +21,30 @@
#include "untrustedcertificatewidget.h"
#include <hblabel.h>
#include <hbaction.h>
+#include <hbmessagebox.h>
+#include <QGraphicsLinearLayout>
const int KNoError = 0; // KErrNone
const int KParameterError = -6; // KErrArgument
+// TODO: replace with OST tracing
+#ifdef _DEBUG
+#include <QDebug>
+#define TRACE(x) qDebug() << x
+#define TRACE1(x,y) qDebug() << x << y
+#else
+#define TRACE(x)
+#define TRACE1(x,y)
+#endif
+
// ----------------------------------------------------------------------------
// UntrustedCertificateDialog::UntrustedCertificateDialog()
// ----------------------------------------------------------------------------
//
-UntrustedCertificateDialog::UntrustedCertificateDialog(const QVariantMap ¶meters) : HbDialog(),
- mLastError(KNoError), mShowEventReceived(false), mContent(0)
+UntrustedCertificateDialog::UntrustedCertificateDialog(const QVariantMap ¶meters) :
+ HbDialog(), mLastError(KNoError), mContent(0), mResultMap(),
+ mShowEventReceived(false), mOkAction(0)
{
constructDialog(parameters);
}
@@ -69,6 +82,7 @@
void UntrustedCertificateDialog::closeDeviceDialog(bool byClient)
{
Q_UNUSED(byClient);
+ TRACE("UntrustedCertificateDialog::closeDeviceDialog");
close();
// If show event has been received, close is signalled from hide event.
@@ -93,6 +107,7 @@
//
void UntrustedCertificateDialog::hideEvent(QHideEvent *event)
{
+ TRACE("UntrustedCertificateDialog::hideEvent");
HbDialog::hideEvent(event);
emit deviceDialogClosed();
}
@@ -103,6 +118,7 @@
//
void UntrustedCertificateDialog::showEvent(QShowEvent *event)
{
+ TRACE("UntrustedCertificateDialog::showEvent");
HbDialog::showEvent(event);
mShowEventReceived = true;
}
@@ -128,6 +144,7 @@
//
bool UntrustedCertificateDialog::constructDialog(const QVariantMap ¶meters)
{
+ TRACE("UntrustedCertificateDialog::constructDialog");
if (!isParametersValid(parameters)) {
return false;
}
@@ -152,17 +169,20 @@
setContentWidget(mContent);
if (mContent->isCertificateValid()) {
- HbAction *okAction = new HbAction(qtTrId("txt_common_button_ok"), this);
- connect(okAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
- addAction(okAction);
+ mOkAction = new HbAction(qtTrId("txt_common_button_ok"), this);
+ addAction(mOkAction);
+ disconnect(mOkAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(mOkAction, SIGNAL(triggered()), this, SLOT(handleAccepted()));
HbAction *cancelAction = new HbAction(qtTrId("txt_common_button_cancel"), this);
+ addAction(cancelAction);
+ disconnect(cancelAction, SIGNAL(triggered()), this, SLOT(close()));
connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleRejected()));
- addAction(cancelAction);
} else {
HbAction *closeAction = new HbAction(qtTrId("txt_common_button_close"), this);
+ addAction(closeAction);
+ disconnect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
connect(closeAction, SIGNAL(triggered()), this, SLOT(handleRejected()));
- addAction(closeAction);
}
return true;
@@ -174,6 +194,7 @@
//
bool UntrustedCertificateDialog::updateFromParameters(const QVariantMap ¶meters)
{
+ TRACE("UntrustedCertificateDialog::updateFromParameters");
if (!isParametersValid(parameters)) {
return false;
}
@@ -189,21 +210,63 @@
//
void UntrustedCertificateDialog::sendResult(int result)
{
+ TRACE1("UntrustedCertificateDialog::sendResult", result);
QVariant resultValue(result);
mResultMap.insert(KUntrustedCertificateDialogResult, resultValue);
emit deviceDialogData(mResultMap);
}
// ----------------------------------------------------------------------------
+// UntrustedCertificateDialog::confirmPermanentAccept()
+// ----------------------------------------------------------------------------
+//
+void UntrustedCertificateDialog::confirmPermanentAccept()
+{
+ TRACE("UntrustedCertificateDialog::confirmPermanentAccept");
+
+ HbDialog *dialog = new HbDialog();
+ dialog->setAttribute(Qt::WA_DeleteOnClose, true);
+ dialog->setTimeout(HbPopup::NoTimeout);
+ dialog->setDismissPolicy(HbDialog::NoDismiss);
+ dialog->setModal(true);
+
+ // TODO: localised UI string needed
+ QString questionTitle = tr("Certificate access");
+ dialog->setHeadingWidget(new HbLabel(questionTitle));
+
+ HbWidget *widget = new HbWidget();
+ QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
+ // TODO: localized UI string needed
+ QString questionText =
+ tr("Connections to '%1' will be made without warnings. Continue?")
+ .arg(mContent->serverName());
+ HbLabel *textLabel = new HbLabel(questionText);
+ textLabel->setTextWrapping(Hb::TextWordWrap);
+ layout->addItem(textLabel);
+ widget->setLayout(layout);
+ dialog->setContentWidget(widget);
+
+ HbAction *yesAction = new HbAction(hbTrId("txt_common_button_yes"));
+ dialog->addAction(yesAction);
+ disconnect(yesAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(yesAction, SIGNAL(triggered()), this, SLOT(handlePermanentAcceptance()));
+ dialog->addAction(new HbAction(hbTrId("txt_common_button_no")));
+
+ dialog->show();
+}
+
+// ----------------------------------------------------------------------------
// UntrustedCertificateDialog::handleAccepted()
// ----------------------------------------------------------------------------
//
void UntrustedCertificateDialog::handleAccepted()
{
+ TRACE("UntrustedCertificateDialog::handleAccepted");
if (mContent->isPermanentAcceptChecked()) {
- sendResult(KDialogAcceptedPermanently);
+ confirmPermanentAccept();
} else {
sendResult(KDialogAccepted);
+ close();
}
}
@@ -213,6 +276,19 @@
//
void UntrustedCertificateDialog::handleRejected()
{
+ TRACE("UntrustedCertificateDialog::handleRejected");
sendResult(KDialogRejected);
+ close();
}
+// ----------------------------------------------------------------------------
+// UntrustedCertificateDialog::handlePermanentAcceptance()
+// ----------------------------------------------------------------------------
+//
+void UntrustedCertificateDialog::handlePermanentAcceptance()
+{
+ TRACE("UntrustedCertificateDialog::handlePermanentAcceptance");
+ sendResult(KDialogAcceptedPermanently);
+ close();
+}
+