Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kleopatra
Commits
81dbad4a
Commit
81dbad4a
authored
May 19, 2021
by
Ingo Klöcker
Browse files
Separate update of cached values from card and update of widgets
GnuPG-bug-id: 4876
parent
bc607f1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/view/openpgpkeycardwidget.cpp
View file @
81dbad4a
...
...
@@ -63,7 +63,8 @@ public:
void
update
(
const
Card
*
card
);
private:
void
updateKeyWidgets
(
const
std
::
string
&
keyRef
,
const
Card
*
card
);
void
updateCachedValues
(
const
std
::
string
&
keyRef
,
const
Card
*
card
);
void
updateKeyWidgets
(
const
std
::
string
&
keyRef
);
private:
OpenPGPKeyCardWidget
*
const
q
;
...
...
@@ -97,27 +98,36 @@ OpenPGPKeyCardWidget::Private::Private(OpenPGPKeyCardWidget *q)
void
OpenPGPKeyCardWidget
::
Private
::
update
(
const
Card
*
card
)
{
updateKeyWidgets
(
OpenPGPCard
::
pgpSigKeyRef
(),
card
);
updateKeyWidgets
(
OpenPGPCard
::
pgpEncKeyRef
(),
card
);
updateKeyWidgets
(
OpenPGPCard
::
pgpAuthKeyRef
(),
card
);
if
(
card
)
{
updateCachedValues
(
OpenPGPCard
::
pgpSigKeyRef
(),
card
);
updateCachedValues
(
OpenPGPCard
::
pgpEncKeyRef
(),
card
);
updateCachedValues
(
OpenPGPCard
::
pgpAuthKeyRef
(),
card
);
}
updateKeyWidgets
(
OpenPGPCard
::
pgpSigKeyRef
());
updateKeyWidgets
(
OpenPGPCard
::
pgpEncKeyRef
());
updateKeyWidgets
(
OpenPGPCard
::
pgpAuthKeyRef
());
}
void
OpenPGPKeyCardWidget
::
Private
::
update
KeyWidget
s
(
const
std
::
string
&
keyRef
,
const
Card
*
card
)
void
OpenPGPKeyCardWidget
::
Private
::
update
CachedValue
s
(
const
std
::
string
&
keyRef
,
const
Card
*
card
)
{
KeyWidgets
widgets
=
mKeyWidgets
.
at
(
keyRef
);
const
std
::
string
grip
=
card
?
card
->
keyInfo
(
keyRef
).
grip
:
widgets
.
keyGrip
;
widgets
.
keyGrip
=
grip
;
if
(
grip
.
empty
())
{
KeyWidgets
&
widgets
=
mKeyWidgets
.
at
(
keyRef
);
widgets
.
keyGrip
=
card
->
keyInfo
(
keyRef
).
grip
;
widgets
.
keyFingerprint
=
card
->
keyFingerprint
(
keyRef
);
}
void
OpenPGPKeyCardWidget
::
Private
::
updateKeyWidgets
(
const
std
::
string
&
keyRef
)
{
const
KeyWidgets
&
widgets
=
mKeyWidgets
.
at
(
keyRef
);
if
(
widgets
.
keyGrip
.
empty
())
{
widgets
.
keyInfoLabel
->
setText
(
i18n
(
"Slot empty"
));
if
(
widgets
.
createCSRButton
)
{
widgets
.
createCSRButton
->
setEnabled
(
false
);
}
}
else
{
const
std
::
string
fpr
=
card
?
card
->
keyFingerprint
(
keyRef
)
:
widgets
.
keyFingerprint
;
widgets
.
keyFingerprint
=
fpr
;
QStringList
lines
=
{
Formatting
::
prettyID
(
fpr
.
c_str
())};
if
(
fpr
.
size
()
>=
16
)
{
const
std
::
string
keyid
=
fpr
.
substr
(
fpr
.
size
()
-
16
);
QStringList
lines
=
{
Formatting
::
prettyID
(
widgets
.
keyFingerprint
.
c_str
())};
if
(
widgets
.
keyFingerprint
.
size
()
>=
16
)
{
const
std
::
string
keyid
=
widgets
.
keyFingerprint
.
substr
(
widgets
.
keyFingerprint
.
size
()
-
16
);
const
auto
subkeys
=
KeyCache
::
instance
()
->
findSubkeysByKeyID
({
keyid
});
if
(
subkeys
.
empty
()
||
subkeys
[
0
].
isNull
())
{
lines
.
push_back
(
i18n
(
"Public key not found locally"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment