Migrate to cmake and refine the code structure (#92)

* migrate to cmake

* move the 3rd party libs

* organize 3rdparty

* update the 3rd party version

* refine the CMakeLists.txt

* update install command

* update install command

* update install command

* update install command

* update dependency

* update the dependency

* update the dependency

* remove CPM.cmake

* remove QtCreator project file

* update cmake file

* improve cmake file

* add cmakew

* use wget

* remove echo

* update the doc

* remove the screenshot

* update the doc

* update the install steps

* check the openconnect version

* update the doc

* update install scripts

* fix install scripts

* improve message

* improve message

* improve install scripts

* improve the version check

* improve the version check

* improve install script

* add version

* organize includes

* add version bump

* update CI

* update CI

* add the release flag

* update message
This commit is contained in:
Kevin Yue
2021-09-19 14:32:12 +08:00
committed by GitHub
parent 5c97b2df7a
commit 8a65099ca7
59 changed files with 1034 additions and 357 deletions

78
GPClient/CMakeLists.txt Normal file
View File

@@ -0,0 +1,78 @@
include("${CMAKE_SOURCE_DIR}/cmake/Add3rdParty.cmake")
project(GPClient)
set(gpclient_GENERATED_SOURCES)
qt5_add_dbus_interface(gpclient_GENERATED_SOURCES ${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml gpserviceinterface)
add_executable(gpclient
cdpcommand.cpp
cdpcommandmanager.cpp
enhancedwebview.cpp
gatewayauthenticator.cpp
gatewayauthenticatorparams.cpp
gpgateway.cpp
gphelper.cpp
loginparams.cpp
main.cpp
normalloginwindow.cpp
portalauthenticator.cpp
portalconfigresponse.cpp
preloginresponse.cpp
samlloginwindow.cpp
gpclient.cpp
settingsdialog.cpp
gpclient.ui
normalloginwindow.ui
settingsdialog.ui
resources.qrc
${gpclient_GENERATED_SOURCES}
)
add_3rdparty(
SingleApplication
GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git
GIT_TAG v3.3.0
CMAKE_ARGS -DQAPPLICATION_CLASS=QApplication
)
add_3rdparty(
plog
GIT_REPOSITORY https://github.com/SergiusTheBest/plog.git
GIT_TAG 1.1.5
CMAKE_ARGS -DPLOG_BUILD_SAMPLES=OFF
)
ExternalProject_Get_Property(SingleApplication-${PROJECT_NAME} SOURCE_DIR BINARY_DIR)
set(SingleApplication_INCLUDE_DIR ${SOURCE_DIR})
set(SingleApplication_LIBRARY ${BINARY_DIR}/libSingleApplication.a)
ExternalProject_Get_Property(plog-${PROJECT_NAME} SOURCE_DIR)
set(plog_INCLUDE_DIR "${SOURCE_DIR}/include")
add_dependencies(gpclient SingleApplication-${PROJECT_NAME} plog-${PROJECT_NAME})
target_include_directories(gpclient PRIVATE
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${SingleApplication_INCLUDE_DIR}
${plog_INCLUDE_DIR}
)
target_link_libraries(gpclient
${SingleApplication_LIBRARY}
Qt5::Widgets
Qt5::Network
Qt5::WebSockets
Qt5::WebEngine
Qt5::WebEngineWidgets
Qt5::DBus
)
target_compile_definitions(gpclient PUBLIC QAPPLICATION_CLASS=QApplication)
install(TARGETS gpclient DESTINATION "/usr/bin")
install(FILES com.yuezk.qt.gpclient.desktop DESTINATION "/usr/share/applications")
install(FILES com.yuezk.qt.GPClient.svg DESTINATION "/usr/share/pixmaps")

View File

@@ -1,83 +0,0 @@
TARGET = gpclient
QT += core gui network websockets dbus webenginewidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
include(../singleapplication/singleapplication.pri)
DEFINES += QAPPLICATION_CLASS=QApplication
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
INCLUDEPATH += ../plog/include
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
cdpcommand.cpp \
cdpcommandmanager.cpp \
enhancedwebview.cpp \
gatewayauthenticator.cpp \
gatewayauthenticatorparams.cpp \
gpgateway.cpp \
gphelper.cpp \
loginparams.cpp \
main.cpp \
normalloginwindow.cpp \
portalauthenticator.cpp \
portalconfigresponse.cpp \
preloginresponse.cpp \
samlloginwindow.cpp \
gpclient.cpp \
settingsdialog.cpp
HEADERS += \
cdpcommand.h \
cdpcommandmanager.h \
enhancedwebview.h \
gatewayauthenticator.h \
gatewayauthenticatorparams.h \
gpgateway.h \
gphelper.h \
loginparams.h \
normalloginwindow.h \
portalauthenticator.h \
portalconfigresponse.h \
preloginresponse.h \
samlloginwindow.h \
gpclient.h \
settingsdialog.h
FORMS += \
gpclient.ui \
normalloginwindow.ui \
settingsdialog.ui
DBUS_INTERFACES += ../GPService/gpservice.xml
# Default rules for deployment.
target.path = /usr/bin
INSTALLS += target
DISTFILES += \
com.yuezk.qt.GPClient.svg \
com.yuezk.qt.gpclient.desktop
desktop_entry.path = /usr/share/applications/
desktop_entry.files = com.yuezk.qt.gpclient.desktop
desktop_icon.path = /usr/share/pixmaps/
desktop_icon.files = com.yuezk.qt.GPClient.svg
INSTALLS += desktop_entry desktop_icon
RESOURCES += \
resources.qrc

View File

@@ -1,8 +1,8 @@
#include "cdpcommand.h"
#include <QtCore/QVariantMap>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
#include <QVariantMap>
#include <QJsonDocument>
#include <QJsonObject>
#include "cdpcommand.h"
CDPCommand::CDPCommand(QObject *parent) : QObject(parent)
{

View File

@@ -1,7 +1,7 @@
#ifndef CDPCOMMAND_H
#define CDPCOMMAND_H
#include <QObject>
#include <QtCore/QObject>
class CDPCommand : public QObject
{

View File

@@ -1,7 +1,8 @@
#include "cdpcommandmanager.h"
#include <QVariantMap>
#include <QtCore/QVariantMap>
#include <plog/Log.h>
#include "cdpcommandmanager.h"
CDPCommandManager::CDPCommandManager(QObject *parent)
: QObject(parent)
, networkManager(new QNetworkAccessManager)

View File

@@ -1,11 +1,12 @@
#ifndef CDPCOMMANDMANAGER_H
#define CDPCOMMANDMANAGER_H
#include <QtCore/QObject>
#include <QtCore/QHash>
#include <QtWebSockets/QtWebSockets>
#include <QtNetwork/QNetworkAccessManager>
#include "cdpcommand.h"
#include <QObject>
#include <QHash>
#include <QtWebSockets>
#include <QNetworkAccessManager>
class CDPCommandManager : public QObject
{

View File

@@ -1,9 +1,9 @@
#include <QtCore/QProcessEnvironment>
#include <QtWebEngineWidgets/QWebEngineView>
#include "enhancedwebview.h"
#include "cdpcommandmanager.h"
#include <QtWebEngineWidgets/QWebEngineView>
#include <QProcessEnvironment>
EnhancedWebView::EnhancedWebView(QWidget *parent)
: QWebEngineView(parent)
, cdp(new CDPCommandManager)

View File

@@ -1,9 +1,10 @@
#ifndef ENHANCEDWEBVIEW_H
#define ENHANCEDWEBVIEW_H
#include "cdpcommandmanager.h"
#include <QtWebEngineWidgets/QWebEngineView>
#include "cdpcommandmanager.h"
#define ENV_CDP_PORT "QTWEBENGINE_REMOTE_DEBUGGING"
class EnhancedWebView : public QWebEngineView

View File

@@ -1,11 +1,11 @@
#include <QtNetwork/QNetworkReply>
#include <plog/Log.h>
#include "gatewayauthenticator.h"
#include "gphelper.h"
#include "loginparams.h"
#include "preloginresponse.h"
#include <QNetworkReply>
#include <plog/Log.h>
using namespace gpclient::helper;
GatewayAuthenticator::GatewayAuthenticator(const QString& gateway, const GatewayAuthenticatorParams params)

View File

@@ -1,10 +1,11 @@
#ifndef GATEWAYAUTHENTICATOR_H
#define GATEWAYAUTHENTICATOR_H
#include <QtCore/QObject>
#include "normalloginwindow.h"
#include "loginparams.h"
#include "gatewayauthenticatorparams.h"
#include <QObject>
class GatewayAuthenticator : public QObject
{

View File

@@ -1,7 +1,8 @@
#ifndef GATEWAYAUTHENTICATORPARAMS_H
#define GATEWAYAUTHENTICATORPARAMS_H
#include <QString>
#include <QtCore/QString>
#include "portalconfigresponse.h"
class GatewayAuthenticatorParams

View File

@@ -1,3 +1,6 @@
#include <QtGui/QIcon>
#include <plog/Log.h>
#include "gpclient.h"
#include "gphelper.h"
#include "ui_gpclient.h"
@@ -6,9 +9,6 @@
#include "settingsdialog.h"
#include "gatewayauthenticatorparams.h"
#include <plog/Log.h>
#include <QIcon>
using namespace gpclient::helper;
GPClient::GPClient(QWidget *parent)

View File

@@ -1,15 +1,15 @@
#ifndef GPCLIENT_H
#define GPCLIENT_H
#include "gpservice_interface.h"
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QSystemTrayIcon>
#include <QtWidgets/QMenu>
#include <QtWidgets/QPushButton>
#include "gpserviceinterface.h"
#include "portalconfigresponse.h"
#include "settingsdialog.h"
#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QPushButton>
QT_BEGIN_NAMESPACE
namespace Ui { class GPClient; }
QT_END_NAMESPACE

View File

@@ -1,8 +1,8 @@
#include "gpgateway.h"
#include <QtCore/QJsonObject>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
#include "gpgateway.h"
GPGateway::GPGateway()
{

View File

@@ -1,9 +1,9 @@
#ifndef GPGATEWAY_H
#define GPGATEWAY_H
#include <QString>
#include <QMap>
#include <QJsonObject>
#include <QtCore/QString>
#include <QtCore/QMap>
#include <QtCore/QJsonObject>
class GPGateway
{

View File

@@ -1,14 +1,15 @@
#include "gphelper.h"
#include <QNetworkRequest>
#include <QXmlStreamReader>
#include <QMessageBox>
#include <QDesktopWidget>
#include <QApplication>
#include <QWidget>
#include <QSslConfiguration>
#include <QSslSocket>
#include <QtCore/QXmlStreamReader>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QApplication>
#include <QtWidgets/QWidget>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QSslConfiguration>
#include <QtNetwork/QSslSocket>
#include <plog/Log.h>
#include "gphelper.h"
QNetworkAccessManager* gpclient::helper::networkManager = new QNetworkAccessManager;
QNetworkReply* gpclient::helper::createRequest(QString url, QByteArray params)

View File

@@ -1,16 +1,16 @@
#ifndef GPHELPER_H
#define GPHELPER_H
#include <QtCore/QObject>
#include <QtCore/QUrlQuery>
#include <QtCore/QSettings>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include "samlloginwindow.h"
#include "gpgateway.h"
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QUrlQuery>
#include <QSettings>
const QString UA = "PAN GlobalProtect";

View File

@@ -1,6 +1,6 @@
#include "loginparams.h"
#include <QtCore/QUrlQuery>
#include <QUrlQuery>
#include "loginparams.h"
LoginParams::LoginParams(const QString clientos)
{

View File

@@ -1,7 +1,7 @@
#ifndef LOGINPARAMS_H
#define LOGINPARAMS_H
#include <QUrlQuery>
#include <QtCore/QUrlQuery>
class LoginParams
{

View File

@@ -1,12 +1,14 @@
#include "singleapplication.h"
#include "gpclient.h"
#include "enhancedwebview.h"
#include <QStandardPaths>
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QDir>
#include <QtCore/QStandardPaths>
#include <plog/Log.h>
#include <plog/Appenders/ColorConsoleAppender.h>
static const QString version = "v1.3.3";
#include "singleapplication.h"
#include "gpclient.h"
#include "enhancedwebview.h"
#include "version.h"
int main(int argc, char *argv[])
{
@@ -19,7 +21,7 @@ int main(int argc, char *argv[])
static plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender;
plog::init(plog::debug, logFile.toUtf8()).addAppender(&consoleAppender);
PLOGI << "GlobalProtect started, version: " << version;
PLOGI << "GlobalProtect started, version: " << VERSION;
QString port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));

View File

@@ -1,8 +1,8 @@
#include <QtGui/QCloseEvent>
#include "normalloginwindow.h"
#include "ui_normalloginwindow.h"
#include <QCloseEvent>
NormalLoginWindow::NormalLoginWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::NormalLoginWindow)

View File

@@ -1,7 +1,7 @@
#ifndef PORTALAUTHWINDOW_H
#define PORTALAUTHWINDOW_H
#include <QDialog>
#include <QtWidgets/QDialog>
namespace Ui {
class NormalLoginWindow;

View File

@@ -1,3 +1,6 @@
#include <QtNetwork/QNetworkReply>
#include <plog/Log.h>
#include "portalauthenticator.h"
#include "gphelper.h"
#include "normalloginwindow.h"
@@ -7,9 +10,6 @@
#include "portalconfigresponse.h"
#include "gpgateway.h"
#include <plog/Log.h>
#include <QNetworkReply>
using namespace gpclient::helper;
PortalAuthenticator::PortalAuthenticator(const QString& portal, const QString& clientos) : QObject()

View File

@@ -1,12 +1,13 @@
#ifndef PORTALAUTHENTICATOR_H
#define PORTALAUTHENTICATOR_H
#include <QtCore/QObject>
#include "portalconfigresponse.h"
#include "normalloginwindow.h"
#include "samlloginwindow.h"
#include "preloginresponse.h"
#include <QObject>
class PortalAuthenticator : public QObject
{

View File

@@ -1,8 +1,8 @@
#include "portalconfigresponse.h"
#include <QXmlStreamReader>
#include <QtCore/QXmlStreamReader>
#include <plog/Log.h>
#include "portalconfigresponse.h"
QString PortalConfigResponse::xmlUserAuthCookie = "portal-userauthcookie";
QString PortalConfigResponse::xmlPrelogonUserAuthCookie = "portal-prelogonuserauthcookie";
QString PortalConfigResponse::xmlGateways = "gateways";

View File

@@ -1,11 +1,11 @@
#ifndef PORTALCONFIGRESPONSE_H
#define PORTALCONFIGRESPONSE_H
#include "gpgateway.h"
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtCore/QXmlStreamReader>
#include <QString>
#include <QList>
#include <QXmlStreamReader>
#include "gpgateway.h"
class PortalConfigResponse
{

View File

@@ -1,9 +1,9 @@
#include "preloginresponse.h"
#include <QXmlStreamReader>
#include <QMap>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QMap>
#include <plog/Log.h>
#include "preloginresponse.h"
QString PreloginResponse::xmlAuthMessage = "authentication-message";
QString PreloginResponse::xmlLabelUsername = "username-label";
QString PreloginResponse::xmlLabelPassword = "password-label";

View File

@@ -1,8 +1,8 @@
#ifndef PRELOGINRESPONSE_H
#define PRELOGINRESPONSE_H
#include <QString>
#include <QMap>
#include <QtCore/QString>
#include <QtCore/QMap>
class PreloginResponse
{

View File

@@ -1,9 +1,9 @@
#include "samlloginwindow.h"
#include <QVBoxLayout>
#include <QtWidgets/QVBoxLayout>
#include <QtWebEngineWidgets/QWebEngineProfile>
#include <QtWebEngineWidgets/QWebEngineView>
#include <plog/Log.h>
#include <QWebEngineProfile>
#include <QWebEngineView>
#include "samlloginwindow.h"
SAMLLoginWindow::SAMLLoginWindow(QWidget *parent)
: QDialog(parent)

View File

@@ -1,11 +1,11 @@
#ifndef SAMLLOGINWINDOW_H
#define SAMLLOGINWINDOW_H
#include "enhancedwebview.h"
#include <QtCore/QMap>
#include <QtGui/QCloseEvent>
#include <QtWidgets/QDialog>
#include <QDialog>
#include <QMap>
#include <QCloseEvent>
#include "enhancedwebview.h"
class SAMLLoginWindow : public QDialog
{

View File

@@ -1,7 +1,7 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QDialog>
#include <QtWidgets/QDialog>
namespace Ui {
class SettingsDialog;