File indexing completed on 2024-12-22 04:43:20

0001 /*
0002     This file is part of the KDE project.
0003 
0004     SPDX-FileCopyrightText: 2018 Stefano Crocco <posta@stefanocrocco.it>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 
0009 #ifndef ERRORSCHEMEHANDLER_H
0010 #define ERRORSCHEMEHANDLER_H
0011 
0012 #include <QWebEngineUrlSchemeHandler>
0013 #include <QUrl>
0014 #include <QString>
0015 
0016 #include <KIO/Global>
0017 
0018 class QBuffer;
0019 
0020 namespace WebEngine {
0021 
0022 class ErrorSchemeHandler : public QWebEngineUrlSchemeHandler{
0023     
0024     Q_OBJECT
0025     
0026 public:
0027     
0028     ErrorSchemeHandler(QObject *parent = nullptr);
0029     
0030     ~ErrorSchemeHandler() override {}
0031     
0032     void requestStarted(QWebEngineUrlRequestJob * job) override;
0033     
0034 private:
0035     
0036     struct ErrorInfo{
0037         int code= KIO::ERR_UNKNOWN;
0038         QString text;
0039         QUrl requestUrl;
0040     };
0041     
0042     ErrorInfo parseErrorUrl(const QUrl& url);
0043     
0044     void writeErrorPage(QBuffer *buf, const ErrorInfo &info);
0045     
0046     QString readWarningIconData() const;
0047     
0048     const QString m_warningIconData;
0049 };
0050 
0051 }
0052 
0053 #endif //ERRORSCHEMEHANDLER_H