Use common code formatting style.

This commit is contained in:
SET
2020-11-14 14:46:28 +01:00
parent a7146a07b2
commit a721bb0225
16 changed files with 144 additions and 82 deletions

View File

@@ -187,7 +187,7 @@ bool AppConfig::UpdateSecretKeyOwnership(const WString& fpr, bool own)
Json::Array::iterator it = std::find(aKeyId.begin(), aKeyId.end(), Json::Value(fpr)); Json::Array::iterator it = std::find(aKeyId.begin(), aKeyId.end(), Json::Value(fpr));
if (it == aKeyId.end()) if (it == aKeyId.end())
{ {
if (own) if (own)
aKeyId.push_back(Json::Value(fpr)); aKeyId.push_back(Json::Value(fpr));
else else
return true; // We don't own it. return true; // We don't own it.
@@ -199,7 +199,7 @@ bool AppConfig::UpdateSecretKeyOwnership(const WString& fpr, bool own)
else else
return true; // We already own it. return true; // We already own it.
} }
// TODO : Do this **better**, without replacing sequentially up to root. // TODO : Do this **better**, without replacing sequentially up to root.
cnObject.insert(make_pair("privKeyIds", aKeyId)); cnObject.insert(make_pair("privKeyIds", aKeyId));
m_SubjectCNObject.erase(commonName.toUTF8()); m_SubjectCNObject.erase(commonName.toUTF8());

View File

@@ -22,7 +22,8 @@ using namespace std;
/** /**
* Json configuration file reader. * Json configuration file reader.
*/ */
class AppConfig { class AppConfig
{
public: public:
AppConfig(WText * notifyWidget); AppConfig(WText * notifyWidget);
virtual ~AppConfig(); virtual ~AppConfig();
@@ -101,7 +102,7 @@ private:
* @return * @return
*/ */
const WString GetSubjectDnAttribute(const WSslCertificate::DnAttributeName& attrName) const; const WString GetSubjectDnAttribute(const WSslCertificate::DnAttributeName& attrName) const;
bool WriteTextFile(const WString& filePath, const WString& content); bool WriteTextFile(const WString& filePath, const WString& content);
}; };

View File

@@ -9,24 +9,29 @@
#include "GpgMECWorker.h" #include "GpgMECWorker.h"
GpgMECWorker::GpgMECWorker() { GpgMECWorker::GpgMECWorker()
{
gpgme_error_t c_err = gpgme_new(&c_ctx); gpgme_error_t c_err = gpgme_new(&c_ctx);
} }
GpgMECWorker::~GpgMECWorker() { GpgMECWorker::~GpgMECWorker()
{
gpgme_release(c_ctx); 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_key_t c_key;
gpgme_error_t c_err = gpgme_get_key(c_ctx, fpr, &c_key, secret); 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); e = GpgME::Error::fromCode(c_err);
return false; return false;
} }
int flags = secret ? GPGME_DELETE_ALLOW_SECRET | GPGME_DELETE_FORCE : GPGME_DELETE_FORCE; int flags = secret ? GPGME_DELETE_ALLOW_SECRET | GPGME_DELETE_FORCE : GPGME_DELETE_FORCE;
c_err = gpgme_op_delete_ext(c_ctx, c_key, flags); 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); e = GpgME::Error::fromCode(c_err);
return false; return false;
} }

View File

@@ -13,11 +13,12 @@
#include <gpgme.h> #include <gpgme.h>
#include <gpgme++/error.h> #include <gpgme++/error.h>
class GpgMECWorker { class GpgMECWorker
{
public: public:
GpgMECWorker(); GpgMECWorker();
virtual ~GpgMECWorker(); virtual ~GpgMECWorker();
/** /**
* Deleting keys must be done with the C API because * Deleting keys must be done with the C API because
* gpgmepp does not provide a way to use GPGME_DELETE_FORCE, * gpgmepp does not provide a way to use GPGME_DELETE_FORCE,
@@ -29,7 +30,7 @@ public:
* @return * @return
*/ */
bool DeleteKey(const char * fpr, bool secret, GpgME::Error& e); bool DeleteKey(const char * fpr, bool secret, GpgME::Error& e);
private: private:
gpgme_ctx_t c_ctx; gpgme_ctx_t c_ctx;
}; };

View File

@@ -28,7 +28,9 @@ K7Main::K7Main(const WEnvironment& env)
: WApplication(env) : WApplication(env)
{ {
m_config = NULL; m_config = NULL;
m_btnUpload = NULL; m_btnImport = NULL; m_btnDelete = NULL; m_btnUpload = NULL;
m_btnImport = NULL;
m_btnDelete = NULL;
m_btnCreate = NULL; m_btnCreate = NULL;
WApplication::setTitle(_APPNAME_); WApplication::setTitle(_APPNAME_);
const WString bundle = WApplication::appRoot() + _APPNAME_; const WString bundle = WApplication::appRoot() + _APPNAME_;
@@ -51,7 +53,7 @@ K7Main::K7Main(const WEnvironment& env)
UidValidities[UserID::Validity::Ultimate] = TR("UidUltimate"); UidValidities[UserID::Validity::Ultimate] = TR("UidUltimate");
UidValidities[UserID::Validity::Undefined] = TR("UidUndefined"); UidValidities[UserID::Validity::Undefined] = TR("UidUndefined");
UidValidities[UserID::Validity::Unknown] = TR("UidUnknown"); UidValidities[UserID::Validity::Unknown] = TR("UidUnknown");
OwnerTrustLevel[GpgME::Key::OwnerTrust::Full] = TR("UidFull"); OwnerTrustLevel[GpgME::Key::OwnerTrust::Full] = TR("UidFull");
OwnerTrustLevel[GpgME::Key::OwnerTrust::Marginal] = TR("UidMarginal"); OwnerTrustLevel[GpgME::Key::OwnerTrust::Marginal] = TR("UidMarginal");
OwnerTrustLevel[GpgME::Key::OwnerTrust::Never] = TR("UidNever"); OwnerTrustLevel[GpgME::Key::OwnerTrust::Never] = TR("UidNever");
@@ -59,10 +61,10 @@ K7Main::K7Main(const WEnvironment& env)
OwnerTrustLevel[GpgME::Key::OwnerTrust::Undefined] = TR("UidUndefined"); OwnerTrustLevel[GpgME::Key::OwnerTrust::Undefined] = TR("UidUndefined");
OwnerTrustLevel[GpgME::Key::OwnerTrust::Unknown] = TR("UidUnknown"); OwnerTrustLevel[GpgME::Key::OwnerTrust::Unknown] = TR("UidUnknown");
m_keyEdit = new KeyEdit(this); m_keyEdit = new KeyEdit(this);
WLink link; WLink link;
const WString cssFile = WApplication::appRoot() + _APPNAME_ const WString cssFile = WApplication::appRoot() + _APPNAME_
+ WString(".css"); + WString(".css");
link.setUrl(cssFile.toUTF8()); link.setUrl(cssFile.toUTF8());
WApplication::useStyleSheet(link); WApplication::useStyleSheet(link);
} }
@@ -70,7 +72,8 @@ K7Main::K7Main(const WEnvironment& env)
K7Main::~K7Main() K7Main::~K7Main()
{ {
delete m_config; delete m_config;
delete m_keyEdit; delete m_keyringIO; delete m_keyEdit;
delete m_keyringIO;
} }
void void
@@ -90,11 +93,11 @@ K7Main::Create()
/* /*
* Load config JSON file. * Load config JSON file.
* On error, just abort, AppConfig will print an error message in m_tmwMessage * On error, just abort, AppConfig will print an error message in m_tmwMessage
*/ */
m_config = new AppConfig(m_tmwMessage); m_config = new AppConfig(m_tmwMessage);
if (!m_config->LoadConfig()) if (!m_config->LoadConfig())
return; return;
m_cwMain = new WContainerWidget(); m_cwMain = new WContainerWidget();
WGridLayout * grlMain = new WGridLayout(); WGridLayout * grlMain = new WGridLayout();
grlMain->setColumnStretch(0, 1); grlMain->setColumnStretch(0, 1);
@@ -154,9 +157,9 @@ K7Main::Create()
root()->addWidget(cpp14::make_unique<WBreak>()); root()->addWidget(cpp14::make_unique<WBreak>());
root()->addWidget(unique_ptr<WContainerWidget> (m_cwMain)); root()->addWidget(unique_ptr<WContainerWidget> (m_cwMain));
m_keyringIO = new KeyringIO(this); m_keyringIO = new KeyringIO(this);
#ifdef DEVTIME #ifdef DEVTIME
// Save my fingertips. // Save my fingertips.
m_leSearch->setText("s"); m_leSearch->setText("s");
@@ -190,7 +193,7 @@ void K7Main::Search()
* configPrivKeys.at(i) : we want this to be a full key id(short, normal or fpr) * configPrivKeys.at(i) : we want this to be a full key id(short, normal or fpr)
* But it can be any string in the config file (name, email...). * But it can be any string in the config file (name, email...).
* lst can hence contain many keys. * lst can hence contain many keys.
*/ */
vector<GpgME::Key> lst = gpgw.FindKeys(configPrivKeys.at(i).toUTF8().c_str(), true, e); vector<GpgME::Key> lst = gpgw.FindKeys(configPrivKeys.at(i).toUTF8().c_str(), true, e);
if (e.code() != 0) if (e.code() != 0)
{ {
@@ -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("ID"), 120);
m_ttbKeys->addColumn(TR("OwnerTrust"), 210); m_ttbKeys->addColumn(TR("OwnerTrust"), 210);
m_ttbKeys->addColumn(TR("Fpr"), 300); 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)); anc->clicked().connect(std::bind(&K7Main::OnKeyAnchorClicked, this, anc));
keyNode->setColumnWidget(1, unique_ptr<WAnchor> (anc)); keyNode->setColumnWidget(1, unique_ptr<WAnchor> (anc));
WText * lblOwnerTrust = new WText(OwnerTrustLevel[k.ownerTrust()]); 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. * 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. * Kleopatra doesn't do that for primary keys having ultimate trust level.
*/ */
bool isOurKey = Tools::IsOurKey(k.primaryFingerprint(), ourKeys); 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->doubleClicked().connect(std::bind(&KeyEdit::OnOwnerTrustDoubleClicked, m_keyEdit, keyNode, k.hasSecret()));
lblOwnerTrust->setToolTip(TR("TTTDoubleCLick")); lblOwnerTrust->setToolTip(TR("TTTDoubleCLick"));
} }
@@ -335,7 +341,8 @@ void K7Main::DisplayUids(const WString& fullKeyID, bool secret)
uidNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntUidEmail)); uidNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntUidEmail));
// Show key certify popup on double click // Show key certify popup on double click
WText * lblUidValidity = new WText(UidValidities[uid.validity()]); WText * lblUidValidity = new WText(UidValidities[uid.validity()]);
if (m_config->CanEditUidValidity()) { if (m_config->CanEditUidValidity())
{
lblUidValidity->setToolTip(TR("TTTDoubleCLick")); lblUidValidity->setToolTip(TR("TTTDoubleCLick"));
lblUidValidity->doubleClicked().connect(std::bind(&KeyEdit::OnUidValidityClicked, m_keyEdit, uidNode, privateKeys, WString(k.primaryFingerprint()))); lblUidValidity->doubleClicked().connect(std::bind(&KeyEdit::OnUidValidityClicked, m_keyEdit, uidNode, privateKeys, WString(k.primaryFingerprint())));
} }
@@ -389,8 +396,8 @@ void K7Main::DisplaySubKeys(const WString& fullKeyID, bool secret)
rootNode->expand(); rootNode->expand();
vector<WString> ourKeys = m_config->PrivateKeyIds(); vector<WString> ourKeys = m_config->PrivateKeyIds();
bool canEditExpiry = m_config->CanEditExpiryTime() bool canEditExpiry = m_config->CanEditExpiryTime()
&& Tools::KeyHasSecret(k.primaryFingerprint()) && Tools::KeyHasSecret(k.primaryFingerprint())
&& Tools::IsOurKey(k.primaryFingerprint(), ourKeys); && Tools::IsOurKey(k.primaryFingerprint(), ourKeys);
for (uint i = 0; i < k.numSubkeys(); i++) for (uint i = 0; i < k.numSubkeys(); i++)
{ {
Subkey sk = k.subkey(i); Subkey sk = k.subkey(i);
@@ -400,7 +407,8 @@ void K7Main::DisplaySubKeys(const WString& fullKeyID, bool secret)
skNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntFpr)); skNode->setColumnWidget(1, unique_ptr<TreeTableNodeText> (ttntFpr));
WString exp = sk.neverExpires() ? TR("Never") : MakeDateTimeLabel(sk.expirationTime()); WString exp = sk.neverExpires() ? TR("Never") : MakeDateTimeLabel(sk.expirationTime());
WText * lblExpiry = new WText(exp); WText * lblExpiry = new WText(exp);
if (canEditExpiry) { if (canEditExpiry)
{
lblExpiry->setToolTip(TR("TTTDoubleCLick")); lblExpiry->setToolTip(TR("TTTDoubleCLick"));
lblExpiry->doubleClicked().connect(std::bind(&KeyEdit::OnExpiryClicked, m_keyEdit, skNode, WString(k.primaryFingerprint()))); lblExpiry->doubleClicked().connect(std::bind(&KeyEdit::OnExpiryClicked, m_keyEdit, skNode, WString(k.primaryFingerprint())));
} }

View File

@@ -54,8 +54,8 @@ private:
WLineEdit * m_leSearch; WLineEdit * m_leSearch;
WPushButton * m_btnUpload; WPushButton * m_btnUpload;
WPushButton * m_btnImport; WPushButton * m_btnImport;
WPushButton * m_btnDelete ; WPushButton * m_btnDelete;
WPushButton * m_btnCreate ; WPushButton * m_btnCreate;
WTreeTable * m_ttbKeys; WTreeTable * m_ttbKeys;
WTreeTable * m_ttbUids; WTreeTable * m_ttbUids;
WTreeTable * m_ttbSubKeys; WTreeTable * m_ttbSubKeys;

View File

@@ -17,7 +17,7 @@
using namespace std; using namespace std;
KeyEdit::KeyEdit(K7Main * owner) KeyEdit::KeyEdit(K7Main * owner)
:WObject() : WObject()
{ {
m_owner = owner; m_owner = owner;
m_popupUid = NULL; m_popupUid = NULL;
@@ -41,7 +41,8 @@ void KeyEdit::OnOwnerTrustDoubleClicked(WTreeTableNode * keyNode, bool keyHasSec
WText * lblFpr = static_cast<WText*> (keyNode->columnWidget(3)); WText * lblFpr = static_cast<WText*> (keyNode->columnWidget(3));
vector<WString> ourKeys = m_owner->m_config->PrivateKeyIds(); vector<WString> ourKeys = m_owner->m_config->PrivateKeyIds();
if (!Tools::IsOurKey(lblFpr->text(), ourKeys) if (!Tools::IsOurKey(lblFpr->text(), ourKeys)
&& Tools::KeyHasSecret(lblFpr->text())) { && Tools::KeyHasSecret(lblFpr->text()))
{
m_owner->m_tmwMessage->SetText(TR("OwnerTrustReadOnly")); m_owner->m_tmwMessage->SetText(TR("OwnerTrustReadOnly"));
return; return;
} }
@@ -57,7 +58,7 @@ void KeyEdit::OnOwnerTrustDoubleClicked(WTreeTableNode * keyNode, bool keyHasSec
/* /*
* Prepare to check for change in combobox item. * Prepare to check for change in combobox item.
* Change is detected by index, not value. * Change is detected by index, not value.
*/ */
cmbOwnerTrust->setAttributeValue("previousTrustLevel", std::to_string(cmbOwnerTrust->currentIndex())); cmbOwnerTrust->setAttributeValue("previousTrustLevel", std::to_string(cmbOwnerTrust->currentIndex()));
keyNode->setColumnWidget(2, unique_ptr<WComboBox> (cmbOwnerTrust)); keyNode->setColumnWidget(2, unique_ptr<WComboBox> (cmbOwnerTrust));
// +++ // +++
@@ -72,7 +73,7 @@ void KeyEdit::OnOwnerTrustBlurred(WTreeTableNode* keyNode, bool keyHasSecret)
WStandardItemModel * iModel = static_cast<WStandardItemModel*> (aiModel.get()); WStandardItemModel * iModel = static_cast<WStandardItemModel*> (aiModel.get());
WStandardItem * item = iModel->item(cmbOwnerTrust->currentIndex(), 0); WStandardItem * item = iModel->item(cmbOwnerTrust->currentIndex(), 0);
int newLevel = Tools::ToInt(item->text().toUTF8()); int newLevel = Tools::ToInt(item->text().toUTF8());
WText * lblOwnerTrust = new WText(cmbOwnerTrust->currentText()); WText * lblOwnerTrust = new WText(cmbOwnerTrust->currentText());
lblOwnerTrust->doubleClicked().connect(std::bind(&KeyEdit::OnOwnerTrustDoubleClicked, this, keyNode, keyHasSecret)); lblOwnerTrust->doubleClicked().connect(std::bind(&KeyEdit::OnOwnerTrustDoubleClicked, this, keyNode, keyHasSecret));
const WText * lblFpr = static_cast<WText*> (keyNode->columnWidget(3)); const WText * lblFpr = static_cast<WText*> (keyNode->columnWidget(3));
@@ -82,7 +83,7 @@ void KeyEdit::OnOwnerTrustBlurred(WTreeTableNode* keyNode, bool keyHasSecret)
// If nothing was changed, don't go to engine. // If nothing was changed, don't go to engine.
if (WString(std::to_string(newTrustLevel)) == previousTrustLevel) if (WString(std::to_string(newTrustLevel)) == previousTrustLevel)
return; return;
GpgMEWorker gpgWorker; GpgMEWorker gpgWorker;
GpgME::Error e = gpgWorker.EditOwnerTrust(lblFpr->text().toUTF8().c_str(), (GpgME::Key::OwnerTrust) newLevel); GpgME::Error e = gpgWorker.EditOwnerTrust(lblFpr->text().toUTF8().c_str(), (GpgME::Key::OwnerTrust) newLevel);
if (e.code() != 0) if (e.code() != 0)
@@ -102,10 +103,13 @@ void KeyEdit::FillOwnerTrustCombo(WComboBox * cmb, bool keyHasSecret)
vector<unique_ptr < WStandardItem>> colText; vector<unique_ptr < WStandardItem>> colText;
colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Unknown))); colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Unknown)));
colText.push_back(cpp14::make_unique<WStandardItem> (TR("UidUnknown"))); 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))); colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Ultimate)));
colText.push_back(cpp14::make_unique<WStandardItem> (TR("UidUltimate"))); colText.push_back(cpp14::make_unique<WStandardItem> (TR("UidUltimate")));
} else { }
else
{
colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Never))); colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Never)));
colText.push_back(cpp14::make_unique<WStandardItem> (TR("UidNever"))); colText.push_back(cpp14::make_unique<WStandardItem> (TR("UidNever")));
colIndex.push_back(cpp14::make_unique<WStandardItem> (std::to_string(UserID::Validity::Marginal))); 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) void KeyEdit::OnUidValidityClicked(WTreeTableNode* uidNode, vector<WString>& privateKeys, const WString& targetKeyFpr)
{ {
if (targetKeyFpr != m_targetUidValidityKeyFpr) { if (targetKeyFpr != m_targetUidValidityKeyFpr)
{
bool passwordVisibility = true; bool passwordVisibility = true;
if (m_popupUid) if (m_popupUid)
passwordVisibility = m_popupUid->IsPasswordVisible(); passwordVisibility = m_popupUid->IsPasswordVisible();
@@ -140,7 +145,8 @@ void KeyEdit::OnUidValidityClicked(WTreeTableNode* uidNode, vector<WString>& pri
void KeyEdit::CertifyKey() void KeyEdit::CertifyKey()
{ {
vector<uint>& uidsToSign = m_popupUid->GetUidsToSign(); vector<uint>& uidsToSign = m_popupUid->GetUidsToSign();
if (uidsToSign.size() == 0) { if (uidsToSign.size() == 0)
{
m_owner->m_tmwMessage->SetText(TR("NoUidSelected")); m_owner->m_tmwMessage->SetText(TR("NoUidSelected"));
return; return;
} }
@@ -165,7 +171,8 @@ void KeyEdit::CertifyKey()
void KeyEdit::OnExpiryClicked(WTreeTableNode* subkeyNode, const WString& keyFpr) void KeyEdit::OnExpiryClicked(WTreeTableNode* subkeyNode, const WString& keyFpr)
{ {
if (keyFpr != m_expiryEditedKeyFpr) { if (keyFpr != m_expiryEditedKeyFpr)
{
delete m_popupExpiryTime; delete m_popupExpiryTime;
WText * lblExpiry = static_cast<WText*> (subkeyNode->columnWidget(2)); WText * lblExpiry = static_cast<WText*> (subkeyNode->columnWidget(2));
m_popupExpiryTime = new PopupExpiryTime(lblExpiry, m_owner->m_tmwMessage); m_popupExpiryTime = new PopupExpiryTime(lblExpiry, m_owner->m_tmwMessage);

View File

@@ -31,18 +31,18 @@ class KeyEdit : public WObject
{ {
friend class K7Main; friend class K7Main;
public: public:
private: private:
KeyEdit(K7Main * owner); KeyEdit(K7Main * owner);
virtual ~KeyEdit(); virtual ~KeyEdit();
K7Main * m_owner; K7Main * m_owner;
PopupCertifyUserId * m_popupUid; PopupCertifyUserId * m_popupUid;
WString m_targetUidValidityKeyFpr; WString m_targetUidValidityKeyFpr;
PopupExpiryTime * m_popupExpiryTime; PopupExpiryTime * m_popupExpiryTime;
WString m_expiryEditedKeyFpr; WString m_expiryEditedKeyFpr;
/** /**
* Unknown is common. * Unknown is common.
* \n If keyHasSecret is true, show only Ultimate level. * \n If keyHasSecret is true, show only Ultimate level.
@@ -54,7 +54,7 @@ private:
void FillOwnerTrustCombo(WComboBox * cmb, bool keyHasSecret); void FillOwnerTrustCombo(WComboBox * cmb, bool keyHasSecret);
void CertifyKey(); void CertifyKey();
void SetExpiryTime(); void SetExpiryTime();
/** /**
* Shows a combobox with all trust levels * Shows a combobox with all trust levels
* @param keyNode * @param keyNode
@@ -80,7 +80,7 @@ private:
* @param keyFpr * @param keyFpr
*/ */
void OnExpiryClicked(WTreeTableNode * subkeyNode, const WString& keyFpr); void OnExpiryClicked(WTreeTableNode * subkeyNode, const WString& keyFpr);
}; };
#endif /* KEYEDIT_H */ #endif /* KEYEDIT_H */

View File

@@ -233,7 +233,7 @@ void KeyringIO::DoCreateKey()
{ {
const WString fpr(k.primaryFingerprint()); const WString fpr(k.primaryFingerprint());
m_tmwMessage->SetText(TR("CreateSuccess") m_tmwMessage->SetText(TR("CreateSuccess")
+ fpr + WString(" - ") + WString(k.userID(0).name())); + fpr + WString(" - ") + WString(k.userID(0).name()));
// Add the key fingerprint to the list of keys managed by the user. // Add the key fingerprint to the list of keys managed by the user.
m_config->UpdateSecretKeyOwnership(fpr, true); m_config->UpdateSecretKeyOwnership(fpr, true);
m_popupCreate->hide(); m_popupCreate->hide();

View File

@@ -63,6 +63,7 @@ public:
* @param show * @param show
*/ */
void ShowPassphrase(bool show = true); void ShowPassphrase(bool show = true);
/** /**
* Used to restore the state of the widgets when target key changes. * Used to restore the state of the widgets when target key changes.
* @return * @return
@@ -72,6 +73,7 @@ public:
// isVisible is always false when the popup is hidden ! // isVisible is always false when the popup is hidden !
return !(m_lePassphrase->isHidden()); return !(m_lePassphrase->isHidden());
} }
/** /**
* Used to forward the passphrase to the loopback passphrase provider. * Used to forward the passphrase to the loopback passphrase provider.
* @return * @return
@@ -80,6 +82,7 @@ public:
{ {
return m_lePassphrase->text().toUTF8(); return m_lePassphrase->text().toUTF8();
} }
/** /**
* Obviously. * Obviously.
* @return * @return
@@ -88,6 +91,7 @@ public:
{ {
return m_fprKeyToSign; return m_fprKeyToSign;
} }
/** /**
* We can select what identity (email) to certify. GPG expects it as a * We can select what identity (email) to certify. GPG expects it as a
* vector of indices. * vector of indices.
@@ -97,6 +101,7 @@ public:
{ {
return m_uidsToSign; return m_uidsToSign;
} }
/** /**
* Sum of option values * Sum of option values
* <ul> * <ul>
@@ -110,6 +115,7 @@ public:
{ {
return m_certifyOptions; return m_certifyOptions;
} }
/** /**
* Caller binds its certify function here. * Caller binds its certify function here.
* @return * @return

View File

@@ -14,19 +14,25 @@
using namespace std; using namespace std;
PopupDelete::PopupDelete(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width) PopupDelete::PopupDelete(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width)
: WPopupWidget(cpp14::make_unique<WContainerWidget>()) { : WPopupWidget(cpp14::make_unique<WContainerWidget>())
m_tmwMessage = txtMessage; m_cwMain = NULL; m_cbConfirm = NULL; {
m_cbReConfirm = NULL; m_btnDelete = NULL; m_tmwMessage = txtMessage;
m_cwMain = NULL;
m_cbConfirm = NULL;
m_cbReConfirm = NULL;
m_btnDelete = NULL;
setTransient(true); setTransient(true);
setAnchorWidget(anchorWidget); setAnchorWidget(anchorWidget);
setWidth(width); setWidth(width);
} }
PopupDelete::~PopupDelete() { PopupDelete::~PopupDelete()
{
} }
void PopupDelete::Create() { void PopupDelete::Create()
{
m_cwMain = static_cast<WContainerWidget*> (implementation()); m_cwMain = static_cast<WContainerWidget*> (implementation());
// White in css file, like default background color. // White in css file, like default background color.
m_cwMain->setStyleClass("popup"); m_cwMain->setStyleClass("popup");
@@ -45,7 +51,8 @@ void PopupDelete::Create() {
this->hidden().connect(this, &PopupDelete::Reset); this->hidden().connect(this, &PopupDelete::Reset);
} }
void PopupDelete::Reset() { void PopupDelete::Reset()
{
m_btnDelete->hide(); m_btnDelete->hide();
m_cbReConfirm->setUnChecked(); m_cbReConfirm->setUnChecked();
m_cbReConfirm->hide(); m_cbReConfirm->hide();
@@ -53,12 +60,14 @@ void PopupDelete::Reset() {
m_cbConfirm->show(); m_cbConfirm->show();
} }
void PopupDelete::OnCbConfirm() { void PopupDelete::OnCbConfirm()
{
m_cbReConfirm->setHidden(m_cbConfirm->checkState() != CheckState::Checked); m_cbReConfirm->setHidden(m_cbConfirm->checkState() != CheckState::Checked);
m_cbReConfirm->setUnChecked(); m_cbReConfirm->setUnChecked();
m_btnDelete->setHidden(m_cbReConfirm->checkState() != CheckState::Checked); m_btnDelete->setHidden(m_cbReConfirm->checkState() != CheckState::Checked);
} }
void PopupDelete::OnCbReConfirm() { void PopupDelete::OnCbReConfirm()
{
m_btnDelete->setHidden(m_cbReConfirm->checkState() != CheckState::Checked); m_btnDelete->setHidden(m_cbReConfirm->checkState() != CheckState::Checked);
} }

View File

@@ -17,27 +17,33 @@
#include "TransientMessageWidget.h" #include "TransientMessageWidget.h"
using namespace Wt; using namespace Wt;
/** /**
* A transient popup window with a forward confirmation * A transient popup window with a forward confirmation
* before deleting a key. * before deleting a key.
*/ */
class PopupDelete : public WPopupWidget { class PopupDelete : public WPopupWidget
{
public: public:
PopupDelete(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width = 350); PopupDelete(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width = 350);
virtual ~PopupDelete(); virtual ~PopupDelete();
void Create(); void Create();
/** /**
* Caller can bind the delete function to this button. * Caller can bind the delete function to this button.
* @return * @return
*/ */
WPushButton* GetDeleteButton() {return m_btnDelete;} WPushButton* GetDeleteButton()
{
return m_btnDelete;
}
private: private:
TransientMessageWidget * m_tmwMessage; TransientMessageWidget * m_tmwMessage;
WContainerWidget * m_cwMain; WContainerWidget * m_cwMain;
WCheckBox * m_cbConfirm; WCheckBox * m_cbConfirm;
WCheckBox * m_cbReConfirm; WCheckBox * m_cbReConfirm;
WPushButton * m_btnDelete; WPushButton * m_btnDelete;
// Visibility management // Visibility management
void Reset(); void Reset();
void OnCbConfirm(); void OnCbConfirm();

View File

@@ -16,7 +16,7 @@
using namespace std; using namespace std;
PopupExpiryTime::PopupExpiryTime(WWidget * anchorWidget, TransientMessageWidget * txtMessage, PopupExpiryTime::PopupExpiryTime(WWidget * anchorWidget, TransientMessageWidget * txtMessage,
const WLength& width) const WLength& width)
: WPopupWidget(cpp14::make_unique<WContainerWidget>()) : WPopupWidget(cpp14::make_unique<WContainerWidget>())
{ {
m_tmwMessage = txtMessage; m_tmwMessage = txtMessage;
@@ -47,17 +47,17 @@ void PopupExpiryTime::Create(const WString& keyFpr)
m_keyFpr = keyFpr; m_keyFpr = keyFpr;
m_cwMain = static_cast<WContainerWidget*> (implementation()); m_cwMain = static_cast<WContainerWidget*> (implementation());
m_cwMain->setStyleClass("popup"); m_cwMain->setStyleClass("popup");
WVBoxLayout * vblMain = new WVBoxLayout(); WVBoxLayout * vblMain = new WVBoxLayout();
m_cwMain->setLayout(unique_ptr<WVBoxLayout> (vblMain)); m_cwMain->setLayout(unique_ptr<WVBoxLayout> (vblMain));
WHBoxLayout * hblExpiry = new WHBoxLayout(); WHBoxLayout * hblExpiry = new WHBoxLayout();
WText * lblExpiry = new WText(TR("ExpiryDate")); WText * lblExpiry = new WText(TR("ExpiryDate"));
hblExpiry->addWidget(unique_ptr<WText> (lblExpiry)); hblExpiry->addWidget(unique_ptr<WText> (lblExpiry));
m_deExpiry = new WDateEdit(); m_deExpiry = new WDateEdit();
hblExpiry->addWidget(unique_ptr<WDateEdit> (m_deExpiry), 1); hblExpiry->addWidget(unique_ptr<WDateEdit> (m_deExpiry), 1);
vblMain->addLayout(unique_ptr<WHBoxLayout> (hblExpiry)); vblMain->addLayout(unique_ptr<WHBoxLayout> (hblExpiry));
WHBoxLayout * hblPassphrase = new WHBoxLayout(); WHBoxLayout * hblPassphrase = new WHBoxLayout();
m_lblPassphrase = new WText(TR("Passphrase")); m_lblPassphrase = new WText(TR("Passphrase"));
hblPassphrase->addWidget(unique_ptr<WText> (m_lblPassphrase)); hblPassphrase->addWidget(unique_ptr<WText> (m_lblPassphrase));
@@ -65,7 +65,7 @@ void PopupExpiryTime::Create(const WString& keyFpr)
m_lePassphrase->setEchoMode(EchoMode::Password); m_lePassphrase->setEchoMode(EchoMode::Password);
hblPassphrase->addWidget(unique_ptr<WLineEdit> (m_lePassphrase), 1); hblPassphrase->addWidget(unique_ptr<WLineEdit> (m_lePassphrase), 1);
vblMain->addLayout(unique_ptr<WHBoxLayout> (hblPassphrase)); vblMain->addLayout(unique_ptr<WHBoxLayout> (hblPassphrase));
WHBoxLayout * hblButtons = new WHBoxLayout(); WHBoxLayout * hblButtons = new WHBoxLayout();
WPushButton * btnClose = new WPushButton(TR("Close")); WPushButton * btnClose = new WPushButton(TR("Close"));
btnClose->clicked().connect(this, &WPopupWidget::hide); btnClose->clicked().connect(this, &WPopupWidget::hide);

View File

@@ -15,18 +15,25 @@
using namespace std; using namespace std;
PopupUpload::PopupUpload(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width) PopupUpload::PopupUpload(WWidget * anchorWidget, TransientMessageWidget * txtMessage, const WLength& width)
: WPopupWidget(cpp14::make_unique<WContainerWidget>()) { : WPopupWidget(cpp14::make_unique<WContainerWidget>())
m_tmwMessage = txtMessage; m_upload = NULL; m_cwMain = NULL; {
m_cbConfirm = NULL; m_cbReConfirm = NULL; m_btnUpload = NULL; m_tmwMessage = txtMessage;
m_upload = NULL;
m_cwMain = NULL;
m_cbConfirm = NULL;
m_cbReConfirm = NULL;
m_btnUpload = NULL;
setTransient(true); setTransient(true);
setAnchorWidget(anchorWidget); setAnchorWidget(anchorWidget);
setWidth(width); setWidth(width);
} }
PopupUpload::~PopupUpload() { PopupUpload::~PopupUpload()
{
} }
void PopupUpload::Create() { void PopupUpload::Create()
{
m_upload = new WFileUpload(); m_upload = new WFileUpload();
m_upload->setFileTextSize(10240); // Is really approximate m_upload->setFileTextSize(10240); // Is really approximate
m_upload->setMultiple(false); m_upload->setMultiple(false);
@@ -54,7 +61,8 @@ void PopupUpload::Create() {
this->hidden().connect(this, &PopupUpload::Reset); this->hidden().connect(this, &PopupUpload::Reset);
} }
void PopupUpload::Reset() { void PopupUpload::Reset()
{
m_btnUpload->hide(); m_btnUpload->hide();
m_cbReConfirm->setUnChecked(); m_cbReConfirm->setUnChecked();
m_cbReConfirm->hide(); m_cbReConfirm->hide();
@@ -62,31 +70,40 @@ void PopupUpload::Reset() {
m_cbConfirm->show(); m_cbConfirm->show();
m_btnUpload->enable(); m_btnUpload->enable();
} }
void PopupUpload::OnCbConfirm() {
void PopupUpload::OnCbConfirm()
{
m_cbReConfirm->setHidden(m_cbConfirm->checkState() != CheckState::Checked); m_cbReConfirm->setHidden(m_cbConfirm->checkState() != CheckState::Checked);
m_cbReConfirm->setUnChecked(); m_cbReConfirm->setUnChecked();
m_btnUpload->setHidden(m_cbReConfirm->checkState() != CheckState::Checked); m_btnUpload->setHidden(m_cbReConfirm->checkState() != CheckState::Checked);
} }
void PopupUpload::OnCbReConfirm() { void PopupUpload::OnCbReConfirm()
{
m_btnUpload->setHidden(m_cbReConfirm->checkState() != CheckState::Checked); m_btnUpload->setHidden(m_cbReConfirm->checkState() != CheckState::Checked);
} }
void PopupUpload::DoUpload() { void PopupUpload::DoUpload()
if (m_upload->canUpload()) { {
if (m_upload->canUpload())
{
m_btnUpload->disable(); m_btnUpload->disable();
m_upload->upload(); m_upload->upload();
} else { }
else
{
m_tmwMessage->SetText(TR("CantUpload")); m_tmwMessage->SetText(TR("CantUpload"));
} }
} }
void PopupUpload::OnUploadDone() { void PopupUpload::OnUploadDone()
{
m_sigUploadDone.emit(m_upload->spoolFileName()); m_sigUploadDone.emit(m_upload->spoolFileName());
m_btnUpload->enable(); m_btnUpload->enable();
} }
void PopupUpload::OnFileTooLarge() { void PopupUpload::OnFileTooLarge()
{
m_tmwMessage->SetText(TR("FileTooLarge")); m_tmwMessage->SetText(TR("FileTooLarge"));
m_btnUpload->enable(); m_btnUpload->enable();
} }

View File

@@ -56,7 +56,7 @@ private:
void DoUpload(); void DoUpload();
void OnUploadDone(); void OnUploadDone();
void OnFileTooLarge(); void OnFileTooLarge();
}; };
#endif /* POPUPUPLOADER_H */ #endif /* POPUPUPLOADER_H */

View File

@@ -49,9 +49,11 @@ void TransientMessageWidget::OnTimer()
void TransientMessageWidget::SetText(const WString& text, bool stack) void TransientMessageWidget::SetText(const WString& text, bool stack)
{ {
m_timer.stop(); m_timer.stop();
if (stack) { if (stack)
{
// Remove the oldest message if stack is full // 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.pop_back();
} }
m_stack.push_front(text); m_stack.push_front(text);