Skip to content

Commit

Permalink
Pull in license code
Browse files Browse the repository at this point in the history
  • Loading branch information
nbolton committed Sep 27, 2024
1 parent 2332fc5 commit 1c3b1e3
Show file tree
Hide file tree
Showing 42 changed files with 2,627 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Deskflow -- mouse and keyboard sharing utility
# Synergy -- mouse and keyboard sharing utility
# Copyright (C) 2024 Symless Ltd.
# Copyright (C) 2009 Nick Bolton
#
Expand All @@ -19,7 +19,9 @@ cmake_minimum_required(VERSION 3.8)
project(synergy C CXX)

include(cmake/Deskflow.cmake)
include(cmake/Licensing.cmake)

configure_deskflow()

add_subdirectory(deskflow)
add_subdirectory(src)
24 changes: 23 additions & 1 deletion cmake/Deskflow.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Deskflow -- mouse and keyboard sharing utility
# Synergy -- mouse and keyboard sharing utility
# Copyright (C) 2024 Symless Ltd.
# Copyright (C) 2009 Nick Bolton
#
Expand All @@ -19,6 +19,24 @@ macro(configure_deskflow)
configure_meta()
configure_dist()
configure_bin_names()
# configure_pre_start()

endmacro()

macro(configure_pre_start)

set(DESKFLOW_PRE_START_INCLUDE "synergy/pre_start.h")
add_definitions(-DSYNERGY_PRE_START_INCLUDE="${DESKFLOW_PRE_START_INCLUDE}")

set(DESKFLOW_PRE_START_SNIPPET "if (!synergy::preStart()) { return 0; }")
add_definitions(-DSYNERGY_PRE_START_SNIPPET="${DESKFLOW_PRE_START_SNIPPET}")

set(DESKFLOW_PRE_START_LIB
"synergy"
CACHE STRING "Pre-start library")

include_directories(${CMAKE_SOURCE_DIR}/src/lib)

endmacro()

macro(configure_meta)
Expand Down Expand Up @@ -55,6 +73,10 @@ macro(configure_meta)
"https://api.symless.com/version/synergy1"
CACHE STRING "URL to get the latest version")

set(DESKFLOW_HELP_TEXT
"Get technical support"
CACHE STRING "Text label for the help menu item")

set(DESKFLOW_RES_DIR
"${CMAKE_SOURCE_DIR}/res"
CACHE STRING "Path to the res directory")
Expand Down
18 changes: 18 additions & 0 deletions cmake/Licensing.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Synergy -- mouse and keyboard sharing utility
# Copyright (C) 2024 Symless Ltd.
# Copyright (C) 2009 Nick Bolton
#
# 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/>.

