Simplify compile options and use comprehensive edition logic (#7365)

* Simplify options

* Use more sensible edition logic

* Use set instead of option for string

* Improve macro for product name

* Add tests launch config

* Restore unregistered state

* Reorganize cases for title and improve function name

* Code coverage on by default

* Fixed copyright

* Improve code coverage and test readability

* Separate build-all and build-coverage

* Back out coverage on by default

* Fixed bad var in cmake

* More verbose logging for coverage

* Restore tasks

* Restore preLaunchTask

* Use default comparitor

* Move temp files to temp dir

* Add tasks for tests

* Support for wstring

* Upgrade sonar-scanner to 6 on Debian 12

* Use modern pip install

* Install python for sonarcloud

* Use Ubuntu and install deps

* Fixed sonar-scanner URL

* Fix exported dir

* Persist build dir

* Don't use venv for pip install gcovr

* Fixed another path

* Update actions/checkout to v4 for SonarCloud analysis workflow

* Add coverage task

* Improve coverage for SerialKeyEdition.cpp

* Enable licensing for builds

* Fixed invalid macro names, missing arguments, etc

* Fixed more copyright

* Fixed incorrect use of "enterprise"

* Fixed incorrect use of "business"

* Experiment with environment

* Make package prefix variable

* Add environment matrix to all OS

* Improve job names

* Make job names easier to read

* Roll back environment matrix (too much noise)

* Fixed: default should override required

* Refactor CI with vars

* Fixed arg for env.get_env
This commit is contained in:
Nick Bolton
2024-07-04 10:14:54 +01:00
committed by GitHub
parent 37bb0f989e
commit 4690b61551
46 changed files with 533 additions and 487 deletions

View File

@ -23,6 +23,9 @@ on:
env:
SYNERGY_VERSION: ${{ github.event.inputs.version || github.event.release.tag_name }}
SYNERGY_PRODUCT_NAME: ${{ vars.SYNERGY_PRODUCT_NAME }}
SYNERGY_PACKAGE_PREFIX: ${{ vars.SYNERGY_PACKAGE_PREFIX }}
SYNERGY_ENABLE_LICENSING: ${{ vars.SYNERGY_ENABLE_LICENSING }}
PACKAGE_BUILD: ${{ !github.event.pull_request.draft }}
PACKAGE_UPLOAD: ${{ !github.event.pull_request.draft && github.event_name != 'schedule' }}
UPLOAD_TO_GITHUB: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }}
@ -30,13 +33,20 @@ env:
jobs:
windows:
name: windows-2022
runs-on: windows-2022
name: ${{ matrix.target.name }}
runs-on: ${{ matrix.target.runs-on }}
timeout-minutes: 20
env:
QT_BASE_DIR: ${{ github.workspace }}\deps\Qt
strategy:
matrix:
target:
- name: windows-2022
runs-on: windows-2022
arch: x64
steps:
- name: Checkout
uses: actions/checkout@v4
@ -75,48 +85,48 @@ jobs:
run: ./build/bin/unittests
- name: Package
if: ${{ env.PACKAGE_BUILD == 'true' }}
if: ${{ vars.SYNERGY_ENABLE_PACKAGING && env.PACKAGE_BUILD == 'true' }}
run: python ./scripts/package.py
env:
WINDOWS_PFX_CERTIFICATE: ${{ secrets.WINDOWS_PFX }}
WINDOWS_PFX_PASSWORD: ${{ secrets.WINDOWS_PFX_PASS }}
- name: Upload
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
if: ${{ vars.SYNERGY_ENABLE_PACKAGING && env.PACKAGE_UPLOAD == 'true' }}
uses: ./.github/actions/dist-upload
with:
use_github: ${{ env.UPLOAD_TO_GITHUB }}
use_gdrive: ${{ env.UPLOAD_TO_GDRIVE }}
github-target-filename: "synergy-windows-x64"
gdrive-target-base-dir: "synergy1/personal"
github-target-filename: "${{ env.SYNERGY_PACKAGE_PREFIX }}-windows-${{ matrix.target.name }}"
gdrive-target-base-dir: ${{ vars.GDRIVE_TARGET_BASE_DIR }}
gdrive-secret-key: ${{ secrets.GOOGLE_DRIVE_KEY }}
gdrive-parent-folder-id: ${{ secrets.GOOGLE_DRIVE_TECH_DRIVE }}
package-version: ${{ env.SYNERGY_VERSION }}
macos:
runs-on: ${{ matrix.runtime.os }}
timeout-minutes: ${{ matrix.runtime.timeout }}
name: ${{ matrix.runtime.name }}
name: ${{ matrix.target.name }}
runs-on: ${{ matrix.target.os }}
timeout-minutes: ${{ matrix.target.timeout }}
defaults:
run:
shell: ${{ matrix.runtime.shell }}
shell: ${{ matrix.target.shell }}
strategy:
matrix:
runtime:
target:
- name: "macos-11-arm64"
timeout: 10
os: "macos-14"
arch: arm64
target: "11"
version: "11"
shell: "/usr/bin/arch -arch arm64e /bin/bash --noprofile --norc -eo pipefail {0}"
- name: "macos-10-intel"
timeout: 20
os: "macos-14-large"
arch: x64
target: "10.14"
version: "10.14"
shell: "bash"
steps:
@ -130,7 +140,7 @@ jobs:
- name: Configure
env:
CMAKE_OSX_DEPLOYMENT_TARGET: ${{ matrix.runtime.target }}
CMAKE_OSX_DEPLOYMENT_TARGET: ${{ matrix.target.version }}
run: cmake -B build --preset=macos-release -DCMAKE_PREFIX_PATH=$(brew --prefix qt@5)
- name: Build
@ -140,7 +150,7 @@ jobs:
run: ./build/bin/unittests
- name: Package
if: ${{ env.PACKAGE_BUILD == 'true' }}
if: ${{ vars.SYNERGY_ENABLE_PACKAGING && env.PACKAGE_BUILD == 'true' }}
run: ./scripts/package.py
env:
APPLE_CODESIGN_ID: ${{ secrets.APPLE_CODESIGN_ID }}
@ -151,21 +161,21 @@ jobs:
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
- name: Upload
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
if: ${{ vars.SYNERGY_ENABLE_PACKAGING && env.PACKAGE_UPLOAD == 'true' }}
uses: ./.github/actions/dist-upload
with:
use_github: ${{ env.UPLOAD_TO_GITHUB }}
use_gdrive: ${{ env.UPLOAD_TO_GDRIVE }}
github-target-filename: "synergy-${{ matrix.runtime.name }}"
gdrive-target-base-dir: "synergy1/personal"
github-target-filename: "${{ env.SYNERGY_PACKAGE_PREFIX }}-${{ matrix.target.name }}"
gdrive-target-base-dir: ${{ vars.GDRIVE_TARGET_BASE_DIR }}
gdrive-secret-key: ${{ secrets.GOOGLE_DRIVE_KEY }}
gdrive-parent-folder-id: ${{ secrets.GOOGLE_DRIVE_TECH_DRIVE }}
package-version: ${{ env.SYNERGY_VERSION }}
linux:
name: linux-${{ matrix.distro.name }}
runs-on: ${{ matrix.distro.runs-on }}
timeout-minutes: 10
name: linux-${{ matrix.distro.name }}
container: ${{ matrix.distro.container }}
env:
@ -265,20 +275,20 @@ jobs:
run: ./build/bin/unittests
- name: Package
if: ${{ env.PACKAGE_BUILD == 'true' }}
if: ${{ vars.SYNERGY_ENABLE_PACKAGING && env.PACKAGE_BUILD == 'true' }}
env:
LINUX_EXTRA_PACKAGES: ${{ matrix.distro.extra-packages }}
LINUX_PACKAGE_USER: ${{ matrix.distro.package-user }}
run: ./scripts/package.py
- name: Upload
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
if: ${{ vars.SYNERGY_ENABLE_PACKAGING && env.PACKAGE_UPLOAD == 'true' }}
uses: ./.github/actions/dist-upload
with:
use_github: ${{ env.UPLOAD_TO_GITHUB }}
use_gdrive: ${{ env.UPLOAD_TO_GDRIVE }}
github-target-filename: "synergy-${{ matrix.distro.name }}"
gdrive-target-base-dir: "synergy1/personal"
github-target-filename: "${{ env.SYNERGY_PACKAGE_PREFIX }}-${{ matrix.distro.name }}"
gdrive-target-base-dir: ${{ vars.GDRIVE_TARGET_BASE_DIR }}
gdrive-secret-key: ${{ secrets.GOOGLE_DRIVE_KEY }}
gdrive-parent-folder-id: ${{ secrets.GOOGLE_DRIVE_TECH_DRIVE }}
package-version: ${{ env.SYNERGY_VERSION }}

