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
80904450
Commit
80904450
authored
Feb 18, 2021
by
Ingo Klöcker
Browse files
Use std::vector for lists of keys everywhere
This way we avoid unnecessary conversions between std::vector and QVector.
parent
9e50e0f9
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/crypto/gui/signencryptfileswizard.cpp
View file @
80904450
...
...
@@ -194,21 +194,20 @@ public:
return
true
;
}
QV
ector
<
Key
>
recipients
()
const
std
::
v
ector
<
Key
>
recipients
()
const
{
return
mWidget
->
recipients
();
}
/* In the future we might find a usecase for multiple
* signers */
QV
ector
<
Key
>
signers
()
const
std
::
v
ector
<
Key
>
signers
()
const
{
QVector
<
Key
>
ret
;
const
Key
k
=
mWidget
->
signKey
();
if
(
!
k
.
isNull
())
{
ret
<<
k
;
ret
urn
{
k
}
;
}
return
ret
;
return
{}
;
}
private:
...
...
@@ -309,7 +308,7 @@ private Q_SLOTS:
if
(
mRequester
.
isEmpty
())
{
return
;
}
const
QV
ector
<
Key
>
recipients
=
mWidget
->
recipients
();
const
std
::
v
ector
<
Key
>
recipients
=
mWidget
->
recipients
();
const
Key
sigKey
=
mWidget
->
signKey
();
bool
pgp
=
mWidget
->
encryptSymmetric
();
bool
cms
=
false
;
...
...
@@ -461,12 +460,12 @@ void SignEncryptFilesWizard::setArchiveMutable(bool archive)
mSigEncPage
->
setArchiveMutable
(
archive
);
}
QV
ector
<
Key
>
SignEncryptFilesWizard
::
resolvedRecipients
()
const
std
::
v
ector
<
Key
>
SignEncryptFilesWizard
::
resolvedRecipients
()
const
{
return
mSigEncPage
->
recipients
();
}
QV
ector
<
Key
>
SignEncryptFilesWizard
::
resolvedSigners
()
const
std
::
v
ector
<
Key
>
SignEncryptFilesWizard
::
resolvedSigners
()
const
{
return
mSigEncPage
->
signers
();
}
...
...
src/crypto/gui/signencryptfileswizard.h
View file @
80904450
...
...
@@ -76,8 +76,8 @@ public:
void
setTaskCollection
(
const
std
::
shared_ptr
<
Kleo
::
Crypto
::
TaskCollection
>
&
coll
);
// Outputs
QV
ector
<
GpgME
::
Key
>
resolvedRecipients
()
const
;
QV
ector
<
GpgME
::
Key
>
resolvedSigners
()
const
;
std
::
v
ector
<
GpgME
::
Key
>
resolvedRecipients
()
const
;
std
::
v
ector
<
GpgME
::
Key
>
resolvedSigners
()
const
;
bool
encryptSymmetric
()
const
;
void
setLabelText
(
const
QString
&
label
)
const
;
...
...
src/crypto/gui/signencryptwidget.cpp
View file @
80904450
...
...
@@ -406,9 +406,9 @@ Key SignEncryptWidget::selfKey() const
return
Key
();
}
QV
ector
<
Key
>
SignEncryptWidget
::
recipients
()
const
std
::
v
ector
<
Key
>
SignEncryptWidget
::
recipients
()
const
{
QV
ector
<
Key
>
ret
;
std
::
v
ector
<
Key
>
ret
;
for
(
const
CertificateLineEdit
*
w
:
qAsConst
(
mRecpWidgets
))
{
if
(
!
w
->
isEnabled
())
{
// If one is disabled, all are disabled.
...
...
@@ -417,7 +417,7 @@ QVector <Key> SignEncryptWidget::recipients() const
const
Key
k
=
w
->
key
();
const
KeyGroup
g
=
w
->
group
();
if
(
!
k
.
isNull
())
{
ret
<<
k
;
ret
.
push_back
(
k
)
;
}
else
if
(
!
g
.
isNull
())
{
const
auto
keys
=
g
.
keys
();
std
::
copy
(
keys
.
begin
(),
keys
.
end
(),
std
::
back_inserter
(
ret
));
...
...
@@ -425,7 +425,7 @@ QVector <Key> SignEncryptWidget::recipients() const
}
const
Key
k
=
selfKey
();
if
(
!
k
.
isNull
())
{
ret
<<
k
;
ret
.
push_back
(
k
)
;
}
return
ret
;
}
...
...
@@ -454,12 +454,12 @@ bool SignEncryptWidget::isDeVsAndValid() const
void
SignEncryptWidget
::
updateOp
()
{
const
Key
sigKey
=
signKey
();
const
QV
ector
<
Key
>
recp
=
recipients
();
const
std
::
v
ector
<
Key
>
recp
=
recipients
();
QString
newOp
;
if
(
!
sigKey
.
isNull
()
&&
(
!
recp
.
isE
mpty
()
||
encryptSymmetric
()))
{
if
(
!
sigKey
.
isNull
()
&&
(
!
recp
.
e
mpty
()
||
encryptSymmetric
()))
{
newOp
=
i18nc
(
"@action"
,
"Sign / Encrypt"
);
}
else
if
(
!
recp
.
isE
mpty
()
||
encryptSymmetric
())
{
}
else
if
(
!
recp
.
e
mpty
()
||
encryptSymmetric
())
{
newOp
=
i18nc
(
"@action"
,
"Encrypt"
);
}
else
if
(
!
sigKey
.
isNull
())
{
newOp
=
i18nc
(
"@action"
,
"Sign"
);
...
...
src/crypto/gui/signencryptwidget.h
View file @
80904450
...
...
@@ -34,7 +34,7 @@ public:
/** Returns the list of recipients selected in the dialog
* or an empty list if encryption is disabled */
QV
ector
<
GpgME
::
Key
>
recipients
()
const
;
std
::
v
ector
<
GpgME
::
Key
>
recipients
()
const
;
/** Returns the selected signing key or a null key if signing
* is disabled. */
...
...
src/crypto/signencryptfilescontroller.cpp
View file @
80904450
...
...
@@ -507,26 +507,26 @@ void SignEncryptFilesController::Private::slotWizardOperationPrepared()
const
bool
archive
=
(
wizard
->
outputNames
().
value
(
SignEncryptFilesWizard
::
Directory
).
isNull
()
&&
files
.
size
()
>
1
)
||
((
operation
&
ArchiveMask
)
==
ArchiveForced
);
const
QV
ector
<
Key
>
recipients
=
wizard
->
resolvedRecipients
();
const
QV
ector
<
Key
>
signers
=
wizard
->
resolvedSigners
();
const
std
::
v
ector
<
Key
>
recipients
=
wizard
->
resolvedRecipients
();
const
std
::
v
ector
<
Key
>
signers
=
wizard
->
resolvedSigners
();
const
FileOperationsPreferences
prefs
;
const
bool
ascii
=
prefs
.
addASCIIArmor
();
QV
ector
<
Key
>
pgpRecipients
,
cmsRecipients
,
pgpSigners
,
cmsSigners
;
std
::
v
ector
<
Key
>
pgpRecipients
,
cmsRecipients
,
pgpSigners
,
cmsSigners
;
Q_FOREACH
(
const
Key
&
k
,
recipients
)
{
if
(
k
.
protocol
()
==
GpgME
::
OpenPGP
)
{
pgpRecipients
<<
k
;
pgpRecipients
.
push_back
(
k
)
;
}
else
{
cmsRecipients
<<
k
;
cmsRecipients
.
push_back
(
k
)
;
}
}
Q_FOREACH
(
const
Key
&
k
,
signers
)
{
if
(
k
.
protocol
()
==
GpgME
::
OpenPGP
)
{
pgpSigners
<<
k
;
pgpSigners
.
push_back
(
k
)
;
}
else
{
cmsSigners
<<
k
;
cmsSigners
.
push_back
(
k
)
;
}
}
...
...
@@ -539,10 +539,10 @@ void SignEncryptFilesController::Private::slotWizardOperationPrepared()
tasks
=
createArchiveSignEncryptTasksForFiles
(
files
,
getDefaultAd
(),
ascii
,
pgpRecipients
.
toStdVector
()
,
pgpSigners
.
toStdVector
()
,
cmsRecipients
.
toStdVector
()
,
cmsSigners
.
toStdVector
()
,
pgpRecipients
,
pgpSigners
,
cmsRecipients
,
cmsSigners
,
wizard
->
outputNames
(),
wizard
->
encryptSymmetric
());
...
...
@@ -550,10 +550,10 @@ void SignEncryptFilesController::Private::slotWizardOperationPrepared()
Q_FOREACH
(
const
QString
&
file
,
files
)
{
const
std
::
vector
<
std
::
shared_ptr
<
SignEncryptTask
>
>
created
=
createSignEncryptTasksForFileInfo
(
QFileInfo
(
file
),
ascii
,
pgpRecipients
.
toStdVector
()
,
pgpSigners
.
toStdVector
()
,
cmsRecipients
.
toStdVector
()
,
cmsSigners
.
toStdVector
()
,
pgpRecipients
,
pgpSigners
,
cmsRecipients
,
cmsSigners
,
buildOutputNamesForDir
(
file
,
wizard
->
outputNames
()),
wizard
->
encryptSymmetric
());
tasks
.
insert
(
tasks
.
end
(),
created
.
begin
(),
created
.
end
());
...
...
src/view/padwidget.cpp
View file @
80904450
...
...
@@ -378,8 +378,9 @@ public:
const
auto
sigKey
=
mSigEncWidget
->
signKey
();
bool
encrypt
=
mSigEncWidget
->
encryptSymmetric
()
||
!
mSigEncWidget
->
recipients
().
isEmpty
();
bool
sign
=
!
sigKey
.
isNull
();
const
std
::
vector
<
GpgME
::
Key
>
recipients
=
mSigEncWidget
->
recipients
();
const
bool
encrypt
=
mSigEncWidget
->
encryptSymmetric
()
||
!
recipients
.
empty
();
const
bool
sign
=
!
sigKey
.
isNull
();
if
(
sign
)
{
task
->
setSign
(
true
);
...
...
@@ -390,7 +391,7 @@ public:
task
->
setSign
(
false
);
}
task
->
setEncrypt
(
encrypt
);
task
->
setRecipients
(
mSigEncWidget
->
recipients
().
toStdVector
()
);
task
->
setRecipients
(
recipients
);
task
->
setEncryptSymmetric
(
mSigEncWidget
->
encryptSymmetric
());
task
->
setAsciiArmor
(
true
);
...
...
Write
Preview
Supports
Markdown
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