diff --git a/.clang-format b/.clang-format index a792fee3..e400fea6 100644 --- a/.clang-format +++ b/.clang-format @@ -5,7 +5,7 @@ AccessModifierOffset: -4 AlignAfterOpenBracket: DontAlign AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false -AlignEscapedNewlinesLeft: false +AlignEscapedNewlines: Right AlignOperands: false AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: true @@ -29,17 +29,24 @@ BraceWrapping: AfterObjCDeclaration: false AfterStruct: false AfterUnion: false + AfterExternBlock: false BeforeCatch: false BeforeElse: false IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true BreakBeforeBinaryOperators: All BreakBeforeBraces: WebKit +BreakBeforeInheritanceComma: false BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true ColumnLimit: 0 CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 @@ -47,17 +54,25 @@ Cpp11BracedListStyle: false DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - - Regex: '^(<|"(gtest|isl|json)/)' + - Regex: '^(<|"(gtest|gmock|isl|json)/)' Priority: 3 - Regex: '.*' Priority: 1 +IncludeIsMainRegex: '(Test)?$' IndentCaseLabels: false +IndentPPDirectives: None IndentWidth: 4 IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: true MacroBlockBegin: '' MacroBlockEnd: '' @@ -66,6 +81,7 @@ NamespaceIndentation: Inner ObjCBlockIndentWidth: 4 ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 @@ -73,9 +89,15 @@ PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left +RawStringFormats: + - Delimiter: pb + Language: TextProto + BasedOnStyle: google ReflowComments: true SortIncludes: true +SortUsingDeclarations: true SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false @@ -85,9 +107,8 @@ SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Cpp03 -TabWidth: 8 +Standard: Cpp11 +TabWidth: 4 UseTab: Never -JavaScriptQuotes: Leave ... diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index c8259ca6..1a250bfb 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -37,4 +37,10 @@ possible. Thank you! ### Other Information - + diff --git a/.gitignore b/.gitignore index 94c11c06..221b1678 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ build-release*/ # temporary... _xxx/ *.zip +*.exe diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..8c0b08cf --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Nikos Mavrogiannopoulos (author) +Ľubomír Carik (current maintainer) + +Thanks to all Contributors diff --git a/CHANGELOG.md b/CHANGELOG.md index 39996160..fdf9f991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,22 @@ History of user-visible changes. -## [v1.5.3](https://github.com/openconnect/openconnect-gui/tree/v1.5.3) (unreleased) +## [v1.5.4](https://github.com/openconnect/openconnect-gui/tree/v1.5.4) (unreleased) - TBD +[Full Changelog](https://github.com/openconnect/openconnect-gui/compare/v1.5.3...develop) + + +## [v1.5.3](https://github.com/openconnect/openconnect-gui/tree/v1.5.3) (2018-03-25) +- Don't lose password in batch mode and keys from storage (resolve #220, #142, #144) +- No disconnection triggered before quit (#202) +- Don't use system wide defined proxy when disabled in profile (#208) +- Unable to use socks5 proxy built by ssh tunneling (#187) +- Invalid routes (#190) +- macOS tray icons improved for dark/light dock panel (#192) + +- update Qt(5.10.1), spdlog(0.16.3) +- update (msys2): GnuTLS(3.6.1), p11-kit(0.23.9), stoken(0.92), libproxy(0.4.15), nettle(3.4), lz4(1.8.1.2), libxml2(2.9.7), libidn2(2.0.4) + [Full Changelog](https://github.com/openconnect/openconnect-gui/compare/v1.5.2...v1.5.3) diff --git a/CMake/Includes/CMakeLists_qt-solutions.cmake.in b/CMake/Includes/CMakeLists_qt-solutions.cmake.in index edb29917..2959185a 100644 --- a/CMake/Includes/CMakeLists_qt-solutions.cmake.in +++ b/CMake/Includes/CMakeLists_qt-solutions.cmake.in @@ -11,7 +11,7 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -find_package(Qt5 5.6 REQUIRED COMPONENTS Core Gui Widgets Network) +find_package(Qt5 5.10 REQUIRED COMPONENTS Core Gui Widgets Network) add_definitions(-DUNICODE) add_library(qtsingleapplication STATIC @@ -39,4 +39,4 @@ install( qtsingleapplication/src/QtLockedFile qtsingleapplication/src/QtSingleApplication DESTINATION include -) \ No newline at end of file +) diff --git a/CMake/Includes/ProjectDependencies.cmake b/CMake/Includes/ProjectDependencies.cmake index f29bf456..1ee14fbf 100644 --- a/CMake/Includes/ProjectDependencies.cmake +++ b/CMake/Includes/ProjectDependencies.cmake @@ -3,12 +3,18 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -find_package(Qt5 5.6 REQUIRED COMPONENTS Core Gui Widgets Network) +find_package(Qt5 5.10 REQUIRED COMPONENTS Core Gui Widgets Network) if(MINGW) get_target_property(_qwindows_dll Qt5::QWindowsIntegrationPlugin LOCATION) + if(NOT Qt5Core_VERSION STRLESS "5.10") + get_target_property(_qwinstyle_dylib Qt5::QWindowsVistaStylePlugin LOCATION) + endif() endif() if(APPLE) get_target_property(_qcocoa_dylib Qt5::QCocoaIntegrationPlugin LOCATION) + if(NOT Qt5Core_VERSION STRLESS "5.10") + get_target_property(_qmacstyle_dylib Qt5::QMacStylePlugin LOCATION) + endif() endif() # macOS & GNU/Linux dependencies diff --git a/CMake/Includes/ProjectExternals.cmake b/CMake/Includes/ProjectExternals.cmake index 4700e9a8..5f016c38 100644 --- a/CMake/Includes/ProjectExternals.cmake +++ b/CMake/Includes/ProjectExternals.cmake @@ -1,6 +1,6 @@ set(openconnect-TAG v7.08) set(vpnc-scripts-TAG master) -set(spdlog-TAG v0.13.0) +set(spdlog-TAG v0.16.3) set(qt-solutions-TAG master) set(tap-driver-TAG 9.21.2) diff --git a/CMake/Includes/ProjectExternals_openconnect.cmake b/CMake/Includes/ProjectExternals_openconnect.cmake index 38c33be4..611db69b 100644 --- a/CMake/Includes/ProjectExternals_openconnect.cmake +++ b/CMake/Includes/ProjectExternals_openconnect.cmake @@ -1,10 +1,16 @@ +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(MINGW_VARIANT mingw64) +else() + set(MINGW_VARIANT mingw32) +endif() + # -------------------------------------------------------------------------------------------------- # openconnect (libs, headers, etc.) # -------------------------------------------------------------------------------------------------- -if(NOT EXISTS ${CMAKE_SOURCE_DIR}/external/openconnect-devel-${openconnect-TAG}_mingw32.zip) +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/external/openconnect-devel-${openconnect-TAG}_${MINGW_VARIANT}.zip) set(OPENCONNECT_DEV_URL https://github.com/horar/openconnect/releases/download/${openconnect-TAG}) else() - message(STATUS "Using local openconnect-devel packages...") + message(STATUS "Using local openconnect-devel packages... (${MINGW_VARIANT})") set(OPENCONNECT_DEV_URL ${CMAKE_SOURCE_DIR}/external) endif() @@ -14,7 +20,7 @@ ExternalProject_Add(openconnect-devel-${openconnect-TAG} DOWNLOAD_NO_PROGRESS 1 - URL ${OPENCONNECT_DEV_URL}/openconnect-devel-${openconnect-TAG}_mingw32.zip + URL ${OPENCONNECT_DEV_URL}/openconnect-devel-${openconnect-TAG}_${MINGW_VARIANT}.zip CONFIGURE_COMMAND "" BUILD_COMMAND "" @@ -37,10 +43,10 @@ ExternalProject_Add_Step(openconnect-devel-${openconnect-TAG} deploy_libraries # -------------------------------------------------------------------------------------------------- # openconnect (util & libs) # -------------------------------------------------------------------------------------------------- -if(NOT EXISTS ${CMAKE_SOURCE_DIR}/external/openconnect-${openconnect-TAG}_mingw32.zip) +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/external/openconnect-${openconnect-TAG}_${MINGW_VARIANT}.zip) set(OPENCONNECT_URL https://github.com/horar/openconnect/releases/download/${openconnect-TAG}) else() - message(STATUS "Using local openconnect-devel packages...") + message(STATUS "Using local openconnect packages... ${MINGW_VARIANT}") set(OPENCONNECT_URL ${CMAKE_SOURCE_DIR}/external) endif() @@ -50,7 +56,7 @@ ExternalProject_Add(openconnect-${openconnect-TAG} DOWNLOAD_NO_PROGRESS 1 - URL ${OPENCONNECT_URL}/openconnect-${openconnect-TAG}_mingw32.zip + URL ${OPENCONNECT_URL}/openconnect-${openconnect-TAG}_${MINGW_VARIANT}.zip CONFIGURE_COMMAND "" BUILD_COMMAND "" @@ -99,7 +105,10 @@ set_property(TARGET openconnect::xml2 PROPERTY IMPORTED_LOCATION ${CMAKE_BINARY_ set_property(TARGET openconnect::xml2 PROPERTY IMPORTED_IMPLIB ${CMAKE_BINARY_DIR}/external/lib/libxml2.dll.a) -install(FILES ${CMAKE_BINARY_DIR}/external/lib/openconnect.exe +install( + FILES + ${CMAKE_BINARY_DIR}/external/lib/openconnect.exe + ${CMAKE_BINARY_DIR}/external/lib/vpnc-script-win.js DESTINATION . COMPONENT App_Console ) diff --git a/CMake/Includes/ProjectExternals_qt-solutions.cmake b/CMake/Includes/ProjectExternals_qt-solutions.cmake index cf60b478..ed636d0d 100644 --- a/CMake/Includes/ProjectExternals_qt-solutions.cmake +++ b/CMake/Includes/ProjectExternals_qt-solutions.cmake @@ -19,6 +19,10 @@ ExternalProject_Add(qt-solutions-${qt-solutions-TAG} ${CMAKE_SOURCE_DIR}/CMake/Includes/CMakeLists_qt-solutions.cmake.in ${CMAKE_BINARY_DIR}/external/src/qt-solutions-master/CMakeLists.txt CMAKE_COMMAND ${CMAKE_CROSS_COMMAND} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + + # Note: ninja-1.8.2 & cmake-3.10.2 failed in find/install this dependency wo next 2 lines :( + BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/external/lib/libqtsingleapplication.a + INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install ) add_library(qt-solutions::qtsingleapplication STATIC IMPORTED) @@ -26,3 +30,6 @@ set_target_properties(qt-solutions::qtsingleapplication PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/external/include" IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/external/lib/libqtsingleapplication.a ) +set_property(TARGET qt-solutions::qtsingleapplication PROPERTY + DEPENDS qt-solutions-${qt-solutions-TAG} +) diff --git a/CMake/Includes/ProjectExternals_spdlog.cmake b/CMake/Includes/ProjectExternals_spdlog.cmake index 2374838a..daa188f7 100644 --- a/CMake/Includes/ProjectExternals_spdlog.cmake +++ b/CMake/Includes/ProjectExternals_spdlog.cmake @@ -13,7 +13,7 @@ ExternalProject_Add(spdlog-${spdlog-TAG} GIT_TAG ${spdlog-TAG} GIT_SHALLOW 1 - CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_TESTING=off -DSPDLOG_BUILD_TESTING=off + CMAKE_ARGS "${CMAKE_ARGS};-DCMAKE_BUILD_TYPE=Release;-DCMAKE_INSTALL_PREFIX:PATH=;-DBUILD_TESTING=off;-DSPDLOG_BUILD_TESTING=off" CMAKE_COMMAND ${CMAKE_CROSS_COMMAND} ) @@ -21,3 +21,4 @@ add_library(spdlog::spdlog INTERFACE IMPORTED) set_target_properties(spdlog::spdlog PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/external/include" ) +add_dependencies(spdlog::spdlog DEPENDS spdlog-${spdlog-TAG}) diff --git a/CMake/Includes/ProjectPackage.cmake b/CMake/Includes/ProjectPackage.cmake index 107c09a5..7bf7117e 100644 --- a/CMake/Includes/ProjectPackage.cmake +++ b/CMake/Includes/ProjectPackage.cmake @@ -13,6 +13,7 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PRODUCT_NAME_SHORT}") if(APPLE) set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/mono_lock.icns) endif() +set(CPACK_PACKAGE_CHECKSUM SHA512) set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt) #set(CPACK_RESOURCE_FILE_README ...) #set(CPACK_RESOURCE_FILE_WELCOME ...) @@ -51,7 +52,7 @@ if(WIN32 AND MINGW) set(CPACK_COMPONENTS_ALL App App_Console vpnc_script TAP_drivers VcRedist_libs) set(CPACK_COMPONENT_APP_REQUIRED on) - set(CPACK_COMPONENT_APP_DISPLAY_NAME "${PRODUCT_NAME_SHORT}") + set(CPACK_COMPONENT_APP_DISPLAY_NAME "GUI") set(CPACK_COMPONENT_APP_DESCRIPTION "${PRODUCT_NAME_LONG} GUI") set(CPACK_COMPONENT_APP_GROUP "Application") set(CPACK_COMPONENT_APP_INSTALL_TYPES Full AppOnly Standard) @@ -77,7 +78,7 @@ if(WIN32 AND MINGW) set(CPACK_COMPONENT_APP_CONSOLE_DISABLED on) set(CPACK_COMPONENT_APP_CONSOLE_REQUIRED off) - set(CPACK_COMPONENT_APP_CONSOLE_DISPLAY_NAME "${PRODUCT_NAME_SHORT}") + set(CPACK_COMPONENT_APP_CONSOLE_DISPLAY_NAME "console") set(CPACK_COMPONENT_APP_CONSOLE_DESCRIPTION "${PRODUCT_NAME_LONG} (console)") set(CPACK_COMPONENT_APP_CONSOLE_GROUP "Application") set(CPACK_COMPONENT_APP_CONSOLE_INSTALL_TYPES Full) diff --git a/CMake/Includes/ProjectSettings.cmake b/CMake/Includes/ProjectSettings.cmake index 0235a0b4..ec8a56bd 100644 --- a/CMake/Includes/ProjectSettings.cmake +++ b/CMake/Includes/ProjectSettings.cmake @@ -11,6 +11,8 @@ endif() option(PROJ_PKCS11 "Enable PKCS11" ON) option(PROJ_INI_SETTINGS "Store the settings in INI files." OFF) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/CMakeLists.txt b/CMakeLists.txt index 185eaa2a..b61ebb1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,17 @@ -cmake_minimum_required(VERSION 3.5 FATAL_ERROR) +cmake_minimum_required(VERSION 3.10 FATAL_ERROR) if(APPLE) if(NOT CMAKE_OSX_SYSROOT) - set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk" CACHE STRING "" FORCE) + set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" CACHE STRING "" FORCE) endif() if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "" FORCE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "" FORCE) endif() endif() project(openconnect-gui - VERSION 1.5.2 + VERSION 1.5.3 LANGUAGES CXX ) @@ -21,8 +21,8 @@ set(PRODUCT_NAME_SHORT "OpenConnect-GUI") set(PRODUCT_NAME_LONG "OpenConnect-GUI VPN client") set(PRODUCT_NAME_COMPANY "OpenConnect-GUI Team") set(PRODUCT_NAME_COMPANY_DOMAIN "openconnect.github.io") -set(PRODUCT_NAME_COPYRIGHT_SHORT "Copyright (C) 2016-2017 OpenConnect-GUI Team") -set(PRODUCT_NAME_COPYRIGHT_FULL "Copyright (C) 2014-2015 Red Hat Inc.
Copyright (C) 2016-2017 OpenConnect-GUI Team") +set(PRODUCT_NAME_COPYRIGHT_SHORT "Copyright (C) 2016-2018 OpenConnect-GUI Team") +set(PRODUCT_NAME_COPYRIGHT_FULL "Copyright (C) 2014-2015 Red Hat Inc.
${PRODUCT_NAME_COPYRIGHT_SHORT}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/Modules/") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/Includes/") diff --git a/README.md b/README.md index 983755fa..5845b515 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # OpenConnect GUI [![Last Release:](https://img.shields.io/github/release/openconnect/openconnect-gui.svg)](https://github.com/openconnect/openconnect-gui/releases) +[![Downloades](https://img.shields.io/github/downloads/openconnect/openconnect-gui/latest/total.svg)](https://github.com/openconnect/openconnect-gui/releases) [![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://img.shields.io/badge/License-GPL%20v2-blue.svg) [![Join the chat at https://gitter.im/openconnect-gui/Lobby](https://badges.gitter.im/openconnect-gui/Lobby.svg)](https://gitter.im/openconnect-gui/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Build Status](https://travis-ci.org/openconnect/openconnect-gui.svg?branch=master)](https://travis-ci.org/openconnect/openconnect-gui) +[![Build status](https://ci.appveyor.com/api/projects/status/hueumkrrgut9r3d7?svg=true)](https://ci.appveyor.com/project/horar/openconnect-gui) This is the GUI client for openconnect VPN. This client is in beta testing phase. It cannot be assumed to provide @@ -21,6 +22,10 @@ Look to [OpenConnect-GUI](http://openconnect.github.io/openconnect-gui/) project - [OpenConnect library compilation and dependencies](docs/openconnect.md) - [Web page maintenance](docs/webpage.md) +If you are brave and you would like to try [upcoming development snapshots](https://goo.gl/P88mTi) of OpenConnect-GUI or [OpenConnect](https://www.infradead.org/openconnect/) for Windows. (I'm not developer on second mentioned project, but this GUI is based on this great project). + +These are unofficial builds, without warranty, please don't complain... ;-) + # License The content of this project itself is licensed under the [GNU General Public License v2](LICENSE.txt) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..54d043dc --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,57 @@ +version: '{branch}-{build}' +pull_requests: + do_not_increment_build_number: true +branches: + except: + - gh-pages +image: Visual Studio 2017 +clone_depth: 100 +environment: + QT5: C:\Qt\5.10.1\mingw53_32 + MINGW: C:\Qt\Tools\mingw530_32 + NSIS: C:\Program Files (x86)\NSIS + matrix: +# - GENERATOR: '"MinGW Makefiles"' +# BUILD_TYPE: Debug +# TARGET: all + - GENERATOR: '"MinGW Makefiles"' + BUILD_TYPE: Release + TARGET: package +cache: .\build -> appveyor.yml +build_script: +- cmd: >- + set + + set PATH=%PATH:C:\Program Files\Git\usr\bin;=% + + set PATH=%MINGW%\bin;%QT5%\bin;%PATH% + + set PATH="%NSIS%";%PATH% + + if not exist build md build + + cd .\build + + cmake -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% .. + + cmake --build . --config %BUILD_TYPE% --target %TARGET% + +test: off +artifacts: +- path: build\openconnect-gui*.exe + name: 'Installer' +- path: build\openconnect-gui*.exe.sha512 + name: 'Installer - sha512 hash' +deploy: +- provider: GitHub + tag: $(APPVEYOR_REPO_TAG_NAME) + release: $(APPVEYOR_REPO_TAG_NAME) + description: TBD... + auth_token: + secure: x7ZSG2iQyNioIlyguchg7/Tzl5NzY521hr8Op0H4EQt/kPIndb2KHe/OlGiX+GSK + artifact: /build\/openconnect-gui-.*\.exe.*/ + draft: true + force_update: true + on: + appveyor_repo_tag: true + diff --git a/contrib/.gitignore b/contrib/.gitignore new file mode 100644 index 00000000..260c1054 --- /dev/null +++ b/contrib/.gitignore @@ -0,0 +1,3 @@ +/work/ +/*.txt +/*.sha512 diff --git a/contrib/build_mingw-openconnect-w32@fedora26.sh b/contrib/build_mingw-openconnect-w32@fedora27.sh old mode 100644 new mode 100755 similarity index 79% rename from contrib/build_mingw-openconnect-w32@fedora26.sh rename to contrib/build_mingw-openconnect-w32@fedora27.sh index 0e69ee56..09fee115 --- a/contrib/build_mingw-openconnect-w32@fedora26.sh +++ b/contrib/build_mingw-openconnect-w32@fedora27.sh @@ -4,23 +4,31 @@ # export OC_TAG=v7.08 -export STOKEN_TAG=v0.91 +export STOKEN_TAG=v0.92 -dnf -y install mingw32-gnutls mingw32-libxml2 mingw32-gettext -dnf -y install gcc libtool -dnf -y install gettext -dnf -y install git p7zip +dnf -y install \ + mingw32-gnutls \ + mingw32-libxml2 \ + mingw32-gettext +dnf -y install \ + gcc \ + libtool \ + gettext \ + git \ + p7zip -mkdir work + +[ -d work ] || mkdir work cd work -git clone https://github.com/cernekee/stoken +[ -d stoken ] || git clone https://github.com/cernekee/stoken cd stoken git checkout ${STOKEN_TAG} ./autogen.sh -mkdir build32 +[ -d build32 ] || mkdir build32 cd build32 -mingw32-configure +git clean -fdx +mingw32-configure --disable-dependency-tracking --without-tomcrypt --without-gtk mingw32-make -j4 mingw32-make install cd ../../ @@ -30,9 +38,10 @@ cd openconnect git reset --hard git checkout ${OC_TAG} ./autogen.sh -mkdir build32 +[ -d build32 ] || mkdir build32 cd build32 -mingw32-configure --with-vpnc-script=vpnc-script.js +git clean -fdx +mingw32-configure --disable-dependency-tracking --with-gnutls --without-openssl --without-libpskc --with-vpnc-script=vpnc-script-win.js mingw32-make -j4 cd ../../ @@ -62,6 +71,7 @@ cp ${MINGW_PREFIX}/bin/zlib1.dll . cp ${MINGW_PREFIX}/bin/libstoken-1.dll . cp ../../openconnect/build32/.libs/libopenconnect-5.dll . cp ../../openconnect/build32/.libs/openconnect.exe . +curl -v -o vpnc-script-win.js http://git.infradead.org/users/dwmw2/vpnc-scripts.git/blob_plain/HEAD:/vpnc-script-win.js cd ../../ mkdir -p pkg/lib && cd pkg/lib @@ -113,6 +123,8 @@ cd ../ echo "List of system-wide used packages versions:" \ > openconnect-${OC_TAG}_mingw32.txt +echo "openconnect-${OC_TAG}" \ + >> openconnect-${OC_TAG}_mingw32.txt echo "stoken-${STOKEN_TAG}" \ >> openconnect-${OC_TAG}_mingw32.txt rpm -qv \ @@ -122,4 +134,6 @@ rpm -qv \ mingw32-p11-kit \ mingw32-zlib \ mingw32-libxml2 \ - >> openconnect-${OC_TAG}_mingw32.txt + >> openconnect-${OC_TAG}_mingw32.txt + +mv -v openconnect-*.zip openconnect-*.txt .. diff --git a/contrib/build_mingw-openconnect-w32@msys2.sh b/contrib/build_mingw-openconnect-w32@msys2.sh new file mode 100755 index 00000000..3e4b1b4b --- /dev/null +++ b/contrib/build_mingw-openconnect-w32@msys2.sh @@ -0,0 +1,167 @@ +# +# Sample script to checkout & build 'openconnect' project +# with mingw32 on MSYS2 toolchain +# + +[ "$MSYSTEM" != "MINGW32" ] && exit -1 +echo "Starting under MINGW32 build environment..." + +export OC_TAG=v7.08 +export STOKEN_TAG=v0.92 + +pacman --needed -S \ + mingw-w64-i686-gnutls \ + mingw-w64-i686-libidn2 \ + mingw-w64-i686-libunistring \ + mingw-w64-i686-nettle \ + mingw-w64-i686-gmp \ + mingw-w64-i686-p11-kit \ + mingw-w64-i686-zlib \ + mingw-w64-i686-libxml2 \ + mingw-w64-i686-zlib \ + mingw-w64-i686-libxml2 \ + mingw-w64-i686-lz4 \ + mingw-w64-i686-libproxy + + +[ -d work ] || mkdir work +cd work + +[ -d stoken ] || git clone https://github.com/cernekee/stoken +cd stoken +git checkout ${STOKEN_TAG} +./autogen.sh +[ -d build32 ] || mkdir build32 +cd build32 +git clean -fdx +../configure --disable-dependency-tracking --without-tomcrypt --without-gtk +mingw32-make -j4 +mingw32-make install +cd ../../ + +[ -d openconnect ] || git clone git://git.infradead.org/users/dwmw2/openconnect.git +cd openconnect +git reset --hard +git checkout ${OC_TAG} +./autogen.sh +[ -d build32 ] || mkdir build32 +cd build32 +git clean -fdx +../configure --disable-dependency-tracking --with-gnutls --without-openssl --without-libpskc --with-vpnc-script=vpnc-script-win.js +mingw32-make -j4 +cd ../../ + + +# +# Sample script to create a package from build 'openconnect' project +# incl. all dependencies (hardcoded paths!) +# + +export MINGW_PREFIX=/mingw32 + +rm -rf pkg +mkdir -p pkg/nsis && cd pkg/nsis +#cp ${MINGW_PREFIX}/bin/iconv.dll . +cp ${MINGW_PREFIX}/bin/libffi-6.dll . +cp ${MINGW_PREFIX}/bin/libgcc_*-1.dll . +cp ${MINGW_PREFIX}/bin/libgmp-10.dll . +cp ${MINGW_PREFIX}/bin/libgnutls-30.dll . +cp ${MINGW_PREFIX}/bin/libhogweed-4.dll . +cp ${MINGW_PREFIX}/bin/libintl-8.dll . +cp ${MINGW_PREFIX}/bin/libnettle-6.dll . +cp ${MINGW_PREFIX}/bin/libp11-kit-0.dll . +cp ${MINGW_PREFIX}/bin/libtasn1-6.dll . +cp ${MINGW_PREFIX}/bin/libwinpthread-1.dll . +cp ${MINGW_PREFIX}/bin/libxml2-2.dll . +cp ${MINGW_PREFIX}/bin/zlib1.dll . +cp ${MINGW_PREFIX}/bin/libstoken-1.dll . +cp ${MINGW_PREFIX}/bin/libproxy-1.dll . +cp ${MINGW_PREFIX}/bin/liblz4.dll . +cp ${MINGW_PREFIX}/bin/libiconv-2.dll . +cp ${MINGW_PREFIX}/bin/libunistring-2.dll . +cp ${MINGW_PREFIX}/bin/libidn2-0.dll . +cp ${MINGW_PREFIX}/bin/libstdc++-6.dll . +cp ${MINGW_PREFIX}/bin/liblzma-5.dll . +cp ../../openconnect/build32/.libs/libopenconnect-5.dll . +cp ../../openconnect/build32/.libs/openconnect.exe . +curl -v -o vpnc-script-win.js http://git.infradead.org/users/dwmw2/vpnc-scripts.git/blob_plain/HEAD:/vpnc-script-win.js +cd ../../ + +mkdir -p pkg/lib && cd pkg/lib +cp ${MINGW_PREFIX}/lib/libgmp.dll.a . +cp ${MINGW_PREFIX}/lib/libgnutls.dll.a . +cp ${MINGW_PREFIX}/lib/libhogweed.dll.a . +cp ${MINGW_PREFIX}/lib/libnettle.dll.a . +cp ${MINGW_PREFIX}/lib/libp11-kit.dll.a . +cp ${MINGW_PREFIX}/lib/libxml2.dll.a . +cp ${MINGW_PREFIX}/lib/libz.dll.a . +cp ${MINGW_PREFIX}/lib/libstoken.dll.a . +cp ${MINGW_PREFIX}/lib/libproxy.dll.a . +cp ${MINGW_PREFIX}/lib/liblz4.dll.a . +cp ${MINGW_PREFIX}/lib/libiconv.dll.a . +cp ${MINGW_PREFIX}/lib/libunistring.dll.a . +cp ${MINGW_PREFIX}/lib/libidn2.dll.a . +cp ${MINGW_PREFIX}/lib/liblzma.dll.a . +cp ../../openconnect/build32/.libs/libopenconnect.dll.a . +cd ../../ + +mkdir -p pkg/lib/pkgconfig && cd pkg/lib/pkgconfig +cp ${MINGW_PREFIX}/lib/pkgconfig/gnutls.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/hogweed.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/libxml-2.0.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/nettle.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/zlib.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/stoken.pc . +cp ../../../openconnect/build32/openconnect.pc . +cd ../../../ + +mkdir -p pkg/include && cd pkg/include +cp -R ${MINGW_PREFIX}/include/gnutls/ . +cp -R ${MINGW_PREFIX}/include/libxml2/ . +cp -R ${MINGW_PREFIX}/include/nettle/ . +cp -R ${MINGW_PREFIX}/include/p11-kit-1/p11-kit/ . +cp ${MINGW_PREFIX}/include/gmp.h . +cp ${MINGW_PREFIX}/include/zconf.h . +cp ${MINGW_PREFIX}/include/zlib.h . +cp ${MINGW_PREFIX}/include/stoken.h . +cp ../../openconnect/openconnect.h . +cd ../../ + +export MINGW_PREFIX= + +cd pkg/nsis +7za a -tzip -mx=9 -sdel ../../openconnect-${OC_TAG}_mingw32.zip * +cd ../ +rmdir -v nsis +7za a -tzip -mx=9 -sdel ../openconnect-devel-${OC_TAG}_mingw32.zip * +cd ../ +rmdir -v pkg + + +#cd stoken/build32 +#sudo mingw32-make uninstall + +echo "List of system-wide used packages versions:" \ + > openconnect-${OC_TAG}_mingw32.txt +echo "openconnect-${OC_TAG}" \ + >> openconnect-${OC_TAG}_mingw32.txt +echo "stoken-${STOKEN_TAG}" \ + >> openconnect-${OC_TAG}_mingw32.txt +pacman -Q \ + mingw-w64-i686-gnutls \ + mingw-w64-i686-libidn2 \ + mingw-w64-i686-libunistring \ + mingw-w64-i686-nettle \ + mingw-w64-i686-gmp \ + mingw-w64-i686-p11-kit \ + mingw-w64-i686-libxml2 \ + mingw-w64-i686-zlib \ + mingw-w64-i686-libxml2 \ + mingw-w64-i686-lz4 \ + mingw-w64-i686-libproxy \ + >> openconnect-${OC_TAG}_mingw32.txt + +sha512sum.exe openconnect-${OC_TAG}_mingw32.zip > openconnect-${OC_TAG}_mingw32.zip.sha512 +sha512sum.exe openconnect-devel-${OC_TAG}_mingw32.zip > openconnect-devel-${OC_TAG}_mingw32.zip.sha512 + +mv -v openconnect-*.zip openconnect-*.txt openconnect-*.zip.sha512 .. diff --git a/contrib/build_mingw-openconnect-w64@fedora26.sh b/contrib/build_mingw-openconnect-w64@fedora27.sh old mode 100644 new mode 100755 similarity index 78% rename from contrib/build_mingw-openconnect-w64@fedora26.sh rename to contrib/build_mingw-openconnect-w64@fedora27.sh index a443951c..15aeda77 --- a/contrib/build_mingw-openconnect-w64@fedora26.sh +++ b/contrib/build_mingw-openconnect-w64@fedora27.sh @@ -4,24 +4,32 @@ # export OC_TAG=v7.08 -export STOKEN_TAG=v0.91 - -dnf -y install mingw64-gnutls mingw64-libxml2 mingw64-gettext -dnf -y install gcc libtool -dnf -y install gettext -dnf -y install git p7zip -dnf -y install patch - -mkdir work +export STOKEN_TAG=v0.92 + +dnf -y install \ + mingw64-gnutls \ + mingw64-libxml2 \ + mingw64-gettext +dnf -y install \ + gcc \ + libtool \ + gettext \ + git \ + p7zip \ + patch + + +[ -d work ] || mkdir work cd work -git clone https://github.com/cernekee/stoken +[ -d stoken ] || git clone https://github.com/cernekee/stoken cd stoken git checkout ${STOKEN_TAG} ./autogen.sh -mkdir build64 +[ -d build64 ] || mkdir build64 cd build64 -mingw64-configure +git clean -fdx +mingw64-configure --disable-dependency-tracking --without-tomcrypt --without-gtk mingw64-make -j4 mingw64-make install cd ../../ @@ -31,10 +39,10 @@ cd openconnect git reset --hard git checkout ${OC_TAG} ./autogen.sh - -mkdir build64 +[ -d build64 ] || mkdir build64 cd build64 -mingw64-configure --with-vpnc-script=vpnc-script.js +git clean -fdx +mingw64-configure --disable-dependency-tracking --with-gnutls --without-openssl --without-libpskc --with-vpnc-script=vpnc-script-win.js mingw64-make -j4 cd ../../ @@ -64,6 +72,7 @@ cp ${MINGW_PREFIX}/bin/zlib1.dll . cp ${MINGW_PREFIX}/bin/libstoken-1.dll . cp ../../openconnect/build64/.libs/libopenconnect-5.dll . cp ../../openconnect/build64/.libs/openconnect.exe . +curl -v -o vpnc-script-win.js http://git.infradead.org/users/dwmw2/vpnc-scripts.git/blob_plain/HEAD:/vpnc-script-win.js cd ../../ mkdir -p pkg/lib && cd pkg/lib @@ -115,8 +124,10 @@ cd ../ echo "List of system-wide used packages versions:" \ > openconnect-${OC_TAG}_mingw64.txt +echo "openconnect-${OC_TAG}" \ + >> openconnect-${OC_TAG}_mingw64.txt echo "stoken-${STOKEN_TAG}" \ - >> openconnect-${OC_TAG}_mingw32.txt + >> openconnect-${OC_TAG}_mingw64.txt rpm -qv \ mingw64-gnutls \ mingw64-gmp \ @@ -124,4 +135,6 @@ rpm -qv \ mingw64-p11-kit \ mingw64-zlib \ mingw64-libxml2 \ - >> openconnect-${OC_TAG}_mingw64.txt + >> openconnect-${OC_TAG}_mingw64.txt + +mv -v openconnect-*.zip openconnect-*.txt .. diff --git a/contrib/build_mingw-openconnect-w64@msys2.sh b/contrib/build_mingw-openconnect-w64@msys2.sh new file mode 100755 index 00000000..e817350d --- /dev/null +++ b/contrib/build_mingw-openconnect-w64@msys2.sh @@ -0,0 +1,167 @@ +# +# Sample script to checkout & build 'openconnect' project +# with mingw64 on MSYS2 toolchain +# + +[ "$MSYSTEM" != "MINGW64" ] && exit -1 +echo "Starting under MINGW64 build environment..." + +export OC_TAG=v7.08 +export STOKEN_TAG=v0.92 + +pacman --needed -S \ + mingw-w64-x86_64-gnutls \ + mingw-w64-x86_64-libidn2 \ + mingw-w64-x86_64-libunistring \ + mingw-w64-x86_64-nettle \ + mingw-w64-x86_64-gmp \ + mingw-w64-x86_64-p11-kit \ + mingw-w64-x86_64-zlib \ + mingw-w64-x86_64-libxml2 \ + mingw-w64-x86_64-zlib \ + mingw-w64-x86_64-libxml2 \ + mingw-w64-x86_64-lz4 \ + mingw-w64-x86_64-libproxy + + +[ -d work ] || mkdir work +cd work + +[ -d stoken ] || git clone https://github.com/cernekee/stoken +cd stoken +git checkout ${STOKEN_TAG} +./autogen.sh +[ -d build64 ] || mkdir build64 +cd build64 +git clean -fdx +../configure --disable-dependency-tracking --without-tomcrypt --without-gtk +mingw32-make -j4 +mingw32-make install +cd ../../ + +[ -d openconnect ] || git clone git://git.infradead.org/users/dwmw2/openconnect.git +cd openconnect +git reset --hard +git checkout ${OC_TAG} +./autogen.sh +[ -d build64 ] || mkdir build64 +cd build64 +git clean -fdx +../configure --disable-dependency-tracking --with-gnutls --without-openssl --without-libpskc --with-vpnc-script=vpnc-script-win.js +mingw32-make -j4 +cd ../../ + + +# +# Sample script to create a package from build 'openconnect' project +# incl. all dependencies (hardcoded paths!) +# + +export MINGW_PREFIX=/mingw64 + +rm -rf pkg +mkdir -p pkg/nsis && cd pkg/nsis +#cp ${MINGW_PREFIX}/bin/iconv.dll . +cp ${MINGW_PREFIX}/bin/libffi-6.dll . +cp ${MINGW_PREFIX}/bin/libgcc_*-1.dll . +cp ${MINGW_PREFIX}/bin/libgmp-10.dll . +cp ${MINGW_PREFIX}/bin/libgnutls-30.dll . +cp ${MINGW_PREFIX}/bin/libhogweed-4.dll . +cp ${MINGW_PREFIX}/bin/libintl-8.dll . +cp ${MINGW_PREFIX}/bin/libnettle-6.dll . +cp ${MINGW_PREFIX}/bin/libp11-kit-0.dll . +cp ${MINGW_PREFIX}/bin/libtasn1-6.dll . +cp ${MINGW_PREFIX}/bin/libwinpthread-1.dll . +cp ${MINGW_PREFIX}/bin/libxml2-2.dll . +cp ${MINGW_PREFIX}/bin/zlib1.dll . +cp ${MINGW_PREFIX}/bin/libstoken-1.dll . +cp ${MINGW_PREFIX}/bin/libproxy-1.dll . +cp ${MINGW_PREFIX}/bin/liblz4.dll . +cp ${MINGW_PREFIX}/bin/libiconv-2.dll . +cp ${MINGW_PREFIX}/bin/libunistring-2.dll . +cp ${MINGW_PREFIX}/bin/libidn2-0.dll . +cp ${MINGW_PREFIX}/bin/libstdc++-6.dll . +cp ${MINGW_PREFIX}/bin/liblzma-5.dll . +cp ../../openconnect/build64/.libs/libopenconnect-5.dll . +cp ../../openconnect/build64/.libs/openconnect.exe . +curl -v -o vpnc-script-win.js http://git.infradead.org/users/dwmw2/vpnc-scripts.git/blob_plain/HEAD:/vpnc-script-win.js +cd ../../ + +mkdir -p pkg/lib && cd pkg/lib +cp ${MINGW_PREFIX}/lib/libgmp.dll.a . +cp ${MINGW_PREFIX}/lib/libgnutls.dll.a . +cp ${MINGW_PREFIX}/lib/libhogweed.dll.a . +cp ${MINGW_PREFIX}/lib/libnettle.dll.a . +cp ${MINGW_PREFIX}/lib/libp11-kit.dll.a . +cp ${MINGW_PREFIX}/lib/libxml2.dll.a . +cp ${MINGW_PREFIX}/lib/libz.dll.a . +cp ${MINGW_PREFIX}/lib/libstoken.dll.a . +cp ${MINGW_PREFIX}/lib/libproxy.dll.a . +cp ${MINGW_PREFIX}/lib/liblz4.dll.a . +cp ${MINGW_PREFIX}/lib/libiconv.dll.a . +cp ${MINGW_PREFIX}/lib/libunistring.dll.a . +cp ${MINGW_PREFIX}/lib/libidn2.dll.a . +cp ${MINGW_PREFIX}/lib/liblzma.dll.a . +cp ../../openconnect/build64/.libs/libopenconnect.dll.a . +cd ../../ + +mkdir -p pkg/lib/pkgconfig && cd pkg/lib/pkgconfig +cp ${MINGW_PREFIX}/lib/pkgconfig/gnutls.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/hogweed.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/libxml-2.0.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/nettle.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/zlib.pc . +cp ${MINGW_PREFIX}/lib/pkgconfig/stoken.pc . +cp ../../../openconnect/build64/openconnect.pc . +cd ../../../ + +mkdir -p pkg/include && cd pkg/include +cp -R ${MINGW_PREFIX}/include/gnutls/ . +cp -R ${MINGW_PREFIX}/include/libxml2/ . +cp -R ${MINGW_PREFIX}/include/nettle/ . +cp -R ${MINGW_PREFIX}/include/p11-kit-1/p11-kit/ . +cp ${MINGW_PREFIX}/include/gmp.h . +cp ${MINGW_PREFIX}/include/zconf.h . +cp ${MINGW_PREFIX}/include/zlib.h . +cp ${MINGW_PREFIX}/include/stoken.h . +cp ../../openconnect/openconnect.h . +cd ../../ + +export MINGW_PREFIX= + +cd pkg/nsis +7za a -tzip -mx=9 -sdel ../../openconnect-${OC_TAG}_mingw64.zip * +cd ../ +rmdir -v nsis +7za a -tzip -mx=9 -sdel ../openconnect-devel-${OC_TAG}_mingw64.zip * +cd ../ +rmdir -v pkg + + +#cd stoken/build64 +#sudo mingw64-make uninstall + +echo "List of system-wide used packages versions:" \ + > openconnect-${OC_TAG}_mingw64.txt +echo "openconnect-${OC_TAG}" \ + >> openconnect-${OC_TAG}_mingw64.txt +echo "stoken-${STOKEN_TAG}" \ + >> openconnect-${OC_TAG}_mingw64.txt +pacman -Q \ + mingw-w64-x86_64-gnutls \ + mingw-w64-x86_64-libidn2 \ + mingw-w64-x86_64-libunistring \ + mingw-w64-x86_64-nettle \ + mingw-w64-x86_64-gmp \ + mingw-w64-x86_64-p11-kit \ + mingw-w64-x86_64-libxml2 \ + mingw-w64-x86_64-zlib \ + mingw-w64-x86_64-libxml2 \ + mingw-w64-x86_64-lz4 \ + mingw-w64-x86_64-libproxy \ + >> openconnect-${OC_TAG}_mingw64.txt + +sha512sum.exe openconnect-${OC_TAG}_mingw64.zip > openconnect-${OC_TAG}_mingw64.zip.sha512 +sha512sum.exe openconnect-devel-${OC_TAG}_mingw64.zip > openconnect-devel-${OC_TAG}_mingw64.zip.sha512 + +mv -v openconnect-*.zip openconnect-*.txt openconnect-*.zip.sha512 .. diff --git a/contrib/build_mingw@msys2.sh b/contrib/build_mingw@msys2.sh new file mode 100644 index 00000000..87bbe61f --- /dev/null +++ b/contrib/build_mingw@msys2.sh @@ -0,0 +1,53 @@ +# +# Sample build script & release package preapration +# +# It should be used only as illustration how to build application +# and create an installer package +# +# (c) 2016-2018, Lubomir Carik +# + +echo "=======================================================================" +echo " Preparing sandbox..." +echo "=======================================================================" +mkdir -pv build-release-$MSYSTEM + +echo "=======================================================================" +echo " Generating project..." +echo "=======================================================================" +cd build-release-$MSYSTEM +cmake -G "MSYS Makefiles" \ + -DCMAKE_BUILD_TYPE=Release \ + ../.. + +echo "=======================================================================" +echo " Compiling..." +echo "=======================================================================" +make -j5 + +# echo "=======================================================================" +# echo " LC: Bundling... (dynamic Qt only)" +# echo "=======================================================================" +# rd /s /q out +# md out +# windeployqt ^ +# src\openconnect-gui.exe ^ +# --verbose 1 ^ +# --compiler-runtime ^ +# --release ^ +# --force ^ +# --no-webkit2 ^ +# --no-quick-import ^ +# --no-translations + +echo "=======================================================================" +echo " Packaging..." +echo "=======================================================================" +cmake . +make package VERBOSE=1 +# make package_source VERBOSE=1 + +mv -vf *.exe .. +mv -vf *.exe.sha512 .. + +cd .. diff --git a/build_mingw@win.cmd b/contrib/build_mingw@win.cmd similarity index 92% rename from build_mingw@win.cmd rename to contrib/build_mingw@win.cmd index d0643a9d..22871eaf 100644 --- a/build_mingw@win.cmd +++ b/contrib/build_mingw@win.cmd @@ -5,16 +5,16 @@ REM REM It should be used only as illustration how to build application REM and create an installer package REM -REM (c) 2016-2017, Lubomir Carik +REM (c) 2016-2018, Lubomir Carik REM echo "=======================================================================" echo " Preparing environment..." echo "=======================================================================" -REM look for "Qt 5.9.1 for Desktop (MinGW 5.3.0 32 bit)" StartMenu item +REM look for "Qt 5.10.1 for Desktop (MinGW 5.3.0 32 bit)" StartMenu item REM and check 'qtenv2.bat' echo Setting up environment for Qt usage... -set PATH=C:\Dev\Qt\5.9.1\mingw53_32\bin\;%PATH% +set PATH=C:\Dev\Qt\5.10.1\mingw53_32\bin\;%PATH% echo Setting up environment for 'mingw32' usage... set PATH=c:\Dev\Qt\Tools\mingw530_32\bin\;%PATH% @@ -48,7 +48,7 @@ echo "=======================================================================" cd build-release cmake -G "MinGW Makefiles" ^ -DCMAKE_BUILD_TYPE=Release ^ - ..\ + ..\..\ echo "=======================================================================" echo " Compiling..." @@ -77,4 +77,7 @@ cmake . mingw32-make package VERBOSE=1 REM mingw32-make package_source VERBOSE=1 +move /Y *.exe .. +move /Y *.exe.sha512 .. + cd .. diff --git a/docs/dev_QtCreator.md b/docs/dev_QtCreator.md index f963f7d1..a7924bb1 100644 --- a/docs/dev_QtCreator.md +++ b/docs/dev_QtCreator.md @@ -10,8 +10,8 @@ - update desired Qt 5.8 version build types and click "Configure" - open 'Project' tab on left side of QtCreator with CMake configuration - change - - 'PROJ\_UAC\_ON' to 'off' because QtCreator is not able to start app with UAC (?) :/ - - if you like; change 'PROJ\_INI\_SETTINGS' to 'off' if you want store all settings into file instead of Registry for development/tests + - 'PROJ\_UAC\_ON' to 'off' because QtCreator is not able to start app with UAC (?) :/ + - if you like; change 'PROJ\_INI\_SETTINGS' to 'off' if you want store all settings into file instead of Registry for development/tests - click 'Apply Configuration Changes' and then switch again to 'Edit' tab on left side of QtCreator - build the project diff --git a/docs/dev_commandLine.md b/docs/dev_commandLine.md index f79765aa..da9055fa 100644 --- a/docs/dev_commandLine.md +++ b/docs/dev_commandLine.md @@ -5,6 +5,17 @@ may be found in [shell script](../build_mingw@win.cmd) in project root. #### Hints For macOS +Install [Homebrew](https://docs.brew.sh/) system-wide: +``` +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + +``` +or localy: +``` +mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew +``` +and continue: + ``` # Install dependencies brew install qt5 @@ -12,10 +23,6 @@ brew install openconnect cd openconnect-gui -# Make sure all git submodules are up-to-date -git submodule init -git submodule update - # Build it mkdir build-release cd build-release diff --git a/docs/openconnect.md b/docs/openconnect.md index 9104cfc4..fd2f09e1 100644 --- a/docs/openconnect.md +++ b/docs/openconnect.md @@ -1,8 +1,8 @@ ### OpenConnect compilation The 'openconnect' binary and libraries incl. dependent libraries -used in this project are actually build and packaged -incl. library/header dependencies on Fedora 26 -via [this script](../contrib/build_mingw-openconnect-w32@fedora26.sh). +used in this project may be actually build and packaged +include libraries/headers dependencies on MSYS2 build environment +or Fedora OS via [these scripts](../contrib/). These commands and paths may vary... diff --git a/docs/sw_requirements.md b/docs/sw_requirements.md index c4a9f794..ffa42d39 100644 --- a/docs/sw_requirements.md +++ b/docs/sw_requirements.md @@ -5,44 +5,45 @@ This chapter summarize actual development environment. Newer or older versions m This is target platform for the product. - [Qt 5 (incl. mingw32) & QtCreator 4+](http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe) and choose: - - 5.9.1/MinGW 5.3.0 (32-bit) + - 5.10.0/MinGW 5.3.0 (32-bit) - Tools/MinGW 5.3.0 component - Tools/QtCreator component - Tools/QtCreator CDB Debugger support -- [NSIS 3.0+](http://nsis.sourceforge.net/Main_Page) -- [CMake 3.6+](https://cmake.org/) +- [NSIS 3.0+](https://sourceforge.net/projects/nsis) +- [CMake 3.10+](https://cmake.org/) - [Git 2.7+](https://git-scm.com/) ##### Externals -These project will by downloaded automatically by CMake. +These projects will be downloaded automatically by CMake. -- [OpenConnect 7.08 for MinGW32](https://github.com/horar/openconnect/releases/tag/v7.08) -- [TAP-windoes 9.21.2](https://openvpn.net/index.php/open-source/downloads.html) -- [spdlog 0.13.0](https://github.com/gabime/spdlog) +- [OpenConnect for MinGW32](https://github.com/horar/openconnect/releases) +- [TAP-windows](https://openvpn.net/index.php/open-source/downloads.html) +- [spdlog](https://github.com/gabime/spdlog) - [qt-solutions](https://github.com/qtproject/qt-solutions.git) #### GNU/Linux -##### Fedora 26 (MinGW) +##### Fedora 27 (MinGW32) Just try install following packages: - sudo dnf install cmake - sudo dnf install mingw32-qt5-qtbase - sudo dnf install mingw32-nsis + sudo dnf install -y git + sudo dnf install -y cmake + sudo dnf install -y mingw32-qt5-qtbase + sudo dnf install -y mingw32-nsis -##### Fedora 26 +##### Fedora 27 This is not main target platform, because openconnect is used by other projects integrated into desktop environments. On the other side - the minimum of required packages to build this GUI should be installed by following commands: - sudo dnf install git gitflow - sudo dnf install cmake - sudo dnf install qt5-qtbase-devel gcc-c++ - sudo dnf install gnutls-devel openconnect-devel - ~~sudo dnf install spdlog-devel~~ + sudo dnf install -y git gitflow + sudo dnf install -y cmake + sudo dnf install -y qt5-qtbase-devel gcc-c++ + sudo dnf install -y gnutls-devel openconnect-devel + ~~sudo dnf install -y spdlog-devel~~ #### MacOS -- MacOS 10.10+ -- Xcode 8.2.1+ incl. command line tools +- MacOS 10.13+ +- Xcode 9.2+ incl. command line tools - [Qt online installer](http://download.qt.io/official_releases/online_installers/qt-unified-mac-x64-online.dmg) and choose: - - 5.9.1/"OS X" component + - 5.10.0/"OS X" component - Tools/QtCreator component diff --git a/docs/webpage.md b/docs/webpage.md index aacb5445..ca670e05 100644 --- a/docs/webpage.md +++ b/docs/webpage.md @@ -3,14 +3,14 @@ Following stesp summarize how to update OpenConnect-GUI web page, screen shots and its conten: 1. images/screenshots preaparation: - - prepare desired screen shots (common width is 650px) - - checkout project into 'gh-pages' branch - - create or upload images to e.g. screenshots folder - - commit & submit - and continue with web-text changes... + - prepare desired screen shots (common width is 650px) + - checkout project into 'gh-pages' branch + - create or upload images to e.g. screenshots folder + - commit & submit - and continue with web-text changes... 2. web page text: - - open GitHub project settings - - look for GitHub pages and click "Launch automatic page generator" - - edit 'markdown' page content - - click "Continue to layouts" - - choose 'Tactile' style in list - - review your changes and finish with clicking to "Publish page" + - open GitHub project settings + - look for GitHub pages and click "Launch automatic page generator" + - edit 'markdown' page content + - click "Continue to layouts" + - choose 'Tactile' style in list + - review your changes and finish with clicking to "Publish page" diff --git a/external/.gitignore b/external/.gitignore new file mode 100644 index 00000000..0d275de5 --- /dev/null +++ b/external/.gitignore @@ -0,0 +1,3 @@ +*.zip +*.zip.sha512 +*.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3adebbb..d6e393c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,54 +1,37 @@ +set_property(SOURCE ${PROJECT_NAME}.cpp PROPERTY SKIP_AUTOGEN ON) +set_property(SOURCE timestamp.cpp PROPERTY SKIP_AUTOGEN ON) + set(${PROJECT_NAME}_SRCS ${PROJECT_NAME}.cpp - ${PROJECT_NAME}.h ${PROJECT_NAME}.qrc cert.cpp - cert.h - common.h - config.h config.h.in cryptdata.cpp - cryptdata.h dialog/MyCertMsgBox.cpp - dialog/MyCertMsgBox.h dialog/MyInputDialog.cpp - dialog/MyInputDialog.h dialog/MyMsgBox.cpp - dialog/MyMsgBox.h dialog/editdialog.cpp - dialog/editdialog.h dialog/editdialog.ui dialog/NewProfileDialog.cpp - dialog/NewProfileDialog.h dialog/NewProfileDialog.ui dialog/logdialog.cpp - dialog/logdialog.h dialog/logdialog.ui dialog/mainwindow.cpp - dialog/mainwindow.h dialog/mainwindow.ui gtdb.cpp - gtdb.h key.cpp - key.h keypair.cpp - keypair.h main.cpp server_storage.cpp - server_storage.h - timestamp.h timestamp.cpp vpninfo.cpp - vpninfo.h logger.cpp - logger.h FileLogger.cpp - FileLogger.h ) set_source_files_properties( @@ -105,9 +88,6 @@ if(MINGW) openconnect-devel-${openconnect-TAG} openconnect-${openconnect-TAG} vpnc-scripts-${vpnc-scripts-TAG} - qt-solutions-${qt-solutions-TAG} - - spdlog-${spdlog-TAG} ) set_target_properties(${PROJECT_NAME} PROPERTIES @@ -161,6 +141,7 @@ target_link_libraries (${PROJECT_NAME} Qt5::Gui Qt5::Widgets Qt5::Network + #??? Qt5::QMacStylePlugin ) if(UNIX) @@ -208,6 +189,13 @@ if(MINGW) ) set(additionalLib ${_qwindows_dll}) + if(NOT Qt5Core_VERSION STRLESS "5.10") + install(FILES + ${_qwinstyle_dylib} + DESTINATION plugins/styles + COMPONENT App + ) + endif() elseif(APPLE) set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app") list(APPEND libSearchDirs "") @@ -218,13 +206,23 @@ elseif(APPLE) DESTINATION ${PROJECT_NAME}.app/Contents/PlugIns/platforms COMPONENT App ) + set(additionalLib \${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/PlugIns/platforms/libqcocoa.dylib) + if(NOT Qt5Core_VERSION STRLESS "5.10") + install(FILES + ${_qmacstyle_dylib} + DESTINATION ${PROJECT_NAME}.app/Contents/PlugIns/styles + COMPONENT App + ) + set(additionalLib + ${additionalLib} + \${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/PlugIns/styles/libqmacstyle.dylib + ) + endif() install(FILES ${CMAKE_SOURCE_DIR}/bundle/qt.conf DESTINATION ${PROJECT_NAME}.app/Contents/Resources COMPONENT App ) - - set(additionalLib \${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/PlugIns/platforms/libqcocoa.dylib) else() message(STATUS "Nothing to bundle...") endif() diff --git a/src/FileLogger.cpp b/src/FileLogger.cpp index 6ac1a10a..ce2736d0 100644 --- a/src/FileLogger.cpp +++ b/src/FileLogger.cpp @@ -1,17 +1,17 @@ #include "FileLogger.h" -#include #include #include +#include #include namespace spd = spdlog; -FileLogger::FileLogger(QObject *parent, const QString& logPath, const size_t logSize, const size_t logCount) : - QObject(parent), - m_logPath{logPath}, - m_logSize{logSize}, - m_logCount{logCount} +FileLogger::FileLogger(QObject* parent, const QString& logPath, const size_t logSize, const size_t logCount) + : QObject(parent) + , m_logPath{ logPath } + , m_logSize{ logSize } + , m_logCount{ logCount } { QDir dir; @@ -19,17 +19,17 @@ FileLogger::FileLogger(QObject *parent, const QString& logPath, const size_t log try { m_logger = spd::rotating_logger_mt("openconnect-logger", #ifdef Q_OS_WIN - QString("%1/%2").arg(m_logPath).arg(qApp->applicationName()).toStdWString(), + QString("%1/%2").arg(m_logPath).arg(qApp->applicationName()).toStdWString(), #else - QString("%1/%2").arg(m_logPath).arg(qApp->applicationName()).toStdString(), + QString("%1/%2").arg(m_logPath).arg(qApp->applicationName()).toStdString(), #endif - logSize, - logCount); + logSize, + logCount); spd::set_pattern("%v"); } catch (const spd::spdlog_ex& ex) { QMessageBox::critical(nullptr, - QString("Log file init failed"), - QString(ex.what())); + QString("Log file init failed"), + QString(ex.what())); } connect(&Logger::instance(), &Logger::newLogMessage, this, &FileLogger::addLogMessage); @@ -46,9 +46,9 @@ void FileLogger::addLogMessage(const Logger::Message& message) dt.setMSecsSinceEpoch(message.timeStamp); m_logger->log(spdlog::level::off, - "{:<24} | {:>4} | {}", - dt.toString("yyyy-MM-dd hh:mm:ss.ms").toStdString(), - QString::number((long long)message.threadId, 16).toStdString(), - message.text.toStdString()); + "{:<24} | {:>4} | {}", + dt.toString("yyyy-MM-dd hh:mm:ss.ms").toStdString(), + QString::number((long long)message.threadId, 16).toStdString(), + message.text.toStdString()); m_logger->flush(); } diff --git a/src/FileLogger.h b/src/FileLogger.h index 600cf6ad..e8e3468b 100644 --- a/src/FileLogger.h +++ b/src/FileLogger.h @@ -1,6 +1,5 @@ #pragma once - #include "spdlog/spdlog.h" #include @@ -8,15 +7,13 @@ #include "logger.h" - -class FileLogger : public QObject -{ +class FileLogger : public QObject { Q_OBJECT public: - explicit FileLogger(QObject *parent = nullptr, - const QString& logPath = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).arg("logs"), - const size_t logSize = 1024*1024, - const size_t logCount = 5); + explicit FileLogger(QObject* parent = nullptr, + const QString& logPath = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).arg("logs"), + const size_t logSize = 1024 * 1024, + const size_t logCount = 5); ~FileLogger(); FileLogger(const FileLogger&) = delete; FileLogger& operator=(const FileLogger&) = delete; diff --git a/src/Resources/openconnect-gui.plist.in b/src/Resources/openconnect-gui.plist.in index 8dc07f78..9ccf853f 100644 --- a/src/Resources/openconnect-gui.plist.in +++ b/src/Resources/openconnect-gui.plist.in @@ -33,7 +33,7 @@ NSPrincipalClass NSApplication NSHighResolutionCapable - True + LSMinimumSystemVersion ${CMAKE_OSX_DEPLOYMENT_TARGET} diff --git a/src/common.h b/src/common.h index 2ab4a8f8..376ff357 100644 --- a/src/common.h +++ b/src/common.h @@ -25,13 +25,10 @@ #define TMP_CERT_PREFIX "tmp-certXXXXXX" #define TMP_KEY_PREFIX "tmp-keyXXXXXX" -#define OFF_ICON QPixmap(QString::fromLatin1(":/new/resource/images/traffic_light_red.png")) -#define ON_ICON QPixmap(QString::fromLatin1(":/new/resource/images/traffic_light_green.png")) -#define CONNECTING_ICON QPixmap(QString::fromLatin1(":/new/resource/images/traffic_light_yellow.png")) -#define CONNECTING_ICON2 QPixmap(QString::fromLatin1(":/new/resource/images/traffic_light_off.png")) - -#define TRAY_OFF_ICON QPixmap(QString::fromLatin1(":/new/resource/images/network-disconnected.png")) -#define TRAY_ON_ICON QPixmap(QString::fromLatin1(":/new/resource/images/network-connected.png")) +#define OFF_ICON QPixmap(QString::fromLatin1(":/images/traffic_light_red.png")) +#define ON_ICON QPixmap(QString::fromLatin1(":/images/traffic_light_green.png")) +#define CONNECTING_ICON QPixmap(QString::fromLatin1(":/images/traffic_light_yellow.png")) +#define CONNECTING_ICON2 QPixmap(QString::fromLatin1(":/images/traffic_light_off.png")) #define UPDATE_TIMER 10000 diff --git a/src/cryptdata.cpp b/src/cryptdata.cpp index b6f9127d..e302110e 100644 --- a/src/cryptdata.cpp +++ b/src/cryptdata.cpp @@ -69,16 +69,19 @@ QByteArray CryptData::encode(QString& txt, QString password) } DATA_BLOB DataIn; - DataIn.pbData = (BYTE*)password.toUtf8().data(); - DataIn.cbData = password.toUtf8().size(); + QByteArray passwordArray{password.toUtf8()}; + DataIn.pbData = (BYTE*)passwordArray.data(); + DataIn.cbData = passwordArray.size() + 1; + + DATA_BLOB Entropy; + QByteArray txtArray{txt.toUtf8()}; + Entropy.pbData = (BYTE*)txtArray.data(); + Entropy.cbData = txtArray.size() + 1; - DATA_BLOB Opt; - Opt.pbData = (BYTE*)txt.toUtf8().data(); - Opt.cbData = txt.toUtf8().size(); DATA_BLOB DataOut; QByteArray res; - BOOL r = pCryptProtectData(&DataIn, NULL, &Opt, NULL, NULL, 0, &DataOut); + BOOL r = pCryptProtectData(&DataIn, NULL, &Entropy, NULL, NULL, 0, &DataOut); if (r == false) { return res; } @@ -103,24 +106,24 @@ bool CryptData::decode(QString& txt, QByteArray _enc, QString& res) return true; } - QByteArray enc; - enc = QByteArray::fromBase64(_enc.mid(4)); - DATA_BLOB DataIn; + QByteArray enc{QByteArray::fromBase64(_enc.mid(4))}; DataIn.pbData = (BYTE*)enc.data(); - DataIn.cbData = enc.size(); + DataIn.cbData = enc.size() + 1; - DATA_BLOB Opt; - Opt.pbData = (BYTE*)txt.toLatin1().data(); - Opt.cbData = txt.toLatin1().size(); + DATA_BLOB Entropy; + QByteArray txtArray{txt.toUtf8()}; + Entropy.pbData = (BYTE*)txtArray.data(); + Entropy.cbData = txtArray.size() + 1; DATA_BLOB DataOut; - BOOL r = pCryptUnprotectData(&DataIn, NULL, &Opt, NULL, NULL, 0, &DataOut); + + BOOL r = pCryptUnprotectData(&DataIn, NULL, &Entropy, NULL, NULL, 0, &DataOut); if (r == false) { return false; } - res = QString::fromUtf8((const char*)DataOut.pbData, DataOut.cbData); + res = QString::fromUtf8((const char*)DataOut.pbData, DataOut.cbData - 1); LocalFree(DataOut.pbData); return true; } diff --git a/src/dialog/NewProfileDialog.cpp b/src/dialog/NewProfileDialog.cpp index c04c09fa..2e6ee81e 100644 --- a/src/dialog/NewProfileDialog.cpp +++ b/src/dialog/NewProfileDialog.cpp @@ -4,14 +4,14 @@ #include "server_storage.h" #include -#include #include +#include #include -NewProfileDialog::NewProfileDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::NewProfileDialog) +NewProfileDialog::NewProfileDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::NewProfileDialog) { ui->setupUi(this); @@ -32,15 +32,15 @@ QString NewProfileDialog::getNewProfileName() const return ui->lineEditName->text(); } -void NewProfileDialog::changeEvent(QEvent *e) +void NewProfileDialog::changeEvent(QEvent* e) { QDialog::changeEvent(e); switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; } } @@ -58,12 +58,12 @@ void NewProfileDialog::on_checkBoxCustomize_toggled(bool checked) } } -void NewProfileDialog::on_lineEditName_textChanged(const QString &) +void NewProfileDialog::on_lineEditName_textChanged(const QString&) { updateButtons(); } -void NewProfileDialog::on_lineEditGateway_textChanged(const QString &text) +void NewProfileDialog::on_lineEditGateway_textChanged(const QString& text) { QUrl url(text, QUrl::StrictMode); if (ui->checkBoxCustomize->isChecked() == false && (url.isValid() || text.isEmpty())) { @@ -76,9 +76,8 @@ void NewProfileDialog::on_lineEditGateway_textChanged(const QString &text) #define PREFIX "server:" void NewProfileDialog::updateButtons() { - bool enableButtons{false}; - if (ui->lineEditName->text().isEmpty() == false && - ui->lineEditGateway->text().isEmpty() == false) { + bool enableButtons{ false }; + if (ui->lineEditName->text().isEmpty() == false && ui->lineEditGateway->text().isEmpty() == false) { enableButtons = true; @@ -86,7 +85,7 @@ void NewProfileDialog::updateButtons() QSettings settings; for (const auto& key : settings.allKeys()) { if (key.startsWith(PREFIX) && key.endsWith("/server")) { - QString str{key}; + QString str{ key }; str.remove(0, sizeof(PREFIX) - 1); /* remove prefix */ str.remove(str.size() - 7, 7); /* remove /server suffix */ if (str == ui->lineEditName->text()) { @@ -101,7 +100,7 @@ void NewProfileDialog::updateButtons() ui->buttonBox->button(QDialogButtonBox::SaveAll)->setEnabled(enableButtons); } -void NewProfileDialog::on_buttonBox_clicked(QAbstractButton *button) +void NewProfileDialog::on_buttonBox_clicked(QAbstractButton* button) { if (ui->buttonBox->standardButton(button) == QDialogButtonBox::SaveAll) { emit connect(); @@ -110,7 +109,7 @@ void NewProfileDialog::on_buttonBox_clicked(QAbstractButton *button) void NewProfileDialog::on_buttonBox_accepted() { - auto ss{std::make_unique()}; + auto ss{ std::make_unique() }; ss->set_label(ui->lineEditName->text()); ss->set_servername(ui->lineEditGateway->text()); ss->save(); diff --git a/src/dialog/NewProfileDialog.h b/src/dialog/NewProfileDialog.h index 6e52c181..3654b220 100644 --- a/src/dialog/NewProfileDialog.h +++ b/src/dialog/NewProfileDialog.h @@ -7,12 +7,11 @@ namespace Ui { class NewProfileDialog; } -class NewProfileDialog : public QDialog -{ +class NewProfileDialog : public QDialog { Q_OBJECT public: - explicit NewProfileDialog(QWidget *parent = 0); + explicit NewProfileDialog(QWidget* parent = 0); ~NewProfileDialog(); QString getNewProfileName() const; @@ -21,18 +20,18 @@ class NewProfileDialog : public QDialog void connect(); protected: - void changeEvent(QEvent *e); + void changeEvent(QEvent* e); private slots: void on_checkBoxCustomize_toggled(bool checked); - void on_lineEditName_textChanged(const QString &); - void on_lineEditGateway_textChanged(const QString &text); + void on_lineEditName_textChanged(const QString&); + void on_lineEditGateway_textChanged(const QString& text); - void on_buttonBox_clicked(QAbstractButton *button); + void on_buttonBox_clicked(QAbstractButton* button); void on_buttonBox_accepted(); private: void updateButtons(); - Ui::NewProfileDialog *ui; + Ui::NewProfileDialog* ui; }; diff --git a/src/dialog/editdialog.cpp b/src/dialog/editdialog.cpp index 3acad422..2b04c779 100644 --- a/src/dialog/editdialog.cpp +++ b/src/dialog/editdialog.cpp @@ -56,7 +56,7 @@ static int token_tab(int mode) } static int token_rtab[] = { - [0] = OC_TOKEN_MODE_HOTP, + [0] = OC_TOKEN_MODE_HOTP, [1] = OC_TOKEN_MODE_TOTP, [2] = OC_TOKEN_MODE_STOKEN }; @@ -336,32 +336,32 @@ void EditDialog::on_loadWinCert_clicked() ui->userKeyEdit->setText(st.key_url); } -void EditDialog::on_groupnameEdit_textChanged(const QString &arg1) +void EditDialog::on_groupnameEdit_textChanged(const QString& arg1) { ui->groupnameClear->setEnabled(!arg1.isEmpty()); } -void EditDialog::on_caCertEdit_textChanged(const QString &arg1) +void EditDialog::on_caCertEdit_textChanged(const QString& arg1) { ui->caCertClear->setEnabled(!arg1.isEmpty()); } -void EditDialog::on_serverCertHash_textChanged(const QString &arg1) +void EditDialog::on_serverCertHash_textChanged(const QString& arg1) { ui->serverCertClear->setEnabled(!arg1.isEmpty()); } -void EditDialog::on_tokenEdit_textChanged(const QString &arg1) +void EditDialog::on_tokenEdit_textChanged(const QString& arg1) { ui->tokenClear->setEnabled(!arg1.isEmpty()); } -void EditDialog::on_userCertEdit_textChanged(const QString &arg1) +void EditDialog::on_userCertEdit_textChanged(const QString& arg1) { ui->userCertClear->setEnabled(!arg1.isEmpty()); } -void EditDialog::on_userKeyEdit_textChanged(const QString &arg1) +void EditDialog::on_userKeyEdit_textChanged(const QString& arg1) { ui->userKeyClear->setEnabled(!arg1.isEmpty()); } diff --git a/src/dialog/editdialog.h b/src/dialog/editdialog.h index 791bb769..5cf8405e 100644 --- a/src/dialog/editdialog.h +++ b/src/dialog/editdialog.h @@ -50,12 +50,12 @@ private slots: void on_groupnameClear_clicked(); void on_loadWinCert_clicked(); - void on_groupnameEdit_textChanged(const QString &arg1); - void on_caCertEdit_textChanged(const QString &arg1); - void on_serverCertHash_textChanged(const QString &arg1); - void on_tokenEdit_textChanged(const QString &arg1); - void on_userCertEdit_textChanged(const QString &arg1); - void on_userKeyEdit_textChanged(const QString &arg1); + void on_groupnameEdit_textChanged(const QString& arg1); + void on_caCertEdit_textChanged(const QString& arg1); + void on_serverCertHash_textChanged(const QString& arg1); + void on_tokenEdit_textChanged(const QString& arg1); + void on_userCertEdit_textChanged(const QString& arg1); + void on_userKeyEdit_textChanged(const QString& arg1); private: void load_win_certs(); diff --git a/src/dialog/editdialog.ui b/src/dialog/editdialog.ui index b2c064b5..8e061616 100644 --- a/src/dialog/editdialog.ui +++ b/src/dialog/editdialog.ui @@ -105,7 +105,7 @@ - :/new/resource/images/trashcan.png:/new/resource/images/trashcan.png + :/images/trashcan.png:/images/trashcan.png @@ -147,7 +147,7 @@ - :/new/resource/images/trashcan.png:/new/resource/images/trashcan.png + :/images/trashcan.png:/images/trashcan.png @@ -185,7 +185,7 @@ - :/new/resource/images/trashcan.png:/new/resource/images/trashcan.png + :/images/trashcan.png:/images/trashcan.png @@ -248,7 +248,7 @@ - :/new/resource/images/trashcan.png:/new/resource/images/trashcan.png + :/images/trashcan.png:/images/trashcan.png @@ -347,7 +347,7 @@ - :/new/resource/images/trashcan.png:/new/resource/images/trashcan.png + :/images/trashcan.png:/images/trashcan.png @@ -408,7 +408,7 @@ - :/new/resource/images/trashcan.png:/new/resource/images/trashcan.png + :/images/trashcan.png:/images/trashcan.png diff --git a/src/dialog/logdialog.cpp b/src/dialog/logdialog.cpp index 3caf93fe..c91de3be 100644 --- a/src/dialog/logdialog.cpp +++ b/src/dialog/logdialog.cpp @@ -21,9 +21,9 @@ #include "ui_logdialog.h" #include +#include #include #include -#include #include LogDialog::LogDialog(QWidget* parent) @@ -45,18 +45,18 @@ LogDialog::LogDialog(QWidget* parent) } connect(&Logger::instance(), &Logger::newLogMessage, - this, &LogDialog::append, Qt::QueuedConnection); + this, &LogDialog::append, Qt::QueuedConnection); m_timer->setSingleShot(true); m_timer->setInterval(100); connect(m_timer.get(), &QTimer::timeout, - ui->listWidget, &QListWidget::scrollToBottom); + ui->listWidget, &QListWidget::scrollToBottom); } LogDialog::~LogDialog() { disconnect(&Logger::instance(), &Logger::newLogMessage, - this, &LogDialog::append); + this, &LogDialog::append); delete ui; } @@ -71,22 +71,14 @@ void LogDialog::append(const Logger::Message& message) QDateTime dt; dt.setMSecsSinceEpoch(message.timeStamp); ui->listWidget->addItem(QString("%1 | %2 | %3") - .arg(dt.toString("yyyy-MM-dd hh:mm:ss")) - .arg(QString::number((long long)message.threadId, 16), 4) - .arg(message.text) - ); + .arg(dt.toString("yyyy-MM-dd hh:mm:ss")) + .arg(QString::number((long long)message.threadId, 16), 4) + .arg(message.text)); if (ui->checkBox_autoScroll->checkState() == Qt::Checked) { m_timer->start(); } } -void LogDialog::closeEvent(QCloseEvent* event) -{ - saveSettings(); - - QDialog::closeEvent(event); -} - void LogDialog::on_pushButtonClear_clicked() { if (ui->listWidget->count()) { @@ -151,3 +143,8 @@ void LogDialog::on_checkBox_autoScroll_toggled(bool checked) m_timer->stop(); } } + +void LogDialog::on_LogDialog_rejected() +{ + saveSettings(); +} diff --git a/src/dialog/logdialog.h b/src/dialog/logdialog.h index 0ad49660..1024a5dd 100644 --- a/src/dialog/logdialog.h +++ b/src/dialog/logdialog.h @@ -33,7 +33,7 @@ class LogDialog; class LogDialog : public QDialog { Q_OBJECT public: - LogDialog(QWidget* parent = 0); + explicit LogDialog(QWidget* parent = 0); ~LogDialog(); signals: @@ -41,9 +41,6 @@ class LogDialog : public QDialog { public slots: void append(const Logger::Message& message); -protected slots: - void closeEvent(QCloseEvent* event) override; - private slots: void on_pushButtonClear_clicked(); void on_pushButtonSelectAll_clicked(); @@ -53,6 +50,8 @@ private slots: void on_checkBox_autoScroll_toggled(bool checked); + void on_LogDialog_rejected(); + private: void loadSettings(); void saveSettings(); diff --git a/src/dialog/logdialog.ui b/src/dialog/logdialog.ui index 12f363d8..b214c434 100644 --- a/src/dialog/logdialog.ui +++ b/src/dialog/logdialog.ui @@ -125,7 +125,7 @@ pushButtonClose clicked() LogDialog - close() + reject() 652 diff --git a/src/dialog/mainwindow.cpp b/src/dialog/mainwindow.cpp index c3744da0..d90707dd 100644 --- a/src/dialog/mainwindow.cpp +++ b/src/dialog/mainwindow.cpp @@ -18,14 +18,14 @@ */ #include "mainwindow.h" -#include "ui_mainwindow.h" -#include "config.h" #include "NewProfileDialog.h" +#include "config.h" #include "editdialog.h" #include "logdialog.h" #include "openconnect-gui.h" -#include "timestamp.h" #include "server_storage.h" +#include "timestamp.h" +#include "ui_mainwindow.h" #include "vpninfo.h" #include "logger.h" @@ -37,24 +37,25 @@ extern "C" { #include #include +#include #include +#include +#include #include #include #include #include +#include +#include #include #include #include #include #include -#include -#include -#include -#include +#include #include #include -#include #ifdef _WIN32 #define pipe_write(x, y, z) send(x, y, z, 0) @@ -69,14 +70,22 @@ MainWindow::MainWindow(QWidget* parent, const QString profileName) ui->setupUi(this); connect(ui->viewLogButton, &QPushButton::clicked, - this, &MainWindow::createLogDialog); + this, &MainWindow::createLogDialog); timer = new QTimer(this); blink_timer = new QTimer(this); this->cmd_fd = INVALID_SOCKET; connect(ui->actionQuit, &QAction::triggered, - qApp, &QApplication::quit); + [=]() { + if (m_disconnectAction->isEnabled()) { + connect(this, &MainWindow::readyToShutdown, + qApp, &QApplication::quit); + on_disconnectClicked(); + } else { + qApp->quit(); + } + }); connect(blink_timer, &QTimer::timeout, this, &MainWindow::blink_ui, @@ -103,8 +112,9 @@ MainWindow::MainWindow(QWidget* parent, const QString profileName) connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::iconActivated); - QIcon icon; - icon.addPixmap(TRAY_OFF_ICON, QIcon::Normal, QIcon::Off); + QFileSelector selector; + QIcon icon(selector.select(QStringLiteral(":/images/network-disconnected.png"))); + icon.setIsMask(true); m_trayIcon->setIcon(icon); m_trayIcon->show(); } else { @@ -135,17 +145,21 @@ MainWindow::MainWindow(QWidget* parent, const QString profileName) s2_connectionReady->assignProperty(m_trayIconMenuConnections, "enabled", true); machine->addState(s2_connectionReady); - class ServerListTransition : public QSignalTransition - { + class ServerListTransition : public QSignalTransition { public: - ServerListTransition(QComboBox *cb, bool hasServers) - : QSignalTransition(cb, SIGNAL(currentIndexChanged(int))), hasServers(hasServers) {} + ServerListTransition(QComboBox* cb, bool hasServers) + : QSignalTransition(cb, SIGNAL(currentIndexChanged(int))) + , hasServers(hasServers) + { + } + protected: - bool eventTest(QEvent *e) { + bool eventTest(QEvent* e) + { if (!QSignalTransition::eventTest(e)) { return false; } - QStateMachine::SignalEvent *se = static_cast(e); + QStateMachine::SignalEvent* se = static_cast(e); bool isEmpty = se->arguments().at(0).toInt() == -1; return (hasServers ? !isEmpty : isEmpty); } @@ -177,8 +191,8 @@ MainWindow::MainWindow(QWidget* parent, const QString profileName) return; } else { QMessageBox::warning(this, - tr("Connection failed"), - tr("Selected VPN profile '%1' does not exists.").arg(profileName)); + tr("Connection failed"), + tr("Selected VPN profile '%1' does not exists.").arg(profileName)); } } @@ -231,43 +245,55 @@ MainWindow::MainWindow(QWidget* parent, const QString profileName) } // TODO: move outside... - class MinimizeEventTransition : public QEventTransition - { + class MinimizeEventTransition : public QEventTransition { public: - MinimizeEventTransition(QMainWindow* mw, Qt::WindowState state) - : QEventTransition(mw, QEvent::WindowStateChange), m_mw(mw), m_state(state) {} + MinimizeEventTransition(QMainWindow* mw, Qt::WindowState state) + : QEventTransition(mw, QEvent::WindowStateChange) + , m_mw(mw) + , m_state(state) + { + } + protected: - bool eventTest(QEvent *e) override { + bool eventTest(QEvent* e) override + { if (!QEventTransition::eventTest(e)) { return false; } - QStateMachine::WrappedEvent *we = static_cast(e); - if(we->event()->type() == QEvent::WindowStateChange) { + QStateMachine::WrappedEvent* we = static_cast(e); + if (we->event()->type() == QEvent::WindowStateChange) { return (m_mw->windowState() == m_state); } return false; } + private: QMainWindow* m_mw; Qt::WindowState m_state; }; // TODO: move outside... - class RestoreEventTransition : public QEventTransition - { + class RestoreEventTransition : public QEventTransition { public: - RestoreEventTransition(QMainWindow* mw, Qt::WindowState state) - : QEventTransition(mw, QEvent::WindowStateChange), m_mw(mw), m_state(state) {} + RestoreEventTransition(QMainWindow* mw, Qt::WindowState state) + : QEventTransition(mw, QEvent::WindowStateChange) + , m_mw(mw) + , m_state(state) + { + } + protected: - bool eventTest(QEvent *e) override { + bool eventTest(QEvent* e) override + { if (!QEventTransition::eventTest(e)) { return false; } - QStateMachine::WrappedEvent *we = static_cast(e); - if(we->event()->type() == QEvent::WindowStateChange) { + QStateMachine::WrappedEvent* we = static_cast(e); + if (we->event()->type() == QEvent::WindowStateChange) { return (m_mw->windowState() == m_state); } return false; } + private: QMainWindow* m_mw; Qt::WindowState m_state; @@ -341,13 +367,13 @@ void MainWindow::vpn_status_changed(int connected, QString& dns, QString& ip, QS QString MainWindow::normalize_byte_size(uint64_t bytes) { - const unsigned unit = 1024;// TODO: add support for SI units? (optional) + const unsigned unit = 1024; // TODO: add support for SI units? (optional) if (bytes < unit) { return QString("%1 B").arg(QString::number(bytes)); } const int exp = static_cast(std::log(bytes) / std::log(unit)); static const char suffixChar[] = "KMGTPE"; - return QString("%1 %2B").arg(QString::number(bytes / std::pow(unit, exp), 'f', 3)).arg(suffixChar[exp-1]); + return QString("%1 %2B").arg(QString::number(bytes / std::pow(unit, exp), 'f', 3)).arg(suffixChar[exp - 1]); } void MainWindow::statsChanged(QString tx, QString rx, QString dtls) @@ -415,10 +441,12 @@ void MainWindow::changeStatus(int val) m_disconnectAction->setEnabled(true); ui->iconLabel->setPixmap(ON_ICON); - ui->connectionButton->setIcon(QIcon(":/new/resource/images/process-stop.png")); + ui->connectionButton->setIcon(QIcon(":/images/process-stop.png")); ui->connectionButton->setText(tr("Disconnect")); - QIcon icon(TRAY_ON_ICON); + QFileSelector selector; + QIcon icon(selector.select(QStringLiteral(":/images/network-connected.png"))); + icon.setIsMask(true); m_trayIcon->setIcon(icon); this->ui->ipV4Label->setText(ip); @@ -442,7 +470,9 @@ void MainWindow::changeStatus(int val) } else if (val == STATUS_CONNECTING) { if (m_trayIcon) { - QIcon icon(TRAY_OFF_ICON); + QFileSelector selector; + QIcon icon(selector.select(QStringLiteral(":/images/network-disconnected.png"))); + icon.setIsMask(true); m_trayIcon->setIcon(icon); } @@ -452,7 +482,7 @@ void MainWindow::changeStatus(int val) m_disconnectAction->setEnabled(true); ui->iconLabel->setPixmap(CONNECTING_ICON); - ui->connectionButton->setIcon(QIcon(":/new/resource/images/process-stop.png")); + ui->connectionButton->setIcon(QIcon(":/images/process-stop.png")); ui->connectionButton->setText(tr("Cancel")); blink_timer->start(1500); @@ -484,11 +514,13 @@ void MainWindow::changeStatus(int val) ui->iconLabel->setPixmap(OFF_ICON); ui->connectionButton->setEnabled(true); - ui->connectionButton->setIcon(QIcon(":/new/resource/images/network-wired.png")); + ui->connectionButton->setIcon(QIcon(":/images/network-wired.png")); ui->connectionButton->setText(tr("Connect")); if (m_trayIcon) { - QIcon icon(TRAY_OFF_ICON); + QFileSelector selector; + QIcon icon(selector.select(QStringLiteral(":/images/network-disconnected.png"))); + icon.setIsMask(true); m_trayIcon->setIcon(icon); if (this->isHidden() == true) @@ -501,9 +533,11 @@ void MainWindow::changeStatus(int val) connect(ui->connectionButton, &QPushButton::clicked, this, &MainWindow::on_connectClicked, Qt::QueuedConnection); + + emit readyToShutdown(); } else if (val == STATUS_DISCONNECTING) { ui->iconLabel->setPixmap(CONNECTING_ICON); - ui->connectionButton->setIcon(QIcon(":/new/resource/images/process-stop.png")); + ui->connectionButton->setIcon(QIcon(":/images/process-stop.png")); ui->connectionButton->setEnabled(false); blink_timer->start(1500); } else { @@ -591,7 +625,7 @@ void MainWindow::on_connectClicked() VpnInfo* vpninfo = nullptr; StoredServer* ss = new StoredServer(); QFuture future; - QString name, str, url; + QString name, url; QList proxies; QUrl turl; QNetworkProxyQuery query; @@ -627,8 +661,8 @@ void MainWindow::on_connectClicked() vpninfo = new VpnInfo(QString("%1 %2").arg(qApp->applicationName()).arg(qApp->applicationVersion()), ss, this); } catch (std::exception& ex) { QMessageBox::information(this, - qApp->applicationName(), - tr("There was an issue initializing the VPN ") + "(" + ex.what() + ")."); + qApp->applicationName(), + tr("There was an issue initializing the VPN ") + "(" + ex.what() + ")."); goto fail; } @@ -644,22 +678,29 @@ void MainWindow::on_connectClicked() goto fail; } - proxies = QNetworkProxyFactory::systemProxyForQuery(query); - if (proxies.size() > 0 && proxies.at(0).type() != QNetworkProxy::NoProxy) { - if (proxies.at(0).type() == QNetworkProxy::Socks5Proxy) - url = "socks5://"; - else if (proxies.at(0).type() == QNetworkProxy::HttpCachingProxy - || proxies.at(0).type() == QNetworkProxy::HttpProxy) - url = "http://"; + if (ss->get_proxy()) { + proxies = QNetworkProxyFactory::systemProxyForQuery(query); + if (proxies.size() > 0 && proxies.at(0).type() != QNetworkProxy::NoProxy) { + if (proxies.at(0).type() == QNetworkProxy::Socks5Proxy) + url = "socks5://"; + else if (proxies.at(0).type() == QNetworkProxy::HttpCachingProxy + || proxies.at(0).type() == QNetworkProxy::HttpProxy) + url = "http://"; - if (url.isEmpty() == false) { + if (url.isEmpty() == false) { - str = proxies.at(0).user() + ":" + proxies.at(0).password() + "@" + proxies.at(0).hostName(); - if (proxies.at(0).port() != 0) { - str += ":" + QString::number(proxies.at(0).port()); + QString str; + if (proxies.at(0).user() != 0) { + str = proxies.at(0).user() + ":" + proxies.at(0).password() + "@"; + } + str += proxies.at(0).hostName(); + if (proxies.at(0).port() != 0) { + str += ":" + QString::number(proxies.at(0).port()); + } + Logger::instance().addMessage(tr("Setting proxy to: ") + str); + // FIXME: ... + int ret = openconnect_set_http_proxy(vpninfo->vpninfo, str.toLatin1().data()); } - Logger::instance().addMessage(tr("Setting proxy to: ") + str); - openconnect_set_http_proxy(vpninfo->vpninfo, str.toLatin1().data()); } } @@ -681,7 +722,14 @@ void MainWindow::closeEvent(QCloseEvent* event) event->ignore(); } else { event->accept(); - qApp->quit(); + + if (m_disconnectAction->isEnabled()) { + connect(this, &MainWindow::readyToShutdown, + qApp, &QApplication::quit); + on_disconnectClicked(); + } else { + qApp->quit(); + } } QMainWindow::closeEvent(event); } @@ -745,25 +793,25 @@ void MainWindow::writeSettings() void MainWindow::createLogDialog() { - auto dialog{new LogDialog()}; + auto dialog{ new LogDialog() }; disconnect(ui->viewLogButton, &QPushButton::clicked, - this, &MainWindow::createLogDialog); + this, &MainWindow::createLogDialog); connect(ui->viewLogButton, &QPushButton::clicked, - dialog, &QDialog::show); + dialog, &QDialog::show); connect(ui->viewLogButton, &QPushButton::clicked, - dialog, &QDialog::raise); + dialog, &QDialog::raise); connect(ui->viewLogButton, &QPushButton::clicked, - dialog, &QDialog::activateWindow); + dialog, &QDialog::activateWindow); connect(dialog, &QDialog::finished, - [this]() { - connect(ui->viewLogButton, &QPushButton::clicked, + [this]() { + connect(ui->viewLogButton, &QPushButton::clicked, this, &MainWindow::createLogDialog); - }); + }); connect(dialog, &QDialog::finished, - dialog, &QDialog::deleteLater); + dialog, &QDialog::deleteLater); dialog->show(); dialog->raise(); @@ -779,7 +827,7 @@ void MainWindow::createTrayIcon() m_disconnectAction = new QAction(tr("Disconnect"), this); m_trayIconMenu->addAction(m_disconnectAction); connect(m_disconnectAction, &QAction::triggered, - this, &MainWindow::on_disconnectClicked); + this, &MainWindow::on_disconnectClicked); m_trayIconMenu->addSeparator(); m_trayIconMenu->addAction(ui->actionLogWindow); @@ -816,8 +864,8 @@ void MainWindow::on_actionNewProfile_triggered() { NewProfileDialog dialog(this); connect(&dialog, &NewProfileDialog::connect, - this, &MainWindow::on_connectClicked, - Qt::QueuedConnection); + this, &MainWindow::on_connectClicked, + Qt::QueuedConnection); if (dialog.exec() != QDialog::Accepted) { return; } @@ -891,10 +939,10 @@ void MainWindow::on_actionAbout_triggered() txt += tr("

