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
559bcdda
Commit
559bcdda
authored
Aug 31, 2020
by
Ingo Klöcker
Browse files
Use the new getCard() to get the card
... instead of iterating manually over the cards GnuPG-bug-id: 4794
parent
2bca8779
Pipeline
#32480
passed with stage
in 43 minutes and 40 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/commands/keytocardcommand.cpp
View file @
559bcdda
...
...
@@ -103,40 +103,27 @@ private:
void
slotDetermined
(
int
slot
)
{
// Check if we need to do the overwrite warning.
const
auto
cards
=
ReaderStatus
::
instance
()
->
getCards
();
qCDebug
(
KLEOPATRA_LOG
)
<<
"KeyToCardCommand::Private::slotDetermined():"
<<
slot
;
qDebug
()
<<
"slot determined"
<<
slot
;
bool
cardFound
=
false
;
std
::
string
existingKey
;
QString
encKeyWarning
;
for
(
const
auto
&
card
:
cards
)
{
if
(
card
->
serialNumber
()
==
mSerial
)
{
const
auto
pgpCard
=
dynamic_cast
<
SmartCard
::
OpenPGPCard
*>
(
card
.
get
());
Q_ASSERT
(
pgpCard
);
cardFound
=
true
;
if
(
slot
==
1
)
{
existingKey
=
pgpCard
->
sigFpr
();
break
;
}
if
(
slot
==
2
)
{
existingKey
=
pgpCard
->
encFpr
();
encKeyWarning
=
i18n
(
"It will no longer be possible to decrypt past communication "
"encrypted for the existing key."
);
break
;
}
if
(
slot
==
3
)
{
existingKey
=
pgpCard
->
authFpr
();
break
;
}
break
;
}
}
if
(
!
cardFound
)
{
// Check if we need to do the overwrite warning.
const
auto
pgpCard
=
ReaderStatus
::
instance
()
->
getCard
<
OpenPGPCard
>
(
mSerial
);
if
(
!
pgpCard
)
{
error
(
i18n
(
"Failed to find the card with the serial number: %1"
,
QString
::
fromStdString
(
mSerial
)));
finished
();
return
;
}
std
::
string
existingKey
;
QString
encKeyWarning
;
if
(
slot
==
1
)
{
existingKey
=
pgpCard
->
sigFpr
();
}
else
if
(
slot
==
2
)
{
existingKey
=
pgpCard
->
encFpr
();
encKeyWarning
=
i18n
(
"It will no longer be possible to decrypt past communication "
"encrypted for the existing key."
);
}
else
if
(
slot
==
3
)
{
existingKey
=
pgpCard
->
authFpr
();
}
if
(
!
existingKey
.
empty
())
{
if
(
KMessageBox
::
warningContinueCancel
(
parentWidgetOrView
(),
i18nc
(
"@info"
,
"<p>This card already contains a key in this slot. Continuing will <b>overwrite</b> that key.</p>"
...
...
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