View File

@ -12,33 +12,35 @@ concurrency:
jobs:
sonarcloud-analysis:
if: ${{ vars.SONAR_SCANNER_ENABLED }}
runs-on: ubuntu-latest
container: symless/synergy-core:debian10
timeout-minutes: 20
env:
SONAR_SCANNER_VERSION: 5.0.1.3006
SONAR_SCANNER_VERSION: 6.1.0.4477
SONAR_SCANNER_OPTS: -server
SONAR_SCANNER_URL_BASE: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Installing gcovr
run: |
apt-get update
apt-get install -y python python-pip
pip install gcovr
- name: Install dependencies
run: ./scripts/install_deps.py
- name: Installing Sonar Scanner
- name: Install gcovr
run: pip install gcovr
- name: Install SonarScanner
run: |
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip \
$SONAR_SCANNER_URL_BASE/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- name: Installing build-wrapper
- name: Install build-wrapper
run: |
curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
@ -46,19 +48,19 @@ jobs:
- name: Build
run: |
export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH
mkdir build
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
build-wrapper-linux-x86-64 --out-dir bw-output make -j
- name: Running coverage
- name: Make coverage
run: |
cd build
make coverage
- name: Run Sonar Scanner
- name: Run SonarScanner
run: |
export PATH=$HOME/.sonar/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin:$PATH
export PATH=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64/bin:$PATH
cd build
sonar-scanner \
-Dsonar.organization=symless \

View File

@ -5,6 +5,7 @@
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cpptools",
"vadimcn.vscode-lldb",
"cheshirekow.cmake-format"
"cheshirekow.cmake-format",
"jacqueslucke.gcov-viewer"
]
}

14
.vscode/launch.json vendored
View File

@ -8,6 +8,20 @@
"program": "${workspaceFolder}/build/bin/synergy",
"preLaunchTask": "build"
},
{
"name": "unittests lldb",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/bin/unittests",
"preLaunchTask": "build"
},
{
"name": "integtests lldb",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/build/bin/integtests",
"preLaunchTask": "build"
},
{
"name": "win daemon attach",
"type": "cppvsdbg",

20
.vscode/tasks.json vendored
View File

@ -12,11 +12,31 @@
"isDefault": true
}
},
{
"type": "cmake",
"label": "coverage",
"command": "build",
"targets": ["coverage"],
"preset": "${command:cmake.activeBuildPresetName}",
"group": "build"
},
{
"label": "reinstall windows daemon",
"type": "shell",
"command": "python scripts/windows_daemon.py",
"dependsOn": ["build"]
},
{
"label": "unittests",
"type": "shell",
"command": "./build/bin/unittests",
"dependsOn": ["build"]
},
{
"label": "integtests",
"type": "shell",
"command": "./build/bin/integtests",
"dependsOn": ["build"]
}
]
}

View File

@ -69,7 +69,7 @@ Enhancements:
- #7190 Maintenance license serial key support
- #7193 Support for maintenance licenses in China
- #7197 Special contributor mentions on the about screen
- #7203 License registration for Business edition
- #7203 License registration for more editions
- #7210 Update macos workflow to use macos-latest
- #7213 Update azure pipelines to use macos-latest
@ -87,8 +87,8 @@ Bug fixes:
Enhancements:
- #7143 Ability to stop Synergy on the login screen
- #7157 Synergy Business accepts only business licenses
- #7188 Synergy Basic\Pro accepts business licenses
- #7157 Only accept correct license for specific edition
- #7188 Only accept correct license for personal edition
- #7166 Replace language notifications with warnings in logs
- #7181 Fedora 36 support to CI system
- #7177 Create workflow for flatpak build support
@ -127,7 +127,7 @@ Bug fixes:
- #7096 The system duplicates hotkeys in setup
- #7099 Compilation broken with msvc 2014
- #7100 No configuration available on Windows
- #7097 The title "Enterprise" disappeares after clicking on "Preferences"
- #7097 Title disappeares after clicking on "Preferences"
- #7108 Wrong characters on client for unicode
- #7114 Problem with reading languages on Linux system
- #7115 Prevent notifications if language reading fails
@ -279,9 +279,9 @@ Bug fixes:
- #6831 Incorporating Sonar's major
- #6837 Memory leaks on macOS system
- #6838 Enterprise asks for serial key on Linux system
- #6838 Serial key requested by mistake
- #6849 Auto-hide resets itself
- #6846 TLS certificate is not created by default for Synergy Enterprise.
- #6846 TLS certificate is not created by default
- #6859 Systray Icon on Ubuntu Auto Start
- #6863 Adding MacOS CI Build Steps for Homebrew Cleanup
@ -307,7 +307,7 @@ Bug fixes:
- #6804 Synergy loses edition when creating a System scope config
- #6660 + #6582 Add missing XAtom for utf-8 handling with Xorg
- #6814 The system asks to save twice.
- #6817 Configure requires dns_sd.h for enterprise version
- #6817 Configure requires dns_sd.h
- #6826 + #6829 SonarCloud Critical bugs
- #6821 Blocker bugs found by sonar in synergy and in tests
- #6825 The system requires google test even when tests are disabled with BUILD_TESTS=OFF
@ -318,7 +318,7 @@ Enhancements:
- #6750 Integrate SonarCloud for static analysis and test coverage
- #6792 License key expiry
- #6799 Synergy "Business" edition
- #6799 New edition
- #6803 Update Synergy icons
- #6800 Update behaviour when unregistered
- #6806 Move to Github Action for general PR builds and tests
@ -430,7 +430,7 @@ Bug fixes:
- #6495 Event queue memory leak in server cleanup
- #6471 Unable to stop core retry loop in config app
- #6460 TLS memory leak on Linux server when using client
- #6407 Enterprise config app shows auto-config elements
- #6407 Config app shows auto-config elements
- #6403 Mouse cursor movement drifts over time
- #6392 Hostname alert shows unnecessarily on every open
- #6373 Compile fails on BSD Unix with dl error
@ -479,7 +479,7 @@ Enhancements:
- #6312 Removal of redundant CURL library
- #6306 Show version number in config app title
- #6305 Support for Raspbian in package config
- #6301 Combine enterprise and community codebases
- #6301 Combine codebases for all editions
# 1.9.1

View File