# activation is off by default to make life easier for contributors.
option(ENABLE_ACTIVATION "Enable activation dialog, etc" ON)
2 changes: 1 addition & 1 deletion deskflow
Submodule deskflow updated 64 files
+0 −9 .env.example
+10 −16 cmake/Definitions.cmake
+0 −1 src/cmd/deskflowd/CMakeLists.txt
+0 −1 src/gui/CMakeLists.txt
+1 −0 src/gui/src/AboutDialog.cpp
+0 −189 src/gui/src/ActivationDialog.cpp
+0 −59 src/gui/src/ActivationDialog.h
+0 −153 src/gui/src/ActivationDialog.ui
+0 −33 src/gui/src/CancelActivationDialog.cpp
+0 −35 src/gui/src/CancelActivationDialog.h
+0 −77 src/gui/src/CancelActivationDialog.ui
+10 −165 src/gui/src/MainWindow.cpp
+0 −10 src/gui/src/MainWindow.h
+15 −6 src/gui/src/main.cpp
+0 −1 src/lib/CMakeLists.txt
+3 −2 src/lib/arch/unix/ArchSystemUnix.cpp
+1 −1 src/lib/arch/win32/ArchSystemWindows.cpp
+0 −5 src/lib/deskflow/ArgParser.cpp
+2 −2 src/lib/deskflow/DaemonApp.cpp
+0 −3 src/lib/deskflow/ServerArgs.h
+1 −1 src/lib/deskflow/unix/AppUtilUnix.cpp
+3 −2 src/lib/deskflow/win32/AppUtilWindows.cpp
+1 −6 src/lib/gui/CMakeLists.txt
+5 −5 src/lib/gui/config/AppConfig.cpp
+7 −2 src/lib/gui/config/AppConfig.h
+2 −12 src/lib/gui/core/CoreProcess.cpp
+0 −4 src/lib/gui/core/CoreProcess.h
+3 −22 src/lib/gui/dialogs/SettingsDialog.cpp
+1 −4 src/lib/gui/dialogs/SettingsDialog.h
+0 −45 src/lib/gui/dialogs/UpgradeDialog.cpp
+0 −31 src/lib/gui/dialogs/UpgradeDialog.h
+0 −103 src/lib/gui/license/LicenseHandler.cpp
+0 −58 src/lib/gui/license/LicenseHandler.h
+0 −77 src/lib/gui/license/license_notices.cpp
+0 −28 src/lib/gui/license/license_notices.h
+0 −71 src/lib/gui/license/license_utils.cpp
+0 −30 src/lib/gui/license/license_utils.h
+3 −13 src/lib/gui/messages.cpp
+4 −14 src/lib/gui/tls/TlsUtility.cpp
+2 −5 src/lib/gui/tls/TlsUtility.h
+0 −26 src/lib/license/CMakeLists.txt
+0 −32 src/lib/license/ILicense.h
+0 −101 src/lib/license/License.cpp
+0 −96 src/lib/license/License.h
+0 −121 src/lib/license/Product.cpp
+0 −64 src/lib/license/Product.h
+0 −23 src/lib/license/ProductEdition.h
+0 −60 src/lib/license/SerialKey.h
+0 −30 src/lib/license/SerialKeyType.cpp
+0 −41 src/lib/license/SerialKeyType.h
+0 −150 src/lib/license/parse_serial_key.cpp
+0 −58 src/lib/license/parse_serial_key.h
+1 −1 src/lib/platform/MSWindowsScreen.cpp
+0 −2 src/lib/server/CMakeLists.txt
+0 −11 src/lib/server/Server.cpp
+0 −1 src/test/CMakeLists.txt
+0 −17 src/test/unittests/deskflow/ServerArgsParsingTests.cpp
+1 −14 src/test/unittests/gui/core/CoreProcessTests.cpp
+2 −8 src/test/unittests/gui/dialogs/SettingsDialogTests.cpp
+0 −39 src/test/unittests/gui/license/LicenseHandlerTests.cpp
+0 −143 src/test/unittests/gui/license/license_notices_tests.cpp
+0 −182 src/test/unittests/shared/LicenseTests.cpp
+0 −83 src/test/unittests/shared/ProductTests.cpp
+0 −42 src/test/unittests/shared/SerialKeyTypeTests.cpp
150 changes: 150 additions & 0 deletions src/ test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Deskflow -- mouse and keyboard sharing utility
# Copyright (C) 2012-2024 Symless Ltd.
# Copyright (C) 2009-2012 Nick Bolton
#
# 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/>.

macro(config_all_tests)

set(base_dir ${PROJECT_SOURCE_DIR})
set(src_dir ${base_dir}/src)
set(test_base_dir ${src_dir}/test)
set(gui_dir ${src_dir}/gui/src)

config_test_deps()

add_subdirectory(integtests)
add_subdirectory(unittests)

endmacro()

macro(config_test)

include_directories(
${test_base_dir}
${src_dir}
${src_dir}/lib
${gui_dir}
${ext_dir})

set_sources()

endmacro()

macro(set_sources)

