File indexing completed on 2024-04-21 15:00:04

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <kalle@kde.org>
0004     SPDX-FileCopyrightText: 1998, 1999, 2000 Waldo Bastian <bastian@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "kurlauthorized.h"
0010 #include <KConfig>
0011 #include <QUrl>
0012 #include <kprotocolinfo.h>
0013 
0014 namespace KAuthorized
0015 {
0016 KCONFIGCORE_EXPORT extern bool
0017 authorizeUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL, const QString &baseClass, const QString &destClass);
0018 
0019 KCONFIGCORE_EXPORT extern void allowUrlActionInternal(const QString &action, const QUrl &_baseURL, const QUrl &_destURL);
0020 
0021 }
0022 
0023 namespace KUrlAuthorized
0024 {
0025 bool authorizeUrlAction(const QString &action, const QUrl &baseURL, const QUrl &destURL)
0026 {
0027     const QString baseClass = baseURL.isEmpty() ? QString() : KProtocolInfo::protocolClass(baseURL.scheme());
0028     const QString destClass = destURL.isEmpty() ? QString() : KProtocolInfo::protocolClass(destURL.scheme());
0029     return KAuthorized::authorizeUrlActionInternal(action, baseURL, destURL, baseClass, destClass);
0030 }
0031 
0032 void allowUrlAction(const QString &action, const QUrl &_baseURL, const QUrl &_destURL)
0033 {
0034     if (authorizeUrlAction(action, _baseURL, _destURL)) {
0035         return;
0036     }
0037 
0038     KAuthorized::allowUrlActionInternal(action, _baseURL, _destURL);
0039 }
0040 
0041 } // namespace