Commit 74f90c8f authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Support OpenPGP keys on other cards than OpenPGP cards

We need to differentiate between the keyRefs for the actual card keys
and the keyRefs of the corresponding OpenPGP keys.

GnuPG-bug-id: 4876
parent 9ea7dfff
...@@ -30,6 +30,7 @@ using namespace SmartCard; ...@@ -30,6 +30,7 @@ using namespace SmartCard;
namespace namespace
{ {
struct KeyWidgets { struct KeyWidgets {
std::string cardKeyRef;
std::string keyGrip; std::string keyGrip;
std::string keyFingerprint; std::string keyFingerprint;
QLabel *keyTitleLabel = nullptr; QLabel *keyTitleLabel = nullptr;
...@@ -63,8 +64,8 @@ public: ...@@ -63,8 +64,8 @@ public:
void update(const Card *card); void update(const Card *card);
private: private:
void updateCachedValues(const std::string &keyRef, const Card *card); void updateCachedValues(const std::string &openPGPKeyRef, const std::string &cardKeyRef, const Card *card);
void updateKeyWidgets(const std::string &keyRef); void updateKeyWidgets(const std::string &openPGPKeyRef);
private: private:
OpenPGPKeyCardWidget *const q; OpenPGPKeyCardWidget *const q;
...@@ -99,25 +100,26 @@ OpenPGPKeyCardWidget::Private::Private(OpenPGPKeyCardWidget *q) ...@@ -99,25 +100,26 @@ OpenPGPKeyCardWidget::Private::Private(OpenPGPKeyCardWidget *q)
void OpenPGPKeyCardWidget::Private::update(const Card *card) void OpenPGPKeyCardWidget::Private::update(const Card *card)
{ {
if (card) { if (card) {
updateCachedValues(OpenPGPCard::pgpSigKeyRef(), card); updateCachedValues(OpenPGPCard::pgpSigKeyRef(), card->signingKeyRef(), card);
updateCachedValues(OpenPGPCard::pgpEncKeyRef(), card); updateCachedValues(OpenPGPCard::pgpEncKeyRef(), card->encryptionKeyRef(), card);
updateCachedValues(OpenPGPCard::pgpAuthKeyRef(), card); updateCachedValues(OpenPGPCard::pgpAuthKeyRef(), card->authenticationKeyRef(), card);
} }
updateKeyWidgets(OpenPGPCard::pgpSigKeyRef()); updateKeyWidgets(OpenPGPCard::pgpSigKeyRef());
updateKeyWidgets(OpenPGPCard::pgpEncKeyRef()); updateKeyWidgets(OpenPGPCard::pgpEncKeyRef());
updateKeyWidgets(OpenPGPCard::pgpAuthKeyRef()); updateKeyWidgets(OpenPGPCard::pgpAuthKeyRef());
} }
void OpenPGPKeyCardWidget::Private::updateCachedValues(const std::string &keyRef, const Card *card) void OpenPGPKeyCardWidget::Private::updateCachedValues(const std::string &openPGPKeyRef, const std::string &cardKeyRef, const Card *card)
{ {
KeyWidgets &widgets = mKeyWidgets.at(keyRef); KeyWidgets &widgets = mKeyWidgets.at(openPGPKeyRef);
widgets.keyGrip = card->keyInfo(keyRef).grip; widgets.cardKeyRef = cardKeyRef;
widgets.keyFingerprint = card->keyFingerprint(keyRef); widgets.keyGrip = card->keyInfo(cardKeyRef).grip;
widgets.keyFingerprint = card->keyFingerprint(openPGPKeyRef);
} }
void OpenPGPKeyCardWidget::Private::updateKeyWidgets(const std::string &keyRef) void OpenPGPKeyCardWidget::Private::updateKeyWidgets(const std::string &openPGPKeyRef)
{ {
const KeyWidgets &widgets = mKeyWidgets.at(keyRef); const KeyWidgets &widgets = mKeyWidgets.at(openPGPKeyRef);
if (widgets.keyFingerprint.empty()) { if (widgets.keyFingerprint.empty()) {
widgets.keyInfoLabel->setTextFormat(Qt::RichText); widgets.keyInfoLabel->setTextFormat(Qt::RichText);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment