diff --git a/.gitignore b/.gitignore index 6c77b7e..4d7464d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ gpservice *.gz .DS_Store build-debian +build # Auto generated DBus files *_adaptor.cpp diff --git a/.gitmodules b/.gitmodules index a95cc4c..9a0c98c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ [submodule "singleapplication"] - path = singleapplication + path = SingleApplication url = https://github.com/itay-grudev/SingleApplication.git [submodule "plog"] diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d5f3cbd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.1.0) + +project(GlobalProtect-openconnect VERSION 1.3.3) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication") + +include(cmake/CPM.cmake) + +find_package(Qt5 REQUIRED COMPONENTS + Core + Widgets + WebSockets + WebEngine + WebEngineWidgets + DBus +) + +CPMAddPackage("gh:itay-grudev/SingleApplication@3.3.0") +CPMAddPackage("gh:SergiusTheBest/plog#1.1.5") + +add_subdirectory(GPService) +add_subdirectory(GPClient) \ No newline at end of file diff --git a/GPClient/CMakeLists.txt b/GPClient/CMakeLists.txt new file mode 100644 index 0000000..024f54d --- /dev/null +++ b/GPClient/CMakeLists.txt @@ -0,0 +1,37 @@ +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_GENERATED_SOURCES} +) + +target_include_directories(gpclient PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(gpclient + plog + SingleApplication + Qt5::Widgets + Qt5::WebSockets + Qt5::WebEngine + Qt5::WebEngineWidgets + Qt5::DBus +) \ No newline at end of file diff --git a/GPClient/gpclient.h b/GPClient/gpclient.h index 45ca86d..b1518e3 100644 --- a/GPClient/gpclient.h +++ b/GPClient/gpclient.h @@ -1,7 +1,7 @@ #ifndef GPCLIENT_H #define GPCLIENT_H -#include "gpservice_interface.h" +#include "gpserviceinterface.h" #include "portalconfigresponse.h" #include "settingsdialog.h" diff --git a/GPService/CMakeLists.txt b/GPService/CMakeLists.txt new file mode 100644 index 0000000..089ebb1 --- /dev/null +++ b/GPService/CMakeLists.txt @@ -0,0 +1,29 @@ +project(gpservice) + +set(gpservice_GENERATED_SOURCES) + +# generate the dbus xml definition +qt5_generate_dbus_interface(gpservice.h ${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml) + +# generate dbus adaptor +qt5_add_dbus_adaptor( + gpservice_GENERATED_SOURCES + ${CMAKE_BINARY_DIR}/com.yuezk.qt.GPService.xml + gpservice.h + GPService +) + +add_executable(gpservice + gpservice.cpp + main.cpp + sigwatch.cpp + ${gpservice_GENERATED_SOURCES} +) + +target_include_directories(gpservice PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(gpservice + SingleApplication + Qt5::Core + Qt5::DBus +) diff --git a/GPService/gpservice.cpp b/GPService/gpservice.cpp index 04d018f..54acb44 100644 --- a/GPService/gpservice.cpp +++ b/GPService/gpservice.cpp @@ -1,5 +1,5 @@ #include "gpservice.h" -#include "gpservice_adaptor.h" +#include "gpserviceadaptor.h" #include #include diff --git a/GPService/gpservice.h b/GPService/gpservice.h index 63c4e5a..146d032 100644 --- a/GPService/gpservice.h +++ b/GPService/gpservice.h @@ -21,6 +21,8 @@ public: explicit GPService(QObject *parent = nullptr); ~GPService(); + void quit(); + enum VpnStatus { VpnNotConnected, VpnConnecting, @@ -38,7 +40,6 @@ public slots: void connect(QString server, QString username, QString passwd, QString extraArgs); void disconnect(); int status(); - void quit(); private slots: void onProcessStarted(); diff --git a/singleapplication b/SingleApplication similarity index 100% rename from singleapplication rename to SingleApplication diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake new file mode 100644 index 0000000..ed335e6 --- /dev/null +++ b/cmake/CPM.cmake @@ -0,0 +1,21 @@ +set(CPM_DOWNLOAD_VERSION 0.32.3) + +if(CPM_SOURCE_CACHE) + # Expand relative path. This is important if the provided path contains a tilde (~) + get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE) + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else() + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif() + +if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file(DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) +endif() + +include(${CPM_DOWNLOAD_LOCATION})