Skip to content
GitLab
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
cf9b98e6
Commit
cf9b98e6
authored
Nov 29, 2021
by
Ingo Klöcker
Browse files
Disable actions for signing clipboard content if needed keys are missing
parent
c3635355
Pipeline
#102793
passed with stage
in 5 minutes and 30 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
cf9b98e6
...
...
@@ -30,7 +30,7 @@ option(DISABLE_KWATCHGNUPG "Don't build the kwatchgnupg tool [default=OFF]" OFF)
# Standalone build. Find / include everything necessary.
set
(
KF5_MIN_VERSION
"5.88.0"
)
set
(
KMIME_VERSION
"5.19.40"
)
set
(
LIBKLEO_VERSION
"5.19.4
5
"
)
set
(
LIBKLEO_VERSION
"5.19.4
6
"
)
set
(
QT_REQUIRED_VERSION
"5.15.2"
)
set
(
GPGME_REQUIRED_VERSION
"1.13.1"
)
set
(
BOOST_REQUIRED_VERSION
"1.58"
)
...
...
src/commands/signclipboardcommand.cpp
View file @
cf9b98e6
...
...
@@ -20,6 +20,8 @@
#include
<utils/input.h>
#include
<utils/output.h>
#include
<Libkleo/Algorithm>
#include
<Libkleo/KeyCache>
#include
<Libkleo/Stl_Util>
#include
<KLocalizedString>
...
...
@@ -29,6 +31,8 @@
#include
<QClipboard>
#include
<QMimeData>
#include
<gpgme++/key.h>
#include
<exception>
using
namespace
Kleo
;
...
...
@@ -119,13 +123,19 @@ SignClipboardCommand::~SignClipboardCommand()
}
// static
bool
SignClipboardCommand
::
canSignCurrentClipboard
()
bool
SignClipboardCommand
::
canSignCurrentClipboard
(
GpgME
::
Protocol
protocol
)
{
if
(
const
QClipboard
*
clip
=
QApplication
::
clipboard
())
if
(
const
QMimeData
*
mime
=
clip
->
mimeData
())
{
return
mime
->
hasText
();
bool
canSign
=
false
;
if
(
const
QClipboard
*
const
clip
=
QApplication
::
clipboard
())
{
if
(
const
QMimeData
*
const
mime
=
clip
->
mimeData
())
{
canSign
=
mime
->
hasText
();
}
return
false
;
}
if
(
canSign
)
{
canSign
&=
Kleo
::
any_of
(
KeyCache
::
instance
()
->
secretKeys
(),
[](
const
auto
&
k
)
{
return
k
.
hasSecret
();
});
}
return
canSign
;
}
void
SignClipboardCommand
::
doStart
()
...
...
src/commands/signclipboardcommand.h
View file @
cf9b98e6
...
...
@@ -30,7 +30,7 @@ public:
explicit
SignClipboardCommand
(
GpgME
::
Protocol
protocol
,
KeyListController
*
parent
);
~
SignClipboardCommand
()
override
;
static
bool
canSignCurrentClipboard
();
static
bool
canSignCurrentClipboard
(
GpgME
::
Protocol
protocol
);
private:
void
doStart
()
override
;
...
...
src/utils/clipboardmenu.cpp
View file @
cf9b98e6
...
...
@@ -115,9 +115,9 @@ void ClipboardMenu::slotEnableDisableActions()
const
QSignalBlocker
blocker
(
QApplication
::
clipboard
());
mImportClipboardAction
->
setEnabled
(
ImportCertificateFromClipboardCommand
::
canImportCurrentClipboard
());
mEncryptClipboardAction
->
setEnabled
(
EncryptClipboardCommand
::
canEncryptCurrentClipboard
());
mOpenPGPSignClipboardAction
->
setEnabled
(
SignClipboardCommand
::
canSignCurrentClipboard
());
mOpenPGPSignClipboardAction
->
setEnabled
(
SignClipboardCommand
::
canSignCurrentClipboard
(
GpgME
::
OpenPGP
));
if
(
mSmimeSignClipboardAction
)
{
mSmimeSignClipboardAction
->
setEnabled
(
SignClipboardCommand
::
canSignCurrentClipboard
());
mSmimeSignClipboardAction
->
setEnabled
(
SignClipboardCommand
::
canSignCurrentClipboard
(
GpgME
::
CMS
));
}
mDecryptVerifyClipboardAction
->
setEnabled
(
DecryptVerifyClipboardCommand
::
canDecryptVerifyCurrentClipboard
());
}
Ingo Klöcker
@kloecker
mentioned in commit
010a83a6
·
Dec 01, 2021
mentioned in commit
010a83a6
mentioned in commit 010a83a6239f4ccc445d26eca8f4f85afffe5a7a
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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