Commit 90a674d1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Activate check phishing url

parent 9e8beaad
......@@ -1104,11 +1104,7 @@ bool KRunURLHandler::handleClick(const QUrl &url, ViewerPrivate *w) const
return true;
}
}
if (!MessageViewer::Util::handleUrlWithQDesktopServices(url)) {
KRun *runner = new KRun(url, w->viewer()); // will delete itself
runner->setRunExecutables(false);
}
w->checkPhishingUrl();
return true;
} else {
return false;
......
......@@ -2009,24 +2009,33 @@ void ViewerPrivate::slotUrlOpen(const QUrl &url)
if (URLHandlerManager::instance()->handleClick(mClickedUrl, this)) {
return;
}
#if 0
if (MessageViewer::MessageViewerSettings::self()->checkPhishingUrl()) {
Q_EMIT urlClicked(mMessageItem, mClickedUrl);
}
void ViewerPrivate::checkPhishingUrl()
{
if (MessageViewer::MessageViewerSettings::self()->checkPhishingUrl() && (mClickedUrl.scheme() != QLatin1String("mailto"))) {
MessageViewer::MailCheckPhishingUrlJob *job = new MessageViewer::MailCheckPhishingUrlJob(this);
connect(job, &MessageViewer::MailCheckPhishingUrlJob::result, this, &ViewerPrivate::slotCheckUrl);
job->setUrl(mClickedUrl);
job->setItem(mMessageItem);
job->start();
} else {
Q_EMIT urlClicked(mMessageItem, mClickedUrl);
executeRunner(mClickedUrl);
}
#else
Q_EMIT urlClicked(mMessageItem, mClickedUrl);
#endif
}
void ViewerPrivate::executeRunner(const QUrl &url)
{
if (!MessageViewer::Util::handleUrlWithQDesktopServices(url)) {
KRun *runner = new KRun(url, viewer()); // will delete itself
runner->setRunExecutables(false);
}
}
void ViewerPrivate::slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url, const Akonadi::Item &item)
{
Q_UNUSED(item);
switch (status) {
case WebEngineViewer::CheckPhishingUrlJob::BrokenNetwork:
KMessageBox::error(mMainWindow, i18n("The network is broken."), i18n("Check Phishing Url"));
......@@ -2045,7 +2054,7 @@ void ViewerPrivate::slotCheckUrl(WebEngineViewer::CheckPhishingUrlJob::UrlStatus
qCWarning(MESSAGEVIEWER_LOG) << "WebEngineViewer::CheckPhishingUrlJob unknown error ";
break;
}
Q_EMIT urlClicked(item, url);
executeRunner(mClickedUrl);
}
void ViewerPrivate::slotUrlOn(const QString &link)
......
......@@ -429,6 +429,9 @@ public:
void setPrintElementBackground(bool printElementBackground);
bool showEmoticons() const;
void checkPhishingUrl();
void executeRunner(const QUrl &url);
private Q_SLOTS:
void slotActivatePlugin(MessageViewer::ViewerPluginInterface *interface);
......
......@@ -32,20 +32,22 @@ CheckPhishingUrlJob::CheckPhishingUrlJob(QObject *parent)
{
mNetworkAccessManager = new QNetworkAccessManager(this);
connect(mNetworkAccessManager, &QNetworkAccessManager::finished, this, &CheckPhishingUrlJob::slotCheckUrlFinished);
connect(mNetworkAccessManager, &QNetworkAccessManager::sslErrors, this, &CheckPhishingUrlJob::slotSslErrors);
}
CheckPhishingUrlJob::~CheckPhishingUrlJob()
{
}
QString CheckPhishingUrlJob::apiKey() const
void CheckPhishingUrlJob::slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error)
{
return QStringLiteral("AIzaSyBS62pXATjabbH2RM_jO2EzDg1mTMHlnyo");
qCDebug(WEBENGINEVIEWER_LOG) << " void StorageServiceAbstractJob::slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error)" << error.count();
reply->ignoreSslErrors(error);
}
QString CheckPhishingUrlJob::secretKey() const
QString CheckPhishingUrlJob::apiKey() const
{
return QStringLiteral("mdT1DjzohxN3npUUzkENT0gO");
return QStringLiteral("AIzaSyBS62pXATjabbH2RM_jO2EzDg1mTMHlnyo");
}
void CheckPhishingUrlJob::parse(const QByteArray &replyStr)
......@@ -165,9 +167,9 @@ void CheckPhishingUrlJob::start()
void CheckPhishingUrlJob::slotError(QNetworkReply::NetworkError error)
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
qCDebug(WEBENGINEVIEWER_LOG)<<" error "<<error << " error string : "<< reply->errorString();
qDebug()<<" error "<<error << " error string : "<< reply->errorString();
reply->deleteLater();
Q_EMIT result(WebEngineViewer::CheckPhishingUrlJob::Unknown, mUrl);
//Q_EMIT result(WebEngineViewer::CheckPhishingUrlJob::Unknown, mUrl);
deleteLater();
}
......
......@@ -54,9 +54,10 @@ Q_SIGNALS:
void result(WebEngineViewer::CheckPhishingUrlJob::UrlStatus status, const QUrl &url);
void debugJson(const QByteArray &ba);
private Q_SLOTS:
void slotSslErrors(QNetworkReply *reply, const QList<QSslError> &error);
private:
QString apiKey() const;
QString secretKey() const;
void slotError(QNetworkReply::NetworkError error);
void slotCheckUrlFinished(QNetworkReply *reply);
QUrl mUrl;
......
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