file(GLOB_RECURSE headers ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

file(GLOB_RECURSE shared_headers ${test_base_dir}/shared/*.h)
file(GLOB_RECURSE shared_sources ${test_base_dir}/shared/*.cpp)

list(APPEND headers ${shared_headers})
list(APPEND sources ${shared_sources})

file(GLOB_RECURSE mock_headers ${test_base_dir}/mock/*.h)
file(GLOB_RECURSE mock_sources ${test_base_dir}/mock/*.cpp)

list(APPEND headers ${mock_headers})
list(APPEND sources ${mock_sources})

if(ADD_HEADERS_TO_SOURCES)
list(APPEND sources ${headers})
endif()

if(WIN32)
list(APPEND sources ${PROJECT_BINARY_DIR}/src/version.rc)
endif()

replace_platform_sources()
replace_arch_sources()

endmacro()

macro(replace_platform_sources)

set(platform_dir ${CMAKE_CURRENT_SOURCE_DIR}/platform)

# Remove platform files so that specific platform files can be added later.
# This is a bit weird, but it's simpler to include everything, remove all
# platform files, then only include the platforms we need.
file(GLOB_RECURSE all_platform_files ${platform_dir}/*)
list(REMOVE_ITEM headers ${all_platform_files})
list(REMOVE_ITEM sources ${all_platform_files})

if(WIN32)
file(GLOB platform_sources ${platform_dir}/MSWindows*.cpp)
file(GLOB platform_headers ${platform_dir}/MSWindows*.h)
elseif(APPLE)
file(GLOB platform_sources ${platform_dir}/OSX*.cpp)
file(GLOB platform_headers ${platform_dir}/OSX*.h)
elseif(UNIX)
file(GLOB platform_sources ${platform_dir}/XWindows*.cpp)
file(GLOB platform_headers ${platform_dir}/XWindows*.h)
endif()

list(APPEND sources ${platform_sources})
list(APPEND headers ${platform_headers})

endmacro()

macro(replace_arch_sources)

set(arch_dir ${CMAKE_CURRENT_SOURCE_DIR}/arch)

# Remove arch files so that specific arch files can be added later.
# This is a bit weird, but it's simpler to include everything, remove all
# arch files, then only include the archs we need.
file(GLOB_RECURSE all_arch_files ${arch_dir}/*)
list(REMOVE_ITEM headers ${all_arch_files})
list(REMOVE_ITEM sources ${all_arch_files})

if(WIN32)
file(GLOB arch_sources ${arch_dir}/win32/*.cpp)
file(GLOB arch_headers ${arch_dir}/win32/*.h)
elseif(UNIX)
file(GLOB arch_sources ${arch_dir}/unix/*.cpp)
file(GLOB arch_headers ${arch_dir}/unix/*.h)
endif()

list(APPEND sources ${arch_sources})
list(APPEND headers ${arch_headers})

endmacro()

macro(config_test_deps)

# gui library autogen headers:
# qt doesn't seem to auto include the autogen headers for libraries.
include_directories(${PROJECT_BINARY_DIR}/src/lib/gui/gui_autogen/include)

set(test_libs
arch
base
client
server
io
net
platform
server
app
mt
ipc
gui
${GMOCK_LIB}
${GTEST_LIB}
${libs})

endmacro()

config_all_tests()
20 changes: 20 additions & 0 deletions src/ test/integtests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Deskflow -- mouse and keyboard sharing utility
# Copyright (C) 2012-2024 Symless Ltd.
# Copyright (C) 2009-2012 Nick Bolton
#
# 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/>.

config_test()
set(target ${INTEG_TESTS_BIN})
add_executable(${target} ${sources})
target_link_libraries(${target} ${test_libs})
20 changes: 20 additions & 0 deletions src/ test/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Deskflow -- mouse and keyboard sharing utility
# Copyright (C) 2012-2024 Symless Ltd.
# Copyright (C) 2009-2012 Nick Bolton
#
# 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/>.

config_test()
set(target ${UNIT_TESTS_BIN})
add_executable(${target} ${sources})
target_link_libraries(${target} ${test_libs})
39 changes: 39 additions & 0 deletions src/ test/unittests/gui/license/LicenseHandlerTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* Copyright (C) 2024 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 "gui/license/LicenseHandler.h"

#include <chrono>
#include <gtest/gtest.h>

using namespace deskflow::license;
using namespace std::chrono;

const auto kPast = system_clock::now() - hours(1);
const auto kFuture = system_clock::now() + hours(1);

TEST(LicenseHandlerTests, changeSerialKey_validExpiredLicense_returnsTrue) {
LicenseHandler licenseHandler;
licenseHandler.setEnabled(true);
auto hexString = //
"7B76313B70726F3B6E69636B20626F6C746F6E3B313B6"
"E69636B4073796D6C6573732E636F6D3B203B303B307D";

auto result = licenseHandler.changeSerialKey(hexString);

ASSERT_EQ(LicenseHandler::ChangeSerialKeyResult::kSuccess, result);
}
Loading

0 comments on commit 1c3b1e3

Please sign in to comment.