Validate uid certification input.
Check all input in the popup before calling KeyEdit::
This commit is contained in:
@@ -145,10 +145,9 @@ void KeyEdit::OnUidValidityClicked(WTreeTableNode* uidNode, vector<WString>& pri
|
||||
|
||||
void KeyEdit::EditUidValidity()
|
||||
{
|
||||
vector<uint>& 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<uint>& uidsToSign = m_popupCertifyUid->GetUidsToSign();
|
||||
int options = m_popupCertifyUid->GetCertifyOptions();
|
||||
e = gpgWorker.CertifyKey(signingKey.toUTF8().c_str(),
|
||||
keyToSign.toUTF8().c_str(),
|
||||
|
||||
@@ -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<WString>& privateKeys,
|
||||
m_bgWhat->setCheckedButton(rbCertifyUid);
|
||||
vblMain->addLayout(unique_ptr<WHBoxLayout> (hblWhat));
|
||||
|
||||
m_cbConfirm = new WCheckBox(TR("Confirm"));
|
||||
vblMain->addWidget(unique_ptr<WCheckBox> (m_cbConfirm));
|
||||
|
||||
WHBoxLayout * hblButtons = new WHBoxLayout();
|
||||
WPushButton * btnClose = new WPushButton(TR("Close"));
|
||||
hblButtons->addWidget(unique_ptr<WPushButton> (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;
|
||||
}
|
||||
|
||||
@@ -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<uint> m_uidsToSign;
|
||||
|
||||
Reference in New Issue
Block a user