@ -22,28 +22,37 @@ macro(configure_definitions)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(PRODUCT_NAME "Synergy 1 Community Edition")
if(DEFINED $ENV{SYNERGY_PRODUCT_NAME})
message(STATUS "Product name: $ENV{SYNERGY_PRODUCT_NAME}")
set(PRODUCT_NAME $ENV{SYNERGY_PRODUCT_NAME})
endif()
add_definitions(-DSYNERGY_PRODUCT_NAME="${PRODUCT_NAME}")
configure_ninja()
configure_options()
if(SYNERGY_ENTERPRISE)
add_definitions(-DSYNERGY_ENTERPRISE=1)
if(ENABLE_LICENSING)
message(STATUS "Licensing enabled")
add_definitions(-DSYNERGY_ENABLE_LICENSING=1)
endif()
if(SYNERGY_BUSINESS)
add_definitions(-DSYNERGY_BUSINESS=1)
if(ENABLE_AUTO_CONFIG)
message(STATUS "Auto config enabled")
add_definitions(-DSYNERGY_ENABLE_AUTO_CONFIG=1)
endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Disabling debug build")
add_definitions(-DNDEBUG)
endif()
# TODO: Find out why we need these, and remove them if we don't
# TODO: find out why we need these, and remove them if we don't
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0005 NEW)
endif()
# Add headers to source list
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
set(SYNERGY_ADD_HEADERS FALSE)
else()
@ -64,36 +73,49 @@ macro(configure_ninja)
endmacro()
macro(configure_options)
if(DEFINED ENV{SYNERGY_BUILD_MINIMAL})
option(SYNERGY_BUILD_GUI "Build the GUI" OFF)
option(SYNERGY_BUILD_INSTALLER "Build the installer" OFF)
else()
option(SYNERGY_BUILD_GUI "Build the GUI" ON)
option(SYNERGY_BUILD_INSTALLER "Build the installer" ON)
set(DEFAULT_BUILD_GUI ON)
set(DEFAULT_BUILD_INSTALLER ON)
set(DEFAULT_BUILD_TESTS ON)
# unified binary is off by default for now, for backwards compatibility.
set(DEFAULT_BUILD_UNIFIED OFF)
# coverage is off by default because it's GCC only and a developer preference.
set(DEFAULT_ENABLE_COVERAGE OFF)
# licensing is off by default to make life easier for contributors.
set(DEFAULT_ENABLE_LICENSING OFF)
if(DEFINED $ENV{SYNERGY_BUILD_MINIMAL})
set(DEFAULT_BUILD_GUI OFF)
set(DEFAULT_BUILD_INSTALLER OFF)
endif()
if(DEFINED ENV{SYNERGY_NO_TESTS})
option(BUILD_TESTS "Override building of tests" OFF)
else()
option(BUILD_TESTS "Override building of tests" ON)
option(ENABLE_COVERAGE "Build with coverage")
if(DEFINED $ENV{SYNERGY_NO_TESTS})
set(DEFAULT_BUILD_TESTS OFF)
endif()
if(DEFINED ENV{SYNERGY_UNIFIED_CORE})
option(UNIFIED_CORE "Build a single core binary" ON)
else()
option(UNIFIED_CORE "Build a single core binary" OFF)
if(DEFINED $ENV{SYNERGY_BUILD_UNIFIED})
set(DEFAULT_BUILD_UNIFIED ON)
endif()
if($ENV{SYNERGY_ENTERPRISE})
option(SYNERGY_ENTERPRISE "Build Enterprise" ON)
else()
option(SYNERGY_ENTERPRISE "Build Enterprise" OFF)
if(DEFINED $ENV{SYNERGY_ENABLE_LICENSING})
set(DEFAULT_ENABLE_LICENSING ON)
endif()
if($ENV{SYNERGY_BUSINESS})
option(SYNERGY_BUSINESS "Build Business" ON)
else()
option(SYNERGY_BUSINESS "Build Business" OFF)
if(DEFINED $ENV{SYNERGY_ENABLE_COVERAGE})
set(DEFAULT_ENABLE_COVERAGE ON)
endif()
option(BUILD_GUI "Build GUI" ${DEFAULT_BUILD_GUI})
option(BUILD_INSTALLER "Build installer" ${DEFAULT_BUILD_INSTALLER})
option(BUILD_TESTS "Build tests" ${DEFAULT_BUILD_TESTS})
option(BUILD_UNIFIED "Build unified binary" ${DEFAULT_BUILD_UNIFIED})
option(ENABLE_LICENSING "Enable licensing" ${DEFAULT_ENABLE_LICENSING})
option(ENABLE_COVERAGE "Enable test coverage" ${DEFAULT_ENABLE_COVERAGE})
# auto config is off by default because it requires bonjour, which sucks.
option(ENABLE_AUTO_CONFIG "Enable auto config (zeroconf)" OFF)
endmacro()

View File

@ -326,6 +326,7 @@ macro(configure_test_libs)
endif()
if(ENABLE_COVERAGE)
message(STATUS "Enabling code coverage")
include(cmake/CodeCoverage.cmake)
append_coverage_compiler_flags()
setup_target_for_coverage_gcovr_xml(
@ -337,6 +338,8 @@ macro(configure_test_libs)
"${PROJECT_SOURCE_DIR}/src"
EXCLUDE
"ext/*")
else()
message(STATUS "Code coverage is disabled")
endif()
include_directories(BEFORE SYSTEM

View File

@ -19,7 +19,7 @@
#
macro(configure_packaging)
if(${SYNERGY_BUILD_INSTALLER})
if(${BUILD_INSTALLER})
set(CPACK_PACKAGE_NAME "synergy")
set(CPACK_PACKAGE_CONTACT "Synergy <support@symless.com>")
set(CPACK_PACKAGE_DESCRIPTION "Mouse and keyboard sharing utility")

View File

@ -1,45 +0,0 @@
app-id: com.symless.Synergy
runtime: org.kde.Platform
runtime-version: "5.15-21.08"
sdk: org.kde.Sdk
rename-icon: synergy
rename-desktop-file: synergy.desktop
build-options:
env:
SYNERGY_BUSINESS: "1"
modules:
- name: openssl
buildsystem: simple
build-commands:
- "./config --prefix=/var/run/host/usr/local/ssl"
- "make"
- "make install_sw"
sources:
- type: archive
url: https://github.com/openssl/openssl/archive/OpenSSL_1_1_1n.tar.gz
sha256: 6b2d2440ced8c802aaa61475919f0870ec556694c466ebea460e35ea2b14839e
- name: libnotify
buildsystem: meson
config-opts:
- "-Dman=false"
- "-Dgtk_doc=false"
sources:
- type: git
url: https://gitlab.gnome.org/GNOME/libnotify.git
- name: synergy
buildsystem: cmake-ninja
config-opts:
- "-DCMAKE_BUILD_TYPE=Release"
sources:
- type: dir
path: ../
- type: patch
path: flatpak-desktop.patch
command: synergy
finish-args:
- "--share=ipc"
- "--socket=x11"
- "--share=network"
- "--device=dri"
- "--talk-name=org.a11y.*"
- "--filesystem=host"

View File

@ -1,45 +0,0 @@
app-id: com.symless.Synergy
runtime: org.kde.Platform
runtime-version: "5.15-21.08"
sdk: org.kde.Sdk
rename-icon: synergy
rename-desktop-file: synergy.desktop
build-options:
env:
SYNERGY_ENTERPRISE: "1"
modules:
- name: openssl
buildsystem: simple
build-commands:
- "./config --prefix=/var/run/host/usr/local/ssl"
- "make"
- "make install_sw"
sources:
- type: archive
url: https://github.com/openssl/openssl/archive/OpenSSL_1_1_1n.tar.gz
sha256: 6b2d2440ced8c802aaa61475919f0870ec556694c466ebea460e35ea2b14839e
- name: libnotify
buildsystem: meson
config-opts:
- "-Dman=false"
- "-Dgtk_doc=false"
sources:
- type: git
url: https://gitlab.gnome.org/GNOME/libnotify.git
- name: synergy
buildsystem: cmake-ninja
config-opts:
- "-DCMAKE_BUILD_TYPE=Release"
sources:
- type: dir
path: ../
- type: patch
path: flatpak-desktop.patch
command: synergy
finish-args:
- "--share=ipc"
- "--socket=x11"
- "--share=network"
- "--device=dri"
- "--talk-name=org.a11y.*"
- "--filesystem=host"

View File

@ -62,14 +62,21 @@ def get_linux_distro():
return name, name_like, version
def get_env(name, required=True):
"""Returns an env var (stripped) or optionally raises an error if not set."""
def get_env(name, required=True, default=None):
"""
Returns an env var (stripped) or optionally raises an error if not set.
If `default` is set, it will be returned even if `required` is True.
"""
value = os.getenv(name)
if value:
value = value.strip()
if required and not value:
raise ValueError(f"Required env var not set: {name}")
if not value:
if default:
return default
elif required:
raise ValueError(f"Required env var not set: {name}")
return value

View File

@ -7,7 +7,7 @@ from lib.certificate import Certificate
cmake_env_var = "CMAKE_PREFIX_PATH"
shell_rc = "~/.zshrc"
dist_dir = "dist"
product_name = "Synergy"
product_name = "Synergy 1"
settings_file = "res/dist/macos/dmgbuild/settings.py"
app_path = "build/bundle/Synergy.app"
security_path = "/usr/bin/security"

View File

@ -4,7 +4,7 @@ import platform
import lib.env as env
env_file = ".env"
package_name = "synergy"
default_package_prefix = "synergy"
def main():
@ -32,6 +32,8 @@ def main():
def get_filename_base(version, use_linux_distro=True):
os = env.get_os()
machine = platform.machine().lower()
package_base = env.get_env("SYNERGY_PACKAGE_PREFIX", default=default_package_prefix)
if os == "linux" and use_linux_distro:
distro_name, _distro_like, distro_version = env.get_linux_distro()
if not distro_name:
@ -43,9 +45,9 @@ def get_filename_base(version, use_linux_distro=True):
else:
distro = distro_name
return f"{package_name}-{distro}-{machine}-{version}"
return f"{package_base}-{distro}-{machine}-{version}"
else:
return f"{package_name}-{os}-{machine}-{version}"
return f"{package_base}-{os}-{machine}-{version}"
def windows_package(filename_base):

View File

@ -19,9 +19,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/lib)
add_subdirectory(lib)
add_subdirectory(cmd)
if(SYNERGY_BUILD_GUI)
if(BUILD_GUI)
add_subdirectory(gui)
endif(SYNERGY_BUILD_GUI)
endif(BUILD_GUI)
if(BUILD_TESTS)
add_subdirectory(test)

