diff --git a/KeyEdit.cpp b/KeyEdit.cpp index e14f674..0f6f633 100644 --- a/KeyEdit.cpp +++ b/KeyEdit.cpp @@ -145,10 +145,9 @@ void KeyEdit::OnUidValidityClicked(WTreeTableNode* uidNode, vector& pri void KeyEdit::EditUidValidity() { - vector& uidsToSign = m_popupCertifyUid->GetUidsToSign(); - if (uidsToSign.size() == 0) + if (!m_popupCertifyUid->Validate()) { - m_owner->m_tmwMessage->SetText(TR("NoUidSelected")); + m_owner->m_tmwMessage->SetText(TR("InvalidInput")); return; } const WString signingKey = m_popupCertifyUid->GetSelectedKey(); @@ -157,6 +156,7 @@ void KeyEdit::EditUidValidity() GpgME::Error e; if (m_popupCertifyUid->WhatToDo() == PopupCertifyUserId::CertifyUid) { + vector& uidsToSign = m_popupCertifyUid->GetUidsToSign(); int options = m_popupCertifyUid->GetCertifyOptions(); e = gpgWorker.CertifyKey(signingKey.toUTF8().c_str(), keyToSign.toUTF8().c_str(), diff --git a/PopupCertifyUserId.cpp b/PopupCertifyUserId.cpp index b6d0b12..bef647a 100644 --- a/PopupCertifyUserId.cpp +++ b/PopupCertifyUserId.cpp @@ -28,6 +28,7 @@ PopupCertifyUserId::PopupCertifyUserId(WWidget * anchorWidget, TransientMessageW m_cbOptionExportable = NULL; m_cbOptionNonRevocable = NULL; // m_cbOptionTrust = NULL; + m_cbConfirm = NULL; m_lblPassphrase = NULL; m_lePassphrase = NULL; m_btnApply = NULL; @@ -98,6 +99,9 @@ void PopupCertifyUserId::Create(vector& privateKeys, m_bgWhat->setCheckedButton(rbCertifyUid); vblMain->addLayout(unique_ptr (hblWhat)); + m_cbConfirm = new WCheckBox(TR("Confirm")); + vblMain->addWidget(unique_ptr (m_cbConfirm)); + WHBoxLayout * hblButtons = new WHBoxLayout(); WPushButton * btnClose = new WPushButton(TR("Close")); hblButtons->addWidget(unique_ptr (btnClose)); @@ -279,3 +283,20 @@ void PopupCertifyUserId::OnButtonGroupWhat(WRadioButton* btn) == What::RevokeUidCertification); } + +bool PopupCertifyUserId::Validate() const +{ + if (!m_cbConfirm->isChecked() || m_lePassphrase->text().empty()) + return false; + if (m_bgWhat->checkedId() == What::CertifyUid) + { + if (m_uidsToSign.size() == 0) + return false; + } + else + { + if (m_uidsToRevokeCertification.size() == 0) + return false; + } + return true; +} diff --git a/PopupCertifyUserId.h b/PopupCertifyUserId.h index 98a5773..95b4b48 100644 --- a/PopupCertifyUserId.h +++ b/PopupCertifyUserId.h @@ -149,6 +149,11 @@ public: { return m_btnApply; } + /** + * Check required parameters are set and confirmed. + * @return + */ + bool Validate() const; private: TransientMessageWidget * m_tmwMessage; WContainerWidget * m_cwMain; @@ -163,6 +168,7 @@ private: // WCheckBox * m_cbOptionTrust; // Always fails WText * m_lblPassphrase; WLineEdit * m_lePassphrase; + WCheckBox * m_cbConfirm; WPushButton * m_btnApply; vector m_uidsToSign;