File indexing completed on 2024-07-14 14:34:09

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2020 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #ifndef WIDGETSUNTRUSTEDPROGRAMHANDLER_H
0009 #define WIDGETSUNTRUSTEDPROGRAMHANDLER_H
0010 
0011 #include "untrustedprogramhandlerinterface.h"
0012 
0013 #include <memory>
0014 
0015 class QDialog;
0016 class QWidget;
0017 
0018 namespace KIO
0019 {
0020 // TODO KF6: Make KIO::JobUiDelegate inherit from WidgetsUntrustedProgramHandler
0021 // (or even merge the two classes)
0022 // so that setDelegate(new KIO::JobUiDelegate) provides both dialog boxes on error
0023 // and the messagebox for handling untrusted programs.
0024 // Then port those users of ApplicationLauncherJob which were setting a KDialogJobUiDelegate
0025 // to set a KIO::JobUiDelegate instead.
0026 class WidgetsUntrustedProgramHandlerPrivate;
0027 
0028 class WidgetsUntrustedProgramHandler : public UntrustedProgramHandlerInterface
0029 {
0030     Q_OBJECT
0031 public:
0032     explicit WidgetsUntrustedProgramHandler(QObject *parent = nullptr);
0033     ~WidgetsUntrustedProgramHandler() override;
0034 
0035     void showUntrustedProgramWarning(KJob *job, const QString &programName) override;
0036 
0037     // Compat code for KRun::runUrl. Will disappear before KF6
0038     bool execUntrustedProgramWarning(QWidget *window, const QString &programName);
0039 
0040     void setWindow(QWidget *window);
0041 
0042 private:
0043     QDialog *createDialog(QWidget *parentWidget, const QString &programName);
0044 
0045     std::unique_ptr<WidgetsUntrustedProgramHandlerPrivate> d;
0046 };
0047 
0048 }
0049 
0050 #endif // WIDGETSUNTRUSTEDPROGRAMHANDLER_H