Commit 333fe625 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Allow URLs with certain schemes to be blocked by Kleopatra

Add a setting for specifying a list of URL schemes that shall be blocked
by Kleopatra, i.e. for URLs with those schemes nothing shall happen.

GnuPG-bug-id: 5777
parent 7b08d57e
Pipeline #129412 passed with stage
in 3 minutes and 14 seconds
......@@ -113,6 +113,14 @@
<default>true</default>
</entry>
</group>
<group name="Privacy">
<entry name="BlockedUrlSchemes" type="StringList">
<label>URL schemes to block</label>
<whatsthis>This is a list of URL schemes that shall be blocked by the application.
This can be used to prevent the application from opening external applications for certain URLs.</whatsthis>
<default></default>
</entry>
</group>
<group name="Smartcard">
<entry name="AlwaysSearchCardOnKeyserver" type="Bool">
<label>Always search smartcard certificates on keyserver</label>
......
......@@ -56,6 +56,7 @@
#include <KMessageBox>
#include <KWindowSystem>
#include <QDesktopServices>
#include <QFile>
#include <QDir>
#include <QPointer>
......@@ -224,6 +225,10 @@ void KleopatraApplication::init()
QWindowsWindowFunctions::setWindowActivationBehavior(
QWindowsWindowFunctions::AlwaysActivateWindow);
#endif
const auto blockedUrlSchemes = Settings{}.blockedUrlSchemes();
for (const auto &scheme : blockedUrlSchemes) {
QDesktopServices::setUrlHandler(scheme, this, "blockUrl");
}
add_resources();
DN::setAttributeOrder(Settings{}.attributeOrder());
d->setupKeyCache();
......@@ -684,3 +689,8 @@ bool KleopatraApplication::ignoreNewInstance() const
{
return d->ignoreNewInstance;
}
void KleopatraApplication::blockUrl(const QUrl &url)
{
qCDebug(KLEOPATRA_LOG) << "Blocking URL" << url;
}
......@@ -97,6 +97,10 @@ Q_SIGNALS:
void configurationChanged();
private Q_SLOTS:
// used as URL handler for URLs with schemes that shall be blocked
void blockUrl(const QUrl &url);
private:
class Private;
kdtools::pimpl_ptr<Private> d;
......
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