Use common code formatting style.
This commit is contained in:
@@ -22,7 +22,8 @@ using namespace std;
|
||||
/**
|
||||
* Json configuration file reader.
|
||||
*/
|
||||
class AppConfig {
|
||||
class AppConfig
|
||||
{
|
||||
public:
|
||||
AppConfig(WText * notifyWidget);
|
||||
virtual ~AppConfig();
|
||||
|
||||
@@ -9,24 +9,29 @@
|
||||
|
||||
#include "GpgMECWorker.h"
|
||||
|
||||
GpgMECWorker::GpgMECWorker() {
|
||||
GpgMECWorker::GpgMECWorker()
|
||||
{
|
||||
gpgme_error_t c_err = gpgme_new(&c_ctx);
|
||||
}
|
||||
|
||||
GpgMECWorker::~GpgMECWorker() {
|
||||
GpgMECWorker::~GpgMECWorker()
|
||||
{
|
||||
gpgme_release(c_ctx);
|
||||
}
|
||||
|
||||
bool GpgMECWorker::DeleteKey(const char * fpr, bool secret, GpgME::Error& e) {
|
||||
bool GpgMECWorker::DeleteKey(const char * fpr, bool secret, GpgME::Error& e)
|
||||
{
|
||||
gpgme_key_t c_key;
|
||||
gpgme_error_t c_err = gpgme_get_key(c_ctx, fpr, &c_key, secret);
|
||||
if (c_key == NULL) {
|
||||
if (c_key == NULL)
|
||||
{
|
||||
e = GpgME::Error::fromCode(c_err);
|
||||
return false;
|
||||
}
|
||||
int flags = secret ? GPGME_DELETE_ALLOW_SECRET | GPGME_DELETE_FORCE : GPGME_DELETE_FORCE;
|
||||
c_err = gpgme_op_delete_ext(c_ctx, c_key, flags);
|
||||
if (c_err != 0) {
|
||||
if (c_err != 0)
|
||||
{
|
||||
e = GpgME::Error::fromCode(c_err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#include <gpgme.h>
|
||||
#include <gpgme++/error.h>
|
||||
|
||||
class GpgMECWorker {
|
||||
class GpgMECWorker
|
||||
{
|
||||
public:
|
||||
GpgMECWorker();
|
||||
virtual ~GpgMECWorker();
|
||||
|
||||
22
K7Main.cpp
22
K7Main.cpp
@@ -28,7 +28,9 @@ K7Main::K7Main(const WEnvironment& env)
|
||||
: WApplication(env)
|
||||
{
|
||||
m_config = NULL;
|
||||
m_btnUpload = NULL; m_btnImport = NULL; m_btnDelete = NULL;
|
||||
m_btnUpload = NULL;
|
||||
m_btnImport = NULL;
|
||||
m_btnDelete = NULL;
|
||||
m_btnCreate = NULL;
|
||||
WApplication::setTitle(_APPNAME_);
|
||||
const WString bundle = WApplication::appRoot() + _APPNAME_;
|
||||
@@ -70,7 +72,8 @@ K7Main::K7Main(const WEnvironment& env)
|
||||
K7Main::~K7Main()
|
||||
{
|
||||
delete m_config;
|
||||
delete m_keyEdit; delete m_keyringIO;
|
||||
delete m_keyEdit;
|
||||
delete m_keyringIO;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -225,7 +228,8 @@ void K7Main::Search()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ttbKeys->columnCount() == 1) {
|
||||
if (m_ttbKeys->columnCount() == 1)
|
||||
{
|
||||
m_ttbKeys->addColumn(TR("ID"), 120);
|
||||
m_ttbKeys->addColumn(TR("OwnerTrust"), 210);
|
||||
m_ttbKeys->addColumn(TR("Fpr"), 300);
|
||||
@@ -268,13 +272,15 @@ void K7Main::DisplayKeys(const vector<GpgME::Key>& kList, const WString& grpLabe
|
||||
anc->clicked().connect(std::bind(&K7Main::OnKeyAnchorClicked, this, anc));
|
||||
keyNode->setColumnWidget(1, unique_ptr<WAnchor> (anc));
|
||||
WText * lblOwnerTrust = new WText(OwnerTrustLevel[k.ownerTrust()]);
|
||||
if (m_config->CanEditOwnerTrust()) {
|
||||
if (m_config->CanEditOwnerTrust())
|
||||
{
|
||||
/*
|
||||
* Here we allow the owner trust level of primary keys to be changed anytime.
|
||||
* Kleopatra doesn't do that for primary keys having ultimate trust level.
|
||||
*/
|
||||
bool isOurKey = Tools::IsOurKey(k.primaryFingerprint(), ourKeys);
|
||||
if (!isOurKey || (isOurKey && k.hasSecret())) {
|
||||
if (!isOurKey || (isOurKey && k.hasSecret()))
|
||||
{
|
||||
lblOwnerTrust->doubleClicked().connect(std::bind(&KeyEdit::OnOwnerTrustDoubleClicked, m_keyEdit, keyNode, k.hasSecret()));
|
||||
lblOwnerTrust->setToolTip(TR("TTTDoubleCLick"));
|
||||
}
|
||||
@@ -335,7 +341,8 @@ void K7Main::DisplayUids(const WString& fullKeyID, bool secret)
|
||||
uidNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntUidEmail));
|
||||
// Show key certify popup on double click
|
||||
WText * lblUidValidity = new WText(UidValidities[uid.validity()]);
|
||||
if (m_config->CanEditUidValidity()) {
|
||||
if (m_config->CanEditUidValidity())
|
||||
{
|
||||
lblUidValidity->setToolTip(TR("TTTDoubleCLick"));
|
||||
lblUidValidity->doubleClicked().connect(std::bind(&KeyEdit::OnUidValidityClicked, m_keyEdit, uidNode, privateKeys, WString(k.primaryFingerprint())));
|
||||
}
|
||||
@@ -400,7 +407,8 @@ void K7Main::DisplaySubKeys(const WString& fullKeyID, bool secret)
|
||||
skNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntFpr));
|
||||
WString exp = sk.neverExpires() ? TR("Never") : MakeDateTimeLabel(sk.expirationTime());
|
||||
WText * lblExpiry = new WText(exp);
|
||||
if (canEditExpiry) {
|
||||
if (canEditExpiry)
|
||||
{
|
||||
lblExpiry->setToolTip(TR("TTTDoubleCLick"));
|
||||
lblExpiry->doubleClicked().connect(std::bind(&KeyEdit::OnExpiryClicked, m_keyEdit, skNode, WString(k.primaryFingerprint())));
|
||||
}
|
||||
|
||||
4
K7Main.h
4
K7Main.h
@@ -54,8 +54,8 @@ private:
|
||||
WLineEdit * m_leSearch;
|
||||
WPushButton * m_btnUpload;
|
||||
WPushButton * m_btnImport;
|
||||
WPushButton * m_btnDelete ;
|
||||
WPushButton * m_btnCreate ;
|
||||
WPushButton * m_btnDelete;
|
||||
WPushButton * m_btnCreate;
|
||||
WTreeTable * m_ttbKeys;
|
||||
WTreeTable * m_ttbUids;
|
||||
WTreeTable * m_ttbSubKeys;
|
||||
|
||||
21
KeyEdit.cpp
21
KeyEdit.cpp
@@ -17,7 +17,7 @@
|
||||
using namespace std;
|
||||
|
||||
KeyEdit::KeyEdit(K7Main * owner)
|
||||
:WObject()
|
||||
: WObject()
|
||||
{
|
||||
m_owner = owner;
|
||||
m_popupUid = NULL;
|
||||
@@ -41,7 +41,8 @@ void KeyEdit::OnOwnerTrustDoubleClicked(WTreeTableNode * keyNode, bool keyHasSec
|
||||
WText * lblFpr = static_cast<WText*> (keyNode->columnWidget(3));
|
||||
vector<WString> ourKeys = m_owner->m_config->PrivateKeyIds();
|
||||
if (!Tools::IsOurKey(lblFpr->text(), ourKeys)
|
||||
&& Tools::KeyHasSecret(lblFpr->text())) {
|
||||
&& Tools::KeyHasSecret(lblFpr->text()))
|
||||
{
|
||||
m_owner->m_tmwMessage->SetText(TR("OwnerTrustReadOnly"));
|
||||
return;
|
||||
}
|
||||
@@ -102,10 +103,13 @@ void KeyEdit::FillOwnerTrustCombo(WComboBox * cmb, bool keyHasSecret)
|
||||
vector<unique_ptr < WStandardItem>> colText;
|
||||
colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Unknown)));
|
||||
colText.push_back(cpp14::make_unique<WStandardItem> (TR("UidUnknown")));
|
||||
if (keyHasSecret) {
|
||||
if (keyHasSecret)
|
||||
{
|
||||
colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Ultimate)));
|
||||
colText.push_back(cpp14::make_unique<WStandardItem> (TR("UidUltimate")));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Never)));
|
||||
colText.push_back(cpp14::make_unique<WStandardItem> (TR("UidNever")));
|
||||
colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Marginal)));
|
||||
@@ -122,7 +126,8 @@ void KeyEdit::FillOwnerTrustCombo(WComboBox * cmb, bool keyHasSecret)
|
||||
|
||||
void KeyEdit::OnUidValidityClicked(WTreeTableNode* uidNode, vector<WString>& privateKeys, const WString& targetKeyFpr)
|
||||
{
|
||||
if (targetKeyFpr != m_targetUidValidityKeyFpr) {
|
||||
if (targetKeyFpr != m_targetUidValidityKeyFpr)
|
||||
{
|
||||
bool passwordVisibility = true;
|
||||
if (m_popupUid)
|
||||
passwordVisibility = m_popupUid->IsPasswordVisible();
|
||||
@@ -140,7 +145,8 @@ void KeyEdit::OnUidValidityClicked(WTreeTableNode* uidNode, vector<WString>& pri
|
||||
void KeyEdit::CertifyKey()
|
||||
{
|
||||
vector<uint>& uidsToSign = m_popupUid->GetUidsToSign();
|
||||
if (uidsToSign.size() == 0) {
|
||||
if (uidsToSign.size() == 0)
|
||||
{
|
||||
m_owner->m_tmwMessage->SetText(TR("NoUidSelected"));
|
||||
return;
|
||||
}
|
||||
@@ -165,7 +171,8 @@ void KeyEdit::CertifyKey()
|
||||
|
||||
void KeyEdit::OnExpiryClicked(WTreeTableNode* subkeyNode, const WString& keyFpr)
|
||||
{
|
||||
if (keyFpr != m_expiryEditedKeyFpr) {
|
||||
if (keyFpr != m_expiryEditedKeyFpr)
|
||||
{
|
||||
delete m_popupExpiryTime;
|
||||
WText * lblExpiry = static_cast<WText*> (subkeyNode->columnWidget(2));
|
||||
m_popupExpiryTime = new PopupExpiryTime(lblExpiry, m_owner->m_tmwMessage);
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
* @param show
|
||||
*/
|
||||
void ShowPassphrase(bool show = true);
|
||||
|
||||
/**
|
||||
* Used to restore the state of the widgets when target key changes.
|
||||
* @return
|
||||
@@ -72,6 +73,7 @@ public:
|
||||
// isVisible is always false when the popup is hidden !
|
||||
return !(m_lePassphrase->isHidden());
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to forward the passphrase to the loopback passphrase provider.
|
||||
* @return
|
||||
@@ -80,6 +82,7 @@ public:
|
||||
{
|
||||
return m_lePassphrase->text().toUTF8();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obviously.
|
||||
* @return
|
||||
@@ -88,6 +91,7 @@ public:
|
||||
{
|
||||
return m_fprKeyToSign;
|
||||
}
|
||||
|
||||
/**
|
||||
* We can select what identity (email) to certify. GPG expects it as a
|
||||
* vector of indices.
|
||||
@@ -97,6 +101,7 @@ public:
|
||||
{
|
||||
return m_uidsToSign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sum of option values
|
||||
* <ul>
|
||||
@@ -110,6 +115,7 @@ public:
|
||||
{
|
||||
return m_certifyOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Caller binds its certify function here.
|
||||
* @return
|
||||
|
||||
@@ -15,18 +15,24 @@
|
||||
using namespace std;
|
||||
|
||||
PopupDelete::PopupDelete(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width)
|
||||
: WPopupWidget(cpp14::make_unique<WContainerWidget>()) {
|
||||
m_tmwMessage = txtMessage; m_cwMain = NULL; m_cbConfirm = NULL;
|
||||
m_cbReConfirm = NULL; m_btnDelete = NULL;
|
||||
: WPopupWidget(cpp14::make_unique<WContainerWidget>())
|
||||
{
|
||||
m_tmwMessage = txtMessage;
|
||||
m_cwMain = NULL;
|
||||
m_cbConfirm = NULL;
|
||||
m_cbReConfirm = NULL;
|
||||
m_btnDelete = NULL;
|
||||
setTransient(true);
|
||||
setAnchorWidget(anchorWidget);
|
||||
setWidth(width);
|
||||
}
|
||||
|
||||
PopupDelete::~PopupDelete() {
|
||||
PopupDelete::~PopupDelete()
|
||||
{
|
||||
}
|
||||
|
||||
void PopupDelete::Create() {
|
||||
void PopupDelete::Create()
|
||||
{
|
||||
m_cwMain = static_cast<WContainerWidget*> (implementation());
|
||||
// White in css file, like default background color.
|
||||
m_cwMain->setStyleClass("popup");
|
||||
@@ -45,7 +51,8 @@ void PopupDelete::Create() {
|
||||
this->hidden().connect(this, &PopupDelete::Reset);
|
||||
}
|
||||
|
||||
void PopupDelete::Reset() {
|
||||
void PopupDelete::Reset()
|
||||
{
|
||||
m_btnDelete->hide();
|
||||
m_cbReConfirm->setUnChecked();
|
||||
m_cbReConfirm->hide();
|
||||
@@ -53,12 +60,14 @@ void PopupDelete::Reset() {
|
||||
m_cbConfirm->show();
|
||||
}
|
||||
|
||||
void PopupDelete::OnCbConfirm() {
|
||||
void PopupDelete::OnCbConfirm()
|
||||
{
|
||||
m_cbReConfirm->setHidden(m_cbConfirm->checkState() != CheckState::Checked);
|
||||
m_cbReConfirm->setUnChecked();
|
||||
m_btnDelete->setHidden(m_cbReConfirm->checkState() != CheckState::Checked);
|
||||
}
|
||||
|
||||
void PopupDelete::OnCbReConfirm() {
|
||||
void PopupDelete::OnCbReConfirm()
|
||||
{
|
||||
m_btnDelete->setHidden(m_cbReConfirm->checkState() != CheckState::Checked);
|
||||
}
|
||||
|
||||
@@ -17,20 +17,26 @@
|
||||
#include "TransientMessageWidget.h"
|
||||
|
||||
using namespace Wt;
|
||||
|
||||
/**
|
||||
* A transient popup window with a forward confirmation
|
||||
* before deleting a key.
|
||||
*/
|
||||
class PopupDelete : public WPopupWidget {
|
||||
class PopupDelete : public WPopupWidget
|
||||
{
|
||||
public:
|
||||
PopupDelete(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width = 350);
|
||||
virtual ~PopupDelete();
|
||||
void Create();
|
||||
|
||||
/**
|
||||
* Caller can bind the delete function to this button.
|
||||
* @return
|
||||
*/
|
||||
WPushButton* GetDeleteButton() {return m_btnDelete;}
|
||||
WPushButton* GetDeleteButton()
|
||||
{
|
||||
return m_btnDelete;
|
||||
}
|
||||
private:
|
||||
TransientMessageWidget * m_tmwMessage;
|
||||
WContainerWidget * m_cwMain;
|
||||
|
||||
@@ -15,18 +15,25 @@
|
||||
using namespace std;
|
||||
|
||||
PopupUpload::PopupUpload(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width)
|
||||
: WPopupWidget(cpp14::make_unique<WContainerWidget>()) {
|
||||
m_tmwMessage = txtMessage; m_upload = NULL; m_cwMain = NULL;
|
||||
m_cbConfirm = NULL; m_cbReConfirm = NULL; m_btnUpload = NULL;
|
||||
: WPopupWidget(cpp14::make_unique<WContainerWidget>())
|
||||
{
|
||||
m_tmwMessage = txtMessage;
|
||||
m_upload = NULL;
|
||||
m_cwMain = NULL;
|
||||
m_cbConfirm = NULL;
|
||||
m_cbReConfirm = NULL;
|
||||
m_btnUpload = NULL;
|
||||
setTransient(true);
|
||||
setAnchorWidget(anchorWidget);
|
||||
setWidth(width);
|
||||
}
|
||||
|
||||
PopupUpload::~PopupUpload() {
|
||||
PopupUpload::~PopupUpload()
|
||||
{
|
||||
}
|
||||
|
||||
void PopupUpload::Create() {
|
||||
void PopupUpload::Create()
|
||||
{
|
||||
m_upload = new WFileUpload();
|
||||
m_upload->setFileTextSize(10240); // Is really approximate
|
||||
m_upload->setMultiple(false);
|
||||
@@ -54,7 +61,8 @@ void PopupUpload::Create() {
|
||||
this->hidden().connect(this, &PopupUpload::Reset);
|
||||
}
|
||||
|
||||
void PopupUpload::Reset() {
|
||||
void PopupUpload::Reset()
|
||||
{
|
||||
m_btnUpload->hide();
|
||||
m_cbReConfirm->setUnChecked();
|
||||
m_cbReConfirm->hide();
|
||||
@@ -62,31 +70,40 @@ void PopupUpload::Reset() {
|
||||
m_cbConfirm->show();
|
||||
m_btnUpload->enable();
|
||||
}
|
||||
void PopupUpload::OnCbConfirm() {
|
||||
|
||||
void PopupUpload::OnCbConfirm()
|
||||
{
|
||||
m_cbReConfirm->setHidden(m_cbConfirm->checkState() != CheckState::Checked);
|
||||
m_cbReConfirm->setUnChecked();
|
||||
m_btnUpload->setHidden(m_cbReConfirm->checkState() != CheckState::Checked);
|
||||
}
|
||||
|
||||
void PopupUpload::OnCbReConfirm() {
|
||||
void PopupUpload::OnCbReConfirm()
|
||||
{
|
||||
m_btnUpload->setHidden(m_cbReConfirm->checkState() != CheckState::Checked);
|
||||
}
|
||||
|
||||
void PopupUpload::DoUpload() {
|
||||
if (m_upload->canUpload()) {
|
||||
void PopupUpload::DoUpload()
|
||||
{
|
||||
if (m_upload->canUpload())
|
||||
{
|
||||
m_btnUpload->disable();
|
||||
m_upload->upload();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tmwMessage->SetText(TR("CantUpload"));
|
||||
}
|
||||
}
|
||||
|
||||
void PopupUpload::OnUploadDone() {
|
||||
void PopupUpload::OnUploadDone()
|
||||
{
|
||||
m_sigUploadDone.emit(m_upload->spoolFileName());
|
||||
m_btnUpload->enable();
|
||||
}
|
||||
|
||||
void PopupUpload::OnFileTooLarge() {
|
||||
void PopupUpload::OnFileTooLarge()
|
||||
{
|
||||
m_tmwMessage->SetText(TR("FileTooLarge"));
|
||||
m_btnUpload->enable();
|
||||
}
|
||||
|
||||
@@ -49,9 +49,11 @@ void TransientMessageWidget::OnTimer()
|
||||
void TransientMessageWidget::SetText(const WString& text, bool stack)
|
||||
{
|
||||
m_timer.stop();
|
||||
if (stack) {
|
||||
if (stack)
|
||||
{
|
||||
// Remove the oldest message if stack is full
|
||||
if (m_stack.size() == m_stackSize) {
|
||||
if (m_stack.size() == m_stackSize)
|
||||
{
|
||||
m_stack.pop_back();
|
||||
}
|
||||
m_stack.push_front(text);
|
||||
|
||||
Reference in New Issue
Block a user