Commit 8094abcc authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add test apps

parent cb624944
......@@ -13,6 +13,16 @@ target_link_libraries(checkphishingurlgui
KF5::I18n
)
set(searchfullhashgui_SRCS searchfullhashgui.cpp)
add_executable(searchfullhashgui ${searchfullhashgui_SRCS})
target_link_libraries(searchfullhashgui
KF5::KIOCore
KF5::WebEngineViewer
Qt5::WebEngine
Qt5::WebEngineWidgets
KF5::I18n
)
set(createphishingurldatabasegui_SRCS createphishingurldatabasegui.cpp)
add_executable(createphishingurldatabasegui ${createphishingurldatabasegui_SRCS})
target_link_libraries(createphishingurldatabasegui
......
/*
Copyright (C) 2016 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "searchfullhashgui.h"
#include <QApplication>
#include <QStandardPaths>
#include <QLineEdit>
#include <QPushButton>
#include <QTextEdit>
#include <QLabel>
#include <QVBoxLayout>
SearchFullHashGui::SearchFullHashGui(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *layout = new QVBoxLayout(this);
QHBoxLayout *checkUrlLayout = new QHBoxLayout;
layout->addLayout(checkUrlLayout);
QLabel *lab = new QLabel(QStringLiteral("Url to Check:"), this);
checkUrlLayout->addWidget(lab);
mCheckUrlLineEdit = new QLineEdit(this);
checkUrlLayout->addWidget(mCheckUrlLineEdit);
QPushButton *button = new QPushButton(QStringLiteral("Check"), this);
checkUrlLayout->addWidget(button);
connect(button, &QPushButton::clicked, this, &SearchFullHashGui::slotCheckUrl);
connect(mCheckUrlLineEdit, &QLineEdit::returnPressed, this, &SearchFullHashGui::slotCheckUrl);
mResult = new QTextEdit(this);
mResult->setReadOnly(true);
mResult->setAcceptRichText(false);
layout->addWidget(mResult);
mJson = new QTextEdit(this);
mJson->setReadOnly(true);
mJson->setAcceptRichText(false);
layout->addWidget(mJson);
}
SearchFullHashGui::~SearchFullHashGui()
{
}
void SearchFullHashGui::slotCheckUrl()
{
const QString urlStr = mCheckUrlLineEdit->text().trimmed();
if (urlStr.isEmpty()) {
return;
}
mResult->clear();
/*
WebEngineViewer::CheckPhishingUrlJob *job = new WebEngineViewer::CheckPhishingUrlJob(this);
job->setUseCompactJson(false);
connect(job, &WebEngineViewer::CheckPhishingUrlJob::result, this, &SearchFullHashGui::slotGetResult);
connect(job, &WebEngineViewer::CheckPhishingUrlJob::debugJson, this, &SearchFullHashGui::slotJSonDebug);
job->setUrl(QUrl::fromUserInput(urlStr));
job->start();
*/
}
void SearchFullHashGui::slotJSonDebug(const QByteArray &debug)
{
mJson->setText(QString::fromLatin1(debug));
}
void SearchFullHashGui::slotGetResult(WebEngineViewer::SearchFullHashJob::UrlStatus result)
{
QString resultStr;
switch (result) {
case WebEngineViewer::SearchFullHashJob::Ok:
resultStr = QStringLiteral("Url ok");
break;
case WebEngineViewer::SearchFullHashJob::MalWare:
resultStr = QStringLiteral("Url MalWare");
break;
case WebEngineViewer::SearchFullHashJob::Unknown:
resultStr = QStringLiteral("Url Unknow state");
break;
case WebEngineViewer::SearchFullHashJob::BrokenNetwork:
resultStr = QStringLiteral("Broken Network");
break;
case WebEngineViewer::SearchFullHashJob::InvalidUrl:
resultStr = QStringLiteral("Invalid Url");
break;
}
mResult->setText(resultStr);
}
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QStandardPaths::setTestModeEnabled(true);
SearchFullHashGui *w = new SearchFullHashGui;
w->show();
app.exec();
delete w;
return 0;
}
/*
Copyright (C) 2016 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CHECKPHISHINGURLGUI_H
#define CHECKPHISHINGURLGUI_H
#include <QWidget>
#include "../searchfullhashjob.h"
class QLineEdit;
class QTextEdit;
class SearchFullHashGui : public QWidget
{
Q_OBJECT
public:
explicit SearchFullHashGui(QWidget *parent = Q_NULLPTR);
~SearchFullHashGui();
private Q_SLOTS:
void slotCheckUrl();
void slotGetResult(WebEngineViewer::SearchFullHashJob::UrlStatus result);
void slotJSonDebug(const QByteArray &debug);
private:
QLineEdit *mCheckUrlLineEdit;
QTextEdit *mJson;
QTextEdit *mResult;
};
#endif // CHECKPHISHINGURLGUI_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