| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <kalle@kde.org> |
| 4 | SPDX-FileCopyrightText: 1998, 1999, 2000 Waldo Bastian <bastian@kde.org> |
| 5 | |
| 6 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | #include "kurlauthorized.h" |
| 10 | #include <KConfig> |
| 11 | #include <QUrl> |
| 12 | #include <kprotocolinfo.h> |
| 13 | |
| 14 | namespace KAuthorizedInternal |
| 15 | { |
| 16 | KCONFIGCORE_EXPORT extern bool |
| 17 | authorizeUrlAction(const QString &action, const QUrl &_baseURL, const QUrl &_destURL, const QString &baseClass, const QString &destClass); |
| 18 | |
| 19 | KCONFIGCORE_EXPORT extern void allowUrlAction(const QString &action, const QUrl &_baseURL, const QUrl &_destURL); |
| 20 | } |
| 21 | |
| 22 | namespace KUrlAuthorized |
| 23 | { |
| 24 | bool authorizeUrlAction(const QString &action, const QUrl &baseURL, const QUrl &destURL) |
| 25 | { |
| 26 | const QString baseClass = baseURL.isEmpty() ? QString() : KProtocolInfo::protocolClass(protocol: baseURL.scheme()); |
| 27 | const QString destClass = destURL.isEmpty() ? QString() : KProtocolInfo::protocolClass(protocol: destURL.scheme()); |
| 28 | return KAuthorizedInternal::authorizeUrlAction(action, baseURL: baseURL, destURL: destURL, baseClass, destClass); |
| 29 | } |
| 30 | |
| 31 | void allowUrlAction(const QString &action, const QUrl &_baseURL, const QUrl &_destURL) |
| 32 | { |
| 33 | if (authorizeUrlAction(action, baseURL: _baseURL, destURL: _destURL)) { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | KAuthorizedInternal::allowUrlAction(action, _baseURL, _destURL); |
| 38 | } |
| 39 | |
| 40 | } // namespace |
| 41 | |