View File

@ -15,10 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(synergyd)
if(UNIFIED_CORE)
if(BUILD_UNIFIED)
add_subdirectory(synergy-core)
else()
add_subdirectory(synergyc)
add_subdirectory(synergys)
endif(UNIFIED_CORE)
endif(BUILD_UNIFIED)
add_subdirectory(syntool)

View File

@ -32,7 +32,7 @@ get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}")
find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${_qt_bin_dir}")
if(SYNERGY_ENTERPRISE)
if(NOT ENABLE_LICENSING)
list(REMOVE_ITEM GUI_SOURCE_FILES ${ACTIVATION_FILES})
list(REMOVE_ITEM GUI_UI_FILES ${ACTIVATION_FILES})
endif()

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015 Synergy Seamless Inc.
* Copyright (C) 2015 Synergy Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015 Synergy Seamless Inc.
* Copyright (C) 2015 Synergy Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -171,10 +171,9 @@ const QString &AppConfig::language() const { return m_Language; }
bool AppConfig::startedBefore() const { return m_StartedBefore; }
bool AppConfig::autoConfig() const {
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef ENABLE_AUTO_CONFIG
return m_AutoConfig;
#else
// always disable auto config for enterprise edition.
return false;
#endif
}
@ -319,7 +318,7 @@ void AppConfig::saveSettings() {
m_unsavedChanges = false;
}
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
bool AppConfig::activationHasRun() const { return m_ActivationHasRun; }
AppConfig &AppConfig::activationHasRun(bool value) {
@ -378,7 +377,7 @@ void AppConfig::setAutoConfigServer(const QString &autoConfigServer) {
setSettingModified(m_AutoConfigServer, autoConfigServer);
}
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
void AppConfig::setEdition(Edition e) {
setSettingModified(m_Edition, e);
setCommonSetting(kEditionSetting, m_Edition);
@ -422,10 +421,10 @@ void AppConfig::setCryptoEnabled(bool newValue) {
bool AppConfig::isCryptoAvailable() const {
bool result{true};
#if !defined(SYNERGY_ENTERPRISE) && !defined(SYNERGY_BUSINESS)
result = (edition() == kPro || edition() == kPro_China ||
#ifdef SYNERGY_ENABLE_LICENSING
result = (edition() == kPro || edition() == kProChina ||
edition() == kBusiness || edition() == kUltimate);
#endif
#endif // SYNERGY_ENABLE_LICENSING
return result;
}

View File

@ -85,7 +85,8 @@ public:
void setAutoConfig(bool autoConfig);
QString autoConfigServer() const;
void setAutoConfigServer(const QString &autoConfigServer);
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
void setEdition(Edition);
Edition edition() const;
void setSerialKey(const QString &serial);
@ -124,7 +125,7 @@ public:
bool getClientHostMode() const;
bool getServerClientMode() const;
bool getInitiateConnectionFromServer() const;
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
bool activationHasRun() const;
AppConfig &activationHasRun(bool value);
#endif

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015 Synergy Seamless Inc.
* Copyright (C) 2015 Synergy Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -53,12 +53,11 @@ void checkSerialKey(const SerialKey &serialKey, bool acceptExpired) {
throw std::runtime_error("Serial key expired");
}
#ifdef SYNERGY_BUSINESS
#ifdef SYNERGY_ENABLE_LICENSING
if (!serialKey.isValid()) {
throw std::runtime_error("The serial key is not compatible with the "
"business version of Synergy.");
throw std::runtime_error("The serial key is not valid.");
}
#endif
#endif // SYNERGY_ENABLE_LICENSING
}
} // namespace
@ -136,7 +135,7 @@ void LicenseManager::skipActivation() const {
QString LicenseManager::getEditionName(Edition const edition, bool trial) {
SerialKeyEdition KeyEdition(edition);
std::string name = KeyEdition.getDisplayName();
std::string name = KeyEdition.getProductName();
if (trial) {
name += " (Trial)";

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015 Synergy Seamless Inc.
* Copyright (C) 2015 Synergy Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2022 Synergy Seamless Inc.
* Copyright (C) 2022 Synergy Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2022 Synergy Seamless Inc.
* Copyright (C) 2022 Synergy Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -85,13 +85,13 @@ static const char *synergyDefaultIconFiles[] = {
":/res/icons/16x16/synergy-disconnected.png" // synergyPendingRetry
};
#ifdef SYNERGY_ENTERPRISE
MainWindow::MainWindow(AppConfig &appConfig)
#else
#ifdef SYNERGY_ENABLE_LICENSING
MainWindow::MainWindow(AppConfig &appConfig, LicenseManager &licenseManager)
#else
MainWindow::MainWindow(AppConfig &appConfig)
#endif
:
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
m_LicenseManager(&licenseManager), m_ActivationDialogRunning(false),
#endif
m_pZeroconf(nullptr), m_AppConfig(&appConfig), m_pSynergy(NULL),
@ -101,7 +101,7 @@ MainWindow::MainWindow(AppConfig &appConfig, LicenseManager &licenseManager)
m_pMenuWindow(NULL), m_pMenuHelp(NULL), m_pCancelButton(NULL),
m_ExpectedRunningState(kStopped), m_SecureSocket(false),
m_serverConnection(*this), m_clientConnection(*this) {
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
m_pZeroconf = new Zeroconf(this);
#endif
@ -157,7 +157,7 @@ MainWindow::MainWindow(AppConfig &appConfig, LicenseManager &licenseManager)
connect(this, SIGNAL(windowShown()), this, SLOT(on_windowShown()),
Qt::QueuedConnection);
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
connect(m_LicenseManager, SIGNAL(editionChanged(Edition)), this,
SLOT(setEdition(Edition)), Qt::QueuedConnection);
@ -179,16 +179,17 @@ MainWindow::MainWindow(AppConfig &appConfig, LicenseManager &licenseManager)
QString lastVersion = m_AppConfig->lastVersion();
if (lastVersion != SYNERGY_VERSION) {
m_AppConfig->setLastVersion(SYNERGY_VERSION);
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
m_LicenseManager->notifyUpdate(lastVersion, SYNERGY_VERSION);
#endif
}
#ifdef SYNERGY_ENTERPRISE
#ifndef SYNERGY_ENABLE_LICENSING
m_pActivate->setVisible(false);
#endif
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
updateZeroconfService();
addZeroconfServer(m_AppConfig->autoConfigServer());
@ -209,7 +210,7 @@ MainWindow::~MainWindow() {
}
}
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
delete m_pZeroconf;
#endif
}
@ -316,7 +317,7 @@ void MainWindow::saveSettings() {
}
void MainWindow::zeroConfToggled() {
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
updateZeroconfService();
addZeroconfServer(m_AppConfig->autoConfigServer());
@ -438,7 +439,7 @@ void MainWindow::updateFromLogLine(const QString &line) {
checkOSXNotification(line);
#endif
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
checkLicense(line);
#endif
}
@ -475,7 +476,7 @@ void MainWindow::checkConnected(const QString &line) {
}
}
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
void MainWindow::checkLicense(const QString &line) {
if (line.contains("trial has expired")) {
licenseManager().refresh();
@ -589,7 +590,7 @@ void MainWindow::startSynergy() {
requestOSXNotificationPermission();
#endif
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
SerialKey serialKey = m_LicenseManager->serialKey();
if (!serialKey.isValid()) {
if (QDialog::Rejected == raiseActivationDialog()) {
@ -764,7 +765,7 @@ bool MainWindow::clientArgs(QStringList &args, QString &app) {
args << "--invert-scroll";
}
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
// check auto config first, if it is disabled or no server detected,
// use line edit host name if it is not empty
if (appConfig().autoConfig()) {
@ -784,7 +785,7 @@ bool MainWindow::clientArgs(QStringList &args, QString &app) {
if (m_pLineEditHostname->text().isEmpty() &&
!appConfig().getClientHostMode()) {
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
// check if autoconfig mode is enabled
if (!appConfig().autoConfig()) {
#endif
@ -794,7 +795,7 @@ bool MainWindow::clientArgs(QStringList &args, QString &app) {
"client to connect to."));
return false;
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
} else {
return false;
}
@ -917,7 +918,7 @@ bool MainWindow::serverArgs(QStringList &args, QString &app) {
args << "-c" << configFilename << "--address" << address();
appendLogInfo("config file: " + configFilename);
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
if (!appConfig().serialKey().isEmpty()) {
args << "--serial-key" << appConfig().serialKey();
}
@ -1134,12 +1135,12 @@ void MainWindow::addZeroconfServer(const QString name) {
}
void MainWindow::setEdition(Edition edition) {
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
setWindowTitle(m_LicenseManager->getEditionName(edition));
#endif
}
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
void MainWindow::InvalidLicense() {
stopSynergy();
m_AppConfig->activationHasRun(false);
@ -1166,7 +1167,7 @@ void MainWindow::updateLocalFingerprint() {
}
}
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
LicenseManager &MainWindow::licenseManager() const { return *m_LicenseManager; }
#endif
@ -1184,18 +1185,8 @@ bool MainWindow::on_m_pActionSave_triggered() {
}
void MainWindow::on_m_pActionAbout_triggered() {
#if defined(SYNERGY_ENTERPRISE) || defined(SYNERGY_BUSINESS)
AboutDialog dlg(this, appConfig());
dlg.exec();
#else
if (appConfig().edition() == Edition::kBusiness) {
AboutDialog dlg(this, appConfig());
dlg.exec();
} else {
AboutDialogEliteBackers dlg(this, appConfig());
dlg.exec();
}
#endif
}
void MainWindow::on_m_pActionHelp_triggered() {
@ -1203,7 +1194,7 @@ void MainWindow::on_m_pActionHelp_triggered() {
}
void MainWindow::updateZeroconfService() {
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
// reset the server list in case one has gone away.
// it'll be re-added after the zeroconf service restarts.
@ -1228,10 +1219,13 @@ void MainWindow::updateAutoConfigWidgets() {
}
void MainWindow::updateWindowTitle() {
#ifdef SYNERGY_ENTERPRISE
setWindowTitle("Synergy 1 Enterprise");
#else
#ifdef SYNERGY_ENABLE_LICENSING
setWindowTitle(m_LicenseManager->activeEditionName());
#else
setWindowTitle(SYNERGY_PRODUCT_NAME);
#endif
#ifdef SYNERGY_ENABLE_LICENSING
m_LicenseManager->refresh();
#endif
}
@ -1255,7 +1249,7 @@ void MainWindow::autoAddScreen(const QString name) {
return;
}
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
if (m_ActivationDialogRunning) {
// TODO: refactor this code
// add this screen to the pending list and check this list until
@ -1283,7 +1277,7 @@ void MainWindow::autoAddScreen(const QString name) {
}
void MainWindow::showConfigureServer(const QString &message) {
ServerConfigDialog dlg(this, serverConfig());
ServerConfigDialog dlg(this, serverConfig(), appConfig());
dlg.message(message);
auto result = dlg.exec();
@ -1301,7 +1295,7 @@ void MainWindow::on_m_pButtonConfigureServer_clicked() {
}
void MainWindow::on_m_pActivate_triggered() {
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
raiseActivationDialog();
#endif
}
@ -1311,7 +1305,7 @@ void MainWindow::on_m_pButtonApply_clicked() {
restartSynergy();
}
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
int MainWindow::raiseActivationDialog() {
if (m_ActivationDialogRunning) {
return QDialog::Rejected;
@ -1332,7 +1326,7 @@ int MainWindow::raiseActivationDialog() {
#endif
void MainWindow::on_windowShown() {
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
auto serialKey = m_LicenseManager->serialKey();
if (!m_AppConfig->activationHasRun() && !serialKey.isValid()) {
setEdition(Edition::kUnregistered);

View File

@ -87,10 +87,10 @@ public:
enum qRuningState { kStarted, kStopped };
public:
#ifdef SYNERGY_ENTERPRISE
MainWindow(AppConfig &appConfig);
#else
#ifdef SYNERGY_ENABLE_LICENSING
MainWindow(AppConfig &appConfig, LicenseManager &licenseManager);
#else
MainWindow(AppConfig &appConfig);
#endif
~MainWindow();
@ -113,7 +113,7 @@ public:
void autoAddScreen(const QString name);
void addZeroconfServer(const QString name);
Zeroconf &zeroconf() { return *m_pZeroconf; }
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
LicenseManager &licenseManager() const;
int raiseActivationDialog();
#endif
@ -122,7 +122,7 @@ public:
public slots:
void setEdition(Edition edition);
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
void InvalidLicense();
void showLicenseNotice(const QString &message);
#endif
@ -202,7 +202,7 @@ protected:
#ifdef Q_OS_MAC
void checkOSXNotification(const QString &line);
#endif
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
void checkLicense(const QString &line);
#endif
QString getTimeStamp();
@ -215,7 +215,7 @@ protected:
void windowStateChanged();
private:
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
LicenseManager *m_LicenseManager;
bool m_ActivationDialogRunning;
QStringList m_PendingClientNames;

View File

@ -566,7 +566,7 @@ QSettings &ServerConfig::settings() {
}
bool ServerConfig::isHotkeysAvailable() const {
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
return (m_pAppConfig->edition() != Edition::kLite);
#else
return true;

View File

@ -22,13 +22,15 @@
#include "ScreenSettingsDialog.h"
#include "ServerConfig.h"
#include "UpgradeDialog.h"
#include "shared/EditionType.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QtCore>
#include <QtGui>
ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config,
AppConfig &appConfig)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
Ui::ServerConfigDialogBase(), m_OrigServerConfig(config),
m_OrigServerAppConfigUseExternalConfig(config.getUseExternalConfig()),
@ -36,7 +38,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
m_ServerConfig(config),
m_ScreenSetupModel(serverConfig().screens(), serverConfig().numColumns(),
serverConfig().numRows()),
m_Message("") {
m_Message(""), m_appConfig(appConfig) {
setupUi(this);
m_pEditConfigFile->setText(serverConfig().getConfigFile());
@ -266,10 +268,18 @@ void ServerConfigDialog::on_m_pButtonNewHotkey_clicked() {
onChange();
}
} else {
UpgradeDialog upgradeDialog(this);
upgradeDialog.showDialog(
"Configuring custom hotkeys is a Synergy Ultimate feature.",
"synergy/purchase/purchase-ultimate-upgrade?source=gui");
#ifdef SYNERGY_ENABLE_LICENSING
auto edition = appConfig().edition();
if (edition == Edition::kLite || edition == Edition::kBasic) {
UpgradeDialog upgradeDialog(this);
if (appConfig().edition() == Edition::kLite) {
upgradeDialog.showDialog(
"Upgrade to Synergy 1 Ultimate to enable hotkeys");
} else if (appConfig().edition() == Edition::kBasic) {
upgradeDialog.showDialog("Upgrade to Synergy 1 Pro to enable hotkeys");
}
}
#endif // SYNERGY_ENABLE_LICENSING
}
}

View File

@ -20,6 +20,7 @@
#define SERVERCONFIGDIALOG__H
#include "AppConfig.h"
#include "ScreenSetupModel.h"
#include "ServerConfig.h"
@ -31,7 +32,8 @@ class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase {
Q_OBJECT
public:
ServerConfigDialog(QWidget *parent, ServerConfig &config);
ServerConfigDialog(QWidget *parent, ServerConfig &config,
AppConfig &appConfig);
bool addClient(const QString &clientName);
public slots:
@ -61,6 +63,7 @@ protected:
ServerConfig &serverConfig() { return m_ServerConfig; }
void setOrigServerConfig(const ServerConfig &s) { m_OrigServerConfig = s; }
ScreenSetupModel &model() { return m_ScreenSetupModel; }
AppConfig &appConfig() { return m_appConfig; }
private:
ServerConfig &m_OrigServerConfig;
@ -69,6 +72,7 @@ private:
ServerConfig m_ServerConfig;
ScreenSetupModel m_ScreenSetupModel;
QString m_Message;
AppConfig &m_appConfig;
private slots:
void onChange();

View File

@ -18,6 +18,7 @@
#include "ServerConnection.h"
#include "AppConfig.h"
#include "MainWindow.h"
#include "ServerConfigDialog.h"
#include "ServerMessage.h"
@ -68,7 +69,8 @@ void ServerConnection::addClient(const QString &clientName) {
}
void ServerConnection::configureClient(const QString &clientName) {
ServerConfigDialog dlg(&m_parent, m_parent.serverConfig());
ServerConfigDialog dlg(&m_parent, m_parent.serverConfig(),
m_parent.appConfig());
if (dlg.addClient(clientName) && dlg.exec() == QDialog::Accepted) {
m_parent.restartSynergy();

View File

@ -193,7 +193,7 @@ void SettingsDialog::loadFromConfig() {
allowAutoConfig();
#endif
#if !defined(SYNERGY_ENTERPRISE) && defined(SYNERGY_AUTOCONFIG)
#ifdef SYNERGY_ENABLE_AUTO_CONFIG
m_pCheckBoxAutoConfig->setChecked(appConfig().autoConfig());
#else
m_pCheckBoxAutoConfig->hide();
@ -274,17 +274,20 @@ void SettingsDialog::on_m_pCheckBoxEnableCrypto_clicked(bool checked) {
buttonBox->button(QDialogButtonBox::Save)->setEnabled(isModified());
} else {
m_pCheckBoxEnableCrypto->setChecked(false);
#if !defined(SYNERGY_ENTERPRISE) && !defined(SYNERGY_BUSINESS)
UpgradeDialog upgradeDialog(this);
if (appConfig().edition() == Edition::kLite) {
upgradeDialog.showDialog(
"TLS encryption is a Synergy Ultimate feature.",
"synergy/purchase/purchase-ultimate-upgrade?source=gui");
} else {
upgradeDialog.showDialog("TLS encryption is a Synergy Pro feature.",
"synergy/purchase/upgrade?source=gui");
#ifdef SYNERGY_ENABLE_LICENSING
auto edition = appConfig().edition();
if (edition == Edition::kLite || edition == Edition::kBasic) {
UpgradeDialog upgradeDialog(this);
if (appConfig().edition() == Edition::kLite) {
upgradeDialog.showDialog(
"Upgrade to Synergy Ultimate to enable TLS encryption.");
} else if (appConfig().edition() == Edition::kBasic) {
upgradeDialog.showDialog(
"Upgrade to Synergy Pro to enable TLS encryption.");
}
}
#endif
#endif // SYNERGY_ENABLE_LICENSING
}
}

View File

@ -25,11 +25,11 @@ UpgradeDialog::UpgradeDialog(QWidget *parent) : QMessageBox(parent) {
addButton(QObject::tr("Upgrade"), QMessageBox::AcceptRole);
}
void UpgradeDialog::showDialog(const QString &text, const QString &link) {
void UpgradeDialog::showDialog(const QString &text) {
setText(QObject::tr(text.toStdString().c_str()));
if (exec() == QMessageBox::Accepted) {
QDesktopServices::openUrl(
QUrl(QCoreApplication::organizationDomain() + link));
QDesktopServices::openUrl(QUrl(QCoreApplication::organizationDomain() +
"/synergy/purchase/upgrade?source=gui"));
}
}

View File

@ -20,5 +20,5 @@
class UpgradeDialog : public QMessageBox {
public:
explicit UpgradeDialog(QWidget *parent = nullptr);
void showDialog(const QString &text, const QString &link);
void showDialog(const QString &text);
};

View File

@ -83,16 +83,16 @@ int main(int argc, char *argv[]) {
AppConfig appConfig;
qRegisterMetaType<Edition>("Edition");
#ifndef SYNERGY_ENTERPRISE
#ifdef SYNERGY_ENABLE_LICENSING
LicenseManager licenseManager(&appConfig);
#endif
app.switchTranslator(appConfig.language());
#ifdef SYNERGY_ENTERPRISE
MainWindow mainWindow(appConfig);
#else
#ifdef SYNERGY_ENABLE_LICENSING
MainWindow mainWindow(appConfig, licenseManager);
#else
MainWindow mainWindow(appConfig);
#endif
QObject::connect(dynamic_cast<QObject *>(&app), SIGNAL(aboutToQuit()),

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
* Copyright (C) 2015 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -23,11 +23,11 @@
enum Edition {
kBasic,
kPro,
Trial_DO_NOT_USE_OR_THERE_WILL_BE_PAIN,
kValueNotUsed,
kUnregistered,
kBusiness,
kBasic_China,
kPro_China,
kBasicChina,
kProChina,
kLite,
kUltimate
};

View File

@ -14,6 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "SerialKeyEdition.h"

View File

@ -1,133 +1,126 @@
#include <algorithm>
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <map>
#include "SerialKeyEdition.h"
const std::string SerialKeyEdition::PRO = "pro";
const std::string SerialKeyEdition::PRO_CHINA = "pro_china";
const std::string SerialKeyEdition::BASIC = "basic";
const std::string SerialKeyEdition::BASIC_CHINA = "basic_china";
const std::string SerialKeyEdition::BUSINESS = "business";
const std::string SerialKeyEdition::UNREGISTERED = "unregistered";
const std::string SerialKeyEdition::ULTIMATE = "ultimate";
const std::string SerialKeyEdition::LITE = "lite";
const std::string SerialKeyEdition::Pro = "pro";
const std::string SerialKeyEdition::ProChina = "pro_china";
const std::string SerialKeyEdition::Basic = "basic";
const std::string SerialKeyEdition::BasicChina = "basic_china";
const std::string SerialKeyEdition::Buisiness = "business";
const std::string SerialKeyEdition::Unregistered = "community";
const std::string SerialKeyEdition::Ultimate = "ultimate";
const std::string SerialKeyEdition::Lite = "lite";
namespace {
const std::map<std::string, Edition, std::less<>> serialTypes{
{SerialKeyEdition::Basic, kBasic},
{SerialKeyEdition::Pro, kPro},
{SerialKeyEdition::BasicChina, kBasicChina},
{SerialKeyEdition::ProChina, kProChina},
{SerialKeyEdition::Buisiness, kBusiness},
{SerialKeyEdition::Lite, kLite},
{SerialKeyEdition::Ultimate, kUltimate}};
const std::map<std::string, Edition> &getSerialTypes() {
#ifdef SYNERGY_BUSINESS
static const std::map<std::string, Edition> serialTypes = {
{SerialKeyEdition::BUSINESS, kBusiness}};
#else
static const std::map<std::string, Edition> serialTypes{
{SerialKeyEdition::BASIC, kBasic},
{SerialKeyEdition::PRO, kPro},
{SerialKeyEdition::BASIC_CHINA, kBasic_China},
{SerialKeyEdition::PRO_CHINA, kPro_China},
{SerialKeyEdition::BUSINESS, kBusiness},
{SerialKeyEdition::LITE, kLite},
{SerialKeyEdition::ULTIMATE, kUltimate}};
#endif
return serialTypes;
}
} // namespace
SerialKeyEdition::SerialKeyEdition() {}
SerialKeyEdition::SerialKeyEdition(Edition type) : m_Type(type) {}
SerialKeyEdition::SerialKeyEdition(Edition type) : m_type(type) {}
SerialKeyEdition::SerialKeyEdition(const std::string &type) { setType(type); }
Edition SerialKeyEdition::getType() const { return m_Type; }
Edition SerialKeyEdition::getType() const { return m_type; }
std::string SerialKeyEdition::getName() const {
std::string Name;
switch (getType()) {
case kPro:
Name = PRO;
break;
case kBasic:
Name = BASIC;
break;
case kBusiness:
Name = BUSINESS;
break;
case kUnregistered:
Name = UNREGISTERED;
break;
case kBasic_China:
Name = BASIC_CHINA;
break;
case kPro_China:
Name = PRO_CHINA;
break;
case kLite:
Name = LITE;
break;
case kUltimate:
Name = ULTIMATE;
break;
default:
break;
}
return Lite;
return Name;
case kUltimate:
return Ultimate;
case kPro:
return Pro;
case kBasic:
return Basic;
case kBusiness:
return Buisiness;
case kBasicChina:
return BasicChina;
case kProChina:
return ProChina;
default:
return Unregistered;
}
}
std::string SerialKeyEdition::getDisplayName() const {
const std::string ApplicationName = "Synergy 1 ";
std::string DisplayName(ApplicationName);
std::string SerialKeyEdition::getProductName() const {
const std::string nameBase = "Synergy 1";
switch (getType()) {
case kBasic_China:
DisplayName = "Synergy 中文版";
break;
case kPro_China:
DisplayName = "Synergy Pro 中文版";
break;
case kLite:
DisplayName = "Synergy 1";
break;
default:
std::string EditionName = getName();
if (!EditionName.empty()) {
if (EditionName == UNREGISTERED) {
std::transform(EditionName.begin(), EditionName.end(),
EditionName.begin(), ::toupper);
EditionName = "(" + EditionName + ")";
} else {
EditionName[0] = static_cast<char>(::toupper(EditionName[0]));
}
DisplayName = ApplicationName + EditionName;
}
}
return DisplayName;
case kLite:
return nameBase;
case kUltimate:
return nameBase + " Ultimate";
case kPro:
return nameBase + " Pro";
case kBasic:
return nameBase + " Basic";
case kBusiness:
return nameBase + " Business";
case kBasicChina:
return nameBase + " 中文版";
case kProChina:
return nameBase + " Pro 中文版";
default:
return nameBase + " (Unregistered)";
}
}
void SerialKeyEdition::setType(Edition type) {
m_Type = type;
m_type = type;
setType(getName());
}
void SerialKeyEdition::setType(const std::string &type) {
auto types = getSerialTypes();
const auto &pType = types.find(type);
void SerialKeyEdition::setType(const std::string &name) {
const auto &pType = serialTypes.find(name);
if (pType != types.end()) {
m_Type = pType->second;
if (pType != serialTypes.end()) {
m_type = pType->second;
} else {
m_Type = kUnregistered;
m_type = kUnregistered;
}
}
bool SerialKeyEdition::isValid() const {
auto types = getSerialTypes();
return (types.find(getName()) != types.end());
return serialTypes.contains(getName());
}
bool SerialKeyEdition::isChina() const {
return ((m_Type == kBasic_China) || (m_Type == kPro_China));
return ((m_type == kBasicChina) || (m_type == kProChina));
}

View File

@ -14,22 +14,24 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "EditionType.h"
#include <string>
class SerialKeyEdition {
friend bool operator==(SerialKeyEdition const &, SerialKeyEdition const &);
friend bool operator==(SerialKeyEdition const &,
SerialKeyEdition const &) = default;
public:
SerialKeyEdition();
SerialKeyEdition() = default;
explicit SerialKeyEdition(Edition type);
explicit SerialKeyEdition(const std::string &type);
explicit SerialKeyEdition(const std::string &name);
Edition getType() const;
std::string getName() const;
std::string getDisplayName() const;
std::string getProductName() const;
void setType(Edition type);
void setType(const std::string &type);
@ -37,25 +39,15 @@ public:
bool isValid() const;
bool isChina() const;
static const std::string PRO;
static const std::string PRO_CHINA;
static const std::string BASIC;
static const std::string BASIC_CHINA;
static const std::string BUSINESS;
static const std::string UNREGISTERED;
static const std::string ULTIMATE;
static const std::string LITE;
static const std::string Pro;
static const std::string ProChina;
static const std::string Basic;
static const std::string BasicChina;
static const std::string Buisiness;
static const std::string Unregistered;
static const std::string Ultimate;
static const std::string Lite;
private:
Edition m_Type = kUnregistered;
Edition m_type = kUnregistered;
};
inline bool operator==(SerialKeyEdition const &lhs,
SerialKeyEdition const &rhs) {
return (lhs.m_Type == rhs.m_Type);
}
inline bool operator!=(SerialKeyEdition const &lhs,
SerialKeyEdition const &rhs) {
return !(lhs == rhs);
}

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015 Synergy Seamless Inc.
* Copyright (C) 2015 Synergy Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -17,16 +17,16 @@
#include "SerialKeyType.h"
const std::string SerialKeyType::TRIAL = "trial";
const std::string SerialKeyType::SUBSCRIPTION = "subscription";
const std::string SerialKeyType::MAINTENANCE = "maintenance";
const std::string SerialKeyType::Trial = "trial";
const std::string SerialKeyType::Subscription = "subscription";
const std::string SerialKeyType::Maintenance = "maintenance";
SerialKeyType::SerialKeyType() {}
void SerialKeyType::setKeyType(const std::string &Type) {
m_isTrial = (Type == SerialKeyType::TRIAL);
m_isTemporary = (m_isTrial || (Type == SerialKeyType::SUBSCRIPTION));
m_isMaintenance = (Type == SerialKeyType::MAINTENANCE);
m_isTrial = (Type == SerialKeyType::Trial);
m_isTemporary = (m_isTrial || (Type == SerialKeyType::Subscription));
m_isMaintenance = (Type == SerialKeyType::Maintenance);
}
bool SerialKeyType::isTrial() const { return m_isTrial; }

View File

@ -14,6 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
@ -23,13 +24,13 @@ private:
friend bool operator==(SerialKeyType const &, SerialKeyType const &);
public:
static const std::string TRIAL;
static const std::string SUBSCRIPTION;
static const std::string MAINTENANCE;
static const std::string Trial;
static const std::string Subscription;
static const std::string Maintenance;
SerialKeyType();
void setKeyType(const std::string &Type);
void setKeyType(const std::string &type);
bool isTrial() const;
bool isTemporary() const;
bool isMaintenance() const;

View File

@ -16,15 +16,22 @@
*/
#include "base/Path.h"
#include <filesystem>
#include <fstream>
#include "test/global/gtest.h"
const std::string testDir = "tmp/test";
const std::wstring testDirW = L"tmp/test";
TEST(PathTests, open_file_using_path) {
std::string utf8FileName = "тіás.txt";
std::filesystem::create_directories(testDir);
std::string utf8FileName = testDir + "іás.txt";
#if SYSAPI_WIN32
// Windows uses UTF-16 for file path and names
std::wstring fileName = L"\x0442\x0456\x00E1\x0073\x002E\x0074\x0078\x0074";
std::wstring fileName =
testDirW + L"/\x0442\x0456\x00E1\x0073\x002E\x0074\x0078\x0074";
#else
std::string fileName = utf8FileName;
#endif

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless Inc.
* Copyright (C) 2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -15,85 +15,119 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "shared/EditionType.h"
#define TEST_ENV
#include "shared/SerialKeyEdition.h"
#include "test/global/gtest.h"
TEST(SerialKeyEditionTests, DefaultEditionType_Unregistered) {
TEST(SerialKeyEditionTests, equal_operator) {
SerialKeyEdition edition1(kPro);
SerialKeyEdition edition2(kPro);
EXPECT_EQ(edition1, edition2);
}
TEST(SerialKeyEditionTests, ctor_default_unregistered) {
SerialKeyEdition edition;
EXPECT_EQ(kUnregistered, edition.getType());
EXPECT_EQ(SerialKeyEdition::UNREGISTERED, edition.getName());
EXPECT_EQ("Synergy 1 (UNREGISTERED)", edition.getDisplayName());
EXPECT_EQ(SerialKeyEdition::Unregistered, edition.getName());
EXPECT_EQ("Synergy 1 (Unregistered)", edition.getProductName());
EXPECT_FALSE(edition.isValid());
}
TEST(SerialKeyEditionTests, SetEditionType_edition) {
TEST(SerialKeyEditionTests, ctor_businessName_isValid) {
SerialKeyEdition edition(SerialKeyEdition::Buisiness);
EXPECT_EQ(kBusiness, edition.getType());
EXPECT_TRUE(edition.isValid());
}
TEST(SerialKeyEditionTests, ctor_basicType_isValid) {
SerialKeyEdition edition(kBasic);
EXPECT_TRUE(edition.isValid());
}
TEST(SerialKeyEditionTests, setType_invalidType_unregistered) {
SerialKeyEdition edition;
edition.setType("stub");
EXPECT_EQ(kUnregistered, edition.getType());
}
TEST(SerialKeyEditionTests, setType_lite_isValid) {
SerialKeyEdition edition;
edition.setType(kLite);
EXPECT_EQ(kLite, edition.getType());
EXPECT_EQ(SerialKeyEdition::Lite, edition.getName());
EXPECT_EQ("Synergy 1", edition.getProductName());
EXPECT_TRUE(edition.isValid());
}
TEST(SerialKeyEditionTests, setType_ultimate_isValid) {
SerialKeyEdition edition;
edition.setType(SerialKeyEdition::Ultimate);
EXPECT_EQ(kUltimate, edition.getType());
EXPECT_EQ(SerialKeyEdition::Ultimate, edition.getName());
EXPECT_EQ("Synergy 1 Ultimate", edition.getProductName());
}
TEST(SerialKeyEditionTests, setType_pro_isValid) {
SerialKeyEdition edition;
edition.setType(kPro);
EXPECT_EQ(kPro, edition.getType());
EXPECT_EQ(SerialKeyEdition::PRO, edition.getName());
EXPECT_EQ("Synergy 1 Pro", edition.getDisplayName());
EXPECT_EQ(SerialKeyEdition::Pro, edition.getName());
EXPECT_EQ("Synergy 1 Pro", edition.getProductName());
EXPECT_TRUE(edition.isValid());
}
TEST(SerialKeyEditionTests, SetEditionType_string) {
TEST(SerialKeyEditionTests, setType_basic_isValid) {
SerialKeyEdition edition;
edition.setType(SerialKeyEdition::BASIC);
edition.setType(kBasic);
EXPECT_EQ(kBasic, edition.getType());
EXPECT_EQ(SerialKeyEdition::BASIC, edition.getName());
EXPECT_EQ("Synergy 1 Basic", edition.getDisplayName());
EXPECT_EQ(SerialKeyEdition::Basic, edition.getName());
EXPECT_EQ("Synergy 1 Basic", edition.getProductName());
}
TEST(SerialKeyEditionTests, SetEditionBusiness) {
TEST(SerialKeyEditionTests, setType_business_isValid) {
SerialKeyEdition edition;
edition.setType(kBusiness);
EXPECT_EQ(kBusiness, edition.getType());
EXPECT_EQ(SerialKeyEdition::BUSINESS, edition.getName());
EXPECT_EQ("Synergy 1 Business", edition.getDisplayName());
EXPECT_EQ(SerialKeyEdition::Buisiness, edition.getName());
EXPECT_EQ("Synergy 1 Business", edition.getProductName());
}
TEST(SerialKeyEditionTests, SetEditionBasicChina) {
TEST(SerialKeyEditionTests, setType_basicChina_isValid) {
SerialKeyEdition edition;
edition.setType(kBasic_China);
EXPECT_EQ(kBasic_China, edition.getType());
EXPECT_EQ(SerialKeyEdition::BASIC_CHINA, edition.getName());
EXPECT_EQ("Synergy 中文版", edition.getDisplayName());
edition.setType(kBasicChina);
EXPECT_EQ(kBasicChina, edition.getType());
EXPECT_EQ(SerialKeyEdition::BasicChina, edition.getName());
EXPECT_EQ("Synergy 1 中文版", edition.getProductName());
EXPECT_TRUE(edition.isChina());
}
TEST(SerialKeyEditionTests, SetEditionProChina) {
TEST(SerialKeyEditionTests, setType_proChina_isValid) {
SerialKeyEdition edition;
edition.setType(kPro_China);
EXPECT_EQ(kPro_China, edition.getType());
EXPECT_EQ(SerialKeyEdition::PRO_CHINA, edition.getName());
EXPECT_EQ("Synergy Pro 中文版", edition.getDisplayName());
edition.setType(kProChina);
EXPECT_EQ(kProChina, edition.getType());
EXPECT_EQ(SerialKeyEdition::ProChina, edition.getName());
EXPECT_EQ("Synergy 1 Pro 中文版", edition.getProductName());
EXPECT_TRUE(edition.isChina());
}
TEST(SerialKeyEditionTests, NameConstructor) {
SerialKeyEdition edition(SerialKeyEdition::BUSINESS);
EXPECT_EQ(kBusiness, edition.getType());
EXPECT_TRUE(edition.isValid());
}
TEST(SerialKeyEditionTests, isValid) {
SerialKeyEdition edition;
edition.setType(Edition::kBasic);
EXPECT_TRUE(edition.isValid());
edition.setType(Edition::kBasic_China);
EXPECT_TRUE(edition.isValid());
edition.setType(Edition::kBusiness);
EXPECT_TRUE(edition.isValid());
edition.setType(Edition::kPro);
EXPECT_TRUE(edition.isValid());
edition.setType(Edition::kPro_China);
EXPECT_TRUE(edition.isValid());
edition.setType(Edition::kUnregistered);
EXPECT_FALSE(edition.isValid());
}

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless Inc.
* Copyright (C) 2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -1,6 +1,6 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless Inc.
* Copyright (C) 2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -15,13 +15,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtest/gtest.h>
#if WINAPI_XWINDOWS
#include "synergy/unix/X11LayoutsParser.h"
#include "test/global/gtest.h"
#include <filesystem>
#include <fstream>
const std::string testDir = "tmp/test";
void createTestFiles() {
std::ofstream correctEvdevFile("correctEvdev.xml");
std::filesystem::create_directories(testDir);
std::ofstream correctEvdevFile(testDir + "/correctEvdev.xml");
if (!correctEvdevFile.is_open()) {
FAIL();
}
@ -74,7 +80,7 @@ void createTestFiles() {
correctEvdevFile << "</xkbConfigRegistry>" << std::endl;
correctEvdevFile.close();
std::ofstream evdevFromFutureFile("evdevFromFuture.xml");
std::ofstream evdevFromFutureFile(testDir + "/evdevFromFuture.xml");
if (!evdevFromFutureFile.is_open()) {
FAIL();
}
@ -95,7 +101,7 @@ void createTestFiles() {
evdevFromFutureFile << "</xkbConfigRegistry>" << std::endl;
evdevFromFutureFile.close();
std::ofstream incorrectEvdevFile1("incorrectEvdev1.xml");
std::ofstream incorrectEvdevFile1(testDir + "/incorrectEvdev1.xml");
if (!incorrectEvdevFile1.is_open()) {
FAIL();
}
@ -103,7 +109,7 @@ void createTestFiles() {
incorrectEvdevFile1 << "<incorrectRootTag></incorrectRootTag>" << std::endl;
incorrectEvdevFile1.close();
std::ofstream incorrectEvdevFile2("incorrectEvdev2.xml");
std::ofstream incorrectEvdevFile2(testDir + "/incorrectEvdev2.xml");
if (!incorrectEvdevFile2.is_open()) {
FAIL();
}
@ -114,7 +120,7 @@ void createTestFiles() {
incorrectEvdevFile2 << "</xkbConfigRegistry>" << std::endl;
incorrectEvdevFile2.close();
std::ofstream incorrectEvdevFile3("incorrectEvdev3.xml");
std::ofstream incorrectEvdevFile3(testDir + "/incorrectEvdev3.xml");
if (!incorrectEvdevFile3.is_open()) {
FAIL();
}
@ -133,35 +139,41 @@ void createTestFiles() {
TEST(X11LayoutsParsingTests, xmlCorrectParsingTest) {
createTestFiles();
std::vector<String> expectedResult = {"en", "ru"};
auto parsedResult = X11LayoutsParser::getX11LanguageList("correctEvdev.xml");
auto parsedResult =
X11LayoutsParser::getX11LanguageList(testDir + "/correctEvdev.xml");
EXPECT_EQ(parsedResult, parsedResult);
}
TEST(X11LayoutsParsingTests, xmlParsingMissedEvdevFileTest) {
auto parsedResult = X11LayoutsParser::getX11LanguageList("missedFile");
auto parsedResult =
X11LayoutsParser::getX11LanguageList(testDir + "/missedFile");
EXPECT_TRUE(parsedResult.empty());
}
TEST(X11LayoutsParsingTests, xmlParsingIncorrectEvdevFileTest) {
std::vector<String> parsedResult;
parsedResult = X11LayoutsParser::getX11LanguageList("incorrectEvdev1.xml");
parsedResult =
X11LayoutsParser::getX11LanguageList(testDir + "/incorrectEvdev1.xml");
EXPECT_TRUE(parsedResult.empty());
parsedResult = X11LayoutsParser::getX11LanguageList("incorrectEvdev2.xml");
parsedResult =
X11LayoutsParser::getX11LanguageList(testDir + "/incorrectEvdev2.xml");
EXPECT_TRUE(parsedResult.empty());
parsedResult = X11LayoutsParser::getX11LanguageList("incorrectEvdev3.xml");
parsedResult =
X11LayoutsParser::getX11LanguageList(testDir + "/incorrectEvdev3.xml");
EXPECT_TRUE(parsedResult.empty());
}
TEST(X11LayoutsParsingTests, layoutConvertTest) {
EXPECT_EQ(X11LayoutsParser::convertLayotToISO("correctEvdev.xml", "us", true),
EXPECT_EQ(X11LayoutsParser::convertLayotToISO(testDir + "/correctEvdev.xml",
"us", true),
"en");
EXPECT_EQ(
X11LayoutsParser::convertLayotToISO("incorrectEvdev1.xml", "us", true),
"");
EXPECT_EQ(
X11LayoutsParser::convertLayotToISO("evdevFromFuture.xml", "us", true),
"");
EXPECT_EQ(X11LayoutsParser::convertLayotToISO(
testDir + "/incorrectEvdev1.xml", "us", true),
"");
EXPECT_EQ(X11LayoutsParser::convertLayotToISO(
testDir + "/evdevFromFuture.xml", "us", true),
"");
}
#endif