Commit c1f58e1b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add a cidreference interceptor (it will adapt to new code)

parent 1a21862c
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "cidreferencesurlinterceptor.h"
#include "htmlwriter/webengineembedpart.h"
#include <QWebEngineUrlRequestInfo>
#include <QDebug>
using namespace MessageViewer;
CidReferencesUrlInterceptor::CidReferencesUrlInterceptor(QObject *parent)
: NetworkPluginUrlInterceptorInterface(parent)
{
}
CidReferencesUrlInterceptor::~CidReferencesUrlInterceptor()
{
}
bool CidReferencesUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
qDebug()<<" info.requestUrl().scheme()"<<info.requestUrl().scheme();
if (info.requestUrl().scheme() == QLatin1String("cid")) {
qDebug() << "cid requested "<<info.requestUrl();
const QString newUrl = MessageViewer::WebEngineEmbedPart::self()->contentUrl(info.requestUrl().path());
if (!newUrl.isEmpty()) {
qDebug()<<" newUrl "<<newUrl;
info.redirect(QUrl(newUrl));
}
}
return false;
}
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef CIDREFERENCESURLINTERCEPTOR_H
#define CIDREFERENCESURLINTERCEPTOR_H
#include <MessageViewer/NetworkPluginUrlInterceptorInterface>
namespace MessageViewer
{
class CidReferencesUrlInterceptor : public NetworkPluginUrlInterceptorInterface
{
Q_OBJECT
public:
explicit CidReferencesUrlInterceptor(QObject *parent = Q_NULLPTR);
~CidReferencesUrlInterceptor();
bool interceptRequest(QWebEngineUrlRequestInfo &info) Q_DECL_OVERRIDE;
};
}
#endif // CIDREFERENCESURLINTERCEPTOR_H
Supports Markdown
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