%1
").arg(appCopyright); txt += tr("
%1 comes with ABSOLUTELY NO WARRANTY. This is free software, " "and you are welcome to redistribute it under the conditions " - "of the GNU General Public License version 2.").arg(appDescriptionLong); + "of the GNU General Public License version 2.") + .arg(appDescriptionLong); QMessageBox::about(this, "", txt); - } void MainWindow::on_actionAboutQt_triggered() diff --git a/src/dialog/mainwindow.h b/src/dialog/mainwindow.h index 45aab555..89756fb9 100644 --- a/src/dialog/mainwindow.h +++ b/src/dialog/mainwindow.h @@ -80,7 +80,6 @@ public slots: void request_update_stats(); - void on_connectClicked(); void on_disconnectClicked(); @@ -100,6 +99,7 @@ public slots: void stats_changed_sig(QString, QString, QString); void vpn_status_changed_sig(int); void timeout(void); + void readyToShutdown(); private slots: void createLogDialog(); diff --git a/src/dialog/mainwindow.ui b/src/dialog/mainwindow.ui index d6dd0659..3831da2a 100644 --- a/src/dialog/mainwindow.ui +++ b/src/dialog/mainwindow.ui @@ -33,7 +33,7 @@ - :/new/resource/Resources/mono_lock.png:/new/resource/Resources/mono_lock.png + :/Resources/mono_lock.png:/Resources/mono_lock.png false @@ -67,7 +67,7 @@ false - true + false @@ -123,7 +123,7 @@ - :/new/resource/images/profiles.png:/new/resource/images/profiles.png + :/images/profiles.png:/images/profiles.png QToolButton::InstantPopup @@ -141,7 +141,7 @@ - :/new/resource/images/network-wired.png:/new/resource/images/network-wired.png + :/images/network-wired.png:/images/network-wired.png @@ -152,7 +152,7 @@ - :/new/resource/images/edit-find.png:/new/resource/images/edit-find.png + :/images/edit-find.png:/images/edit-find.png @@ -399,7 +399,7 @@ - :/new/resource/images/text-new.png:/new/resource/images/text-new.png + :/images/text-new.png:/images/text-new.png &New profile @@ -414,7 +414,7 @@ - :/new/resource/images/text-editor.png:/new/resource/images/text-editor.png + :/images/text-editor.png:/images/text-editor.png &Edit selected profile @@ -426,7 +426,7 @@ - :/new/resource/images/trashcan.png:/new/resource/images/trashcan.png + :/images/trashcan.png:/images/trashcan.png &Remove selected profile @@ -438,7 +438,7 @@ - :/new/resource/images/edit-find.png:/new/resource/images/edit-find.png + :/images/edit-find.png:/images/edit-find.png &Log window @@ -496,7 +496,7 @@ - :/new/resource/images/text-new.png:/new/resource/images/text-new.png + :/images/text-new.png:/images/text-new.png New profile (&advanced) diff --git a/src/images/+mac/network-connected.png b/src/images/+mac/network-connected.png new file mode 100644 index 00000000..027d9eee Binary files /dev/null and b/src/images/+mac/network-connected.png differ diff --git a/src/images/+mac/network-disconnected.png b/src/images/+mac/network-disconnected.png new file mode 100644 index 00000000..3aec537e Binary files /dev/null and b/src/images/+mac/network-disconnected.png differ diff --git a/src/logger.cpp b/src/logger.cpp index 547d989b..82343e8b 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -7,16 +7,15 @@ void Logger::addMessage(const QString& message, const MessageType& messageType, { QWriteLocker lock(&m_lock); - Message tmp{QDateTime::currentMSecsSinceEpoch(), - messageType, - componentType, - message, - ++m_messageCounter, - QThread::currentThreadId() - }; + Message tmp{ QDateTime::currentMSecsSinceEpoch(), + messageType, + componentType, + message, + ++m_messageCounter, + QThread::currentThreadId() }; m_messages.push_back(tmp); - if (m_messages.size() >= 20000) {// TODO: magic constant + if (m_messages.size() >= 20000) { // TODO: magic constant m_messages.pop_front(); } @@ -27,8 +26,8 @@ QVector Logger::getMessages(int lastKnownId) const { QReadLocker lock(&m_lock); - int diff{m_messageCounter - lastKnownId}; - int size{m_messages.size()}; + int diff{ m_messageCounter - lastKnownId }; + int size{ m_messages.size() }; if (lastKnownId == -1 || diff >= size) { return m_messages; @@ -47,8 +46,9 @@ void Logger::clear() m_messages.clear(); } -Logger::Logger(QObject *parent) : QObject(parent), - m_messageCounter{-1}, - m_lock{QReadWriteLock::Recursive} +Logger::Logger(QObject* parent) + : QObject(parent) + , m_messageCounter{ -1 } + , m_lock{ QReadWriteLock::Recursive } { } diff --git a/src/logger.h b/src/logger.h index e1805679..1417561d 100644 --- a/src/logger.h +++ b/src/logger.h @@ -1,12 +1,11 @@ #pragma once #include +#include #include #include -#include -class Logger : public QObject -{ +class Logger : public QObject { Q_OBJECT public: @@ -36,25 +35,25 @@ class Logger : public QObject Qt::HANDLE threadId; }; - static Logger& instance() { + static Logger& instance() + { static Logger logger; return logger; } void addMessage(const QString& message, - const MessageType& type = MessageType::NORMAL, - const ComponentType& componentType = ComponentType::UNKNOWN); + const MessageType& type = MessageType::NORMAL, + const ComponentType& componentType = ComponentType::UNKNOWN); QVector getMessages(int lastKnownId = -1) const; void clear(); - signals: void newLogMessage(const Logger::Message& message); public slots: private: - explicit Logger(QObject *parent = nullptr); + explicit Logger(QObject* parent = nullptr); ~Logger() = default; Logger(const Logger&) = delete; Logger& operator=(const Logger&) = delete; @@ -76,4 +75,3 @@ Q_DECLARE_METATYPE(Logger::Message) // os << static_cast::type>(msgType); // return os; //}; - diff --git a/src/main.cpp b/src/main.cpp index 6f7a4445..b2e121a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,8 +24,8 @@ #include "dialog/mainwindow.h" #include "openconnect-gui.h" -#include "logger.h" #include "FileLogger.h" +#include "logger.h" extern "C" { #include @@ -36,13 +36,13 @@ extern "C" { #if !defined(_WIN32) && !defined(PROJ_GNUTLS_DEBUG) #include #endif -#include #include +#include #include #ifdef __MACH__ -#include #include +#include #endif #include @@ -51,9 +51,8 @@ extern "C" { static void log_callback(int level, const char* str) { Logger::instance().addMessage(QString(str).trimmed(), - Logger::MessageType::DEBUG, - Logger::ComponentType::GNUTLS - ); + Logger::MessageType::DEBUG, + Logger::ComponentType::GNUTLS); } #ifdef __MACH__ @@ -67,8 +66,7 @@ bool relaunch_as_root() /* Get the path of the current program */ if (_NSGetExecutablePath(appPath, &size) != 0) { - msgBox.setText(QObject::tr - ("Could not get program path to elevate privileges.")); + msgBox.setText(QObject::tr("Could not get program path to elevate privileges.")); return false; } @@ -76,8 +74,7 @@ bool relaunch_as_root() kAuthorizationFlagDefaults, &authRef); if (status != errAuthorizationSuccess) { - msgBox.setText(QObject::tr - ("Failed to create authorization reference.")); + msgBox.setText(QObject::tr("Failed to create authorization reference.")); return false; } status = AuthorizationExecuteWithPrivileges(authRef, appPath, @@ -148,7 +145,7 @@ int main(int argc, char* argv[]) QCoreApplication::setOrganizationName(appOrganizationName); QCoreApplication::setOrganizationDomain(appOrganizationDomain); - QtSingleApplication app(argc, argv); + QtSingleApplication app(argc, argv); if (app.isRunning()) { QSettings settings; if (settings.value(QLatin1Literal("Settings/singleInstanceMode"), true).toBool()) { @@ -185,21 +182,20 @@ int main(int argc, char* argv[]) QCommandLineParser parser; parser.setApplicationDescription( - QObject::tr("OpenConnect is a VPN client, that utilizes TLS and DTLS " - "for secure session establishment, and is compatible " - "with the CISCO AnyConnect SSL VPN protocol.")); + QObject::tr("OpenConnect is a VPN client, that utilizes TLS and DTLS " + "for secure session establishment, and is compatible " + "with the CISCO AnyConnect SSL VPN protocol.")); parser.addHelpOption(); parser.addVersionOption(); - parser.addOption({ - {"s", "server"}, - QObject::tr("auto-connect to existing profile "), - QObject::tr("name") + parser.addOption({ { "s", "server" }, + QObject::tr("auto-connect to existing profile "), + QObject::tr("name") - }); + }); parser.process(app); - const QString profileName{parser.value(QLatin1String("server"))}; + const QString profileName{ parser.value(QLatin1String("server")) }; MainWindow mainWindow(nullptr, profileName); app.setActivationWindow(&mainWindow); #ifdef PROJ_PKCS11 @@ -212,9 +208,8 @@ int main(int argc, char* argv[]) mainWindow.show(); QObject::connect(&app, &QtSingleApplication::messageReceived, - [&mainWindow](const QString &message) { - Logger::instance().addMessage(message); - } - ); + [&mainWindow](const QString& message) { + Logger::instance().addMessage(message); + }); return app.exec(); } diff --git a/src/openconnect-gui.qrc b/src/openconnect-gui.qrc index 827e7d1a..a346824a 100644 --- a/src/openconnect-gui.qrc +++ b/src/openconnect-gui.qrc @@ -1,5 +1,5 @@ - + images/trashcan.png images/text-editor.png images/network-wired.png @@ -11,6 +11,8 @@ images/traffic_light_off.png images/network-connected.png images/network-disconnected.png + images/+mac/network-connected.png + images/+mac/network-disconnected.png images/profiles.png images/text-new.png Resources/mono_lock.png diff --git a/src/server_storage.cpp b/src/server_storage.cpp index e96701ef..93472ca5 100644 --- a/src/server_storage.cpp +++ b/src/server_storage.cpp @@ -22,15 +22,15 @@ #include #include -const char* const StoredServer::m_vpnProtocol[] = {"anyconnect", "nc"}; +const char* const StoredServer::m_vpnProtocol[] = { "anyconnect", "nc" }; StoredServer::~StoredServer(void) { } -StoredServer::StoredServer() : - m_protocol_id(0), - m_server_hash_algo(0) +StoredServer::StoredServer() + : m_protocol_id(0) + , m_server_hash_algo(0) { set_window(nullptr); } @@ -169,8 +169,10 @@ int StoredServer::load(QString& name) ret = CryptData::decode(this->m_servername, settings.value("password").toByteArray(), this->m_password); - if (ret == false) + if (ret == false) { + m_last_err = "decoding of password failed"; rval = -1; + } } QByteArray data; @@ -190,6 +192,7 @@ int StoredServer::load(QString& name) ret = CryptData::decode(this->m_servername, settings.value("client-key").toByteArray(), str); if (ret == false) { + m_last_err = "decoding of client keyfailed"; rval = -1; } @@ -207,6 +210,7 @@ int StoredServer::load(QString& name) settings.value("token-str").toByteArray(), this->m_token_string); if (ret == false) { + m_last_err = "decoding of OTP token failed"; rval = -1; } diff --git a/src/vpninfo.cpp b/src/vpninfo.cpp index b8358345..e2c2b014 100644 --- a/src/vpninfo.cpp +++ b/src/vpninfo.cpp @@ -20,12 +20,12 @@ #include "vpninfo.h" #include "config.h" #include "dialog/MyCertMsgBox.h" -#include "dialog/MyMsgBox.h" #include "dialog/MyInputDialog.h" +#include "dialog/MyMsgBox.h" #include "dialog/mainwindow.h" #include "gtdb.h" -#include "server_storage.h" #include "logger.h" +#include "server_storage.h" #include @@ -103,10 +103,10 @@ static int process_auth_form(void* privdata, struct oc_auth_form* form) if (select_opt->nr_choices == 1) { openconnect_set_option_value(&select_opt->form, - select_opt->choices[0]->name); + select_opt->choices[0]->name); } else if (gitems.contains(vpn->ss->get_groupname())) { openconnect_set_option_value(&select_opt->form, - vpn->ss->get_groupname().toLatin1().data()); + vpn->ss->get_groupname().toLatin1().data()); } else { { MyInputDialog dialog(vpn->m, @@ -181,6 +181,7 @@ static int process_auth_form(void* privdata, struct oc_auth_form* form) && strcasecmp(opt->name, "username") == 0) { openconnect_set_option_value(opt, vpn->ss->get_username().toLatin1().data()); + empty = 0; continue; } @@ -210,6 +211,7 @@ static int process_auth_form(void* privdata, struct oc_auth_form* form) && strcasecmp(opt->name, "password") == 0) { openconnect_set_option_value(opt, vpn->ss->get_password().toLatin1().data()); + empty = 0; continue; } @@ -285,15 +287,15 @@ static int validate_peer_cert(void* privdata, const char* reason) QString hostInfoStr = QObject::tr("Host: ") + vpn->ss->get_servername() + QObject::tr("\n") + hash; MyCertMsgBox msgBox( - vpn->m, - QObject::tr("You are connecting for the first time to this peer.\n" - "You have no guarantee that the server is the computer you think it is.\n\n" - "If the information provided bellow is valid and you trust this host, " - "hit 'Accurate information' to remember it and to carry on connecting.\n" - "If you do not trust this host, hit Cancel to abandon the connection."), - hostInfoStr, - QObject::tr("Accurate information"), - dstr); + vpn->m, + QObject::tr("You are connecting for the first time to this peer.\n" + "You have no guarantee that the server is the computer you think it is.\n\n" + "If the information provided bellow is valid and you trust this host, " + "hit 'Accurate information' to remember it and to carry on connecting.\n" + "If you do not trust this host, hit Cancel to abandon the connection."), + hostInfoStr, + QObject::tr("Accurate information"), + dstr); msgBox.show(); if (msgBox.result() == false) { return -1; @@ -361,7 +363,7 @@ static int unlock_token_vfn(void* privdata, const char* newtok) return 0; } -static void setup_tun_vfn(void *privdata) +static void setup_tun_vfn(void* privdata) { VpnInfo* vpn = static_cast(privdata); @@ -372,7 +374,7 @@ static void setup_tun_vfn(void *privdata) int ret = openconnect_setup_tun_device(vpn->vpninfo, vpncScriptFullPath.constData(), NULL); if (ret != 0) { vpn->last_err = QObject::tr("Error setting up the TUN device"); -//FIXME: ??? return ret; + //FIXME: ??? return ret; } vpn->logVpncScriptOutput(); @@ -463,9 +465,9 @@ int VpnInfo::connect() } #ifdef Q_OS_WIN32 - const QString osName{"win"}; + const QString osName{ "win" }; #elif defined Q_OS_OSX - const QString osName{"mac-intel"}; + const QString osName{ "mac-intel" }; #elif defined Q_OS_LINUX const QString osName = QString("linux%1").arg(QSysInfo::buildCpuArchitecture() == "i386" ? "" : "-64").toStdString().c_str(); #elif defined Q_OS_FREEBSD @@ -494,7 +496,7 @@ int VpnInfo::dtls_connect() { if (this->ss->get_disable_udp() != true) { int ret = openconnect_setup_dtls(vpninfo, - ss->get_dtls_reconnect_timeout()); + ss->get_dtls_reconnect_timeout()); if (ret != 0) { this->last_err = QObject::tr("Error setting up DTLS"); return ret; @@ -508,8 +510,8 @@ void VpnInfo::mainloop() { while (true) { int ret = openconnect_mainloop(vpninfo, - ss->get_reconnect_timeout(), - RECONNECT_INTERVAL_MIN); + ss->get_reconnect_timeout(), + RECONNECT_INTERVAL_MIN); if (ret != 0) { this->last_err = QObject::tr("Disconnected"); logVpncScriptOutput(); @@ -594,7 +596,7 @@ void VpnInfo::logVpncScriptOutput() bool processBannerMessage = false; while (!in.atEnd()) { - const QString line{in.readLine()}; + const QString line{ in.readLine() }; Logger::instance().addMessage(line); if (line == QLatin1String("--------------------- BANNER ---------------------")) { diff --git a/src/vpninfo.h b/src/vpninfo.h index 27cb1665..49d7dede 100644 --- a/src/vpninfo.h +++ b/src/vpninfo.h @@ -57,6 +57,7 @@ class VpnInfo { unsigned int form_pass_attempt; void logVpncScriptOutput(); + private: SOCKET cmd_fd; };