init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
This commit is contained in:
1
Telegram/ThirdParty/kcoreaddons/.git-blame-ignore-revs
vendored
Normal file
1
Telegram/ThirdParty/kcoreaddons/.git-blame-ignore-revs
vendored
Normal file
@@ -0,0 +1 @@
|
||||
0cf8afacd8df68412039e0e6caa6f17481f2be06
|
||||
28
Telegram/ThirdParty/kcoreaddons/.gitignore
vendored
Normal file
28
Telegram/ThirdParty/kcoreaddons/.gitignore
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# Ignore the following files
|
||||
*~
|
||||
*.[oa]
|
||||
*.diff
|
||||
*.kate-swp
|
||||
*.kdev4
|
||||
.kdev_include_paths
|
||||
*.kdevelop.pcs
|
||||
*.moc
|
||||
*.moc.cpp
|
||||
*.orig
|
||||
*.user
|
||||
.*.swp
|
||||
.swp.*
|
||||
Doxyfile
|
||||
Makefile
|
||||
avail
|
||||
random_seed
|
||||
/build*/
|
||||
CMakeLists.txt.user*
|
||||
*.unc-backup*
|
||||
.cmake/
|
||||
/.clang-format
|
||||
/compile_commands.json
|
||||
.clangd
|
||||
.idea
|
||||
/cmake-build*
|
||||
.cache
|
||||
12
Telegram/ThirdParty/kcoreaddons/.gitlab-ci.yml
vendored
Normal file
12
Telegram/ThirdParty/kcoreaddons/.gitlab-ci.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
include:
|
||||
- project: sysadmin/ci-utilities
|
||||
file:
|
||||
- /gitlab-templates/linux.yml
|
||||
- /gitlab-templates/linux-static.yml
|
||||
- /gitlab-templates/android.yml
|
||||
- /gitlab-templates/freebsd.yml
|
||||
- /gitlab-templates/windows.yml
|
||||
- /gitlab-templates/windows-static.yml
|
||||
8
Telegram/ThirdParty/kcoreaddons/.kde-ci.yml
vendored
Normal file
8
Telegram/ThirdParty/kcoreaddons/.kde-ci.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
Dependencies:
|
||||
- 'on': ['@all']
|
||||
'require':
|
||||
'frameworks/extra-cmake-modules': '@same'
|
||||
|
||||
Options:
|
||||
test-before-installing: True
|
||||
require-passing-tests-on: [ 'Linux' ]
|
||||
158
Telegram/ThirdParty/kcoreaddons/CMakeLists.txt
vendored
Normal file
158
Telegram/ThirdParty/kcoreaddons/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(KF_VERSION "5.116.0") # handled by release scripts
|
||||
project(KCoreAddons VERSION ${KF_VERSION})
|
||||
|
||||
include(FeatureSummary)
|
||||
find_package(ECM 5.116.0 NO_MODULE)
|
||||
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
|
||||
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
include(KDEInstallDirs)
|
||||
include(KDECMakeSettings)
|
||||
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
|
||||
include(KDEGitCommitHooks)
|
||||
|
||||
include(ECMGenerateExportHeader)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(ECMSetupVersion)
|
||||
include(ECMGenerateHeaders)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
include(ECMAddQch)
|
||||
include(ECMSetupQtPluginMacroNames)
|
||||
include(ECMDeprecationSettings)
|
||||
|
||||
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
||||
|
||||
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF)
|
||||
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")
|
||||
|
||||
set(REQUIRED_QT_VERSION 5.15.2)
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core)
|
||||
|
||||
ecm_setup_qtplugin_macro_names(
|
||||
JSON_NONE
|
||||
"K_PLUGIN_FACTORY"
|
||||
"K_PLUGIN_CLASS"
|
||||
JSON_ARG2
|
||||
"K_PLUGIN_FACTORY_WITH_JSON"
|
||||
"K_PLUGIN_CLASS_WITH_JSON"
|
||||
CONFIG_CODE_VARIABLE
|
||||
PACKAGE_SETUP_AUTOMOC_VARIABLES
|
||||
)
|
||||
|
||||
if(NOT WIN32)
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
|
||||
# Configure checks for kdirwatch
|
||||
find_package(FAM)
|
||||
|
||||
set_package_properties(FAM PROPERTIES
|
||||
PURPOSE "Provides file alteration notification facilities using a separate service. FAM provides additional support for NFS.")
|
||||
|
||||
set(HAVE_FAM ${FAM_FOUND})
|
||||
|
||||
option(ENABLE_INOTIFY "Try to use inotify for directory monitoring" ON)
|
||||
if(ENABLE_INOTIFY)
|
||||
# Find libinotify
|
||||
find_package(Inotify)
|
||||
set_package_properties(Inotify PROPERTIES
|
||||
PURPOSE "Filesystem alteration notifications using inotify")
|
||||
set(HAVE_SYS_INOTIFY_H ${Inotify_FOUND})
|
||||
else()
|
||||
set(HAVE_SYS_INOTIFY_H FALSE)
|
||||
endif()
|
||||
|
||||
set(HAVE_PROCSTAT FALSE)
|
||||
string(REGEX MATCH "[Bb][Ss][Dd]" BSDLIKE ${CMAKE_SYSTEM_NAME})
|
||||
if (BSDLIKE)
|
||||
option(ENABLE_PROCSTAT "Try to use libprocstat for process information (for BSD-like systems)" ON)
|
||||
if (ENABLE_PROCSTAT)
|
||||
# Find libprocstat
|
||||
find_package(Procstat)
|
||||
set_package_properties(Procstat PROPERTIES
|
||||
PURPOSE "Process information using libprocstat")
|
||||
set(HAVE_PROCSTAT ${PROCSTAT_FOUND})
|
||||
endif()
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
set_package_properties(Procstat PROPERTIES
|
||||
TYPE REQUIRED
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT WIN32) # never relevant there
|
||||
find_package(Qt${QT_MAJOR_VERSION}DBus ${QT_MIN_VERSION} CONFIG)
|
||||
set(HAVE_QTDBUS ${Qt${QT_MAJOR_VERSION}DBus_FOUND})
|
||||
add_feature_info(XDGPortalDragAndDrop HAVE_QTDBUS "Drag and Drop support via xdg-desktop-portal requies QtDBus")
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
find_package(UDev) # Used by KFilesystemType
|
||||
set(HAVE_UDEV ${UDev_FOUND})
|
||||
endif()
|
||||
|
||||
configure_file(src/lib/io/config-kdirwatch.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/lib/io/config-kdirwatch.h)
|
||||
|
||||
configure_file(src/lib/io/config-kfilesystemtype.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/lib/io/config-kfilesystemtype.h)
|
||||
|
||||
include(ECMPoQmTools)
|
||||
|
||||
ecm_setup_version(PROJECT VARIABLE_PREFIX KCOREADDONS
|
||||
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kcoreaddons_version.h"
|
||||
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5CoreAddonsConfigVersion.cmake"
|
||||
SOVERSION 5)
|
||||
|
||||
|
||||
ecm_install_po_files_as_qm(poqm)
|
||||
|
||||
kde_enable_exceptions()
|
||||
|
||||
|
||||
ecm_set_disabled_deprecation_versions(
|
||||
QT 5.14.0 # Not 5.15 because of qsrand
|
||||
)
|
||||
|
||||
add_subdirectory(src)
|
||||
if (BUILD_TESTING)
|
||||
add_subdirectory(autotests)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
# create a Config.cmake and a ConfigVersion.cmake file and install them
|
||||
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5CoreAddons")
|
||||
|
||||
if (BUILD_QCH)
|
||||
ecm_install_qch_export(
|
||||
TARGETS KF5CoreAddons_QCH
|
||||
FILE KF5CoreAddonsQchTargets.cmake
|
||||
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5CoreAddonsQchTargets.cmake\")")
|
||||
endif()
|
||||
|
||||
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KF5CoreAddonsConfig.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/KF5CoreAddonsConfig.cmake"
|
||||
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5CoreAddonsConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/KF5CoreAddonsConfigVersion.cmake"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/KF5CoreAddonsMacros.cmake"
|
||||
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
|
||||
COMPONENT Devel )
|
||||
|
||||
install(EXPORT KF5CoreAddonsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5CoreAddonsTargets.cmake NAMESPACE KF5:: )
|
||||
install(EXPORT KF5CoreAddonsToolingTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5CoreAddonsToolingTargets.cmake NAMESPACE KF5:: )
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kcoreaddons_version.h
|
||||
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KCoreAddons COMPONENT Devel)
|
||||
|
||||
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
|
||||
55
Telegram/ThirdParty/kcoreaddons/KF5CoreAddonsConfig.cmake.in
vendored
Normal file
55
Telegram/ThirdParty/kcoreaddons/KF5CoreAddonsConfig.cmake.in
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(Qt@QT_MAJOR_VERSION@Core @REQUIRED_QT_VERSION@)
|
||||
|
||||
if(NOT @BUILD_SHARED_LIBS@)
|
||||
if(NOT WIN32)
|
||||
find_dependency(Threads)
|
||||
endif()
|
||||
|
||||
# Should be if(Inotify_FOUND) here, but for some reason this doesn't work when building statically
|
||||
# due to ECM's FindInotify.cmake misbehavior — see https://bugs.kde.org/show_bug.cgi?id=460656 for details.
|
||||
# This workaround stops CMake from failing on Linux by relying on the fact that Inotify is built into
|
||||
# kernel there, so no additional linking is required, resulting in an empty Inotify_LIBRARIES var.
|
||||
# The issue (most likely) persists on BSD, though, where Inotify is, in fact, provided by a library.
|
||||
if(@Inotify_LIBRARIES@)
|
||||
find_dependency(Inotify)
|
||||
endif()
|
||||
|
||||
if(@Procstat_FOUND@)
|
||||
find_dependency(Procstat)
|
||||
endif()
|
||||
|
||||
if(@HAVE_QTDBUS@)
|
||||
find_dependency(Qt@QT_MAJOR_VERSION@DBus @REQUIRED_QT_VERSION@)
|
||||
endif()
|
||||
|
||||
if (@UDev_FOUND@)
|
||||
find_dependency(UDev)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@PACKAGE_SETUP_AUTOMOC_VARIABLES@
|
||||
|
||||
if(CMAKE_CROSSCOMPILING AND KF5_HOST_TOOLING)
|
||||
find_file(KCOREADDONS_TARGETSFILE KF5CoreAddons/KF5CoreAddonsToolingTargets.cmake
|
||||
PATHS ${KF5_HOST_TOOLING} ${CMAKE_CURRENT_LIST_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH)
|
||||
include("${KCOREADDONS_TARGETSFILE}")
|
||||
# Check that the host tool version is the same to avoid incompatibilities.
|
||||
get_target_property(HOST_TOOL_VERSION KF5::desktoptojson TOOL_VERSION)
|
||||
if (NOT ("${HOST_TOOL_VERSION}" VERSION_EQUAL "@KF_VERSION@"))
|
||||
message(WARNING "Found incompatible host tool version ${HOST_TOOL_VERSION}, expected @KF_VERSION@")
|
||||
endif()
|
||||
else()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/KF5CoreAddonsToolingTargets.cmake")
|
||||
if(CMAKE_CROSSCOMPILING AND DESKTOPTOJSON_EXECUTABLE)
|
||||
set_target_properties(KF5::desktoptojson PROPERTIES IMPORTED_LOCATION_NONE ${DESKTOPTOJSON_EXECUTABLE})
|
||||
set_target_properties(KF5::desktoptojson PROPERTIES IMPORTED_LOCATION ${DESKTOPTOJSON_EXECUTABLE})
|
||||
endif()
|
||||
endif()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/KF5CoreAddonsTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/KF5CoreAddonsMacros.cmake")
|
||||
@PACKAGE_INCLUDE_QCHTARGETS@
|
||||
274
Telegram/ThirdParty/kcoreaddons/KF5CoreAddonsMacros.cmake
vendored
Normal file
274
Telegram/ThirdParty/kcoreaddons/KF5CoreAddonsMacros.cmake
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
#
|
||||
# kcoreaddons_desktop_to_json(target desktopfile
|
||||
# DEFAULT_SERVICE_TYPE | SERVICE_TYPES <file> [<file> [...]]
|
||||
# [OUTPUT_DIR dir | OUTPUT_FILE file] [COMPAT_MODE])
|
||||
#
|
||||
# This macro uses desktoptojson to generate a json file from a plugin
|
||||
# description in a .desktop file. The generated file can be compiled
|
||||
# into the plugin using the K_PLUGIN_FACTORY_WITH_JSON (cpp) macro.
|
||||
#
|
||||
# All files in SERVICE_TYPES will be parsed by desktoptojson to ensure that the generated
|
||||
# json uses the right data type (string, string list, int, double or bool) for all of the
|
||||
# properties. If your application does not have any custom properties defined you should pass
|
||||
# DEFAULT_SERVICE_TYPE instead. It is an error if neither of these arguments is given.
|
||||
# This is done in order to ensure that all applications explicitly choose the right service
|
||||
# type and don't have runtime errors because of the data being wrong (QJsonValue does not
|
||||
# perform any type conversions).
|
||||
#
|
||||
# If COMPAT_MODE is passed as an argument the generated JSON file will be compatible with
|
||||
# the metadata format used by KPluginInfo (from KService), otherwise it will default to
|
||||
# the new format that is used by KPluginMetaData (from KCoreAddons).
|
||||
#
|
||||
# If OUTPUT_DIR is set the generated file will be created inside <dir> instead of in
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}
|
||||
#
|
||||
# If OUTPUT_FILE is set the generated file will be <file> instead of the default
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/$(basename desktopfile).json
|
||||
# .. note::
|
||||
# This is only considered porting aid and will be removed in KF6. Please convert the desktop files
|
||||
# in-source to json using the desktoptojson executable
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# kcoreaddons_desktop_to_json(plasma_engine_time plasma-dataengine-time.desktop
|
||||
# SERVICE_TYPES plasma-dataengine.desktop)
|
||||
|
||||
function(kcoreaddons_desktop_to_json target desktop)
|
||||
message(WARNING "kcoreaddons_desktop_to_json is deprecated and will be removed in KF6. Convert the desktop files to JSON in source using the desktoptojson executable")
|
||||
get_filename_component(desktop_basename ${desktop} NAME_WE) # allow passing an absolute path to the .desktop
|
||||
cmake_parse_arguments(DESKTOP_TO_JSON "COMPAT_MODE;DEFAULT_SERVICE_TYPE" "OUTPUT_DIR;OUTPUT_FILE" "SERVICE_TYPES" ${ARGN})
|
||||
|
||||
if(DESKTOP_TO_JSON_OUTPUT_FILE)
|
||||
set(json "${DESKTOP_TO_JSON_OUTPUT_FILE}")
|
||||
elseif(DESKTOP_TO_JSON_OUTPUT_DIR)
|
||||
set(json "${DESKTOP_TO_JSON_OUTPUT_DIR}/${desktop_basename}.json")
|
||||
else()
|
||||
set(json "${CMAKE_CURRENT_BINARY_DIR}/${desktop_basename}.json")
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 2.8.12.20140127 OR "${target}" STREQUAL "")
|
||||
_desktop_to_json_cmake28(${desktop} ${json} ${DESKTOP_TO_JSON_COMPAT_MODE})
|
||||
return()
|
||||
elseif(MSVC_IDE AND CMAKE_VERSION VERSION_LESS 3.0)
|
||||
# autogen dependencies for visual studio generator are broken until cmake commit 2ed0d06
|
||||
_desktop_to_json_cmake28(${desktop} ${json} ${DESKTOP_TO_JSON_COMPAT_MODE})
|
||||
return()
|
||||
endif()
|
||||
kcoreaddons_desktop_to_json_crosscompilation_args(_crosscompile_args)
|
||||
set(command KF5::desktoptojson ${_crosscompile_args} -i ${desktop} -o ${json})
|
||||
if(DESKTOP_TO_JSON_COMPAT_MODE)
|
||||
list(APPEND command -c)
|
||||
endif()
|
||||
if(DESKTOP_TO_JSON_SERVICE_TYPES)
|
||||
foreach(type ${DESKTOP_TO_JSON_SERVICE_TYPES})
|
||||
if(NOT IS_ABSOLUTE "${type}")
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
if (DEFINED KSERVICETYPE_PATH_${type})
|
||||
set(_guess ${KSERVICETYPE_PATH_${type}})
|
||||
else()
|
||||
set(_guess ${CMAKE_SYSROOT}/${KDE_INSTALL_FULL_KSERVICETYPESDIR}/${type})
|
||||
endif()
|
||||
if(EXISTS ${_guess})
|
||||
set(type ${CMAKE_SYSROOT}/${KDE_INSTALL_FULL_KSERVICETYPESDIR}/${type})
|
||||
else()
|
||||
message(WARNING "Could not find service type ${type}, tried ${_guess}. Set KSERVICETYPE_PATH_${type} to override this guess.")
|
||||
endif()
|
||||
elseif(EXISTS ${KDE_INSTALL_FULL_KSERVICETYPESDIR}/${type})
|
||||
set(type ${KDE_INSTALL_FULL_KSERVICETYPESDIR}/${type})
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND command -s ${type})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
file(RELATIVE_PATH relativejson ${CMAKE_CURRENT_BINARY_DIR} ${json})
|
||||
add_custom_command(
|
||||
OUTPUT ${json}
|
||||
COMMAND ${command}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDS ${desktop}
|
||||
COMMENT "Generating ${relativejson}"
|
||||
)
|
||||
set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${json})
|
||||
endfunction()
|
||||
|
||||
# Internal function to get the additional arguments that should be passed to desktoptojson when cross-compiling
|
||||
function(kcoreaddons_desktop_to_json_crosscompilation_args output_var)
|
||||
set(_extra_args)
|
||||
# When cross-compiling we can't use relative paths since that might find an incompatible file on the host
|
||||
# using QStandardPaths (or not find any at all e.g. when cross-compiling from macOS).
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(_extra_args --strict-path-mode --generic-data-path "${CMAKE_SYSROOT}/${KDE_INSTALL_FULL_DATAROOTDIR}")
|
||||
endif()
|
||||
set(${output_var} ${_extra_args} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_desktop_to_json_cmake28 desktop json compat)
|
||||
# This function runs desktoptojson at *configure* time, ie, when CMake runs.
|
||||
# This is necessary with CMake < 3.0.0 because the .json file must be
|
||||
# generated before moc is run, and there was no way until CMake 3.0.0 to
|
||||
# define a target as a dependency of the automoc target.
|
||||
message("Using CMake 2.8 way to call desktoptojson")
|
||||
get_target_property(DESKTOPTOJSON_LOCATION KF5::desktoptojson LOCATION)
|
||||
if(compat)
|
||||
execute_process(
|
||||
COMMAND ${DESKTOPTOJSON_LOCATION} -i ${desktop} -o ${json} -c
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND ${DESKTOPTOJSON_LOCATION} -i ${desktop} -o ${json}
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT result EQUAL 0)
|
||||
message(FATAL_ERROR "Generating ${json} failed")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#
|
||||
# kcoreaddons_add_plugin(plugin_name
|
||||
# [SOURCES <src> [<src> [...]]] # optional since 5.83, required before
|
||||
# [JSON "pluginname.json"]
|
||||
# [STATIC]
|
||||
# [INSTALL_NAMESPACE "servicename"]
|
||||
# )
|
||||
#
|
||||
# This macro helps simplifying the creation of plugins for KPluginFactory
|
||||
# based systems.
|
||||
# It will create a plugin given the SOURCES list and the INSTALL_NAMESPACE so that
|
||||
# the plugin is installed with the rest of the plugins from the same sub-system,
|
||||
# within ${KDE_INSTALL_PLUGINDIR}.
|
||||
# The JSON parameter is deprecated since 5.85, because it is not needed when the project is properly set up using
|
||||
# the ECMSetupQtPluginMacroNames module. In case of plugin export macros provided by the KDE Frameworks this is already done and the parameter
|
||||
# can be dropped with any older KF5 requirement.
|
||||
# In case you generate the JSON files during the build it should be manually added to the AUTOGEN_TARGET_DEPENDS property,
|
||||
# the kcoreaddons_desktop_to_json already does this for the generated file.
|
||||
# Since 5.89 the macro supports static plugins by passing in the STATIC option.
|
||||
#
|
||||
# Example:
|
||||
# kcoreaddons_add_plugin(kdeconnect_share SOURCES ${kdeconnect_share_SRCS} INSTALL_NAMESPACE "kdeconnect")
|
||||
#
|
||||
# Since 5.10.0
|
||||
|
||||
function(kcoreaddons_add_plugin plugin)
|
||||
set(options STATIC)
|
||||
set(oneValueArgs JSON INSTALL_NAMESPACE)
|
||||
set(multiValueArgs SOURCES)
|
||||
cmake_parse_arguments(KCA_ADD_PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT KCA_ADD_PLUGIN_INSTALL_NAMESPACE)
|
||||
message(FATAL_ERROR "Must specify INSTALL_NAMESPACE for ${plugin}")
|
||||
endif()
|
||||
if (KCA_ADD_PLUGIN_UNPARSED_ARGUMENTS)
|
||||
if ("${ECM_GLOBAL_FIND_VERSION}" VERSION_GREATER_EQUAL "5.91.0")
|
||||
message(FATAL_ERROR "kcoreaddons_add_plugin method call recieved unexpected arguments: ${KCA_ADD_PLUGIN_UNPARSED_ARGUMENTS}")
|
||||
else()
|
||||
message(WARNING "kcoreaddons_add_plugin method call recieved unexpected arguments: ${KCA_ADD_PLUGIN_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(REPLACE "-" "_" SANITIZED_PLUGIN_NAME ${plugin})
|
||||
string(REPLACE "." "_" SANITIZED_PLUGIN_NAME ${SANITIZED_PLUGIN_NAME})
|
||||
if (KCA_ADD_PLUGIN_STATIC)
|
||||
add_library(${plugin} STATIC ${KCA_ADD_PLUGIN_SOURCES})
|
||||
target_compile_definitions(${plugin} PRIVATE QT_STATICPLUGIN)
|
||||
set_property(TARGET ${plugin} PROPERTY AUTOMOC_MOC_OPTIONS -MX-KDE-FileName=${KCA_ADD_PLUGIN_INSTALL_NAMESPACE}/${plugin})
|
||||
string(REPLACE "/" "_" SANITIZED_PLUGIN_NAMESPACE ${KCA_ADD_PLUGIN_INSTALL_NAMESPACE})
|
||||
|
||||
if (NOT ${SANITIZED_PLUGIN_NAME} IN_LIST KCOREADDONS_STATIC_PLUGINS${SANITIZED_PLUGIN_NAMESPACE})
|
||||
set(KCOREADDONS_STATIC_PLUGINS${SANITIZED_PLUGIN_NAMESPACE} "${KCOREADDONS_STATIC_PLUGINS${SANITIZED_PLUGIN_NAMESPACE}};${SANITIZED_PLUGIN_NAME}" CACHE INTERNAL "list of known static plugins for ${KCA_ADD_PLUGIN_INSTALL_NAMESPACE} namespace, used to generate Q_IMPORT_PLUGIN macros")
|
||||
endif()
|
||||
else()
|
||||
add_library(${plugin} MODULE ${KCA_ADD_PLUGIN_SOURCES})
|
||||
endif()
|
||||
|
||||
if ("${ECM_GLOBAL_FIND_VERSION}" VERSION_GREATER_EQUAL "5.85.0" AND KCA_ADD_PLUGIN_JSON)
|
||||
message(WARNING "Setting the JSON parameter is deprecated, see function docs for details")
|
||||
endif()
|
||||
get_filename_component(json "${KCA_ADD_PLUGIN_JSON}" REALPATH)
|
||||
set_property(TARGET ${plugin} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${json})
|
||||
|
||||
|
||||
if ("${ECM_GLOBAL_FIND_VERSION}" VERSION_GREATER_EQUAL "5.88.0")
|
||||
target_compile_definitions(${plugin} PRIVATE KPLUGINFACTORY_PLUGIN_CLASS_INTERNAL_NAME=${SANITIZED_PLUGIN_NAME}_factory)
|
||||
endif()
|
||||
|
||||
# If we have static plugins there are no plugins to install
|
||||
if (KCA_ADD_PLUGIN_STATIC)
|
||||
return()
|
||||
endif()
|
||||
# If find_package(ECM 5.38) or higher is called, output the plugin in a INSTALL_NAMESPACE subfolder.
|
||||
# See https://community.kde.org/Guidelines_and_HOWTOs/Making_apps_run_uninstalled
|
||||
# From 5.90 we went back to putting the plugins in a INSTALL_NAMESPACE subfolder in the builddir, but
|
||||
# without putting that in a "plugins/" dir as that broke running unittests directly on the command line
|
||||
# (i.e. without using ctest, e.g. in gdb).
|
||||
if(ECM_GLOBAL_FIND_VERSION VERSION_EQUAL "5.88.0" OR ECM_GLOBAL_FIND_VERSION VERSION_EQUAL "5.89.0")
|
||||
set_target_properties(${plugin} PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugins/${KCA_ADD_PLUGIN_INSTALL_NAMESPACE}")
|
||||
elseif(ECM_GLOBAL_FIND_VERSION VERSION_GREATER_EQUAL "5.38.0")
|
||||
set_target_properties(${plugin} PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${KCA_ADD_PLUGIN_INSTALL_NAMESPACE}")
|
||||
endif()
|
||||
|
||||
if (NOT KCOREADDONS_INTERNAL_SKIP_PLUGIN_INSTALLATION)
|
||||
if(NOT ANDROID)
|
||||
install(TARGETS ${plugin} DESTINATION ${KDE_INSTALL_PLUGINDIR}/${KCA_ADD_PLUGIN_INSTALL_NAMESPACE})
|
||||
else()
|
||||
string(REPLACE "/" "_" pluginprefix "${KCA_ADD_PLUGIN_INSTALL_NAMESPACE}")
|
||||
set_property(TARGET ${plugin} PROPERTY PREFIX "libplugins_")
|
||||
if(NOT pluginprefix STREQUAL "")
|
||||
set_property(TARGET ${plugin} APPEND_STRING PROPERTY PREFIX "${pluginprefix}_")
|
||||
endif()
|
||||
install(TARGETS ${plugin} DESTINATION ${KDE_INSTALL_PLUGINDIR})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# This macro imports the plugins for the given namespace that were
|
||||
# registered using the kcoreaddons_add_plugin function.
|
||||
# This includes the K_IMPORT_PLUGIN statements and linking the plugins to the given target.
|
||||
#
|
||||
# In case the plugins are used in both the executable and multiple autotests it it recommended to
|
||||
# bundle the static plugins in a shared lib for the autotests. In case of shared libs the plugin registrations
|
||||
# will take effect when the test link against it.
|
||||
#
|
||||
# Since 5.89
|
||||
function(kcoreaddons_target_static_plugins app_target plugin_namespace)
|
||||
cmake_parse_arguments(ARGS "" "LINK_OPTION" "" ${ARGN})
|
||||
set(IMPORT_PLUGIN_STATEMENTS "#include <kstaticpluginhelpers.h>\n\n")
|
||||
string(REPLACE "/" "_" SANITIZED_PLUGIN_NAMESPACE ${plugin_namespace})
|
||||
set(TMP_PLUGIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/kcoreaddons_static_${SANITIZED_PLUGIN_NAMESPACE}_plugins_tmp.cpp")
|
||||
set(PLUGIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/kcoreaddons_static_${SANITIZED_PLUGIN_NAMESPACE}_plugins.cpp")
|
||||
|
||||
foreach(PLUGIN_TARGET_NAME IN LISTS KCOREADDONS_STATIC_PLUGINS${SANITIZED_PLUGIN_NAMESPACE})
|
||||
if (PLUGIN_TARGET_NAME)
|
||||
set(IMPORT_PLUGIN_STATEMENTS "${IMPORT_PLUGIN_STATEMENTS}K_IMPORT_PLUGIN(QStringLiteral(\"${plugin_namespace}\"), ${PLUGIN_TARGET_NAME}_factory)\;\n")
|
||||
target_link_libraries(${app_target} ${ARGS_LINK_OPTION} ${PLUGIN_TARGET_NAME})
|
||||
endif()
|
||||
endforeach()
|
||||
file(WRITE ${TMP_PLUGIN_FILE} ${IMPORT_PLUGIN_STATEMENTS})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TMP_PLUGIN_FILE} ${PLUGIN_FILE})
|
||||
file(REMOVE ${TMP_PLUGIN_FILE})
|
||||
if(ECM_GLOBAL_FIND_VERSION VERSION_GREATER_EQUAL "5.91.0")
|
||||
target_sources(${app_target} PRIVATE ${PLUGIN_FILE})
|
||||
else()
|
||||
# in case of apps bundling their plugins in a small static lib the linking needs to be public
|
||||
# see API docs for a better solution in consumer's code.
|
||||
# Because this will not change the behavior if the plugins are targeted directly to the executable, only
|
||||
# an ECM version check is used and not an additional option.
|
||||
target_sources(${app_target} PUBLIC ${PLUGIN_FILE})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Clear previously set plugins, otherwise Q_IMPORT_PLUGIN statements
|
||||
# will fail to compile if plugins got removed from the build
|
||||
get_directory_property(_cache_vars CACHE_VARIABLES)
|
||||
foreach(CACHED_VAR IN LISTS _cache_vars)
|
||||
if (CACHED_VAR MATCHES "^KCOREADDONS_STATIC_PLUGINS")
|
||||
set(${CACHED_VAR} "" CACHE INTERNAL "")
|
||||
endif()
|
||||
endforeach()
|
||||
22
Telegram/ThirdParty/kcoreaddons/LICENSES/BSD-2-Clause.txt
vendored
Normal file
22
Telegram/ThirdParty/kcoreaddons/LICENSES/BSD-2-Clause.txt
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) <year> <owner>. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
26
Telegram/ThirdParty/kcoreaddons/LICENSES/BSD-3-Clause.txt
vendored
Normal file
26
Telegram/ThirdParty/kcoreaddons/LICENSES/BSD-3-Clause.txt
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Copyright (c) <year> <owner>. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
121
Telegram/ThirdParty/kcoreaddons/LICENSES/CC0-1.0.txt
vendored
Normal file
121
Telegram/ThirdParty/kcoreaddons/LICENSES/CC0-1.0.txt
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
||||
319
Telegram/ThirdParty/kcoreaddons/LICENSES/GPL-2.0-only.txt
vendored
Normal file
319
Telegram/ThirdParty/kcoreaddons/LICENSES/GPL-2.0-only.txt
vendored
Normal file
@@ -0,0 +1,319 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share
|
||||
and change it. By contrast, the GNU General Public License is intended to
|
||||
guarantee your freedom to share and change free software--to make sure the
|
||||
software is free for all its users. This General Public License applies to
|
||||
most of the Free Software Foundation's software and to any other program whose
|
||||
authors commit to using it. (Some other Free Software Foundation software
|
||||
is covered by the GNU Lesser General Public License instead.) You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for this service if you
|
||||
wish), that you receive source code or can get it if you want it, that you
|
||||
can change the software or use pieces of it in new free programs; and that
|
||||
you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to
|
||||
deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of
|
||||
the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or
|
||||
for a fee, you must give the recipients all the rights that you have. You
|
||||
must make sure that they, too, receive or can get the source code. And you
|
||||
must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and (2)
|
||||
offer you this license which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain that
|
||||
everyone understands that there is no warranty for this free software. If
|
||||
the software is modified by someone else and passed on, we want its recipients
|
||||
to know that what they have is not the original, so that any problems introduced
|
||||
by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We
|
||||
wish to avoid the danger that redistributors of a free program will individually
|
||||
obtain patent licenses, in effect making the program proprietary. To prevent
|
||||
this, we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains a notice
|
||||
placed by the copyright holder saying it may be distributed under the terms
|
||||
of this General Public License. The "Program", below, refers to any such program
|
||||
or work, and a "work based on the Program" means either the Program or any
|
||||
derivative work under copyright law: that is to say, a work containing the
|
||||
Program or a portion of it, either verbatim or with modifications and/or translated
|
||||
into another language. (Hereinafter, translation is included without limitation
|
||||
in the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running the Program
|
||||
is not restricted, and the output from the Program is covered only if its
|
||||
contents constitute a work based on the Program (independent of having been
|
||||
made by running the Program). Whether that is true depends on what the Program
|
||||
does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source code
|
||||
as you receive it, in any medium, provided that you conspicuously and appropriately
|
||||
publish on each copy an appropriate copyright notice and disclaimer of warranty;
|
||||
keep intact all the notices that refer to this License and to the absence
|
||||
of any warranty; and give any other recipients of the Program a copy of this
|
||||
License along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of it,
|
||||
thus forming a work based on the Program, and copy and distribute such modifications
|
||||
or work under the terms of Section 1 above, provided that you also meet all
|
||||
of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in whole or
|
||||
in part contains or is derived from the Program or any part thereof, to be
|
||||
licensed as a whole at no charge to all third parties under the terms of this
|
||||
License.
|
||||
|
||||
c) If the modified program normally reads commands interactively when run,
|
||||
you must cause it, when started running for such interactive use in the most
|
||||
ordinary way, to print or display an announcement including an appropriate
|
||||
copyright notice and a notice that there is no warranty (or else, saying that
|
||||
you provide a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this License.
|
||||
(Exception: if the Program itself is interactive but does not normally print
|
||||
such an announcement, your work based on the Program is not required to print
|
||||
an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Program, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them as
|
||||
separate works. But when you distribute the same sections as part of a whole
|
||||
which is a work based on the Program, the distribution of the whole must be
|
||||
on the terms of this License, whose permissions for other licensees extend
|
||||
to the entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your
|
||||
rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works based
|
||||
on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program with
|
||||
the Program (or with a work based on the Program) on a volume of a storage
|
||||
or distribution medium does not bring the other work under the scope of this
|
||||
License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, under Section
|
||||
2) in object code or executable form under the terms of Sections 1 and 2 above
|
||||
provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable source code,
|
||||
which must be distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three years, to give
|
||||
any third party, for a charge no more than your cost of physically performing
|
||||
source distribution, a complete machine-readable copy of the corresponding
|
||||
source code, to be distributed under the terms of Sections 1 and 2 above on
|
||||
a medium customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer to distribute
|
||||
corresponding source code. (This alternative is allowed only for noncommercial
|
||||
distribution and only if you received the program in object code or executable
|
||||
form with such an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for making
|
||||
modifications to it. For an executable work, complete source code means all
|
||||
the source code for all modules it contains, plus any associated interface
|
||||
definition files, plus the scripts used to control compilation and installation
|
||||
of the executable. However, as a special exception, the source code distributed
|
||||
need not include anything that is normally distributed (in either source or
|
||||
binary form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component itself
|
||||
accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering access to
|
||||
copy from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place counts as distribution of the source code,
|
||||
even though third parties are not compelled to copy the source along with
|
||||
the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program except
|
||||
as expressly provided under this License. Any attempt otherwise to copy, modify,
|
||||
sublicense or distribute the Program is void, and will automatically terminate
|
||||
your rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses terminated
|
||||
so long as such parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not signed
|
||||
it. However, nothing else grants you permission to modify or distribute the
|
||||
Program or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the Program
|
||||
(or any work based on the Program), you indicate your acceptance of this License
|
||||
to do so, and all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the Program),
|
||||
the recipient automatically receives a license from the original licensor
|
||||
to copy, distribute or modify the Program subject to these terms and conditions.
|
||||
You may not impose any further restrictions on the recipients' exercise of
|
||||
the rights granted herein. You are not responsible for enforcing compliance
|
||||
by third parties to this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent infringement
|
||||
or for any other reason (not limited to patent issues), conditions are imposed
|
||||
on you (whether by court order, agreement or otherwise) that contradict the
|
||||
conditions of this License, they do not excuse you from the conditions of
|
||||
this License. If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations, then as
|
||||
a consequence you may not distribute the Program at all. For example, if a
|
||||
patent license would not permit royalty-free redistribution of the Program
|
||||
by all those who receive copies directly or indirectly through you, then the
|
||||
only way you could satisfy both it and this License would be to refrain entirely
|
||||
from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply and
|
||||
the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents
|
||||
or other property right claims or to contest validity of any such claims;
|
||||
this section has the sole purpose of protecting the integrity of the free
|
||||
software distribution system, which is implemented by public license practices.
|
||||
Many people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Program under this License may add an explicit geographical
|
||||
distribution limitation excluding those countries, so that distribution is
|
||||
permitted only in or among countries not thus excluded. In such case, this
|
||||
License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions of
|
||||
the General Public License from time to time. Such new versions will be similar
|
||||
in spirit to the present version, but may differ in detail to address new
|
||||
problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that version
|
||||
or of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of this License, you may choose
|
||||
any version ever published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free programs
|
||||
whose distribution conditions are different, write to the author to ask for
|
||||
permission. For software which is copyrighted by the Free Software Foundation,
|
||||
write to the Free Software Foundation; we sometimes make exceptions for this.
|
||||
Our decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing and reuse
|
||||
of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
|
||||
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
|
||||
OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
|
||||
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
|
||||
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible
|
||||
use to the public, the best way to achieve this is to make it free software
|
||||
which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach
|
||||
them to the start of each source file to most effectively convey the exclusion
|
||||
of warranty; and each file should have at least the "copyright" line and a
|
||||
pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and an idea of what it does.>
|
||||
|
||||
Copyright (C)< yyyy> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program 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, write to the Free Software Foundation, Inc., 51 Franklin
|
||||
Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this when
|
||||
it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
|
||||
with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software,
|
||||
and you are welcome to redistribute it under certain conditions; type `show
|
||||
c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may be
|
||||
called something other than `show w' and `show c'; they could even be mouse-clicks
|
||||
or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
|
||||
is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'
|
||||
(which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon >, 1 April 1989 Ty Coon, President of Vice This General
|
||||
Public License does not permit incorporating your program into proprietary
|
||||
programs. If your program is a subroutine library, you may consider it more
|
||||
useful to permit linking proprietary applications with the library. If this
|
||||
is what you want to do, use the GNU Lesser General Public License instead
|
||||
of this License.
|
||||
319
Telegram/ThirdParty/kcoreaddons/LICENSES/GPL-2.0-or-later.txt
vendored
Normal file
319
Telegram/ThirdParty/kcoreaddons/LICENSES/GPL-2.0-or-later.txt
vendored
Normal file
@@ -0,0 +1,319 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share
|
||||
and change it. By contrast, the GNU General Public License is intended to
|
||||
guarantee your freedom to share and change free software--to make sure the
|
||||
software is free for all its users. This General Public License applies to
|
||||
most of the Free Software Foundation's software and to any other program whose
|
||||
authors commit to using it. (Some other Free Software Foundation software
|
||||
is covered by the GNU Lesser General Public License instead.) You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for this service if you
|
||||
wish), that you receive source code or can get it if you want it, that you
|
||||
can change the software or use pieces of it in new free programs; and that
|
||||
you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to
|
||||
deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of
|
||||
the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or
|
||||
for a fee, you must give the recipients all the rights that you have. You
|
||||
must make sure that they, too, receive or can get the source code. And you
|
||||
must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and (2)
|
||||
offer you this license which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain that
|
||||
everyone understands that there is no warranty for this free software. If
|
||||
the software is modified by someone else and passed on, we want its recipients
|
||||
to know that what they have is not the original, so that any problems introduced
|
||||
by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We
|
||||
wish to avoid the danger that redistributors of a free program will individually
|
||||
obtain patent licenses, in effect making the program proprietary. To prevent
|
||||
this, we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains a notice
|
||||
placed by the copyright holder saying it may be distributed under the terms
|
||||
of this General Public License. The "Program", below, refers to any such program
|
||||
or work, and a "work based on the Program" means either the Program or any
|
||||
derivative work under copyright law: that is to say, a work containing the
|
||||
Program or a portion of it, either verbatim or with modifications and/or translated
|
||||
into another language. (Hereinafter, translation is included without limitation
|
||||
in the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running the Program
|
||||
is not restricted, and the output from the Program is covered only if its
|
||||
contents constitute a work based on the Program (independent of having been
|
||||
made by running the Program). Whether that is true depends on what the Program
|
||||
does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source code
|
||||
as you receive it, in any medium, provided that you conspicuously and appropriately
|
||||
publish on each copy an appropriate copyright notice and disclaimer of warranty;
|
||||
keep intact all the notices that refer to this License and to the absence
|
||||
of any warranty; and give any other recipients of the Program a copy of this
|
||||
License along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of it,
|
||||
thus forming a work based on the Program, and copy and distribute such modifications
|
||||
or work under the terms of Section 1 above, provided that you also meet all
|
||||
of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in whole or
|
||||
in part contains or is derived from the Program or any part thereof, to be
|
||||
licensed as a whole at no charge to all third parties under the terms of this
|
||||
License.
|
||||
|
||||
c) If the modified program normally reads commands interactively when run,
|
||||
you must cause it, when started running for such interactive use in the most
|
||||
ordinary way, to print or display an announcement including an appropriate
|
||||
copyright notice and a notice that there is no warranty (or else, saying that
|
||||
you provide a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this License.
|
||||
(Exception: if the Program itself is interactive but does not normally print
|
||||
such an announcement, your work based on the Program is not required to print
|
||||
an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Program, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them as
|
||||
separate works. But when you distribute the same sections as part of a whole
|
||||
which is a work based on the Program, the distribution of the whole must be
|
||||
on the terms of this License, whose permissions for other licensees extend
|
||||
to the entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your
|
||||
rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works based
|
||||
on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program with
|
||||
the Program (or with a work based on the Program) on a volume of a storage
|
||||
or distribution medium does not bring the other work under the scope of this
|
||||
License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, under Section
|
||||
2) in object code or executable form under the terms of Sections 1 and 2 above
|
||||
provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable source code,
|
||||
which must be distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three years, to give
|
||||
any third party, for a charge no more than your cost of physically performing
|
||||
source distribution, a complete machine-readable copy of the corresponding
|
||||
source code, to be distributed under the terms of Sections 1 and 2 above on
|
||||
a medium customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer to distribute
|
||||
corresponding source code. (This alternative is allowed only for noncommercial
|
||||
distribution and only if you received the program in object code or executable
|
||||
form with such an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for making
|
||||
modifications to it. For an executable work, complete source code means all
|
||||
the source code for all modules it contains, plus any associated interface
|
||||
definition files, plus the scripts used to control compilation and installation
|
||||
of the executable. However, as a special exception, the source code distributed
|
||||
need not include anything that is normally distributed (in either source or
|
||||
binary form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component itself
|
||||
accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering access to
|
||||
copy from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place counts as distribution of the source code,
|
||||
even though third parties are not compelled to copy the source along with
|
||||
the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program except
|
||||
as expressly provided under this License. Any attempt otherwise to copy, modify,
|
||||
sublicense or distribute the Program is void, and will automatically terminate
|
||||
your rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses terminated
|
||||
so long as such parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not signed
|
||||
it. However, nothing else grants you permission to modify or distribute the
|
||||
Program or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the Program
|
||||
(or any work based on the Program), you indicate your acceptance of this License
|
||||
to do so, and all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the Program),
|
||||
the recipient automatically receives a license from the original licensor
|
||||
to copy, distribute or modify the Program subject to these terms and conditions.
|
||||
You may not impose any further restrictions on the recipients' exercise of
|
||||
the rights granted herein. You are not responsible for enforcing compliance
|
||||
by third parties to this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent infringement
|
||||
or for any other reason (not limited to patent issues), conditions are imposed
|
||||
on you (whether by court order, agreement or otherwise) that contradict the
|
||||
conditions of this License, they do not excuse you from the conditions of
|
||||
this License. If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations, then as
|
||||
a consequence you may not distribute the Program at all. For example, if a
|
||||
patent license would not permit royalty-free redistribution of the Program
|
||||
by all those who receive copies directly or indirectly through you, then the
|
||||
only way you could satisfy both it and this License would be to refrain entirely
|
||||
from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply and
|
||||
the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents
|
||||
or other property right claims or to contest validity of any such claims;
|
||||
this section has the sole purpose of protecting the integrity of the free
|
||||
software distribution system, which is implemented by public license practices.
|
||||
Many people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Program under this License may add an explicit geographical
|
||||
distribution limitation excluding those countries, so that distribution is
|
||||
permitted only in or among countries not thus excluded. In such case, this
|
||||
License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions of
|
||||
the General Public License from time to time. Such new versions will be similar
|
||||
in spirit to the present version, but may differ in detail to address new
|
||||
problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that version
|
||||
or of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of this License, you may choose
|
||||
any version ever published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free programs
|
||||
whose distribution conditions are different, write to the author to ask for
|
||||
permission. For software which is copyrighted by the Free Software Foundation,
|
||||
write to the Free Software Foundation; we sometimes make exceptions for this.
|
||||
Our decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing and reuse
|
||||
of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
|
||||
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
|
||||
OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
|
||||
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
|
||||
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible
|
||||
use to the public, the best way to achieve this is to make it free software
|
||||
which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach
|
||||
them to the start of each source file to most effectively convey the exclusion
|
||||
of warranty; and each file should have at least the "copyright" line and a
|
||||
pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and an idea of what it does.>
|
||||
|
||||
Copyright (C) <yyyy> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program 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, write to the Free Software Foundation, Inc., 51 Franklin
|
||||
Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this when
|
||||
it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
|
||||
with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software,
|
||||
and you are welcome to redistribute it under certain conditions; type `show
|
||||
c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may be
|
||||
called something other than `show w' and `show c'; they could even be mouse-clicks
|
||||
or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
|
||||
is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'
|
||||
(which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General
|
||||
Public License does not permit incorporating your program into proprietary
|
||||
programs. If your program is a subroutine library, you may consider it more
|
||||
useful to permit linking proprietary applications with the library. If this
|
||||
is what you want to do, use the GNU Lesser General Public License instead
|
||||
of this License.
|
||||
625
Telegram/ThirdParty/kcoreaddons/LICENSES/GPL-3.0-only.txt
vendored
Normal file
625
Telegram/ThirdParty/kcoreaddons/LICENSES/GPL-3.0-only.txt
vendored
Normal file
@@ -0,0 +1,625 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and
|
||||
other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take
|
||||
away your freedom to share and change the works. By contrast, the GNU General
|
||||
Public License is intended to guarantee your freedom to share and change all
|
||||
versions of a program--to make sure it remains free software for all its users.
|
||||
We, the Free Software Foundation, use the GNU General Public License for most
|
||||
of our software; it applies also to any other work released this way by its
|
||||
authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for them if you wish), that
|
||||
you receive source code or can get it if you want it, that you can change
|
||||
the software or use pieces of it in new free programs, and that you know you
|
||||
can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights
|
||||
or asking you to surrender the rights. Therefore, you have certain responsibilities
|
||||
if you distribute copies of the software, or if you modify it: responsibilities
|
||||
to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or
|
||||
for a fee, you must pass on to the recipients the same freedoms that you received.
|
||||
You must make sure that they, too, receive or can get the source code. And
|
||||
you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert
|
||||
copyright on the software, and (2) offer you this License giving you legal
|
||||
permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that
|
||||
there is no warranty for this free software. For both users' and authors'
|
||||
sake, the GPL requires that modified versions be marked as changed, so that
|
||||
their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified
|
||||
versions of the software inside them, although the manufacturer can do so.
|
||||
This is fundamentally incompatible with the aim of protecting users' freedom
|
||||
to change the software. The systematic pattern of such abuse occurs in the
|
||||
area of products for individuals to use, which is precisely where it is most
|
||||
unacceptable. Therefore, we have designed this version of the GPL to prohibit
|
||||
the practice for those products. If such problems arise substantially in other
|
||||
domains, we stand ready to extend this provision to those domains in future
|
||||
versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States
|
||||
should not allow patents to restrict development and use of software on general-purpose
|
||||
computers, but in those that do, we wish to avoid the special danger that
|
||||
patents applied to a free program could make it effectively proprietary. To
|
||||
prevent this, the GPL assures that patents cannot be used to render the program
|
||||
non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works,
|
||||
such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this License.
|
||||
Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals
|
||||
or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work in
|
||||
a fashion requiring copyright permission, other than the making of an exact
|
||||
copy. The resulting work is called a "modified version" of the earlier work
|
||||
or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based on the
|
||||
Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without permission,
|
||||
would make you directly or secondarily liable for infringement under applicable
|
||||
copyright law, except executing it on a computer or modifying a private copy.
|
||||
Propagation includes copying, distribution (with or without modification),
|
||||
making available to the public, and in some countries other activities as
|
||||
well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other parties
|
||||
to make or receive copies. Mere interaction with a user through a computer
|
||||
network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to the
|
||||
extent that it includes a convenient and prominently visible feature that
|
||||
(1) displays an appropriate copyright notice, and (2) tells the user that
|
||||
there is no warranty for the work (except to the extent that warranties are
|
||||
provided), that licensees may convey the work under this License, and how
|
||||
to view a copy of this License. If the interface presents a list of user commands
|
||||
or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for making
|
||||
modifications to it. "Object code" means any non-source form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official standard
|
||||
defined by a recognized standards body, or, in the case of interfaces specified
|
||||
for a particular programming language, one that is widely used among developers
|
||||
working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other than
|
||||
the work as a whole, that (a) is included in the normal form of packaging
|
||||
a Major Component, but which is not part of that Major Component, and (b)
|
||||
serves only to enable use of the work with that Major Component, or to implement
|
||||
a Standard Interface for which an implementation is available to the public
|
||||
in source code form. A "Major Component", in this context, means a major essential
|
||||
component (kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to produce
|
||||
the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all the source
|
||||
code needed to generate, install, and (for an executable work) run the object
|
||||
code and to modify the work, including scripts to control those activities.
|
||||
However, it does not include the work's System Libraries, or general-purpose
|
||||
tools or generally available free programs which are used unmodified in performing
|
||||
those activities but which are not part of the work. For example, Corresponding
|
||||
Source includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically linked
|
||||
subprograms that the work is specifically designed to require, such as by
|
||||
intimate data communication or control flow between those subprograms and
|
||||
other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate
|
||||
automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of copyright
|
||||
on the Program, and are irrevocable provided the stated conditions are met.
|
||||
This License explicitly affirms your unlimited permission to run the unmodified
|
||||
Program. The output from running a covered work is covered by this License
|
||||
only if the output, given its content, constitutes a covered work. This License
|
||||
acknowledges your rights of fair use or other equivalent, as provided by copyright
|
||||
law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without
|
||||
conditions so long as your license otherwise remains in force. You may convey
|
||||
covered works to others for the sole purpose of having them make modifications
|
||||
exclusively for you, or provide you with facilities for running those works,
|
||||
provided that you comply with the terms of this License in conveying all material
|
||||
for which you do not control copyright. Those thus making or running the covered
|
||||
works for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of your copyrighted
|
||||
material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions
|
||||
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological measure
|
||||
under any applicable law fulfilling obligations under article 11 of the WIPO
|
||||
copyright treaty adopted on 20 December 1996, or similar laws prohibiting
|
||||
or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention
|
||||
of technological measures to the extent such circumvention is effected by
|
||||
exercising rights under this License with respect to the covered work, and
|
||||
you disclaim any intention to limit operation or modification of the work
|
||||
as a means of enforcing, against the work's users, your or third parties'
|
||||
legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you receive
|
||||
it, in any medium, provided that you conspicuously and appropriately publish
|
||||
on each copy an appropriate copyright notice; keep intact all notices stating
|
||||
that this License and any non-permissive terms added in accord with section
|
||||
7 apply to the code; keep intact all notices of the absence of any warranty;
|
||||
and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you
|
||||
may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to produce
|
||||
it from the Program, in the form of source code under the terms of section
|
||||
4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and
|
||||
giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under
|
||||
this License and any conditions added under section 7. This requirement modifies
|
||||
the requirement in section 4 to "keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone
|
||||
who comes into possession of a copy. This License will therefore apply, along
|
||||
with any applicable section 7 additional terms, to the whole of the work,
|
||||
and all its parts, regardless of how they are packaged. This License gives
|
||||
no permission to license the work in any other way, but it does not invalidate
|
||||
such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate
|
||||
Legal Notices; however, if the Program has interactive interfaces that do
|
||||
not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works,
|
||||
which are not by their nature extensions of the covered work, and which are
|
||||
not combined with it such as to form a larger program, in or on a volume of
|
||||
a storage or distribution medium, is called an "aggregate" if the compilation
|
||||
and its resulting copyright are not used to limit the access or legal rights
|
||||
of the compilation's users beyond what the individual works permit. Inclusion
|
||||
of a covered work in an aggregate does not cause this License to apply to
|
||||
the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of sections
|
||||
4 and 5, provided that you also convey the machine-readable Corresponding
|
||||
Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including
|
||||
a physical distribution medium), accompanied by the Corresponding Source fixed
|
||||
on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including
|
||||
a physical distribution medium), accompanied by a written offer, valid for
|
||||
at least three years and valid for as long as you offer spare parts or customer
|
||||
support for that product model, to give anyone who possesses the object code
|
||||
either (1) a copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical medium customarily
|
||||
used for software interchange, for a price no more than your reasonable cost
|
||||
of physically performing this conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written
|
||||
offer to provide the Corresponding Source. This alternative is allowed only
|
||||
occasionally and noncommercially, and only if you received the object code
|
||||
with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis
|
||||
or for a charge), and offer equivalent access to the Corresponding Source
|
||||
in the same way through the same place at no further charge. You need not
|
||||
require recipients to copy the Corresponding Source along with the object
|
||||
code. If the place to copy the object code is a network server, the Corresponding
|
||||
Source may be on a different server (operated by you or a third party) that
|
||||
supports equivalent copying facilities, provided you maintain clear directions
|
||||
next to the object code saying where to find the Corresponding Source. Regardless
|
||||
of what server hosts the Corresponding Source, you remain obligated to ensure
|
||||
that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform
|
||||
other peers where the object code and Corresponding Source of the work are
|
||||
being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from
|
||||
the Corresponding Source as a System Library, need not be included in conveying
|
||||
the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any tangible
|
||||
personal property which is normally used for personal, family, or household
|
||||
purposes, or (2) anything designed or sold for incorporation into a dwelling.
|
||||
In determining whether a product is a consumer product, doubtful cases shall
|
||||
be resolved in favor of coverage. For a particular product received by a particular
|
||||
user, "normally used" refers to a typical or common use of that class of product,
|
||||
regardless of the status of the particular user or of the way in which the
|
||||
particular user actually uses, or expects or is expected to use, the product.
|
||||
A product is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent the
|
||||
only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods, procedures,
|
||||
authorization keys, or other information required to install and execute modified
|
||||
versions of a covered work in that User Product from a modified version of
|
||||
its Corresponding Source. The information must suffice to ensure that the
|
||||
continued functioning of the modified object code is in no case prevented
|
||||
or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically
|
||||
for use in, a User Product, and the conveying occurs as part of a transaction
|
||||
in which the right of possession and use of the User Product is transferred
|
||||
to the recipient in perpetuity or for a fixed term (regardless of how the
|
||||
transaction is characterized), the Corresponding Source conveyed under this
|
||||
section must be accompanied by the Installation Information. But this requirement
|
||||
does not apply if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has been installed
|
||||
in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement
|
||||
to continue to provide support service, warranty, or updates for a work that
|
||||
has been modified or installed by the recipient, or for the User Product in
|
||||
which it has been modified or installed. Access to a network may be denied
|
||||
when the modification itself materially and adversely affects the operation
|
||||
of the network or violates the rules and protocols for communication across
|
||||
the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord
|
||||
with this section must be in a format that is publicly documented (and with
|
||||
an implementation available to the public in source code form), and must require
|
||||
no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this License
|
||||
by making exceptions from one or more of its conditions. Additional permissions
|
||||
that are applicable to the entire Program shall be treated as though they
|
||||
were included in this License, to the extent that they are valid under applicable
|
||||
law. If additional permissions apply only to part of the Program, that part
|
||||
may be used separately under those permissions, but the entire Program remains
|
||||
governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any
|
||||
additional permissions from that copy, or from any part of it. (Additional
|
||||
permissions may be written to require their own removal in certain cases when
|
||||
you modify the work.) You may place additional permissions on material, added
|
||||
by you to a covered work, for which you have or can give appropriate copyright
|
||||
permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add
|
||||
to a covered work, you may (if authorized by the copyright holders of that
|
||||
material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of
|
||||
sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author
|
||||
attributions in that material or in the Appropriate Legal Notices displayed
|
||||
by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring
|
||||
that modified versions of such material be marked in reasonable ways as different
|
||||
from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors
|
||||
of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names,
|
||||
trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by
|
||||
anyone who conveys the material (or modified versions of it) with contractual
|
||||
assumptions of liability to the recipient, for any liability that these contractual
|
||||
assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further restrictions"
|
||||
within the meaning of section 10. If the Program as you received it, or any
|
||||
part of it, contains a notice stating that it is governed by this License
|
||||
along with a term that is a further restriction, you may remove that term.
|
||||
If a license document contains a further restriction but permits relicensing
|
||||
or conveying under this License, you may add to a covered work material governed
|
||||
by the terms of that license document, provided that the further restriction
|
||||
does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place,
|
||||
in the relevant source files, a statement of the additional terms that apply
|
||||
to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form
|
||||
of a separately written license, or stated as exceptions; the above requirements
|
||||
apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly provided
|
||||
under this License. Any attempt otherwise to propagate or modify it is void,
|
||||
and will automatically terminate your rights under this License (including
|
||||
any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from
|
||||
a particular copyright holder is reinstated (a) provisionally, unless and
|
||||
until the copyright holder explicitly and finally terminates your license,
|
||||
and (b) permanently, if the copyright holder fails to notify you of the violation
|
||||
by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently
|
||||
if the copyright holder notifies you of the violation by some reasonable means,
|
||||
this is the first time you have received notice of violation of this License
|
||||
(for any work) from that copyright holder, and you cure the violation prior
|
||||
to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses
|
||||
of parties who have received copies or rights from you under this License.
|
||||
If your rights have been terminated and not permanently reinstated, you do
|
||||
not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run a copy
|
||||
of the Program. Ancillary propagation of a covered work occurring solely as
|
||||
a consequence of using peer-to-peer transmission to receive a copy likewise
|
||||
does not require acceptance. However, nothing other than this License grants
|
||||
you permission to propagate or modify any covered work. These actions infringe
|
||||
copyright if you do not accept this License. Therefore, by modifying or propagating
|
||||
a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically receives
|
||||
a license from the original licensors, to run, modify and propagate that work,
|
||||
subject to this License. You are not responsible for enforcing compliance
|
||||
by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an organization,
|
||||
or substantially all assets of one, or subdividing an organization, or merging
|
||||
organizations. If propagation of a covered work results from an entity transaction,
|
||||
each party to that transaction who receives a copy of the work also receives
|
||||
whatever licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the Corresponding
|
||||
Source of the work from the predecessor in interest, if the predecessor has
|
||||
it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights
|
||||
granted or affirmed under this License. For example, you may not impose a
|
||||
license fee, royalty, or other charge for exercise of rights granted under
|
||||
this License, and you may not initiate litigation (including a cross-claim
|
||||
or counterclaim in a lawsuit) alleging that any patent claim is infringed
|
||||
by making, using, selling, offering for sale, or importing the Program or
|
||||
any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this License
|
||||
of the Program or a work on which the Program is based. The work thus licensed
|
||||
is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned or controlled
|
||||
by the contributor, whether already acquired or hereafter acquired, that would
|
||||
be infringed by some manner, permitted by this License, of making, using,
|
||||
or selling its contributor version, but do not include claims that would be
|
||||
infringed only as a consequence of further modification of the contributor
|
||||
version. For purposes of this definition, "control" includes the right to
|
||||
grant patent sublicenses in a manner consistent with the requirements of this
|
||||
License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent
|
||||
license under the contributor's essential patent claims, to make, use, sell,
|
||||
offer for sale, import and otherwise run, modify and propagate the contents
|
||||
of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express agreement
|
||||
or commitment, however denominated, not to enforce a patent (such as an express
|
||||
permission to practice a patent or covenant not to sue for patent infringement).
|
||||
To "grant" such a patent license to a party means to make such an agreement
|
||||
or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the
|
||||
Corresponding Source of the work is not available for anyone to copy, free
|
||||
of charge and under the terms of this License, through a publicly available
|
||||
network server or other readily accessible means, then you must either (1)
|
||||
cause the Corresponding Source to be so available, or (2) arrange to deprive
|
||||
yourself of the benefit of the patent license for this particular work, or
|
||||
(3) arrange, in a manner consistent with the requirements of this License,
|
||||
to extend the patent license to downstream recipients. "Knowingly relying"
|
||||
means you have actual knowledge that, but for the patent license, your conveying
|
||||
the covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that country
|
||||
that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement,
|
||||
you convey, or propagate by procuring conveyance of, a covered work, and grant
|
||||
a patent license to some of the parties receiving the covered work authorizing
|
||||
them to use, propagate, modify or convey a specific copy of the covered work,
|
||||
then the patent license you grant is automatically extended to all recipients
|
||||
of the covered work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the scope
|
||||
of its coverage, prohibits the exercise of, or is conditioned on the non-exercise
|
||||
of one or more of the rights that are specifically granted under this License.
|
||||
You may not convey a covered work if you are a party to an arrangement with
|
||||
a third party that is in the business of distributing software, under which
|
||||
you make payment to the third party based on the extent of your activity of
|
||||
conveying the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by you
|
||||
(or copies made from those copies), or (b) primarily for and in connection
|
||||
with specific products or compilations that contain the covered work, unless
|
||||
you entered into that arrangement, or that patent license was granted, prior
|
||||
to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied
|
||||
license or other defenses to infringement that may otherwise be available
|
||||
to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise)
|
||||
that contradict the conditions of this License, they do not excuse you from
|
||||
the conditions of this License. If you cannot convey a covered work so as
|
||||
to satisfy simultaneously your obligations under this License and any other
|
||||
pertinent obligations, then as a consequence you may not convey it at all.
|
||||
For example, if you agree to terms that obligate you to collect a royalty
|
||||
for further conveying from those to whom you convey the Program, the only
|
||||
way you could satisfy both those terms and this License would be to refrain
|
||||
entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have permission to
|
||||
link or combine any covered work with a work licensed under version 3 of the
|
||||
GNU Affero General Public License into a single combined work, and to convey
|
||||
the resulting work. The terms of this License will continue to apply to the
|
||||
part which is the covered work, but the special requirements of the GNU Affero
|
||||
General Public License, section 13, concerning interaction through a network
|
||||
will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the
|
||||
GNU General Public License from time to time. Such new versions will be similar
|
||||
in spirit to the present version, but may differ in detail to address new
|
||||
problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies
|
||||
that a certain numbered version of the GNU General Public License "or any
|
||||
later version" applies to it, you have the option of following the terms and
|
||||
conditions either of that numbered version or of any later version published
|
||||
by the Free Software Foundation. If the Program does not specify a version
|
||||
number of the GNU General Public License, you may choose any version ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of
|
||||
the GNU General Public License can be used, that proxy's public statement
|
||||
of acceptance of a version permanently authorizes you to choose that version
|
||||
for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However,
|
||||
no additional obligations are imposed on any author or copyright holder as
|
||||
a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
|
||||
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM
|
||||
PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
|
||||
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM
|
||||
AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
|
||||
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO
|
||||
USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
|
||||
INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
|
||||
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot
|
||||
be given local legal effect according to their terms, reviewing courts shall
|
||||
apply local law that most closely approximates an absolute waiver of all civil
|
||||
liability in connection with the Program, unless a warranty or assumption
|
||||
of liability accompanies a copy of the Program in return for a fee. END OF
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible
|
||||
use to the public, the best way to achieve this is to make it free software
|
||||
which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach
|
||||
them to the start of each source file to most effectively state the exclusion
|
||||
of warranty; and each file should have at least the "copyright" line and a
|
||||
pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program 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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like
|
||||
this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
|
||||
This is free software, and you are welcome to redistribute it under certain
|
||||
conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands might
|
||||
be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary. For
|
||||
more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General Public
|
||||
License instead of this License. But first, please read <https://www.gnu.org/
|
||||
licenses /why-not-lgpl.html>.
|
||||
446
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-2.0-only.txt
vendored
Normal file
446
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-2.0-only.txt
vendored
Normal file
@@ -0,0 +1,446 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is numbered 2 because
|
||||
it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share
|
||||
and change it. By contrast, the GNU General Public Licenses are intended to
|
||||
guarantee your freedom to share and change free software--to make sure the
|
||||
software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some specially
|
||||
designated Free Software Foundation software, and to any other libraries whose
|
||||
authors decide to use it. You can use it for your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for this service if you
|
||||
wish), that you receive source code or can get it if you want it, that you
|
||||
can change the software or use pieces of it in new free programs; and that
|
||||
you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to
|
||||
deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of
|
||||
the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis or for
|
||||
a fee, you must give the recipients all the rights that we gave you. You must
|
||||
make sure that they, too, receive or can get the source code. If you link
|
||||
a program with the library, you must provide complete object files to the
|
||||
recipients so that they can relink them with the library, after making changes
|
||||
to the library and recompiling it. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright the library,
|
||||
and (2) offer you this license which gives you legal permission to copy, distribute
|
||||
and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain that everyone
|
||||
understands that there is no warranty for this free library. If the library
|
||||
is modified by someone else and passed on, we want its recipients to know
|
||||
that what they have is not the original version, so that any problems introduced
|
||||
by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We
|
||||
wish to avoid the danger that companies distributing free software will individually
|
||||
obtain patent licenses, thus in effect transforming the program into proprietary
|
||||
software. To prevent this, we have made it clear that any patent must be licensed
|
||||
for everyone's free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary GNU
|
||||
General Public License, which was designed for utility programs. This license,
|
||||
the GNU Library General Public License, applies to certain designated libraries.
|
||||
This license is quite different from the ordinary one; be sure to read it
|
||||
in full, and don't assume that anything in it is the same as in the ordinary
|
||||
license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that they
|
||||
blur the distinction we usually make between modifying or adding to a program
|
||||
and simply using it. Linking a program with a library, without changing the
|
||||
library, is in some sense simply using the library, and is analogous to running
|
||||
a utility program or application program. However, in a textual and legal
|
||||
sense, the linked executable is a combined work, a derivative of the original
|
||||
library, and the ordinary General Public License treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General Public License
|
||||
for libraries did not effectively promote software sharing, because most developers
|
||||
did not use the libraries. We concluded that weaker conditions might promote
|
||||
sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the users
|
||||
of those programs of all benefit from the free status of the libraries themselves.
|
||||
This Library General Public License is intended to permit developers of non-free
|
||||
programs to use free libraries, while preserving your freedom as a user of
|
||||
such programs to change the free libraries that are incorporated in them.
|
||||
(We have not seen how to achieve this as regards changes in header files,
|
||||
but we have achieved it as regards changes in the actual functions of the
|
||||
Library.) The hope is that this will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow. Pay close attention to the difference between a "work based on the
|
||||
library" and a "work that uses the library". The former contains code derived
|
||||
from the library, while the latter only works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary General
|
||||
Public License rather than by this special one.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which contains a
|
||||
notice placed by the copyright holder or other authorized party saying it
|
||||
may be distributed under the terms of this Library General Public License
|
||||
(also called "this License"). Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data prepared
|
||||
so as to be conveniently linked with application programs (which use some
|
||||
of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work which has
|
||||
been distributed under these terms. A "work based on the Library" means either
|
||||
the Library or any derivative work under copyright law: that is to say, a
|
||||
work containing the Library or a portion of it, either verbatim or with modifications
|
||||
and/or translated straightforwardly into another language. (Hereinafter, translation
|
||||
is included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for making modifications
|
||||
to it. For a library, complete source code means all the source code for all
|
||||
modules it contains, plus any associated interface definition files, plus
|
||||
the scripts used to control compilation and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running a program
|
||||
using the Library is not restricted, and output from such a program is covered
|
||||
only if its contents constitute a work based on the Library (independent of
|
||||
the use of the Library in a tool for writing it). Whether that is true depends
|
||||
on what the Library does and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's complete source
|
||||
code as you receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice and disclaimer
|
||||
of warranty; keep intact all the notices that refer to this License and to
|
||||
the absence of any warranty; and distribute a copy of this License along with
|
||||
the Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion of it,
|
||||
thus forming a work based on the Library, and copy and distribute such modifications
|
||||
or work under the terms of Section 1 above, provided that you also meet all
|
||||
of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no charge to all
|
||||
third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a table of
|
||||
data to be supplied by an application program that uses the facility, other
|
||||
than as an argument passed when the facility is invoked, then you must make
|
||||
a good faith effort to ensure that, in the event an application does not supply
|
||||
such function or table, the facility still operates, and performs whatever
|
||||
part of its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has a purpose
|
||||
that is entirely well-defined independent of the application. Therefore, Subsection
|
||||
2d requires that any application-supplied function or table used by this function
|
||||
must be optional: if the application does not supply it, the square root function
|
||||
must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Library, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them as
|
||||
separate works. But when you distribute the same sections as part of a whole
|
||||
which is a work based on the Library, the distribution of the whole must be
|
||||
on the terms of this License, whose permissions for other licensees extend
|
||||
to the entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your
|
||||
rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works based
|
||||
on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library with
|
||||
the Library (or with a work based on the Library) on a volume of a storage
|
||||
or distribution medium does not bring the other work under the scope of this
|
||||
License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public License
|
||||
instead of this License to a given copy of the Library. To do this, you must
|
||||
alter all the notices that refer to this License, so that they refer to the
|
||||
ordinary GNU General Public License, version 2, instead of to this License.
|
||||
(If a newer version than version 2 of the ordinary GNU General Public License
|
||||
has appeared, then you can specify that version instead if you wish.) Do not
|
||||
make any other change in these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for that copy,
|
||||
so the ordinary GNU General Public License applies to all subsequent copies
|
||||
and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of the Library
|
||||
into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or derivative of
|
||||
it, under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you accompany it with the complete corresponding
|
||||
machine-readable source code, which must be distributed under the terms of
|
||||
Sections 1 and 2 above on a medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy from a designated
|
||||
place, then offering equivalent access to copy the source code from the same
|
||||
place satisfies the requirement to distribute the source code, even though
|
||||
third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the Library, but
|
||||
is designed to work with the Library by being compiled or linked with it,
|
||||
is called a "work that uses the Library". Such a work, in isolation, is not
|
||||
a derivative work of the Library, and therefore falls outside the scope of
|
||||
this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library creates an
|
||||
executable that is a derivative of the Library (because it contains portions
|
||||
of the Library), rather than a "work that uses the library". The executable
|
||||
is therefore covered by this License. Section 6 states terms for distribution
|
||||
of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file that
|
||||
is part of the Library, the object code for the work may be a derivative work
|
||||
of the Library even though the source code is not. Whether this is true is
|
||||
especially significant if the work can be linked without the Library, or if
|
||||
the work is itself a library. The threshold for this to be true is not precisely
|
||||
defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data structure layouts
|
||||
and accessors, and small macros and small inline functions (ten lines or less
|
||||
in length), then the use of the object file is unrestricted, regardless of
|
||||
whether it is legally a derivative work. (Executables containing this object
|
||||
code plus portions of the Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may distribute
|
||||
the object code for the work under the terms of Section 6. Any executables
|
||||
containing that work also fall under Section 6, whether or not they are linked
|
||||
directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or link a "work
|
||||
that uses the Library" with the Library to produce a work containing portions
|
||||
of the Library, and distribute that work under terms of your choice, provided
|
||||
that the terms permit modification of the work for the customer's own use
|
||||
and reverse engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
You must supply a copy of this License. If the work during execution displays
|
||||
copyright notices, you must include the copyright notice for the Library among
|
||||
them, as well as a reference directing the user to the copy of this License.
|
||||
Also, you must do one of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding machine-readable source
|
||||
code for the Library including whatever changes were used in the work (which
|
||||
must be distributed under Sections 1 and 2 above); and, if the work is an
|
||||
executable linked with the Library, with the complete machine-readable "work
|
||||
that uses the Library", as object code and/or source code, so that the user
|
||||
can modify the Library and then relink to produce a modified executable containing
|
||||
the modified Library. (It is understood that the user who changes the contents
|
||||
of definitions files in the Library will not necessarily be able to recompile
|
||||
the application to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at least three years,
|
||||
to give the same user the materials specified in Subsection 6a, above, for
|
||||
a charge no more than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy from a designated
|
||||
place, offer equivalent access to copy the above specified materials from
|
||||
the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these materials or
|
||||
that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the Library" must
|
||||
include any data and utility programs needed for reproducing the executable
|
||||
from it. However, as a special exception, the source code distributed need
|
||||
not include anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the operating
|
||||
system on which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license restrictions of
|
||||
other proprietary libraries that do not normally accompany the operating system.
|
||||
Such a contradiction means you cannot use both them and the Library together
|
||||
in an executable that you distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the Library side-by-side
|
||||
in a single library together with other library facilities not covered by
|
||||
this License, and distribute such a combined library, provided that the separate
|
||||
distribution of the work based on the Library and of the other library facilities
|
||||
is otherwise permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the
|
||||
Library, uncombined with any other library facilities. This must be distributed
|
||||
under the terms of the Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact that part of
|
||||
it is a work based on the Library, and explaining where to find the accompanying
|
||||
uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute the Library
|
||||
except as expressly provided under this License. Any attempt otherwise to
|
||||
copy, modify, sublicense, link with, or distribute the Library is void, and
|
||||
will automatically terminate your rights under this License. However, parties
|
||||
who have received copies, or rights, from you under this License will not
|
||||
have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not signed
|
||||
it. However, nothing else grants you permission to modify or distribute the
|
||||
Library or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the Library
|
||||
(or any work based on the Library), you indicate your acceptance of this License
|
||||
to do so, and all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the Library),
|
||||
the recipient automatically receives a license from the original licensor
|
||||
to copy, distribute, link with or modify the Library subject to these terms
|
||||
and conditions. You may not impose any further restrictions on the recipients'
|
||||
exercise of the rights granted herein. You are not responsible for enforcing
|
||||
compliance by third parties to this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent infringement
|
||||
or for any other reason (not limited to patent issues), conditions are imposed
|
||||
on you (whether by court order, agreement or otherwise) that contradict the
|
||||
conditions of this License, they do not excuse you from the conditions of
|
||||
this License. If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations, then as
|
||||
a consequence you may not distribute the Library at all. For example, if a
|
||||
patent license would not permit royalty-free redistribution of the Library
|
||||
by all those who receive copies directly or indirectly through you, then the
|
||||
only way you could satisfy both it and this License would be to refrain entirely
|
||||
from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents
|
||||
or other property right claims or to contest validity of any such claims;
|
||||
this section has the sole purpose of protecting the integrity of the free
|
||||
software distribution system which is implemented by public license practices.
|
||||
Many people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Library under this License may add an explicit geographical
|
||||
distribution limitation excluding those countries, so that distribution is
|
||||
permitted only in or among countries not thus excluded. In such case, this
|
||||
License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new versions of
|
||||
the Library General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to address
|
||||
new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that version
|
||||
or of any later version published by the Free Software Foundation. If the
|
||||
Library does not specify a license version number, you may choose any version
|
||||
ever published by the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free programs
|
||||
whose distribution conditions are incompatible with these, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free Software
|
||||
Foundation, write to the Free Software Foundation; we sometimes make exceptions
|
||||
for this. Our decision will be guided by the two goals of preserving the free
|
||||
status of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
|
||||
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
|
||||
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
|
||||
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
|
||||
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
|
||||
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest possible
|
||||
use to the public, we recommend making it free software that everyone can
|
||||
redistribute and change. You can do so by permitting redistribution under
|
||||
these terms (or, alternatively, under the terms of the ordinary General Public
|
||||
License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is safest
|
||||
to attach them to the start of each source file to most effectively convey
|
||||
the exclusion of warranty; and each file should have at least the "copyright"
|
||||
line and a pointer to where the full notice is found.
|
||||
|
||||
one line to give the library's name and an idea of what it does.
|
||||
|
||||
Copyright (C) year name of author
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Library General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
This library 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 Library General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school,
|
||||
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
|
||||
is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
|
||||
by James Random Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1990
|
||||
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
446
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-2.0-or-later.txt
vendored
Normal file
446
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-2.0-or-later.txt
vendored
Normal file
@@ -0,0 +1,446 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is numbered 2 because
|
||||
it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share
|
||||
and change it. By contrast, the GNU General Public Licenses are intended to
|
||||
guarantee your freedom to share and change free software--to make sure the
|
||||
software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some specially
|
||||
designated Free Software Foundation software, and to any other libraries whose
|
||||
authors decide to use it. You can use it for your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for this service if you
|
||||
wish), that you receive source code or can get it if you want it, that you
|
||||
can change the software or use pieces of it in new free programs; and that
|
||||
you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to
|
||||
deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of
|
||||
the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis or for
|
||||
a fee, you must give the recipients all the rights that we gave you. You must
|
||||
make sure that they, too, receive or can get the source code. If you link
|
||||
a program with the library, you must provide complete object files to the
|
||||
recipients so that they can relink them with the library, after making changes
|
||||
to the library and recompiling it. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright the library,
|
||||
and (2) offer you this license which gives you legal permission to copy, distribute
|
||||
and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain that everyone
|
||||
understands that there is no warranty for this free library. If the library
|
||||
is modified by someone else and passed on, we want its recipients to know
|
||||
that what they have is not the original version, so that any problems introduced
|
||||
by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We
|
||||
wish to avoid the danger that companies distributing free software will individually
|
||||
obtain patent licenses, thus in effect transforming the program into proprietary
|
||||
software. To prevent this, we have made it clear that any patent must be licensed
|
||||
for everyone's free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary GNU
|
||||
General Public License, which was designed for utility programs. This license,
|
||||
the GNU Library General Public License, applies to certain designated libraries.
|
||||
This license is quite different from the ordinary one; be sure to read it
|
||||
in full, and don't assume that anything in it is the same as in the ordinary
|
||||
license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that they
|
||||
blur the distinction we usually make between modifying or adding to a program
|
||||
and simply using it. Linking a program with a library, without changing the
|
||||
library, is in some sense simply using the library, and is analogous to running
|
||||
a utility program or application program. However, in a textual and legal
|
||||
sense, the linked executable is a combined work, a derivative of the original
|
||||
library, and the ordinary General Public License treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General Public License
|
||||
for libraries did not effectively promote software sharing, because most developers
|
||||
did not use the libraries. We concluded that weaker conditions might promote
|
||||
sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the users
|
||||
of those programs of all benefit from the free status of the libraries themselves.
|
||||
This Library General Public License is intended to permit developers of non-free
|
||||
programs to use free libraries, while preserving your freedom as a user of
|
||||
such programs to change the free libraries that are incorporated in them.
|
||||
(We have not seen how to achieve this as regards changes in header files,
|
||||
but we have achieved it as regards changes in the actual functions of the
|
||||
Library.) The hope is that this will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow. Pay close attention to the difference between a "work based on the
|
||||
library" and a "work that uses the library". The former contains code derived
|
||||
from the library, while the latter only works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary General
|
||||
Public License rather than by this special one.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which contains a
|
||||
notice placed by the copyright holder or other authorized party saying it
|
||||
may be distributed under the terms of this Library General Public License
|
||||
(also called "this License"). Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data prepared
|
||||
so as to be conveniently linked with application programs (which use some
|
||||
of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work which has
|
||||
been distributed under these terms. A "work based on the Library" means either
|
||||
the Library or any derivative work under copyright law: that is to say, a
|
||||
work containing the Library or a portion of it, either verbatim or with modifications
|
||||
and/or translated straightforwardly into another language. (Hereinafter, translation
|
||||
is included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for making modifications
|
||||
to it. For a library, complete source code means all the source code for all
|
||||
modules it contains, plus any associated interface definition files, plus
|
||||
the scripts used to control compilation and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running a program
|
||||
using the Library is not restricted, and output from such a program is covered
|
||||
only if its contents constitute a work based on the Library (independent of
|
||||
the use of the Library in a tool for writing it). Whether that is true depends
|
||||
on what the Library does and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's complete source
|
||||
code as you receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice and disclaimer
|
||||
of warranty; keep intact all the notices that refer to this License and to
|
||||
the absence of any warranty; and distribute a copy of this License along with
|
||||
the Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion of it,
|
||||
thus forming a work based on the Library, and copy and distribute such modifications
|
||||
or work under the terms of Section 1 above, provided that you also meet all
|
||||
of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no charge to all
|
||||
third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a table of
|
||||
data to be supplied by an application program that uses the facility, other
|
||||
than as an argument passed when the facility is invoked, then you must make
|
||||
a good faith effort to ensure that, in the event an application does not supply
|
||||
such function or table, the facility still operates, and performs whatever
|
||||
part of its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has a purpose
|
||||
that is entirely well-defined independent of the application. Therefore, Subsection
|
||||
2d requires that any application-supplied function or table used by this function
|
||||
must be optional: if the application does not supply it, the square root function
|
||||
must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Library, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them as
|
||||
separate works. But when you distribute the same sections as part of a whole
|
||||
which is a work based on the Library, the distribution of the whole must be
|
||||
on the terms of this License, whose permissions for other licensees extend
|
||||
to the entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your
|
||||
rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works based
|
||||
on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library with
|
||||
the Library (or with a work based on the Library) on a volume of a storage
|
||||
or distribution medium does not bring the other work under the scope of this
|
||||
License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public License
|
||||
instead of this License to a given copy of the Library. To do this, you must
|
||||
alter all the notices that refer to this License, so that they refer to the
|
||||
ordinary GNU General Public License, version 2, instead of to this License.
|
||||
(If a newer version than version 2 of the ordinary GNU General Public License
|
||||
has appeared, then you can specify that version instead if you wish.) Do not
|
||||
make any other change in these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for that copy,
|
||||
so the ordinary GNU General Public License applies to all subsequent copies
|
||||
and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of the Library
|
||||
into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or derivative of
|
||||
it, under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you accompany it with the complete corresponding
|
||||
machine-readable source code, which must be distributed under the terms of
|
||||
Sections 1 and 2 above on a medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy from a designated
|
||||
place, then offering equivalent access to copy the source code from the same
|
||||
place satisfies the requirement to distribute the source code, even though
|
||||
third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the Library, but
|
||||
is designed to work with the Library by being compiled or linked with it,
|
||||
is called a "work that uses the Library". Such a work, in isolation, is not
|
||||
a derivative work of the Library, and therefore falls outside the scope of
|
||||
this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library creates an
|
||||
executable that is a derivative of the Library (because it contains portions
|
||||
of the Library), rather than a "work that uses the library". The executable
|
||||
is therefore covered by this License. Section 6 states terms for distribution
|
||||
of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file that
|
||||
is part of the Library, the object code for the work may be a derivative work
|
||||
of the Library even though the source code is not. Whether this is true is
|
||||
especially significant if the work can be linked without the Library, or if
|
||||
the work is itself a library. The threshold for this to be true is not precisely
|
||||
defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data structure layouts
|
||||
and accessors, and small macros and small inline functions (ten lines or less
|
||||
in length), then the use of the object file is unrestricted, regardless of
|
||||
whether it is legally a derivative work. (Executables containing this object
|
||||
code plus portions of the Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may distribute
|
||||
the object code for the work under the terms of Section 6. Any executables
|
||||
containing that work also fall under Section 6, whether or not they are linked
|
||||
directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or link a "work
|
||||
that uses the Library" with the Library to produce a work containing portions
|
||||
of the Library, and distribute that work under terms of your choice, provided
|
||||
that the terms permit modification of the work for the customer's own use
|
||||
and reverse engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
You must supply a copy of this License. If the work during execution displays
|
||||
copyright notices, you must include the copyright notice for the Library among
|
||||
them, as well as a reference directing the user to the copy of this License.
|
||||
Also, you must do one of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding machine-readable source
|
||||
code for the Library including whatever changes were used in the work (which
|
||||
must be distributed under Sections 1 and 2 above); and, if the work is an
|
||||
executable linked with the Library, with the complete machine-readable "work
|
||||
that uses the Library", as object code and/or source code, so that the user
|
||||
can modify the Library and then relink to produce a modified executable containing
|
||||
the modified Library. (It is understood that the user who changes the contents
|
||||
of definitions files in the Library will not necessarily be able to recompile
|
||||
the application to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at least three years,
|
||||
to give the same user the materials specified in Subsection 6a, above, for
|
||||
a charge no more than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy from a designated
|
||||
place, offer equivalent access to copy the above specified materials from
|
||||
the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these materials or
|
||||
that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the Library" must
|
||||
include any data and utility programs needed for reproducing the executable
|
||||
from it. However, as a special exception, the source code distributed need
|
||||
not include anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the operating
|
||||
system on which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license restrictions of
|
||||
other proprietary libraries that do not normally accompany the operating system.
|
||||
Such a contradiction means you cannot use both them and the Library together
|
||||
in an executable that you distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the Library side-by-side
|
||||
in a single library together with other library facilities not covered by
|
||||
this License, and distribute such a combined library, provided that the separate
|
||||
distribution of the work based on the Library and of the other library facilities
|
||||
is otherwise permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the
|
||||
Library, uncombined with any other library facilities. This must be distributed
|
||||
under the terms of the Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact that part of
|
||||
it is a work based on the Library, and explaining where to find the accompanying
|
||||
uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute the Library
|
||||
except as expressly provided under this License. Any attempt otherwise to
|
||||
copy, modify, sublicense, link with, or distribute the Library is void, and
|
||||
will automatically terminate your rights under this License. However, parties
|
||||
who have received copies, or rights, from you under this License will not
|
||||
have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not signed
|
||||
it. However, nothing else grants you permission to modify or distribute the
|
||||
Library or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the Library
|
||||
(or any work based on the Library), you indicate your acceptance of this License
|
||||
to do so, and all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the Library),
|
||||
the recipient automatically receives a license from the original licensor
|
||||
to copy, distribute, link with or modify the Library subject to these terms
|
||||
and conditions. You may not impose any further restrictions on the recipients'
|
||||
exercise of the rights granted herein. You are not responsible for enforcing
|
||||
compliance by third parties to this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent infringement
|
||||
or for any other reason (not limited to patent issues), conditions are imposed
|
||||
on you (whether by court order, agreement or otherwise) that contradict the
|
||||
conditions of this License, they do not excuse you from the conditions of
|
||||
this License. If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations, then as
|
||||
a consequence you may not distribute the Library at all. For example, if a
|
||||
patent license would not permit royalty-free redistribution of the Library
|
||||
by all those who receive copies directly or indirectly through you, then the
|
||||
only way you could satisfy both it and this License would be to refrain entirely
|
||||
from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents
|
||||
or other property right claims or to contest validity of any such claims;
|
||||
this section has the sole purpose of protecting the integrity of the free
|
||||
software distribution system which is implemented by public license practices.
|
||||
Many people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Library under this License may add an explicit geographical
|
||||
distribution limitation excluding those countries, so that distribution is
|
||||
permitted only in or among countries not thus excluded. In such case, this
|
||||
License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new versions of
|
||||
the Library General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to address
|
||||
new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that version
|
||||
or of any later version published by the Free Software Foundation. If the
|
||||
Library does not specify a license version number, you may choose any version
|
||||
ever published by the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free programs
|
||||
whose distribution conditions are incompatible with these, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free Software
|
||||
Foundation, write to the Free Software Foundation; we sometimes make exceptions
|
||||
for this. Our decision will be guided by the two goals of preserving the free
|
||||
status of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
|
||||
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
|
||||
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
|
||||
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
|
||||
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
|
||||
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest possible
|
||||
use to the public, we recommend making it free software that everyone can
|
||||
redistribute and change. You can do so by permitting redistribution under
|
||||
these terms (or, alternatively, under the terms of the ordinary General Public
|
||||
License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is safest
|
||||
to attach them to the start of each source file to most effectively convey
|
||||
the exclusion of warranty; and each file should have at least the "copyright"
|
||||
line and a pointer to where the full notice is found.
|
||||
|
||||
one line to give the library's name and an idea of what it does.
|
||||
|
||||
Copyright (C) year name of author
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Library General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
This library 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 Library General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school,
|
||||
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
|
||||
is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
|
||||
by James Random Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1990
|
||||
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
467
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-2.1-only.txt
vendored
Normal file
467
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-2.1-only.txt
vendored
Normal file
@@ -0,0 +1,467 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts as the
|
||||
successor of the GNU Library Public License, version 2, hence the version
|
||||
number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share
|
||||
and change it. By contrast, the GNU General Public Licenses are intended to
|
||||
guarantee your freedom to share and change free software--to make sure the
|
||||
software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some specially
|
||||
designated software packages--typically libraries--of the Free Software Foundation
|
||||
and other authors who decide to use it. You can use it too, but we suggest
|
||||
you first think carefully about whether this license or the ordinary General
|
||||
Public License is the better strategy to use in any particular case, based
|
||||
on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use, not price.
|
||||
Our General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for this service if you
|
||||
wish); that you receive source code or can get it if you want it; that you
|
||||
can change the software and use pieces of it in new free programs; and that
|
||||
you are informed that you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid distributors
|
||||
to deny you these rights or to ask you to surrender these rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of
|
||||
the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis or for
|
||||
a fee, you must give the recipients all the rights that we gave you. You must
|
||||
make sure that they, too, receive or can get the source code. If you link
|
||||
other code with the library, you must provide complete object files to the
|
||||
recipients, so that they can relink them with the library after making changes
|
||||
to the library and recompiling it. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the library,
|
||||
and (2) we offer you this license, which gives you legal permission to copy,
|
||||
distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that there is no
|
||||
warranty for the free library. Also, if the library is modified by someone
|
||||
else and passed on, the recipients should know that what they have is not
|
||||
the original version, so that the original author's reputation will not be
|
||||
affected by problems that might be introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of any free
|
||||
program. We wish to make sure that a company cannot effectively restrict the
|
||||
users of a free program by obtaining a restrictive license from a patent holder.
|
||||
Therefore, we insist that any patent license obtained for a version of the
|
||||
library must be consistent with the full freedom of use specified in this
|
||||
license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary GNU
|
||||
General Public License. This license, the GNU Lesser General Public License,
|
||||
applies to certain designated libraries, and is quite different from the ordinary
|
||||
General Public License. We use this license for certain libraries in order
|
||||
to permit linking those libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using a shared
|
||||
library, the combination of the two is legally speaking a combined work, a
|
||||
derivative of the original library. The ordinary General Public License therefore
|
||||
permits such linking only if the entire combination fits its criteria of freedom.
|
||||
The Lesser General Public License permits more lax criteria for linking other
|
||||
code with the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it does Less
|
||||
to protect the user's freedom than the ordinary General Public License. It
|
||||
also provides other free software developers Less of an advantage over competing
|
||||
non-free programs. These disadvantages are the reason we use the ordinary
|
||||
General Public License for many libraries. However, the Lesser license provides
|
||||
advantages in certain special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to encourage the
|
||||
widest possible use of a certain library, so that it becomes a de-facto standard.
|
||||
To achieve this, non-free programs must be allowed to use the library. A more
|
||||
frequent case is that a free library does the same job as widely used non-free
|
||||
libraries. In this case, there is little to gain by limiting the free library
|
||||
to free software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free programs
|
||||
enables a greater number of people to use a large body of free software. For
|
||||
example, permission to use the GNU C Library in non-free programs enables
|
||||
many more people to use the whole GNU operating system, as well as its variant,
|
||||
the GNU/Linux operating system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the users'
|
||||
freedom, it does ensure that the user of a program that is linked with the
|
||||
Library has the freedom and the wherewithal to run that program using a modified
|
||||
version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow. Pay close attention to the difference between a "work based on the
|
||||
library" and a "work that uses the library". The former contains code derived
|
||||
from the library, whereas the latter must be combined with the library in
|
||||
order to run.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other program
|
||||
which contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Lesser General
|
||||
Public License (also called "this License"). Each licensee is addressed as
|
||||
"you".
|
||||
|
||||
A "library" means a collection of software functions and/or data prepared
|
||||
so as to be conveniently linked with application programs (which use some
|
||||
of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work which has
|
||||
been distributed under these terms. A "work based on the Library" means either
|
||||
the Library or any derivative work under copyright law: that is to say, a
|
||||
work containing the Library or a portion of it, either verbatim or with modifications
|
||||
and/or translated straightforwardly into another language. (Hereinafter, translation
|
||||
is included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for making modifications
|
||||
to it. For a library, complete source code means all the source code for all
|
||||
modules it contains, plus any associated interface definition files, plus
|
||||
the scripts used to control compilation and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running a program
|
||||
using the Library is not restricted, and output from such a program is covered
|
||||
only if its contents constitute a work based on the Library (independent of
|
||||
the use of the Library in a tool for writing it). Whether that is true depends
|
||||
on what the Library does and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's complete source
|
||||
code as you receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice and disclaimer
|
||||
of warranty; keep intact all the notices that refer to this License and to
|
||||
the absence of any warranty; and distribute a copy of this License along with
|
||||
the Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion of it,
|
||||
thus forming a work based on the Library, and copy and distribute such modifications
|
||||
or work under the terms of Section 1 above, provided that you also meet all
|
||||
of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no charge to all
|
||||
third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a table of
|
||||
data to be supplied by an application program that uses the facility, other
|
||||
than as an argument passed when the facility is invoked, then you must make
|
||||
a good faith effort to ensure that, in the event an application does not supply
|
||||
such function or table, the facility still operates, and performs whatever
|
||||
part of its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has a purpose
|
||||
that is entirely well-defined independent of the application. Therefore, Subsection
|
||||
2d requires that any application-supplied function or table used by this function
|
||||
must be optional: if the application does not supply it, the square root function
|
||||
must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Library, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them as
|
||||
separate works. But when you distribute the same sections as part of a whole
|
||||
which is a work based on the Library, the distribution of the whole must be
|
||||
on the terms of this License, whose permissions for other licensees extend
|
||||
to the entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your
|
||||
rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works based
|
||||
on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library with
|
||||
the Library (or with a work based on the Library) on a volume of a storage
|
||||
or distribution medium does not bring the other work under the scope of this
|
||||
License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public License
|
||||
instead of this License to a given copy of the Library. To do this, you must
|
||||
alter all the notices that refer to this License, so that they refer to the
|
||||
ordinary GNU General Public License, version 2, instead of to this License.
|
||||
(If a newer version than version 2 of the ordinary GNU General Public License
|
||||
has appeared, then you can specify that version instead if you wish.) Do not
|
||||
make any other change in these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for that copy,
|
||||
so the ordinary GNU General Public License applies to all subsequent copies
|
||||
and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of the Library
|
||||
into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or derivative of
|
||||
it, under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you accompany it with the complete corresponding
|
||||
machine-readable source code, which must be distributed under the terms of
|
||||
Sections 1 and 2 above on a medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy from a designated
|
||||
place, then offering equivalent access to copy the source code from the same
|
||||
place satisfies the requirement to distribute the source code, even though
|
||||
third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the Library, but
|
||||
is designed to work with the Library by being compiled or linked with it,
|
||||
is called a "work that uses the Library". Such a work, in isolation, is not
|
||||
a derivative work of the Library, and therefore falls outside the scope of
|
||||
this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library creates an
|
||||
executable that is a derivative of the Library (because it contains portions
|
||||
of the Library), rather than a "work that uses the library". The executable
|
||||
is therefore covered by this License. Section 6 states terms for distribution
|
||||
of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file that
|
||||
is part of the Library, the object code for the work may be a derivative work
|
||||
of the Library even though the source code is not. Whether this is true is
|
||||
especially significant if the work can be linked without the Library, or if
|
||||
the work is itself a library. The threshold for this to be true is not precisely
|
||||
defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data structure layouts
|
||||
and accessors, and small macros and small inline functions (ten lines or less
|
||||
in length), then the use of the object file is unrestricted, regardless of
|
||||
whether it is legally a derivative work. (Executables containing this object
|
||||
code plus portions of the Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may distribute
|
||||
the object code for the work under the terms of Section 6. Any executables
|
||||
containing that work also fall under Section 6, whether or not they are linked
|
||||
directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or link a "work
|
||||
that uses the Library" with the Library to produce a work containing portions
|
||||
of the Library, and distribute that work under terms of your choice, provided
|
||||
that the terms permit modification of the work for the customer's own use
|
||||
and reverse engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
You must supply a copy of this License. If the work during execution displays
|
||||
copyright notices, you must include the copyright notice for the Library among
|
||||
them, as well as a reference directing the user to the copy of this License.
|
||||
Also, you must do one of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding machine-readable source
|
||||
code for the Library including whatever changes were used in the work (which
|
||||
must be distributed under Sections 1 and 2 above); and, if the work is an
|
||||
executable linked with the Library, with the complete machine-readable "work
|
||||
that uses the Library", as object code and/or source code, so that the user
|
||||
can modify the Library and then relink to produce a modified executable containing
|
||||
the modified Library. (It is understood that the user who changes the contents
|
||||
of definitions files in the Library will not necessarily be able to recompile
|
||||
the application to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the Library. A
|
||||
suitable mechanism is one that (1) uses at run time a copy of the library
|
||||
already present on the user's computer system, rather than copying library
|
||||
functions into the executable, and (2) will operate properly with a modified
|
||||
version of the library, if the user installs one, as long as the modified
|
||||
version is interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at least three years,
|
||||
to give the same user the materials specified in Subsection 6a, above, for
|
||||
a charge no more than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy from a designated
|
||||
place, offer equivalent access to copy the above specified materials from
|
||||
the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these materials or
|
||||
that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the Library" must
|
||||
include any data and utility programs needed for reproducing the executable
|
||||
from it. However, as a special exception, the materials to be distributed
|
||||
need not include anything that is normally distributed (in either source or
|
||||
binary form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component itself
|
||||
accompanies the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license restrictions of
|
||||
other proprietary libraries that do not normally accompany the operating system.
|
||||
Such a contradiction means you cannot use both them and the Library together
|
||||
in an executable that you distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the Library side-by-side
|
||||
in a single library together with other library facilities not covered by
|
||||
this License, and distribute such a combined library, provided that the separate
|
||||
distribution of the work based on the Library and of the other library facilities
|
||||
is otherwise permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the
|
||||
Library, uncombined with any other library facilities. This must be distributed
|
||||
under the terms of the Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact that part of
|
||||
it is a work based on the Library, and explaining where to find the accompanying
|
||||
uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute the Library
|
||||
except as expressly provided under this License. Any attempt otherwise to
|
||||
copy, modify, sublicense, link with, or distribute the Library is void, and
|
||||
will automatically terminate your rights under this License. However, parties
|
||||
who have received copies, or rights, from you under this License will not
|
||||
have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not signed
|
||||
it. However, nothing else grants you permission to modify or distribute the
|
||||
Library or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the Library
|
||||
(or any work based on the Library), you indicate your acceptance of this License
|
||||
to do so, and all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the Library),
|
||||
the recipient automatically receives a license from the original licensor
|
||||
to copy, distribute, link with or modify the Library subject to these terms
|
||||
and conditions. You may not impose any further restrictions on the recipients'
|
||||
exercise of the rights granted herein. You are not responsible for enforcing
|
||||
compliance by third parties with this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent infringement
|
||||
or for any other reason (not limited to patent issues), conditions are imposed
|
||||
on you (whether by court order, agreement or otherwise) that contradict the
|
||||
conditions of this License, they do not excuse you from the conditions of
|
||||
this License. If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations, then as
|
||||
a consequence you may not distribute the Library at all. For example, if a
|
||||
patent license would not permit royalty-free redistribution of the Library
|
||||
by all those who receive copies directly or indirectly through you, then the
|
||||
only way you could satisfy both it and this License would be to refrain entirely
|
||||
from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents
|
||||
or other property right claims or to contest validity of any such claims;
|
||||
this section has the sole purpose of protecting the integrity of the free
|
||||
software distribution system which is implemented by public license practices.
|
||||
Many people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Library under this License may add an explicit geographical
|
||||
distribution limitation excluding those countries, so that distribution is
|
||||
permitted only in or among countries not thus excluded. In such case, this
|
||||
License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new versions of
|
||||
the Lesser General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to address
|
||||
new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that version
|
||||
or of any later version published by the Free Software Foundation. If the
|
||||
Library does not specify a license version number, you may choose any version
|
||||
ever published by the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free programs
|
||||
whose distribution conditions are incompatible with these, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free Software
|
||||
Foundation, write to the Free Software Foundation; we sometimes make exceptions
|
||||
for this. Our decision will be guided by the two goals of preserving the free
|
||||
status of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
|
||||
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
|
||||
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
|
||||
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
|
||||
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
|
||||
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest possible
|
||||
use to the public, we recommend making it free software that everyone can
|
||||
redistribute and change. You can do so by permitting redistribution under
|
||||
these terms (or, alternatively, under the terms of the ordinary General Public
|
||||
License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is safest
|
||||
to attach them to the start of each source file to most effectively convey
|
||||
the exclusion of warranty; and each file should have at least the "copyright"
|
||||
line and a pointer to where the full notice is found.
|
||||
|
||||
< one line to give the library's name and an idea of what it does. >
|
||||
|
||||
Copyright (C) < year > < name of author >
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the Free
|
||||
Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
This library 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information
|
||||
on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school,
|
||||
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
|
||||
is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
|
||||
by James Random Hacker.
|
||||
|
||||
< signature of Ty Coon > , 1 April 1990
|
||||
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
468
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-2.1-or-later.txt
vendored
Normal file
468
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-2.1-or-later.txt
vendored
Normal file
@@ -0,0 +1,468 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts as the
|
||||
successor of the GNU Library Public License, version 2, hence the version
|
||||
number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share
|
||||
and change it. By contrast, the GNU General Public Licenses are intended to
|
||||
guarantee your freedom to share and change free software--to make sure the
|
||||
software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some specially
|
||||
designated software packages--typically libraries--of the Free Software Foundation
|
||||
and other authors who decide to use it. You can use it too, but we suggest
|
||||
you first think carefully about whether this license or the ordinary General
|
||||
Public License is the better strategy to use in any particular case, based
|
||||
on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use, not price.
|
||||
Our General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for this service if you
|
||||
wish); that you receive source code or can get it if you want it; that you
|
||||
can change the software and use pieces of it in new free programs; and that
|
||||
you are informed that you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid distributors
|
||||
to deny you these rights or to ask you to surrender these rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of
|
||||
the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis or for
|
||||
a fee, you must give the recipients all the rights that we gave you. You must
|
||||
make sure that they, too, receive or can get the source code. If you link
|
||||
other code with the library, you must provide complete object files to the
|
||||
recipients, so that they can relink them with the library after making changes
|
||||
to the library and recompiling it. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the library,
|
||||
and (2) we offer you this license, which gives you legal permission to copy,
|
||||
distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that there is no
|
||||
warranty for the free library. Also, if the library is modified by someone
|
||||
else and passed on, the recipients should know that what they have is not
|
||||
the original version, so that the original author's reputation will not be
|
||||
affected by problems that might be introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of any free
|
||||
program. We wish to make sure that a company cannot effectively restrict the
|
||||
users of a free program by obtaining a restrictive license from a patent holder.
|
||||
Therefore, we insist that any patent license obtained for a version of the
|
||||
library must be consistent with the full freedom of use specified in this
|
||||
license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary GNU
|
||||
General Public License. This license, the GNU Lesser General Public License,
|
||||
applies to certain designated libraries, and is quite different from the ordinary
|
||||
General Public License. We use this license for certain libraries in order
|
||||
to permit linking those libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using a shared
|
||||
library, the combination of the two is legally speaking a combined work, a
|
||||
derivative of the original library. The ordinary General Public License therefore
|
||||
permits such linking only if the entire combination fits its criteria of freedom.
|
||||
The Lesser General Public License permits more lax criteria for linking other
|
||||
code with the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it does Less
|
||||
to protect the user's freedom than the ordinary General Public License. It
|
||||
also provides other free software developers Less of an advantage over competing
|
||||
non-free programs. These disadvantages are the reason we use the ordinary
|
||||
General Public License for many libraries. However, the Lesser license provides
|
||||
advantages in certain special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to encourage the
|
||||
widest possible use of a certain library, so that it becomes a de-facto standard.
|
||||
To achieve this, non-free programs must be allowed to use the library. A more
|
||||
frequent case is that a free library does the same job as widely used non-free
|
||||
libraries. In this case, there is little to gain by limiting the free library
|
||||
to free software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free programs
|
||||
enables a greater number of people to use a large body of free software. For
|
||||
example, permission to use the GNU C Library in non-free programs enables
|
||||
many more people to use the whole GNU operating system, as well as its variant,
|
||||
the GNU/Linux operating system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the users'
|
||||
freedom, it does ensure that the user of a program that is linked with the
|
||||
Library has the freedom and the wherewithal to run that program using a modified
|
||||
version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow. Pay close attention to the difference between a "work based on the
|
||||
library" and a "work that uses the library". The former contains code derived
|
||||
from the library, whereas the latter must be combined with the library in
|
||||
order to run.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other program
|
||||
which contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Lesser General
|
||||
Public License (also called "this License"). Each licensee is addressed as
|
||||
"you".
|
||||
|
||||
A "library" means a collection of software functions and/or data prepared
|
||||
so as to be conveniently linked with application programs (which use some
|
||||
of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work which has
|
||||
been distributed under these terms. A "work based on the Library" means either
|
||||
the Library or any derivative work under copyright law: that is to say, a
|
||||
work containing the Library or a portion of it, either verbatim or with modifications
|
||||
and/or translated straightforwardly into another language. (Hereinafter, translation
|
||||
is included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for making modifications
|
||||
to it. For a library, complete source code means all the source code for all
|
||||
modules it contains, plus any associated interface definition files, plus
|
||||
the scripts used to control compilation and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running a program
|
||||
using the Library is not restricted, and output from such a program is covered
|
||||
only if its contents constitute a work based on the Library (independent of
|
||||
the use of the Library in a tool for writing it). Whether that is true depends
|
||||
on what the Library does and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's complete source
|
||||
code as you receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice and disclaimer
|
||||
of warranty; keep intact all the notices that refer to this License and to
|
||||
the absence of any warranty; and distribute a copy of this License along with
|
||||
the Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion of it,
|
||||
thus forming a work based on the Library, and copy and distribute such modifications
|
||||
or work under the terms of Section 1 above, provided that you also meet all
|
||||
of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no charge to all
|
||||
third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a table of
|
||||
data to be supplied by an application program that uses the facility, other
|
||||
than as an argument passed when the facility is invoked, then you must make
|
||||
a good faith effort to ensure that, in the event an application does not supply
|
||||
such function or table, the facility still operates, and performs whatever
|
||||
part of its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has a purpose
|
||||
that is entirely well-defined independent of the application. Therefore, Subsection
|
||||
2d requires that any application-supplied function or table used by this function
|
||||
must be optional: if the application does not supply it, the square root function
|
||||
must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Library, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them as
|
||||
separate works. But when you distribute the same sections as part of a whole
|
||||
which is a work based on the Library, the distribution of the whole must be
|
||||
on the terms of this License, whose permissions for other licensees extend
|
||||
to the entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your
|
||||
rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works based
|
||||
on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library with
|
||||
the Library (or with a work based on the Library) on a volume of a storage
|
||||
or distribution medium does not bring the other work under the scope of this
|
||||
License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public License
|
||||
instead of this License to a given copy of the Library. To do this, you must
|
||||
alter all the notices that refer to this License, so that they refer to the
|
||||
ordinary GNU General Public License, version 2, instead of to this License.
|
||||
(If a newer version than version 2 of the ordinary GNU General Public License
|
||||
has appeared, then you can specify that version instead if you wish.) Do not
|
||||
make any other change in these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for that copy,
|
||||
so the ordinary GNU General Public License applies to all subsequent copies
|
||||
and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of the Library
|
||||
into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or derivative of
|
||||
it, under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you accompany it with the complete corresponding
|
||||
machine-readable source code, which must be distributed under the terms of
|
||||
Sections 1 and 2 above on a medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy from a designated
|
||||
place, then offering equivalent access to copy the source code from the same
|
||||
place satisfies the requirement to distribute the source code, even though
|
||||
third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the Library, but
|
||||
is designed to work with the Library by being compiled or linked with it,
|
||||
is called a "work that uses the Library". Such a work, in isolation, is not
|
||||
a derivative work of the Library, and therefore falls outside the scope of
|
||||
this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library creates an
|
||||
executable that is a derivative of the Library (because it contains portions
|
||||
of the Library), rather than a "work that uses the library". The executable
|
||||
is therefore covered by this License. Section 6 states terms for distribution
|
||||
of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file that
|
||||
is part of the Library, the object code for the work may be a derivative work
|
||||
of the Library even though the source code is not. Whether this is true is
|
||||
especially significant if the work can be linked without the Library, or if
|
||||
the work is itself a library. The threshold for this to be true is not precisely
|
||||
defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data structure layouts
|
||||
and accessors, and small macros and small inline functions (ten lines or less
|
||||
in length), then the use of the object file is unrestricted, regardless of
|
||||
whether it is legally a derivative work. (Executables containing this object
|
||||
code plus portions of the Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may distribute
|
||||
the object code for the work under the terms of Section 6. Any executables
|
||||
containing that work also fall under Section 6, whether or not they are linked
|
||||
directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or link a "work
|
||||
that uses the Library" with the Library to produce a work containing portions
|
||||
of the Library, and distribute that work under terms of your choice, provided
|
||||
that the terms permit modification of the work for the customer's own use
|
||||
and reverse engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
You must supply a copy of this License. If the work during execution displays
|
||||
copyright notices, you must include the copyright notice for the Library among
|
||||
them, as well as a reference directing the user to the copy of this License.
|
||||
Also, you must do one of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding machine-readable source
|
||||
code for the Library including whatever changes were used in the work (which
|
||||
must be distributed under Sections 1 and 2 above); and, if the work is an
|
||||
executable linked with the Library, with the complete machine-readable "work
|
||||
that uses the Library", as object code and/or source code, so that the user
|
||||
can modify the Library and then relink to produce a modified executable containing
|
||||
the modified Library. (It is understood that the user who changes the contents
|
||||
of definitions files in the Library will not necessarily be able to recompile
|
||||
the application to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the Library. A
|
||||
suitable mechanism is one that (1) uses at run time a copy of the library
|
||||
already present on the user's computer system, rather than copying library
|
||||
functions into the executable, and (2) will operate properly with a modified
|
||||
version of the library, if the user installs one, as long as the modified
|
||||
version is interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at least three years,
|
||||
to give the same user the materials specified in Subsection 6a, above, for
|
||||
a charge no more than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy from a designated
|
||||
place, offer equivalent access to copy the above specified materials from
|
||||
the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these materials or
|
||||
that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the Library" must
|
||||
include any data and utility programs needed for reproducing the executable
|
||||
from it. However, as a special exception, the materials to be distributed
|
||||
need not include anything that is normally distributed (in either source or
|
||||
binary form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component itself
|
||||
accompanies the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license restrictions of
|
||||
other proprietary libraries that do not normally accompany the operating system.
|
||||
Such a contradiction means you cannot use both them and the Library together
|
||||
in an executable that you distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the Library side-by-side
|
||||
in a single library together with other library facilities not covered by
|
||||
this License, and distribute such a combined library, provided that the separate
|
||||
distribution of the work based on the Library and of the other library facilities
|
||||
is otherwise permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the
|
||||
Library, uncombined with any other library facilities. This must be distributed
|
||||
under the terms of the Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact that part of
|
||||
it is a work based on the Library, and explaining where to find the accompanying
|
||||
uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute the Library
|
||||
except as expressly provided under this License. Any attempt otherwise to
|
||||
copy, modify, sublicense, link with, or distribute the Library is void, and
|
||||
will automatically terminate your rights under this License. However, parties
|
||||
who have received copies, or rights, from you under this License will not
|
||||
have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not signed
|
||||
it. However, nothing else grants you permission to modify or distribute the
|
||||
Library or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the Library
|
||||
(or any work based on the Library), you indicate your acceptance of this License
|
||||
to do so, and all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the Library),
|
||||
the recipient automatically receives a license from the original licensor
|
||||
to copy, distribute, link with or modify the Library subject to these terms
|
||||
and conditions. You may not impose any further restrictions on the recipients'
|
||||
exercise of the rights granted herein. You are not responsible for enforcing
|
||||
compliance by third parties with this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent infringement
|
||||
or for any other reason (not limited to patent issues), conditions are imposed
|
||||
on you (whether by court order, agreement or otherwise) that contradict the
|
||||
conditions of this License, they do not excuse you from the conditions of
|
||||
this License. If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations, then as
|
||||
a consequence you may not distribute the Library at all. For example, if a
|
||||
patent license would not permit royalty-free redistribution of the Library
|
||||
by all those who receive copies directly or indirectly through you, then the
|
||||
only way you could satisfy both it and this License would be to refrain entirely
|
||||
from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents
|
||||
or other property right claims or to contest validity of any such claims;
|
||||
this section has the sole purpose of protecting the integrity of the free
|
||||
software distribution system which is implemented by public license practices.
|
||||
Many people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Library under this License may add an explicit geographical
|
||||
distribution limitation excluding those countries, so that distribution is
|
||||
permitted only in or among countries not thus excluded. In such case, this
|
||||
License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new versions of
|
||||
the Lesser General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to address
|
||||
new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that version
|
||||
or of any later version published by the Free Software Foundation. If the
|
||||
Library does not specify a license version number, you may choose any version
|
||||
ever published by the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free programs
|
||||
whose distribution conditions are incompatible with these, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free Software
|
||||
Foundation, write to the Free Software Foundation; we sometimes make exceptions
|
||||
for this. Our decision will be guided by the two goals of preserving the free
|
||||
status of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
|
||||
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
|
||||
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
|
||||
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
|
||||
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
|
||||
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest possible
|
||||
use to the public, we recommend making it free software that everyone can
|
||||
redistribute and change. You can do so by permitting redistribution under
|
||||
these terms (or, alternatively, under the terms of the ordinary General Public
|
||||
License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is safest
|
||||
to attach them to the start of each source file to most effectively convey
|
||||
the exclusion of warranty; and each file should have at least the "copyright"
|
||||
line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and an idea of what it does.>
|
||||
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the Free
|
||||
Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
This library 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school,
|
||||
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
|
||||
is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
|
||||
by James Random Hacker.
|
||||
|
||||
< signature of Ty Coon > , 1 April 1990
|
||||
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
163
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-3.0-only.txt
vendored
Normal file
163
Telegram/ThirdParty/kcoreaddons/LICENSES/LGPL-3.0-only.txt
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the terms
|
||||
and conditions of version 3 of the GNU General Public License, supplemented
|
||||
by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser General
|
||||
Public License, and the "GNU GPL" refers to version 3 of the GNU General Public
|
||||
License.
|
||||
|
||||
|
||||
|
||||
"The Library" refers to a covered work governed by this License, other than
|
||||
an Application or a Combined Work as defined below.
|
||||
|
||||
|
||||
|
||||
An "Application" is any work that makes use of an interface provided by the
|
||||
Library, but which is not otherwise based on the Library. Defining a subclass
|
||||
of a class defined by the Library is deemed a mode of using an interface provided
|
||||
by the Library.
|
||||
|
||||
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an Application
|
||||
with the Library. The particular version of the Library with which the Combined
|
||||
Work was made is also called the "Linked Version".
|
||||
|
||||
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the Corresponding
|
||||
Source for the Combined Work, excluding any source code for portions of the
|
||||
Combined Work that, considered in isolation, are based on the Application,
|
||||
and not on the Linked Version.
|
||||
|
||||
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the object
|
||||
code and/or source code for the Application, including any data and utility
|
||||
programs needed for reproducing the Combined Work from the Application, but
|
||||
excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License without
|
||||
being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a facility
|
||||
refers to a function or data to be supplied by an Application that uses the
|
||||
facility (other than as an argument passed when the facility is invoked),
|
||||
then you may convey a copy of the modified version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to ensure
|
||||
that, in the event an Application does not supply the function or data, the
|
||||
facility still operates, and performs whatever part of its purpose remains
|
||||
meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of this License
|
||||
applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from a header
|
||||
file that is part of the Library. You may convey such object code under terms
|
||||
of your choice, provided that, if the incorporated material is not limited
|
||||
to numerical parameters, data structure layouts and accessors, or small macros,
|
||||
inline functions and templates (ten or fewer lines in length), you do both
|
||||
of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that, taken together,
|
||||
effectively do not restrict modification of the portions of the Library contained
|
||||
in the Combined Work and reverse engineering for debugging such modifications,
|
||||
if you also do each of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during execution, include
|
||||
the copyright notice for the Library among these notices, as well as a reference
|
||||
directing the user to the copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License,
|
||||
and the Corresponding Application Code in a form suitable for, and under terms
|
||||
that permit, the user to recombine or relink the Application with a modified
|
||||
version of the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A
|
||||
suitable mechanism is one that (a) uses at run time a copy of the Library
|
||||
already present on the user's computer system, and (b) will operate properly
|
||||
with a modified version of the Library that is interface-compatible with the
|
||||
Linked Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise be required
|
||||
to provide such information under section 6 of the GNU GPL, and only to the
|
||||
extent that such information is necessary to install and execute a modified
|
||||
version of the Combined Work produced by recombining or relinking the Application
|
||||
with a modified version of the Linked Version. (If you use option 4d0, the
|
||||
Installation Information must accompany the Minimal Corresponding Source and
|
||||
Corresponding Application Code. If you use option 4d1, you must provide the
|
||||
Installation Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the Library side
|
||||
by side in a single library together with other library facilities that are
|
||||
not Applications and are not covered by this License, and convey such a combined
|
||||
library under terms of your choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the
|
||||
Library, uncombined with any other library facilities, conveyed under the
|
||||
terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it is a work
|
||||
based on the Library, and explaining where to find the accompanying uncombined
|
||||
form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the
|
||||
GNU Lesser General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to address
|
||||
new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library as you
|
||||
received it specifies that a certain numbered version of the GNU Lesser General
|
||||
Public License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that published version or of
|
||||
any later version published by the Free Software Foundation. If the Library
|
||||
as you received it does not specify a version number of the GNU Lesser General
|
||||
Public License, you may choose any version of the GNU Lesser General Public
|
||||
License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide whether
|
||||
future versions of the GNU Lesser General Public License shall apply, that
|
||||
proxy's public statement of acceptance of any version is permanent authorization
|
||||
for you to choose that version for the Library.
|
||||
12
Telegram/ThirdParty/kcoreaddons/LICENSES/LicenseRef-KDE-Accepted-GPL.txt
vendored
Normal file
12
Telegram/ThirdParty/kcoreaddons/LICENSES/LicenseRef-KDE-Accepted-GPL.txt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 3 of
|
||||
the license or (at your option) at any later version that is
|
||||
accepted by the membership of KDE e.V. (or its successor
|
||||
approved by the membership of KDE e.V.), which shall act as a
|
||||
proxy as defined in Section 14 of version 3 of the license.
|
||||
|
||||
This program 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.
|
||||
12
Telegram/ThirdParty/kcoreaddons/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt
vendored
Normal file
12
Telegram/ThirdParty/kcoreaddons/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the license or (at your option) any later version
|
||||
that is accepted by the membership of KDE e.V. (or its successor
|
||||
approved by the membership of KDE e.V.), which shall act as a
|
||||
proxy as defined in Section 6 of version 3 of the license.
|
||||
|
||||
This program 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.
|
||||
7
Telegram/ThirdParty/kcoreaddons/LICENSES/LicenseRef-Qt-Commercial.txt
vendored
Normal file
7
Telegram/ThirdParty/kcoreaddons/LICENSES/LicenseRef-Qt-Commercial.txt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Commercial License Usage
|
||||
Licensees holding valid commercial Qt licenses may use this file in
|
||||
accordance with the commercial license agreement provided with the
|
||||
Software or, alternatively, in accordance with the terms contained in
|
||||
a written agreement between you and The Qt Company. For licensing terms
|
||||
and conditions see https://www.qt.io/terms-conditions. For further
|
||||
information use the contact form at https://www.qt.io/contact-us.
|
||||
422
Telegram/ThirdParty/kcoreaddons/LICENSES/MPL-1.1.txt
vendored
Normal file
422
Telegram/ThirdParty/kcoreaddons/LICENSES/MPL-1.1.txt
vendored
Normal file
@@ -0,0 +1,422 @@
|
||||
Mozilla Public License Version 1.1
|
||||
|
||||
1. Definitions.
|
||||
|
||||
1.0.1. "Commercial Use" means distribution or otherwise making the Covered
|
||||
Code available to a third party.
|
||||
|
||||
1.1. "Contributor" means each entity that creates or contributes to the creation
|
||||
of Modifications.
|
||||
|
||||
1.2. "Contributor Version" means the combination of the Original Code, prior
|
||||
Modifications used by a Contributor, and the Modifications made by that particular
|
||||
Contributor.
|
||||
|
||||
1.3. "Covered Code" means the Original Code or Modifications or the combination
|
||||
of the Original Code and Modifications, in each case including portions thereof.
|
||||
|
||||
1.4. "Electronic Distribution Mechanism" means a mechanism generally accepted
|
||||
in the software development community for the electronic transfer of data.
|
||||
|
||||
1.5. "Executable" means Covered Code in any form other than Source Code.
|
||||
|
||||
1.6. "Initial Developer" means the individual or entity identified as the
|
||||
Initial Developer in the Source Code notice required by Exhibit A.
|
||||
|
||||
1.7. "Larger Work" means a work which combines Covered Code or portions thereof
|
||||
with code not governed by the terms of this License.
|
||||
|
||||
1.8. "License" means this document.
|
||||
|
||||
1.8.1. "Licensable" means having the right to grant, to the maximum extent
|
||||
possible, whether at the time of the initial grant or subsequently acquired,
|
||||
any and all of the rights conveyed herein.
|
||||
|
||||
1.9. "Modifications" means any addition to or deletion from the substance
|
||||
or structure of either the Original Code or any previous Modifications. When
|
||||
Covered Code is released as a series of files, a Modification is:
|
||||
|
||||
Any addition to or deletion from the contents of a file containing Original
|
||||
Code or previous Modifications.
|
||||
|
||||
Any new file that contains any part of the Original Code or previous Modifications.
|
||||
|
||||
1.10. "Original Code" means Source Code of computer software code which is
|
||||
described in the Source Code notice required by Exhibit A as Original Code,
|
||||
and which, at the time of its release under this License is not already Covered
|
||||
Code governed by this License.
|
||||
|
||||
1.10.1. "Patent Claims" means any patent claim(s), now owned or hereafter
|
||||
acquired, including without limitation, method, process, and apparatus claims,
|
||||
in any patent Licensable by grantor.
|
||||
|
||||
1.11. "Source Code" means the preferred form of the Covered Code for making
|
||||
modifications to it, including all modules it contains, plus any associated
|
||||
interface definition files, scripts used to control compilation and installation
|
||||
of an Executable, or source code differential comparisons against either the
|
||||
Original Code or another well known, available Covered Code of the Contributor's
|
||||
choice. The Source Code can be in a compressed or archival form, provided
|
||||
the appropriate decompression or de-archiving software is widely available
|
||||
for no charge.
|
||||
|
||||
1.12. "You" (or "Your") means an individual or a legal entity exercising rights
|
||||
under, and complying with all of the terms of, this License or a future version
|
||||
of this License issued under Section 6.1. For legal entities, "You" includes
|
||||
any entity which controls, is controlled by, or is under common control with
|
||||
You. For purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity, whether
|
||||
by contract or otherwise, or (b) ownership of more than fifty percent (50%)
|
||||
of the outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
2. Source Code License.
|
||||
|
||||
2.1. The Initial Developer Grant. The Initial Developer hereby grants You
|
||||
a world-wide, royalty-free, non-exclusive license, subject to third party
|
||||
intellectual property claims:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark) Licensable
|
||||
by Initial Developer to use, reproduce, modify, display, perform, sublicense
|
||||
and distribute the Original Code (or portions thereof) with or without Modifications,
|
||||
and/or as part of a Larger Work; and
|
||||
|
||||
b. under Patents Claims infringed by the making, using or selling of Original
|
||||
Code, to make, have made, use, practice, sell, and offer for sale, and/or
|
||||
otherwise dispose of the Original Code (or portions thereof).
|
||||
|
||||
c. the licenses granted in this Section 2.1 (a) and (b) are effective on the
|
||||
date Initial Developer first distributes Original Code under the terms of
|
||||
this License.
|
||||
|
||||
d. Notwithstanding Section 2.1 (b) above, no patent license is granted: 1)
|
||||
for code that You delete from the Original Code; 2) separate from the Original
|
||||
Code; or 3) for infringements caused by: i) the modification of the Original
|
||||
Code or ii) the combination of the Original Code with other software or devices.
|
||||
|
||||
2.2. Contributor Grant. Subject to third party intellectual property claims,
|
||||
each Contributor hereby grants You a world-wide, royalty-free, non-exclusive
|
||||
license
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark) Licensable
|
||||
by Contributor, to use, reproduce, modify, display, perform, sublicense and
|
||||
distribute the Modifications created by such Contributor (or portions thereof)
|
||||
either on an unmodified basis, with other Modifications, as Covered Code and/or
|
||||
as part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims infringed by the making, using, or selling of Modifications
|
||||
made by that Contributor either alone and/or in combination with its Contributor
|
||||
Version (or portions of such combination), to make, use, sell, offer for sale,
|
||||
have made, and/or otherwise dispose of: 1) Modifications made by that Contributor
|
||||
(or portions thereof); and 2) the combination of Modifications made by that
|
||||
Contributor with its Contributor Version (or portions of such combination).
|
||||
|
||||
c. the licenses granted in Sections 2.2 (a) and 2.2 (b) are effective on the
|
||||
date Contributor first makes Commercial Use of the Covered Code.
|
||||
|
||||
d. Notwithstanding Section 2.2 (b) above, no patent license is granted: 1)
|
||||
for any code that Contributor has deleted from the Contributor Version; 2)
|
||||
separate from the Contributor Version; 3) for infringements caused by: i)
|
||||
third party modifications of Contributor Version or ii) the combination of
|
||||
Modifications made by that Contributor with other software (except as part
|
||||
of the Contributor Version) or other devices; or 4) under Patent Claims infringed
|
||||
by Covered Code in the absence of Modifications made by that Contributor.
|
||||
|
||||
3. Distribution Obligations.
|
||||
|
||||
3.1. Application of License. The Modifications which You create or to which
|
||||
You contribute are governed by the terms of this License, including without
|
||||
limitation Section 2.2. The Source Code version of Covered Code may be distributed
|
||||
only under the terms of this License or a future version of this License released
|
||||
under Section 6.1, and You must include a copy of this License with every
|
||||
copy of the Source Code You distribute. You may not offer or impose any terms
|
||||
on any Source Code version that alters or restricts the applicable version
|
||||
of this License or the recipients' rights hereunder. However, You may include
|
||||
an additional document offering the additional rights described in Section
|
||||
3.5.
|
||||
|
||||
3.2. Availability of Source Code. Any Modification which You create or to
|
||||
which You contribute must be made available in Source Code form under the
|
||||
terms of this License either on the same media as an Executable version or
|
||||
via an accepted Electronic Distribution Mechanism to anyone to whom you made
|
||||
an Executable version available; and if made available via Electronic Distribution
|
||||
Mechanism, must remain available for at least twelve (12) months after the
|
||||
date it initially became available, or at least six (6) months after a subsequent
|
||||
version of that particular Modification has been made available to such recipients.
|
||||
You are responsible for ensuring that the Source Code version remains available
|
||||
even if the Electronic Distribution Mechanism is maintained by a third party.
|
||||
|
||||
3.3. Description of Modifications. You must cause all Covered Code to which
|
||||
You contribute to contain a file documenting the changes You made to create
|
||||
that Covered Code and the date of any change. You must include a prominent
|
||||
statement that the Modification is derived, directly or indirectly, from Original
|
||||
Code provided by the Initial Developer and including the name of the Initial
|
||||
Developer in (a) the Source Code, and (b) in any notice in an Executable version
|
||||
or related documentation in which You describe the origin or ownership of
|
||||
the Covered Code.
|
||||
|
||||
3.4. Intellectual Property Matters
|
||||
|
||||
(a) Third Party Claims
|
||||
|
||||
If Contributor has knowledge that a license under a third party's intellectual
|
||||
property rights is required to exercise the rights granted by such Contributor
|
||||
under Sections 2.1 or 2.2, Contributor must include a text file with the Source
|
||||
Code distribution titled "LEGAL" which describes the claim and the party making
|
||||
the claim in sufficient detail that a recipient will know whom to contact.
|
||||
If Contributor obtains such knowledge after the Modification is made available
|
||||
as described in Section 3.2, Contributor shall promptly modify the LEGAL file
|
||||
in all copies Contributor makes available thereafter and shall take other
|
||||
steps (such as notifying appropriate mailing lists or newsgroups) reasonably
|
||||
calculated to inform those who received the Covered Code that new knowledge
|
||||
has been obtained.
|
||||
|
||||
(b) Contributor APIs
|
||||
|
||||
If Contributor's Modifications include an application programming interface
|
||||
and Contributor has knowledge of patent licenses which are reasonably necessary
|
||||
to implement that API, Contributor must also include this information in the
|
||||
LEGAL file.
|
||||
|
||||
(c) Representations.
|
||||
|
||||
Contributor represents that, except as disclosed pursuant to Section 3.4 (a)
|
||||
above, Contributor believes that Contributor's Modifications are Contributor's
|
||||
original creation(s) and/or Contributor has sufficient rights to grant the
|
||||
rights conveyed by this License.
|
||||
|
||||
3.5. Required Notices. You must duplicate the notice in Exhibit A in each
|
||||
file of the Source Code. If it is not possible to put such notice in a particular
|
||||
Source Code file due to its structure, then You must include such notice in
|
||||
a location (such as a relevant directory) where a user would be likely to
|
||||
look for such a notice. If You created one or more Modification(s) You may
|
||||
add your name as a Contributor to the notice described in Exhibit A. You must
|
||||
also duplicate this License in any documentation for the Source Code where
|
||||
You describe recipients' rights or ownership rights relating to Covered Code.
|
||||
You may choose to offer, and to charge a fee for, warranty, support, indemnity
|
||||
or liability obligations to one or more recipients of Covered Code. However,
|
||||
You may do so only on Your own behalf, and not on behalf of the Initial Developer
|
||||
or any Contributor. You must make it absolutely clear than any such warranty,
|
||||
support, indemnity or liability obligation is offered by You alone, and You
|
||||
hereby agree to indemnify the Initial Developer and every Contributor for
|
||||
any liability incurred by the Initial Developer or such Contributor as a result
|
||||
of warranty, support, indemnity or liability terms You offer.
|
||||
|
||||
3.6. Distribution of Executable Versions. You may distribute Covered Code
|
||||
in Executable form only if the requirements of Sections 3.1, 3.2, 3.3, 3.4
|
||||
and 3.5 have been met for that Covered Code, and if You include a notice stating
|
||||
that the Source Code version of the Covered Code is available under the terms
|
||||
of this License, including a description of how and where You have fulfilled
|
||||
the obligations of Section 3.2. The notice must be conspicuously included
|
||||
in any notice in an Executable version, related documentation or collateral
|
||||
in which You describe recipients' rights relating to the Covered Code. You
|
||||
may distribute the Executable version of Covered Code or ownership rights
|
||||
under a license of Your choice, which may contain terms different from this
|
||||
License, provided that You are in compliance with the terms of this License
|
||||
and that the license for the Executable version does not attempt to limit
|
||||
or alter the recipient's rights in the Source Code version from the rights
|
||||
set forth in this License. If You distribute the Executable version under
|
||||
a different license You must make it absolutely clear that any terms which
|
||||
differ from this License are offered by You alone, not by the Initial Developer
|
||||
or any Contributor. You hereby agree to indemnify the Initial Developer and
|
||||
every Contributor for any liability incurred by the Initial Developer or such
|
||||
Contributor as a result of any such terms You offer.
|
||||
|
||||
3.7. Larger Works. You may create a Larger Work by combining Covered Code
|
||||
with other code not governed by the terms of this License and distribute the
|
||||
Larger Work as a single product. In such a case, You must make sure the requirements
|
||||
of this License are fulfilled for the Covered Code.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation.
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Code due to statute, judicial order,
|
||||
or regulation then You must: (a) comply with the terms of this License to
|
||||
the maximum extent possible; and (b) describe the limitations and the code
|
||||
they affect. Such description must be included in the LEGAL file described
|
||||
in Section 3.4 and must be included with all distributions of the Source Code.
|
||||
Except to the extent prohibited by statute or regulation, such description
|
||||
must be sufficiently detailed for a recipient of ordinary skill to be able
|
||||
to understand it.
|
||||
|
||||
5. Application of this License.
|
||||
|
||||
This License applies to code to which the Initial Developer has attached the
|
||||
notice in Exhibit A and to related Covered Code.
|
||||
|
||||
6. Versions of the License.
|
||||
|
||||
6.1. New Versions
|
||||
|
||||
Netscape Communications Corporation ("Netscape") may publish revised and/or
|
||||
new versions of the License from time to time. Each version will be given
|
||||
a distinguishing version number.
|
||||
|
||||
6.2. Effect of New Versions
|
||||
|
||||
Once Covered Code has been published under a particular version of the License,
|
||||
You may always continue to use it under the terms of that version. You may
|
||||
also choose to use such Covered Code under the terms of any subsequent version
|
||||
of the License published by Netscape. No one other than Netscape has the right
|
||||
to modify the terms applicable to Covered Code created under this License.
|
||||
|
||||
6.3. Derivative Works
|
||||
|
||||
If You create or use a modified version of this License (which you may only
|
||||
do in order to apply it to code which is not already Covered Code governed
|
||||
by this License), You must (a) rename Your license so that the phrases "Mozilla",
|
||||
"MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or any confusingly similar
|
||||
phrase do not appear in your license (except to note that your license differs
|
||||
from this License) and (b) otherwise make it clear that Your version of the
|
||||
license contains terms which differ from the Mozilla Public License and Netscape
|
||||
Public License. (Filling in the name of the Initial Developer, Original Code
|
||||
or Contributor in the notice described in Exhibit A shall not of themselves
|
||||
be deemed to be modifications of this License.)
|
||||
|
||||
7. DISCLAIMER OF WARRANTY
|
||||
|
||||
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
|
||||
THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
|
||||
PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN
|
||||
ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME
|
||||
THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
|
||||
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED
|
||||
CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||
|
||||
8. Termination
|
||||
|
||||
8.1. This License and the rights granted hereunder will terminate automatically
|
||||
if You fail to comply with terms herein and fail to cure such breach within
|
||||
30 days of becoming aware of the breach. All sublicenses to the Covered Code
|
||||
which are properly granted shall survive any termination of this License.
|
||||
Provisions which, by their nature, must remain in effect beyond the termination
|
||||
of this License shall survive.
|
||||
|
||||
8.2. If You initiate litigation by asserting a patent infringement claim (excluding
|
||||
declatory judgment actions) against Initial Developer or a Contributor (the
|
||||
Initial Developer or Contributor against whom You file such action is referred
|
||||
to as "Participant") alleging that:
|
||||
|
||||
a. such Participant's Contributor Version directly or indirectly infringes
|
||||
any patent, then any and all rights granted by such Participant to You under
|
||||
Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant
|
||||
terminate prospectively, unless if within 60 days after receipt of notice
|
||||
You either: (i) agree in writing to pay Participant a mutually agreeable reasonable
|
||||
royalty for Your past and future use of Modifications made by such Participant,
|
||||
or (ii) withdraw Your litigation claim with respect to the Contributor Version
|
||||
against such Participant. If within 60 days of notice, a reasonable royalty
|
||||
and payment arrangement are not mutually agreed upon in writing by the parties
|
||||
or the litigation claim is not withdrawn, the rights granted by Participant
|
||||
to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration
|
||||
of the 60 day notice period specified above.
|
||||
|
||||
b. any software, hardware, or device, other than such Participant's Contributor
|
||||
Version, directly or indirectly infringes any patent, then any rights granted
|
||||
to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective
|
||||
as of the date You first made, used, sold, distributed, or had made, Modifications
|
||||
made by that Participant.
|
||||
|
||||
8.3. If You assert a patent infringement claim against Participant alleging
|
||||
that such Participant's Contributor Version directly or indirectly infringes
|
||||
any patent where such claim is resolved (such as by license or settlement)
|
||||
prior to the initiation of patent infringement litigation, then the reasonable
|
||||
value of the licenses granted by such Participant under Sections 2.1 or 2.2
|
||||
shall be taken into account in determining the amount or value of any payment
|
||||
or license.
|
||||
|
||||
8.4. In the event of termination under Sections 8.1 or 8.2 above, all end
|
||||
user license agreements (excluding distributors and resellers) which have
|
||||
been validly granted by You or any distributor hereunder prior to termination
|
||||
shall survive termination.
|
||||
|
||||
9. LIMITATION OF LIABILITY
|
||||
|
||||
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING
|
||||
NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY
|
||||
OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF
|
||||
ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL,
|
||||
OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES
|
||||
FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY
|
||||
AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE
|
||||
BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY
|
||||
SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH
|
||||
PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION.
|
||||
SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL
|
||||
OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO
|
||||
YOU.
|
||||
|
||||
10. U.S. government end users
|
||||
|
||||
The Covered Code is a "commercial item," as that term is defined in 48 C.F.R.
|
||||
2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial
|
||||
computer software documentation," as such terms are used in 48 C.F.R. 12.212
|
||||
(Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through
|
||||
227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code
|
||||
with only those rights set forth herein.
|
||||
|
||||
11. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning subject matter hereof.
|
||||
If any provision of this License is held to be unenforceable, such provision
|
||||
shall be reformed only to the extent necessary to make it enforceable. This
|
||||
License shall be governed by California law provisions (except to the extent
|
||||
applicable law, if any, provides otherwise), excluding its conflict-of-law
|
||||
provisions. With respect to disputes in which at least one party is a citizen
|
||||
of, or an entity chartered or registered to do business in the United States
|
||||
of America, any litigation relating to this License shall be subject to the
|
||||
jurisdiction of the Federal Courts of the Northern District of California,
|
||||
with venue lying in Santa Clara County, California, with the losing party
|
||||
responsible for costs, including without limitation, court costs and reasonable
|
||||
attorneys' fees and expenses. The application of the United Nations Convention
|
||||
on Contracts for the International Sale of Goods is expressly excluded. Any
|
||||
law or regulation which provides that the language of a contract shall be
|
||||
construed against the drafter shall not apply to this License.
|
||||
|
||||
12. Responsibility for claims
|
||||
|
||||
As between Initial Developer and the Contributors, each party is responsible
|
||||
for claims and damages arising, directly or indirectly, out of its utilization
|
||||
of rights under this License and You agree to work with Initial Developer
|
||||
and Contributors to distribute such responsibility on an equitable basis.
|
||||
Nothing herein is intended or shall be deemed to constitute any admission
|
||||
of liability.
|
||||
|
||||
13. Multiple-licensed code
|
||||
|
||||
Initial Developer may designate portions of the Covered Code as "Multiple-Licensed".
|
||||
"Multiple-Licensed" means that the Initial Developer permits you to utilize
|
||||
portions of the Covered Code under Your choice of the MPL or the alternative
|
||||
licenses, if any, specified by the Initial Developer in the file described
|
||||
in Exhibit A. Exhibit A - Mozilla Public License.
|
||||
|
||||
"The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with the
|
||||
License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is ______________________________________ .
|
||||
|
||||
The Initial Developer of the Original Code is ________________________ .
|
||||
|
||||
Portions created by ______________________ are Copyright (C) ______ . All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________ .
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of the
|
||||
_____ license (the " [___] License"), in which case the provisions of [______]
|
||||
License are applicable instead of those above. If you wish to allow use of
|
||||
your version of this file only under the terms of the [____] License and not
|
||||
to allow others to use your version of this file under the MPL, indicate your
|
||||
decision by deleting the provisions above and replace them with the notice
|
||||
and other provisions required by the [___] License. If you do not delete the
|
||||
provisions above, a recipient may use your version of this file under either
|
||||
the MPL or the [___] License."
|
||||
|
||||
NOTE: The text of this Exhibit A may differ slightly from the text of the
|
||||
notices in the Source Code files of the Original Code. You should use the
|
||||
text of this Exhibit A rather than the text found in the Original Code Source
|
||||
Code for Your Modifications.
|
||||
21
Telegram/ThirdParty/kcoreaddons/LICENSES/Qt-LGPL-exception-1.1.txt
vendored
Normal file
21
Telegram/ThirdParty/kcoreaddons/LICENSES/Qt-LGPL-exception-1.1.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The Qt Company Qt LGPL Exception version 1.1
|
||||
|
||||
As an additional permission to the GNU Lesser General Public License version 2.1, the object code form of a "work that uses the Library" may incorporate material from a header file that is part of the Library. You may distribute such object code under terms of your choice, provided that:
|
||||
|
||||
(i) the header files of the Library have not been modified; and
|
||||
|
||||
(ii) the incorporated material is limited to numerical parameters, data structure layouts, accessors, macros, inline functions and templates; and
|
||||
|
||||
(iii) you comply with the terms of Section 6 of the GNU Lesser General Public License version 2.1.
|
||||
|
||||
Moreover, you may apply this exception to a modified version of the Library, provided that such modification does not involve copying material from the Library into the modified Library's header files unless such material is limited to
|
||||
|
||||
(i) numerical parameters;
|
||||
|
||||
(ii) data structure layouts;
|
||||
|
||||
(iii) accessors; and
|
||||
|
||||
(iv) small macros, templates and inline functions of five lines or less in length.
|
||||
|
||||
Furthermore, you are not required to apply this additional permission to a modified version of the Library.
|
||||
11
Telegram/ThirdParty/kcoreaddons/README.md
vendored
Normal file
11
Telegram/ThirdParty/kcoreaddons/README.md
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# KCoreAddons
|
||||
|
||||
Qt addon library with a collection of non-GUI utilities
|
||||
|
||||
## Introduction
|
||||
|
||||
KCoreAddons provides classes built on top of QtCore to perform various tasks
|
||||
such as manipulating mime types, autosaving files, creating backup files,
|
||||
generating random sequences, performing text manipulations such as macro
|
||||
replacement, accessing user information and many more.
|
||||
|
||||
206
Telegram/ThirdParty/kcoreaddons/autotests/CMakeLists.txt
vendored
Normal file
206
Telegram/ThirdParty/kcoreaddons/autotests/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
|
||||
set(KCOREADDONS_INTERNAL_SKIP_PLUGIN_INSTALLATION ON)
|
||||
|
||||
include(ECMAddTests)
|
||||
include(ConfigureChecks.cmake) #configure checks for QFileSystemWatcher
|
||||
include(../KF5CoreAddonsMacros.cmake)
|
||||
|
||||
find_package(Qt${QT_MAJOR_VERSION}Test ${REQUIRED_QT_VERSION} CONFIG QUIET)
|
||||
|
||||
if(NOT TARGET Qt${QT_MAJOR_VERSION}::Test)
|
||||
message(STATUS "QtTest not found, autotests will not be built.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE MATCHES "[Dd]ebug$")
|
||||
set(ENABLE_BENCHMARKS 1)
|
||||
endif()
|
||||
|
||||
add_library(autotests_static STATIC)
|
||||
# Needed to link this static lib to shared libs
|
||||
set_property(TARGET autotests_static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
ecm_qt_declare_logging_category(autotests_static
|
||||
HEADER kcoreaddons_debug.h
|
||||
IDENTIFIER KCOREADDONS_DEBUG
|
||||
CATEGORY_NAME kf.coreaddons
|
||||
)
|
||||
target_link_libraries(autotests_static Qt${QT_MAJOR_VERSION}::Core)
|
||||
|
||||
configure_file(config-tests.h.in config-tests.h)
|
||||
|
||||
macro(build_plugin pname)
|
||||
add_library(${pname} MODULE ${ARGN})
|
||||
ecm_mark_as_test(${pname})
|
||||
target_link_libraries(${pname} KF5::CoreAddons autotests_static)
|
||||
endmacro()
|
||||
|
||||
# Build some sample plugins
|
||||
build_plugin(jsonplugin jsonplugin.cpp)
|
||||
build_plugin(jsonplugin2 jsonplugin2.cpp)
|
||||
build_plugin(versionedplugin versionedplugin.cpp)
|
||||
build_plugin(unversionedplugin unversionedplugin.cpp)
|
||||
build_plugin(multiplugin multiplugin.cpp)
|
||||
build_plugin(alwaysunloadplugin alwaysunloadplugin.cpp)
|
||||
build_plugin(qtplugin qtplugin.cpp)
|
||||
|
||||
kcoreaddons_add_plugin(jsonplugin_cmake_macro SOURCES kpluginclass.cpp INSTALL_NAMESPACE "namespace")
|
||||
ecm_mark_as_test(jsonplugin_cmake_macro)
|
||||
target_link_libraries(jsonplugin_cmake_macro KF5::CoreAddons autotests_static)
|
||||
|
||||
kcoreaddons_add_plugin(pluginwithoutmetadata SOURCES pluginwithoutmetadata.cpp INSTALL_NAMESPACE "namespace")
|
||||
ecm_mark_as_test(pluginwithoutmetadata)
|
||||
target_link_libraries(pluginwithoutmetadata KF5::CoreAddons autotests_static)
|
||||
|
||||
add_library(org.kde.test MODULE jsonplugin.cpp)
|
||||
target_link_libraries(org.kde.test KF5::CoreAddons)
|
||||
|
||||
add_definitions( -DKDELIBS4CONFIGMIGRATOR_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
|
||||
|
||||
if (WIN32)
|
||||
set(autotests_OPTIONAL_SRCS
|
||||
${autotests_OPTIONAL_SRCS}
|
||||
klistopenfilesjobtest_win.cpp
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (UNIX)
|
||||
set(autotests_OPTIONAL_SRCS
|
||||
${autotests_OPTIONAL_SRCS}
|
||||
klistopenfilesjobtest_unix.cpp
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (NOT ${QT_MAJOR_VERSION} STREQUAL "6")
|
||||
set(autotests_OPTIONAL_SRCS
|
||||
${autotests_OPTIONAL_SRCS}
|
||||
kdelibs4migrationtest.cpp
|
||||
kdelibs4configmigratortest.cpp
|
||||
)
|
||||
endif ()
|
||||
ecm_add_tests(
|
||||
kaboutdatatest.cpp
|
||||
kaboutdataapplicationdatatest.cpp
|
||||
kautosavefiletest.cpp
|
||||
kcompositejobtest.cpp
|
||||
kformattest.cpp
|
||||
kjobtest.cpp
|
||||
kosreleasetest.cpp
|
||||
kpluginfactorytest.cpp
|
||||
kpluginloadertest.cpp
|
||||
kpluginmetadatatest.cpp
|
||||
kprocesstest.cpp
|
||||
krandomtest.cpp
|
||||
kshareddatacachetest.cpp
|
||||
kshelltest.cpp
|
||||
kurlmimedatatest.cpp
|
||||
kstringhandlertest.cpp
|
||||
kmacroexpandertest.cpp
|
||||
kusertest.cpp
|
||||
kprocesslisttest.cpp
|
||||
kfileutilstest.cpp
|
||||
kfuzzymatchertest.cpp
|
||||
knetworkmountstestcanonical.cpp
|
||||
knetworkmountstestnoconfig.cpp
|
||||
knetworkmountstestpaths.cpp
|
||||
knetworkmountsteststatic.cpp
|
||||
klibexectest.cpp
|
||||
kmemoryinfotest.cpp
|
||||
kruntimeplatformtest.cpp
|
||||
${autotests_OPTIONAL_SRCS}
|
||||
LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KF5::CoreAddons autotests_static
|
||||
)
|
||||
if(TARGET klistopenfilesjobtest_unix AND CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
find_package(Qt${QT_MAJOR_VERSION}Network ${REQUIRED_QT_VERSION} CONFIG QUIET)
|
||||
target_link_libraries(klistopenfilesjobtest_unix Qt${QT_MAJOR_VERSION}::Network)
|
||||
endif()
|
||||
|
||||
kcoreaddons_add_plugin(static_jsonplugin_cmake_macro SOURCES statickpluginclass.cpp INSTALL_NAMESPACE "staticnamespace" STATIC)
|
||||
target_link_libraries(static_jsonplugin_cmake_macro KF5::CoreAddons autotests_static)
|
||||
|
||||
kcoreaddons_add_plugin(static_jsonplugin_cmake_macro_2 SOURCES statickpluginclass_2.cpp INSTALL_NAMESPACE "staticnamespace2" STATIC)
|
||||
target_link_libraries(static_jsonplugin_cmake_macro_2 KF5::CoreAddons autotests_static)
|
||||
|
||||
kcoreaddons_add_plugin(static_plugin_without_metadata SOURCES staticpluginwithoutmetadata.cpp INSTALL_NAMESPACE "staticnamespace3" STATIC)
|
||||
target_link_libraries(static_plugin_without_metadata KF5::CoreAddons autotests_static)
|
||||
|
||||
|
||||
kcoreaddons_target_static_plugins(kpluginfactorytest "staticnamespace")
|
||||
kcoreaddons_target_static_plugins(kpluginfactorytest "staticnamespace2")
|
||||
kcoreaddons_target_static_plugins(kpluginmetadatatest "staticnamespace")
|
||||
kcoreaddons_target_static_plugins(kpluginmetadatatest "staticnamespace2")
|
||||
kcoreaddons_target_static_plugins(kpluginmetadatatest "staticnamespace3")
|
||||
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
ecm_add_tests(desktoptojsontest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KF5::CoreAddons autotests_static)
|
||||
target_compile_definitions(desktoptojsontest PRIVATE
|
||||
DESKTOP_TO_JSON_EXE="$<TARGET_FILE:desktoptojson>"
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(ktexttohtmlteststatic STATIC ${CMAKE_SOURCE_DIR}/src/lib/text/ktexttohtml.cpp)
|
||||
# include the binary dir in order to get kcoreaddons_export.h
|
||||
target_include_directories(ktexttohtmlteststatic PUBLIC ${KCoreAddons_BINARY_DIR}/src/lib)
|
||||
# fake static linking to prevent the export macros on Windows from kicking in
|
||||
target_compile_definitions(ktexttohtmlteststatic PUBLIC -DKCOREADDONS_STATIC_DEFINE=1)
|
||||
target_link_libraries(ktexttohtmlteststatic PUBLIC Qt${QT_MAJOR_VERSION}::Test autotests_static)
|
||||
ecm_add_test(ktexttohtmltest.cpp
|
||||
TEST_NAME ktexttohtmltest
|
||||
LINK_LIBRARIES ktexttohtmlteststatic
|
||||
)
|
||||
|
||||
add_executable(ktexttohtmlbenchmarktest ktexttohtmlbenchmarktest.cpp ${CMAKE_SOURCE_DIR}/src/lib/text/ktexttohtml.cpp)
|
||||
target_link_libraries(ktexttohtmlbenchmarktest PUBLIC ktexttohtmlteststatic)
|
||||
|
||||
add_executable(kprocesstest_helper kprocesstest_helper.cpp)
|
||||
target_link_libraries(kprocesstest_helper KF5::CoreAddons)
|
||||
|
||||
target_compile_definitions(kpluginloadertest PRIVATE
|
||||
JSONPLUGIN_FILE="$<TARGET_FILE:jsonplugin>"
|
||||
VERSIONEDPLUGIN_FILE="$<TARGET_FILE:versionedplugin>"
|
||||
UNVERSIONEDPLUGIN_FILE="$<TARGET_FILE:unversionedplugin>"
|
||||
MULTIPLUGIN_FILE="$<TARGET_FILE:multiplugin>"
|
||||
ALWAYSUNLOADPLUGIN_FILE="$<TARGET_FILE:alwaysunloadplugin>"
|
||||
)
|
||||
|
||||
set(KDIRWATCH_BACKENDS_TO_TEST Stat)#Stat is always compiled
|
||||
|
||||
if (HAVE_SYS_INOTIFY_H)
|
||||
list(APPEND KDIRWATCH_BACKENDS_TO_TEST INotify)
|
||||
endif()
|
||||
|
||||
if (HAVE_FAM)
|
||||
list(APPEND KDIRWATCH_BACKENDS_TO_TEST Fam)
|
||||
endif()
|
||||
|
||||
if (HAVE_QFILESYSTEMWATCHER)
|
||||
list(APPEND KDIRWATCH_BACKENDS_TO_TEST QFSWatch)
|
||||
endif()
|
||||
|
||||
foreach(_backendName ${KDIRWATCH_BACKENDS_TO_TEST})
|
||||
string(TOLOWER ${_backendName} _lowercaseBackendName)
|
||||
set(BACKEND_TEST_TARGET kdirwatch_${_lowercaseBackendName}_unittest)
|
||||
set(BACKEND_BENCHMARK_TARGET kdirwatch_${_lowercaseBackendName}_benchmarktest)
|
||||
add_executable(${BACKEND_TEST_TARGET} kdirwatch_unittest.cpp)
|
||||
target_link_libraries(${BACKEND_TEST_TARGET} Qt${QT_MAJOR_VERSION}::Test KF5::CoreAddons autotests_static)
|
||||
|
||||
if(FAM_FOUND)
|
||||
target_include_directories(${BACKEND_TEST_TARGET} PRIVATE ${FAM_INCLUDE_DIR})
|
||||
target_link_libraries(${BACKEND_TEST_TARGET} ${FAM_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(${BACKEND_TEST_TARGET} Threads::Threads)
|
||||
endif()
|
||||
|
||||
ecm_mark_as_test(${BACKEND_TEST_TARGET})
|
||||
add_test(NAME ${BACKEND_TEST_TARGET} COMMAND ${BACKEND_TEST_TARGET})
|
||||
target_compile_definitions(${BACKEND_TEST_TARGET} PUBLIC -DKDIRWATCH_TEST_METHOD=\"${_backendName}\")
|
||||
|
||||
add_executable(${BACKEND_BENCHMARK_TARGET} kdirwatch_benchmarktest.cpp)
|
||||
target_compile_definitions(${BACKEND_BENCHMARK_TARGET} PUBLIC -DKDIRWATCH_TEST_METHOD=\"${_backendName}\")
|
||||
target_link_libraries(${BACKEND_BENCHMARK_TARGET} Qt${QT_MAJOR_VERSION}::Test KF5::CoreAddons autotests_static)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(${BACKEND_BENCHMARK_TARGET} Threads::Threads)
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
9
Telegram/ThirdParty/kcoreaddons/autotests/ConfigureChecks.cmake
vendored
Normal file
9
Telegram/ThirdParty/kcoreaddons/autotests/ConfigureChecks.cmake
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
set(CMAKE_REQUIRED_LIBRARIES Qt${QT_MAJOR_VERSION}::Core)
|
||||
check_cxx_source_compiles(
|
||||
"#include <QtCore/QFileSystemWatcher>
|
||||
int main()
|
||||
{
|
||||
QFileSystemWatcher *watcher = new QFileSystemWatcher();
|
||||
delete watcher;
|
||||
return 0;
|
||||
}" HAVE_QFILESYSTEMWATCHER)
|
||||
24
Telegram/ThirdParty/kcoreaddons/autotests/alwaysunloadplugin.cpp
vendored
Normal file
24
Telegram/ThirdParty/kcoreaddons/autotests/alwaysunloadplugin.cpp
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
SPDX-FileCopyrightText: 2014 Alex Merry <alexmerry@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#include "alwaysunloadplugin.h"
|
||||
#include "kcoreaddons_debug.h"
|
||||
#include <QDebug>
|
||||
#include <kexportplugin.h>
|
||||
#include <kpluginfactory.h>
|
||||
|
||||
AlwaysUnloadPlugin::AlwaysUnloadPlugin(QObject *parent, const QVariantList &args)
|
||||
: QObject(parent)
|
||||
{
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Created AlwaysUnloadPlugin with args" << args;
|
||||
}
|
||||
|
||||
K_PLUGIN_FACTORY(AlwaysUnloadPluginFactory, registerPlugin<AlwaysUnloadPlugin>();)
|
||||
|
||||
#include "alwaysunloadplugin.moc"
|
||||
|
||||
#include "moc_alwaysunloadplugin.cpp"
|
||||
21
Telegram/ThirdParty/kcoreaddons/autotests/alwaysunloadplugin.h
vendored
Normal file
21
Telegram/ThirdParty/kcoreaddons/autotests/alwaysunloadplugin.h
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
SPDX-FileCopyrightText: 2014 Alex Merry <alexmerry@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#ifndef ALWAYSUNLOADPLUGIN_H
|
||||
#define ALWAYSUNLOADPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class AlwaysUnloadPlugin : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AlwaysUnloadPlugin(QObject *parent, const QVariantList &args);
|
||||
};
|
||||
|
||||
#endif // ALWAYSUNLOADPLUGIN_H
|
||||
1
Telegram/ThirdParty/kcoreaddons/autotests/config-tests.h.in
vendored
Normal file
1
Telegram/ThirdParty/kcoreaddons/autotests/config-tests.h.in
vendored
Normal file
@@ -0,0 +1 @@
|
||||
#cmakedefine01 ENABLE_BENCHMARKS
|
||||
0
Telegram/ThirdParty/kcoreaddons/autotests/data/appui1rc
vendored
Normal file
0
Telegram/ThirdParty/kcoreaddons/autotests/data/appui1rc
vendored
Normal file
0
Telegram/ThirdParty/kcoreaddons/autotests/data/appuirc
vendored
Normal file
0
Telegram/ThirdParty/kcoreaddons/autotests/data/appuirc
vendored
Normal file
90
Telegram/ThirdParty/kcoreaddons/autotests/data/fakeplugin.desktop
vendored
Normal file
90
Telegram/ThirdParty/kcoreaddons/autotests/data/fakeplugin.desktop
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
[Desktop Entry]
|
||||
Name=NSA Plugin
|
||||
Name[ast]=Complementu NSA
|
||||
Name[bs]=NSA dodatak
|
||||
Name[ca]=Connector de la NSA
|
||||
Name[ca@valencia]=Connector de la NSA
|
||||
Name[cs]=Modul NSA
|
||||
Name[da]=NSA-plugin
|
||||
Name[de]=NSA-Modul
|
||||
Name[el]=NSA Plugin
|
||||
Name[en_GB]=NSA Plugin
|
||||
Name[es]=Complemento NSA
|
||||
Name[fi]=NSA-liitännäinen
|
||||
Name[gd]=Plugan NSA
|
||||
Name[gl]=Complemento de NSA
|
||||
Name[he]=תוסף NSA
|
||||
Name[hu]=NSA bővítmény
|
||||
Name[it]=Estensione NSA
|
||||
Name[ko]=NSA 플러그인
|
||||
Name[nb]=NSA programtillegg
|
||||
Name[nl]=NSA-plug-in
|
||||
Name[nn]=NSA-tillegg
|
||||
Name[pl]=Wtyczka NSA
|
||||
Name[pt]='Plugin' da NSA
|
||||
Name[pt_BR]=Plugin NSA
|
||||
Name[ru]=Модуль ФСБ
|
||||
Name[sk]=NSA plugin
|
||||
Name[sl]=Vstavek NSA
|
||||
Name[sr]=НСА‑ов прикључак
|
||||
Name[sr@ijekavian]=НСА‑ов прикључак
|
||||
Name[sr@ijekavianlatin]=NSA‑ov priključak
|
||||
Name[sr@latin]=NSA‑ov priključak
|
||||
Name[sv]=NSA-insticksprogram
|
||||
Name[tr]=NSA Eklentisi
|
||||
Name[uk]=Додаток NSA
|
||||
Name[x-test]=xxNSA Pluginxx
|
||||
Name[zh_CN]=NSA 插件
|
||||
Name[zh_TW]=NSA 外掛程式
|
||||
Comment=Test Plugin Spy
|
||||
Comment[ast]=Complementu de prueba qu'escluca
|
||||
Comment[bs]=Špijun provjere dodataka
|
||||
Comment[ca]=Connector de proves espia
|
||||
Comment[ca@valencia]=Connector de proves espia
|
||||
Comment[cs]=Testovací modul Spy
|
||||
Comment[da]=Test-plugin spion
|
||||
Comment[de]=Spionage-Testmodul
|
||||
Comment[el]=Test Plugin Spy
|
||||
Comment[en_GB]=Test Plugin Spy
|
||||
Comment[es]=Probar espía de complementos
|
||||
Comment[fi]=Testivakoiluliitännäinen
|
||||
Comment[gd]=Plugan deuchainneach brathadair
|
||||
Comment[gl]=Complemento espía de proba
|
||||
Comment[he]=בדיקת תוסף ריגול
|
||||
Comment[hu]=Kémbővítmény tesztelése
|
||||
Comment[it]=Estensione di prova Spy
|
||||
Comment[ko]=테스트 플러그인 첩자
|
||||
Comment[nb]=Test tilleggsspion
|
||||
Comment[nl]=Plug-in Spy testen
|
||||
Comment[nn]=Spion for test-tillegg
|
||||
Comment[pl]=Wypróbuj szpiega wtyczki
|
||||
Comment[pt]=Espião dos 'Plugins' de Testes
|
||||
Comment[pt_BR]=Plugin de teste de espionagem
|
||||
Comment[ru]=Тестовый прослушивающий модуль
|
||||
Comment[sk]=Testovací plugin špión
|
||||
Comment[sl]=Preizkusni vohunski vstavek
|
||||
Comment[sr]=Пробни прикључак шпијун
|
||||
Comment[sr@ijekavian]=Пробни прикључак шпијун
|
||||
Comment[sr@ijekavianlatin]=Probni priključak špijun
|
||||
Comment[sr@latin]=Probni priključak špijun
|
||||
Comment[sv]=Testa insticksprogramspion
|
||||
Comment[tr]=Test Eklenti Ajanı
|
||||
Comment[uk]=Тестовий додаток
|
||||
Comment[x-test]=xxTest Plugin Spyxx
|
||||
Comment[zh_CN]=Test Plugin Spy
|
||||
Comment[zh_TW]=測試外掛程式
|
||||
Type=Service
|
||||
Icon=preferences-system-time
|
||||
MimeType=image/png;application/pdf;
|
||||
|
||||
X-KDE-ServiceTypes=KService/NSA
|
||||
X-KDE-Library=fakeplugin
|
||||
X-KDE-FormFactors=mediacenter,desktop
|
||||
X-KDE-PluginInfo-Author=Sebastian Kügler
|
||||
X-KDE-PluginInfo-Email=sebas@kde.org
|
||||
X-KDE-PluginInfo-Name=fakeplugin
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=https://kde.org/
|
||||
X-KDE-PluginInfo-Category=Examples
|
||||
X-KDE-PluginInfo-License=LGPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
0
Telegram/ThirdParty/kcoreaddons/autotests/data/foo1rc
vendored
Normal file
0
Telegram/ThirdParty/kcoreaddons/autotests/data/foo1rc
vendored
Normal file
0
Telegram/ThirdParty/kcoreaddons/autotests/data/foorc
vendored
Normal file
0
Telegram/ThirdParty/kcoreaddons/autotests/data/foorc
vendored
Normal file
90
Telegram/ThirdParty/kcoreaddons/autotests/data/hiddenplugin.desktop
vendored
Normal file
90
Telegram/ThirdParty/kcoreaddons/autotests/data/hiddenplugin.desktop
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
[Desktop Entry]
|
||||
Name=NSA Plugin
|
||||
Name[ast]=Complementu NSA
|
||||
Name[bs]=NSA dodatak
|
||||
Name[ca]=Connector de la NSA
|
||||
Name[ca@valencia]=Connector de la NSA
|
||||
Name[cs]=Modul NSA
|
||||
Name[da]=NSA-plugin
|
||||
Name[de]=NSA-Modul
|
||||
Name[el]=NSA Plugin
|
||||
Name[en_GB]=NSA Plugin
|
||||
Name[es]=Complemento NSA
|
||||
Name[fi]=NSA-liitännäinen
|
||||
Name[gd]=Plugan NSA
|
||||
Name[gl]=Complemento de NSA
|
||||
Name[he]=תוסף NSA
|
||||
Name[hu]=NSA bővítmény
|
||||
Name[it]=Estensione NSA
|
||||
Name[ko]=NSA 플러그인
|
||||
Name[nb]=NSA programtillegg
|
||||
Name[nl]=NSA-plug-in
|
||||
Name[nn]=NSA-tillegg
|
||||
Name[pl]=Wtyczka NSA
|
||||
Name[pt]='Plugin' da NSA
|
||||
Name[pt_BR]=Plugin NSA
|
||||
Name[ru]=Модуль ФСБ
|
||||
Name[sk]=NSA plugin
|
||||
Name[sl]=Vstavek NSA
|
||||
Name[sr]=НСА‑ов прикључак
|
||||
Name[sr@ijekavian]=НСА‑ов прикључак
|
||||
Name[sr@ijekavianlatin]=NSA‑ov priključak
|
||||
Name[sr@latin]=NSA‑ov priključak
|
||||
Name[sv]=NSA-insticksprogram
|
||||
Name[tr]=NSA Eklentisi
|
||||
Name[uk]=Додаток NSA
|
||||
Name[x-test]=xxNSA Pluginxx
|
||||
Name[zh_CN]=NSA 插件
|
||||
Name[zh_TW]=NSA 外掛程式
|
||||
Comment=Test Plugin Spy
|
||||
Comment[ast]=Complementu de prueba qu'escluca
|
||||
Comment[bs]=Špijun provjere dodataka
|
||||
Comment[ca]=Connector de proves espia
|
||||
Comment[ca@valencia]=Connector de proves espia
|
||||
Comment[cs]=Testovací modul Spy
|
||||
Comment[da]=Test-plugin spion
|
||||
Comment[de]=Spionage-Testmodul
|
||||
Comment[el]=Test Plugin Spy
|
||||
Comment[en_GB]=Test Plugin Spy
|
||||
Comment[es]=Probar espía de complementos
|
||||
Comment[fi]=Testivakoiluliitännäinen
|
||||
Comment[gd]=Plugan deuchainneach brathadair
|
||||
Comment[gl]=Complemento espía de proba
|
||||
Comment[he]=בדיקת תוסף ריגול
|
||||
Comment[hu]=Kémbővítmény tesztelése
|
||||
Comment[it]=Estensione di prova Spy
|
||||
Comment[ko]=테스트 플러그인 첩자
|
||||
Comment[nb]=Test tilleggsspion
|
||||
Comment[nl]=Plug-in Spy testen
|
||||
Comment[nn]=Spion for test-tillegg
|
||||
Comment[pl]=Wypróbuj szpiega wtyczki
|
||||
Comment[pt]=Espião dos 'Plugins' de Testes
|
||||
Comment[pt_BR]=Plugin de teste de espionagem
|
||||
Comment[ru]=Тестовый прослушивающий модуль
|
||||
Comment[sk]=Testovací plugin špión
|
||||
Comment[sl]=Preizkusni vohunski vstavek
|
||||
Comment[sr]=Пробни прикључак шпијун
|
||||
Comment[sr@ijekavian]=Пробни прикључак шпијун
|
||||
Comment[sr@ijekavianlatin]=Probni priključak špijun
|
||||
Comment[sr@latin]=Probni priključak špijun
|
||||
Comment[sv]=Testa insticksprogramspion
|
||||
Comment[tr]=Test Eklenti Ajanı
|
||||
Comment[uk]=Тестовий додаток
|
||||
Comment[x-test]=xxTest Plugin Spyxx
|
||||
Comment[zh_CN]=Test Plugin Spy
|
||||
Comment[zh_TW]=測試外掛程式
|
||||
Type=Service
|
||||
Icon=preferences-system-time
|
||||
Hidden=true
|
||||
|
||||
X-KDE-ServiceTypes=KService/NSA
|
||||
X-KDE-Library=fakeplugin
|
||||
|
||||
X-KDE-PluginInfo-Author=Sebastian Kügler
|
||||
X-KDE-PluginInfo-Email=sebas@kde.org
|
||||
X-KDE-PluginInfo-Name=fakeplugin
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=https://kde.org/
|
||||
X-KDE-PluginInfo-Category=Examples
|
||||
X-KDE-PluginInfo-License=LGPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
22
Telegram/ThirdParty/kcoreaddons/autotests/data/os-release
vendored
Normal file
22
Telegram/ThirdParty/kcoreaddons/autotests/data/os-release
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
NAME="Name"
|
||||
VERSION="100.5"
|
||||
ID=theid
|
||||
ID_LIKE="otherid otherotherid"
|
||||
VERSION_CODENAME=versioncodename
|
||||
VERSION_ID="500.1"
|
||||
PRETTY_NAME="Pretty Name #1"
|
||||
ANSI_COLOR="1;34"
|
||||
CPE_NAME="cpe:/o:foo:bar:100"
|
||||
HOME_URL="https://url.home"
|
||||
DOCUMENTATION_URL="https://url.docs"
|
||||
SUPPORT_URL="https://url.support"
|
||||
BUG_REPORT_URL="https://url.bugs"
|
||||
PRIVACY_POLICY_URL="https://url.privacy"
|
||||
BUILD_ID="105.5"
|
||||
# comment
|
||||
VARIANT="Test = Edition"
|
||||
BROKENLINE_SHOULD_BE_IGNORED
|
||||
VARIANT_ID=test
|
||||
# indented comment
|
||||
LOGO=start-here-test
|
||||
DEBIAN_BTS="debbugs://bugs.debian.org/"
|
||||
46
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/bad-groups-input.desktop
vendored
Normal file
46
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/bad-groups-input.desktop
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
[Desktop Entry]
|
||||
Name=Bad Groups
|
||||
Name[ca]=Grups dolents
|
||||
Name[ca@valencia]=Grups dolents
|
||||
Name[da]=Dårlige grupper
|
||||
Name[de]=Schlechte Gruppen
|
||||
Name[el]=Κακές ομάδες
|
||||
Name[en_GB]=Bad Groups
|
||||
Name[es]=Grupos incorrectos
|
||||
Name[fi]=Huonot ryhmät
|
||||
Name[gl]=Grupos malos
|
||||
Name[it]=Gruppi errati
|
||||
Name[ko]=불량 그룹
|
||||
Name[nl]=Foute groepen
|
||||
Name[pl]=Złe grupy
|
||||
Name[pt]=Grupos Inválidos
|
||||
Name[pt_BR]=Grupos inválidos
|
||||
Name[sk]=Zlé skupiny
|
||||
Name[sl]=Slabe skupine
|
||||
Name[sr]=Лоше групе
|
||||
Name[sr@ijekavian]=Лоше групе
|
||||
Name[sr@ijekavianlatin]=Loše grupe
|
||||
Name[sr@latin]=Loše grupe
|
||||
Name[sv]=Felaktiga grupper
|
||||
Name[uk]=Погані групи
|
||||
Name[x-test]=xxBad Groupsxx
|
||||
Name[zh_CN]=坏分组
|
||||
Type=Service
|
||||
# one value for every property definition in bad-groups-servicetype.desktop
|
||||
ThisIsOkay=10
|
||||
#empty
|
||||
=11
|
||||
#missing terminator
|
||||
MissingTerminator=12
|
||||
# empty and missing terminator
|
||||
=13
|
||||
# completely empty
|
||||
=14
|
||||
SomeOtherProperty=15
|
||||
# extra spaces in group name (should be okay)
|
||||
TrailingSpacesAreOkay=16
|
||||
#missing type
|
||||
MissingType=17
|
||||
InvalidType=18
|
||||
# ok again after invalid ones
|
||||
ThisIsOkayAgain=19
|
||||
34
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/bad-groups-servicetype.desktop
vendored
Normal file
34
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/bad-groups-servicetype.desktop
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
[Desktop Entry]
|
||||
Type=ServiceType
|
||||
|
||||
[PropertyDef::ThisIsOkay]
|
||||
Type=int
|
||||
# missing name
|
||||
[PropertyDef::]
|
||||
Type=int
|
||||
# missing terminator
|
||||
[PropertyDef::MissingTerminator
|
||||
Type=int
|
||||
# empty and missing terminator
|
||||
[PropertyDef::
|
||||
Type=int
|
||||
# completely empty group
|
||||
[
|
||||
Type=int
|
||||
# completely empty group
|
||||
[DoesNotStartWithPropertyDef::SomeOtherProperty]
|
||||
Type=int
|
||||
# extra spaces
|
||||
[PropertyDef::TrailingSpacesAreOkay ]
|
||||
Type=int
|
||||
|
||||
# missing Type=key
|
||||
[PropertyDef::MissingType]
|
||||
NoType=int
|
||||
|
||||
# invalid Type=key
|
||||
[PropertyDef::InvalidType]
|
||||
Type=integer
|
||||
|
||||
[PropertyDef::ThisIsOkayAgain]
|
||||
Type=int
|
||||
6
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/bool-servicetype.desktop
vendored
Normal file
6
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/bool-servicetype.desktop
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Type=ServiceType
|
||||
|
||||
[PropertyDef::X-Test-Bool]
|
||||
Type=bool
|
||||
|
||||
39
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/example-input.desktop
vendored
Normal file
39
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/example-input.desktop
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
[Desktop Entry]
|
||||
Name=Example
|
||||
Name[ca]=Exemple
|
||||
Name[ca@valencia]=Exemple
|
||||
Name[da]=Eksempel
|
||||
Name[de]=Beispiel
|
||||
Name[el]=Παράδειγμα
|
||||
Name[en_GB]=Example
|
||||
Name[es]=Ejemplo
|
||||
Name[fi]=Esimerkki
|
||||
Name[gl]=Exemplo
|
||||
Name[it]=Esempio
|
||||
Name[ko]=예제
|
||||
Name[nb]=Eksempel
|
||||
Name[nl]=Voorbeeld
|
||||
Name[pl]=Przykład
|
||||
Name[pt]=Exemplo
|
||||
Name[pt_BR]=Exemplo
|
||||
Name[sk]=Príklad
|
||||
Name[sl]=Primer
|
||||
Name[sr]=Пример
|
||||
Name[sr@ijekavian]=Пример
|
||||
Name[sr@ijekavianlatin]=Primer
|
||||
Name[sr@latin]=Primer
|
||||
Name[sv]=Exempel
|
||||
Name[uk]=Приклад
|
||||
Name[x-test]=xxExamplexx
|
||||
Name[zh_CN]=例子
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=example/servicetype,bar/foo
|
||||
X-Test-Integer=42
|
||||
X-Test-Double=42.42
|
||||
X-Test-List=a,b,c,def
|
||||
X-Test-String=foobar
|
||||
X-Test-Bool=true
|
||||
# not defined -> string
|
||||
X-Test-Unknown=true
|
||||
# QSize not supported -> string
|
||||
X-Test-Size=10,20
|
||||
18
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/example-servicetype.desktop
vendored
Normal file
18
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/example-servicetype.desktop
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
[Desktop Entry]
|
||||
Type=ServiceType
|
||||
X-KDE-ServiceType=example/servicetype
|
||||
|
||||
[PropertyDef::X-Test-Integer]
|
||||
Type=int
|
||||
[PropertyDef::X-Test-Double]
|
||||
Type=double
|
||||
[PropertyDef::X-Test-Bool]
|
||||
Type=bool
|
||||
[PropertyDef::X-Test-List]
|
||||
Type=QStringList
|
||||
[PropertyDef::X-Test-String]
|
||||
Type=QString
|
||||
# this is not supported -> should not convert
|
||||
# was used by KDE4 plasma-applet.desktop but that is no longer the case
|
||||
[PropertyDef::X-Test-Size]
|
||||
Type=QSize
|
||||
9
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/fake-kdedmodule.desktop
vendored
Normal file
9
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/fake-kdedmodule.desktop
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Type=ServiceType
|
||||
X-KDE-ServiceType=KDEDModule
|
||||
[PropertyDef::X-KDE-FactoryName]
|
||||
Type=QString
|
||||
[PropertyDef::X-KDE-Kded-autoload]
|
||||
Type=bool
|
||||
[PropertyDef::X-KDE-Kded-load-on-demand]
|
||||
Type=bool
|
||||
70
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/fake-kdevelopplugin.desktop
vendored
Normal file
70
Telegram/ThirdParty/kcoreaddons/autotests/data/servicetypes/fake-kdevelopplugin.desktop
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
# this is a copy of kdevelopplugin.desktop as an example of a real service type definition
|
||||
|
||||
[Desktop Entry]
|
||||
Type=ServiceType
|
||||
X-KDE-ServiceType=KDevelop/NonExistentPlugin
|
||||
X-KDE-Derived=KPluginInfo
|
||||
#Name=KDevelop Plugin
|
||||
|
||||
# mandatory, versioning - prevent DLL hell
|
||||
[PropertyDef::X-KDevelop-Version]
|
||||
Type=int
|
||||
|
||||
# optional, determines whether a plugin is loaded only after
|
||||
# a project is opened, or is a global plugin.
|
||||
# If it is not set, the plugin can only be loaded by the
|
||||
# user or via requesting one of its dependencies
|
||||
# allowed values: Global, Project
|
||||
[PropertyDef::X-KDevelop-Category]
|
||||
Type=QString
|
||||
|
||||
# mandatory, GUI-Operation Mode, determines whether a plugin
|
||||
# can work without having a mainwindow/partcontroller
|
||||
# running
|
||||
# allowed values: GUI, NoGUI
|
||||
[PropertyDef::X-KDevelop-Mode]
|
||||
Type=QString
|
||||
|
||||
# optional, Arguments to pass to the plugin
|
||||
[PropertyDef::X-KDevelop-Args]
|
||||
Type=QString
|
||||
|
||||
# optional, Interfaces that a plugin implements
|
||||
# usually values start with org.kdevelop
|
||||
[PropertyDef::X-KDevelop-Interfaces]
|
||||
Type=QStringList
|
||||
|
||||
# optional, interfaces that this plugin depends
|
||||
# on
|
||||
[PropertyDef::X-KDevelop-IRequired]
|
||||
Type=QStringList
|
||||
|
||||
# optional, interfaces that this plugin can use,
|
||||
# but the plugin still works if the interfaces are
|
||||
# not available.
|
||||
[PropertyDef::X-KDevelop-IOptional]
|
||||
Type=QStringList
|
||||
|
||||
# optional, mimetypes supported by a language plugin
|
||||
[PropertyDef::X-KDevelop-SupportedMimeTypes]
|
||||
Type=QStringList
|
||||
|
||||
# optional, language supported by a language plugin
|
||||
[PropertyDef::X-KDevelop-Language]
|
||||
Type=QString
|
||||
|
||||
# optional, defines whether the plugin can be disabled
|
||||
# by the user. Possible values are "AlwaysOn" and "UserSelectable".
|
||||
# If the property is missing then UserSelectable is assumed
|
||||
[PropertyDef::X-KDevelop-LoadMode]
|
||||
Type=QString
|
||||
|
||||
# optional, list of filters for "projectfiles" for the project plugin
|
||||
# For example: Makefile,Makefile.* for Makefile's
|
||||
[PropertyDef::X-KDevelop-ProjectFilesFilter]
|
||||
Type=QStringList
|
||||
|
||||
# optional, description for the projectfiles filter
|
||||
[PropertyDef::X-KDevelop-ProjectFilesFilterDescription]
|
||||
Type=QString
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
# Type must be ServiceType otherwise this file is invalid
|
||||
Type=Service
|
||||
|
||||
# as this file is invalid check that this property is not converted
|
||||
[PropertyDef::ShouldNotBeConvertedToInt]
|
||||
Type=int
|
||||
21
Telegram/ThirdParty/kcoreaddons/autotests/data/testmetadata.json
vendored
Normal file
21
Telegram/ThirdParty/kcoreaddons/autotests/data/testmetadata.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"KPlugin": {
|
||||
"Authors": [
|
||||
{
|
||||
"Name": "Aleix Pol"
|
||||
}
|
||||
],
|
||||
"Description": "Test stuff.",
|
||||
"Icon": "kdevelop",
|
||||
"License": "GPL",
|
||||
"Name": "Test"
|
||||
},
|
||||
"X-Plasma-MainScript": "ui/main.qml",
|
||||
"X-Purpose-PluginTypes": [ "Export" ],
|
||||
"SomeInt" : 42,
|
||||
"SomeIntAsString" : "42",
|
||||
"SomeStringNotAInt" : "not-a-string",
|
||||
"SomeBool" : true,
|
||||
"SomeBoolAsString" : "true",
|
||||
"SomeBoolThatIsFalse": false
|
||||
}
|
||||
19
Telegram/ThirdParty/kcoreaddons/autotests/data/twostepsparsetest.desktop
vendored
Normal file
19
Telegram/ThirdParty/kcoreaddons/autotests/data/twostepsparsetest.desktop
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
[Desktop Entry]
|
||||
Name=Parse Test
|
||||
Comment=Two Steps Parsing Test
|
||||
Type=Service
|
||||
Icon=preferences-system-time
|
||||
MimeType=image/png;application/pdf;
|
||||
|
||||
X-Test-List=first,second
|
||||
X-KDE-ServiceTypes=example/servicetype
|
||||
X-KDE-Library=fakeplugin
|
||||
X-KDE-FormFactors=mediacenter,desktop
|
||||
X-KDE-PluginInfo-Author=Sebastian Kügler
|
||||
X-KDE-PluginInfo-Email=sebas@kde.org
|
||||
X-KDE-PluginInfo-Name=fakeplugin
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=https://kde.org/
|
||||
X-KDE-PluginInfo-Category=Examples
|
||||
X-KDE-PluginInfo-License=LGPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
357
Telegram/ThirdParty/kcoreaddons/autotests/desktoptojsontest.cpp
vendored
Normal file
357
Telegram/ThirdParty/kcoreaddons/autotests/desktoptojsontest.cpp
vendored
Normal file
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2014 Alex Richardson <arichardson.kde@gmail.com>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kcoreaddons_debug.h"
|
||||
#include <QDebug>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTest>
|
||||
#include <kcoreaddons_export.h>
|
||||
|
||||
namespace QTest
|
||||
{
|
||||
template<>
|
||||
inline char *toString(const QJsonValue &val)
|
||||
{
|
||||
// simply reuse the QDebug representation
|
||||
QString result;
|
||||
QDebug(&result) << val;
|
||||
return QTest::toString(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DesktopToJsonTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
void compareJson(const QJsonObject &actual, const QJsonObject &expected)
|
||||
{
|
||||
for (auto it = actual.constBegin(); it != actual.constEnd(); ++it) {
|
||||
if (expected.constFind(it.key()) == expected.constEnd()) {
|
||||
qCritical() << "Result has key" << it.key() << "which is not expected!";
|
||||
QFAIL("Invalid output");
|
||||
}
|
||||
if (it.value().isObject() && expected.value(it.key()).isObject()) {
|
||||
compareJson(it.value().toObject(), expected.value(it.key()).toObject());
|
||||
} else {
|
||||
QCOMPARE(it.value(), expected.value(it.key()));
|
||||
}
|
||||
}
|
||||
for (auto it = expected.constBegin(); it != expected.constEnd(); ++it) {
|
||||
if (actual.constFind(it.key()) == actual.constEnd()) {
|
||||
qCritical() << "Result is missing key" << it.key();
|
||||
QFAIL("Invalid output");
|
||||
}
|
||||
if (it.value().isObject() && actual.value(it.key()).isObject()) {
|
||||
compareJson(it.value().toObject(), actual.value(it.key()).toObject());
|
||||
} else {
|
||||
QCOMPARE(it.value(), actual.value(it.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void testDesktopToJson_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("input");
|
||||
QTest::addColumn<QJsonObject>("expectedResult");
|
||||
QTest::addColumn<bool>("compatibilityMode");
|
||||
QTest::addColumn<QStringList>("serviceTypes");
|
||||
|
||||
QJsonObject expectedResult;
|
||||
QJsonObject kpluginObj;
|
||||
QByteArray input =
|
||||
// include an insignificant group
|
||||
"[Some Group]\n"
|
||||
"Foo=Bar\n"
|
||||
"\n"
|
||||
"[Desktop Entry]\n"
|
||||
// only data inside [Desktop Entry] should be included
|
||||
"Name=Example\n"
|
||||
// empty lines
|
||||
"\n"
|
||||
" \n"
|
||||
// make sure translations are included:
|
||||
"Name[de_DE]=Beispiel\n"
|
||||
// ignore comments:
|
||||
"#Comment=Comment\n"
|
||||
" #Comment=Comment\n"
|
||||
"Categories=foo;bar;a\\;b\n"
|
||||
// As the case is significant, the keys Name and NAME are not equivalent:
|
||||
"CaseSensitive=ABC\n"
|
||||
"CASESENSITIVE=abc\n"
|
||||
// Space before and after the equals sign should be ignored:
|
||||
"SpacesBeforeEq =foo\n"
|
||||
"SpacesAfterEq= foo\n"
|
||||
// Space before and after the equals sign should be ignored; the = sign is the actual delimiter.
|
||||
// TODO: error in spec (spaces before and after the key??)
|
||||
" SpacesBeforeKey=foo\n"
|
||||
"SpacesAfterKey =foo\n"
|
||||
// ignore trailing spaces
|
||||
"TrailingSpaces=foo \n"
|
||||
// However spaces in the value are significant:
|
||||
"SpacesInValue=Hello, World!\n"
|
||||
// The escape sequences \s, \n, \t, \r, and \\ are supported for values of
|
||||
// type string and localestring, meaning ASCII space, newline, tab,
|
||||
// carriage return, and backslash, respectively:
|
||||
"EscapeSequences=So\\sme esc\\nap\\te se\\\\qu\\re\\\\nces\n" // make sure that the last n is a literal n not a newline!
|
||||
// the standard keys that are used by plugins, make sure correct types are used:
|
||||
"X-KDE-PluginInfo-Category=Examples\n" // string key
|
||||
"X-KDE-PluginInfo-Version=1.0\n"
|
||||
// The multiple values should be separated by a semicolon and the value of the key
|
||||
// may be optionally terminated by a semicolon. Trailing empty strings must always
|
||||
// be terminated with a semicolon. Semicolons in these values need to be escaped using \;.
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 79)
|
||||
"X-KDE-PluginInfo-Depends=foo,bar,esc\\,aped\n" // string list key
|
||||
#endif
|
||||
"X-KDE-ServiceTypes=\n" // empty string list
|
||||
"X-KDE-PluginInfo-EnabledByDefault=true\n" // bool key
|
||||
// now start a new group
|
||||
"[New Group]\n"
|
||||
"InWrongGroup=true\n";
|
||||
|
||||
expectedResult[QStringLiteral("Categories")] = QStringLiteral("foo;bar;a\\;b");
|
||||
expectedResult[QStringLiteral("CaseSensitive")] = QStringLiteral("ABC");
|
||||
expectedResult[QStringLiteral("CASESENSITIVE")] = QStringLiteral("abc");
|
||||
expectedResult[QStringLiteral("SpacesBeforeEq")] = QStringLiteral("foo");
|
||||
expectedResult[QStringLiteral("SpacesAfterEq")] = QStringLiteral("foo");
|
||||
expectedResult[QStringLiteral("SpacesBeforeKey")] = QStringLiteral("foo");
|
||||
expectedResult[QStringLiteral("SpacesAfterKey")] = QStringLiteral("foo");
|
||||
expectedResult[QStringLiteral("TrailingSpaces")] = QStringLiteral("foo");
|
||||
expectedResult[QStringLiteral("SpacesInValue")] = QStringLiteral("Hello, World!");
|
||||
expectedResult[QStringLiteral("EscapeSequences")] = QStringLiteral("So me esc\nap\te se\\qu\re\\nces");
|
||||
kpluginObj[QStringLiteral("Name")] = QStringLiteral("Example");
|
||||
kpluginObj[QStringLiteral("Name[de_DE]")] = QStringLiteral("Beispiel");
|
||||
kpluginObj[QStringLiteral("Category")] = QStringLiteral("Examples");
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 79)
|
||||
kpluginObj[QStringLiteral("Dependencies")] =
|
||||
QJsonArray::fromStringList(QStringList() << QStringLiteral("foo") << QStringLiteral("bar") << QStringLiteral("esc,aped"));
|
||||
#endif
|
||||
kpluginObj[QStringLiteral("ServiceTypes")] = QJsonArray::fromStringList(QStringList());
|
||||
kpluginObj[QStringLiteral("EnabledByDefault")] = true;
|
||||
kpluginObj[QStringLiteral("Version")] = QStringLiteral("1.0");
|
||||
QJsonObject compatResult = expectedResult;
|
||||
compatResult[QStringLiteral("Name")] = QStringLiteral("Example");
|
||||
compatResult[QStringLiteral("Name[de_DE]")] = QStringLiteral("Beispiel");
|
||||
compatResult[QStringLiteral("X-KDE-PluginInfo-Category")] = QStringLiteral("Examples");
|
||||
compatResult[QStringLiteral("X-KDE-PluginInfo-Version")] = QStringLiteral("1.0");
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 79)
|
||||
compatResult[QStringLiteral("X-KDE-PluginInfo-Depends")] =
|
||||
QJsonArray::fromStringList(QStringList() << QStringLiteral("foo") << QStringLiteral("bar") << QStringLiteral("esc,aped"));
|
||||
#endif
|
||||
compatResult[QStringLiteral("X-KDE-ServiceTypes")] = QJsonArray::fromStringList(QStringList());
|
||||
compatResult[QStringLiteral("X-KDE-PluginInfo-EnabledByDefault")] = true;
|
||||
|
||||
expectedResult[QStringLiteral("KPlugin")] = kpluginObj;
|
||||
|
||||
QTest::newRow("newFormat") << input << expectedResult << false << QStringList();
|
||||
QTest::newRow("compatFormat") << input << compatResult << true << QStringList();
|
||||
|
||||
// test conversion of a currently existing .desktop file (excluding most of the translations):
|
||||
QByteArray kdevInput =
|
||||
"[Desktop Entry]\n"
|
||||
"Type = Service\n"
|
||||
"Icon=text-x-c++src\n"
|
||||
"Exec=blubb\n"
|
||||
"Comment=C/C++ Language Support\n"
|
||||
"Comment[fr]=Prise en charge du langage C/C++\n"
|
||||
"Comment[it]=Supporto al linguaggio C/C++\n"
|
||||
"Name=C++ Support\n"
|
||||
"Name[fi]=C++-tuki\n"
|
||||
"Name[fr]=Prise en charge du C++\n"
|
||||
"GenericName=Language Support\n"
|
||||
"GenericName[sl]=Podpora jeziku\n"
|
||||
"ServiceTypes=KDevelop/NonExistentPlugin\n"
|
||||
"X-KDE-Library=kdevcpplanguagesupport\n"
|
||||
"X-KDE-PluginInfo-Name=kdevcppsupport\n"
|
||||
"X-KDE-PluginInfo-Category=Language Support\n"
|
||||
"X-KDevelop-Version=1\n"
|
||||
"X-KDevelop-Language=C++\n"
|
||||
"X-KDevelop-Args=CPP\n"
|
||||
"X-KDevelop-Interfaces=ILanguageSupport\n"
|
||||
"X-KDevelop-SupportedMimeTypes=text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\n"
|
||||
"X-KDevelop-Mode=NoGUI\n"
|
||||
"X-KDevelop-LoadMode=AlwaysOn";
|
||||
|
||||
QJsonParseError e;
|
||||
QJsonObject kdevExpected = QJsonDocument::fromJson(
|
||||
"{\n"
|
||||
" \"GenericName\": \"Language Support\",\n"
|
||||
" \"GenericName[sl]\": \"Podpora jeziku\",\n"
|
||||
" \"KPlugin\": {\n"
|
||||
" \"Category\": \"Language Support\",\n"
|
||||
" \"Description\": \"C/C++ Language Support\",\n"
|
||||
" \"Description[fr]\": \"Prise en charge du langage C/C++\",\n"
|
||||
" \"Description[it]\": \"Supporto al linguaggio C/C++\",\n"
|
||||
" \"Icon\": \"text-x-c++src\",\n"
|
||||
" \"Id\": \"kdevcppsupport\",\n"
|
||||
" \"Name\": \"C++ Support\",\n"
|
||||
" \"Name[fi]\": \"C++-tuki\",\n"
|
||||
" \"Name[fr]\": \"Prise en charge du C++\",\n"
|
||||
" \"ServiceTypes\": [ \"KDevelop/NonExistentPlugin\" ]\n"
|
||||
" },\n"
|
||||
" \"X-KDevelop-Args\": \"CPP\",\n"
|
||||
" \"X-KDevelop-Interfaces\": \"ILanguageSupport\",\n"
|
||||
" \"X-KDevelop-Language\": \"C++\",\n"
|
||||
" \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n"
|
||||
" \"X-KDevelop-Mode\": \"NoGUI\",\n"
|
||||
" \"X-KDevelop-SupportedMimeTypes\": \"text/x-chdr,text/x-c++hdr,text/x-csrc,text/x-c++src\",\n"
|
||||
" \"X-KDevelop-Version\": \"1\"\n"
|
||||
"}\n",
|
||||
&e)
|
||||
.object();
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
QTest::newRow("kdevcpplanguagesupport no servicetype") << kdevInput << kdevExpected << false << QStringList();
|
||||
|
||||
QJsonObject kdevExpectedWithServiceType =
|
||||
QJsonDocument::fromJson(
|
||||
"{\n"
|
||||
" \"GenericName\": \"Language Support\",\n"
|
||||
" \"GenericName[sl]\": \"Podpora jeziku\",\n"
|
||||
" \"KPlugin\": {\n"
|
||||
" \"Category\": \"Language Support\",\n"
|
||||
" \"Description\": \"C/C++ Language Support\",\n"
|
||||
" \"Description[fr]\": \"Prise en charge du langage C/C++\",\n"
|
||||
" \"Description[it]\": \"Supporto al linguaggio C/C++\",\n"
|
||||
" \"Icon\": \"text-x-c++src\",\n"
|
||||
" \"Id\": \"kdevcppsupport\",\n"
|
||||
" \"Name\": \"C++ Support\",\n"
|
||||
" \"Name[fi]\": \"C++-tuki\",\n"
|
||||
" \"Name[fr]\": \"Prise en charge du C++\",\n"
|
||||
" \"ServiceTypes\": [ \"KDevelop/NonExistentPlugin\" ]\n"
|
||||
" },\n"
|
||||
" \"X-KDevelop-Args\": \"CPP\",\n"
|
||||
" \"X-KDevelop-Interfaces\": [\"ILanguageSupport\"],\n"
|
||||
" \"X-KDevelop-Language\": \"C++\",\n"
|
||||
" \"X-KDevelop-LoadMode\": \"AlwaysOn\",\n"
|
||||
" \"X-KDevelop-Mode\": \"NoGUI\",\n"
|
||||
" \"X-KDevelop-SupportedMimeTypes\": [\"text/x-chdr\", \"text/x-c++hdr\", \"text/x-csrc\", \"text/x-c++src\"],\n"
|
||||
" \"X-KDevelop-Version\": 1\n"
|
||||
"}\n",
|
||||
&e)
|
||||
.object();
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
const QString kdevServiceTypePath = QFINDTESTDATA("data/servicetypes/fake-kdevelopplugin.desktop");
|
||||
QVERIFY(!kdevServiceTypePath.isEmpty());
|
||||
QTest::newRow("kdevcpplanguagesupport with servicetype") << kdevInput << kdevExpectedWithServiceType << false << QStringList(kdevServiceTypePath);
|
||||
// test conversion of the X-KDE-PluginInfo-Author + X-KDE-PluginInfo-Email key:
|
||||
QByteArray authorInput =
|
||||
"[Desktop Entry]\n"
|
||||
"Type=Service\n"
|
||||
"X-KDE-PluginInfo-Author=Foo Bar\n"
|
||||
"X-KDE-PluginInfo-Email=foo.bar@baz.com\n";
|
||||
|
||||
QJsonObject authorsExpected = QJsonDocument::fromJson(
|
||||
"{\n"
|
||||
" \"KPlugin\": {\n"
|
||||
" \"Authors\": [ { \"Name\": \"Foo Bar\", \"Email\": \"foo.bar@baz.com\" } ]\n"
|
||||
" }\n }\n",
|
||||
&e)
|
||||
.object();
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
QTest::newRow("authors") << authorInput << authorsExpected << false << QStringList();
|
||||
|
||||
// test case-insensitive conversion of boolean keys
|
||||
const QString boolServiceType = QFINDTESTDATA("data/servicetypes/bool-servicetype.desktop");
|
||||
QVERIFY(!boolServiceType.isEmpty());
|
||||
|
||||
QByteArray boolInput1 = "[Desktop Entry]\nType=Service\nX-Test-Bool=true\n";
|
||||
QByteArray boolInput2 = "[Desktop Entry]\nType=Service\nX-Test-Bool=TRue\n";
|
||||
QByteArray boolInput3 = "[Desktop Entry]\nType=Service\nX-Test-Bool=false\n";
|
||||
QByteArray boolInput4 = "[Desktop Entry]\nType=Service\nX-Test-Bool=FALse\n";
|
||||
|
||||
auto boolResultTrue = QJsonDocument::fromJson("{\"KPlugin\":{},\"X-Test-Bool\": true}", &e).object();
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
auto boolResultFalse = QJsonDocument::fromJson("{\"KPlugin\":{},\"X-Test-Bool\": false}", &e).object();
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
QTest::newRow("bool true") << boolInput1 << boolResultTrue << false << QStringList(boolServiceType);
|
||||
QTest::newRow("bool TRue") << boolInput2 << boolResultTrue << false << QStringList(boolServiceType);
|
||||
QTest::newRow("bool false") << boolInput3 << boolResultFalse << false << QStringList(boolServiceType);
|
||||
QTest::newRow("bool FALse") << boolInput4 << boolResultFalse << false << QStringList(boolServiceType);
|
||||
|
||||
// test conversion of kcookiejar.desktop (for some reason the wrong boolean values were committed)
|
||||
QByteArray kcookiejarInput =
|
||||
"[Desktop Entry]\n"
|
||||
"Type= Service\n"
|
||||
"Name=Cookie Jar\n"
|
||||
"Comment=Stores network cookies\n"
|
||||
"X-KDE-ServiceTypes=KDEDModule\n"
|
||||
"X-KDE-Library=kf5/kded/kcookiejar\n"
|
||||
"X-KDE-Kded-autoload=false\n"
|
||||
"X-KDE-Kded-load-on-demand=true\n";
|
||||
auto kcookiejarResult = QJsonDocument::fromJson(
|
||||
"{\n"
|
||||
" \"KPlugin\": {\n"
|
||||
" \"Description\": \"Stores network cookies\",\n"
|
||||
" \"Name\": \"Cookie Jar\",\n"
|
||||
" \"ServiceTypes\": [\n"
|
||||
" \"KDEDModule\"\n"
|
||||
" ]\n"
|
||||
" },\n"
|
||||
"\"X-KDE-Kded-autoload\": false,\n"
|
||||
"\"X-KDE-Kded-load-on-demand\": true\n"
|
||||
"}\n",
|
||||
&e)
|
||||
.object();
|
||||
const QString kdedmoduleServiceType = QFINDTESTDATA("data/servicetypes/fake-kdedmodule.desktop");
|
||||
QVERIFY(!kdedmoduleServiceType.isEmpty());
|
||||
QTest::newRow("kcookiejar") << kcookiejarInput << kcookiejarResult << false << QStringList(kdedmoduleServiceType);
|
||||
}
|
||||
|
||||
void testDesktopToJson()
|
||||
{
|
||||
QTemporaryFile output;
|
||||
QTemporaryFile inputFile;
|
||||
QVERIFY(inputFile.open());
|
||||
QVERIFY(output.open()); // create the file
|
||||
QFETCH(QByteArray, input);
|
||||
QFETCH(QJsonObject, expectedResult);
|
||||
QFETCH(bool, compatibilityMode);
|
||||
QFETCH(QStringList, serviceTypes);
|
||||
output.close();
|
||||
inputFile.write(input);
|
||||
inputFile.flush();
|
||||
inputFile.close();
|
||||
|
||||
QProcess proc;
|
||||
proc.setProgram(QStringLiteral(DESKTOP_TO_JSON_EXE));
|
||||
QStringList arguments = QStringList() << QStringLiteral("-i") << inputFile.fileName() << QStringLiteral("-o") << output.fileName();
|
||||
if (compatibilityMode) {
|
||||
arguments << QStringLiteral("-c");
|
||||
}
|
||||
for (const QString &s : std::as_const(serviceTypes)) {
|
||||
arguments << QStringLiteral("-s") << s;
|
||||
}
|
||||
proc.setArguments(arguments);
|
||||
proc.start();
|
||||
QVERIFY(proc.waitForFinished(10000));
|
||||
QByteArray errorOut = proc.readAllStandardError();
|
||||
if (!errorOut.isEmpty()) {
|
||||
qCWarning(KCOREADDONS_DEBUG).nospace() << "desktoptojson STDERR:\n\n" << errorOut.constData() << "\n";
|
||||
}
|
||||
QCOMPARE(proc.exitCode(), 0);
|
||||
QVERIFY(output.open());
|
||||
QByteArray jsonString = output.readAll();
|
||||
QJsonParseError e;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(jsonString, &e);
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
QJsonObject result = doc.object();
|
||||
compareJson(result, expectedResult);
|
||||
QVERIFY(!QTest::currentTestFailed());
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(DesktopToJsonTest)
|
||||
|
||||
#include "desktoptojsontest.moc"
|
||||
20
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin.cpp
vendored
Normal file
20
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin.cpp
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#include "jsonplugin.h"
|
||||
#include <kpluginfactory.h>
|
||||
|
||||
JsonPlugin::JsonPlugin(QObject *parent, const QVariantList &args)
|
||||
: QObject(parent)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
}
|
||||
|
||||
K_PLUGIN_FACTORY_WITH_JSON(jsonpluginfa, "jsonplugin.json", registerPlugin<JsonPlugin>();)
|
||||
|
||||
#include "jsonplugin.moc"
|
||||
|
||||
#include "moc_jsonplugin.cpp"
|
||||
20
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin.h
vendored
Normal file
20
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#ifndef JSONPLUGIN_H
|
||||
#define JSONPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class JsonPlugin : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JsonPlugin(QObject *parent, const QVariantList &args);
|
||||
};
|
||||
|
||||
#endif // JSONPLUGIN_H
|
||||
12
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin.json
vendored
Normal file
12
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"KPlugin": {
|
||||
"Description": "This is a plugin",
|
||||
"Description[nl]": "Dit is een plug-in",
|
||||
"Description[pt]": "Isto é um 'plugin'",
|
||||
"Description[pt_BR]": "Isto é um plugin",
|
||||
"Description[sv]": "Det här är ett insticksprogram",
|
||||
"Description[uk]": "Це додаток",
|
||||
"Description[x-test]": "xxThis is a pluginxx",
|
||||
"MimeTypes": [ "text/plain", "image/png" ]
|
||||
}
|
||||
}
|
||||
20
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin2.cpp
vendored
Normal file
20
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin2.cpp
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#include "jsonplugin2.h"
|
||||
#include <kpluginfactory.h>
|
||||
|
||||
JsonPlugin2::JsonPlugin2(QObject *parent, const QVariantList &args)
|
||||
: QObject(parent)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
}
|
||||
|
||||
K_PLUGIN_FACTORY_WITH_JSON(jsonplugin2, "jsonplugin2.json", registerPlugin<JsonPlugin2>();)
|
||||
|
||||
#include "jsonplugin2.moc"
|
||||
|
||||
#include "moc_jsonplugin2.cpp"
|
||||
20
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin2.h
vendored
Normal file
20
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin2.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#ifndef JSONPLUGIN2_H
|
||||
#define JSONPLUGIN2_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class JsonPlugin2 : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JsonPlugin2(QObject *parent, const QVariantList &args);
|
||||
};
|
||||
|
||||
#endif // JSONPLUGIN_H
|
||||
13
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin2.json
vendored
Normal file
13
Telegram/ThirdParty/kcoreaddons/autotests/jsonplugin2.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"KPlugin": {
|
||||
"Description": "This is another plugin",
|
||||
"Description[nl]": "Dit is een andere plug-in",
|
||||
"Description[pt]": "Este é outro 'plugin'",
|
||||
"Description[pt_BR]": "Isto é outro plugin",
|
||||
"Description[sv]": "Det här är ännu ett insticksprogram",
|
||||
"Description[uk]": "Це інший додаток",
|
||||
"Description[x-test]": "xxThis is another pluginxx",
|
||||
"Id": "foobar",
|
||||
"MimeTypes": [ "text/html" ]
|
||||
}
|
||||
}
|
||||
106
Telegram/ThirdParty/kcoreaddons/autotests/kaboutdataapplicationdatatest.cpp
vendored
Normal file
106
Telegram/ThirdParty/kcoreaddons/autotests/kaboutdataapplicationdatatest.cpp
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2016 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
// test object
|
||||
#include <kaboutdata.h>
|
||||
// Qt
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
|
||||
// Separate test for reading & setting applicationData
|
||||
// to ensure a separate process where no other test case has
|
||||
// directly or indirectly called KAboutData::setApplicationData before
|
||||
// and thus created the global KAboutData object
|
||||
class KAboutDataApplicationDataTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void testInteractionWithQApplicationData();
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
|
||||
void testRegisterPluginData();
|
||||
#endif
|
||||
};
|
||||
|
||||
static const char AppName[] = "app";
|
||||
static const char ProgramName[] = "ProgramName";
|
||||
static const char Version[] = "Version";
|
||||
static const char OrganizationDomain[] = "no.where";
|
||||
static const char DesktopFileName[] = "org.kde.someapp";
|
||||
|
||||
static const char AppName2[] = "otherapp";
|
||||
static const char ProgramName2[] = "OtherProgramName";
|
||||
static const char Version2[] = "OtherVersion";
|
||||
static const char OrganizationDomain2[] = "other.no.where";
|
||||
static const char DesktopFileName2[] = "org.kde.otherapp";
|
||||
|
||||
void KAboutDataApplicationDataTest::testInteractionWithQApplicationData()
|
||||
{
|
||||
// init the app metadata the Qt way
|
||||
QCoreApplication *app = QCoreApplication::instance();
|
||||
app->setApplicationName(QLatin1String(AppName));
|
||||
app->setProperty("applicationDisplayName", QLatin1String(ProgramName));
|
||||
app->setApplicationVersion(QLatin1String(Version));
|
||||
app->setOrganizationDomain(QLatin1String(OrganizationDomain));
|
||||
app->setProperty("desktopFileName", QLatin1String(DesktopFileName));
|
||||
|
||||
// without setting before, get KAboutData::applicationData
|
||||
const KAboutData applicationAboutData = KAboutData::applicationData();
|
||||
|
||||
// should be initialized with Q*Application metadata
|
||||
QCOMPARE(applicationAboutData.componentName(), QLatin1String(AppName));
|
||||
QCOMPARE(applicationAboutData.displayName(), QLatin1String(ProgramName));
|
||||
QCOMPARE(applicationAboutData.organizationDomain(), QLatin1String(OrganizationDomain));
|
||||
QCOMPARE(applicationAboutData.version(), QLatin1String(Version));
|
||||
QCOMPARE(applicationAboutData.desktopFileName(), QLatin1String(DesktopFileName));
|
||||
|
||||
// now set some new KAboutData, with different values
|
||||
KAboutData aboutData2(QString::fromLatin1(AppName2), QString::fromLatin1(ProgramName2), QString::fromLatin1(Version2));
|
||||
aboutData2.setOrganizationDomain(OrganizationDomain2);
|
||||
aboutData2.setDesktopFileName(QLatin1String(DesktopFileName2));
|
||||
|
||||
KAboutData::setApplicationData(aboutData2);
|
||||
|
||||
// check that Q*Application metadata has been updated, as expected per API definition
|
||||
QCOMPARE(app->applicationName(), QLatin1String(AppName2));
|
||||
QCOMPARE(app->property("applicationDisplayName").toString(), QLatin1String(ProgramName2));
|
||||
QCOMPARE(app->organizationDomain(), QLatin1String(OrganizationDomain2));
|
||||
QCOMPARE(app->applicationVersion(), QLatin1String(Version2));
|
||||
QCOMPARE(app->property("desktopFileName").toString(), QLatin1String(DesktopFileName2));
|
||||
|
||||
// and check as well KAboutData::applicationData itself
|
||||
const KAboutData applicationAboutData2 = KAboutData::applicationData();
|
||||
|
||||
QCOMPARE(applicationAboutData2.componentName(), QLatin1String(AppName2));
|
||||
QCOMPARE(applicationAboutData2.displayName(), QLatin1String(ProgramName2));
|
||||
QCOMPARE(applicationAboutData2.organizationDomain(), QLatin1String(OrganizationDomain2));
|
||||
QCOMPARE(applicationAboutData2.version(), QLatin1String(Version2));
|
||||
QCOMPARE(applicationAboutData2.desktopFileName(), QLatin1String(DesktopFileName2));
|
||||
}
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 76)
|
||||
void KAboutDataApplicationDataTest::testRegisterPluginData()
|
||||
{
|
||||
for (const auto &name : {QStringLiteral("foo"), QStringLiteral("bar")}) {
|
||||
QVERIFY(!KAboutData::pluginData(name));
|
||||
KAboutData::registerPluginData(KAboutData(name));
|
||||
|
||||
auto v1 = KAboutData::pluginData(name);
|
||||
QVERIFY(v1);
|
||||
QCOMPARE(v1->componentName(), name);
|
||||
|
||||
// re-registering will overwrite and not trigger memory leaks (check LSAN)
|
||||
KAboutData::registerPluginData(KAboutData(name));
|
||||
|
||||
// the pointer staid the same, as QHash is node based
|
||||
QCOMPARE(KAboutData::pluginData(name), v1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QTEST_MAIN(KAboutDataApplicationDataTest)
|
||||
|
||||
#include "kaboutdataapplicationdatatest.moc"
|
||||
445
Telegram/ThirdParty/kcoreaddons/autotests/kaboutdatatest.cpp
vendored
Normal file
445
Telegram/ThirdParty/kcoreaddons/autotests/kaboutdatatest.cpp
vendored
Normal file
@@ -0,0 +1,445 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
SPDX-FileCopyrightText: 2017 Harald Sitter <sitter@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
// test object
|
||||
#include <kaboutdata.h>
|
||||
// Qt
|
||||
#include <QFile>
|
||||
#include <QLatin1String>
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
#include <QTextStream>
|
||||
#ifndef Q_OS_WIN
|
||||
void initLocale()
|
||||
{
|
||||
qputenv("LC_ALL", "en_US.utf-8");
|
||||
}
|
||||
|
||||
Q_CONSTRUCTOR_FUNCTION(initLocale)
|
||||
#endif
|
||||
|
||||
class KAboutDataTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void testLongFormConstructorWithDefaults();
|
||||
void testLongFormConstructor();
|
||||
void testShortFormConstructor();
|
||||
void testSetAddLicense();
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
|
||||
void testSetProgramIconName();
|
||||
#endif
|
||||
void testSetDesktopFileName();
|
||||
void testCopying();
|
||||
|
||||
void testKAboutDataOrganizationDomain();
|
||||
|
||||
void testLicenseSPDXID();
|
||||
void testLicenseOrLater();
|
||||
|
||||
void testProductName();
|
||||
};
|
||||
|
||||
static const char AppName[] = "app";
|
||||
static const char ProgramName[] = "ProgramName";
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
|
||||
static const char ProgramIconName[] = "program-icon";
|
||||
#endif
|
||||
static const char Version[] = "Version";
|
||||
static const char ShortDescription[] = "ShortDescription";
|
||||
static const char CopyrightStatement[] = "CopyrightStatement";
|
||||
static const char Text[] = "Text";
|
||||
static const char HomePageAddress[] = "http://test.no.where/";
|
||||
static const char HomePageSecure[] = "https://test.no.where/";
|
||||
static const char OrganizationDomain[] = "no.where";
|
||||
static const char BugsEmailAddress[] = "bugs@no.else";
|
||||
static const char LicenseText[] = "free to write, reading forbidden";
|
||||
static const char LicenseFileName[] = "testlicensefile";
|
||||
static const char LicenseFileText[] = "free to write, reading forbidden, in the file";
|
||||
|
||||
void KAboutDataTest::testLongFormConstructorWithDefaults()
|
||||
{
|
||||
KAboutData aboutData(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::Unknown);
|
||||
|
||||
QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName));
|
||||
QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName));
|
||||
QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName));
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
|
||||
QCOMPARE(aboutData.programIconName(), QString::fromLatin1(AppName));
|
||||
#endif
|
||||
QCOMPARE(aboutData.programLogo(), QVariant());
|
||||
QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1("kde.org"));
|
||||
QCOMPARE(aboutData.version(), QString::fromLatin1(Version));
|
||||
QCOMPARE(aboutData.homepage(), QString());
|
||||
QCOMPARE(aboutData.bugAddress(), QString::fromLatin1("submit@bugs.kde.org"));
|
||||
QVERIFY(aboutData.authors().isEmpty());
|
||||
QVERIFY(aboutData.credits().isEmpty());
|
||||
QVERIFY(aboutData.translators().isEmpty());
|
||||
QCOMPARE(aboutData.otherText(), QString());
|
||||
QCOMPARE(aboutData.licenses().count(), 1);
|
||||
// We don't know the default text, do we?
|
||||
// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty());
|
||||
// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty());
|
||||
// QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
|
||||
QCOMPARE(aboutData.copyrightStatement(), QString());
|
||||
QCOMPARE(aboutData.shortDescription(), (QLatin1String(ShortDescription)));
|
||||
QCOMPARE(aboutData.customAuthorPlainText(), QString());
|
||||
QCOMPARE(aboutData.customAuthorRichText(), QString());
|
||||
QVERIFY(!aboutData.customAuthorTextEnabled());
|
||||
QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app"));
|
||||
|
||||
QCOMPARE(aboutData.internalVersion(), Version);
|
||||
QCOMPARE(aboutData.internalProgramName(), ProgramName);
|
||||
QCOMPARE(aboutData.internalBugAddress(), "submit@bugs.kde.org");
|
||||
QCOMPARE(aboutData.internalProductName(), nullptr);
|
||||
}
|
||||
|
||||
void KAboutDataTest::testLongFormConstructor()
|
||||
{
|
||||
KAboutData aboutData(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::Unknown,
|
||||
QLatin1String(CopyrightStatement),
|
||||
QLatin1String(Text),
|
||||
QString::fromLatin1(HomePageAddress),
|
||||
QString::fromLatin1(BugsEmailAddress));
|
||||
|
||||
QCOMPARE(aboutData.componentName(), QLatin1String(AppName));
|
||||
QCOMPARE(aboutData.productName(), QLatin1String(AppName));
|
||||
QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName));
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
|
||||
QCOMPARE(aboutData.programIconName(), QLatin1String(AppName));
|
||||
#endif
|
||||
QCOMPARE(aboutData.programLogo(), QVariant());
|
||||
QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1(OrganizationDomain));
|
||||
QCOMPARE(aboutData.version(), QString::fromLatin1(Version));
|
||||
QCOMPARE(aboutData.homepage(), QString::fromLatin1(HomePageAddress));
|
||||
QCOMPARE(aboutData.bugAddress(), QString::fromLatin1(BugsEmailAddress));
|
||||
QVERIFY(aboutData.authors().isEmpty());
|
||||
QVERIFY(aboutData.credits().isEmpty());
|
||||
QVERIFY(aboutData.translators().isEmpty());
|
||||
QCOMPARE(aboutData.otherText(), QLatin1String(Text));
|
||||
QCOMPARE(aboutData.licenses().count(), 1);
|
||||
// We don't know the default text, do we?
|
||||
// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty());
|
||||
// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty());
|
||||
// QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
|
||||
QCOMPARE(aboutData.copyrightStatement(), QLatin1String(CopyrightStatement));
|
||||
QCOMPARE(aboutData.shortDescription(), QLatin1String(ShortDescription));
|
||||
QCOMPARE(aboutData.customAuthorPlainText(), QString());
|
||||
QCOMPARE(aboutData.customAuthorRichText(), QString());
|
||||
QVERIFY(!aboutData.customAuthorTextEnabled());
|
||||
QCOMPARE(aboutData.desktopFileName(), QStringLiteral("where.no.app"));
|
||||
|
||||
QCOMPARE(aboutData.internalVersion(), Version);
|
||||
QCOMPARE(aboutData.internalProgramName(), ProgramName);
|
||||
QCOMPARE(aboutData.internalBugAddress(), BugsEmailAddress);
|
||||
QCOMPARE(aboutData.internalProductName(), nullptr);
|
||||
|
||||
// We support http and https protocols on the homepage address, ensure they
|
||||
// give the same org. domain and desktop file name.
|
||||
KAboutData aboutDataSecure(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::Unknown,
|
||||
QLatin1String(CopyrightStatement),
|
||||
QLatin1String(Text),
|
||||
QString::fromLatin1(HomePageSecure),
|
||||
QString::fromLatin1(BugsEmailAddress));
|
||||
QCOMPARE(aboutDataSecure.componentName(), QLatin1String(AppName));
|
||||
QCOMPARE(aboutDataSecure.productName(), QLatin1String(AppName));
|
||||
QCOMPARE(aboutDataSecure.organizationDomain(), QString::fromLatin1(OrganizationDomain));
|
||||
QCOMPARE(aboutDataSecure.desktopFileName(), QStringLiteral("where.no.app"));
|
||||
}
|
||||
|
||||
void KAboutDataTest::testShortFormConstructor()
|
||||
{
|
||||
KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version));
|
||||
|
||||
QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName));
|
||||
QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName));
|
||||
QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName));
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
|
||||
QCOMPARE(aboutData.programIconName(), QString::fromLatin1(AppName));
|
||||
#endif
|
||||
QCOMPARE(aboutData.programLogo(), QVariant());
|
||||
QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1("kde.org"));
|
||||
QCOMPARE(aboutData.version(), QString::fromLatin1(Version));
|
||||
QCOMPARE(aboutData.homepage(), QString());
|
||||
QCOMPARE(aboutData.bugAddress(), QString::fromLatin1("submit@bugs.kde.org"));
|
||||
QVERIFY(aboutData.authors().isEmpty());
|
||||
QVERIFY(aboutData.credits().isEmpty());
|
||||
QVERIFY(aboutData.translators().isEmpty());
|
||||
QCOMPARE(aboutData.otherText(), QString());
|
||||
QCOMPARE(aboutData.licenses().count(), 1);
|
||||
// We don't know the default text, do we?
|
||||
// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty());
|
||||
// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty());
|
||||
// QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
|
||||
QCOMPARE(aboutData.copyrightStatement(), QString());
|
||||
QCOMPARE(aboutData.shortDescription(), QString());
|
||||
QCOMPARE(aboutData.customAuthorPlainText(), QString());
|
||||
QCOMPARE(aboutData.customAuthorRichText(), QString());
|
||||
QVERIFY(!aboutData.customAuthorTextEnabled());
|
||||
QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app"));
|
||||
|
||||
QCOMPARE(aboutData.internalVersion(), Version);
|
||||
QCOMPARE(aboutData.internalProgramName(), ProgramName);
|
||||
QCOMPARE(aboutData.internalBugAddress(), "submit@bugs.kde.org");
|
||||
QCOMPARE(aboutData.internalProductName(), nullptr);
|
||||
}
|
||||
|
||||
void KAboutDataTest::testKAboutDataOrganizationDomain()
|
||||
{
|
||||
KAboutData data(QString::fromLatin1("app"),
|
||||
QLatin1String("program"),
|
||||
QString::fromLatin1("version"),
|
||||
QLatin1String("description"),
|
||||
KAboutLicense::LGPL,
|
||||
QLatin1String("copyright"),
|
||||
QLatin1String("hello world"),
|
||||
QStringLiteral("http://www.koffice.org"));
|
||||
QCOMPARE(data.organizationDomain(), QString::fromLatin1("koffice.org"));
|
||||
QCOMPARE(data.desktopFileName(), QStringLiteral("org.koffice.app"));
|
||||
|
||||
KAboutData data2(QString::fromLatin1("app"),
|
||||
QLatin1String("program"),
|
||||
QString::fromLatin1("version"),
|
||||
QLatin1String("description"),
|
||||
KAboutLicense::LGPL,
|
||||
QString::fromLatin1("copyright"),
|
||||
QLatin1String("hello world"),
|
||||
QStringLiteral("app"));
|
||||
QCOMPARE(data2.organizationDomain(), QString::fromLatin1("kde.org"));
|
||||
QCOMPARE(data2.desktopFileName(), QStringLiteral("org.kde.app"));
|
||||
}
|
||||
|
||||
void KAboutDataTest::testSetAddLicense()
|
||||
{
|
||||
// prepare a file with a license text
|
||||
QFile licenseFile(QString::fromLatin1(LicenseFileName));
|
||||
licenseFile.open(QIODevice::WriteOnly);
|
||||
QTextStream licenseFileStream(&licenseFile);
|
||||
licenseFileStream << LicenseFileText;
|
||||
licenseFile.close();
|
||||
|
||||
const QString copyrightStatement = QLatin1String(CopyrightStatement);
|
||||
const QString lineFeed = QString::fromLatin1("\n\n");
|
||||
|
||||
KAboutData aboutData(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::Unknown,
|
||||
QLatin1String(CopyrightStatement),
|
||||
QLatin1String(Text),
|
||||
QString::fromLatin1(HomePageAddress),
|
||||
QString::fromLatin1(BugsEmailAddress));
|
||||
|
||||
// set to GPL2
|
||||
aboutData.setLicense(KAboutLicense::GPL_V2);
|
||||
|
||||
QCOMPARE(aboutData.licenses().count(), 1);
|
||||
QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v2"));
|
||||
QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 2"));
|
||||
// QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL2Text) );
|
||||
QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
|
||||
|
||||
// set to Unknown again
|
||||
aboutData.setLicense(KAboutLicense::Unknown);
|
||||
|
||||
QCOMPARE(aboutData.licenses().count(), 1);
|
||||
// We don't know the default text, do we?
|
||||
// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty());
|
||||
// QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty());
|
||||
// QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) );
|
||||
QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
|
||||
|
||||
// add GPL3
|
||||
aboutData.addLicense(KAboutLicense::GPL_V3);
|
||||
|
||||
QCOMPARE(aboutData.licenses().count(), 1);
|
||||
QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v3"));
|
||||
QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 3"));
|
||||
// QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL3Text) );
|
||||
QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
|
||||
|
||||
// add GPL2, Custom and File
|
||||
aboutData.addLicense(KAboutLicense::GPL_V2);
|
||||
aboutData.addLicenseText(QLatin1String(LicenseText));
|
||||
aboutData.addLicenseTextFile(QLatin1String(LicenseFileName));
|
||||
|
||||
QCOMPARE(aboutData.licenses().count(), 4);
|
||||
QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v3"));
|
||||
QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 3"));
|
||||
// QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL3Text) );
|
||||
QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
|
||||
QCOMPARE(aboutData.licenses().at(1).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v2"));
|
||||
QCOMPARE(aboutData.licenses().at(1).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 2"));
|
||||
// QCOMPARE( aboutData.licenses().at(1).text(), QString(GPL2Text) );
|
||||
QVERIFY(!aboutData.licenses().at(1).text().isEmpty());
|
||||
QCOMPARE(aboutData.licenses().at(2).name(KAboutLicense::ShortName), QString::fromLatin1("Custom"));
|
||||
QCOMPARE(aboutData.licenses().at(2).name(KAboutLicense::FullName), QString::fromLatin1("Custom"));
|
||||
QCOMPARE(aboutData.licenses().at(2).text(), QLatin1String(LicenseText));
|
||||
QCOMPARE(aboutData.licenses().at(3).name(KAboutLicense::ShortName), QString::fromLatin1("Custom"));
|
||||
QCOMPARE(aboutData.licenses().at(3).name(KAboutLicense::FullName), QString::fromLatin1("Custom"));
|
||||
QCOMPARE(aboutData.licenses().at(3).text(), QString(copyrightStatement + lineFeed + QLatin1String(LicenseFileText)));
|
||||
}
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
|
||||
void KAboutDataTest::testSetProgramIconName()
|
||||
{
|
||||
const QString programIconName(QString::fromLatin1(ProgramIconName));
|
||||
|
||||
KAboutData aboutData(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::Unknown,
|
||||
QLatin1String(CopyrightStatement),
|
||||
QLatin1String(Text),
|
||||
QString::fromLatin1(HomePageAddress),
|
||||
QString::fromLatin1(BugsEmailAddress));
|
||||
|
||||
// Deprecated, still want to test this though. Silence GCC warnings.
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
// set different iconname
|
||||
aboutData.setProgramIconName(programIconName);
|
||||
#pragma GCC diagnostic pop
|
||||
QCOMPARE(aboutData.programIconName(), programIconName);
|
||||
}
|
||||
#endif
|
||||
|
||||
void KAboutDataTest::testCopying()
|
||||
{
|
||||
KAboutData aboutData(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::GPL_V2);
|
||||
|
||||
{
|
||||
KAboutData aboutData2(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::GPL_V3);
|
||||
aboutData2.addLicense(KAboutLicense::GPL_V2, KAboutLicense::OrLaterVersions);
|
||||
aboutData = aboutData2;
|
||||
}
|
||||
QList<KAboutLicense> licenses = aboutData.licenses();
|
||||
QCOMPARE(licenses.count(), 2);
|
||||
QCOMPARE(licenses.at(0).key(), KAboutLicense::GPL_V3);
|
||||
QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-3.0"));
|
||||
// check it doesn't crash
|
||||
QVERIFY(!licenses.at(0).text().isEmpty());
|
||||
QCOMPARE(licenses.at(1).key(), KAboutLicense::GPL_V2);
|
||||
QCOMPARE(aboutData.licenses().at(1).spdx(), QStringLiteral("GPL-2.0+"));
|
||||
// check it doesn't crash
|
||||
QVERIFY(!licenses.at(1).text().isEmpty());
|
||||
}
|
||||
|
||||
void KAboutDataTest::testSetDesktopFileName()
|
||||
{
|
||||
KAboutData aboutData(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::Unknown);
|
||||
QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app"));
|
||||
|
||||
// set different desktopFileName
|
||||
aboutData.setDesktopFileName(QStringLiteral("foo.bar.application"));
|
||||
QCOMPARE(aboutData.desktopFileName(), QStringLiteral("foo.bar.application"));
|
||||
}
|
||||
|
||||
void KAboutDataTest::testLicenseSPDXID()
|
||||
{
|
||||
// Input with + should output with +.
|
||||
auto license = KAboutLicense::byKeyword(QStringLiteral("GPLv2+"));
|
||||
QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0+"));
|
||||
// Input without should output without.
|
||||
license = KAboutLicense::byKeyword(QStringLiteral("GPLv2"));
|
||||
QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0"));
|
||||
// Input of spdx with or-later should also work
|
||||
license = KAboutLicense::byKeyword(QStringLiteral("GPL-2.0-or-later"));
|
||||
QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0+")); // TODO: should not return the deprecatd version
|
||||
|
||||
// we should be able to match by spdx too
|
||||
// create a KAboutLicense from enum, then make sure going to spdx and back gives the same enum
|
||||
for (int i = 1; i <= KAboutLicense::LGPL_V2_1; ++i) { /*current highest enum value*/
|
||||
KAboutData aboutData(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::GPL_V2);
|
||||
aboutData.setLicense(KAboutLicense::LicenseKey(i));
|
||||
QVERIFY(aboutData.licenses().count() == 1);
|
||||
const auto license = aboutData.licenses().constFirst();
|
||||
auto licenseFromKeyword = KAboutLicense::byKeyword(license.spdx());
|
||||
|
||||
QCOMPARE(license.key(), licenseFromKeyword.key());
|
||||
}
|
||||
}
|
||||
|
||||
void KAboutDataTest::testLicenseOrLater()
|
||||
{
|
||||
// For kaboutdata we can replace the license with an orLater version. Or add a second one.
|
||||
KAboutData aboutData(QString::fromLatin1(AppName),
|
||||
QLatin1String(ProgramName),
|
||||
QString::fromLatin1(Version),
|
||||
QLatin1String(ShortDescription),
|
||||
KAboutLicense::GPL_V2);
|
||||
QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-2.0"));
|
||||
aboutData.setLicense(KAboutLicense::GPL_V2, KAboutLicense::OrLaterVersions);
|
||||
QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-2.0+"));
|
||||
aboutData.addLicense(KAboutLicense::LGPL_V3, KAboutLicense::OrLaterVersions);
|
||||
bool foundLGPL = false;
|
||||
const QList<KAboutLicense> licenses = aboutData.licenses();
|
||||
for (const auto &license : licenses) {
|
||||
if (license.key() == KAboutLicense::LGPL_V3) {
|
||||
QCOMPARE(license.spdx(), QStringLiteral("LGPL-3.0+"));
|
||||
foundLGPL = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
QCOMPARE(foundLGPL, true);
|
||||
}
|
||||
|
||||
void KAboutDataTest::testProductName()
|
||||
{
|
||||
KAboutData aboutData(QString::fromLatin1(AppName), QString::fromLatin1(ProgramName));
|
||||
QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName));
|
||||
QCOMPARE(aboutData.internalProductName(), nullptr);
|
||||
aboutData.setProductName("frameworks-kcoreaddons/aboutdata");
|
||||
QCOMPARE(aboutData.productName(), QString::fromLatin1("frameworks-kcoreaddons/aboutdata"));
|
||||
QCOMPARE(aboutData.internalProductName(), "frameworks-kcoreaddons/aboutdata");
|
||||
}
|
||||
|
||||
QTEST_MAIN(KAboutDataTest)
|
||||
|
||||
#include "kaboutdatatest.moc"
|
||||
158
Telegram/ThirdParty/kcoreaddons/autotests/kautosavefiletest.cpp
vendored
Normal file
158
Telegram/ThirdParty/kcoreaddons/autotests/kautosavefiletest.cpp
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2006 Jacob R Rideout <kde@jacobrideout.net>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kautosavefiletest.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QtAlgorithms>
|
||||
|
||||
#include <QTemporaryFile>
|
||||
#include <kautosavefile.h>
|
||||
|
||||
#include <QTest>
|
||||
|
||||
QTEST_MAIN(KAutoSaveFileTest)
|
||||
|
||||
void KAutoSaveFileTest::initTestCase()
|
||||
{
|
||||
QCoreApplication::instance()->setApplicationName(QLatin1String("qttest")); // TODO do this in qtestlib itself
|
||||
}
|
||||
|
||||
void KAutoSaveFileTest::cleanupTestCase()
|
||||
{
|
||||
for (const QString &fileToRemove : std::as_const(filesToRemove)) {
|
||||
QFile::remove(fileToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
void KAutoSaveFileTest::test_readWrite()
|
||||
{
|
||||
QTemporaryFile file;
|
||||
|
||||
QVERIFY(file.open());
|
||||
|
||||
QUrl normalFile = QUrl::fromLocalFile(QFileInfo(file).absoluteFilePath());
|
||||
|
||||
// Test basic functionality
|
||||
KAutoSaveFile saveFile(normalFile);
|
||||
|
||||
QVERIFY(!QFile::exists(saveFile.fileName()));
|
||||
QVERIFY(saveFile.open(QIODevice::ReadWrite));
|
||||
|
||||
QString inText = QString::fromLatin1("This is test data one.\n");
|
||||
|
||||
{
|
||||
QTextStream ts(&saveFile);
|
||||
ts << inText;
|
||||
ts.flush();
|
||||
}
|
||||
|
||||
saveFile.close();
|
||||
|
||||
{
|
||||
QFile testReader(saveFile.fileName());
|
||||
testReader.open(QIODevice::ReadWrite);
|
||||
QTextStream ts(&testReader);
|
||||
|
||||
QString outText = ts.readAll();
|
||||
|
||||
QCOMPARE(outText, inText);
|
||||
}
|
||||
|
||||
filesToRemove << file.fileName();
|
||||
}
|
||||
|
||||
void KAutoSaveFileTest::test_fileNameMaxLength()
|
||||
{
|
||||
// In KAutoSaveFilePrivate::tempFile() the name of the kautosavefile that's going to be created
|
||||
// is concatanated in the form:
|
||||
// fileName + junk.truncated + protocol + _ + path.truncated + junk
|
||||
// see tempFile() for details.
|
||||
//
|
||||
// Make sure that the generated filename (e.g. as you would get from QUrl::fileName()) doesn't
|
||||
// exceed NAME_MAX (the maximum length allowed for filenames, see e.g. /usr/include/linux/limits.h)
|
||||
// otherwise the file can't be opened.
|
||||
//
|
||||
// see https://phabricator.kde.org/D24489
|
||||
|
||||
QString s;
|
||||
s.fill(QLatin1Char('b'), 80);
|
||||
// create a long path that:
|
||||
// - exceeds NAME_MAX (255)
|
||||
// - is less than the maximum allowed path length, PATH_MAX (4096)
|
||||
// see e.g. /usr/include/linux/limits.h
|
||||
const QString path = QDir::tempPath() + QLatin1Char('/') + s + QLatin1Char('/') + s + QLatin1Char('/') + s + QLatin1Char('/') + s;
|
||||
|
||||
QFile file(path + QLatin1Char('/') + QLatin1String("testFile.txt"));
|
||||
|
||||
QUrl normalFile = QUrl::fromLocalFile(file.fileName());
|
||||
|
||||
KAutoSaveFile saveFile(normalFile);
|
||||
|
||||
QVERIFY(!QFile::exists(saveFile.fileName()));
|
||||
QVERIFY(saveFile.open(QIODevice::ReadWrite));
|
||||
|
||||
filesToRemove << file.fileName();
|
||||
}
|
||||
|
||||
void KAutoSaveFileTest::test_fileStaleFiles()
|
||||
{
|
||||
QUrl normalFile = QUrl::fromLocalFile(QDir::temp().absoluteFilePath(QStringLiteral("test directory/tîst me.txt")));
|
||||
|
||||
KAutoSaveFile saveFile(normalFile);
|
||||
QVERIFY(saveFile.open(QIODevice::ReadWrite));
|
||||
saveFile.write("testdata");
|
||||
|
||||
// Make sure the stale file is found
|
||||
|
||||
const auto listOfStaleFiles = saveFile.staleFiles(normalFile, QStringLiteral("qttest"));
|
||||
QVERIFY(listOfStaleFiles.count() == 1);
|
||||
saveFile.releaseLock();
|
||||
qDeleteAll(listOfStaleFiles);
|
||||
|
||||
// Make sure the stale file is deleted
|
||||
|
||||
QVERIFY(saveFile.staleFiles(normalFile, QStringLiteral("qttest")).isEmpty());
|
||||
}
|
||||
|
||||
void KAutoSaveFileTest::test_applicationStaleFiles()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void KAutoSaveFileTest::test_locking()
|
||||
{
|
||||
QUrl normalFile(QString::fromLatin1("fish://user@example.com/home/remote/test.txt"));
|
||||
|
||||
KAutoSaveFile saveFile(normalFile);
|
||||
|
||||
QVERIFY(!QFile::exists(saveFile.fileName()));
|
||||
QVERIFY(saveFile.open(QIODevice::ReadWrite));
|
||||
|
||||
const QList<KAutoSaveFile *> staleFiles(KAutoSaveFile::staleFiles(normalFile));
|
||||
|
||||
QVERIFY(!staleFiles.isEmpty());
|
||||
|
||||
KAutoSaveFile *saveFile2 = staleFiles.at(0);
|
||||
|
||||
const QString fn = saveFile2->fileName();
|
||||
// It looks like $XDG_DATA_HOME/stalefiles/qttest/test.txtXXXfish_%2Fhome%2FremoteXXXXXXX
|
||||
QVERIFY2(fn.contains(QLatin1String("stalefiles/qttest/test.txt")), qPrintable(fn));
|
||||
QVERIFY2(fn.contains(QLatin1String("fish_%2Fhome%2Fremote")), qPrintable(fn));
|
||||
|
||||
QVERIFY(QFile::exists(saveFile2->fileName()));
|
||||
QVERIFY(!saveFile2->open(QIODevice::ReadWrite));
|
||||
|
||||
saveFile.releaseLock();
|
||||
|
||||
QVERIFY(saveFile2->open(QIODevice::ReadWrite));
|
||||
|
||||
qDeleteAll(staleFiles);
|
||||
}
|
||||
|
||||
#include "moc_kautosavefiletest.cpp"
|
||||
31
Telegram/ThirdParty/kcoreaddons/autotests/kautosavefiletest.h
vendored
Normal file
31
Telegram/ThirdParty/kcoreaddons/autotests/kautosavefiletest.h
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2006 Jacob R Rideout <kde@jacobrideout.net>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef kautosavefiletest_h
|
||||
#define kautosavefiletest_h
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
class KAutoSaveFileTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void test_readWrite();
|
||||
void test_fileNameMaxLength();
|
||||
void test_fileStaleFiles();
|
||||
void test_applicationStaleFiles();
|
||||
void test_locking();
|
||||
void cleanupTestCase();
|
||||
|
||||
private:
|
||||
QStringList filesToRemove;
|
||||
};
|
||||
|
||||
#endif
|
||||
98
Telegram/ThirdParty/kcoreaddons/autotests/kcompositejobtest.cpp
vendored
Normal file
98
Telegram/ThirdParty/kcoreaddons/autotests/kcompositejobtest.cpp
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2013 Kevin Funk <kevin@kfunk.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "kcompositejobtest.h"
|
||||
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
#include <QTimer>
|
||||
|
||||
TestJob::TestJob(QObject *parent)
|
||||
: KJob(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void TestJob::start()
|
||||
{
|
||||
QTimer::singleShot(1000, this, &TestJob::doEmit);
|
||||
}
|
||||
|
||||
void TestJob::doEmit()
|
||||
{
|
||||
emitResult();
|
||||
}
|
||||
|
||||
void CompositeJob::start()
|
||||
{
|
||||
if (hasSubjobs()) {
|
||||
subjobs().first()->start();
|
||||
} else {
|
||||
emitResult();
|
||||
}
|
||||
}
|
||||
|
||||
bool CompositeJob::addSubjob(KJob *job)
|
||||
{
|
||||
return KCompositeJob::addSubjob(job);
|
||||
}
|
||||
|
||||
void CompositeJob::slotResult(KJob *job)
|
||||
{
|
||||
KCompositeJob::slotResult(job);
|
||||
|
||||
if (!error() && hasSubjobs()) {
|
||||
// start next
|
||||
subjobs().first()->start();
|
||||
} else {
|
||||
setError(job->error());
|
||||
setErrorText(job->errorText());
|
||||
emitResult();
|
||||
}
|
||||
}
|
||||
|
||||
KCompositeJobTest::KCompositeJobTest()
|
||||
: loop(this)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* In case a composite job is deleted during execution
|
||||
* we still want to assure that we don't crash
|
||||
*
|
||||
* see bug: https://bugs.kde.org/show_bug.cgi?id=230692
|
||||
*/
|
||||
void KCompositeJobTest::testDeletionDuringExecution()
|
||||
{
|
||||
QObject *someParent = new QObject;
|
||||
KJob *job = new TestJob(someParent);
|
||||
|
||||
CompositeJob *compositeJob = new CompositeJob;
|
||||
compositeJob->setAutoDelete(false);
|
||||
QVERIFY(compositeJob->addSubjob(job));
|
||||
|
||||
QCOMPARE(job->parent(), compositeJob);
|
||||
|
||||
QSignalSpy destroyed_spy(job, &QObject::destroyed);
|
||||
// check if job got reparented properly
|
||||
delete someParent;
|
||||
someParent = nullptr;
|
||||
// the job should still exist, because it is a child of KCompositeJob now
|
||||
QCOMPARE(destroyed_spy.size(), 0);
|
||||
|
||||
// start async, the subjob takes 1 second to finish
|
||||
compositeJob->start();
|
||||
|
||||
// delete the job during the execution
|
||||
delete compositeJob;
|
||||
compositeJob = nullptr;
|
||||
// at this point, the subjob should be deleted, too
|
||||
QCOMPARE(destroyed_spy.size(), 1);
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(KCompositeJobTest)
|
||||
|
||||
#include "moc_kcompositejobtest.cpp"
|
||||
61
Telegram/ThirdParty/kcoreaddons/autotests/kcompositejobtest.h
vendored
Normal file
61
Telegram/ThirdParty/kcoreaddons/autotests/kcompositejobtest.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2013 Kevin Funk <kevin@kfunk.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#ifndef KCOMPOSITEJOBTEST_H
|
||||
#define KCOMPOSITEJOBTEST_H
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QObject>
|
||||
|
||||
#include "kcompositejob.h"
|
||||
|
||||
class TestJob : public KJob
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TestJob(QObject *parent = nullptr);
|
||||
|
||||
/// Takes 1 second to finish
|
||||
void start() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void doEmit();
|
||||
};
|
||||
|
||||
class CompositeJob : public KCompositeJob
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CompositeJob(QObject *parent = nullptr)
|
||||
: KCompositeJob(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void start() override;
|
||||
bool addSubjob(KJob *job) override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void slotResult(KJob *job) override;
|
||||
};
|
||||
|
||||
class KCompositeJobTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KCompositeJobTest();
|
||||
|
||||
private Q_SLOTS:
|
||||
void testDeletionDuringExecution();
|
||||
|
||||
private:
|
||||
QEventLoop loop;
|
||||
};
|
||||
|
||||
#endif // KCOMPOSITEJOBTEST_H
|
||||
127
Telegram/ThirdParty/kcoreaddons/autotests/kdelibs4configmigratortest.cpp
vendored
Normal file
127
Telegram/ThirdParty/kcoreaddons/autotests/kdelibs4configmigratortest.cpp
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2014 Montel Laurent <montel@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
// test object
|
||||
#include "kdelibs4configmigrator.h"
|
||||
// Qt
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTest>
|
||||
|
||||
class Kdelibs4ConfigMigratorTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void shouldNotMigrateIfKde4HomeDirDoesntExist();
|
||||
void shouldMigrateIfKde4HomeDirExist();
|
||||
void shouldMigrateConfigFiles();
|
||||
void shouldMigrateUiFiles();
|
||||
};
|
||||
|
||||
void Kdelibs4ConfigMigratorTest::initTestCase()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
const QString configHome = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
|
||||
QDir(configHome).removeRecursively();
|
||||
const QString dataHome = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
QDir(dataHome).removeRecursively();
|
||||
}
|
||||
|
||||
void Kdelibs4ConfigMigratorTest::shouldNotMigrateIfKde4HomeDirDoesntExist()
|
||||
{
|
||||
qputenv("KDEHOME", "");
|
||||
Kdelibs4ConfigMigrator migration(QLatin1String("foo"));
|
||||
QCOMPARE(migration.migrate(), false);
|
||||
}
|
||||
|
||||
void Kdelibs4ConfigMigratorTest::shouldMigrateIfKde4HomeDirExist()
|
||||
{
|
||||
QTemporaryDir kdehomeDir;
|
||||
QVERIFY(kdehomeDir.isValid());
|
||||
const QString kdehome = kdehomeDir.path();
|
||||
qputenv("KDEHOME", QFile::encodeName(kdehome));
|
||||
Kdelibs4ConfigMigrator migration(QLatin1String("foo"));
|
||||
QCOMPARE(migration.migrate(), true);
|
||||
}
|
||||
|
||||
void Kdelibs4ConfigMigratorTest::shouldMigrateConfigFiles()
|
||||
{
|
||||
QTemporaryDir kdehomeDir;
|
||||
const QString kdehome = kdehomeDir.path();
|
||||
qputenv("KDEHOME", QFile::encodeName(kdehome));
|
||||
|
||||
// Generate kde4 config dir
|
||||
const QString configPath = kdehome + QLatin1Char('/') + QLatin1String("share/config/");
|
||||
QDir().mkpath(configPath);
|
||||
QVERIFY(QDir(configPath).exists());
|
||||
|
||||
const QStringList listConfig = {QLatin1String("foorc"), QLatin1String("foo1rc")};
|
||||
for (const QString &config : listConfig) {
|
||||
QFile fooConfigFile(QLatin1String(KDELIBS4CONFIGMIGRATOR_DATA_DIR) + QLatin1Char('/') + config);
|
||||
QVERIFY(fooConfigFile.exists());
|
||||
const QString storedConfigFilePath = configPath + QLatin1Char('/') + config;
|
||||
QVERIFY(QFile::copy(fooConfigFile.fileName(), storedConfigFilePath));
|
||||
QCOMPARE(QStandardPaths::locate(QStandardPaths::GenericConfigLocation, config), QString());
|
||||
}
|
||||
|
||||
Kdelibs4ConfigMigrator migration(QLatin1String("foo"));
|
||||
migration.setConfigFiles(listConfig);
|
||||
QVERIFY(migration.migrate());
|
||||
|
||||
for (const QString &config : listConfig) {
|
||||
const QString migratedConfigFile = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, config);
|
||||
QVERIFY(!migratedConfigFile.isEmpty());
|
||||
QVERIFY(QFile(migratedConfigFile).exists());
|
||||
QFile::remove(migratedConfigFile);
|
||||
}
|
||||
}
|
||||
|
||||
void Kdelibs4ConfigMigratorTest::shouldMigrateUiFiles()
|
||||
{
|
||||
QTemporaryDir kdehomeDir;
|
||||
const QString kdehome = kdehomeDir.path();
|
||||
qputenv("KDEHOME", QFile::encodeName(kdehome));
|
||||
|
||||
const QString appName = QLatin1String("foo");
|
||||
|
||||
// Generate kde4 data dir
|
||||
const QString dataPath = kdehome + QLatin1Char('/') + QLatin1String("share/apps/");
|
||||
QDir().mkpath(dataPath);
|
||||
QVERIFY(QDir(dataPath).exists());
|
||||
|
||||
const QString xdgDatahome = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
|
||||
QStringList listUi;
|
||||
listUi << QLatin1String("appuirc") << QLatin1String("appui1rc");
|
||||
for (const QString &uifile : std::as_const(listUi)) {
|
||||
QFile fooConfigFile(QLatin1String(KDELIBS4CONFIGMIGRATOR_DATA_DIR) + QLatin1Char('/') + uifile);
|
||||
QVERIFY(fooConfigFile.exists());
|
||||
QDir().mkpath(dataPath + QLatin1Char('/') + appName);
|
||||
const QString storedConfigFilePath = dataPath + QLatin1Char('/') + appName + QLatin1Char('/') + uifile;
|
||||
QVERIFY(QFile::copy(fooConfigFile.fileName(), storedConfigFilePath));
|
||||
|
||||
const QString xdgUiFile = xdgDatahome + QLatin1String("/kxmlgui5/") + appName + QLatin1Char('/') + uifile;
|
||||
QVERIFY(!QFile::exists(xdgUiFile));
|
||||
}
|
||||
|
||||
Kdelibs4ConfigMigrator migration(appName);
|
||||
migration.setUiFiles(QStringList() << listUi);
|
||||
QVERIFY(migration.migrate());
|
||||
|
||||
for (const QString &uifile : std::as_const(listUi)) {
|
||||
const QString xdgUiFile = xdgDatahome + QLatin1String("/kxmlgui5/") + appName + QLatin1Char('/') + uifile;
|
||||
QVERIFY(QFile(xdgUiFile).exists());
|
||||
QFile::remove(xdgUiFile);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(Kdelibs4ConfigMigratorTest)
|
||||
|
||||
#include "kdelibs4configmigratortest.moc"
|
||||
45
Telegram/ThirdParty/kcoreaddons/autotests/kdelibs4migrationtest.cpp
vendored
Normal file
45
Telegram/ThirdParty/kcoreaddons/autotests/kdelibs4migrationtest.cpp
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2014 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
// test object
|
||||
#include <kdelibs4migration.h>
|
||||
// Qt
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTest>
|
||||
|
||||
class MigrationTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void testPaths();
|
||||
};
|
||||
|
||||
void MigrationTest::testPaths()
|
||||
{
|
||||
// Setup
|
||||
QTemporaryDir kdehomeDir;
|
||||
QVERIFY(kdehomeDir.isValid());
|
||||
QString kdehome = kdehomeDir.path();
|
||||
qputenv("KDEHOME", QFile::encodeName(kdehome));
|
||||
|
||||
QString oldConfigDir = kdehome + QStringLiteral("/share/config/");
|
||||
QVERIFY(QDir().mkpath(oldConfigDir));
|
||||
QString oldAppsDir = kdehome + QStringLiteral("/share/apps/");
|
||||
QVERIFY(QDir().mkpath(oldAppsDir));
|
||||
// Test
|
||||
Kdelibs4Migration migration;
|
||||
|
||||
QVERIFY(migration.kdeHomeFound());
|
||||
QCOMPARE(migration.saveLocation("config"), oldConfigDir);
|
||||
QCOMPARE(migration.saveLocation("data"), oldAppsDir);
|
||||
}
|
||||
|
||||
QTEST_MAIN(MigrationTest)
|
||||
|
||||
#include "kdelibs4migrationtest.moc"
|
||||
119
Telegram/ThirdParty/kcoreaddons/autotests/kdirwatch_benchmarktest.cpp
vendored
Normal file
119
Telegram/ThirdParty/kcoreaddons/autotests/kdirwatch_benchmarktest.cpp
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2009 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <kdirwatch.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QSignalSpy>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTest>
|
||||
#include <QThread>
|
||||
#include <sys/stat.h>
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <unistd.h> // ::link()
|
||||
#endif
|
||||
|
||||
#include "config-tests.h"
|
||||
#include "kcoreaddons_debug.h"
|
||||
|
||||
#include "kdirwatch_test_utils.h"
|
||||
|
||||
using namespace KDirWatchTestUtils;
|
||||
|
||||
class KDirWatch_UnitTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KDirWatch_UnitTest()
|
||||
{
|
||||
// Speed up the test by making the kdirwatch timer (to compress changes) faster
|
||||
qputenv("KDIRWATCH_POLLINTERVAL", "50");
|
||||
qputenv("KDIRWATCH_METHOD", KDIRWATCH_TEST_METHOD);
|
||||
s_staticObjectUsingSelf();
|
||||
|
||||
m_path = m_tempDir.path() + QLatin1Char('/');
|
||||
KDirWatch *dirW = &s_staticObject()->m_dirWatch;
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Using method" << methodToString(dirW->internalMethod());
|
||||
}
|
||||
|
||||
private Q_SLOTS: // test methods
|
||||
void initTestCase()
|
||||
{
|
||||
QFileInfo pathInfo(m_path);
|
||||
QVERIFY(pathInfo.isDir() && pathInfo.isWritable());
|
||||
|
||||
// By creating the files upfront, we save waiting a full second for an mtime change
|
||||
createFile(m_path + QLatin1String("ExistingFile"));
|
||||
createFile(m_path + QLatin1String("TestFile"));
|
||||
createFile(m_path + QLatin1String("nested_0"));
|
||||
createFile(m_path + QLatin1String("nested_1"));
|
||||
|
||||
s_staticObject()->m_dirWatch.addFile(m_path + QLatin1String("ExistingFile"));
|
||||
}
|
||||
void benchCreateTree();
|
||||
void benchCreateWatcher();
|
||||
void benchNotifyWatcher();
|
||||
|
||||
private:
|
||||
QTemporaryDir m_tempDir;
|
||||
QString m_path;
|
||||
};
|
||||
|
||||
QTEST_MAIN(KDirWatch_UnitTest)
|
||||
|
||||
void KDirWatch_UnitTest::benchCreateTree()
|
||||
{
|
||||
#if !ENABLE_BENCHMARKS
|
||||
QSKIP("Benchmarks are disabled in debug mode");
|
||||
#endif
|
||||
QTemporaryDir dir;
|
||||
|
||||
QBENCHMARK {
|
||||
createDirectoryTree(dir.path());
|
||||
}
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::benchCreateWatcher()
|
||||
{
|
||||
#if !ENABLE_BENCHMARKS
|
||||
QSKIP("Benchmarks are disabled in debug mode");
|
||||
#endif
|
||||
QTemporaryDir dir;
|
||||
createDirectoryTree(dir.path());
|
||||
|
||||
QBENCHMARK {
|
||||
KDirWatch watch;
|
||||
watch.addDir(dir.path(), KDirWatch::WatchSubDirs | KDirWatch::WatchFiles);
|
||||
}
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::benchNotifyWatcher()
|
||||
{
|
||||
#if !ENABLE_BENCHMARKS
|
||||
QSKIP("Benchmarks are disabled in debug mode");
|
||||
#endif
|
||||
QTemporaryDir dir;
|
||||
// create the dir once upfront
|
||||
auto numFiles = createDirectoryTree(dir.path());
|
||||
waitUntilMTimeChange(dir.path());
|
||||
|
||||
KDirWatch watch;
|
||||
watch.addDir(dir.path(), KDirWatch::WatchSubDirs | KDirWatch::WatchFiles);
|
||||
|
||||
// now touch all the files repeatedly and wait for the dirty updates to come in
|
||||
QSignalSpy spy(&watch, &KDirWatch::dirty);
|
||||
QBENCHMARK {
|
||||
createDirectoryTree(dir.path());
|
||||
QTRY_COMPARE_WITH_TIMEOUT(spy.count(), numFiles, 30000);
|
||||
spy.clear();
|
||||
}
|
||||
}
|
||||
|
||||
#include "kdirwatch_benchmarktest.moc"
|
||||
142
Telegram/ThirdParty/kcoreaddons/autotests/kdirwatch_test_utils.h
vendored
Normal file
142
Telegram/ThirdParty/kcoreaddons/autotests/kdirwatch_test_utils.h
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2009 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <kdirwatch.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QTest>
|
||||
#include <QThread>
|
||||
|
||||
#include "kcoreaddons_debug.h"
|
||||
|
||||
class StaticObject
|
||||
{
|
||||
public:
|
||||
KDirWatch m_dirWatch;
|
||||
};
|
||||
Q_GLOBAL_STATIC(StaticObject, s_staticObject)
|
||||
|
||||
class StaticObjectUsingSelf // like KSambaShare does, bug 353080
|
||||
{
|
||||
public:
|
||||
StaticObjectUsingSelf()
|
||||
{
|
||||
KDirWatch::self();
|
||||
}
|
||||
~StaticObjectUsingSelf()
|
||||
{
|
||||
if (KDirWatch::exists() && KDirWatch::self()->contains(QDir::homePath())) {
|
||||
KDirWatch::self()->removeDir(QDir::homePath());
|
||||
}
|
||||
}
|
||||
};
|
||||
Q_GLOBAL_STATIC(StaticObjectUsingSelf, s_staticObjectUsingSelf)
|
||||
|
||||
namespace KDirWatchTestUtils
|
||||
{
|
||||
// Just to make the inotify packets bigger
|
||||
static const char s_filePrefix[] = "This_is_a_test_file_";
|
||||
|
||||
static const char *methodToString(KDirWatch::Method method)
|
||||
{
|
||||
switch (method) {
|
||||
case KDirWatch::FAM:
|
||||
return "Fam";
|
||||
case KDirWatch::INotify:
|
||||
return "INotify";
|
||||
case KDirWatch::Stat:
|
||||
return "Stat";
|
||||
case KDirWatch::QFSWatch:
|
||||
return "QFSWatch";
|
||||
}
|
||||
return "ERROR!";
|
||||
}
|
||||
|
||||
// helper method: create a file
|
||||
inline void createFile(const QString &path, bool slow = false)
|
||||
{
|
||||
QFile file(path);
|
||||
QVERIFY(file.open(QIODevice::WriteOnly));
|
||||
#ifdef Q_OS_FREEBSD
|
||||
// FreeBSD has inotify implemented as user-space library over native kevent API.
|
||||
// When using it, one has to open() a file to start watching it, so workaround
|
||||
// test breakage by giving inotify time to react to file creation.
|
||||
// Full context: https://github.com/libinotify-kqueue/libinotify-kqueue/issues/10
|
||||
if (!slow) {
|
||||
QThread::msleep(1);
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(slow)
|
||||
#endif
|
||||
file.write(QByteArray("foo"));
|
||||
file.close();
|
||||
}
|
||||
|
||||
inline int createDirectoryTree(const QString &basePath, int depth = 4)
|
||||
{
|
||||
int filesCreated = 0;
|
||||
|
||||
const int numFiles = 10;
|
||||
for (int i = 0; i < numFiles; ++i) {
|
||||
createFile(basePath + QLatin1Char('/') + QLatin1String(s_filePrefix) + QString::number(i));
|
||||
++filesCreated;
|
||||
}
|
||||
|
||||
if (depth <= 0) {
|
||||
return filesCreated;
|
||||
}
|
||||
|
||||
const int numFolders = 5;
|
||||
for (int i = 0; i < numFolders; ++i) {
|
||||
const QString childPath = basePath + QLatin1String("/subdir") + QString::number(i);
|
||||
QDir().mkdir(childPath);
|
||||
filesCreated += createDirectoryTree(childPath, depth - 1);
|
||||
}
|
||||
|
||||
return filesCreated;
|
||||
}
|
||||
|
||||
inline void waitUntilAfter(const QDateTime &ctime)
|
||||
{
|
||||
int totalWait = 0;
|
||||
QDateTime now;
|
||||
Q_FOREVER {
|
||||
now = QDateTime::currentDateTime();
|
||||
if (now.toMSecsSinceEpoch() / 1000 == ctime.toMSecsSinceEpoch() / 1000) // truncate milliseconds
|
||||
{
|
||||
totalWait += 50;
|
||||
QTest::qWait(50);
|
||||
} else {
|
||||
QVERIFY(now > ctime); // can't go back in time ;)
|
||||
QTest::qWait(50); // be safe
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if (totalWait > 0)
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Waited" << totalWait << "ms so that now" << now.toString(Qt::ISODate) << "is >" << ctime.toString(Qt::ISODate);
|
||||
}
|
||||
inline void waitUntilMTimeChange(const QString &path)
|
||||
{
|
||||
// Wait until the current second is more than the file's mtime
|
||||
// otherwise this change will go unnoticed
|
||||
|
||||
QFileInfo fi(path);
|
||||
QVERIFY(fi.exists());
|
||||
const QDateTime ctime = fi.lastModified();
|
||||
waitUntilAfter(ctime);
|
||||
}
|
||||
|
||||
inline void waitUntilNewSecond()
|
||||
{
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
waitUntilAfter(now);
|
||||
}
|
||||
|
||||
}
|
||||
767
Telegram/ThirdParty/kcoreaddons/autotests/kdirwatch_unittest.cpp
vendored
Normal file
767
Telegram/ThirdParty/kcoreaddons/autotests/kdirwatch_unittest.cpp
vendored
Normal file
@@ -0,0 +1,767 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2009 David Faure <faure@kde.org>
|
||||
SPDX-FileCopyrightText: 2023 Harald Sitter <sitter@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <kdirwatch.h>
|
||||
#include <kdirwatch_p.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QRegularExpression>
|
||||
#include <QSignalSpy>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTest>
|
||||
#include <QThread>
|
||||
#include <sys/stat.h>
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <unistd.h> // ::link()
|
||||
#endif
|
||||
|
||||
#include "kcoreaddons_debug.h"
|
||||
#include "kdirwatch_test_utils.h"
|
||||
|
||||
using namespace KDirWatchTestUtils;
|
||||
|
||||
// Debugging notes: to see which inotify signals are emitted, either set s_verboseDebug=true
|
||||
// at the top of kdirwatch.cpp, or use the command-line tool "inotifywait -m /path"
|
||||
|
||||
class KDirWatch_UnitTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KDirWatch_UnitTest()
|
||||
{
|
||||
// Speed up the test by making the kdirwatch timer (to compress changes) faster
|
||||
qputenv("KDIRWATCH_POLLINTERVAL", "50");
|
||||
qputenv("KDIRWATCH_METHOD", KDIRWATCH_TEST_METHOD);
|
||||
s_staticObjectUsingSelf();
|
||||
|
||||
m_path = m_tempDir.path() + QLatin1Char('/');
|
||||
KDirWatch *dirW = &s_staticObject()->m_dirWatch;
|
||||
m_stat = dirW->internalMethod() == KDirWatch::Stat;
|
||||
m_slow = (dirW->internalMethod() == KDirWatch::FAM || m_stat);
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Using method" << methodToString(dirW->internalMethod());
|
||||
}
|
||||
|
||||
private Q_SLOTS: // test methods
|
||||
void initTestCase()
|
||||
{
|
||||
QFileInfo pathInfo(m_path);
|
||||
QVERIFY(pathInfo.isDir() && pathInfo.isWritable());
|
||||
|
||||
// By creating the files upfront, we save waiting a full second for an mtime change
|
||||
createFile(m_path + QLatin1String("ExistingFile"));
|
||||
createFile(m_path + QLatin1String("TestFile"));
|
||||
createFile(m_path + QLatin1String("nested_0"));
|
||||
createFile(m_path + QLatin1String("nested_1"));
|
||||
|
||||
s_staticObject()->m_dirWatch.addFile(m_path + QLatin1String("ExistingFile"));
|
||||
}
|
||||
void touchOneFile();
|
||||
void touch1000Files();
|
||||
void watchAndModifyOneFile();
|
||||
void removeAndReAdd();
|
||||
void watchNonExistent();
|
||||
void watchNonExistentWithSingleton();
|
||||
void testDelete();
|
||||
void testDeleteAndRecreateFile();
|
||||
void testDeleteAndRecreateDir();
|
||||
void testMoveTo();
|
||||
void nestedEventLoop();
|
||||
void testHardlinkChange();
|
||||
void stopAndRestart();
|
||||
void testRefcounting();
|
||||
void testRelativeRefcounting();
|
||||
void testMoveToThread();
|
||||
|
||||
protected Q_SLOTS: // internal slots
|
||||
void nestedEventLoopSlot();
|
||||
|
||||
private:
|
||||
QList<QVariantList> waitForDirtySignal(KDirWatch &watch, int expected);
|
||||
QList<QVariantList> waitForDeletedSignal(KDirWatch &watch, int expected);
|
||||
bool waitForOneSignal(KDirWatch &watch, const char *sig, const QString &path);
|
||||
bool waitForRecreationSignal(KDirWatch &watch, const QString &path);
|
||||
bool verifySignalPath(QSignalSpy &spy, const char *sig, const QString &expectedPath);
|
||||
QString createFile(int num);
|
||||
void createFile(const QString &file)
|
||||
{
|
||||
KDirWatchTestUtils::createFile(file, m_slow);
|
||||
}
|
||||
void removeFile(int num);
|
||||
void appendToFile(const QString &path);
|
||||
void appendToFile(int num);
|
||||
|
||||
QTemporaryDir m_tempDir;
|
||||
QString m_path;
|
||||
bool m_slow;
|
||||
bool m_stat;
|
||||
};
|
||||
|
||||
QTEST_MAIN(KDirWatch_UnitTest)
|
||||
|
||||
static const int s_maxTries = 50;
|
||||
|
||||
// helper method: create a file (identified by number)
|
||||
QString KDirWatch_UnitTest::createFile(int num)
|
||||
{
|
||||
const QString fileName = QLatin1String(s_filePrefix) + QString::number(num);
|
||||
KDirWatchTestUtils::createFile(m_path + fileName, m_slow);
|
||||
return m_path + fileName;
|
||||
}
|
||||
|
||||
// helper method: delete a file (identified by number)
|
||||
void KDirWatch_UnitTest::removeFile(int num)
|
||||
{
|
||||
const QString fileName = QLatin1String(s_filePrefix) + QString::number(num);
|
||||
QFile::remove(m_path + fileName);
|
||||
}
|
||||
|
||||
// helper method: modifies a file
|
||||
void KDirWatch_UnitTest::appendToFile(const QString &path)
|
||||
{
|
||||
QVERIFY(QFile::exists(path));
|
||||
waitUntilMTimeChange(path);
|
||||
|
||||
QFile file(path);
|
||||
QVERIFY(file.open(QIODevice::Append | QIODevice::WriteOnly));
|
||||
file.write(QByteArray("foobar"));
|
||||
file.close();
|
||||
}
|
||||
|
||||
// helper method: modifies a file (identified by number)
|
||||
void KDirWatch_UnitTest::appendToFile(int num)
|
||||
{
|
||||
const QString fileName = QLatin1String(s_filePrefix) + QString::number(num);
|
||||
appendToFile(m_path + fileName);
|
||||
}
|
||||
|
||||
static QString removeTrailingSlash(const QString &path)
|
||||
{
|
||||
if (path.endsWith(QLatin1Char('/'))) {
|
||||
return path.left(path.length() - 1);
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
// helper method
|
||||
QList<QVariantList> KDirWatch_UnitTest::waitForDirtySignal(KDirWatch &watch, int expected)
|
||||
{
|
||||
QSignalSpy spyDirty(&watch, &KDirWatch::dirty);
|
||||
int numTries = 0;
|
||||
// Give time for KDirWatch to notify us
|
||||
while (spyDirty.count() < expected) {
|
||||
if (++numTries > s_maxTries) {
|
||||
qWarning() << "Timeout waiting for KDirWatch. Got" << spyDirty.count() << "dirty() signals, expected" << expected;
|
||||
return std::move(spyDirty);
|
||||
}
|
||||
spyDirty.wait(50);
|
||||
}
|
||||
return std::move(spyDirty);
|
||||
}
|
||||
|
||||
bool KDirWatch_UnitTest::waitForOneSignal(KDirWatch &watch, const char *sig, const QString &path)
|
||||
{
|
||||
const QString expectedPath = removeTrailingSlash(path);
|
||||
while (true) {
|
||||
QSignalSpy spyDirty(&watch, sig);
|
||||
int numTries = 0;
|
||||
// Give time for KDirWatch to notify us
|
||||
while (spyDirty.isEmpty()) {
|
||||
if (++numTries > s_maxTries) {
|
||||
qWarning() << "Timeout waiting for KDirWatch signal" << QByteArray(sig).mid(1) << "(" << path << ")";
|
||||
return false;
|
||||
}
|
||||
spyDirty.wait(50);
|
||||
}
|
||||
return verifySignalPath(spyDirty, sig, expectedPath);
|
||||
}
|
||||
}
|
||||
|
||||
bool KDirWatch_UnitTest::verifySignalPath(QSignalSpy &spy, const char *sig, const QString &expectedPath)
|
||||
{
|
||||
for (int i = 0; i < spy.count(); ++i) {
|
||||
const QString got = spy[i][0].toString();
|
||||
if (got == expectedPath) {
|
||||
return true;
|
||||
}
|
||||
if (got.startsWith(expectedPath + QLatin1Char('/'))) {
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Ignoring (inotify) notification of" << (sig + 1) << '(' << got << ')';
|
||||
continue;
|
||||
}
|
||||
qWarning() << "Expected" << sig << '(' << expectedPath << ')' << "but got" << sig << '(' << got << ')';
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KDirWatch_UnitTest::waitForRecreationSignal(KDirWatch &watch, const QString &path)
|
||||
{
|
||||
// When watching for a deleted + created signal pair, the two might come so close that
|
||||
// using waitForOneSignal will miss the created signal. This function monitors both all
|
||||
// the time to ensure both are received.
|
||||
//
|
||||
// In addition, it allows dirty() to be emitted (for that same path) as an alternative
|
||||
|
||||
const QString expectedPath = removeTrailingSlash(path);
|
||||
QSignalSpy spyDirty(&watch, &KDirWatch::dirty);
|
||||
QSignalSpy spyDeleted(&watch, &KDirWatch::deleted);
|
||||
QSignalSpy spyCreated(&watch, &KDirWatch::created);
|
||||
|
||||
int numTries = 0;
|
||||
while (spyDeleted.isEmpty() && spyDirty.isEmpty()) {
|
||||
if (++numTries > s_maxTries) {
|
||||
return false;
|
||||
}
|
||||
spyDeleted.wait(50);
|
||||
while (!spyDirty.isEmpty()) {
|
||||
if (spyDirty.at(0).at(0).toString() != expectedPath) { // unrelated
|
||||
spyDirty.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!spyDirty.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't bother waiting for the created signal if the signal spy already received a signal.
|
||||
if (spyCreated.isEmpty() && !spyCreated.wait(50 * s_maxTries)) {
|
||||
qWarning() << "Timeout waiting for KDirWatch signal created(QString) (" << path << ")";
|
||||
return false;
|
||||
}
|
||||
|
||||
return verifySignalPath(spyDeleted, "deleted(QString)", expectedPath) && verifySignalPath(spyCreated, "created(QString)", expectedPath);
|
||||
}
|
||||
|
||||
QList<QVariantList> KDirWatch_UnitTest::waitForDeletedSignal(KDirWatch &watch, int expected)
|
||||
{
|
||||
QSignalSpy spyDeleted(&watch, &KDirWatch::created);
|
||||
int numTries = 0;
|
||||
// Give time for KDirWatch to notify us
|
||||
while (spyDeleted.count() < expected) {
|
||||
if (++numTries > s_maxTries) {
|
||||
qWarning() << "Timeout waiting for KDirWatch. Got" << spyDeleted.count() << "deleted() signals, expected" << expected;
|
||||
return std::move(spyDeleted);
|
||||
}
|
||||
spyDeleted.wait(50);
|
||||
}
|
||||
return std::move(spyDeleted);
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::touchOneFile() // watch a dir, create a file in it
|
||||
{
|
||||
KDirWatch watch;
|
||||
watch.addDir(m_path);
|
||||
watch.startScan();
|
||||
|
||||
waitUntilMTimeChange(m_path);
|
||||
|
||||
// dirty(the directory) should be emitted.
|
||||
QSignalSpy spyCreated(&watch, &KDirWatch::created);
|
||||
createFile(0);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), m_path));
|
||||
QCOMPARE(spyCreated.count(), 0); // "This is not emitted when creating a file is created in a watched directory."
|
||||
|
||||
removeFile(0);
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::touch1000Files()
|
||||
{
|
||||
KDirWatch watch;
|
||||
watch.addDir(m_path);
|
||||
watch.startScan();
|
||||
|
||||
waitUntilMTimeChange(m_path);
|
||||
|
||||
const int fileCount = 100;
|
||||
for (int i = 0; i < fileCount; ++i) {
|
||||
createFile(i);
|
||||
}
|
||||
|
||||
QList<QVariantList> spy = waitForDirtySignal(watch, fileCount);
|
||||
if (watch.internalMethod() == KDirWatch::INotify) {
|
||||
QVERIFY(spy.count() >= fileCount);
|
||||
} else {
|
||||
// More stupid backends just see one mtime change on the directory
|
||||
QVERIFY(spy.count() >= 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < fileCount; ++i) {
|
||||
removeFile(i);
|
||||
}
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::watchAndModifyOneFile() // watch a specific file, and modify it
|
||||
{
|
||||
KDirWatch watch;
|
||||
const QString existingFile = m_path + QLatin1String("ExistingFile");
|
||||
watch.addFile(existingFile);
|
||||
watch.startScan();
|
||||
if (m_slow) {
|
||||
waitUntilNewSecond();
|
||||
}
|
||||
appendToFile(existingFile);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), existingFile));
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::removeAndReAdd()
|
||||
{
|
||||
KDirWatch watch;
|
||||
watch.addDir(m_path);
|
||||
// This triggers bug #374075.
|
||||
watch.addDir(QStringLiteral(":/kio5/newfile-templates"));
|
||||
watch.startScan();
|
||||
if (watch.internalMethod() != KDirWatch::INotify) {
|
||||
waitUntilNewSecond(); // necessary for mtime checks in scanEntry
|
||||
}
|
||||
createFile(0);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), m_path));
|
||||
|
||||
// Just like KDirLister does: remove the watch, then re-add it.
|
||||
watch.removeDir(m_path);
|
||||
watch.addDir(m_path);
|
||||
if (watch.internalMethod() != KDirWatch::INotify) {
|
||||
waitUntilMTimeChange(m_path); // necessary for FAM and QFSWatcher
|
||||
}
|
||||
createFile(1);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), m_path));
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::watchNonExistent()
|
||||
{
|
||||
KDirWatch watch;
|
||||
// Watch "subdir", that doesn't exist yet
|
||||
const QString subdir = m_path + QLatin1String("subdir");
|
||||
QVERIFY(!QFile::exists(subdir));
|
||||
watch.addDir(subdir);
|
||||
watch.startScan();
|
||||
|
||||
if (m_slow) {
|
||||
waitUntilNewSecond();
|
||||
}
|
||||
|
||||
// Now create it, KDirWatch should emit created()
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Creating" << subdir;
|
||||
QDir().mkdir(subdir);
|
||||
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(created(QString)), subdir));
|
||||
|
||||
KDirWatch::statistics();
|
||||
|
||||
// Play with addDir/removeDir, just for fun
|
||||
watch.addDir(subdir);
|
||||
watch.removeDir(subdir);
|
||||
watch.addDir(subdir);
|
||||
|
||||
// Now watch files that don't exist yet
|
||||
const QString file = subdir + QLatin1String("/0");
|
||||
watch.addFile(file); // doesn't exist yet
|
||||
const QString file1 = subdir + QLatin1String("/1");
|
||||
watch.addFile(file1); // doesn't exist yet
|
||||
watch.removeFile(file1); // forget it again
|
||||
|
||||
KDirWatch::statistics();
|
||||
|
||||
QVERIFY(!QFile::exists(file));
|
||||
// Now create it, KDirWatch should emit created
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Creating" << file;
|
||||
createFile(file);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(created(QString)), file));
|
||||
|
||||
appendToFile(file);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), file));
|
||||
|
||||
// Create the file after all; we're not watching for it, but the dir will emit dirty
|
||||
createFile(file1);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), subdir));
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::watchNonExistentWithSingleton()
|
||||
{
|
||||
const QString file = QLatin1String("/root/.ssh/authorized_keys");
|
||||
KDirWatch::self()->addFile(file);
|
||||
// When running this test in KDIRWATCH_METHOD=QFSWatch, or when FAM is not available
|
||||
// and we fallback to qfswatch when inotify fails above, we end up creating the fsWatch
|
||||
// in the kdirwatch singleton. Bug 261541 discovered that Qt hanged when deleting fsWatch
|
||||
// once QCoreApp was gone, this is what this test is about.
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::testDelete()
|
||||
{
|
||||
const QString file1 = m_path + QLatin1String("del");
|
||||
if (!QFile::exists(file1)) {
|
||||
createFile(file1);
|
||||
}
|
||||
waitUntilMTimeChange(file1);
|
||||
|
||||
// Watch the file, then delete it, KDirWatch will emit deleted (and possibly dirty for the dir, if mtime changed)
|
||||
KDirWatch watch;
|
||||
watch.addFile(file1);
|
||||
|
||||
KDirWatch::statistics();
|
||||
|
||||
QSignalSpy spyDirty(&watch, &KDirWatch::dirty);
|
||||
QFile::remove(file1);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(deleted(QString)), file1));
|
||||
QTest::qWait(40); // just in case delayed processing would emit it
|
||||
QCOMPARE(spyDirty.count(), 0);
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::testDeleteAndRecreateFile() // Useful for /etc/localtime for instance
|
||||
{
|
||||
const QString subdir = m_path + QLatin1String("subdir");
|
||||
QDir().mkdir(subdir);
|
||||
const QString file1 = subdir + QLatin1String("/1");
|
||||
if (!QFile::exists(file1)) {
|
||||
createFile(file1);
|
||||
}
|
||||
waitUntilMTimeChange(file1);
|
||||
|
||||
// Watch the file, then delete it, KDirWatch will emit deleted (and possibly dirty for the dir, if mtime changed)
|
||||
KDirWatch watch;
|
||||
watch.addFile(file1);
|
||||
|
||||
// Make sure this even works multiple times, as needed for ksycoca
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (m_slow || watch.internalMethod() == KDirWatch::QFSWatch) {
|
||||
waitUntilNewSecond();
|
||||
}
|
||||
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Attempt #" << (i + 1) << "removing+recreating" << file1;
|
||||
|
||||
// When watching for a deleted + created signal pair, the two might come so close that
|
||||
// using waitForOneSignal will miss the created signal. This function monitors both all
|
||||
// the time to ensure both are received.
|
||||
//
|
||||
// In addition, allow dirty() to be emitted (for that same path) as an alternative
|
||||
|
||||
const QString expectedPath = file1;
|
||||
QSignalSpy spyDirty(&watch, &KDirWatch::dirty);
|
||||
QSignalSpy spyDeleted(&watch, &KDirWatch::deleted);
|
||||
QSignalSpy spyCreated(&watch, &KDirWatch::created);
|
||||
|
||||
// WHEN
|
||||
QFile::remove(file1);
|
||||
// And recreate immediately, to try and fool KDirWatch with unchanged ctime/mtime ;)
|
||||
// (This emulates the /etc/localtime case)
|
||||
createFile(file1);
|
||||
|
||||
// THEN
|
||||
int numTries = 0;
|
||||
while (spyDeleted.isEmpty() && spyDirty.isEmpty()) {
|
||||
if (++numTries > s_maxTries) {
|
||||
QFAIL("Failed to detect file deletion and recreation through either a deleted/created signal pair or through a dirty signal!");
|
||||
return;
|
||||
}
|
||||
spyDeleted.wait(50);
|
||||
while (!spyDirty.isEmpty()) {
|
||||
if (spyDirty.at(0).at(0).toString() != expectedPath) { // unrelated
|
||||
spyDirty.removeFirst();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!spyDirty.isEmpty()) {
|
||||
continue; // all ok
|
||||
}
|
||||
|
||||
// Don't bother waiting for the created signal if the signal spy already received a signal.
|
||||
if (spyCreated.isEmpty() && !spyCreated.wait(50 * s_maxTries)) {
|
||||
qWarning() << "Timeout waiting for KDirWatch signal created(QString) (" << expectedPath << ")";
|
||||
QFAIL("Timeout waiting for KDirWatch signal created, after deleted was emitted");
|
||||
return;
|
||||
}
|
||||
|
||||
QVERIFY(verifySignalPath(spyDeleted, "deleted(QString)", expectedPath) && verifySignalPath(spyCreated, "created(QString)", expectedPath));
|
||||
}
|
||||
|
||||
waitUntilMTimeChange(file1);
|
||||
|
||||
appendToFile(file1);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), file1));
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::testDeleteAndRecreateDir()
|
||||
{
|
||||
// Like KDirModelTest::testOverwriteFileWithDir does at the end.
|
||||
// The linux-2.6.31 bug made kdirwatch emit deletion signals about the -new- dir!
|
||||
QTemporaryDir *tempDir1 = new QTemporaryDir(QDir::tempPath() + QLatin1Char('/') + QLatin1String("olddir-"));
|
||||
KDirWatch watch;
|
||||
const QString path1 = tempDir1->path() + QLatin1Char('/');
|
||||
watch.addDir(path1);
|
||||
|
||||
delete tempDir1;
|
||||
QTemporaryDir *tempDir2 = new QTemporaryDir(QDir::tempPath() + QLatin1Char('/') + QLatin1String("newdir-"));
|
||||
const QString path2 = tempDir2->path() + QLatin1Char('/');
|
||||
watch.addDir(path2);
|
||||
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(deleted(QString)), path1));
|
||||
|
||||
delete tempDir2;
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::testMoveTo()
|
||||
{
|
||||
// This reproduces the famous digikam crash, #222974
|
||||
// A watched file was being rewritten (overwritten by ksavefile),
|
||||
// which gives inotify notifications "moved_to" followed by "delete_self"
|
||||
//
|
||||
// What happened then was that the delayed slotRescan
|
||||
// would adjust things, making it status==Normal but the entry was
|
||||
// listed as a "non-existent sub-entry" for the parent directory.
|
||||
// That's inconsistent, and after removeFile() a dangling sub-entry would be left.
|
||||
|
||||
// Initial data: creating file subdir/1
|
||||
const QString file1 = m_path + QLatin1String("moveTo");
|
||||
createFile(file1);
|
||||
|
||||
KDirWatch watch;
|
||||
watch.addDir(m_path);
|
||||
watch.addFile(file1);
|
||||
watch.startScan();
|
||||
|
||||
if (watch.internalMethod() != KDirWatch::INotify) {
|
||||
waitUntilMTimeChange(m_path);
|
||||
}
|
||||
|
||||
// Atomic rename of "temp" to "file1", much like KAutoSave would do when saving file1 again
|
||||
// ### TODO: this isn't an atomic rename anymore. We need ::rename for that, or API from Qt.
|
||||
const QString filetemp = m_path + QLatin1String("temp");
|
||||
createFile(filetemp);
|
||||
QFile::remove(file1);
|
||||
QVERIFY(QFile::rename(filetemp, file1)); // overwrite file1 with the tempfile
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Overwrite file1 with tempfile";
|
||||
|
||||
QSignalSpy spyCreated(&watch, &KDirWatch::created);
|
||||
QSignalSpy spyDirty(&watch, &KDirWatch::dirty);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), m_path));
|
||||
|
||||
// Getting created() on an unwatched file is an inotify bonus, it's not part of the requirements.
|
||||
if (watch.internalMethod() == KDirWatch::INotify) {
|
||||
QCOMPARE(spyCreated.count(), 1);
|
||||
QCOMPARE(spyCreated[0][0].toString(), file1);
|
||||
|
||||
QCOMPARE(spyDirty.size(), 2);
|
||||
QCOMPARE(spyDirty[1][0].toString(), filetemp);
|
||||
}
|
||||
|
||||
// make sure we're still watching it
|
||||
appendToFile(file1);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), file1));
|
||||
|
||||
watch.removeFile(file1); // now we remove it
|
||||
|
||||
// Just touch another file to trigger a findSubEntry - this where the crash happened
|
||||
waitUntilMTimeChange(m_path);
|
||||
createFile(filetemp);
|
||||
#ifdef Q_OS_WIN
|
||||
if (watch.internalMethod() == KDirWatch::QFSWatch) {
|
||||
QEXPECT_FAIL(nullptr, "QFSWatch fails here on Windows!", Continue);
|
||||
}
|
||||
#endif
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), m_path));
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::nestedEventLoop() // #220153: watch two files, and modify 2nd while in slot for 1st
|
||||
{
|
||||
KDirWatch watch;
|
||||
|
||||
const QString file0 = m_path + QLatin1String("nested_0");
|
||||
watch.addFile(file0);
|
||||
const QString file1 = m_path + QLatin1String("nested_1");
|
||||
watch.addFile(file1);
|
||||
watch.startScan();
|
||||
|
||||
if (m_slow) {
|
||||
waitUntilNewSecond();
|
||||
}
|
||||
|
||||
appendToFile(file0);
|
||||
|
||||
// use own spy, to connect it before nestedEventLoopSlot, otherwise it reverses order
|
||||
QSignalSpy spyDirty(&watch, &KDirWatch::dirty);
|
||||
connect(&watch, &KDirWatch::dirty, this, &KDirWatch_UnitTest::nestedEventLoopSlot);
|
||||
waitForDirtySignal(watch, 1);
|
||||
QVERIFY(spyDirty.count() >= 2);
|
||||
QCOMPARE(spyDirty[0][0].toString(), file0);
|
||||
QCOMPARE(spyDirty[spyDirty.count() - 1][0].toString(), file1);
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::nestedEventLoopSlot()
|
||||
{
|
||||
const KDirWatch *const_watch = qobject_cast<const KDirWatch *>(sender());
|
||||
KDirWatch *watch = const_cast<KDirWatch *>(const_watch);
|
||||
// let's not come in this slot again
|
||||
disconnect(watch, &KDirWatch::dirty, this, &KDirWatch_UnitTest::nestedEventLoopSlot);
|
||||
|
||||
const QString file1 = m_path + QLatin1String("nested_1");
|
||||
appendToFile(file1);
|
||||
// The nested event processing here was from a messagebox in #220153
|
||||
QList<QVariantList> spy = waitForDirtySignal(*watch, 1);
|
||||
QVERIFY(spy.count() >= 1);
|
||||
QCOMPARE(spy[spy.count() - 1][0].toString(), file1);
|
||||
|
||||
// Now the user pressed reload...
|
||||
const QString file0 = m_path + QLatin1String("nested_0");
|
||||
watch->removeFile(file0);
|
||||
watch->addFile(file0);
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::testHardlinkChange()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
|
||||
// The unittest for the "detecting hardlink change to /etc/localtime" problem
|
||||
// described on kde-core-devel (2009-07-03).
|
||||
// It shows that watching a specific file doesn't inform us that the file is
|
||||
// being recreated. Better watch the directory, for that.
|
||||
// Well, it works with inotify (and fam - which uses inotify I guess?)
|
||||
|
||||
const QString existingFile = m_path + QLatin1String("ExistingFile");
|
||||
KDirWatch watch;
|
||||
watch.addFile(existingFile);
|
||||
watch.startScan();
|
||||
|
||||
QFile::remove(existingFile);
|
||||
const QString testFile = m_path + QLatin1String("TestFile");
|
||||
QVERIFY(::link(QFile::encodeName(testFile).constData(), QFile::encodeName(existingFile).constData()) == 0); // make ExistingFile "point" to TestFile
|
||||
QVERIFY(QFile::exists(existingFile));
|
||||
|
||||
QVERIFY(waitForRecreationSignal(watch, existingFile));
|
||||
|
||||
// The mtime of the existing file is the one of "TestFile", so it's old.
|
||||
// We won't detect the change then, if we use that as baseline for waiting.
|
||||
// We really need msec granularity, but that requires using statx which isn't available everywhere...
|
||||
waitUntilNewSecond();
|
||||
appendToFile(existingFile);
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), existingFile));
|
||||
#else
|
||||
QSKIP("Unix-specific");
|
||||
#endif
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::stopAndRestart()
|
||||
{
|
||||
KDirWatch watch;
|
||||
watch.addDir(m_path);
|
||||
watch.startScan();
|
||||
|
||||
waitUntilMTimeChange(m_path);
|
||||
|
||||
watch.stopDirScan(m_path);
|
||||
|
||||
qCDebug(KCOREADDONS_DEBUG) << "create file 2 at" << QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
const QString file2 = createFile(2);
|
||||
QSignalSpy spyDirty(&watch, &KDirWatch::dirty);
|
||||
QTest::qWait(200);
|
||||
QCOMPARE(spyDirty.count(), 0); // suspended -> no signal
|
||||
|
||||
watch.restartDirScan(m_path);
|
||||
|
||||
QTest::qWait(200);
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QCOMPARE(spyDirty.count(), 0); // as documented by restartDirScan: no signal
|
||||
// On Windows, however, signals will get emitted, due to the ifdef Q_OS_WIN in the timestamp
|
||||
// comparison ("trust QFSW since the mtime of dirs isn't modified")
|
||||
#endif
|
||||
|
||||
KDirWatch::statistics();
|
||||
|
||||
waitUntilMTimeChange(m_path); // necessary for the mtime comparison in scanEntry
|
||||
|
||||
qCDebug(KCOREADDONS_DEBUG) << "create file 3 at" << QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
const QString file3 = createFile(3);
|
||||
#ifdef Q_OS_WIN
|
||||
if (watch.internalMethod() == KDirWatch::QFSWatch) {
|
||||
QEXPECT_FAIL(nullptr, "QFSWatch fails here on Windows!", Continue);
|
||||
}
|
||||
#endif
|
||||
QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), m_path));
|
||||
|
||||
QFile::remove(file2);
|
||||
QFile::remove(file3);
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::testRefcounting()
|
||||
{
|
||||
#if QT_CONFIG(cxx11_future)
|
||||
bool initialExists = false;
|
||||
bool secondExists = true; // the expectation is it will be set false
|
||||
auto thread = QThread::create([&] {
|
||||
QTemporaryDir dir;
|
||||
{
|
||||
KDirWatch watch;
|
||||
watch.addFile(dir.path());
|
||||
initialExists = KDirWatch::exists();
|
||||
} // out of scope, the internal private should have been unset
|
||||
secondExists = KDirWatch::exists();
|
||||
});
|
||||
thread->start();
|
||||
thread->wait();
|
||||
delete thread;
|
||||
QVERIFY(initialExists);
|
||||
QVERIFY(!secondExists);
|
||||
#endif
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::testRelativeRefcounting()
|
||||
{
|
||||
// Relative files aren't supported but should still result in correct ref
|
||||
// handling. Specifically when watch1 gets destroyed it should take all
|
||||
// its entries with it regardless of whether the entry was well-formed
|
||||
KDirWatch watch0;
|
||||
|
||||
if (watch0.internalMethod() != KDirWatch::INotify) {
|
||||
// Only test on inotify. Otherwise Entry count expectations may diverge.
|
||||
return;
|
||||
}
|
||||
|
||||
const auto initialSize = watch0.d->m_mapEntries.size();
|
||||
{
|
||||
KDirWatch watch1;
|
||||
watch1.addFile(QStringLiteral("AVeryRelativePath.txt"));
|
||||
// NOTE: addFile actually adds two entires: one for '.' to watch for the appearance of the file and one for the file.
|
||||
QCOMPARE(watch0.d->m_mapEntries.size(), initialSize + 2);
|
||||
}
|
||||
// NOTE: we leak the directory entry from above but it has no clients so it's mostly harmless
|
||||
QCOMPARE(watch0.d->m_mapEntries.size(), initialSize + 1);
|
||||
}
|
||||
|
||||
void KDirWatch_UnitTest::testMoveToThread()
|
||||
{
|
||||
QTemporaryDir dir;
|
||||
{
|
||||
const QRegularExpression expression(QStringLiteral("KDirwatch is moving its thread. This is not supported at this time;.+"));
|
||||
QTest::ignoreMessage(QtCriticalMsg, expression);
|
||||
|
||||
auto watch = new KDirWatch;
|
||||
watch->addDir(dir.path());
|
||||
|
||||
auto thread = new QThread;
|
||||
watch->moveToThread(thread);
|
||||
thread->start();
|
||||
|
||||
waitUntilMTimeChange(dir.path());
|
||||
|
||||
QObject::connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
||||
QObject::connect(thread, &QThread::finished, watch, &QObject::deleteLater);
|
||||
|
||||
thread->quit();
|
||||
thread->wait();
|
||||
}
|
||||
// trigger an event on the now deleted watch. This should not crash!
|
||||
const QString file = dir.path() + QLatin1String("/bar");
|
||||
createFile(file);
|
||||
waitUntilMTimeChange(file);
|
||||
}
|
||||
|
||||
#include "kdirwatch_unittest.moc"
|
||||
93
Telegram/ThirdParty/kcoreaddons/autotests/kfileutilstest.cpp
vendored
Normal file
93
Telegram/ThirdParty/kcoreaddons/autotests/kfileutilstest.cpp
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2000-2005 David Faure <faure@kde.org>
|
||||
SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kfileutilstest.h"
|
||||
|
||||
#include <KFileUtils>
|
||||
#include <QStandardPaths>
|
||||
#include <QTest>
|
||||
|
||||
QTEST_MAIN(KFileUtilsTest)
|
||||
|
||||
void KFileUtilsTest::testSuggestName_data()
|
||||
{
|
||||
QTest::addColumn<QString>("oldName");
|
||||
QTest::addColumn<QStringList>("existingFiles");
|
||||
QTest::addColumn<QString>("expectedOutput");
|
||||
|
||||
QTest::newRow("non-existing") << "foobar" << QStringList() << "foobar (1)";
|
||||
QTest::newRow("existing") << "foobar" << QStringList(QStringLiteral("foobar")) << "foobar (1)";
|
||||
QTest::newRow("existing_1") << "foobar" << (QStringList() << QStringLiteral("foobar") << QStringLiteral("foobar (1)")) << "foobar (2)";
|
||||
QTest::newRow("extension") << "foobar.txt" << QStringList() << "foobar (1).txt";
|
||||
QTest::newRow("extension_exists") << "foobar.txt" << (QStringList() << QStringLiteral("foobar.txt")) << "foobar (1).txt";
|
||||
QTest::newRow("extension_exists_1") << "foobar.txt" << (QStringList() << QStringLiteral("foobar.txt") << QStringLiteral("foobar (1).txt"))
|
||||
<< "foobar (2).txt";
|
||||
QTest::newRow("two_extensions") << "foobar.tar.gz" << QStringList() << "foobar (1).tar.gz";
|
||||
QTest::newRow("two_extensions_exists") << "foobar.tar.gz" << (QStringList() << QStringLiteral("foobar.tar.gz")) << "foobar (1).tar.gz";
|
||||
QTest::newRow("two_extensions_exists_1") << "foobar.tar.gz" << (QStringList() << QStringLiteral("foobar.tar.gz") << QStringLiteral("foobar (1).tar.gz"))
|
||||
<< "foobar (2).tar.gz";
|
||||
QTest::newRow("with_space") << "foo bar" << QStringList(QStringLiteral("foo bar")) << "foo bar (1)";
|
||||
QTest::newRow("dot_at_beginning") << ".aFile.tar.gz" << QStringList() << ".aFile (1).tar.gz";
|
||||
QTest::newRow("dots_at_beginning") << "..aFile.tar.gz" << QStringList() << "..aFile (1).tar.gz";
|
||||
QTest::newRow("empty_basename") << ".txt" << QStringList() << ". (1).txt";
|
||||
QTest::newRow("empty_basename_2dots") << "..txt" << QStringList() << ". (1).txt";
|
||||
QTest::newRow("basename_with_dots") << "filename.5.3.2.tar.gz" << QStringList() << "filename.5.3.2 (1).tar.gz";
|
||||
QTest::newRow("unknown_extension_trashinfo") << "fileFromHome.trashinfo" << QStringList() << "fileFromHome (1).trashinfo";
|
||||
}
|
||||
|
||||
void KFileUtilsTest::testSuggestName()
|
||||
{
|
||||
QFETCH(QString, oldName);
|
||||
QFETCH(QStringList, existingFiles);
|
||||
QFETCH(QString, expectedOutput);
|
||||
|
||||
QTemporaryDir dir;
|
||||
const QUrl baseUrl = QUrl::fromLocalFile(dir.path());
|
||||
for (const QString &localFile : std::as_const(existingFiles)) {
|
||||
QFile file(dir.path() + QLatin1Char('/') + localFile);
|
||||
QVERIFY(file.open(QIODevice::WriteOnly));
|
||||
}
|
||||
QCOMPARE(KFileUtils::suggestName(baseUrl, oldName), expectedOutput);
|
||||
}
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID)
|
||||
#define XDG_PLATFORM
|
||||
#endif
|
||||
|
||||
void KFileUtilsTest::testfindAllUniqueFiles()
|
||||
{
|
||||
#ifndef XDG_PLATFORM
|
||||
QSKIP("This test requires XDG_DATA_DIRS; no way to configure QStandardPaths on Windows");
|
||||
#endif
|
||||
const QString testBaseDirPath = QDir::currentPath() + QLatin1String("/kfileutilstestdata/");
|
||||
QDir testDataBaseDir(testBaseDirPath);
|
||||
testDataBaseDir.mkpath(QStringLiteral("."));
|
||||
testDataBaseDir.mkpath(QStringLiteral("testdir1/testDirName"));
|
||||
testDataBaseDir.mkpath(QStringLiteral("testdir2/testDirName"));
|
||||
testDataBaseDir.mkpath(QStringLiteral("testdir3/testDirName"));
|
||||
|
||||
QFile file1(testBaseDirPath + QLatin1String("/testdir1/testDirName/testfile.test"));
|
||||
file1.open(QFile::WriteOnly);
|
||||
QFile file2(testBaseDirPath + QLatin1String("/testdir2/testDirName/testfile.test"));
|
||||
file2.open(QFile::WriteOnly);
|
||||
QFile file3(testBaseDirPath + QLatin1String("/testdir3/testDirName/differentfile.test"));
|
||||
file3.open(QFile::WriteOnly);
|
||||
QFile file4(testBaseDirPath + QLatin1String("/testdir3/testDirName/nomatch.txt"));
|
||||
file4.open(QFile::WriteOnly);
|
||||
|
||||
qputenv("XDG_DATA_DIRS", qPrintable(QStringLiteral("%1testdir1:%1testdir2:%1testdir3").arg(testBaseDirPath)));
|
||||
|
||||
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("testDirName"), QStandardPaths::LocateDirectory);
|
||||
const QStringList expected = {testDataBaseDir.filePath(QStringLiteral("testdir1/testDirName/testfile.test")),
|
||||
testDataBaseDir.filePath(QStringLiteral("testdir3/testDirName/differentfile.test"))};
|
||||
|
||||
const QStringList actual = KFileUtils::findAllUniqueFiles(dirs, QStringList{QStringLiteral("*.test")});
|
||||
QCOMPARE(actual, expected);
|
||||
}
|
||||
|
||||
#include "moc_kfileutilstest.cpp"
|
||||
22
Telegram/ThirdParty/kcoreaddons/autotests/kfileutilstest.h
vendored
Normal file
22
Telegram/ThirdParty/kcoreaddons/autotests/kfileutilstest.h
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2000-2005 David Faure <faure@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KFILEUTILSTEST_H
|
||||
#define KFILEUTILSTEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KFileUtilsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void testSuggestName_data();
|
||||
void testSuggestName();
|
||||
void testfindAllUniqueFiles();
|
||||
};
|
||||
|
||||
#endif
|
||||
402
Telegram/ThirdParty/kcoreaddons/autotests/kformattest.cpp
vendored
Normal file
402
Telegram/ThirdParty/kcoreaddons/autotests/kformattest.cpp
vendored
Normal file
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
This file is part of the KDE Frameworks
|
||||
|
||||
SPDX-FileCopyrightText: 2013 John Layt <jlayt@kde.org>
|
||||
SPDX-FileCopyrightText: 2010 Michael Leupold <lemma@confuego.org>
|
||||
SPDX-FileCopyrightText: 2009 Michael Pyne <mpyne@kde.org>
|
||||
SPDX-FileCopyrightText: 2008 Albert Astals Cid <aacid@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kformattest.h"
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "kformat.h"
|
||||
|
||||
void setupEnvironment()
|
||||
{
|
||||
#ifndef Q_OS_WIN
|
||||
// ignore translations
|
||||
qputenv("XDG_DATA_DIRS", "does-not-exist");
|
||||
#endif
|
||||
}
|
||||
Q_CONSTRUCTOR_FUNCTION(setupEnvironment)
|
||||
|
||||
void KFormatTest::formatByteSize()
|
||||
{
|
||||
QLocale locale(QLocale::c());
|
||||
locale.setNumberOptions(QLocale::DefaultNumberOptions); // Qt >= 5.6 sets QLocale::OmitGroupSeparator for the C locale
|
||||
KFormat format(locale);
|
||||
|
||||
QCOMPARE(format.formatByteSize(0), QStringLiteral("0 B"));
|
||||
QCOMPARE(format.formatByteSize(50), QStringLiteral("50 B"));
|
||||
QCOMPARE(format.formatByteSize(500), QStringLiteral("500 B"));
|
||||
QCOMPARE(format.formatByteSize(5000), QStringLiteral("4.9 KiB"));
|
||||
QCOMPARE(format.formatByteSize(50000), QStringLiteral("48.8 KiB"));
|
||||
QCOMPARE(format.formatByteSize(500000), QStringLiteral("488.3 KiB"));
|
||||
QCOMPARE(format.formatByteSize(5000000), QStringLiteral("4.8 MiB"));
|
||||
QCOMPARE(format.formatByteSize(50000000), QStringLiteral("47.7 MiB"));
|
||||
QCOMPARE(format.formatByteSize(500000000), QStringLiteral("476.8 MiB"));
|
||||
#if (defined(__WORDSIZE) && (__WORDSIZE == 64)) || defined(_LP64) || defined(__LP64__) || defined(__ILP64__)
|
||||
QCOMPARE(format.formatByteSize(5000000000), QStringLiteral("4.7 GiB"));
|
||||
QCOMPARE(format.formatByteSize(50000000000), QStringLiteral("46.6 GiB"));
|
||||
QCOMPARE(format.formatByteSize(500000000000), QStringLiteral("465.7 GiB"));
|
||||
QCOMPARE(format.formatByteSize(5000000000000), QStringLiteral("4.5 TiB"));
|
||||
QCOMPARE(format.formatByteSize(50000000000000), QStringLiteral("45.5 TiB"));
|
||||
QCOMPARE(format.formatByteSize(500000000000000), QStringLiteral("454.7 TiB"));
|
||||
#endif
|
||||
|
||||
QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::IECBinaryDialect), QStringLiteral("1.0 KiB"));
|
||||
QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::IECBinaryDialect), QStringLiteral("1,023 B"));
|
||||
QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::IECBinaryDialect), QStringLiteral("1.1 MiB")); // 1.2 metric
|
||||
|
||||
QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::IECBinaryDialect), QStringLiteral("-1.0 KiB"));
|
||||
QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::IECBinaryDialect), QStringLiteral("-1,023 B"));
|
||||
QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::IECBinaryDialect), QStringLiteral("-1.1 MiB")); // 1.2 metric
|
||||
|
||||
QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("1.0 KB"));
|
||||
QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("1,023 B"));
|
||||
QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("1.1 MB"));
|
||||
|
||||
QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("-1.0 KB"));
|
||||
QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("-1,023 B"));
|
||||
QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::JEDECBinaryDialect), QStringLiteral("-1.1 MB"));
|
||||
|
||||
QCOMPARE(format.formatByteSize(1024.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("1.0 kB"));
|
||||
QCOMPARE(format.formatByteSize(1023.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("1.0 kB"));
|
||||
QCOMPARE(format.formatByteSize(1163000.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("1.2 MB"));
|
||||
|
||||
QCOMPARE(format.formatByteSize(-1024.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("-1.0 kB"));
|
||||
QCOMPARE(format.formatByteSize(-1023.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("-1.0 kB"));
|
||||
QCOMPARE(format.formatByteSize(-1163000.0, 1, KFormat::MetricBinaryDialect), QStringLiteral("-1.2 MB"));
|
||||
|
||||
// Ensure all units are represented
|
||||
QCOMPARE(format.formatByteSize(2.0e9, 1, KFormat::MetricBinaryDialect), QStringLiteral("2.0 GB"));
|
||||
QCOMPARE(format.formatByteSize(3.2e12, 1, KFormat::MetricBinaryDialect), QStringLiteral("3.2 TB"));
|
||||
QCOMPARE(format.formatByteSize(4.1e15, 1, KFormat::MetricBinaryDialect), QStringLiteral("4.1 PB"));
|
||||
QCOMPARE(format.formatByteSize(6.7e18, 2, KFormat::MetricBinaryDialect), QStringLiteral("6.70 EB"));
|
||||
QCOMPARE(format.formatByteSize(5.6e20, 2, KFormat::MetricBinaryDialect), QStringLiteral("560.00 EB"));
|
||||
QCOMPARE(format.formatByteSize(2.3e22, 2, KFormat::MetricBinaryDialect), QStringLiteral("23.00 ZB"));
|
||||
QCOMPARE(format.formatByteSize(1.0e27, 1, KFormat::MetricBinaryDialect), QStringLiteral("1,000.0 YB"));
|
||||
|
||||
// Spattering of specific units
|
||||
QCOMPARE(format.formatByteSize(823000, 3, KFormat::IECBinaryDialect, KFormat::UnitMegaByte), QStringLiteral("0.785 MiB"));
|
||||
QCOMPARE(format.formatByteSize(1234034.0, 4, KFormat::JEDECBinaryDialect, KFormat::UnitByte), QStringLiteral("1,234,034 B"));
|
||||
|
||||
// Check examples from the documentation
|
||||
QCOMPARE(format.formatByteSize(1000, 1, KFormat::MetricBinaryDialect, KFormat::UnitKiloByte), QStringLiteral("1.0 kB"));
|
||||
QCOMPARE(format.formatByteSize(1000, 1, KFormat::IECBinaryDialect, KFormat::UnitKiloByte), QStringLiteral("1.0 KiB"));
|
||||
QCOMPARE(format.formatByteSize(1000, 1, KFormat::JEDECBinaryDialect, KFormat::UnitKiloByte), QStringLiteral("1.0 KB"));
|
||||
}
|
||||
|
||||
void KFormatTest::formatValue()
|
||||
{
|
||||
QLocale locale(QLocale::c());
|
||||
locale.setNumberOptions(QLocale::DefaultNumberOptions); // Qt >= 5.6 sets QLocale::OmitGroupSeparator for the C locale
|
||||
KFormat format(locale);
|
||||
|
||||
// Check examples from the documentation
|
||||
QCOMPARE(format.formatValue(1000, KFormat::Unit::Byte, 1, KFormat::UnitPrefix::Kilo, KFormat::MetricBinaryDialect), QStringLiteral("1.0 kB"));
|
||||
QCOMPARE(format.formatValue(1000, KFormat::Unit::Byte, 1, KFormat::UnitPrefix::Kilo, KFormat::IECBinaryDialect), QStringLiteral("1.0 KiB"));
|
||||
QCOMPARE(format.formatValue(1000, KFormat::Unit::Byte, 1, KFormat::UnitPrefix::Kilo, KFormat::JEDECBinaryDialect), QStringLiteral("1.0 KB"));
|
||||
|
||||
// Check examples from the documentation
|
||||
QCOMPARE(format.formatValue(1000, KFormat::Unit::Bit, 1, KFormat::UnitPrefix::Kilo, KFormat::MetricBinaryDialect), QStringLiteral("1.0 kbit"));
|
||||
QCOMPARE(format.formatValue(1000, QStringLiteral("bit"), 1, KFormat::UnitPrefix::Kilo), QStringLiteral("1.0 kbit"));
|
||||
QCOMPARE(format.formatValue(1000, QStringLiteral("bit/s"), 1, KFormat::UnitPrefix::Kilo), QStringLiteral("1.0 kbit/s"));
|
||||
|
||||
QCOMPARE(format.formatValue(100, QStringLiteral("bit/s")), QStringLiteral("100.0 bit/s"));
|
||||
QCOMPARE(format.formatValue(1000, QStringLiteral("bit/s")), QStringLiteral("1.0 kbit/s"));
|
||||
QCOMPARE(format.formatValue(10e3, QStringLiteral("bit/s")), QStringLiteral("10.0 kbit/s"));
|
||||
QCOMPARE(format.formatValue(10e6, QStringLiteral("bit/s")), QStringLiteral("10.0 Mbit/s"));
|
||||
|
||||
QCOMPARE(format.formatValue(0.010, KFormat::Unit::Meter, 1, KFormat::UnitPrefix::Milli, KFormat::MetricBinaryDialect), QStringLiteral("10.0 mm"));
|
||||
QCOMPARE(format.formatValue(10.12e-6, KFormat::Unit::Meter, 2, KFormat::UnitPrefix::Micro, KFormat::MetricBinaryDialect), QString::fromUtf8("10.12 µm"));
|
||||
QCOMPARE(format.formatValue(10.55e-6, KFormat::Unit::Meter, 1, KFormat::UnitPrefix::AutoAdjust, KFormat::MetricBinaryDialect),
|
||||
QString::fromUtf8("10.6 µm"));
|
||||
}
|
||||
|
||||
enum TimeConstants {
|
||||
MSecsInDay = 86400000,
|
||||
MSecsInHour = 3600000,
|
||||
MSecsInMinute = 60000,
|
||||
MSecsInSecond = 1000,
|
||||
};
|
||||
|
||||
void KFormatTest::formatDuration()
|
||||
{
|
||||
KFormat format(QLocale::c());
|
||||
|
||||
quint64 singleSecond = 3 * MSecsInSecond + 700;
|
||||
quint64 doubleSecond = 33 * MSecsInSecond + 700;
|
||||
quint64 singleMinute = 8 * MSecsInMinute + 3 * MSecsInSecond + 700;
|
||||
quint64 doubleMinute = 38 * MSecsInMinute + 3 * MSecsInSecond + 700;
|
||||
quint64 singleHour = 5 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700;
|
||||
quint64 doubleHour = 15 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700;
|
||||
quint64 singleDay = 1 * MSecsInDay + 5 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700;
|
||||
quint64 doubleDay = 10 * MSecsInDay + 5 * MSecsInHour + 8 * MSecsInMinute + 3 * MSecsInSecond + 700;
|
||||
quint64 roundingIssues = 2 * MSecsInHour + 59 * MSecsInMinute + 59 * MSecsInSecond + 900;
|
||||
quint64 largeValue = 9999999999;
|
||||
|
||||
// Default format
|
||||
QCOMPARE(format.formatDuration(singleSecond), QStringLiteral("0:00:04"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond), QStringLiteral("0:00:34"));
|
||||
QCOMPARE(format.formatDuration(singleMinute), QStringLiteral("0:08:04"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute), QStringLiteral("0:38:04"));
|
||||
QCOMPARE(format.formatDuration(singleHour), QStringLiteral("5:08:04"));
|
||||
QCOMPARE(format.formatDuration(doubleHour), QStringLiteral("15:08:04"));
|
||||
QCOMPARE(format.formatDuration(singleDay), QStringLiteral("29:08:04"));
|
||||
QCOMPARE(format.formatDuration(doubleDay), QStringLiteral("245:08:04"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues), QStringLiteral("3:00:00"));
|
||||
QCOMPARE(format.formatDuration(largeValue), QStringLiteral("2777:46:40"));
|
||||
|
||||
// ShowMilliseconds format
|
||||
KFormat::DurationFormatOptions options = KFormat::ShowMilliseconds;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:00:03.700"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0:00:33.700"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0:08:03.700"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0:38:03.700"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5:08:03.700"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15:08:03.700"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29:08:03.700"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245:08:03.700"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("2:59:59.900"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777:46:39.999"));
|
||||
|
||||
// HideSeconds format
|
||||
options = KFormat::HideSeconds;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:00"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0:01"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0:08"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0:38"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5:08"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15:08"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29:08"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245:08"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3:00"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777:47"));
|
||||
|
||||
// FoldHours format
|
||||
options = KFormat::FoldHours;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:04"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0:34"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("8:04"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("38:04"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("308:04"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("908:04"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748:04"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708:04"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("180:00"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("166666:40"));
|
||||
|
||||
// FoldHours ShowMilliseconds format
|
||||
options = KFormat::FoldHours;
|
||||
options = options | KFormat::ShowMilliseconds;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0:03.700"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0:33.700"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("8:03.700"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("38:03.700"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("308:03.700"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("908:03.700"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748:03.700"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708:03.700"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("179:59.900"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("166666:39.999"));
|
||||
|
||||
// InitialDuration format
|
||||
options = KFormat::InitialDuration;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0h00m04s"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0h00m34s"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0h08m04s"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0h38m04s"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5h08m04s"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15h08m04s"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m04s"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m04s"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3h00m00s"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777h46m40s"));
|
||||
|
||||
// InitialDuration and ShowMilliseconds format
|
||||
options = KFormat::InitialDuration;
|
||||
options = options | KFormat::ShowMilliseconds;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0h00m03.700s"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0h00m33.700s"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0h08m03.700s"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0h38m03.700s"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5h08m03.700s"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15h08m03.700s"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m03.700s"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m03.700s"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("2h59m59.900s"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777h46m39.999s"));
|
||||
|
||||
// InitialDuration and HideSeconds format
|
||||
options = KFormat::InitialDuration;
|
||||
options = options | KFormat::HideSeconds;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0h00m"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0h01m"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("0h08m"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("0h38m"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("5h08m"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("15h08m"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("29h08m"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("245h08m"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("3h00m"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("2777h47m"));
|
||||
|
||||
// InitialDuration and FoldHours format
|
||||
options = KFormat::InitialDuration;
|
||||
options = options | KFormat::FoldHours;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0m04s"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0m34s"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("8m04s"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("38m04s"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("308m04s"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("908m04s"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748m04s"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708m04s"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("180m00s"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("166666m40s"));
|
||||
|
||||
// InitialDuration and FoldHours and ShowMilliseconds format
|
||||
options = KFormat::InitialDuration;
|
||||
options = options | KFormat::FoldHours | KFormat::ShowMilliseconds;
|
||||
QCOMPARE(format.formatDuration(singleSecond, options), QStringLiteral("0m03.700s"));
|
||||
QCOMPARE(format.formatDuration(doubleSecond, options), QStringLiteral("0m33.700s"));
|
||||
QCOMPARE(format.formatDuration(singleMinute, options), QStringLiteral("8m03.700s"));
|
||||
QCOMPARE(format.formatDuration(doubleMinute, options), QStringLiteral("38m03.700s"));
|
||||
QCOMPARE(format.formatDuration(singleHour, options), QStringLiteral("308m03.700s"));
|
||||
QCOMPARE(format.formatDuration(doubleHour, options), QStringLiteral("908m03.700s"));
|
||||
QCOMPARE(format.formatDuration(singleDay, options), QStringLiteral("1748m03.700s"));
|
||||
QCOMPARE(format.formatDuration(doubleDay, options), QStringLiteral("14708m03.700s"));
|
||||
QCOMPARE(format.formatDuration(roundingIssues, options), QStringLiteral("179m59.900s"));
|
||||
QCOMPARE(format.formatDuration(largeValue, options), QStringLiteral("166666m39.999s"));
|
||||
}
|
||||
|
||||
void KFormatTest::formatDecimalDuration()
|
||||
{
|
||||
KFormat format(QLocale::c());
|
||||
|
||||
QCOMPARE(format.formatDecimalDuration(10), QStringLiteral("10 millisecond(s)"));
|
||||
QCOMPARE(format.formatDecimalDuration(10, 3), QStringLiteral("10 millisecond(s)"));
|
||||
QCOMPARE(format.formatDecimalDuration(1 * MSecsInSecond + 10), QStringLiteral("1.01 seconds"));
|
||||
QCOMPARE(format.formatDecimalDuration(1 * MSecsInSecond + 1, 3), QStringLiteral("1.001 seconds"));
|
||||
QCOMPARE(format.formatDecimalDuration(1 * MSecsInMinute + 10 * MSecsInSecond), QStringLiteral("1.17 minutes"));
|
||||
QCOMPARE(format.formatDecimalDuration(1 * MSecsInMinute + 10 * MSecsInSecond, 3), QStringLiteral("1.167 minutes"));
|
||||
QCOMPARE(format.formatDecimalDuration(1 * MSecsInHour + 10 * MSecsInMinute), QStringLiteral("1.17 hours"));
|
||||
QCOMPARE(format.formatDecimalDuration(1 * MSecsInHour + 10 * MSecsInMinute, 3), QStringLiteral("1.167 hours"));
|
||||
QCOMPARE(format.formatDecimalDuration(1 * MSecsInDay + 10 * MSecsInHour), QStringLiteral("1.42 days"));
|
||||
QCOMPARE(format.formatDecimalDuration(1 * MSecsInDay + 10 * MSecsInHour, 3), QStringLiteral("1.417 days"));
|
||||
}
|
||||
|
||||
void KFormatTest::formatSpelloutDuration()
|
||||
{
|
||||
KFormat format(QLocale::c());
|
||||
|
||||
QCOMPARE(format.formatSpelloutDuration(1000), QStringLiteral("1 second(s)"));
|
||||
QCOMPARE(format.formatSpelloutDuration(5000), QStringLiteral("5 second(s)"));
|
||||
QCOMPARE(format.formatSpelloutDuration(60000), QStringLiteral("1 minute(s)"));
|
||||
QCOMPARE(format.formatSpelloutDuration(300000), QStringLiteral("5 minute(s)"));
|
||||
QCOMPARE(format.formatSpelloutDuration(3600000), QStringLiteral("1 hour(s)"));
|
||||
QCOMPARE(format.formatSpelloutDuration(18000000), QStringLiteral("5 hour(s)"));
|
||||
QCOMPARE(format.formatSpelloutDuration(75000), QStringLiteral("1 minute(s) and 15 second(s)"));
|
||||
// Problematic case #1 (there is a reference to this case on kformat.cpp)
|
||||
QCOMPARE(format.formatSpelloutDuration(119999), QStringLiteral("2 minute(s)"));
|
||||
// This case is strictly 2 hours, 15 minutes and 59 seconds. However, since the range is
|
||||
// pretty high between hours and seconds, formatSpelloutDuration always omits seconds when there
|
||||
// are hours in scene.
|
||||
QCOMPARE(format.formatSpelloutDuration(8159000), QStringLiteral("2 hour(s) and 15 minute(s)"));
|
||||
// This case is strictly 1 hour and 10 seconds. For the same reason, formatSpelloutDuration
|
||||
// detects that 10 seconds is just garbage compared to 1 hour, and omits it on the result.
|
||||
QCOMPARE(format.formatSpelloutDuration(3610000), QStringLiteral("1 hour(s)"));
|
||||
}
|
||||
|
||||
void KFormatTest::formatRelativeDate()
|
||||
{
|
||||
KFormat format(QLocale::c());
|
||||
|
||||
QDate testDate = QDate::currentDate();
|
||||
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Today"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QStringLiteral("Today"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("Today"));
|
||||
|
||||
testDate = QDate::currentDate().addDays(1);
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Tomorrow"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QStringLiteral("Tomorrow"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("Tomorrow"));
|
||||
|
||||
testDate = QDate::currentDate().addDays(-1);
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Yesterday"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QStringLiteral("Yesterday"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("Yesterday"));
|
||||
|
||||
testDate = QDate::currentDate().addDays(2);
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("In two days"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QStringLiteral("In two days"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("In two days"));
|
||||
|
||||
testDate = QDate::currentDate().addDays(-2);
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Two days ago"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QStringLiteral("Two days ago"));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QStringLiteral("Two days ago"));
|
||||
|
||||
testDate = QDate::currentDate().addDays(-3);
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QLocale::c().toString(testDate, QLocale::LongFormat));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QLocale::c().toString(testDate, QLocale::ShortFormat));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QLocale::c().toString(testDate, QLocale::NarrowFormat));
|
||||
|
||||
testDate = QDate::currentDate().addDays(3);
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QLocale::c().toString(testDate, QLocale::LongFormat));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::ShortFormat), QLocale::c().toString(testDate, QLocale::ShortFormat));
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::NarrowFormat), QLocale::c().toString(testDate, QLocale::NarrowFormat));
|
||||
|
||||
testDate = QDate(); // invalid date
|
||||
QCOMPARE(format.formatRelativeDate(testDate, QLocale::LongFormat), QStringLiteral("Invalid date"));
|
||||
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
|
||||
// An hour ago is **usually** today, except after midnight; just bump
|
||||
// to after 2am to make the "today" test work.
|
||||
if (now.time().hour() == 0) {
|
||||
now = now.addSecs(7201);
|
||||
}
|
||||
|
||||
QDateTime testDateTime = now.addSecs(-3600);
|
||||
QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat),
|
||||
QStringLiteral("Today at %1").arg(testDateTime.toString(QStringLiteral("hh:mm:ss"))));
|
||||
|
||||
// 1 second ago
|
||||
now = QDateTime::currentDateTime();
|
||||
testDateTime = now.addSecs(-1);
|
||||
QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat), QStringLiteral("Just now"));
|
||||
|
||||
// 5 minutes ago
|
||||
testDateTime = now.addSecs(-300);
|
||||
QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat), QStringLiteral("5 minute(s) ago"));
|
||||
|
||||
testDateTime = QDateTime(QDate::currentDate().addDays(8), QTime(3, 0, 0));
|
||||
QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::LongFormat),
|
||||
QStringLiteral("%1 at %2")
|
||||
.arg(QLocale::c().toString(testDateTime.date(), QLocale::LongFormat), QLocale::c().toString(testDateTime.time(), QLocale::ShortFormat)));
|
||||
|
||||
// 2021-10-03 07:33:57.000
|
||||
testDateTime = QDateTime::fromMSecsSinceEpoch(1633239237000, Qt::UTC);
|
||||
QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::LongFormat),
|
||||
QStringLiteral("%1 at %2")
|
||||
.arg(QLocale::c().toString(testDateTime.date(), QLocale::LongFormat), QLocale::c().toString(testDateTime.time(), QLocale::ShortFormat)));
|
||||
QCOMPARE(format.formatRelativeDateTime(testDateTime, QLocale::ShortFormat),
|
||||
QStringLiteral("%1 at %2")
|
||||
.arg(QLocale::c().toString(testDateTime.date(), QLocale::ShortFormat), QLocale::c().toString(testDateTime.time(), QLocale::ShortFormat)));
|
||||
|
||||
// With a different local for double check
|
||||
QLocale englishLocal = QLocale::English;
|
||||
KFormat formatEnglish(englishLocal);
|
||||
QCOMPARE(formatEnglish.formatRelativeDateTime(testDateTime, QLocale::LongFormat), QStringLiteral("Sunday, October 3, 2021 at 5:33 AM"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(KFormatTest)
|
||||
|
||||
#include "moc_kformattest.cpp"
|
||||
31
Telegram/ThirdParty/kcoreaddons/autotests/kformattest.h
vendored
Normal file
31
Telegram/ThirdParty/kcoreaddons/autotests/kformattest.h
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
This file is part of the KDE Frameworks
|
||||
|
||||
SPDX-FileCopyrightText: 2013 John Layt <jlayt@kde.org>
|
||||
SPDX-FileCopyrightText: 2010 Michael Leupold <lemma@confuego.org>
|
||||
SPDX-FileCopyrightText: 2009 Michael Pyne <mpyne@kde.org>
|
||||
SPDX-FileCopyrightText: 2008 Albert Astals Cid <aacid@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KFORMATTEST_H
|
||||
#define KFORMATTEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KFormatTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void formatByteSize();
|
||||
void formatDuration();
|
||||
void formatDecimalDuration();
|
||||
void formatSpelloutDuration();
|
||||
void formatRelativeDate();
|
||||
void formatValue();
|
||||
};
|
||||
|
||||
#endif // KFORMATTEST_H
|
||||
237
Telegram/ThirdParty/kcoreaddons/autotests/kfuzzymatchertest.cpp
vendored
Normal file
237
Telegram/ThirdParty/kcoreaddons/autotests/kfuzzymatchertest.cpp
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
#include "kfuzzymatchertest.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QTest>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "kfuzzymatcher.h"
|
||||
|
||||
QTEST_MAIN(KFuzzyMatcherTest)
|
||||
|
||||
void KFuzzyMatcherTest::testMatchSimple_data()
|
||||
{
|
||||
QTest::addColumn<QString>("pattern");
|
||||
QTest::addColumn<QString>("inputstr");
|
||||
QTest::addColumn<bool>("expected");
|
||||
|
||||
QTest::newRow("AbcD") << QStringLiteral("AbcD") << QStringLiteral("AbCdefg") << true;
|
||||
QTest::newRow("WithSpace") << QStringLiteral("Wa qa") << QStringLiteral("Wa qar") << true;
|
||||
QTest::newRow("RTL") << QStringLiteral("ارو") << QStringLiteral("اردو") << true;
|
||||
QTest::newRow("WithSep") << QStringLiteral("tf") << QStringLiteral("the_file") << true;
|
||||
QTest::newRow("Umlaut") << QStringLiteral("Häu") << QStringLiteral("Häuser") << true;
|
||||
QTest::newRow("Unmatched") << QStringLiteral("Name") << QStringLiteral("Nam") << false;
|
||||
QTest::newRow("Empty Pattern") << QString("") << QStringLiteral("Nam") << true;
|
||||
}
|
||||
|
||||
void KFuzzyMatcherTest::testMatchSimple()
|
||||
{
|
||||
QFETCH(QString, pattern);
|
||||
QFETCH(QString, inputstr);
|
||||
QFETCH(bool, expected);
|
||||
|
||||
QVERIFY(KFuzzyMatcher::matchSimple(pattern, inputstr) == expected);
|
||||
}
|
||||
|
||||
void KFuzzyMatcherTest::testMatch_data()
|
||||
{
|
||||
QTest::addColumn<QString>("pattern");
|
||||
QTest::addColumn<QStringList>("input");
|
||||
QTest::addColumn<QStringList>("expected");
|
||||
QTest::addColumn<int>("size");
|
||||
// clang-format off
|
||||
QTest::newRow("pattern=sort") << QStringLiteral("sort")
|
||||
<< QStringList{
|
||||
QStringLiteral("Sort"),
|
||||
QStringLiteral("Some other right test"),
|
||||
QStringLiteral("Soup rate"),
|
||||
QStringLiteral("Someother"),
|
||||
QStringLiteral("irrelevant"),
|
||||
}
|
||||
<< QStringList{
|
||||
QStringLiteral("Sort"),
|
||||
QStringLiteral("Some other right test"),
|
||||
QStringLiteral("Soup rate"),
|
||||
}
|
||||
<< 3;
|
||||
|
||||
|
||||
QTest::newRow("pattern=kateapp") << QStringLiteral("kaapp")
|
||||
<< QStringList{
|
||||
QStringLiteral("kateapp.cpp"),
|
||||
QStringLiteral("kate_application"),
|
||||
QStringLiteral("kateapp.h"),
|
||||
QStringLiteral("katepap.c")
|
||||
}
|
||||
<< QStringList{
|
||||
QStringLiteral("kate_application"),
|
||||
QStringLiteral("kateapp.h"),
|
||||
QStringLiteral("kateapp.cpp")
|
||||
}
|
||||
<< 3;
|
||||
|
||||
QTest::newRow("pattern=this") << QStringLiteral("this")
|
||||
<< QStringList{
|
||||
QStringLiteral("th"),
|
||||
QStringLiteral("ths"),
|
||||
QStringLiteral("thsi")
|
||||
}
|
||||
<< QStringList{
|
||||
}
|
||||
<< 0;
|
||||
|
||||
QTest::newRow("pattern=marath") << QStringLiteral("marath")
|
||||
<< QStringList{
|
||||
QStringLiteral("Maralen of the Mornsong"),
|
||||
QStringLiteral("Silumgar, the Drifting Death"),
|
||||
QStringLiteral("Maralen of the Mornsong Avatar"),
|
||||
QStringLiteral("Marshaling the Troops"),
|
||||
QStringLiteral("Homeward Path"),
|
||||
QStringLiteral("Marath, Will of the Wild"),
|
||||
QStringLiteral("Marshal's Anthem"),
|
||||
QStringLiteral("Marchesa, the Black Rose"),
|
||||
QStringLiteral("Mark for Death"),
|
||||
QStringLiteral("Master Apothecary"),
|
||||
QStringLiteral("Mazirek, Kraul Death Priest"),
|
||||
QStringLiteral("Akroma, Angel of Wrath"),
|
||||
QStringLiteral("Akroma, Angel of Wrath Avatar"),
|
||||
QStringLiteral("Commander's Authority"),
|
||||
QStringLiteral("Shaman of the Great Hunt"),
|
||||
QStringLiteral("Halimar Wavewatch"),
|
||||
QStringLiteral("Pyromancer's Swath")
|
||||
}
|
||||
<< QStringList{
|
||||
QStringLiteral("Marath, Will of the Wild"),
|
||||
QStringLiteral("Maralen of the Mornsong"),
|
||||
QStringLiteral("Maralen of the Mornsong Avatar"),
|
||||
QStringLiteral("Marshal's Anthem"),
|
||||
QStringLiteral("Marshaling the Troops"),
|
||||
QStringLiteral("Marchesa, the Black Rose"),
|
||||
QStringLiteral("Mark for Death"),
|
||||
QStringLiteral("Master Apothecary"),
|
||||
QStringLiteral("Mazirek, Kraul Death Priest"),
|
||||
QStringLiteral("Akroma, Angel of Wrath"),
|
||||
QStringLiteral("Akroma, Angel of Wrath Avatar"),
|
||||
QStringLiteral("Commander's Authority"),
|
||||
QStringLiteral("Homeward Path"),
|
||||
QStringLiteral("Shaman of the Great Hunt"),
|
||||
QStringLiteral("Halimar Wavewatch"),
|
||||
QStringLiteral("Pyromancer's Swath"),
|
||||
QStringLiteral("Silumgar, the Drifting Death")
|
||||
}
|
||||
<< 17;
|
||||
|
||||
// This tests our recursive best match
|
||||
QTest::newRow("pattern=lll") << QStringLiteral("lll")
|
||||
<< QStringList{
|
||||
QStringLiteral("SVisualLoggerLogsList.h"),
|
||||
QStringLiteral("SimpleFileLogger.cpp"),
|
||||
QStringLiteral("StringHandlerLogList.txt"),
|
||||
QStringLiteral("LeapFromLostAllan"),
|
||||
QStringLiteral("BumpLLL"),
|
||||
}
|
||||
<< QStringList{
|
||||
QStringLiteral("SVisualLoggerLogsList.h"),
|
||||
QStringLiteral("LeapFromLostAllan"),
|
||||
QStringLiteral("BumpLLL"),
|
||||
QStringLiteral("StringHandlerLogList.txt"),
|
||||
QStringLiteral("SimpleFileLogger.cpp"),
|
||||
}
|
||||
<< 5;
|
||||
|
||||
QTest::newRow("pattern=") << QString("")
|
||||
<< QStringList{
|
||||
QStringLiteral("th"),
|
||||
QStringLiteral("ths"),
|
||||
QStringLiteral("thsi")
|
||||
}
|
||||
<< QStringList{
|
||||
QStringLiteral("th"),
|
||||
QStringLiteral("ths"),
|
||||
QStringLiteral("thsi")
|
||||
}
|
||||
<< 3;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
static QStringList matchHelper(const QString &pattern, const QStringList &input)
|
||||
{
|
||||
QVector<QPair<QString, int>> actual;
|
||||
for (int i = 0; i < input.size(); ++i) {
|
||||
KFuzzyMatcher::Result res = KFuzzyMatcher::match(pattern, input.at(i));
|
||||
if (res.matched) {
|
||||
actual.push_back({input.at(i), res.score});
|
||||
}
|
||||
}
|
||||
|
||||
// sort descending based on score
|
||||
std::sort(actual.begin(), actual.end(), [](const QPair<QString, int> &l, const QPair<QString, int> &r) {
|
||||
return l.second > r.second;
|
||||
});
|
||||
|
||||
QStringList actualOut;
|
||||
for (const auto &s : actual) {
|
||||
actualOut << s.first;
|
||||
}
|
||||
return actualOut;
|
||||
}
|
||||
|
||||
void KFuzzyMatcherTest::testMatch()
|
||||
{
|
||||
QFETCH(QString, pattern);
|
||||
QFETCH(QStringList, input);
|
||||
QFETCH(QStringList, expected);
|
||||
QFETCH(int, size);
|
||||
|
||||
const QStringList actual = matchHelper(pattern, input);
|
||||
|
||||
QCOMPARE(actual.size(), size);
|
||||
QCOMPARE(actual, expected);
|
||||
}
|
||||
|
||||
void KFuzzyMatcherTest::testMatchedRanges_data()
|
||||
{
|
||||
QTest::addColumn<QString>("pattern");
|
||||
QTest::addColumn<QString>("string");
|
||||
|
||||
using Range = QPair<int, int>;
|
||||
QTest::addColumn<QVector<Range>>("expectedRanges");
|
||||
|
||||
QTest::addColumn<bool>("matchingOnly");
|
||||
|
||||
QTest::newRow("Emtpy") << QString("") << QString("") << QVector<Range>{} << true;
|
||||
QTest::newRow("Hello") << QStringLiteral("Hlo") << QStringLiteral("Hello") << QVector<Range>{{0, 1}, {3, 2}} << true;
|
||||
QTest::newRow("lll") << QStringLiteral("lll") << QStringLiteral("SVisualLoggerLogsList") << QVector<Range>{{7, 1}, {13, 1}, {17, 1}} << true;
|
||||
QTest::newRow("Sort") << QStringLiteral("sort") << QStringLiteral("SorT") << QVector<Range>{{0, 4}} << true;
|
||||
QTest::newRow("Unmatching") << QStringLiteral("git") << QStringLiteral("gti") << QVector<Range>{} << true;
|
||||
QTest::newRow("UnmatchingWithAllMatches") << QStringLiteral("git") << QStringLiteral("gti") << QVector<Range>{{0, 1}, {2, 1}} << false;
|
||||
}
|
||||
|
||||
void KFuzzyMatcherTest::testMatchedRanges()
|
||||
{
|
||||
QFETCH(QString, pattern);
|
||||
QFETCH(QString, string);
|
||||
QFETCH(bool, matchingOnly);
|
||||
using Range = QPair<int, int>;
|
||||
QFETCH(QVector<Range>, expectedRanges);
|
||||
|
||||
const auto matchMode = matchingOnly ? KFuzzyMatcher::RangeType::FullyMatched : KFuzzyMatcher::RangeType::All;
|
||||
|
||||
auto resultRanges = KFuzzyMatcher::matchedRanges(pattern, string, matchMode);
|
||||
QCOMPARE(resultRanges.size(), expectedRanges.size());
|
||||
|
||||
bool res = std::equal(expectedRanges.begin(), expectedRanges.end(), resultRanges.begin(), [](const Range &l, const KFuzzyMatcher::Range &r) {
|
||||
return l.first == r.start && l.second == r.length;
|
||||
});
|
||||
QVERIFY(res);
|
||||
}
|
||||
|
||||
#include "moc_kfuzzymatchertest.cpp"
|
||||
26
Telegram/ThirdParty/kcoreaddons/autotests/kfuzzymatchertest.h
vendored
Normal file
26
Telegram/ThirdParty/kcoreaddons/autotests/kfuzzymatchertest.h
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
#ifndef KFUZZYMATCHERTEST_H
|
||||
#define KFUZZYMATCHERTEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KFuzzyMatcherTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void testMatchSimple_data();
|
||||
void testMatchSimple();
|
||||
void testMatch_data();
|
||||
void testMatch();
|
||||
void testMatchedRanges_data();
|
||||
void testMatchedRanges();
|
||||
};
|
||||
|
||||
#endif // KFUZZYMATCHERTEST_H
|
||||
613
Telegram/ThirdParty/kcoreaddons/autotests/kjobtest.cpp
vendored
Normal file
613
Telegram/ThirdParty/kcoreaddons/autotests/kjobtest.cpp
vendored
Normal file
@@ -0,0 +1,613 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "kjobtest.h"
|
||||
|
||||
#include <QMetaEnum>
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
#include <QTimer>
|
||||
#include <QVector>
|
||||
|
||||
#include <string>
|
||||
|
||||
QTEST_MAIN(KJobTest)
|
||||
|
||||
KJobTest::KJobTest()
|
||||
: loop(this)
|
||||
{
|
||||
}
|
||||
|
||||
void KJobTest::testEmitResult_data()
|
||||
{
|
||||
QTest::addColumn<int>("errorCode");
|
||||
QTest::addColumn<QString>("errorText");
|
||||
|
||||
QTest::newRow("no error") << int(KJob::NoError) << QString();
|
||||
QTest::newRow("error no text") << 2 << QString();
|
||||
QTest::newRow("error with text") << 6 << "oops! an error? naaah, really?";
|
||||
}
|
||||
|
||||
void KJobTest::testEmitResult()
|
||||
{
|
||||
TestJob *job = new TestJob;
|
||||
|
||||
connect(job, &KJob::result, this, [this](KJob *job) {
|
||||
slotResult(job);
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QFETCH(int, errorCode);
|
||||
QFETCH(QString, errorText);
|
||||
|
||||
job->setError(errorCode);
|
||||
job->setErrorText(errorText);
|
||||
|
||||
QSignalSpy destroyed_spy(job, &QObject::destroyed);
|
||||
job->start();
|
||||
QVERIFY(!job->isFinished());
|
||||
loop.exec();
|
||||
QVERIFY(job->isFinished());
|
||||
|
||||
QCOMPARE(m_lastError, errorCode);
|
||||
QCOMPARE(m_lastErrorText, errorText);
|
||||
|
||||
// Verify that the job is not deleted immediately...
|
||||
QCOMPARE(destroyed_spy.size(), 0);
|
||||
QTimer::singleShot(0, &loop, &QEventLoop::quit);
|
||||
// ... but when we enter the event loop again.
|
||||
loop.exec();
|
||||
QCOMPARE(destroyed_spy.size(), 1);
|
||||
}
|
||||
|
||||
void KJobTest::testProgressTracking()
|
||||
{
|
||||
TestJob *testJob = new TestJob;
|
||||
KJob *job = testJob;
|
||||
|
||||
qRegisterMetaType<KJob *>("KJob*");
|
||||
qRegisterMetaType<qulonglong>("qulonglong");
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QSignalSpy processed_spy(job, qOverload<KJob *, KJob::Unit, qulonglong>(&KJob::processedAmount));
|
||||
QSignalSpy total_spy(job, qOverload<KJob *, KJob::Unit, qulonglong>(&KJob::totalAmount));
|
||||
QSignalSpy percent_spy(job, qOverload<KJob *, ulong>(&KJob::percent));
|
||||
#endif
|
||||
QSignalSpy processedChanged_spy(job, &KJob::processedAmountChanged);
|
||||
QSignalSpy totalChanged_spy(job, &KJob::totalAmountChanged);
|
||||
QSignalSpy percentChanged_spy(job, &KJob::percentChanged);
|
||||
|
||||
/* Process a first item. Corresponding signal should be emitted.
|
||||
* Total size didn't change.
|
||||
* Since the total size is unknown, no percent signal is emitted.
|
||||
*/
|
||||
testJob->setProcessedSize(1);
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(processed_spy.size(), 1);
|
||||
QCOMPARE(processed_spy.at(0).at(0).value<KJob *>(), static_cast<KJob *>(job));
|
||||
QCOMPARE(processed_spy.at(0).at(2).value<qulonglong>(), qulonglong(1));
|
||||
QCOMPARE(total_spy.size(), 0);
|
||||
QCOMPARE(percent_spy.size(), 0);
|
||||
#endif
|
||||
QCOMPARE(processedChanged_spy.size(), 1);
|
||||
QCOMPARE(processedChanged_spy.at(0).at(0).value<KJob *>(), static_cast<KJob *>(job));
|
||||
QCOMPARE(processedChanged_spy.at(0).at(2).value<qulonglong>(), qulonglong(1));
|
||||
QCOMPARE(totalChanged_spy.size(), 0);
|
||||
QCOMPARE(percentChanged_spy.size(), 0);
|
||||
|
||||
/* Now, we know the total size. It's signaled.
|
||||
* The new percentage is signaled too.
|
||||
*/
|
||||
testJob->setTotalSize(10);
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(processed_spy.size(), 1);
|
||||
QCOMPARE(total_spy.size(), 1);
|
||||
QCOMPARE(total_spy.at(0).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(total_spy.at(0).at(2).value<qulonglong>(), qulonglong(10));
|
||||
QCOMPARE(percent_spy.size(), 1);
|
||||
QCOMPARE(percent_spy.at(0).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percent_spy.at(0).at(1).value<unsigned long>(), static_cast<unsigned long>(10));
|
||||
#endif
|
||||
QCOMPARE(processedChanged_spy.size(), 1);
|
||||
QCOMPARE(totalChanged_spy.size(), 1);
|
||||
QCOMPARE(totalChanged_spy.at(0).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(totalChanged_spy.at(0).at(2).value<qulonglong>(), qulonglong(10));
|
||||
QCOMPARE(percentChanged_spy.size(), 1);
|
||||
QCOMPARE(percentChanged_spy.at(0).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percentChanged_spy.at(0).at(1).value<unsigned long>(), static_cast<unsigned long>(10));
|
||||
|
||||
/* We announce a new percentage by hand.
|
||||
* Total, and processed didn't change, so no signal is emitted for them.
|
||||
*/
|
||||
testJob->setPercent(15);
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(processed_spy.size(), 1);
|
||||
QCOMPARE(total_spy.size(), 1);
|
||||
QCOMPARE(percent_spy.size(), 2);
|
||||
QCOMPARE(percent_spy.at(1).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percent_spy.at(1).at(1).value<unsigned long>(), static_cast<unsigned long>(15));
|
||||
#endif
|
||||
QCOMPARE(processedChanged_spy.size(), 1);
|
||||
QCOMPARE(totalChanged_spy.size(), 1);
|
||||
QCOMPARE(percentChanged_spy.size(), 2);
|
||||
QCOMPARE(percentChanged_spy.at(1).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percentChanged_spy.at(1).at(1).value<unsigned long>(), static_cast<unsigned long>(15));
|
||||
|
||||
/* We make some progress.
|
||||
* Processed size and percent are signaled.
|
||||
*/
|
||||
testJob->setProcessedSize(3);
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(processed_spy.size(), 2);
|
||||
QCOMPARE(processed_spy.at(1).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(processed_spy.at(1).at(2).value<qulonglong>(), qulonglong(3));
|
||||
QCOMPARE(total_spy.size(), 1);
|
||||
QCOMPARE(percent_spy.size(), 3);
|
||||
QCOMPARE(percent_spy.at(2).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percent_spy.at(2).at(1).value<unsigned long>(), static_cast<unsigned long>(30));
|
||||
#endif
|
||||
QCOMPARE(processedChanged_spy.size(), 2);
|
||||
QCOMPARE(processedChanged_spy.at(1).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(processedChanged_spy.at(1).at(2).value<qulonglong>(), qulonglong(3));
|
||||
QCOMPARE(totalChanged_spy.size(), 1);
|
||||
QCOMPARE(percentChanged_spy.size(), 3);
|
||||
QCOMPARE(percentChanged_spy.at(2).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percentChanged_spy.at(2).at(1).value<unsigned long>(), static_cast<unsigned long>(30));
|
||||
|
||||
/* We set a new total size, but equals to the previous one.
|
||||
* No signal is emitted.
|
||||
*/
|
||||
testJob->setTotalSize(10);
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(processed_spy.size(), 2);
|
||||
QCOMPARE(total_spy.size(), 1);
|
||||
QCOMPARE(percent_spy.size(), 3);
|
||||
#endif
|
||||
QCOMPARE(processedChanged_spy.size(), 2);
|
||||
QCOMPARE(totalChanged_spy.size(), 1);
|
||||
QCOMPARE(percentChanged_spy.size(), 3);
|
||||
|
||||
/* We 'lost' the previous work done.
|
||||
* Signals both percentage and new processed size.
|
||||
*/
|
||||
testJob->setProcessedSize(0);
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(processed_spy.size(), 3);
|
||||
QCOMPARE(processed_spy.at(2).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(processed_spy.at(2).at(2).value<qulonglong>(), qulonglong(0));
|
||||
QCOMPARE(total_spy.size(), 1);
|
||||
QCOMPARE(percent_spy.size(), 4);
|
||||
QCOMPARE(percent_spy.at(3).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percent_spy.at(3).at(1).value<unsigned long>(), static_cast<unsigned long>(0));
|
||||
#endif
|
||||
QCOMPARE(processedChanged_spy.size(), 3);
|
||||
QCOMPARE(processedChanged_spy.at(2).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(processedChanged_spy.at(2).at(2).value<qulonglong>(), qulonglong(0));
|
||||
QCOMPARE(totalChanged_spy.size(), 1);
|
||||
QCOMPARE(percentChanged_spy.size(), 4);
|
||||
QCOMPARE(percentChanged_spy.at(3).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percentChanged_spy.at(3).at(1).value<unsigned long>(), static_cast<unsigned long>(0));
|
||||
|
||||
/* We process more than the total size!?
|
||||
* Signals both percentage and new processed size.
|
||||
* Percentage is 150%
|
||||
*
|
||||
* Might sounds weird, but verify that this case is handled gracefully.
|
||||
*/
|
||||
testJob->setProcessedSize(15);
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(processed_spy.size(), 4);
|
||||
QCOMPARE(processed_spy.at(3).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(processed_spy.at(3).at(2).value<qulonglong>(), qulonglong(15));
|
||||
QCOMPARE(total_spy.size(), 1);
|
||||
QCOMPARE(percent_spy.size(), 5);
|
||||
QCOMPARE(percent_spy.at(4).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percent_spy.at(4).at(1).value<unsigned long>(), static_cast<unsigned long>(150));
|
||||
#endif
|
||||
QCOMPARE(processedChanged_spy.size(), 4);
|
||||
QCOMPARE(processedChanged_spy.at(3).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(processedChanged_spy.at(3).at(2).value<qulonglong>(), qulonglong(15));
|
||||
QCOMPARE(totalChanged_spy.size(), 1);
|
||||
QCOMPARE(percentChanged_spy.size(), 5);
|
||||
QCOMPARE(percentChanged_spy.at(4).at(0).value<KJob *>(), job);
|
||||
QCOMPARE(percentChanged_spy.at(4).at(1).value<unsigned long>(), static_cast<unsigned long>(150));
|
||||
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
processed_spy.clear();
|
||||
total_spy.clear();
|
||||
percent_spy.clear();
|
||||
#endif
|
||||
processedChanged_spy.clear();
|
||||
totalChanged_spy.clear();
|
||||
percentChanged_spy.clear();
|
||||
|
||||
/**
|
||||
* Try again with Files as the progress unit
|
||||
*/
|
||||
testJob->setProgressUnit(KJob::Files);
|
||||
testJob->setProcessedSize(16);
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(percent_spy.size(), 0); // no impact on percent
|
||||
#endif
|
||||
QCOMPARE(percentChanged_spy.size(), 0);
|
||||
|
||||
testJob->setTotalFiles(5);
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(percent_spy.size(), 1);
|
||||
QCOMPARE(percent_spy.at(0).at(1).value<unsigned long>(), static_cast<unsigned long>(0));
|
||||
#endif
|
||||
QCOMPARE(percentChanged_spy.size(), 1);
|
||||
QCOMPARE(percentChanged_spy.at(0).at(1).value<unsigned long>(), static_cast<unsigned long>(0));
|
||||
|
||||
testJob->setProcessedFiles(2);
|
||||
#if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 80)
|
||||
QCOMPARE(percent_spy.size(), 2);
|
||||
QCOMPARE(percent_spy.at(1).at(1).value<unsigned long>(), static_cast<unsigned long>(40));
|
||||
#endif
|
||||
QCOMPARE(percentChanged_spy.size(), 2);
|
||||
QCOMPARE(percentChanged_spy.at(1).at(1).value<unsigned long>(), static_cast<unsigned long>(40));
|
||||
|
||||
delete job;
|
||||
}
|
||||
|
||||
void KJobTest::testExec_data()
|
||||
{
|
||||
QTest::addColumn<int>("errorCode");
|
||||
QTest::addColumn<QString>("errorText");
|
||||
|
||||
QTest::newRow("no error") << int(KJob::NoError) << QString();
|
||||
QTest::newRow("error no text") << 2 << QString();
|
||||
QTest::newRow("error with text") << 6 << "oops! an error? naaah, really?";
|
||||
}
|
||||
|
||||
void KJobTest::testExec()
|
||||
{
|
||||
TestJob *job = new TestJob;
|
||||
|
||||
QFETCH(int, errorCode);
|
||||
QFETCH(QString, errorText);
|
||||
|
||||
job->setError(errorCode);
|
||||
job->setErrorText(errorText);
|
||||
|
||||
int resultEmitted = 0;
|
||||
// Prove to Kai Uwe that one can connect a job to a lambdas, despite the "private" signal
|
||||
connect(job, &KJob::result, this, [&resultEmitted](KJob *) {
|
||||
++resultEmitted;
|
||||
});
|
||||
|
||||
QSignalSpy destroyed_spy(job, &QObject::destroyed);
|
||||
|
||||
QVERIFY(!job->isFinished());
|
||||
bool status = job->exec();
|
||||
QVERIFY(job->isFinished());
|
||||
|
||||
QCOMPARE(resultEmitted, 1);
|
||||
QCOMPARE(status, (errorCode == KJob::NoError));
|
||||
QCOMPARE(job->error(), errorCode);
|
||||
QCOMPARE(job->errorText(), errorText);
|
||||
|
||||
// Verify that the job is not deleted immediately...
|
||||
QCOMPARE(destroyed_spy.size(), 0);
|
||||
QTimer::singleShot(0, &loop, &QEventLoop::quit);
|
||||
// ... but when we enter the event loop again.
|
||||
loop.exec();
|
||||
QCOMPARE(destroyed_spy.size(), 1);
|
||||
}
|
||||
|
||||
void KJobTest::testKill_data()
|
||||
{
|
||||
QTest::addColumn<int>("killVerbosity");
|
||||
QTest::addColumn<int>("errorCode");
|
||||
QTest::addColumn<QString>("errorText");
|
||||
QTest::addColumn<int>("resultEmitCount");
|
||||
QTest::addColumn<int>("finishedEmitCount");
|
||||
|
||||
QTest::newRow("killed with result") << int(KJob::EmitResult) << int(KJob::KilledJobError) << QString() << 1 << 1;
|
||||
QTest::newRow("killed quietly") << int(KJob::Quietly) << int(KJob::KilledJobError) << QString() << 0 << 1;
|
||||
}
|
||||
|
||||
void KJobTest::testKill()
|
||||
{
|
||||
auto *const job = setupErrorResultFinished();
|
||||
QSignalSpy destroyed_spy(job, &QObject::destroyed);
|
||||
|
||||
QFETCH(int, killVerbosity);
|
||||
QFETCH(int, errorCode);
|
||||
QFETCH(QString, errorText);
|
||||
QFETCH(int, resultEmitCount);
|
||||
QFETCH(int, finishedEmitCount);
|
||||
|
||||
QVERIFY(!job->isFinished());
|
||||
job->kill(static_cast<KJob::KillVerbosity>(killVerbosity));
|
||||
QVERIFY(job->isFinished());
|
||||
loop.processEvents(QEventLoop::AllEvents, 2000);
|
||||
|
||||
QCOMPARE(m_lastError, errorCode);
|
||||
QCOMPARE(m_lastErrorText, errorText);
|
||||
|
||||
QCOMPARE(job->error(), errorCode);
|
||||
QCOMPARE(job->errorText(), errorText);
|
||||
|
||||
QCOMPARE(m_resultCount, resultEmitCount);
|
||||
QCOMPARE(m_finishedCount, finishedEmitCount);
|
||||
|
||||
// Verify that the job is not deleted immediately...
|
||||
QCOMPARE(destroyed_spy.size(), 0);
|
||||
QTimer::singleShot(0, &loop, &QEventLoop::quit);
|
||||
// ... but when we enter the event loop again.
|
||||
loop.exec();
|
||||
QCOMPARE(destroyed_spy.size(), 1);
|
||||
|
||||
QVERIFY(m_jobFinishCount.size() == (finishedEmitCount - resultEmitCount));
|
||||
m_jobFinishCount.clear();
|
||||
}
|
||||
|
||||
void KJobTest::testDestroy()
|
||||
{
|
||||
auto *const job = setupErrorResultFinished();
|
||||
QVERIFY(!job->isFinished());
|
||||
delete job;
|
||||
QCOMPARE(m_lastError, static_cast<int>(KJob::NoError));
|
||||
QCOMPARE(m_lastErrorText, QString{});
|
||||
QCOMPARE(m_resultCount, 0);
|
||||
QCOMPARE(m_finishedCount, 1);
|
||||
|
||||
QVERIFY(m_jobFinishCount.size() == 1);
|
||||
m_jobFinishCount.clear();
|
||||
}
|
||||
|
||||
void KJobTest::testEmitAtMostOnce_data()
|
||||
{
|
||||
QTest::addColumn<bool>("autoDelete");
|
||||
QTest::addColumn<QVector<Action>>("actions");
|
||||
|
||||
const auto actionName = [](Action action) {
|
||||
return QMetaEnum::fromType<Action>().valueToKey(static_cast<int>(action));
|
||||
};
|
||||
|
||||
for (bool autoDelete : {true, false}) {
|
||||
for (Action a : {Action::Start, Action::KillQuietly, Action::KillVerbosely}) {
|
||||
for (Action b : {Action::Start, Action::KillQuietly, Action::KillVerbosely}) {
|
||||
const auto dataTag = std::string{actionName(a)} + '-' + actionName(b) + (autoDelete ? "-autoDelete" : "");
|
||||
QTest::newRow(dataTag.c_str()) << autoDelete << QVector<Action>{a, b};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KJobTest::testEmitAtMostOnce()
|
||||
{
|
||||
auto *const job = setupErrorResultFinished();
|
||||
QSignalSpy destroyed_spy(job, &QObject::destroyed);
|
||||
|
||||
QFETCH(bool, autoDelete);
|
||||
job->setAutoDelete(autoDelete);
|
||||
|
||||
QFETCH(QVector<Action>, actions);
|
||||
for (auto action : actions) {
|
||||
switch (action) {
|
||||
case Action::Start:
|
||||
job->start(); // in effect calls QTimer::singleShot(0, ... emitResult)
|
||||
break;
|
||||
case Action::KillQuietly:
|
||||
QTimer::singleShot(0, job, [=] {
|
||||
job->kill(KJob::Quietly);
|
||||
});
|
||||
break;
|
||||
case Action::KillVerbosely:
|
||||
QTimer::singleShot(0, job, [=] {
|
||||
job->kill(KJob::EmitResult);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QVERIFY(!job->isFinished());
|
||||
loop.processEvents(QEventLoop::AllEvents, 2000);
|
||||
QCOMPARE(destroyed_spy.size(), autoDelete);
|
||||
if (!autoDelete) {
|
||||
QVERIFY(job->isFinished());
|
||||
}
|
||||
|
||||
QVERIFY(!actions.empty());
|
||||
// The first action alone should determine the job's error and result.
|
||||
const auto firstAction = actions.front();
|
||||
|
||||
const int errorCode = firstAction == Action::Start ? KJob::NoError : KJob::KilledJobError;
|
||||
QCOMPARE(m_lastError, errorCode);
|
||||
QCOMPARE(m_lastErrorText, QString{});
|
||||
if (!autoDelete) {
|
||||
QCOMPARE(job->error(), m_lastError);
|
||||
QCOMPARE(job->errorText(), m_lastErrorText);
|
||||
}
|
||||
|
||||
QCOMPARE(m_resultCount, firstAction == Action::KillQuietly ? 0 : 1);
|
||||
QCOMPARE(m_finishedCount, 1);
|
||||
|
||||
if (!autoDelete) {
|
||||
delete job;
|
||||
}
|
||||
}
|
||||
|
||||
void KJobTest::testDelegateUsage()
|
||||
{
|
||||
TestJob *job1 = new TestJob;
|
||||
TestJob *job2 = new TestJob;
|
||||
TestJobUiDelegate *delegate = new TestJobUiDelegate;
|
||||
QPointer<TestJobUiDelegate> guard(delegate);
|
||||
|
||||
QVERIFY(job1->uiDelegate() == nullptr);
|
||||
job1->setUiDelegate(delegate);
|
||||
QVERIFY(job1->uiDelegate() == delegate);
|
||||
|
||||
QVERIFY(job2->uiDelegate() == nullptr);
|
||||
job2->setUiDelegate(delegate);
|
||||
QVERIFY(job2->uiDelegate() == nullptr);
|
||||
|
||||
delete job1;
|
||||
delete job2;
|
||||
QVERIFY(guard.isNull()); // deleted by job1
|
||||
}
|
||||
|
||||
void KJobTest::testNestedExec()
|
||||
{
|
||||
m_innerJob = nullptr;
|
||||
QTimer::singleShot(100, this, &KJobTest::slotStartInnerJob);
|
||||
m_outerJob = new WaitJob();
|
||||
m_outerJob->exec();
|
||||
}
|
||||
|
||||
void KJobTest::slotStartInnerJob()
|
||||
{
|
||||
QTimer::singleShot(100, this, &KJobTest::slotFinishOuterJob);
|
||||
m_innerJob = new WaitJob();
|
||||
m_innerJob->exec();
|
||||
}
|
||||
|
||||
void KJobTest::slotFinishOuterJob()
|
||||
{
|
||||
QTimer::singleShot(100, this, &KJobTest::slotFinishInnerJob);
|
||||
m_outerJob->makeItFinish();
|
||||
}
|
||||
|
||||
void KJobTest::slotFinishInnerJob()
|
||||
{
|
||||
m_innerJob->makeItFinish();
|
||||
}
|
||||
|
||||
void KJobTest::slotResult(KJob *job)
|
||||
{
|
||||
const auto testJob = qobject_cast<const TestJob *>(job);
|
||||
QVERIFY(testJob);
|
||||
QVERIFY(testJob->isFinished());
|
||||
|
||||
// Ensure the job has already emitted finished() if we are tracking from
|
||||
// setupErrorResultFinished
|
||||
if (m_jobFinishCount.contains(job)) {
|
||||
QVERIFY(m_jobFinishCount.value(job) == 1);
|
||||
QVERIFY(m_jobFinishCount.remove(job) == 1 /* num items removed */);
|
||||
}
|
||||
|
||||
if (job->error()) {
|
||||
m_lastError = job->error();
|
||||
m_lastErrorText = job->errorText();
|
||||
} else {
|
||||
m_lastError = KJob::NoError;
|
||||
m_lastErrorText.clear();
|
||||
}
|
||||
|
||||
m_resultCount++;
|
||||
}
|
||||
|
||||
void KJobTest::slotFinished(KJob *job)
|
||||
{
|
||||
QVERIFY2(m_jobFinishCount.value(job) == 0, "Ensure we have not double-emitted KJob::finished()");
|
||||
m_jobFinishCount[job]++;
|
||||
|
||||
if (job->error()) {
|
||||
m_lastError = job->error();
|
||||
m_lastErrorText = job->errorText();
|
||||
} else {
|
||||
m_lastError = KJob::NoError;
|
||||
m_lastErrorText.clear();
|
||||
}
|
||||
|
||||
m_finishedCount++;
|
||||
}
|
||||
|
||||
TestJob *KJobTest::setupErrorResultFinished()
|
||||
{
|
||||
m_lastError = KJob::UserDefinedError;
|
||||
m_lastErrorText.clear();
|
||||
m_resultCount = 0;
|
||||
m_finishedCount = 0;
|
||||
|
||||
auto *job = new TestJob;
|
||||
m_jobFinishCount[job] = 0;
|
||||
connect(job, &KJob::result, this, &KJobTest::slotResult);
|
||||
connect(job, &KJob::finished, this, &KJobTest::slotFinished);
|
||||
return job;
|
||||
}
|
||||
|
||||
TestJob::TestJob()
|
||||
: KJob()
|
||||
{
|
||||
}
|
||||
|
||||
TestJob::~TestJob()
|
||||
{
|
||||
}
|
||||
|
||||
void TestJob::start()
|
||||
{
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
emitResult();
|
||||
});
|
||||
}
|
||||
|
||||
bool TestJob::doKill()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void TestJob::setError(int errorCode)
|
||||
{
|
||||
KJob::setError(errorCode);
|
||||
}
|
||||
|
||||
void TestJob::setErrorText(const QString &errorText)
|
||||
{
|
||||
KJob::setErrorText(errorText);
|
||||
}
|
||||
|
||||
void TestJob::setProcessedSize(qulonglong size)
|
||||
{
|
||||
KJob::setProcessedAmount(KJob::Bytes, size);
|
||||
}
|
||||
|
||||
void TestJob::setTotalSize(qulonglong size)
|
||||
{
|
||||
KJob::setTotalAmount(KJob::Bytes, size);
|
||||
}
|
||||
|
||||
void TestJob::setProcessedFiles(qulonglong files)
|
||||
{
|
||||
KJob::setProcessedAmount(KJob::Files, files);
|
||||
}
|
||||
|
||||
void TestJob::setTotalFiles(qulonglong files)
|
||||
{
|
||||
KJob::setTotalAmount(KJob::Files, files);
|
||||
}
|
||||
|
||||
void TestJob::setPercent(unsigned long percentage)
|
||||
{
|
||||
KJob::setPercent(percentage);
|
||||
}
|
||||
|
||||
void WaitJob::start()
|
||||
{
|
||||
}
|
||||
|
||||
void WaitJob::makeItFinish()
|
||||
{
|
||||
emitResult();
|
||||
}
|
||||
|
||||
void TestJobUiDelegate::connectJob(KJob *job)
|
||||
{
|
||||
QVERIFY(job->uiDelegate() != nullptr);
|
||||
}
|
||||
|
||||
#include "moc_kjobtest.cpp"
|
||||
109
Telegram/ThirdParty/kcoreaddons/autotests/kjobtest.h
vendored
Normal file
109
Telegram/ThirdParty/kcoreaddons/autotests/kjobtest.h
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#ifndef KJOBTEST_H
|
||||
#define KJOBTEST_H
|
||||
|
||||
#include "kjob.h"
|
||||
#include "kjobuidelegate.h"
|
||||
#include <QEventLoop>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
|
||||
class TestJob : public KJob
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestJob();
|
||||
~TestJob() override;
|
||||
|
||||
void start() override;
|
||||
using KJob::isFinished;
|
||||
using KJob::setProgressUnit;
|
||||
|
||||
protected:
|
||||
bool doKill() override;
|
||||
|
||||
public:
|
||||
void setError(int errorCode);
|
||||
void setErrorText(const QString &errorText);
|
||||
void setProcessedSize(qulonglong size);
|
||||
void setTotalSize(qulonglong size);
|
||||
void setProcessedFiles(qulonglong files);
|
||||
void setTotalFiles(qulonglong files);
|
||||
void setPercent(unsigned long percentage);
|
||||
};
|
||||
|
||||
class TestJobUiDelegate : public KJobUiDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
virtual void connectJob(KJob *job);
|
||||
};
|
||||
|
||||
class WaitJob;
|
||||
|
||||
class KJobTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Action {
|
||||
Start,
|
||||
KillQuietly,
|
||||
KillVerbosely,
|
||||
};
|
||||
Q_ENUM(Action)
|
||||
|
||||
KJobTest();
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
// These slots need to be public, otherwise qtestlib calls them as part of the test
|
||||
void slotStartInnerJob();
|
||||
void slotFinishOuterJob();
|
||||
void slotFinishInnerJob();
|
||||
|
||||
private Q_SLOTS:
|
||||
void testEmitResult_data();
|
||||
void testEmitResult();
|
||||
void testProgressTracking();
|
||||
void testExec_data();
|
||||
void testExec();
|
||||
void testKill_data();
|
||||
void testKill();
|
||||
void testDestroy();
|
||||
void testEmitAtMostOnce_data();
|
||||
void testEmitAtMostOnce();
|
||||
void testDelegateUsage();
|
||||
void testNestedExec();
|
||||
|
||||
void slotResult(KJob *job);
|
||||
void slotFinished(KJob *job);
|
||||
|
||||
private:
|
||||
TestJob *setupErrorResultFinished();
|
||||
|
||||
QEventLoop loop;
|
||||
int m_lastError;
|
||||
QString m_lastErrorText;
|
||||
int m_resultCount;
|
||||
int m_finishedCount;
|
||||
|
||||
WaitJob *m_outerJob;
|
||||
WaitJob *m_innerJob;
|
||||
QMap<KJob *, int> m_jobFinishCount;
|
||||
};
|
||||
|
||||
class WaitJob : public KJob
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
void start() override;
|
||||
void makeItFinish();
|
||||
};
|
||||
|
||||
#endif
|
||||
56
Telegram/ThirdParty/kcoreaddons/autotests/klibexectest.cpp
vendored
Normal file
56
Telegram/ThirdParty/kcoreaddons/autotests/klibexectest.cpp
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org>
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <KLibexec>
|
||||
|
||||
class KLibexecTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
const QString m_relative = QStringLiteral("fakeexec/kf" QT_STRINGIFY(QT_VERSION_MAJOR));
|
||||
const QString m_fixtureName =
|
||||
#ifdef Q_OS_WIN
|
||||
QStringLiteral("klibexectest-fixture-binary.exe");
|
||||
#else
|
||||
QStringLiteral("klibexectest-fixture-binary");
|
||||
#endif
|
||||
QString m_fixtureDir;
|
||||
QString m_fixturePath;
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase()
|
||||
{
|
||||
m_fixtureDir = QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() + m_relative);
|
||||
m_fixturePath = QDir::cleanPath(m_fixtureDir + QDir::separator() + m_fixtureName);
|
||||
QVERIFY(QDir().mkpath(m_fixtureDir));
|
||||
QFile fixture(m_fixturePath);
|
||||
QVERIFY(fixture.open(QFile::ReadWrite));
|
||||
fixture.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner);
|
||||
|
||||
m_fixtureDir = QFileInfo(m_fixtureDir).canonicalFilePath();
|
||||
m_fixturePath = QFileInfo(m_fixtureDir).canonicalFilePath();
|
||||
}
|
||||
|
||||
void testPath()
|
||||
{
|
||||
QCOMPARE(KLibexec::path(m_relative), m_fixtureDir);
|
||||
}
|
||||
|
||||
void testKDEFrameworksPaths()
|
||||
{
|
||||
auto paths = KLibexec::kdeFrameworksPaths(m_relative);
|
||||
QVERIFY(paths.contains(QCoreApplication::applicationDirPath()));
|
||||
QVERIFY(paths.contains(m_fixtureDir));
|
||||
// not exhaustive verification
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(KLibexecTest)
|
||||
|
||||
#include "klibexectest.moc"
|
||||
149
Telegram/ThirdParty/kcoreaddons/autotests/klistopenfilesjobtest_unix.cpp
vendored
Normal file
149
Telegram/ThirdParty/kcoreaddons/autotests/klistopenfilesjobtest_unix.cpp
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2019 David Hallas <david@davidhallas.dk>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "klistopenfilesjobtest_unix.h"
|
||||
#include "klistopenfilesjob.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringLiteral>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTest>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef Q_OS_FREEBSD
|
||||
// See implementation note in testOpenFiles()
|
||||
#include <QProcess>
|
||||
#endif
|
||||
|
||||
QTEST_MAIN(KListOpenFilesJobTest)
|
||||
void initLocale()
|
||||
{
|
||||
qputenv("LC_ALL", "en_US.utf-8");
|
||||
}
|
||||
|
||||
Q_CONSTRUCTOR_FUNCTION(initLocale)
|
||||
|
||||
namespace
|
||||
{
|
||||
bool hasLsofInstalled()
|
||||
{
|
||||
return !QStandardPaths::findExecutable(QStringLiteral("lsof")).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void KListOpenFilesJobTest::testOpenFiles()
|
||||
{
|
||||
if (!hasLsofInstalled()) {
|
||||
QSKIP("lsof is not installed - skipping test");
|
||||
}
|
||||
|
||||
// Create a file and hold it open, so that lsof must report us
|
||||
QTemporaryDir tempDir;
|
||||
QFile tempFile(tempDir.path() + QStringLiteral("/file"));
|
||||
QVERIFY(tempFile.open(QIODevice::WriteOnly));
|
||||
bool xfail_zfs = false; // Expected failure because of ZFS
|
||||
#ifdef Q_OS_FREEBSD
|
||||
// FIXME: On FreeBSD, lsof does not support zfs (as of 2022), see
|
||||
// https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253553
|
||||
//
|
||||
// This affects regular files only. So for FreeBSD, check if
|
||||
// the tempDir seems to be on a ZFS filesystem, e.g.
|
||||
//
|
||||
// ```
|
||||
// [adridg@beastie .../invent/kcoreaddons]$ lsof +d /tmp > /dev/null
|
||||
// lsof: WARNING: no ZFS support has been defined.
|
||||
// See 00FAQ for more information.
|
||||
// ```
|
||||
{
|
||||
QProcess lsof;
|
||||
lsof.start(QStringLiteral("lsof"), {QStringLiteral("+d"), tempDir.path()});
|
||||
lsof.waitForFinished();
|
||||
|
||||
auto stderr = lsof.readAllStandardError();
|
||||
xfail_zfs = (lsof.exitCode() != 0) && stderr.contains("ZFS");
|
||||
}
|
||||
#endif
|
||||
|
||||
auto job = new KListOpenFilesJob(tempDir.path());
|
||||
QVERIFY2(job->exec(), qPrintable(job->errorString()));
|
||||
QCOMPARE(job->error(), KJob::NoError);
|
||||
auto processInfoList = job->processInfoList();
|
||||
if (xfail_zfs) {
|
||||
// Ths list is empty, so the subsequent find and validity-checks
|
||||
// don't make sense.
|
||||
QEXPECT_FAIL("", "lsof(8) does not support regular files on ZFS", Abort);
|
||||
}
|
||||
QVERIFY(!processInfoList.empty());
|
||||
auto testProcessIterator = std::find_if(processInfoList.begin(), processInfoList.end(), [](const KProcessList::KProcessInfo &info) {
|
||||
return info.pid() == QCoreApplication::applicationPid();
|
||||
});
|
||||
QVERIFY(testProcessIterator != processInfoList.end());
|
||||
const auto &processInfo = *testProcessIterator;
|
||||
QVERIFY(processInfo.isValid());
|
||||
QCOMPARE(processInfo.pid(), QCoreApplication::applicationPid());
|
||||
}
|
||||
|
||||
void KListOpenFilesJobTest::testNoOpenFiles()
|
||||
{
|
||||
if (!hasLsofInstalled()) {
|
||||
QSKIP("lsof is not installed - skipping test");
|
||||
}
|
||||
QTemporaryDir tempDir;
|
||||
auto job = new KListOpenFilesJob(tempDir.path());
|
||||
QVERIFY2(job->exec(), qPrintable(job->errorString()));
|
||||
QCOMPARE(job->error(), KJob::NoError);
|
||||
QVERIFY(job->processInfoList().empty());
|
||||
}
|
||||
|
||||
void KListOpenFilesJobTest::testNonExistingDir()
|
||||
{
|
||||
if (!hasLsofInstalled()) {
|
||||
QSKIP("lsof is not installed - skipping test");
|
||||
}
|
||||
QString nonExistingDir(QStringLiteral("/does/not/exist"));
|
||||
auto job = new KListOpenFilesJob(nonExistingDir);
|
||||
QVERIFY(!job->exec());
|
||||
QCOMPARE(job->error(), static_cast<int>(KListOpenFilesJob::Error::DoesNotExist));
|
||||
QCOMPARE(job->errorText(), QStringLiteral("Path %1 doesn't exist").arg(nonExistingDir));
|
||||
QVERIFY(job->processInfoList().empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper class to temporarily set an environment variable and reset it on destruction
|
||||
*/
|
||||
class ScopedEnvVariable
|
||||
{
|
||||
public:
|
||||
ScopedEnvVariable(const QLatin1String &Name, const QByteArray &NewValue)
|
||||
: name(Name)
|
||||
, originalValue(qgetenv(name.latin1()))
|
||||
{
|
||||
qputenv(name.latin1(), NewValue);
|
||||
}
|
||||
~ScopedEnvVariable()
|
||||
{
|
||||
qputenv(name.latin1(), originalValue);
|
||||
}
|
||||
|
||||
private:
|
||||
const QLatin1String name;
|
||||
const QByteArray originalValue;
|
||||
};
|
||||
|
||||
void KListOpenFilesJobTest::testLsofNotFound()
|
||||
{
|
||||
// This test relies on clearing the PATH variable so that lsof is not found
|
||||
ScopedEnvVariable emptyPathEnvironment(QLatin1String("PATH"), QByteArray());
|
||||
QDir path(QCoreApplication::applicationDirPath());
|
||||
auto job = new KListOpenFilesJob(path.path());
|
||||
QVERIFY(!job->exec());
|
||||
QCOMPARE(job->error(), static_cast<int>(KListOpenFilesJob::Error::InternalError));
|
||||
QVERIFY(job->processInfoList().empty());
|
||||
}
|
||||
|
||||
#include "moc_klistopenfilesjobtest_unix.cpp"
|
||||
24
Telegram/ThirdParty/kcoreaddons/autotests/klistopenfilesjobtest_unix.h
vendored
Normal file
24
Telegram/ThirdParty/kcoreaddons/autotests/klistopenfilesjobtest_unix.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2019 David Hallas <david@davidhallas.dk>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#ifndef KLISTOPENFILESJOBTEST_UNIX_H
|
||||
#define KLISTOPENFILESJOBTEST_UNIX_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KListOpenFilesJobTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void testOpenFiles();
|
||||
void testNoOpenFiles();
|
||||
void testNonExistingDir();
|
||||
void testLsofNotFound();
|
||||
};
|
||||
|
||||
#endif
|
||||
26
Telegram/ThirdParty/kcoreaddons/autotests/klistopenfilesjobtest_win.cpp
vendored
Normal file
26
Telegram/ThirdParty/kcoreaddons/autotests/klistopenfilesjobtest_win.cpp
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2019 David Hallas <david@davidhallas.dk>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "klistopenfilesjobtest_win.h"
|
||||
#include "klistopenfilesjob.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QStringLiteral>
|
||||
#include <QTest>
|
||||
|
||||
QTEST_MAIN(KListOpenFilesJobTest)
|
||||
|
||||
void KListOpenFilesJobTest::testNotSupported()
|
||||
{
|
||||
QDir path(QCoreApplication::applicationDirPath());
|
||||
auto job = new KListOpenFilesJob(path.path());
|
||||
job->exec();
|
||||
QCOMPARE(job->error(), static_cast<int>(KListOpenFilesJob::Error::NotSupported));
|
||||
QCOMPARE(job->errorText(), QStringLiteral("KListOpenFilesJob is not supported on Windows"));
|
||||
QVERIFY(job->processInfoList().empty());
|
||||
}
|
||||
|
||||
#include "moc_klistopenfilesjobtest_win.cpp"
|
||||
21
Telegram/ThirdParty/kcoreaddons/autotests/klistopenfilesjobtest_win.h
vendored
Normal file
21
Telegram/ThirdParty/kcoreaddons/autotests/klistopenfilesjobtest_win.h
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2019 David Hallas <david@davidhallas.dk>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#ifndef KLISTOPENFILESJOBTEST_WIN_H
|
||||
#define KLISTOPENFILESJOBTEST_WIN_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KListOpenFilesJobTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void testNotSupported();
|
||||
};
|
||||
|
||||
#endif
|
||||
261
Telegram/ThirdParty/kcoreaddons/autotests/kmacroexpandertest.cpp
vendored
Normal file
261
Telegram/ThirdParty/kcoreaddons/autotests/kmacroexpandertest.cpp
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2003, 2008 Oswald Buddenhagen <ossi@kde.org>
|
||||
SPDX-FileCopyrightText: 2005 Thomas Braxton <brax108@cox.net>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
#include <kmacroexpander.h>
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
||||
class KMacroExpanderTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void expandMacros();
|
||||
void expandMacrosShellQuote();
|
||||
void expandMacrosShellQuoteParens();
|
||||
void expandMacrosSubClass();
|
||||
};
|
||||
|
||||
class MyCExpander : public KCharMacroExpander
|
||||
{
|
||||
QString exp;
|
||||
|
||||
public:
|
||||
MyCExpander()
|
||||
: KCharMacroExpander()
|
||||
, exp("expanded")
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
bool expandMacro(QChar ch, QStringList &ret) override
|
||||
{
|
||||
if (ch == 'm') {
|
||||
ret = QStringList(exp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class MyWExpander : public KWordMacroExpander
|
||||
{
|
||||
QString exp;
|
||||
|
||||
public:
|
||||
MyWExpander()
|
||||
: KWordMacroExpander()
|
||||
, exp("expanded")
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
bool expandMacro(const QString &str, QStringList &ret) override
|
||||
{
|
||||
if (str == QLatin1String("macro")) {
|
||||
ret = QStringList(exp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void KMacroExpanderTest::expandMacros()
|
||||
{
|
||||
QHash<QChar, QStringList> map;
|
||||
QStringList list;
|
||||
QString s;
|
||||
|
||||
list << QString("Restaurant \"Chew It\"");
|
||||
map.insert('n', list);
|
||||
list.clear();
|
||||
list << QString("element1") << QString("'element2'");
|
||||
map.insert('l', list);
|
||||
|
||||
s = "%% text %l text %n";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, map), QLatin1String("% text element1 'element2' text Restaurant \"Chew It\""));
|
||||
s = "text \"%l %n\" text";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, map), QLatin1String("text \"element1 'element2' Restaurant \"Chew It\"\" text"));
|
||||
|
||||
QHash<QChar, QString> map2;
|
||||
map2.insert('a', "%n");
|
||||
map2.insert('f', "filename.txt");
|
||||
map2.insert('u', "https://www.kde.org/index.html");
|
||||
map2.insert('n', "Restaurant \"Chew It\"");
|
||||
s = "Title: %a - %f - %u - %n - %%";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, map2), QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %"));
|
||||
|
||||
QHash<QString, QString> smap;
|
||||
smap.insert("foo", "%n");
|
||||
smap.insert("file", "filename.txt");
|
||||
smap.insert("url", "https://www.kde.org/index.html");
|
||||
smap.insert("name", "Restaurant \"Chew It\"");
|
||||
|
||||
s = "Title: %foo - %file - %url - %name - %";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %"));
|
||||
s = "%foo - %file - %url - %name";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("%n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\""));
|
||||
|
||||
s = "Title: %{foo} - %{file} - %{url} - %{name} - %";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\" - %"));
|
||||
s = "%{foo} - %{file} - %{url} - %{name}";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("%n - filename.txt - https://www.kde.org/index.html - Restaurant \"Chew It\""));
|
||||
|
||||
s = "Title: %foo-%file-%url-%name-%";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("Title: %n-filename.txt-https://www.kde.org/index.html-Restaurant \"Chew It\"-%"));
|
||||
|
||||
s = "Title: %{file} %{url";
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String("Title: filename.txt %{url"));
|
||||
|
||||
s = " * Copyright (C) 2008 %{AUTHOR}";
|
||||
smap.clear();
|
||||
QCOMPARE(KMacroExpander::expandMacros(s, smap), QLatin1String(" * Copyright (C) 2008 %{AUTHOR}"));
|
||||
}
|
||||
|
||||
void KMacroExpanderTest::expandMacrosShellQuote()
|
||||
{
|
||||
QHash<QChar, QStringList> map;
|
||||
QStringList list;
|
||||
QString s;
|
||||
|
||||
list << QString("Restaurant \"Chew It\"");
|
||||
map.insert('n', list);
|
||||
list.clear();
|
||||
list << QString("element1") << QString("'element2'") << QString("\"element3\"");
|
||||
map.insert('l', list);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
s = "text %l %n text";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map),
|
||||
QLatin1String("text element1 'element2' \\^\"element3\\^\" \"Restaurant \"\\^\"\"Chew It\"\\^\" text"));
|
||||
|
||||
s = "text \"%l %n\" text";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map),
|
||||
QLatin1String("text \"element1 'element2' \"\\^\"\"element3\"\\^\"\" Restaurant \"\\^\"\"Chew It\"\\^\"\"\" text"));
|
||||
#else
|
||||
s = "text %l %n text";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map), QLatin1String("text element1 ''\\''element2'\\''' '\"element3\"' 'Restaurant \"Chew It\"' text"));
|
||||
|
||||
s = "text \"%l %n\" text";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map), QLatin1String("text \"element1 'element2' \\\"element3\\\" Restaurant \\\"Chew It\\\"\" text"));
|
||||
#endif
|
||||
|
||||
QHash<QChar, QString> map2;
|
||||
map2.insert('a', "%n");
|
||||
map2.insert('f', "filename.txt");
|
||||
map2.insert('u', "https://www.kde.org/index.html");
|
||||
map2.insert('n', "Restaurant \"Chew It\"");
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
s = "Title: %a - %f - %u - %n - %% - %VARIABLE% foo";
|
||||
QCOMPARE(
|
||||
KMacroExpander::expandMacrosShellQuote(s, map2),
|
||||
QLatin1String(
|
||||
"Title: %PERCENT_SIGN%n - filename.txt - https://www.kde.org/index.html - \"Restaurant \"\\^\"\"Chew It\"\\^\" - %PERCENT_SIGN% - %VARIABLE% foo"));
|
||||
|
||||
s = "kedit --caption %n %f";
|
||||
map2.insert('n', "Restaurant 'Chew It'");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt"));
|
||||
|
||||
s = "kedit --caption \"%n\" %f";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt"));
|
||||
|
||||
map2.insert('n', "Restaurant \"Chew It\"");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant \"\\^\"\"Chew It\"\\^\"\"\" filename.txt"));
|
||||
|
||||
map2.insert('n', "Restaurant %HOME%");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant %PERCENT_SIGN%HOME%PERCENT_SIGN%\" filename.txt"));
|
||||
|
||||
s = "kedit c:\\%f";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit c:\\filename.txt"));
|
||||
|
||||
s = "kedit \"c:\\%f\"";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit \"c:\\filename.txt\""));
|
||||
|
||||
map2.insert('f', "\"filename.txt\"");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit \"c:\\\\\"\\^\"\"filename.txt\"\\^\"\"\""));
|
||||
|
||||
map2.insert('f', "path\\");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit \"c:\\path\\\\\"\"\""));
|
||||
#else
|
||||
s = "Title: %a - %f - %u - %n - %%";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2),
|
||||
QLatin1String("Title: %n - filename.txt - https://www.kde.org/index.html - 'Restaurant \"Chew It\"' - %"));
|
||||
|
||||
s = "kedit --caption %n %f";
|
||||
map2.insert('n', "Restaurant 'Chew It'");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption 'Restaurant '\\''Chew It'\\''' filename.txt"));
|
||||
|
||||
s = "kedit --caption \"%n\" %f";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant 'Chew It'\" filename.txt"));
|
||||
|
||||
map2.insert('n', "Restaurant \"Chew It\"");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant \\\"Chew It\\\"\" filename.txt"));
|
||||
|
||||
map2.insert('n', "Restaurant $HOME");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant \\$HOME\" filename.txt"));
|
||||
|
||||
map2.insert('n', "Restaurant `echo hello`");
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"Restaurant \\`echo hello\\`\" filename.txt"));
|
||||
|
||||
s = "kedit --caption \"`echo %n`\" %f";
|
||||
QCOMPARE(KMacroExpander::expandMacrosShellQuote(s, map2), QLatin1String("kedit --caption \"$( echo 'Restaurant `echo hello`')\" filename.txt"));
|
||||
#endif
|
||||
}
|
||||
|
||||
class DummyMacroExpander : public KMacroExpanderBase
|
||||
{
|
||||
public:
|
||||
DummyMacroExpander()
|
||||
: KMacroExpanderBase(QChar(0x4567))
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
int expandPlainMacro(const QString &, int, QStringList &) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int expandEscapedMacro(const QString &, int, QStringList &) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
void KMacroExpanderTest::expandMacrosShellQuoteParens()
|
||||
{
|
||||
QString s;
|
||||
|
||||
s = "( echo \"just testing (parens)\" ) ) after";
|
||||
int pos = 0;
|
||||
DummyMacroExpander kmx;
|
||||
QVERIFY(kmx.expandMacrosShellQuote(s, pos));
|
||||
QCOMPARE(s.mid(pos), QLatin1String(") after"));
|
||||
QVERIFY(!kmx.expandMacrosShellQuote(s));
|
||||
}
|
||||
|
||||
void KMacroExpanderTest::expandMacrosSubClass()
|
||||
{
|
||||
QString s;
|
||||
|
||||
MyCExpander mx1;
|
||||
s = "subst %m but not %n equ %%";
|
||||
mx1.expandMacros(s);
|
||||
QCOMPARE(s, QLatin1String("subst expanded but not %n equ %"));
|
||||
|
||||
MyWExpander mx2;
|
||||
s = "subst %macro but not %not equ %%";
|
||||
mx2.expandMacros(s);
|
||||
QCOMPARE(s, QLatin1String("subst expanded but not %not equ %"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(KMacroExpanderTest)
|
||||
|
||||
#include "kmacroexpandertest.moc"
|
||||
39
Telegram/ThirdParty/kcoreaddons/autotests/kmemoryinfotest.cpp
vendored
Normal file
39
Telegram/ThirdParty/kcoreaddons/autotests/kmemoryinfotest.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
This file is part of the KDE Frameworks
|
||||
|
||||
SPDX-FileCopyrightText: 2022 Mirco Miranda
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kmemoryinfotest.h"
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "kmemoryinfo.h"
|
||||
|
||||
QTEST_GUILESS_MAIN(KMemoryInfoTest)
|
||||
|
||||
KMemoryInfoTest::KMemoryInfoTest(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void KMemoryInfoTest::isNull()
|
||||
{
|
||||
KMemoryInfo m;
|
||||
QVERIFY(!m.isNull());
|
||||
}
|
||||
|
||||
void KMemoryInfoTest::operators()
|
||||
{
|
||||
KMemoryInfo m;
|
||||
auto m1 = m;
|
||||
QVERIFY(m == m1);
|
||||
|
||||
// paranoia check
|
||||
QVERIFY(m.totalPhysical() != 0);
|
||||
QCOMPARE(m.totalPhysical(), m1.totalPhysical());
|
||||
}
|
||||
|
||||
#include "moc_kmemoryinfotest.cpp"
|
||||
28
Telegram/ThirdParty/kcoreaddons/autotests/kmemoryinfotest.h
vendored
Normal file
28
Telegram/ThirdParty/kcoreaddons/autotests/kmemoryinfotest.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
This file is part of the KDE Frameworks
|
||||
|
||||
SPDX-FileCopyrightText: 2022 Mirco Miranda
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
#ifndef KMEMORYINFOTEST_H
|
||||
#define KMEMORYINFOTEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
/**
|
||||
* @brief The KMemoryInfoTest class
|
||||
*/
|
||||
class KMemoryInfoTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KMemoryInfoTest(QObject *parent = nullptr);
|
||||
|
||||
private Q_SLOTS:
|
||||
void isNull();
|
||||
|
||||
void operators();
|
||||
};
|
||||
|
||||
#endif // KMEMORYINFOTEST_H
|
||||
235
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestcanonical.cpp
vendored
Normal file
235
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestcanonical.cpp
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
This software is a contribution of the LiMux project of the city of Munich.
|
||||
SPDX-FileCopyrightText: 2021 Robert Hoffmann <robert@roberthoffmann.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "knetworkmountstestcanonical.h"
|
||||
|
||||
#include <KNetworkMounts>
|
||||
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
#include <QTest>
|
||||
|
||||
QTEST_MAIN(KNetworkMountsTestCanonical)
|
||||
|
||||
void KNetworkMountsTestCanonical::initTestCase()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
m_configFileName = QStringLiteral("%1/network_mounts").arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
|
||||
|
||||
QFile::remove(m_configFileName);
|
||||
QVERIFY(!QFile::exists(m_configFileName));
|
||||
|
||||
// create directory structure
|
||||
QVERIFY(m_tmpDir.isValid());
|
||||
|
||||
const QString relLinkToPath = QStringLiteral("dir");
|
||||
const QString relSymlinkDirectory = QStringLiteral("symlinkDirectory");
|
||||
const QStringList relPaths = {relLinkToPath,
|
||||
QStringLiteral("dir/subdir1"),
|
||||
QStringLiteral("dir/subdir1/subdir1"),
|
||||
QStringLiteral("dir/subdir1/subdir2"),
|
||||
QStringLiteral("dir/subdir1/subdir3"),
|
||||
QStringLiteral("dir/subdir2"),
|
||||
QStringLiteral("dir/subdir2/subdir1"),
|
||||
QStringLiteral("dir/subdir2/subdir2"),
|
||||
QStringLiteral("dir/subdir2/subdir3"),
|
||||
relSymlinkDirectory};
|
||||
|
||||
const QString relSymlinkToSmbPath = QStringLiteral("symlinkToSmbPath");
|
||||
|
||||
QDir dir(m_tmpDir.path());
|
||||
for (const QString &relPath : relPaths) {
|
||||
QVERIFY(dir.mkpath(relPath));
|
||||
QVERIFY(QFile::exists(m_tmpDir.path() + QLatin1Char('/') + relPath));
|
||||
|
||||
const QString fileName = m_tmpDir.path() + QLatin1Char('/') + relPath + QLatin1String("/file.txt");
|
||||
QFile file(fileName);
|
||||
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||
file.close();
|
||||
QVERIFY(QFile::exists(fileName));
|
||||
}
|
||||
|
||||
const QString linkToPath = m_tmpDir.path() + QLatin1Char('/') + relLinkToPath;
|
||||
|
||||
// SymlinkToNetworkMount
|
||||
const QString symlinkToSmbPath = dir.path() + QLatin1Char('/') + relSymlinkToSmbPath;
|
||||
|
||||
QVERIFY(QFile::link(linkToPath, symlinkToSmbPath));
|
||||
qDebug() << "linkToPath=" << linkToPath << ", symlinkToSmbPath=" << symlinkToSmbPath;
|
||||
|
||||
// SymlinkDirectory
|
||||
QVERIFY(dir.cd(relSymlinkDirectory));
|
||||
const QString symlinkDirectory = dir.path();
|
||||
const QString linkStr = symlinkDirectory + QLatin1Char('/') + relLinkToPath;
|
||||
|
||||
QVERIFY(QFile::link(linkToPath, linkStr));
|
||||
qDebug() << "linkToPath=" << linkToPath << ", symlinkDirectory=" << symlinkDirectory << ", linkStr=" << linkStr;
|
||||
|
||||
// setup config
|
||||
KNetworkMounts::self()->setEnabled(true);
|
||||
|
||||
const QStringList paths = {linkToPath};
|
||||
KNetworkMounts::self()->setPaths(paths, KNetworkMounts::SmbPaths);
|
||||
|
||||
const QStringList savedPaths = {linkToPath + QLatin1Char('/')};
|
||||
QCOMPARE(KNetworkMounts::self()->paths(), savedPaths);
|
||||
|
||||
// SymlinkDirectory
|
||||
const QStringList symlinkDirectories = {symlinkDirectory};
|
||||
KNetworkMounts::self()->setPaths(symlinkDirectories, KNetworkMounts::SymlinkDirectory);
|
||||
|
||||
const QStringList savedSymlinkDirectories = {symlinkDirectory + QLatin1Char('/')};
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SmbPaths), savedPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkDirectory), savedSymlinkDirectories);
|
||||
|
||||
// SymlinkToNetworkMount
|
||||
// addPath
|
||||
KNetworkMounts::self()->addPath(symlinkToSmbPath, KNetworkMounts::SymlinkToNetworkMount);
|
||||
|
||||
const QString savedSymlinkToSmbPath = symlinkToSmbPath + QLatin1Char('/');
|
||||
const QStringList savedSymlinkToSmbPaths = {savedSymlinkToSmbPath};
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkToNetworkMount), savedSymlinkToSmbPaths);
|
||||
|
||||
// setPaths
|
||||
const QStringList symlinkToSmbPaths = {symlinkToSmbPath};
|
||||
KNetworkMounts::self()->setPaths(symlinkToSmbPaths, KNetworkMounts::SymlinkToNetworkMount);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkToNetworkMount), savedSymlinkToSmbPaths);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SmbPaths), savedPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkDirectory), savedSymlinkDirectories);
|
||||
}
|
||||
|
||||
void KNetworkMountsTestCanonical::cleanupTestCase()
|
||||
{
|
||||
KNetworkMounts::self()->sync();
|
||||
QFile::remove(m_configFileName);
|
||||
}
|
||||
|
||||
void KNetworkMountsTestCanonical::testCanonicalSymlinkPath_data()
|
||||
{
|
||||
QTest::addColumn<QString>("relPath");
|
||||
QTest::addColumn<QString>("symlinkedRelPath");
|
||||
|
||||
// SymlinkDirectory
|
||||
QTest::newRow("symlinkDirectory/dir") << "dir"
|
||||
<< "symlinkDirectory/dir";
|
||||
QTest::newRow("symlinkDirectory/dir/file.txt") << "dir/file.txt"
|
||||
<< "symlinkDirectory/dir/file.txt";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir1") << "dir/subdir1"
|
||||
<< "symlinkDirectory/dir/subdir1";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir1/file.txt") << "dir/subdir1/file.txt"
|
||||
<< "symlinkDirectory/dir/subdir1/file.txt";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir1/subdir1") << "dir/subdir1/subdir1"
|
||||
<< "symlinkDirectory/dir/subdir1/subdir1";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir1/subdir1/file.txt") << "dir/subdir1/subdir1/file.txt"
|
||||
<< "symlinkDirectory/dir/subdir1/subdir1/file.txt";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir1/subdir2") << "dir/subdir1/subdir2"
|
||||
<< "symlinkDirectory/dir/subdir1/subdir2";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir1/subdir2/file.txt") << "dir/subdir1/subdir2/file.txt"
|
||||
<< "symlinkDirectory/dir/subdir1/subdir2/file.txt";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir1/subdir3") << "dir/subdir1/subdir3"
|
||||
<< "symlinkDirectory/dir/subdir1/subdir3";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir1/subdir3/file.txt") << "dir/subdir1/subdir3/file.txt"
|
||||
<< "symlinkDirectory/dir/subdir1/subdir3/file.txt";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir2") << "dir/subdir2"
|
||||
<< "symlinkDirectory/dir/subdir2";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir2/file.txt") << "dir/subdir2/file.txt"
|
||||
<< "symlinkDirectory/dir/subdir2/file.txt";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir2/subdir1") << "dir/subdir2/subdir1"
|
||||
<< "symlinkDirectory/dir/subdir2/subdir1";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir2/subdir1/file.txt") << "dir/subdir2/subdir1/file.txt"
|
||||
<< "symlinkDirectory/dir/subdir2/subdir1/file.txt";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir2/subdir2") << "dir/subdir2/subdir2"
|
||||
<< "symlinkDirectory/dir/subdir2/subdir2";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir2/subdir2/file.txt") << "dir/subdir2/subdir2/file.txt"
|
||||
<< "symlinkDirectory/dir/subdir2/subdir2/file.txt";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir2/subdir3") << "dir/subdir2/subdir3"
|
||||
<< "symlinkDirectory/dir/subdir2/subdir3";
|
||||
QTest::newRow("symlinkDirectory/dir/subdir2/subdir3/file.txt") << "dir/subdir2/subdir3/file.txt"
|
||||
<< "symlinkDirectory/dir/subdir2/subdir3/file.txt";
|
||||
QTest::newRow("symlinkDirectory") << "symlinkDirectory"
|
||||
<< "symlinkDirectory";
|
||||
QTest::newRow("symlinkDirectory/file.txt") << "symlinkDirectory/file.txt"
|
||||
<< "symlinkDirectory/file.txt";
|
||||
|
||||
// SymlinkToNetworkMount
|
||||
QTest::newRow("symlinkToSmbPath") << "dir"
|
||||
<< "symlinkToSmbPath";
|
||||
QTest::newRow("symlinkToSmbPath/file.txt") << "dir/file.txt"
|
||||
<< "symlinkToSmbPath/file.txt";
|
||||
QTest::newRow("symlinkToSmbPath/subdir1") << "dir/subdir1"
|
||||
<< "symlinkToSmbPath/subdir1";
|
||||
QTest::newRow("symlinkToSmbPath/subdir1/file.txt") << "dir/subdir1/file.txt"
|
||||
<< "symlinkToSmbPath/subdir1/file.txt";
|
||||
QTest::newRow("symlinkToSmbPath/subdir1/subdir1") << "dir/subdir1/subdir1"
|
||||
<< "symlinkToSmbPath/subdir1/subdir1";
|
||||
QTest::newRow("symlinkToSmbPath/subdir1/subdir1/file.txt") << "dir/subdir1/subdir1/file.txt"
|
||||
<< "symlinkToSmbPath/subdir1/subdir1/file.txt";
|
||||
QTest::newRow("symlinkToSmbPath/subdir1/subdir2") << "dir/subdir1/subdir2"
|
||||
<< "symlinkToSmbPath/subdir1/subdir2";
|
||||
QTest::newRow("symlinkToSmbPath/subdir1/subdir2/file.txt") << "dir/subdir1/subdir2/file.txt"
|
||||
<< "symlinkToSmbPath/subdir1/subdir2/file.txt";
|
||||
QTest::newRow("symlinkToSmbPath/subdir1/subdir3") << "dir/subdir1/subdir3"
|
||||
<< "symlinkToSmbPath/subdir1/subdir3";
|
||||
QTest::newRow("symlinkToSmbPath/subdir1/subdir3/file.txt") << "dir/subdir1/subdir3/file.txt"
|
||||
<< "symlinkToSmbPath/subdir1/subdir3/file.txt";
|
||||
QTest::newRow("symlinkToSmbPath/subdir2") << "dir/subdir2"
|
||||
<< "symlinkToSmbPath/subdir2";
|
||||
QTest::newRow("symlinkToSmbPath/subdir2/file.txt") << "dir/subdir2/file.txt"
|
||||
<< "symlinkToSmbPath/subdir2/file.txt";
|
||||
QTest::newRow("symlinkToSmbPath/subdir2/subdir1") << "dir/subdir2/subdir1"
|
||||
<< "symlinkToSmbPath/subdir2/subdir1";
|
||||
QTest::newRow("symlinkToSmbPath/subdir2/subdir1/file.txt") << "dir/subdir2/subdir1/file.txt"
|
||||
<< "symlinkToSmbPath/subdir2/subdir1/file.txt";
|
||||
QTest::newRow("symlinkToSmbPath/subdir2/subdir2") << "dir/subdir2/subdir2"
|
||||
<< "symlinkToSmbPath/subdir2/subdir2";
|
||||
QTest::newRow("symlinkToSmbPath/subdir2/subdir2/file.txt") << "dir/subdir2/subdir2/file.txt"
|
||||
<< "symlinkToSmbPath/subdir2/subdir2/file.txt";
|
||||
QTest::newRow("symlinkToSmbPath/subdir2/subdir3") << "dir/subdir2/subdir3"
|
||||
<< "symlinkToSmbPath/subdir2/subdir3";
|
||||
QTest::newRow("symlinkToSmbPath/subdir2/subdir3/file.txt") << "dir/subdir2/subdir3/file.txt"
|
||||
<< "symlinkToSmbPath/subdir2/subdir3/file.txt";
|
||||
}
|
||||
|
||||
void KNetworkMountsTestCanonical::testCanonicalSymlinkPath()
|
||||
{
|
||||
QFETCH(QString, relPath);
|
||||
QFETCH(QString, symlinkedRelPath);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QSKIP("QFile::link creates a shortcut on Windows, not a symlink, so no effect on canonical paths, skipped");
|
||||
#endif
|
||||
|
||||
const QString path = m_tmpDir.path() + QLatin1Char('/') + relPath;
|
||||
const QString symlinkedPath = m_tmpDir.path() + QLatin1Char('/') + symlinkedRelPath;
|
||||
const QString canonicalPath = QFileInfo(symlinkedPath).canonicalFilePath();
|
||||
|
||||
// default with cache
|
||||
QCOMPARE(KNetworkMounts::self()->canonicalSymlinkPath(symlinkedPath), canonicalPath);
|
||||
QCOMPARE(path, canonicalPath);
|
||||
qDebug() << "path=" << path << ", canonicalPath=" << canonicalPath << ", symlinkedPath=" << symlinkedPath;
|
||||
|
||||
// from cache
|
||||
QCOMPARE(KNetworkMounts::self()->canonicalSymlinkPath(symlinkedPath), canonicalPath);
|
||||
|
||||
// no cache
|
||||
KNetworkMounts::self()->clearCache();
|
||||
QCOMPARE(KNetworkMounts::self()->canonicalSymlinkPath(symlinkedPath), canonicalPath);
|
||||
|
||||
KNetworkMounts::self()->clearCache();
|
||||
KNetworkMounts::self()->setOption(KNetworkMounts::SymlinkPathsUseCache, false);
|
||||
QCOMPARE(KNetworkMounts::self()->canonicalSymlinkPath(symlinkedPath), canonicalPath);
|
||||
|
||||
// with cache
|
||||
KNetworkMounts::self()->setOption(KNetworkMounts::SymlinkPathsUseCache, true);
|
||||
QCOMPARE(KNetworkMounts::self()->canonicalSymlinkPath(symlinkedPath), canonicalPath);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->canonicalSymlinkPath(symlinkedPath), canonicalPath);
|
||||
}
|
||||
|
||||
#include "moc_knetworkmountstestcanonical.cpp"
|
||||
29
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestcanonical.h
vendored
Normal file
29
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestcanonical.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
This software is a contribution of the LiMux project of the city of Munich.
|
||||
SPDX-FileCopyrightText: 2021 Robert Hoffmann <robert@roberthoffmann.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KNETWORKMOUNTSTESTCANONICAL_H
|
||||
#define KNETWORKMOUNTSTESTCANONICAL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
class KNetworkMountsTestCanonical : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
void testCanonicalSymlinkPath_data();
|
||||
void testCanonicalSymlinkPath();
|
||||
|
||||
private:
|
||||
QString m_configFileName;
|
||||
QTemporaryDir m_tmpDir;
|
||||
};
|
||||
|
||||
#endif
|
||||
144
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestnoconfig.cpp
vendored
Normal file
144
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestnoconfig.cpp
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
This software is a contribution of the LiMux project of the city of Munich.
|
||||
SPDX-FileCopyrightText: 2021 Robert Hoffmann <robert@roberthoffmann.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "knetworkmountstestnoconfig.h"
|
||||
|
||||
#include <KNetworkMounts>
|
||||
|
||||
#include <QFile>
|
||||
#include <QStandardPaths>
|
||||
#include <QTest>
|
||||
|
||||
QTEST_MAIN(KNetworkMountsTestNoConfig)
|
||||
|
||||
void KNetworkMountsTestNoConfig::initTestCase()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
m_configFileName = QStringLiteral("%1/network_mounts").arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
|
||||
|
||||
QFile::remove(m_configFileName);
|
||||
QVERIFY(!QFile::exists(m_configFileName));
|
||||
}
|
||||
|
||||
void KNetworkMountsTestNoConfig::cleanupTestCase()
|
||||
{
|
||||
QVERIFY(!QFile::exists(m_configFileName));
|
||||
QVERIFY(!KNetworkMounts::self()->isEnabled());
|
||||
|
||||
KNetworkMounts::self()->sync();
|
||||
QFile::remove(m_configFileName);
|
||||
}
|
||||
|
||||
void KNetworkMountsTestNoConfig::testNoConfigPathTypes_data()
|
||||
{
|
||||
QTest::addColumn<QString>("path");
|
||||
QTest::addColumn<KNetworkMounts::KNetworkMountsType>("type");
|
||||
|
||||
QTest::newRow("NfsPaths/") << "/" << KNetworkMounts::NfsPaths;
|
||||
QTest::newRow("SmbPaths/") << "/" << KNetworkMounts::SmbPaths;
|
||||
QTest::newRow("SymlinkDirectory/") << "/" << KNetworkMounts::SymlinkDirectory;
|
||||
QTest::newRow("SymlinkToNetworkMount/") << "/" << KNetworkMounts::SymlinkToNetworkMount;
|
||||
QTest::newRow("Any/") << "/" << KNetworkMounts::Any;
|
||||
|
||||
QTest::newRow("NfsPaths/mnt") << "/mnt" << KNetworkMounts::NfsPaths;
|
||||
QTest::newRow("SmbPaths/mnt") << "/mnt" << KNetworkMounts::SmbPaths;
|
||||
QTest::newRow("SymlinkDirectory/mnt") << "/mnt" << KNetworkMounts::SymlinkDirectory;
|
||||
QTest::newRow("SymlinkToNetworkMount/mnt") << "/mnt" << KNetworkMounts::SymlinkToNetworkMount;
|
||||
QTest::newRow("Any/mnt") << "/mnt" << KNetworkMounts::Any;
|
||||
|
||||
QTest::newRow("NfsPaths/mnt/") << "/mnt/" << KNetworkMounts::NfsPaths;
|
||||
QTest::newRow("SmbPaths/mnt/") << "/mnt/" << KNetworkMounts::SmbPaths;
|
||||
QTest::newRow("SymlinkDirectory/mnt/") << "/mnt/" << KNetworkMounts::SymlinkDirectory;
|
||||
QTest::newRow("SymlinkToNetworkMount/mnt/") << "/mnt/" << KNetworkMounts::SymlinkToNetworkMount;
|
||||
QTest::newRow("Any/mnt/") << "/mnt/" << KNetworkMounts::Any;
|
||||
}
|
||||
|
||||
void KNetworkMountsTestNoConfig::testNoConfigPathTypes()
|
||||
{
|
||||
QFETCH(QString, path);
|
||||
QFETCH(KNetworkMounts::KNetworkMountsType, type);
|
||||
|
||||
QVERIFY(!QFile::exists(m_configFileName));
|
||||
QVERIFY(!KNetworkMounts::self()->isEnabled());
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->paths(type), QStringList());
|
||||
QCOMPARE(KNetworkMounts::self()->paths(), QStringList());
|
||||
QCOMPARE(KNetworkMounts::self()->canonicalSymlinkPath(path), path);
|
||||
QVERIFY(!KNetworkMounts::self()->isSlowPath(path, type));
|
||||
QVERIFY(!KNetworkMounts::self()->isSlowPath(path));
|
||||
}
|
||||
|
||||
void KNetworkMountsTestNoConfig::testNoConfigPathOptions_data()
|
||||
{
|
||||
QTest::addColumn<QString>("path");
|
||||
QTest::addColumn<KNetworkMounts::KNetworkMountOption>("option");
|
||||
|
||||
QTest::newRow("LowSideEffectsOptimizations/") << "/" << KNetworkMounts::LowSideEffectsOptimizations;
|
||||
QTest::newRow("MediumSideEffectsOptimizations/") << "/" << KNetworkMounts::MediumSideEffectsOptimizations;
|
||||
QTest::newRow("StrongSideEffectsOptimizations/") << "/" << KNetworkMounts::StrongSideEffectsOptimizations;
|
||||
QTest::newRow("KDirWatchUseINotify/") << "/" << KNetworkMounts::KDirWatchUseINotify;
|
||||
QTest::newRow("KDirWatchDontAddWatches/") << "/" << KNetworkMounts::KDirWatchDontAddWatches;
|
||||
QTest::newRow("SymlinkPathsUseCache/") << "/" << KNetworkMounts::SymlinkPathsUseCache;
|
||||
|
||||
QTest::newRow("LowSideEffectsOptimizations/mnt") << "/mnt" << KNetworkMounts::LowSideEffectsOptimizations;
|
||||
QTest::newRow("MediumSideEffectsOptimizations/mnt") << "/mnt" << KNetworkMounts::MediumSideEffectsOptimizations;
|
||||
QTest::newRow("StrongSideEffectsOptimizations/mnt") << "/mnt" << KNetworkMounts::StrongSideEffectsOptimizations;
|
||||
QTest::newRow("KDirWatchUseINotify/mnt") << "/mnt" << KNetworkMounts::KDirWatchUseINotify;
|
||||
QTest::newRow("KDirWatchDontAddWatches/mnt") << "/mnt" << KNetworkMounts::KDirWatchDontAddWatches;
|
||||
QTest::newRow("SymlinkPathsUseCache/mnt") << "/mnt" << KNetworkMounts::SymlinkPathsUseCache;
|
||||
|
||||
QTest::newRow("LowSideEffectsOptimizations/mnt/") << "/mnt/" << KNetworkMounts::LowSideEffectsOptimizations;
|
||||
QTest::newRow("MediumSideEffectsOptimizations/mnt/") << "/mnt/" << KNetworkMounts::MediumSideEffectsOptimizations;
|
||||
QTest::newRow("StrongSideEffectsOptimizations/mnt/") << "/mnt/" << KNetworkMounts::StrongSideEffectsOptimizations;
|
||||
QTest::newRow("KDirWatchUseINotify/mnt/") << "/mnt/" << KNetworkMounts::KDirWatchUseINotify;
|
||||
QTest::newRow("KDirWatchDontAddWatches/mnt/") << "/mnt/" << KNetworkMounts::KDirWatchDontAddWatches;
|
||||
QTest::newRow("SymlinkPathsUseCache/mnt/") << "/mnt/" << KNetworkMounts::SymlinkPathsUseCache;
|
||||
}
|
||||
|
||||
void KNetworkMountsTestNoConfig::testNoConfigPathOptions()
|
||||
{
|
||||
QFETCH(QString, path);
|
||||
QFETCH(KNetworkMounts::KNetworkMountOption, option);
|
||||
|
||||
QVERIFY(!KNetworkMounts::self()->isOptionEnabledForPath(path, option));
|
||||
}
|
||||
|
||||
void KNetworkMountsTestNoConfig::testNoConfigOptions_data()
|
||||
{
|
||||
QTest::addColumn<KNetworkMounts::KNetworkMountOption>("option");
|
||||
QTest::addColumn<bool>("default_value");
|
||||
QTest::addColumn<bool>("expected_value");
|
||||
|
||||
QTest::newRow("LowSideEffectsOptimizations_false") << KNetworkMounts::LowSideEffectsOptimizations << false << false;
|
||||
QTest::newRow("LowSideEffectsOptimizations_true") << KNetworkMounts::LowSideEffectsOptimizations << true << true;
|
||||
|
||||
QTest::newRow("MediumSideEffectsOptimizationss_false") << KNetworkMounts::MediumSideEffectsOptimizations << false << false;
|
||||
QTest::newRow("MediumSideEffectsOptimizations_true") << KNetworkMounts::MediumSideEffectsOptimizations << true << true;
|
||||
|
||||
QTest::newRow("StrongSideEffectsOptimizations_false") << KNetworkMounts::StrongSideEffectsOptimizations << false << false;
|
||||
QTest::newRow("StrongSideEffectsOptimizationss_true") << KNetworkMounts::StrongSideEffectsOptimizations << true << true;
|
||||
|
||||
QTest::newRow("KDirWatchUseINotify_false") << KNetworkMounts::KDirWatchUseINotify << false << false;
|
||||
QTest::newRow("KDirWatchUseINotifys_true") << KNetworkMounts::KDirWatchUseINotify << true << true;
|
||||
|
||||
QTest::newRow("KDirWatchDontAddWatches_false") << KNetworkMounts::KDirWatchDontAddWatches << false << false;
|
||||
QTest::newRow("KDirWatchDontAddWatches_true") << KNetworkMounts::KDirWatchDontAddWatches << true << true;
|
||||
|
||||
QTest::newRow("SymlinkPathsUseCache_false") << KNetworkMounts::SymlinkPathsUseCache << false << false;
|
||||
QTest::newRow("SymlinkPathsUseCache_true") << KNetworkMounts::SymlinkPathsUseCache << true << true;
|
||||
}
|
||||
|
||||
void KNetworkMountsTestNoConfig::testNoConfigOptions()
|
||||
{
|
||||
QFETCH(KNetworkMounts::KNetworkMountOption, option);
|
||||
QFETCH(bool, default_value);
|
||||
QFETCH(bool, expected_value);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->isOptionEnabled(option, default_value), expected_value);
|
||||
}
|
||||
|
||||
#include "moc_knetworkmountstestnoconfig.cpp"
|
||||
33
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestnoconfig.h
vendored
Normal file
33
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestnoconfig.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
This software is a contribution of the LiMux project of the city of Munich.
|
||||
SPDX-FileCopyrightText: 2021 Robert Hoffmann <robert@roberthoffmann.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KNETWORKMOUNTSTESTNOCONFIG_H
|
||||
#define KNETWORKMOUNTSTESTNOCONFIG_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KNetworkMountsTestNoConfig : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
void testNoConfigPathTypes_data();
|
||||
void testNoConfigPathTypes();
|
||||
|
||||
void testNoConfigPathOptions_data();
|
||||
void testNoConfigPathOptions();
|
||||
|
||||
void testNoConfigOptions_data();
|
||||
void testNoConfigOptions();
|
||||
|
||||
private:
|
||||
QString m_configFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
157
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestpaths.cpp
vendored
Normal file
157
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestpaths.cpp
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
This software is a contribution of the LiMux project of the city of Munich.
|
||||
SPDX-FileCopyrightText: 2021 Robert Hoffmann <robert@roberthoffmann.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "knetworkmountstestpaths.h"
|
||||
|
||||
#include <KNetworkMounts>
|
||||
|
||||
#include <QFile>
|
||||
#include <QStandardPaths>
|
||||
#include <QTest>
|
||||
|
||||
QTEST_MAIN(KNetworkMountsTestPaths)
|
||||
|
||||
void KNetworkMountsTestPaths::initTestCase()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
m_configFileName = QStringLiteral("%1/network_mounts").arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
|
||||
|
||||
QFile::remove(m_configFileName);
|
||||
QVERIFY(!QFile::exists(m_configFileName));
|
||||
|
||||
KNetworkMounts::self()->setEnabled(true);
|
||||
QVERIFY(KNetworkMounts::self()->isEnabled());
|
||||
KNetworkMounts::self()->sync();
|
||||
QVERIFY(QFile::exists(m_configFileName));
|
||||
QVERIFY(KNetworkMounts::self()->isEnabled());
|
||||
|
||||
// nfs path
|
||||
const QString nfsPath = QStringLiteral("/mnt/nfs");
|
||||
const QString savedNfsPath = QStringLiteral("/mnt/nfs/");
|
||||
const QStringList savedNfsPaths = {savedNfsPath};
|
||||
KNetworkMounts::self()->addPath(nfsPath, KNetworkMounts::NfsPaths);
|
||||
|
||||
QStringList allSavedPaths = savedNfsPaths;
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->paths(), allSavedPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SmbPaths), QStringList());
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::NfsPaths), savedNfsPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkDirectory), QStringList());
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkToNetworkMount), QStringList());
|
||||
|
||||
// smb shares
|
||||
const QStringList paths = {QStringLiteral("/mnt/server1"), QStringLiteral("/mnt/server2")};
|
||||
const QStringList savedSmbPaths = {QStringLiteral("/mnt/server1/"), QStringLiteral("/mnt/server2/")};
|
||||
KNetworkMounts::self()->setPaths(paths, KNetworkMounts::SmbPaths);
|
||||
|
||||
allSavedPaths << savedSmbPaths;
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->paths(), allSavedPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SmbPaths), savedSmbPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::NfsPaths), savedNfsPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkDirectory), QStringList());
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkToNetworkMount), QStringList());
|
||||
|
||||
// symlink dir
|
||||
const QStringList symlinkDirs = {QStringLiteral("/home/user/netshares")};
|
||||
const QStringList savedSymlinkDirs = {QStringLiteral("/home/user/netshares/")};
|
||||
KNetworkMounts::self()->setPaths(symlinkDirs, KNetworkMounts::SymlinkDirectory);
|
||||
|
||||
allSavedPaths << savedSymlinkDirs;
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->paths(), allSavedPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SmbPaths), savedSmbPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkDirectory), savedSymlinkDirs);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::NfsPaths), savedNfsPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkToNetworkMount), QStringList());
|
||||
|
||||
// symlink to nfs or smb
|
||||
const QString symlinkToNfs = QStringLiteral("/somedir/symlinkToNfs");
|
||||
const QString savedSymlinkToNfs = QStringLiteral("/somedir/symlinkToNfs/");
|
||||
const QStringList savedSymlinkToNfsPaths = {savedSymlinkToNfs};
|
||||
KNetworkMounts::self()->addPath(symlinkToNfs, KNetworkMounts::SymlinkToNetworkMount);
|
||||
|
||||
allSavedPaths << savedSymlinkToNfsPaths;
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->paths(), allSavedPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SmbPaths), savedSmbPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkDirectory), savedSymlinkDirs);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::NfsPaths), savedNfsPaths);
|
||||
QCOMPARE(KNetworkMounts::self()->paths(KNetworkMounts::SymlinkToNetworkMount), savedSymlinkToNfsPaths);
|
||||
}
|
||||
|
||||
void KNetworkMountsTestPaths::cleanupTestCase()
|
||||
{
|
||||
KNetworkMounts::self()->sync();
|
||||
QFile::remove(m_configFileName);
|
||||
}
|
||||
|
||||
void KNetworkMountsTestPaths::testPaths_data()
|
||||
{
|
||||
QTest::addColumn<QString>("path");
|
||||
QTest::addColumn<bool>("expected_path_option");
|
||||
QTest::addColumn<bool>("expected_path");
|
||||
QTest::addColumn<bool>("expected_symlink_dir");
|
||||
QTest::addColumn<bool>("expected_symlink_to_nfs_or_smb");
|
||||
QTest::addColumn<bool>("expected_nfs");
|
||||
QTest::addColumn<bool>("expected_smb");
|
||||
|
||||
QTest::newRow("fast_path") << "/mnt" << false << false << false << false << false << false;
|
||||
QTest::newRow("fast_path_slash_end") << "/mnt/" << false << false << false << false << false << false;
|
||||
QTest::newRow("slow_path1") << "/mnt/server1" << true << true << false << false << false << true;
|
||||
QTest::newRow("slow_path2") << "/mnt/server2" << true << true << false << false << false << true;
|
||||
QTest::newRow("slow_path2_dir") << "/mnt/server2/dir" << true << true << false << false << false << true;
|
||||
QTest::newRow("slow_path2_dir_subdir") << "/mnt/server2/dir/subdir" << true << true << false << false << false << true;
|
||||
QTest::newRow("slow_path2_dir_subdir_slash_end") << "/mnt/server2/dir/subdir/" << true << true << false << false << false << true;
|
||||
QTest::newRow("slow_symlink_path") << "/home/user/netshares" << true << true << true << false << false << false;
|
||||
QTest::newRow("fast_path_root") << "/" << false << false << false << false << false << false;
|
||||
QTest::newRow("fast_path_home") << "/home" << false << false << false << false << false << false;
|
||||
QTest::newRow("fast_path_home_user") << "/home/user" << false << false << false << false << false << false;
|
||||
QTest::newRow("slow_symlink_path_subdir1") << "/home/user/netshares/subdir1" << true << true << true << false << false << false;
|
||||
QTest::newRow("slow_symlink_path_subdir1_subdir2") << "/home/user/netshares/subdir1/subdir2" << true << true << true << false << false << false;
|
||||
QTest::newRow("slow_symlink_path_subdir1_subdir2_slash_end") << "/home/user/netshares/subdir1/subdir2/" << true << true << true << false << false << false;
|
||||
QTest::newRow("slow_path_nfs") << "/mnt/nfs" << true << true << false << false << true << false;
|
||||
QTest::newRow("slow_path_nfs_dir") << "/mnt/nfs/dir" << true << true << false << false << true << false;
|
||||
QTest::newRow("slow_path_nfs_dir_subdir") << "/mnt/nfs/dir/subdir" << true << true << false << false << true << false;
|
||||
QTest::newRow("slow_path_nfs_dir_subdir_slash_end") << "/mnt/nfs/dir/subdir/" << true << true << false << false << true << false;
|
||||
QTest::newRow("slow_path_symlink_to_nfs") << "/somedir/symlinkToNfs" << true << true << false << true << false << false;
|
||||
QTest::newRow("slow_path_symlink_to_nfs_dir") << "/somedir/symlinkToNfs/dir" << true << true << false << true << false << false;
|
||||
QTest::newRow("slow_path_symlink_to_nfs_dir_subdir") << "/somedir/symlinkToNfs/dir/subdir" << true << true << false << true << false << false;
|
||||
QTest::newRow("slow_path_symlink_to_nfs_dir_subdir_slash_end") << "/somedir/symlinkToNfs/dir/subdir/" << true << true << false << true << false << false;
|
||||
}
|
||||
|
||||
void KNetworkMountsTestPaths::testPaths()
|
||||
{
|
||||
QFETCH(QString, path);
|
||||
QFETCH(bool, expected_path_option);
|
||||
QFETCH(bool, expected_path);
|
||||
QFETCH(bool, expected_symlink_dir);
|
||||
QFETCH(bool, expected_symlink_to_nfs_or_smb);
|
||||
QFETCH(bool, expected_nfs);
|
||||
QFETCH(bool, expected_smb);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->isOptionEnabledForPath(path, KNetworkMounts::SymlinkPathsUseCache), expected_path_option);
|
||||
QCOMPARE(KNetworkMounts::self()->isOptionEnabledForPath(path, KNetworkMounts::KDirWatchUseINotify), expected_path_option);
|
||||
QCOMPARE(KNetworkMounts::self()->isOptionEnabledForPath(path, KNetworkMounts::KDirWatchDontAddWatches), expected_path_option);
|
||||
QCOMPARE(KNetworkMounts::self()->isOptionEnabledForPath(path, KNetworkMounts::LowSideEffectsOptimizations), expected_path_option);
|
||||
QCOMPARE(KNetworkMounts::self()->isOptionEnabledForPath(path, KNetworkMounts::MediumSideEffectsOptimizations), expected_path_option);
|
||||
QCOMPARE(KNetworkMounts::self()->isOptionEnabledForPath(path, KNetworkMounts::StrongSideEffectsOptimizations), expected_path_option);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->isSlowPath(path), expected_path);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->isSlowPath(path, KNetworkMounts::KNetworkMountsType::Any), expected_path);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->isSlowPath(path, KNetworkMounts::SymlinkDirectory), expected_symlink_dir);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->isSlowPath(path, KNetworkMounts::SymlinkToNetworkMount), expected_symlink_to_nfs_or_smb);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->isSlowPath(path, KNetworkMounts::NfsPaths), expected_nfs);
|
||||
|
||||
QCOMPARE(KNetworkMounts::self()->isSlowPath(path, KNetworkMounts::SmbPaths), expected_smb);
|
||||
}
|
||||
|
||||
#include "moc_knetworkmountstestpaths.cpp"
|
||||
27
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestpaths.h
vendored
Normal file
27
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountstestpaths.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
This software is a contribution of the LiMux project of the city of Munich.
|
||||
SPDX-FileCopyrightText: 2021 Robert Hoffmann <robert@roberthoffmann.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KNETWORKMOUNTSTESTPATHS_H
|
||||
#define KNETWORKMOUNTSTESTPATHS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KNetworkMountsTestPaths : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
void testPaths_data();
|
||||
void testPaths();
|
||||
|
||||
private:
|
||||
QString m_configFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
112
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountsteststatic.cpp
vendored
Normal file
112
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountsteststatic.cpp
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
This software is a contribution of the LiMux project of the city of Munich.
|
||||
SPDX-FileCopyrightText: 2021 Robert Hoffmann <robert@roberthoffmann.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "knetworkmountsteststatic.h"
|
||||
|
||||
// include static functions
|
||||
#include "knetworkmounts_p.h"
|
||||
|
||||
#include <KNetworkMounts>
|
||||
|
||||
#include <QFile>
|
||||
#include <QStandardPaths>
|
||||
#include <QTest>
|
||||
|
||||
QTEST_MAIN(KNetworkMountsTestStatic)
|
||||
|
||||
void KNetworkMountsTestStatic::testStaticFunctions_data()
|
||||
{
|
||||
QTest::addColumn<QString>("path");
|
||||
QTest::addColumn<QStringList>("paths");
|
||||
QTest::addColumn<bool>("expected_is_slash_added_to_path");
|
||||
QTest::addColumn<QString>("expected_path_str");
|
||||
QTest::addColumn<bool>("expected_is_slash_added_to_paths");
|
||||
QTest::addColumn<QStringList>("expected_paths_str");
|
||||
QTest::addColumn<QString>("expected_matching");
|
||||
|
||||
QTest::newRow("empty1") << QString() << QStringList() << false << "" << false << QStringList() << QString();
|
||||
QTest::newRow("empty2") << "" << (QStringList() << QString() << QString()) << false << "" << false << (QStringList() << QString() << QString())
|
||||
<< QString();
|
||||
|
||||
QTest::newRow("/1") << "/" << QStringList() << false << "/" << false << QStringList() << QString();
|
||||
QTest::newRow("/2") << "/" << (QStringList() << QString() << QString()) << false << "/" << false << (QStringList() << QString() << QString()) << QString();
|
||||
QTest::newRow("/3") << "/" << (QStringList() << QStringLiteral("/")) << false << "/" << false << (QStringList() << QStringLiteral("/")) << "/";
|
||||
QTest::newRow("/4") << "/" << (QStringList() << QStringLiteral("/") << QString()) << false << "/" << false
|
||||
<< (QStringList() << QStringLiteral("/") << QString()) << "/";
|
||||
|
||||
QTest::newRow("/mnt1") << "/mnt" << QStringList() << true << "/mnt/" << false << QStringList() << QString();
|
||||
QTest::newRow("/mnt2") << "/mnt" << (QStringList() << QStringLiteral("/mnt")) << true << "/mnt/" << true << (QStringList() << QStringLiteral("/mnt/"))
|
||||
<< "/mnt";
|
||||
QTest::newRow("/mnt3") << "/mnt" << (QStringList() << QStringLiteral("/mnt/")) << true << "/mnt/" << false << (QStringList() << QStringLiteral("/mnt/"))
|
||||
<< "/mnt/";
|
||||
|
||||
QTest::newRow("/mnt/test1") << "/mnt" << (QStringList() << QStringLiteral("/mnt/test1") << QStringLiteral("/mnt/test2/")) << true << "/mnt/" << true
|
||||
<< (QStringList() << QStringLiteral("/mnt/test1/") << QStringLiteral("/mnt/test2/")) << "";
|
||||
QTest::newRow("/mnt/test2") << "/mnt/test2" << (QStringList() << QStringLiteral("/mnt/test1/") << QStringLiteral("/mnt/test2/")) << true << "/mnt/test2/"
|
||||
<< false << (QStringList() << QStringLiteral("/mnt/test1/") << QStringLiteral("/mnt/test2/")) << "/mnt/test2/";
|
||||
QTest::newRow("/mnt/test3") << "/mnt/test2/" << (QStringList() << QStringLiteral("/mnt/test1/") << QStringLiteral("/mnt/test2/")) << false << "/mnt/test2/"
|
||||
<< false << (QStringList() << QStringLiteral("/mnt/test1/") << QStringLiteral("/mnt/test2/")) << "/mnt/test2/";
|
||||
}
|
||||
|
||||
void KNetworkMountsTestStatic::testStaticFunctions()
|
||||
{
|
||||
QFETCH(QString, path);
|
||||
QFETCH(QStringList, paths);
|
||||
QFETCH(bool, expected_is_slash_added_to_path);
|
||||
QFETCH(QString, expected_path_str);
|
||||
QFETCH(bool, expected_is_slash_added_to_paths);
|
||||
QFETCH(QStringList, expected_paths_str);
|
||||
QFETCH(QString, expected_matching);
|
||||
|
||||
QCOMPARE(getMatchingPath(path, paths), expected_matching);
|
||||
|
||||
QCOMPARE(ensureTrailingSlash(&path), expected_is_slash_added_to_path);
|
||||
QCOMPARE(path, expected_path_str);
|
||||
QCOMPARE(ensureTrailingSlashes(&paths), expected_is_slash_added_to_paths);
|
||||
QCOMPARE(paths, expected_paths_str);
|
||||
}
|
||||
|
||||
void KNetworkMountsTestStatic::testStaticKNetworkMountOptionToString_data()
|
||||
{
|
||||
QTest::addColumn<KNetworkMounts::KNetworkMountOption>("option");
|
||||
QTest::addColumn<QString>("string");
|
||||
|
||||
QTest::newRow("LowSideEffectsOptimizations") << KNetworkMounts::LowSideEffectsOptimizations << "LowSideEffectsOptimizations";
|
||||
QTest::newRow("MediumSideEffectsOptimizations") << KNetworkMounts::MediumSideEffectsOptimizations << "MediumSideEffectsOptimizations";
|
||||
QTest::newRow("StrongSideEffectsOptimizations") << KNetworkMounts::StrongSideEffectsOptimizations << "StrongSideEffectsOptimizations";
|
||||
QTest::newRow("KDirWatchUseINotify") << KNetworkMounts::KDirWatchUseINotify << "KDirWatchUseINotify";
|
||||
QTest::newRow("KDirWatchDontAddWatches") << KNetworkMounts::KDirWatchDontAddWatches << "KDirWatchDontAddWatches";
|
||||
QTest::newRow("SymlinkPathsUseCache") << KNetworkMounts::SymlinkPathsUseCache << "SymlinkPathsUseCache";
|
||||
}
|
||||
void KNetworkMountsTestStatic::testStaticKNetworkMountOptionToString()
|
||||
{
|
||||
QFETCH(KNetworkMounts::KNetworkMountOption, option);
|
||||
QFETCH(QString, string);
|
||||
|
||||
QCOMPARE(enumToString(option), string);
|
||||
}
|
||||
|
||||
void KNetworkMountsTestStatic::testStaticKNetworkMountsTypeToString_data()
|
||||
{
|
||||
QTest::addColumn<KNetworkMounts::KNetworkMountsType>("type");
|
||||
QTest::addColumn<QString>("string");
|
||||
|
||||
QTest::newRow("NfsPaths") << KNetworkMounts::NfsPaths << "NfsPaths";
|
||||
QTest::newRow("SmbPaths") << KNetworkMounts::SmbPaths << "SmbPaths";
|
||||
QTest::newRow("SymlinkDirectory") << KNetworkMounts::SymlinkDirectory << "SymlinkDirectory";
|
||||
QTest::newRow("SymlinkToNetworkMount") << KNetworkMounts::SymlinkToNetworkMount << "SymlinkToNetworkMount";
|
||||
QTest::newRow("Any") << KNetworkMounts::Any << "Any";
|
||||
}
|
||||
void KNetworkMountsTestStatic::testStaticKNetworkMountsTypeToString()
|
||||
{
|
||||
QFETCH(KNetworkMounts::KNetworkMountsType, type);
|
||||
QFETCH(QString, string);
|
||||
|
||||
QCOMPARE(enumToString(type), string);
|
||||
}
|
||||
|
||||
#include "moc_knetworkmountsteststatic.cpp"
|
||||
28
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountsteststatic.h
vendored
Normal file
28
Telegram/ThirdParty/kcoreaddons/autotests/knetworkmountsteststatic.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
This software is a contribution of the LiMux project of the city of Munich.
|
||||
SPDX-FileCopyrightText: 2021 Robert Hoffmann <robert@roberthoffmann.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KNETWORKMOUNTSTESTSTATIC_H
|
||||
#define KNETWORKMOUNTSTESTSTATIC_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KNetworkMountsTestStatic : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void testStaticFunctions_data();
|
||||
void testStaticFunctions();
|
||||
void testStaticKNetworkMountOptionToString_data();
|
||||
void testStaticKNetworkMountOptionToString();
|
||||
void testStaticKNetworkMountsTypeToString_data();
|
||||
void testStaticKNetworkMountsTypeToString();
|
||||
|
||||
private:
|
||||
QString m_configFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
43
Telegram/ThirdParty/kcoreaddons/autotests/kosreleasetest.cpp
vendored
Normal file
43
Telegram/ThirdParty/kcoreaddons/autotests/kosreleasetest.cpp
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2014-2019 Harald Sitter <sitter@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include "kosrelease.h"
|
||||
|
||||
class KOSReleaseTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void testParse()
|
||||
{
|
||||
KOSRelease r(QFINDTESTDATA("data/os-release"));
|
||||
QCOMPARE(r.name(), QStringLiteral("Name"));
|
||||
QCOMPARE(r.version(), QStringLiteral("100.5"));
|
||||
QCOMPARE(r.id(), QStringLiteral("theid"));
|
||||
QCOMPARE(r.idLike(), QStringList({QStringLiteral("otherid"), QStringLiteral("otherotherid")}));
|
||||
QCOMPARE(r.versionCodename(), QStringLiteral("versioncodename"));
|
||||
QCOMPARE(r.versionId(), QStringLiteral("500.1"));
|
||||
QCOMPARE(r.prettyName(), QStringLiteral("Pretty Name #1"));
|
||||
QCOMPARE(r.ansiColor(), QStringLiteral("1;34"));
|
||||
QCOMPARE(r.cpeName(), QStringLiteral("cpe:/o:foo:bar:100"));
|
||||
QCOMPARE(r.homeUrl(), QStringLiteral("https://url.home"));
|
||||
QCOMPARE(r.documentationUrl(), QStringLiteral("https://url.docs"));
|
||||
QCOMPARE(r.supportUrl(), QStringLiteral("https://url.support"));
|
||||
QCOMPARE(r.bugReportUrl(), QStringLiteral("https://url.bugs"));
|
||||
QCOMPARE(r.privacyPolicyUrl(), QStringLiteral("https://url.privacy"));
|
||||
QCOMPARE(r.buildId(), QStringLiteral("105.5"));
|
||||
QCOMPARE(r.variant(), QStringLiteral("Test = Edition"));
|
||||
QCOMPARE(r.variantId(), QStringLiteral("test"));
|
||||
QCOMPARE(r.logo(), QStringLiteral("start-here-test"));
|
||||
QCOMPARE(r.extraKeys(), QStringList({QStringLiteral("DEBIAN_BTS")}));
|
||||
QCOMPARE(r.extraValue(QStringLiteral("DEBIAN_BTS")), QStringLiteral("debbugs://bugs.debian.org/"));
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(KOSReleaseTest)
|
||||
|
||||
#include "kosreleasetest.moc"
|
||||
18
Telegram/ThirdParty/kcoreaddons/autotests/kpluginclass.cpp
vendored
Normal file
18
Telegram/ThirdParty/kcoreaddons/autotests/kpluginclass.cpp
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
|
||||
// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
|
||||
#include "kpluginfactory.h"
|
||||
|
||||
class SimplePluginClass : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SimplePluginClass(QObject * /*parent*/, const QVariantList & /*args*/)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
K_PLUGIN_CLASS_WITH_JSON(SimplePluginClass, "jsonplugin.json")
|
||||
|
||||
#include "kpluginclass.moc"
|
||||
139
Telegram/ThirdParty/kcoreaddons/autotests/kpluginfactorytest.cpp
vendored
Normal file
139
Telegram/ThirdParty/kcoreaddons/autotests/kpluginfactorytest.cpp
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2014 Alex Merry <alex.merry@kde.org>
|
||||
SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
|
||||
// We do not have QWidgets as a dependency, this is a simple placeholder for the type to be fully qualified
|
||||
class QWidget : public QObject
|
||||
{
|
||||
};
|
||||
|
||||
class KPluginFactoryTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void testCreate()
|
||||
{
|
||||
KPluginFactory::Result<KPluginFactory> factoryResult = KPluginFactory::loadFactory(KPluginMetaData(QStringLiteral("multiplugin")));
|
||||
auto factory = factoryResult.plugin;
|
||||
QVERIFY(factory);
|
||||
QVariantList args;
|
||||
args << QStringLiteral("Some") << QStringLiteral("args") << 5;
|
||||
|
||||
QObject *obj = factory->create<QObject>(this, args);
|
||||
QVERIFY(obj);
|
||||
QCOMPARE(obj->objectName(), QString::fromLatin1("MultiPlugin1"));
|
||||
|
||||
QObject *obj2 = factory->create<QObject>(this, args);
|
||||
QVERIFY(obj2);
|
||||
QCOMPARE(obj2->objectName(), QString::fromLatin1("MultiPlugin1"));
|
||||
QVERIFY(obj != obj2);
|
||||
delete obj;
|
||||
delete obj2;
|
||||
|
||||
// Try creating a part without keyword/args
|
||||
QWidget parentWidget;
|
||||
QObject *partTest = factory->create<QObject>(&parentWidget, this);
|
||||
QVERIFY(partTest);
|
||||
delete partTest;
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 89)
|
||||
obj = factory->create<QObject>(QStringLiteral("secondary"), this, args);
|
||||
QVERIFY(obj);
|
||||
QCOMPARE(obj->objectName(), QString::fromLatin1("MultiPlugin2"));
|
||||
|
||||
obj2 = factory->create<QObject>(QStringLiteral("secondary"), this, args);
|
||||
QVERIFY(obj2);
|
||||
QCOMPARE(obj2->objectName(), QString::fromLatin1("MultiPlugin2"));
|
||||
QVERIFY(obj != obj2);
|
||||
delete obj;
|
||||
delete obj2;
|
||||
#endif
|
||||
}
|
||||
|
||||
void testPluginWithoutMetaData()
|
||||
{
|
||||
KPluginFactory::Result<KPluginFactory> factoryResult = KPluginFactory::loadFactory(KPluginMetaData(QStringLiteral("namespace/pluginwithoutmetadata")));
|
||||
QVERIFY(factoryResult);
|
||||
auto plugin = factoryResult.plugin->create<QObject>();
|
||||
QVERIFY(plugin);
|
||||
QCOMPARE(plugin->metaObject()->className(), "PluginWithoutMetaData");
|
||||
delete plugin;
|
||||
}
|
||||
|
||||
void testResultingCMakeMacroPlugin()
|
||||
{
|
||||
KPluginMetaData data(QStringLiteral("namespace/jsonplugin_cmake_macro"));
|
||||
QVERIFY(data.isValid());
|
||||
|
||||
auto instance = QPluginLoader(data.fileName()).instance();
|
||||
QVERIFY(instance);
|
||||
QCOMPARE(instance->metaObject()->className(), "jsonplugin_cmake_macro_factory");
|
||||
}
|
||||
void testCreateUsingUtilityMethods()
|
||||
{
|
||||
auto result = KPluginFactory::instantiatePlugin<QObject>(KPluginMetaData(QStringLiteral("jsonplugin")), nullptr, QVariantList());
|
||||
QVERIFY(result.plugin);
|
||||
QCOMPARE(result.plugin->metaObject()->className(), "JsonPlugin");
|
||||
QVERIFY(result.errorString.isEmpty());
|
||||
QCOMPARE(result.errorReason, KPluginFactory::NO_PLUGIN_ERROR);
|
||||
delete result.plugin;
|
||||
}
|
||||
|
||||
void testCreateUsingUtilityMethodsErrorHandling()
|
||||
{
|
||||
{
|
||||
auto result = KPluginFactory::instantiatePlugin<QObject>(KPluginMetaData(QFINDTESTDATA("jsonplugin.json")), nullptr, QVariantList());
|
||||
QVERIFY(!result.plugin);
|
||||
QCOMPARE(result.errorReason, KPluginFactory::INVALID_PLUGIN);
|
||||
}
|
||||
{
|
||||
// it is a valid plugin, but does not contain a KPluginFactory
|
||||
QVERIFY(QPluginLoader(QStringLiteral("qtplugin")).instance());
|
||||
auto result = KPluginFactory::instantiatePlugin<QObject>(KPluginMetaData(QStringLiteral("qtplugin")), nullptr, QVariantList());
|
||||
QVERIFY(!result.plugin);
|
||||
// But does not contain a valid plugin factory
|
||||
QCOMPARE(result.errorReason, KPluginFactory::INVALID_FACTORY);
|
||||
}
|
||||
{
|
||||
// it is a QObject, but not a KPluginFactoryTest instance
|
||||
auto result = KPluginFactory::instantiatePlugin<KPluginFactoryTest>(KPluginMetaData(QStringLiteral("jsonplugin")), nullptr, QVariantList());
|
||||
QVERIFY(!result.plugin);
|
||||
QCOMPARE(result.errorReason, KPluginFactory::INVALID_KPLUGINFACTORY_INSTANTIATION);
|
||||
QVERIFY(result.errorText.contains("KPluginFactoryTest"));
|
||||
}
|
||||
}
|
||||
|
||||
void testStaticPlugins()
|
||||
{
|
||||
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("staticnamespace"));
|
||||
QCOMPARE(plugins.count(), 1);
|
||||
|
||||
auto result = KPluginFactory::instantiatePlugin<QObject>(plugins.first());
|
||||
QVERIFY(result);
|
||||
delete result.plugin;
|
||||
}
|
||||
|
||||
void testNonExistingPlugin()
|
||||
{
|
||||
KPluginMetaData data(QStringLiteral("does/not/exist"));
|
||||
QVERIFY(!data.isValid());
|
||||
const auto res = KPluginFactory::instantiatePlugin<QObject>(data);
|
||||
QVERIFY(!res);
|
||||
QCOMPARE(res.errorReason, KPluginFactory::INVALID_PLUGIN);
|
||||
QCOMPARE(res.errorText, QStringLiteral("Could not find plugin does/not/exist"));
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(KPluginFactoryTest)
|
||||
|
||||
#include "kpluginfactorytest.moc"
|
||||
389
Telegram/ThirdParty/kcoreaddons/autotests/kpluginloadertest.cpp
vendored
Normal file
389
Telegram/ThirdParty/kcoreaddons/autotests/kpluginloadertest.cpp
vendored
Normal file
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2014 Alex Merry <alex.merry@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QTest>
|
||||
|
||||
#include "kcoreaddons_debug.h"
|
||||
#include <kpluginloader.h>
|
||||
#include <kpluginmetadata.h>
|
||||
|
||||
class LibraryPathRestorer
|
||||
{
|
||||
public:
|
||||
explicit LibraryPathRestorer(const QStringList &paths)
|
||||
: mPaths(paths)
|
||||
{
|
||||
}
|
||||
~LibraryPathRestorer()
|
||||
{
|
||||
QCoreApplication::setLibraryPaths(mPaths);
|
||||
}
|
||||
|
||||
private:
|
||||
QStringList mPaths;
|
||||
};
|
||||
|
||||
class KPluginLoaderTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 86)
|
||||
private Q_SLOTS:
|
||||
void testFindPlugin_missing()
|
||||
{
|
||||
const QString location = KPluginLoader::findPlugin(QStringLiteral("idonotexist"));
|
||||
QVERIFY2(location.isEmpty(), qPrintable(location));
|
||||
}
|
||||
|
||||
void testFindPlugin()
|
||||
{
|
||||
const QString location = KPluginLoader::findPlugin(QStringLiteral("jsonplugin"));
|
||||
QVERIFY2(!location.isEmpty(), qPrintable(location));
|
||||
}
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 84)
|
||||
void testPluginVersion()
|
||||
{
|
||||
KPluginLoader vplugin(QStringLiteral("versionedplugin"));
|
||||
QCOMPARE(vplugin.pluginVersion(), quint32(5));
|
||||
|
||||
KPluginLoader vplugin2(QStringLiteral("versionedplugin"));
|
||||
QCOMPARE(vplugin2.pluginVersion(), quint32(5));
|
||||
|
||||
KPluginLoader uplugin(QStringLiteral("unversionedplugin"));
|
||||
QCOMPARE(uplugin.pluginVersion(), quint32(-1));
|
||||
|
||||
KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin")));
|
||||
QCOMPARE(jplugin.pluginVersion(), quint32(-1));
|
||||
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QCOMPARE(eplugin.pluginVersion(), quint32(-1));
|
||||
|
||||
KPluginLoader noplugin(QStringLiteral("idonotexist"));
|
||||
QCOMPARE(noplugin.pluginVersion(), quint32(-1));
|
||||
}
|
||||
#endif
|
||||
|
||||
void testPluginName()
|
||||
{
|
||||
KPluginLoader vplugin(QStringLiteral("versionedplugin"));
|
||||
QCOMPARE(vplugin.pluginName(), QString::fromLatin1("versionedplugin"));
|
||||
|
||||
KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin")));
|
||||
QCOMPARE(jplugin.pluginName(), QString::fromLatin1("jsonplugin"));
|
||||
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QVERIFY2(eplugin.pluginName().isEmpty(), qPrintable(eplugin.pluginName()));
|
||||
|
||||
KPluginLoader noplugin(QStringLiteral("idonotexist"));
|
||||
QCOMPARE(noplugin.pluginName(), QString::fromLatin1("idonotexist"));
|
||||
}
|
||||
|
||||
void testFactory()
|
||||
{
|
||||
KPluginLoader vplugin(QStringLiteral("versionedplugin"));
|
||||
QVERIFY(vplugin.factory());
|
||||
|
||||
KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin")));
|
||||
QVERIFY(jplugin.factory());
|
||||
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QVERIFY(!eplugin.factory());
|
||||
|
||||
KPluginLoader noplugin(QStringLiteral("idonotexist"));
|
||||
QVERIFY(!noplugin.factory());
|
||||
}
|
||||
|
||||
void testErrorString()
|
||||
{
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QCOMPARE(eplugin.errorString(), QString::fromLatin1("there was an error"));
|
||||
}
|
||||
|
||||
void testFileName()
|
||||
{
|
||||
KPluginLoader vplugin(QStringLiteral("versionedplugin"));
|
||||
QCOMPARE(QFileInfo(vplugin.fileName()).canonicalFilePath(), QFileInfo(QStringLiteral(VERSIONEDPLUGIN_FILE)).canonicalFilePath());
|
||||
|
||||
KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin")));
|
||||
QCOMPARE(QFileInfo(jplugin.fileName()).canonicalFilePath(), QFileInfo(QStringLiteral(JSONPLUGIN_FILE)).canonicalFilePath());
|
||||
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QVERIFY2(eplugin.fileName().isEmpty(), qPrintable(eplugin.fileName()));
|
||||
|
||||
KPluginLoader noplugin(QStringLiteral("idonotexist"));
|
||||
QVERIFY2(noplugin.fileName().isEmpty(), qPrintable(noplugin.fileName()));
|
||||
}
|
||||
|
||||
void testInstance()
|
||||
{
|
||||
KPluginLoader vplugin(QStringLiteral("versionedplugin"));
|
||||
QVERIFY(vplugin.instance());
|
||||
|
||||
KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin")));
|
||||
QVERIFY(jplugin.instance());
|
||||
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QVERIFY(!eplugin.instance());
|
||||
|
||||
KPluginLoader noplugin(QStringLiteral("idonotexist"));
|
||||
QVERIFY(!noplugin.instance());
|
||||
}
|
||||
|
||||
void testIsLoaded()
|
||||
{
|
||||
KPluginLoader vplugin(QStringLiteral("versionedplugin"));
|
||||
QVERIFY(!vplugin.isLoaded());
|
||||
QVERIFY(vplugin.load());
|
||||
QVERIFY(vplugin.isLoaded());
|
||||
|
||||
KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin")));
|
||||
QVERIFY(!jplugin.isLoaded());
|
||||
QVERIFY(jplugin.load());
|
||||
QVERIFY(jplugin.isLoaded());
|
||||
|
||||
KPluginLoader aplugin(QStringLiteral("alwaysunloadplugin"));
|
||||
QVERIFY(!aplugin.isLoaded());
|
||||
QVERIFY(aplugin.load());
|
||||
QVERIFY(aplugin.isLoaded());
|
||||
if (aplugin.unload()) {
|
||||
QVERIFY(!aplugin.isLoaded());
|
||||
} else {
|
||||
qCDebug(KCOREADDONS_DEBUG) << "Could not unload alwaysunloadplugin:" << aplugin.errorString();
|
||||
}
|
||||
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QVERIFY(!eplugin.isLoaded());
|
||||
QVERIFY(!eplugin.load());
|
||||
QVERIFY(!eplugin.isLoaded());
|
||||
|
||||
KPluginLoader noplugin(QStringLiteral("idonotexist"));
|
||||
QVERIFY(!noplugin.isLoaded());
|
||||
QVERIFY(!noplugin.load());
|
||||
QVERIFY(!noplugin.isLoaded());
|
||||
}
|
||||
|
||||
void testLoad()
|
||||
{
|
||||
KPluginLoader vplugin(QStringLiteral("versionedplugin"));
|
||||
QVERIFY(vplugin.load());
|
||||
|
||||
KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin")));
|
||||
QVERIFY(jplugin.load());
|
||||
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QVERIFY(!eplugin.load());
|
||||
|
||||
KPluginLoader noplugin(QStringLiteral("idonotexist"));
|
||||
QVERIFY(!noplugin.load());
|
||||
}
|
||||
|
||||
void testLoadHints()
|
||||
{
|
||||
KPluginLoader aplugin(QStringLiteral("alwaysunloadplugin"));
|
||||
QCOMPARE(aplugin.loadHints(), QLibrary::PreventUnloadHint);
|
||||
aplugin.setLoadHints(QLibrary::ResolveAllSymbolsHint);
|
||||
// setLoadHints merges in this scenario in the patch collection [1] but not in raw Qt5
|
||||
// [1] https://invent.kde.org/qt/qt/qtbase/-/merge_requests/285
|
||||
QVERIFY(aplugin.loadHints() == (QLibrary::ResolveAllSymbolsHint | QLibrary::PreventUnloadHint)
|
||||
|| aplugin.loadHints() == QLibrary::ResolveAllSymbolsHint);
|
||||
}
|
||||
|
||||
void testMetaData()
|
||||
{
|
||||
KPluginLoader aplugin(QStringLiteral("alwaysunloadplugin"));
|
||||
QJsonObject ametadata = aplugin.metaData();
|
||||
QVERIFY(!ametadata.isEmpty());
|
||||
QVERIFY(ametadata.keys().contains(QLatin1String("IID")));
|
||||
QJsonValue ametadata_metadata = ametadata.value(QStringLiteral("MetaData"));
|
||||
QVERIFY(ametadata_metadata.toObject().isEmpty());
|
||||
QVERIFY(!aplugin.isLoaded()); // didn't load anything
|
||||
|
||||
KPluginLoader jplugin(KPluginName(QStringLiteral("jsonplugin")));
|
||||
QJsonObject jmetadata = jplugin.metaData();
|
||||
QVERIFY(!jmetadata.isEmpty());
|
||||
QJsonValue jmetadata_metadata = jmetadata.value(QStringLiteral("MetaData"));
|
||||
QVERIFY(jmetadata_metadata.isObject());
|
||||
QJsonObject jmetadata_obj = jmetadata_metadata.toObject();
|
||||
QVERIFY(!jmetadata_obj.isEmpty());
|
||||
QJsonValue comment = jmetadata_obj.value(QStringLiteral("KPlugin")).toObject().value(QStringLiteral("Description"));
|
||||
QVERIFY(comment.isString());
|
||||
QCOMPARE(comment.toString(), QString::fromLatin1("This is a plugin"));
|
||||
|
||||
KPluginLoader eplugin(KPluginName::fromErrorString(QStringLiteral("there was an error")));
|
||||
QVERIFY(eplugin.metaData().isEmpty());
|
||||
|
||||
KPluginLoader noplugin(QStringLiteral("idonotexist"));
|
||||
QVERIFY(noplugin.metaData().isEmpty());
|
||||
}
|
||||
|
||||
void testUnload()
|
||||
{
|
||||
KPluginLoader aplugin(QStringLiteral("alwaysunloadplugin"));
|
||||
QVERIFY(aplugin.load());
|
||||
// may need QEXPECT_FAIL on some platforms...
|
||||
QVERIFY(aplugin.unload());
|
||||
}
|
||||
|
||||
void testInstantiatePlugins()
|
||||
{
|
||||
const QString plugin1Path = KPluginLoader::findPlugin(QStringLiteral("jsonplugin"));
|
||||
QVERIFY2(!plugin1Path.isEmpty(), qPrintable(plugin1Path));
|
||||
const QString plugin2Path = KPluginLoader::findPlugin(QStringLiteral("unversionedplugin"));
|
||||
QVERIFY2(!plugin2Path.isEmpty(), qPrintable(plugin2Path));
|
||||
const QString plugin3Path = KPluginLoader::findPlugin(QStringLiteral("jsonplugin2"));
|
||||
QVERIFY2(!plugin3Path.isEmpty(), qPrintable(plugin3Path));
|
||||
|
||||
QTemporaryDir temp;
|
||||
QVERIFY(temp.isValid());
|
||||
QDir dir(temp.path());
|
||||
QVERIFY2(QFile::copy(plugin1Path, dir.absoluteFilePath(QFileInfo(plugin1Path).fileName())),
|
||||
qPrintable(dir.absoluteFilePath(QFileInfo(plugin1Path).fileName())));
|
||||
QVERIFY2(QFile::copy(plugin2Path, dir.absoluteFilePath(QFileInfo(plugin2Path).fileName())),
|
||||
qPrintable(dir.absoluteFilePath(QFileInfo(plugin2Path).fileName())));
|
||||
QVERIFY2(QFile::copy(plugin3Path, dir.absoluteFilePath(QFileInfo(plugin3Path).fileName())),
|
||||
qPrintable(dir.absoluteFilePath(QFileInfo(plugin3Path).fileName())));
|
||||
|
||||
// only jsonplugin, since unversionedplugin has no json metadata
|
||||
QList<QObject *> plugins = KPluginLoader::instantiatePlugins(temp.path());
|
||||
QCOMPARE(plugins.size(), 2);
|
||||
QStringList classNames = QStringList() << QString::fromLatin1(plugins[0]->metaObject()->className())
|
||||
<< QString::fromLatin1(plugins[1]->metaObject()->className());
|
||||
classNames.sort();
|
||||
QCOMPARE(classNames[0], QStringLiteral("jsonplugin2"));
|
||||
QCOMPARE(classNames[1], QStringLiteral("jsonpluginfa"));
|
||||
qDeleteAll(plugins);
|
||||
|
||||
// try filter
|
||||
plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData &md) {
|
||||
return md.pluginId() == QLatin1String("jsonplugin");
|
||||
});
|
||||
QCOMPARE(plugins.size(), 1);
|
||||
QCOMPARE(plugins[0]->metaObject()->className(), "jsonpluginfa");
|
||||
qDeleteAll(plugins);
|
||||
|
||||
plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData &md) {
|
||||
return md.pluginId() == QLatin1String("unversionedplugin");
|
||||
});
|
||||
QCOMPARE(plugins.size(), 0);
|
||||
|
||||
plugins = KPluginLoader::instantiatePlugins(temp.path(), [](const KPluginMetaData &md) {
|
||||
return md.pluginId() == QLatin1String("foobar"); // ID does not match file name, is set in JSON
|
||||
});
|
||||
QCOMPARE(plugins.size(), 1);
|
||||
QCOMPARE(plugins[0]->metaObject()->className(), "jsonplugin2");
|
||||
qDeleteAll(plugins);
|
||||
|
||||
// check that parent gets set
|
||||
plugins = KPluginLoader::instantiatePlugins(
|
||||
temp.path(),
|
||||
[](const KPluginMetaData &) {
|
||||
return true;
|
||||
},
|
||||
this);
|
||||
QCOMPARE(plugins.size(), 2);
|
||||
QCOMPARE(plugins[0]->parent(), this);
|
||||
QCOMPARE(plugins[1]->parent(), this);
|
||||
qDeleteAll(plugins);
|
||||
|
||||
const QString subDirName = dir.dirName();
|
||||
QVERIFY(dir.cdUp()); // should now point to /tmp on Linux
|
||||
LibraryPathRestorer restorer(QCoreApplication::libraryPaths());
|
||||
// instantiate using relative path
|
||||
// make sure library path is set up correctly
|
||||
QCoreApplication::setLibraryPaths(QStringList() << dir.absolutePath());
|
||||
QVERIFY(!QDir::isAbsolutePath(subDirName));
|
||||
plugins = KPluginLoader::instantiatePlugins(subDirName);
|
||||
QCOMPARE(plugins.size(), 2);
|
||||
classNames = QStringList() << QString::fromLatin1(plugins[0]->metaObject()->className()) << QString::fromLatin1(plugins[1]->metaObject()->className());
|
||||
classNames.sort();
|
||||
QCOMPARE(classNames[0], QStringLiteral("jsonplugin2"));
|
||||
QCOMPARE(classNames[1], QStringLiteral("jsonpluginfa"));
|
||||
qDeleteAll(plugins);
|
||||
}
|
||||
|
||||
void testForEachPlugin()
|
||||
{
|
||||
const QString jsonPluginSrc = KPluginLoader::findPlugin(QStringLiteral("jsonplugin"));
|
||||
QVERIFY2(!jsonPluginSrc.isEmpty(), qPrintable(jsonPluginSrc));
|
||||
const QString unversionedPluginSrc = KPluginLoader::findPlugin(QStringLiteral("unversionedplugin"));
|
||||
QVERIFY2(!unversionedPluginSrc.isEmpty(), qPrintable(unversionedPluginSrc));
|
||||
const QString jsonPlugin2Src = KPluginLoader::findPlugin(QStringLiteral("jsonplugin2"));
|
||||
QVERIFY2(!jsonPlugin2Src.isEmpty(), qPrintable(jsonPlugin2Src));
|
||||
|
||||
QTemporaryDir temp;
|
||||
QVERIFY(temp.isValid());
|
||||
QDir dir(temp.path());
|
||||
QVERIFY(dir.mkdir(QStringLiteral("for-each-plugin")));
|
||||
QVERIFY(dir.cd(QStringLiteral("for-each-plugin")));
|
||||
const QString jsonPluginDest = dir.absoluteFilePath(QFileInfo(jsonPluginSrc).fileName());
|
||||
QVERIFY2(QFile::copy(jsonPluginSrc, jsonPluginDest), qPrintable(jsonPluginDest));
|
||||
const QString unversionedPluginDest = dir.absoluteFilePath(QFileInfo(unversionedPluginSrc).fileName());
|
||||
QVERIFY2(QFile::copy(unversionedPluginSrc, unversionedPluginDest), qPrintable(unversionedPluginDest));
|
||||
// copy jsonplugin2 to a "for-each-plugin" subdirectory in a different directory
|
||||
QTemporaryDir temp2;
|
||||
QVERIFY(temp2.isValid());
|
||||
QDir dir2(temp2.path());
|
||||
QVERIFY(dir2.mkdir(QStringLiteral("for-each-plugin")));
|
||||
QVERIFY(dir2.cd(QStringLiteral("for-each-plugin")));
|
||||
const QString jsonPlugin2Dest = dir2.absoluteFilePath(QFileInfo(jsonPlugin2Src).fileName());
|
||||
QVERIFY2(QFile::copy(jsonPlugin2Src, jsonPlugin2Dest), qPrintable(jsonPlugin2Dest));
|
||||
|
||||
QStringList foundPlugins;
|
||||
QStringList expectedPlugins;
|
||||
const auto addToFoundPlugins = [&](const QString &path) {
|
||||
QVERIFY(!path.isEmpty());
|
||||
foundPlugins.append(path);
|
||||
};
|
||||
|
||||
// test finding with absolute path
|
||||
expectedPlugins = QStringList() << jsonPluginDest << unversionedPluginDest;
|
||||
expectedPlugins.sort();
|
||||
KPluginLoader::forEachPlugin(dir.path(), addToFoundPlugins);
|
||||
foundPlugins.sort();
|
||||
QCOMPARE(foundPlugins, expectedPlugins);
|
||||
|
||||
expectedPlugins = QStringList() << jsonPlugin2Dest;
|
||||
expectedPlugins.sort();
|
||||
foundPlugins.clear();
|
||||
KPluginLoader::forEachPlugin(dir2.path(), addToFoundPlugins);
|
||||
foundPlugins.sort();
|
||||
QCOMPARE(foundPlugins, expectedPlugins);
|
||||
|
||||
// now test relative paths
|
||||
|
||||
LibraryPathRestorer restorer(QCoreApplication::libraryPaths());
|
||||
QCoreApplication::setLibraryPaths(QStringList() << temp.path());
|
||||
expectedPlugins = QStringList() << jsonPluginDest << unversionedPluginDest;
|
||||
expectedPlugins.sort();
|
||||
foundPlugins.clear();
|
||||
KPluginLoader::forEachPlugin(QStringLiteral("for-each-plugin"), addToFoundPlugins);
|
||||
foundPlugins.sort();
|
||||
QCOMPARE(foundPlugins, expectedPlugins);
|
||||
|
||||
QCoreApplication::setLibraryPaths(QStringList() << temp2.path());
|
||||
expectedPlugins = QStringList() << jsonPlugin2Dest;
|
||||
expectedPlugins.sort();
|
||||
foundPlugins.clear();
|
||||
KPluginLoader::forEachPlugin(QStringLiteral("for-each-plugin"), addToFoundPlugins);
|
||||
foundPlugins.sort();
|
||||
QCOMPARE(foundPlugins, expectedPlugins);
|
||||
|
||||
QCoreApplication::setLibraryPaths(QStringList() << temp.path() << temp2.path());
|
||||
expectedPlugins = QStringList() << jsonPluginDest << unversionedPluginDest << jsonPlugin2Dest;
|
||||
expectedPlugins.sort();
|
||||
foundPlugins.clear();
|
||||
KPluginLoader::forEachPlugin(QStringLiteral("for-each-plugin"), addToFoundPlugins);
|
||||
foundPlugins.sort();
|
||||
QCOMPARE(foundPlugins, expectedPlugins);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
QTEST_MAIN(KPluginLoaderTest)
|
||||
|
||||
#include "kpluginloadertest.moc"
|
||||
716
Telegram/ThirdParty/kcoreaddons/autotests/kpluginmetadatatest.cpp
vendored
Normal file
716
Telegram/ThirdParty/kcoreaddons/autotests/kpluginmetadatatest.cpp
vendored
Normal file
@@ -0,0 +1,716 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2014 Alex Richardson <arichardson.kde@gmail.com>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
||||
*/
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QPluginLoader>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
#include <QTest>
|
||||
|
||||
#include "kcoreaddons_debug.h"
|
||||
#include <kaboutdata.h>
|
||||
#include <kpluginloader.h>
|
||||
#include <kpluginmetadata.h>
|
||||
|
||||
#include <QLocale>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
namespace QTest
|
||||
{
|
||||
template<>
|
||||
inline char *toString(const QJsonValue &val)
|
||||
{
|
||||
// simply reuse the QDebug representation
|
||||
QString result;
|
||||
QDebug(&result) << val;
|
||||
return QTest::toString(result);
|
||||
}
|
||||
}
|
||||
|
||||
class LibraryPathRestorer
|
||||
{
|
||||
public:
|
||||
explicit LibraryPathRestorer(const QStringList &paths)
|
||||
: mPaths(paths)
|
||||
{
|
||||
}
|
||||
~LibraryPathRestorer()
|
||||
{
|
||||
QCoreApplication::setLibraryPaths(mPaths);
|
||||
}
|
||||
|
||||
private:
|
||||
QStringList mPaths;
|
||||
};
|
||||
|
||||
class KPluginMetaDataTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
bool m_canMessage = false;
|
||||
|
||||
void doMessagesWorkInternal()
|
||||
{
|
||||
}
|
||||
|
||||
Q_REQUIRED_RESULT bool doMessagesWork()
|
||||
{
|
||||
// Q_SKIP returns, but since this is called in multiple tests we want to return a bool so the caller can
|
||||
// return easily.
|
||||
auto internalCheck = [this] {
|
||||
// Make sure output is well formed AND generated. To that end we cannot run this test when any of the
|
||||
// overriding environment variables are set.
|
||||
// https://bugs.kde.org/show_bug.cgi?id=387006
|
||||
if (qEnvironmentVariableIsSet("QT_MESSAGE_PATTERN")) {
|
||||
QSKIP("QT_MESSAGE_PATTERN prevents warning expectations from matching");
|
||||
}
|
||||
if (qEnvironmentVariableIsSet("QT_LOGGING_RULES")) {
|
||||
QSKIP("QT_LOGGING_RULES prevents warning expectations from matching");
|
||||
}
|
||||
if (qEnvironmentVariableIsSet("QT_LOGGING_CONF")) {
|
||||
QSKIP("QT_LOGGING_CONF prevents warning expectations from matching");
|
||||
}
|
||||
m_canMessage = true;
|
||||
// Ensure all frameworks output is enabled so the expectations can match.
|
||||
// qtlogging.ini may have disabled it but we can fix that because setFilterRules overrides the ini files.
|
||||
QLoggingCategory::setFilterRules(QStringLiteral("kf.*=true"));
|
||||
};
|
||||
internalCheck();
|
||||
return m_canMessage;
|
||||
}
|
||||
private Q_SLOTS:
|
||||
|
||||
void testFromPluginLoader()
|
||||
{
|
||||
QString location;
|
||||
location = QPluginLoader(QStringLiteral("jsonplugin")).fileName();
|
||||
QVERIFY2(!location.isEmpty(), "Could not find jsonplugin");
|
||||
|
||||
// now that this file is translated we need to read it instead of hardcoding the contents here
|
||||
QString jsonLocation = QFINDTESTDATA("jsonplugin.json");
|
||||
QVERIFY2(!jsonLocation.isEmpty(), "Could not find jsonplugin.json");
|
||||
QFile jsonFile(jsonLocation);
|
||||
QVERIFY(jsonFile.open(QFile::ReadOnly));
|
||||
QJsonParseError e;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonFile.readAll(), &e);
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
|
||||
location = QFileInfo(location).absoluteFilePath();
|
||||
|
||||
KPluginMetaData fromQPluginLoader(QPluginLoader(QStringLiteral("jsonplugin")));
|
||||
KPluginMetaData fromFullPath(location);
|
||||
KPluginMetaData fromRelativePath(QStringLiteral("jsonplugin"));
|
||||
KPluginMetaData fromRawData(jsonDoc.object(), location);
|
||||
|
||||
auto description = QStringLiteral("This is a plugin");
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 86)
|
||||
KPluginMetaData fromKPluginLoader(KPluginLoader(QStringLiteral("jsonplugin")));
|
||||
QVERIFY(fromKPluginLoader.isValid());
|
||||
QCOMPARE(fromKPluginLoader.description(), description);
|
||||
QCOMPARE(fromKPluginLoader, fromKPluginLoader);
|
||||
QCOMPARE(fromQPluginLoader, fromKPluginLoader);
|
||||
QCOMPARE(fromKPluginLoader, fromQPluginLoader);
|
||||
QCOMPARE(fromKPluginLoader, fromFullPath);
|
||||
QCOMPARE(fromKPluginLoader, fromRawData);
|
||||
QCOMPARE(fromFullPath, fromKPluginLoader);
|
||||
QCOMPARE(fromRawData, fromKPluginLoader);
|
||||
QVERIFY(!KPluginMetaData(KPluginLoader(QStringLiteral("doesnotexist"))).isValid());
|
||||
#endif
|
||||
|
||||
QVERIFY(fromQPluginLoader.isValid());
|
||||
QCOMPARE(fromQPluginLoader.description(), description);
|
||||
QVERIFY(fromFullPath.isValid());
|
||||
QCOMPARE(fromFullPath.description(), description);
|
||||
QVERIFY(fromRelativePath.isValid());
|
||||
QCOMPARE(fromRelativePath.description(), description);
|
||||
QVERIFY(fromRawData.isValid());
|
||||
QCOMPARE(fromRawData.description(), description);
|
||||
|
||||
// check operator==
|
||||
QCOMPARE(fromRawData, fromRawData);
|
||||
QCOMPARE(fromQPluginLoader, fromQPluginLoader);
|
||||
QCOMPARE(fromFullPath, fromFullPath);
|
||||
|
||||
QCOMPARE(fromQPluginLoader, fromFullPath);
|
||||
QCOMPARE(fromQPluginLoader, fromRawData);
|
||||
|
||||
QCOMPARE(fromFullPath, fromQPluginLoader);
|
||||
QCOMPARE(fromFullPath, fromRawData);
|
||||
|
||||
QCOMPARE(fromRawData, fromQPluginLoader);
|
||||
QCOMPARE(fromRawData, fromFullPath);
|
||||
|
||||
QVERIFY(!KPluginMetaData(QPluginLoader(QStringLiteral("doesnotexist"))).isValid());
|
||||
QVERIFY(!KPluginMetaData(QJsonObject(), QString()).isValid());
|
||||
}
|
||||
|
||||
void testAllKeys()
|
||||
{
|
||||
QJsonParseError e;
|
||||
QJsonObject jo = QJsonDocument::fromJson(
|
||||
"{\n"
|
||||
" \"KPlugin\": {\n"
|
||||
" \"Name\": \"Date and Time\",\n"
|
||||
" \"Description\": \"Date and time by timezone\",\n"
|
||||
" \"Icon\": \"preferences-system-time\",\n"
|
||||
" \"Authors\": { \"Name\": \"Aaron Seigo\", \"Email\": \"aseigo@kde.org\" },\n"
|
||||
" \"Translators\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n"
|
||||
" \"OtherContributors\": { \"Name\": \"No One\", \"Email\": \"no.one@kde.org\" },\n"
|
||||
" \"Category\": \"Date and Time\",\n"
|
||||
" \"Dependencies\": [ \"foo\", \"bar\"],\n"
|
||||
" \"EnabledByDefault\": \"true\",\n"
|
||||
" \"ExtraInformation\": \"Something else\",\n"
|
||||
" \"License\": \"LGPL\",\n"
|
||||
" \"Copyright\": \"(c) Alex Richardson 2015\",\n"
|
||||
" \"Id\": \"time\",\n"
|
||||
" \"Version\": \"1.0\",\n"
|
||||
" \"Website\": \"https://plasma.kde.org/\",\n"
|
||||
" \"MimeTypes\": [ \"image/png\" ],\n"
|
||||
" \"ServiceTypes\": [\"Plasma/DataEngine\"]\n"
|
||||
" }\n}\n",
|
||||
&e)
|
||||
.object();
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
KPluginMetaData m(jo, QString());
|
||||
QVERIFY(m.isValid());
|
||||
QCOMPARE(m.pluginId(), QStringLiteral("time"));
|
||||
QCOMPARE(m.name(), QStringLiteral("Date and Time"));
|
||||
QCOMPARE(m.description(), QStringLiteral("Date and time by timezone"));
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 87)
|
||||
QCOMPARE(m.extraInformation(), QStringLiteral("Something else"));
|
||||
#endif
|
||||
QCOMPARE(m.iconName(), QStringLiteral("preferences-system-time"));
|
||||
QCOMPARE(m.category(), QStringLiteral("Date and Time"));
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 79)
|
||||
QCOMPARE(m.dependencies(), QStringList() << QStringLiteral("foo") << QStringLiteral("bar"));
|
||||
#endif
|
||||
QCOMPARE(m.authors().size(), 1);
|
||||
QCOMPARE(m.authors().constFirst().name(), QStringLiteral("Aaron Seigo"));
|
||||
QCOMPARE(m.authors().constFirst().emailAddress(), QStringLiteral("aseigo@kde.org"));
|
||||
QCOMPARE(m.translators().size(), 1);
|
||||
QCOMPARE(m.translators().constFirst().name(), QStringLiteral("No One"));
|
||||
QCOMPARE(m.translators().constFirst().emailAddress(), QStringLiteral("no.one@kde.org"));
|
||||
QCOMPARE(m.otherContributors().size(), 1);
|
||||
QCOMPARE(m.otherContributors().constFirst().name(), QStringLiteral("No One"));
|
||||
QCOMPARE(m.otherContributors().constFirst().emailAddress(), QStringLiteral("no.one@kde.org"));
|
||||
QVERIFY(m.isEnabledByDefault());
|
||||
QCOMPARE(m.license(), QStringLiteral("LGPL"));
|
||||
QCOMPARE(m.copyrightText(), QStringLiteral("(c) Alex Richardson 2015"));
|
||||
QCOMPARE(m.version(), QStringLiteral("1.0"));
|
||||
QCOMPARE(m.website(), QStringLiteral("https://plasma.kde.org/"));
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 89)
|
||||
QCOMPARE(m.serviceTypes(), QStringList() << QStringLiteral("Plasma/DataEngine"));
|
||||
#endif
|
||||
QCOMPARE(m.mimeTypes(), QStringList() << QStringLiteral("image/png"));
|
||||
}
|
||||
|
||||
void testTranslations()
|
||||
{
|
||||
QJsonParseError e;
|
||||
QJsonObject jo = QJsonDocument::fromJson(
|
||||
"{ \"KPlugin\": {\n"
|
||||
"\"Name\": \"Name\",\n"
|
||||
"\"Name[de]\": \"Name (de)\",\n"
|
||||
"\"Name[de_DE]\": \"Name (de_DE)\",\n"
|
||||
"\"Description\": \"Description\",\n"
|
||||
"\"Description[de]\": \"Beschreibung (de)\",\n"
|
||||
"\"Description[de_DE]\": \"Beschreibung (de_DE)\"\n"
|
||||
"}\n}",
|
||||
&e)
|
||||
.object();
|
||||
KPluginMetaData m(jo, QString());
|
||||
QLocale::setDefault(QLocale::c());
|
||||
QCOMPARE(m.name(), QStringLiteral("Name"));
|
||||
QCOMPARE(m.description(), QStringLiteral("Description"));
|
||||
|
||||
QLocale::setDefault(QLocale(QStringLiteral("de_DE")));
|
||||
QCOMPARE(m.name(), QStringLiteral("Name (de_DE)"));
|
||||
QCOMPARE(m.description(), QStringLiteral("Beschreibung (de_DE)"));
|
||||
|
||||
QLocale::setDefault(QLocale(QStringLiteral("de_CH")));
|
||||
QCOMPARE(m.name(), QStringLiteral("Name (de)"));
|
||||
QCOMPARE(m.description(), QStringLiteral("Beschreibung (de)"));
|
||||
|
||||
QLocale::setDefault(QLocale(QStringLiteral("fr_FR")));
|
||||
QCOMPARE(m.name(), QStringLiteral("Name"));
|
||||
QCOMPARE(m.description(), QStringLiteral("Description"));
|
||||
}
|
||||
|
||||
void testReadStringList()
|
||||
{
|
||||
if (!doMessagesWork()) {
|
||||
return;
|
||||
}
|
||||
QJsonParseError e;
|
||||
QJsonObject jo = QJsonDocument::fromJson(
|
||||
"{\n"
|
||||
"\"String\": \"foo\",\n"
|
||||
"\"OneArrayEntry\": [ \"foo\" ],\n"
|
||||
"\"Bool\": true,\n" // make sure booleans are accepted
|
||||
"\"QuotedBool\": \"true\",\n" // make sure booleans are accepted
|
||||
"\"Number\": 12345,\n" // number should also work
|
||||
"\"QuotedNumber\": \"12345\",\n" // number should also work
|
||||
"\"EmptyArray\": [],\n"
|
||||
"\"NumberArray\": [1, 2, 3],\n"
|
||||
"\"BoolArray\": [true, false, true],\n"
|
||||
"\"StringArray\": [\"foo\", \"bar\"],\n"
|
||||
"\"Null\": null,\n" // should return empty list
|
||||
"\"QuotedNull\": \"null\",\n" // this is okay, it is a string
|
||||
"\"ArrayWithNull\": [ \"foo\", null, \"bar\"],\n" // TODO: null is converted to empty string, is this okay?
|
||||
"\"Object\": { \"foo\": \"bar\" }\n" // should return empty list
|
||||
"}",
|
||||
&e)
|
||||
.object();
|
||||
QCOMPARE(e.error, QJsonParseError::NoError);
|
||||
QTest::ignoreMessage(QtWarningMsg, QRegularExpression(QStringLiteral("Expected JSON property ")));
|
||||
KPluginMetaData data(jo, QStringLiteral("test"));
|
||||
QCOMPARE(data.value(QStringLiteral("String"), QStringList()), QStringList(QStringLiteral("foo")));
|
||||
QCOMPARE(data.value(QStringLiteral("OneArrayEntry"), QStringList()), QStringList(QStringLiteral("foo")));
|
||||
QCOMPARE(data.value(QStringLiteral("Bool"), QStringList()), QStringList(QStringLiteral("true")));
|
||||
QCOMPARE(data.value(QStringLiteral("QuotedBool"), QStringList()), QStringList(QStringLiteral("true")));
|
||||
QCOMPARE(data.value(QStringLiteral("Number"), QStringList()), QStringList(QStringLiteral("12345")));
|
||||
QCOMPARE(data.value(QStringLiteral("QuotedNumber"), QStringList()), QStringList(QStringLiteral("12345")));
|
||||
QCOMPARE(data.value(QStringLiteral("EmptyArray"), QStringList()), QStringList());
|
||||
QCOMPARE(data.value(QStringLiteral("NumberArray"), QStringList()), QStringList() << QStringLiteral("1") << QStringLiteral("2") << QStringLiteral("3"));
|
||||
QCOMPARE(data.value(QStringLiteral("BoolArray"), QStringList()),
|
||||
QStringList() << QStringLiteral("true") << QStringLiteral("false") << QStringLiteral("true"));
|
||||
QCOMPARE(data.value(QStringLiteral("StringArray"), QStringList()), QStringList() << QStringLiteral("foo") << QStringLiteral("bar"));
|
||||
QCOMPARE(data.value(QStringLiteral("Null"), QStringList()), QStringList());
|
||||
QCOMPARE(data.value(QStringLiteral("QuotedNull"), QStringList()), QStringList(QStringLiteral("null")));
|
||||
QCOMPARE(data.value(QStringLiteral("ArrayWithNull"), QStringList()), QStringList() << QStringLiteral("foo") << QString() << QStringLiteral("bar"));
|
||||
QCOMPARE(data.value(QStringLiteral("Object"), QStringList()), QStringList());
|
||||
}
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 91)
|
||||
void testFromDesktopFile()
|
||||
{
|
||||
const QString dfile = QFINDTESTDATA("data/fakeplugin.desktop");
|
||||
KPluginMetaData md = KPluginMetaData::fromDesktopFile(dfile);
|
||||
QVERIFY(md.isValid());
|
||||
QCOMPARE(md.pluginId(), QStringLiteral("fakeplugin"));
|
||||
QCOMPARE(md.fileName(), QStringLiteral("fakeplugin"));
|
||||
QCOMPARE(md.metaDataFileName(), dfile);
|
||||
QCOMPARE(md.iconName(), QStringLiteral("preferences-system-time"));
|
||||
QCOMPARE(md.license(), QStringLiteral("LGPL"));
|
||||
QCOMPARE(md.website(), QStringLiteral("https://kde.org/"));
|
||||
QCOMPARE(md.category(), QStringLiteral("Examples"));
|
||||
QCOMPARE(md.version(), QStringLiteral("1.0"));
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 79)
|
||||
QCOMPARE(md.dependencies(), QStringList());
|
||||
#endif
|
||||
QCOMPARE(md.isHidden(), false);
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 89)
|
||||
QCOMPARE(md.serviceTypes(), QStringList(QStringLiteral("KService/NSA")));
|
||||
#endif
|
||||
QCOMPARE(md.mimeTypes(), QStringList() << QStringLiteral("image/png") << QStringLiteral("application/pdf"));
|
||||
|
||||
auto kp = md.rawData()[QStringLiteral("KPlugin")].toObject();
|
||||
QStringList formFactors = kp.value(QStringLiteral("FormFactors")).toVariant().toStringList();
|
||||
QCOMPARE(formFactors, QStringList() << QStringLiteral("mediacenter") << QStringLiteral("desktop"));
|
||||
QCOMPARE(md.formFactors(), QStringList() << QStringLiteral("mediacenter") << QStringLiteral("desktop"));
|
||||
|
||||
const QString dfilehidden = QFINDTESTDATA("data/hiddenplugin.desktop");
|
||||
KPluginMetaData mdhidden = KPluginMetaData::fromDesktopFile(dfilehidden);
|
||||
QVERIFY(mdhidden.isValid());
|
||||
QCOMPARE(mdhidden.isHidden(), true);
|
||||
}
|
||||
|
||||
void twoStepsParseTest()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
const QString dfile = QFINDTESTDATA("data/twostepsparsetest.desktop");
|
||||
const QString typesPath = QFINDTESTDATA("data/servicetypes/example-servicetype.desktop");
|
||||
KPluginMetaData md = KPluginMetaData::fromDesktopFile(dfile, QStringList() << typesPath);
|
||||
QVERIFY(md.isValid());
|
||||
QStringList list = md.value(QStringLiteral("X-Test-List"), QStringList());
|
||||
QCOMPARE(list, QStringList({QStringLiteral("first"), QStringLiteral("second")}));
|
||||
}
|
||||
|
||||
void testServiceTypes_data()
|
||||
{
|
||||
const QString kdevServiceTypePath = QFINDTESTDATA("data/servicetypes/fake-kdevelopplugin.desktop");
|
||||
const QString invalidServiceTypePath = QFINDTESTDATA("data/servicetypes/invalid-servicetype.desktop");
|
||||
const QString exampleServiceTypePath = QFINDTESTDATA("data/servicetypes/example-servicetype.desktop");
|
||||
QVERIFY(!kdevServiceTypePath.isEmpty());
|
||||
QVERIFY(!invalidServiceTypePath.isEmpty());
|
||||
QVERIFY(!exampleServiceTypePath.isEmpty());
|
||||
}
|
||||
|
||||
void testServiceType()
|
||||
{
|
||||
if (!doMessagesWork()) {
|
||||
return;
|
||||
}
|
||||
const QString typesPath = QFINDTESTDATA("data/servicetypes/example-servicetype.desktop");
|
||||
QVERIFY(!typesPath.isEmpty());
|
||||
const QString inputPath = QFINDTESTDATA("data/servicetypes/example-input.desktop");
|
||||
QVERIFY(!inputPath.isEmpty());
|
||||
QTest::ignoreMessage(
|
||||
QtWarningMsg,
|
||||
// We also print out a list of paths we searched in. With the ".+" we ensure that they are printed out,
|
||||
// but don't make fragile assumptions on the exact message
|
||||
QRegularExpression(QStringLiteral("Unable to find service type for service \"bar/foo\" listed in \"") + inputPath + QLatin1String("\" .+")));
|
||||
KPluginMetaData md = KPluginMetaData::fromDesktopFile(inputPath, QStringList() << typesPath);
|
||||
QVERIFY(md.isValid());
|
||||
QCOMPARE(md.name(), QStringLiteral("Example"));
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 89)
|
||||
QCOMPARE(md.serviceTypes(), QStringList() << QStringLiteral("example/servicetype") << QStringLiteral("bar/foo"));
|
||||
#endif
|
||||
QCOMPARE(md.rawData().size(), 8);
|
||||
QVERIFY(md.rawData().value(QStringLiteral("KPlugin")).isObject());
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Integer")), QJsonValue(42));
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Bool")), QJsonValue(true));
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Double")), QJsonValue(42.42));
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("X-Test-String")), QJsonValue(QStringLiteral("foobar")));
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("X-Test-List")),
|
||||
QJsonValue(
|
||||
QJsonArray::fromStringList(QStringList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c") << QStringLiteral("def"))));
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Size")), QJsonValue(QStringLiteral("10,20"))); // QSize no longer supported (and also no longer used)
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("X-Test-Unknown")), QJsonValue(QStringLiteral("true"))); // unknown property -> string
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 88)
|
||||
const QString charOverloadVlaue = md.value(QStringLiteral("X-Test-Unknown"), "true");
|
||||
QCOMPARE(charOverloadVlaue, QStringLiteral("true"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void testBadGroupsInServiceType()
|
||||
{
|
||||
if (!doMessagesWork()) {
|
||||
return;
|
||||
}
|
||||
const QString typesPath = QFINDTESTDATA("data/servicetypes/bad-groups-servicetype.desktop");
|
||||
QVERIFY(!typesPath.isEmpty());
|
||||
const QString inputPath = QFINDTESTDATA("data/servicetypes/bad-groups-input.desktop");
|
||||
QVERIFY(!inputPath.isEmpty());
|
||||
QTest::ignoreMessage(QtWarningMsg, "Illegal .desktop group definition (does not end with ']'): \"[PropertyDef::MissingTerminator\"");
|
||||
QTest::ignoreMessage(QtWarningMsg, "Illegal .desktop group definition (does not end with ']'): \"[PropertyDef::\"");
|
||||
QTest::ignoreMessage(QtWarningMsg, "Illegal .desktop group definition (does not end with ']'): \"[\"");
|
||||
QTest::ignoreMessage(QtWarningMsg, "Read empty .desktop file group name! Invalid file?");
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
QRegularExpression(QStringLiteral("Skipping invalid group \"\" in service type \".*/bad-groups-servicetype.desktop\"")));
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
QRegularExpression(QStringLiteral("Skipping invalid group \"DoesNotStartWithPropertyDef::SomeOtherProperty\" in service type "
|
||||
"\".+/data/servicetypes/bad-groups-servicetype.desktop\"")));
|
||||
QTest::ignoreMessage(QtWarningMsg, "Could not find Type= key in group \"PropertyDef::MissingType\"");
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
QRegularExpression(QStringLiteral("Property type \"integer\" is not a known QVariant type. Found while parsing property "
|
||||
"definition for \"InvalidType\" in \".+/data/servicetypes/bad-groups-servicetype.desktop\"")));
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=11\"")));
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=13\"")));
|
||||
QTest::ignoreMessage(QtWarningMsg,
|
||||
QRegularExpression(QStringLiteral(".+/data/servicetypes/bad-groups-input.desktop:\\d+: Key name is missing: \"=14\"")));
|
||||
KPluginMetaData md = KPluginMetaData::fromDesktopFile(inputPath, QStringList() << typesPath);
|
||||
QVERIFY(md.isValid());
|
||||
QCOMPARE(md.name(), QStringLiteral("Bad Groups"));
|
||||
QCOMPARE(md.rawData().size(), 8);
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("ThisIsOkay")), QJsonValue(10)); // integer
|
||||
// 11 is empty group
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("MissingTerminator")), QJsonValue(12)); // accept missing group terminator (for now) -> integer
|
||||
// 13 is empty group name
|
||||
// 14 is empty group name
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("SomeOtherProperty")),
|
||||
QJsonValue(QStringLiteral("15"))); // does not start with PropertyDef:: -> fall back to string
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("TrailingSpacesAreOkay")), QJsonValue(16)); // accept trailing spaces in group name -> integer
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("MissingType")), QJsonValue(QStringLiteral("17"))); // Type= missing -> fall back to string
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("InvalidType")), QJsonValue(QStringLiteral("18"))); // Type= is invalid -> fall back to string
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("ThisIsOkayAgain")), QJsonValue(19)); // valid definition after invalid ones should still work -> integer
|
||||
}
|
||||
#endif
|
||||
|
||||
void testJSONMetadata()
|
||||
{
|
||||
const QString inputPath = QFINDTESTDATA("data/testmetadata.json");
|
||||
KPluginMetaData md = KPluginMetaData::fromJsonFile(inputPath);
|
||||
QVERIFY(md.isValid());
|
||||
QCOMPARE(md.name(), QStringLiteral("Test"));
|
||||
|
||||
QCOMPARE(md.value(QStringLiteral("X-Plasma-MainScript")), QStringLiteral("ui/main.qml"));
|
||||
QJsonArray expected;
|
||||
expected.append(QStringLiteral("Export"));
|
||||
QCOMPARE(md.rawData().value(QStringLiteral("X-Purpose-PluginTypes")).toArray(), expected);
|
||||
QCOMPARE(md.value(QStringLiteral("SomeInt"), 24), 42);
|
||||
QCOMPARE(md.value(QStringLiteral("SomeIntAsString"), 24), 42);
|
||||
QCOMPARE(md.value(QStringLiteral("SomeStringNotAInt"), 24), 24);
|
||||
QCOMPARE(md.value(QStringLiteral("DoesNotExist"), 24), 24);
|
||||
|
||||
QVERIFY(md.value(QStringLiteral("SomeBool"), false));
|
||||
QVERIFY(!md.value(QStringLiteral("SomeBoolThatIsFalse"), true));
|
||||
QVERIFY(md.value(QStringLiteral("SomeBoolAsString"), false));
|
||||
QVERIFY(md.value(QStringLiteral("DoesNotExist"), true));
|
||||
}
|
||||
|
||||
void testPathIsAbsolute_data()
|
||||
{
|
||||
QTest::addColumn<QString>("inputAbsolute");
|
||||
QTest::addColumn<QString>("pluginPath");
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 91)
|
||||
// The .desktop file has X-KDE-Library, so .fileName() returns different file
|
||||
QTest::newRow("desktop") << QFINDTESTDATA("data/fakeplugin.desktop") << QStringLiteral("fakeplugin");
|
||||
#endif
|
||||
// But for the .json based plugin both are the same.
|
||||
QTest::newRow("json") << QFINDTESTDATA("data/testmetadata.json") << QFINDTESTDATA("data/testmetadata.json");
|
||||
// And also for the library with embedded JSON metadata.
|
||||
QPluginLoader shlibLoader(QCoreApplication::applicationDirPath() + QStringLiteral("/jsonplugin"));
|
||||
QVERIFY2(!shlibLoader.fileName().isEmpty(), "Could not find jsonplugin");
|
||||
QString shlibPath = QFileInfo(shlibLoader.fileName()).absoluteFilePath();
|
||||
QTest::newRow("library") << shlibPath << shlibPath;
|
||||
}
|
||||
|
||||
void testPathIsAbsolute()
|
||||
{
|
||||
// Test that the fileName() accessor always returns an absolute path if it was used.
|
||||
QFETCH(QString, inputAbsolute);
|
||||
QVERIFY2(QDir::isAbsolutePath(inputAbsolute), qPrintable(inputAbsolute));
|
||||
QFETCH(QString, pluginPath);
|
||||
|
||||
const auto createMetaData = [](const QString &path) {
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 91)
|
||||
return KPluginMetaData(path);
|
||||
#else
|
||||
if (path.endsWith(QLatin1String(".json"))) {
|
||||
return KPluginMetaData::fromJsonFile(path);
|
||||
} else {
|
||||
return KPluginMetaData(path);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
KPluginMetaData mdAbsolute = createMetaData(inputAbsolute);
|
||||
QVERIFY(mdAbsolute.isValid());
|
||||
QCOMPARE(mdAbsolute.metaDataFileName(), inputAbsolute);
|
||||
QCOMPARE(mdAbsolute.fileName(), pluginPath);
|
||||
|
||||
// All files that have been opened should be stored as absolute paths.
|
||||
QString inputRelative;
|
||||
if (QLibrary::isLibrary(inputAbsolute)) {
|
||||
// We have a plugin without namespace, with the code path below we would end up with
|
||||
// a path relative to the PWD, but we want to check a path relative to the plugin dir.
|
||||
// Because of that we simply use the baseName of the file.
|
||||
inputRelative = QFileInfo(inputAbsolute).baseName();
|
||||
} else {
|
||||
inputRelative = QDir::current().relativeFilePath(inputAbsolute);
|
||||
}
|
||||
QVERIFY2(QDir::isRelativePath(inputRelative), qPrintable(inputRelative));
|
||||
KPluginMetaData mdRelative = createMetaData(inputRelative);
|
||||
QVERIFY(mdRelative.isValid());
|
||||
QCOMPARE(mdRelative.metaDataFileName(), inputAbsolute);
|
||||
QCOMPARE(mdRelative.fileName(), pluginPath);
|
||||
|
||||
// Check that creating it with the parsed JSON object and a path keeps the path unchanged
|
||||
const QJsonObject json = mdAbsolute.rawData();
|
||||
QString pluginRelative = QDir::current().relativeFilePath(pluginPath);
|
||||
QVERIFY2(QDir::isRelativePath(pluginRelative), qPrintable(pluginRelative));
|
||||
// TODO: KF6: no need to test both constructors once they are merged into one overload.
|
||||
KPluginMetaData mdFromJson1(json, pluginRelative, inputRelative);
|
||||
QCOMPARE(mdFromJson1.metaDataFileName(), inputRelative);
|
||||
// We should not be normalizing files that have not been openened, so both arguments should be unchanged.
|
||||
QCOMPARE(mdFromJson1.fileName(), pluginRelative);
|
||||
KPluginMetaData mdFromJson2(json, inputRelative);
|
||||
QCOMPARE(mdFromJson2.metaDataFileName(), inputRelative);
|
||||
QCOMPARE(mdFromJson2.fileName(), inputRelative);
|
||||
}
|
||||
|
||||
void testFindPlugins()
|
||||
{
|
||||
QTemporaryDir temp;
|
||||
QVERIFY(temp.isValid());
|
||||
QDir dir(temp.path());
|
||||
QVERIFY(dir.mkdir(QStringLiteral("kpluginmetadatatest")));
|
||||
QVERIFY(dir.cd(QStringLiteral("kpluginmetadatatest")));
|
||||
for (const QString &name : {QStringLiteral("jsonplugin"), QStringLiteral("unversionedplugin"), QStringLiteral("jsonplugin2")}) {
|
||||
const QString pluginPath = QPluginLoader(name).fileName();
|
||||
QVERIFY2(!pluginPath.isEmpty(), qPrintable(pluginPath));
|
||||
QVERIFY2(QFile::copy(pluginPath, dir.absoluteFilePath(QFileInfo(pluginPath).fileName())),
|
||||
qPrintable(dir.absoluteFilePath(QFileInfo(pluginPath).fileName())));
|
||||
}
|
||||
|
||||
LibraryPathRestorer restorer(QCoreApplication::libraryPaths());
|
||||
// we only want plugins from our temporary dir
|
||||
QCoreApplication::setLibraryPaths(QStringList() << temp.path());
|
||||
|
||||
auto sortPlugins = [](const KPluginMetaData &a, const KPluginMetaData &b) {
|
||||
return a.pluginId() < b.pluginId();
|
||||
};
|
||||
// it should find jsonplugin and jsonplugin2 since unversionedplugin does not have any meta data
|
||||
auto plugins = KPluginMetaData::findPlugins(QStringLiteral("kpluginmetadatatest"));
|
||||
std::sort(plugins.begin(), plugins.end(), sortPlugins);
|
||||
QCOMPARE(plugins.size(), 2);
|
||||
QCOMPARE(plugins[0].pluginId(), QStringLiteral("foobar")); // ID is not the filename, it is set in the JSON metadata
|
||||
QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin"));
|
||||
QCOMPARE(plugins[1].pluginId(), QStringLiteral("jsonplugin"));
|
||||
QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin"));
|
||||
|
||||
// filter accepts none
|
||||
plugins = KPluginMetaData::findPlugins(QStringLiteral("kpluginmetadatatest"), [](const KPluginMetaData &) {
|
||||
return false;
|
||||
});
|
||||
std::sort(plugins.begin(), plugins.end(), sortPlugins);
|
||||
QCOMPARE(plugins.size(), 0);
|
||||
|
||||
// filter accepts all
|
||||
plugins = KPluginMetaData::findPlugins(QStringLiteral("kpluginmetadatatest"), [](const KPluginMetaData &) {
|
||||
return true;
|
||||
});
|
||||
std::sort(plugins.begin(), plugins.end(), sortPlugins);
|
||||
QCOMPARE(plugins.size(), 2);
|
||||
QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin"));
|
||||
QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin"));
|
||||
|
||||
// mimetype filter. Only one match, jsonplugin2 is specific to text/html.
|
||||
auto supportTextPlain = [](const KPluginMetaData &metaData) {
|
||||
return metaData.supportsMimeType(QLatin1String("text/plain"));
|
||||
};
|
||||
plugins = KPluginMetaData::findPlugins(QStringLiteral("kpluginmetadatatest"), supportTextPlain);
|
||||
QCOMPARE(plugins.size(), 1);
|
||||
QCOMPARE(plugins[0].description(), QStringLiteral("This is a plugin"));
|
||||
|
||||
// mimetype filter. Two matches, both support text/html, via inheritance.
|
||||
auto supportTextHtml = [](const KPluginMetaData &metaData) {
|
||||
return metaData.supportsMimeType(QLatin1String("text/html"));
|
||||
};
|
||||
plugins = KPluginMetaData::findPlugins(QStringLiteral("kpluginmetadatatest"), supportTextHtml);
|
||||
std::sort(plugins.begin(), plugins.end(), sortPlugins);
|
||||
QCOMPARE(plugins.size(), 2);
|
||||
QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin"));
|
||||
QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin"));
|
||||
|
||||
// mimetype filter with invalid mimetype
|
||||
auto supportDoesNotExist = [](const KPluginMetaData &metaData) {
|
||||
return metaData.supportsMimeType(QLatin1String("does/not/exist"));
|
||||
};
|
||||
plugins = KPluginMetaData::findPlugins(QStringLiteral("kpluginmetadatatest"), supportDoesNotExist);
|
||||
QCOMPARE(plugins.size(), 0);
|
||||
|
||||
// invalid std::function as filter
|
||||
plugins = KPluginMetaData::findPlugins(QStringLiteral("kpluginmetadatatest"));
|
||||
std::sort(plugins.begin(), plugins.end(), sortPlugins);
|
||||
QCOMPARE(plugins.size(), 2);
|
||||
QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin"));
|
||||
QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin"));
|
||||
|
||||
// by plugin id
|
||||
KPluginMetaData plugin = KPluginMetaData::findPluginById(dir.absolutePath(), QStringLiteral("foobar"));
|
||||
QVERIFY(plugin.isValid());
|
||||
QCOMPARE(plugin.description(), QStringLiteral("This is another plugin"));
|
||||
|
||||
// by plugin invalid id
|
||||
plugin = KPluginMetaData::findPluginById(dir.absolutePath(), QStringLiteral("invalidid"));
|
||||
QVERIFY(!plugin.isValid());
|
||||
|
||||
// absolute path, no filter
|
||||
plugins = KPluginMetaData::findPlugins(dir.absolutePath());
|
||||
std::sort(plugins.begin(), plugins.end(), sortPlugins);
|
||||
QCOMPARE(plugins.size(), 2);
|
||||
QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin"));
|
||||
QCOMPARE(plugins[1].description(), QStringLiteral("This is a plugin"));
|
||||
|
||||
// This plugin has no explicit pluginId and will fall back to basename of file
|
||||
const KPluginMetaData validPlugin = KPluginMetaData::findPluginById(dir.absolutePath(), QStringLiteral("jsonplugin"));
|
||||
QVERIFY(validPlugin.isValid());
|
||||
QCOMPARE(plugins[0].description(), QStringLiteral("This is another plugin"));
|
||||
|
||||
// The basename matches, but the pluginId does not match
|
||||
const KPluginMetaData nonMatchingPluginId = KPluginMetaData::findPluginById(dir.absolutePath(), QStringLiteral("jsonplugin2"));
|
||||
QVERIFY(!nonMatchingPluginId.isValid());
|
||||
|
||||
const KPluginMetaData nonExistingPlugin = KPluginMetaData::findPluginById(dir.absolutePath(), QStringLiteral("invalidid"));
|
||||
QVERIFY(!nonExistingPlugin.isValid());
|
||||
}
|
||||
|
||||
void testStaticPlugins()
|
||||
{
|
||||
QCOMPARE(QPluginLoader::staticPlugins().count(), 0);
|
||||
|
||||
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("staticnamespace"));
|
||||
QCOMPARE(plugins.count(), 1);
|
||||
|
||||
QCOMPARE(plugins.first().description(), QStringLiteral("This is a plugin"));
|
||||
QCOMPARE(plugins.first().fileName(), QStringLiteral("staticnamespace/static_jsonplugin_cmake_macro"));
|
||||
}
|
||||
|
||||
void testPluginsWithoutMetaData()
|
||||
{
|
||||
KPluginMetaData emptyMetaData(QStringLiteral("namespace/pluginwithoutmetadata"), KPluginMetaData::AllowEmptyMetaData);
|
||||
QVERIFY(emptyMetaData.isValid());
|
||||
QCOMPARE(emptyMetaData.pluginId(), QStringLiteral("pluginwithoutmetadata"));
|
||||
|
||||
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("namespace"), {}, KPluginMetaData::AllowEmptyMetaData);
|
||||
QCOMPARE(plugins.count(), 2);
|
||||
for (auto plugin : plugins) {
|
||||
if (plugin.pluginId() == QLatin1String("pluginwithoutmetadata")) {
|
||||
QVERIFY(plugin.isValid());
|
||||
QVERIFY(plugin.rawData().isEmpty());
|
||||
} else if (plugin.pluginId() == QLatin1String("jsonplugin_cmake_macro")) {
|
||||
QVERIFY(plugin.isValid());
|
||||
QVERIFY(!plugin.rawData().isEmpty());
|
||||
} else {
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void testStaticPluginsWithoutMetadata()
|
||||
{
|
||||
QVERIFY(KPluginMetaData::findPlugins(QStringLiteral("staticnamespace3")).isEmpty());
|
||||
const auto plugins = KPluginMetaData::findPlugins(QStringLiteral("staticnamespace3"), {}, KPluginMetaData::AllowEmptyMetaData);
|
||||
QCOMPARE(plugins.count(), 1);
|
||||
QVERIFY(plugins.first().isValid());
|
||||
QCOMPARE(plugins.first().pluginId(), QStringLiteral("static_plugin_without_metadata"));
|
||||
}
|
||||
|
||||
void testReverseDomainNotationPluginId()
|
||||
{
|
||||
KPluginMetaData data(QStringLiteral("org.kde.test"));
|
||||
QVERIFY(data.isValid());
|
||||
QCOMPARE(data.pluginId(), QStringLiteral("org.kde.test"));
|
||||
}
|
||||
|
||||
void testFindingPluginInAppDirFirst()
|
||||
{
|
||||
const QString originalPluginPath = QPluginLoader(QStringLiteral("namespace/jsonplugin_cmake_macro")).fileName();
|
||||
const QString pluginFileName = QFileInfo(originalPluginPath).fileName();
|
||||
const QString pluginNamespace = QStringLiteral("somepluginnamespace");
|
||||
const QString pluginAppDir = QCoreApplication::applicationDirPath() + QLatin1Char('/') + pluginNamespace;
|
||||
QDir(pluginAppDir).mkpath(QStringLiteral("."));
|
||||
const QString pluginAppPath = pluginAppDir + QLatin1Char('/') + pluginFileName;
|
||||
QFile::remove(pluginAppPath);
|
||||
|
||||
QVERIFY(QFile::copy(originalPluginPath, pluginAppPath));
|
||||
|
||||
QTemporaryDir temp;
|
||||
QVERIFY(temp.isValid());
|
||||
QDir dir(temp.path());
|
||||
QVERIFY(dir.mkdir(pluginNamespace));
|
||||
QVERIFY(dir.cd(pluginNamespace));
|
||||
|
||||
const QString pluginInNamespacePath = dir.absoluteFilePath(pluginFileName);
|
||||
QVERIFY(QFile::copy(originalPluginPath, pluginInNamespacePath));
|
||||
|
||||
LibraryPathRestorer restorer(QCoreApplication::libraryPaths());
|
||||
QCoreApplication::setLibraryPaths(QStringList() << temp.path());
|
||||
|
||||
// Our plugin in the applicationDirPath should come first
|
||||
const QString relativePathWithNamespace = QStringLiteral("somepluginnamespace/jsonplugin_cmake_macro");
|
||||
KPluginMetaData data(relativePathWithNamespace);
|
||||
QVERIFY(data.isValid());
|
||||
QCOMPARE(data.fileName(), pluginAppPath);
|
||||
|
||||
// The other one must be valid
|
||||
QVERIFY(KPluginMetaData(pluginInNamespacePath).isValid());
|
||||
// And after removing the plugin in the applicationDirPath, it should be found
|
||||
QVERIFY(QFile::remove(pluginAppPath));
|
||||
QCOMPARE(KPluginMetaData(relativePathWithNamespace).fileName(), pluginInNamespacePath);
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(KPluginMetaDataTest)
|
||||
|
||||
#include "kpluginmetadatatest.moc"
|
||||
84
Telegram/ThirdParty/kcoreaddons/autotests/kprocesslisttest.cpp
vendored
Normal file
84
Telegram/ThirdParty/kcoreaddons/autotests/kprocesslisttest.cpp
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2019 David Hallas <david@davidhallas.dk>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include "kprocesslisttest.h"
|
||||
#include "kprocesslist.h"
|
||||
#include "kuser.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QTest>
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
QString getTestExeName()
|
||||
{
|
||||
static QString testExeName = QCoreApplication::instance()->applicationFilePath().section(QLatin1Char('/'), -1);
|
||||
return testExeName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QTEST_MAIN(KProcessListTest)
|
||||
|
||||
void KProcessListTest::testKProcessInfoConstructionAssignment()
|
||||
{
|
||||
KProcessList::KProcessInfo processInfoDefaultConstructed;
|
||||
QVERIFY(processInfoDefaultConstructed.isValid() == false);
|
||||
const qint64 pid(42);
|
||||
const QString name(QStringLiteral("/bin/some_exe"));
|
||||
const QString user(QStringLiteral("some_user"));
|
||||
KProcessList::KProcessInfo processInfo(pid, name, user);
|
||||
QVERIFY(processInfo.isValid() == true);
|
||||
QCOMPARE(processInfo.pid(), pid);
|
||||
QCOMPARE(processInfo.name(), name);
|
||||
QCOMPARE(processInfo.user(), user);
|
||||
KProcessList::KProcessInfo processInfoCopy(processInfo);
|
||||
QVERIFY(processInfoCopy.isValid() == true);
|
||||
QCOMPARE(processInfoCopy.pid(), pid);
|
||||
QCOMPARE(processInfoCopy.name(), name);
|
||||
QCOMPARE(processInfoCopy.user(), user);
|
||||
KProcessList::KProcessInfo processInfoAssignment;
|
||||
processInfoAssignment = processInfo;
|
||||
QVERIFY(processInfoAssignment.isValid() == true);
|
||||
QCOMPARE(processInfoAssignment.pid(), pid);
|
||||
QCOMPARE(processInfoAssignment.name(), name);
|
||||
QCOMPARE(processInfoAssignment.user(), user);
|
||||
}
|
||||
|
||||
void KProcessListTest::testProcessInfoList()
|
||||
{
|
||||
KProcessList::KProcessInfoList processInfoList = KProcessList::processInfoList();
|
||||
QVERIFY(processInfoList.empty() == false);
|
||||
auto testProcessIterator = std::find_if(processInfoList.begin(), processInfoList.end(), [](const KProcessList::KProcessInfo &info) {
|
||||
return QDir::fromNativeSeparators(info.command()).endsWith(QLatin1String("/") + getTestExeName());
|
||||
});
|
||||
QVERIFY(testProcessIterator != processInfoList.end());
|
||||
const auto &processInfo = *testProcessIterator;
|
||||
QVERIFY(processInfo.isValid() == true);
|
||||
QVERIFY(QDir::fromNativeSeparators(processInfo.command()).endsWith(QLatin1String("/") + getTestExeName()));
|
||||
QCOMPARE(processInfo.name(), getTestExeName());
|
||||
QCOMPARE(processInfo.pid(), QCoreApplication::applicationPid());
|
||||
QCOMPARE(processInfo.user(), KUser().loginName());
|
||||
}
|
||||
|
||||
void KProcessListTest::testProcessInfo()
|
||||
{
|
||||
const qint64 testExePid = QCoreApplication::applicationPid();
|
||||
KProcessList::KProcessInfo processInfo = KProcessList::processInfo(testExePid);
|
||||
QVERIFY(processInfo.isValid() == true);
|
||||
QVERIFY(QDir::fromNativeSeparators(processInfo.command()).endsWith(QLatin1String("/") + getTestExeName()));
|
||||
QCOMPARE(processInfo.pid(), testExePid);
|
||||
QCOMPARE(processInfo.user(), KUser().loginName());
|
||||
}
|
||||
|
||||
void KProcessListTest::testProcessInfoNotFound()
|
||||
{
|
||||
KProcessList::KProcessInfo processInfo = KProcessList::processInfo(-1);
|
||||
QVERIFY(processInfo.isValid() == false);
|
||||
}
|
||||
|
||||
#include "moc_kprocesslisttest.cpp"
|
||||
24
Telegram/ThirdParty/kcoreaddons/autotests/kprocesslisttest.h
vendored
Normal file
24
Telegram/ThirdParty/kcoreaddons/autotests/kprocesslisttest.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
This file is part of the KDE project
|
||||
SPDX-FileCopyrightText: 2019 David Hallas <david@davidhallas.dk>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#ifndef KPROCESSLISTTEST_H
|
||||
#define KPROCESSLISTTEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class KProcessListTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void testKProcessInfoConstructionAssignment();
|
||||
void testProcessInfoList();
|
||||
void testProcessInfo();
|
||||
void testProcessInfoNotFound();
|
||||
};
|
||||
|
||||
#endif
|
||||
122
Telegram/ThirdParty/kcoreaddons/autotests/kprocesstest.cpp
vendored
Normal file
122
Telegram/ThirdParty/kcoreaddons/autotests/kprocesstest.cpp
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Oswald Buddenhagen <ossi@kde.org>
|
||||
SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kprocesstest_helper.h"
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <QStandardPaths>
|
||||
#include <QTest>
|
||||
#include <kprocess.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
class KProcessTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void test_channels();
|
||||
void test_setShellCommand();
|
||||
void test_inheritance();
|
||||
};
|
||||
|
||||
// IOCCC nomination pending
|
||||
|
||||
static QString callHelper(KProcess::OutputChannelMode how)
|
||||
{
|
||||
QProcess p;
|
||||
p.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QString helper = QCoreApplication::applicationDirPath() + QStringLiteral("/kprocesstest_helper");
|
||||
#ifdef Q_OS_WIN
|
||||
helper += QStringLiteral(".exe");
|
||||
#endif
|
||||
|
||||
Q_ASSERT(QFile::exists(helper));
|
||||
p.start(helper, QStringList() << QString::number(how) << QStringLiteral("--nocrashhandler"));
|
||||
p.waitForFinished();
|
||||
return QString::fromLatin1(p.readAllStandardOutput());
|
||||
}
|
||||
|
||||
#define EO EOUT "\n"
|
||||
#define EE EERR "\n"
|
||||
#define TESTCHAN(me, ms, pout, rout, rerr) \
|
||||
e = QStringLiteral("mode: " ms "\n" POUT pout ROUT rout RERR rerr); \
|
||||
a = QStringLiteral("mode: " ms "\n") + callHelper(KProcess::me); \
|
||||
QCOMPARE(a, e)
|
||||
|
||||
void KProcessTest::test_channels()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
QString e;
|
||||
QString a;
|
||||
TESTCHAN(SeparateChannels, "separate", "", EO, EE);
|
||||
TESTCHAN(ForwardedChannels, "forwarded", EO EE, "", "");
|
||||
TESTCHAN(OnlyStderrChannel, "forwarded stdout", EO, "", EE);
|
||||
TESTCHAN(OnlyStdoutChannel, "forwarded stderr", EE, EO, "");
|
||||
TESTCHAN(MergedChannels, "merged", "", EO EE, "");
|
||||
#else
|
||||
Q_UNUSED(callHelper);
|
||||
QSKIP("This test needs a UNIX system");
|
||||
#endif
|
||||
}
|
||||
|
||||
void KProcessTest::test_setShellCommand()
|
||||
{
|
||||
// Condition copied from kprocess.cpp
|
||||
#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__GNU__)
|
||||
QSKIP("This test needs a free UNIX system");
|
||||
#else
|
||||
KProcess p;
|
||||
|
||||
p.setShellCommand(QStringLiteral("cat"));
|
||||
QCOMPARE(p.program().count(), 1);
|
||||
QCOMPARE(p.program().at(0), QStandardPaths::findExecutable(QStringLiteral("cat")));
|
||||
QVERIFY(p.program().at(0).endsWith(QLatin1String("/cat")));
|
||||
p.setShellCommand(QStringLiteral("true || false"));
|
||||
QCOMPARE(p.program(), QStringList() << QStringLiteral("/bin/sh") << QStringLiteral("-c") << QString::fromLatin1("true || false"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void KProcessTest::test_inheritance()
|
||||
{
|
||||
KProcess kproc;
|
||||
QProcess *qproc = &kproc;
|
||||
const QString program = QStringLiteral("foobar");
|
||||
const QStringList arguments{QStringLiteral("meow")};
|
||||
|
||||
kproc.setProgram(program, arguments);
|
||||
QCOMPARE(qproc->program(), program);
|
||||
QCOMPARE(qproc->arguments(), arguments);
|
||||
kproc.clearProgram();
|
||||
QCOMPARE(qproc->program(), QString());
|
||||
QCOMPARE(qproc->arguments(), QStringList());
|
||||
|
||||
kproc << program << arguments;
|
||||
QCOMPARE(qproc->program(), program);
|
||||
QCOMPARE(qproc->arguments(), arguments);
|
||||
kproc.clearProgram();
|
||||
QCOMPARE(qproc->program(), QString());
|
||||
QCOMPARE(qproc->arguments(), QStringList());
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
kproc.setShellCommand(QStringLiteral("/bin/true meow"));
|
||||
QCOMPARE(qproc->program(), QStringLiteral("/bin/true"));
|
||||
QCOMPARE(qproc->arguments(), arguments);
|
||||
kproc.clearProgram();
|
||||
QCOMPARE(qproc->program(), QString());
|
||||
QCOMPARE(qproc->arguments(), QStringList());
|
||||
#endif
|
||||
}
|
||||
|
||||
QTEST_MAIN(KProcessTest)
|
||||
|
||||
#include "kprocesstest.moc"
|
||||
34
Telegram/ThirdParty/kcoreaddons/autotests/kprocesstest_helper.cpp
vendored
Normal file
34
Telegram/ThirdParty/kcoreaddons/autotests/kprocesstest_helper.cpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Oswald Buddenhagen <ossi@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "kprocesstest_helper.h"
|
||||
#include <kprocess.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("Missing parameter");
|
||||
return -1;
|
||||
}
|
||||
KProcess p;
|
||||
p.setShellCommand(QString::fromLatin1("echo " EOUT "; echo " EERR " >&2"));
|
||||
p.setOutputChannelMode(static_cast<KProcess::OutputChannelMode>(atoi(argv[1])));
|
||||
fputs(POUT, stdout);
|
||||
fflush(stdout);
|
||||
p.execute();
|
||||
fputs(ROUT, stdout);
|
||||
fputs(p.readAllStandardOutput().constData(), stdout);
|
||||
fputs(RERR, stdout);
|
||||
if (p.outputChannelMode() != KProcess::MergedChannels) {
|
||||
fputs(p.readAllStandardError().constData(), stdout);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
13
Telegram/ThirdParty/kcoreaddons/autotests/kprocesstest_helper.h
vendored
Normal file
13
Telegram/ThirdParty/kcoreaddons/autotests/kprocesstest_helper.h
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Oswald Buddenhagen <ossi@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#define EOUT "foo - stdout"
|
||||
#define EERR "bar - stderr"
|
||||
#define POUT "program output:\n"
|
||||
#define ROUT "received stdout:\n"
|
||||
#define RERR "received stderr:\n"
|
||||
282
Telegram/ThirdParty/kcoreaddons/autotests/krandomtest.cpp
vendored
Normal file
282
Telegram/ThirdParty/kcoreaddons/autotests/krandomtest.cpp
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
SPDX-FileCopyrightText: 2016 Michael Pyne <mpyne@kde.org>
|
||||
SPDX-FileCopyrightText: 2016 Arne Spiegelhauer <gm2.asp@gmail.com>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-only
|
||||
*/
|
||||
|
||||
#include <krandom.h>
|
||||
#include <krandomsequence.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QTest>
|
||||
#include <QThread>
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <QVarLengthArray>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
typedef QVarLengthArray<int> intSequenceType;
|
||||
|
||||
static const char *binpath;
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 75)
|
||||
static bool seqsAreEqual(const intSequenceType &l, const intSequenceType &r)
|
||||
{
|
||||
if (l.size() != r.size()) {
|
||||
return false;
|
||||
}
|
||||
const intSequenceType::const_iterator last(l.end());
|
||||
|
||||
intSequenceType::const_iterator l_first(l.begin());
|
||||
intSequenceType::const_iterator r_first(r.begin());
|
||||
|
||||
while (l_first != last && *l_first == *r_first) {
|
||||
l_first++;
|
||||
r_first++;
|
||||
}
|
||||
|
||||
return l_first == last;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 72)
|
||||
// Fills seq with random bytes produced by a new process. Seq should already
|
||||
// be sized to the needed amount of random numbers.
|
||||
static bool getChildRandSeq(intSequenceType &seq)
|
||||
{
|
||||
QProcess subtestProcess;
|
||||
|
||||
// Launch a separate process to generate random numbers to test first-time
|
||||
// seeding.
|
||||
subtestProcess.start(QLatin1String(binpath), QStringList() << QString::number(seq.count()));
|
||||
subtestProcess.waitForFinished();
|
||||
|
||||
QTextStream childStream(subtestProcess.readAllStandardOutput());
|
||||
|
||||
std::generate(seq.begin(), seq.end(), [&]() {
|
||||
int temp;
|
||||
childStream >> temp;
|
||||
return temp;
|
||||
});
|
||||
|
||||
char c;
|
||||
childStream >> c;
|
||||
return c == '@' && childStream.status() == QTextStream::Ok;
|
||||
}
|
||||
#endif
|
||||
|
||||
class KRandomTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 72)
|
||||
void test_random();
|
||||
#endif
|
||||
void test_randomString();
|
||||
void test_randomStringThreaded();
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 75)
|
||||
void test_KRS();
|
||||
#endif
|
||||
void test_shuffle();
|
||||
};
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 72)
|
||||
void KRandomTest::test_random()
|
||||
{
|
||||
int testValue = KRandom::random();
|
||||
|
||||
QVERIFY(testValue >= 0);
|
||||
QVERIFY(testValue < RAND_MAX);
|
||||
|
||||
// Verify seeding results in different numbers across different procs
|
||||
// See bug 362161
|
||||
intSequenceType out1(10);
|
||||
intSequenceType out2(10);
|
||||
|
||||
QVERIFY(getChildRandSeq(out1));
|
||||
QVERIFY(getChildRandSeq(out2));
|
||||
|
||||
QVERIFY(!seqsAreEqual(out1, out2));
|
||||
}
|
||||
#endif
|
||||
|
||||
void KRandomTest::test_randomString()
|
||||
{
|
||||
const int desiredLength = 12;
|
||||
const QString testString = KRandom::randomString(desiredLength);
|
||||
const QRegularExpression outputFormat(QRegularExpression::anchoredPattern(QStringLiteral("[A-Za-z0-9]+")));
|
||||
const QRegularExpressionMatch match = outputFormat.match(testString);
|
||||
|
||||
QCOMPARE(testString.length(), desiredLength);
|
||||
QVERIFY(match.hasMatch());
|
||||
}
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 75)
|
||||
void KRandomTest::test_KRS()
|
||||
{
|
||||
using std::all_of;
|
||||
using std::generate;
|
||||
|
||||
const int maxInt = 50000;
|
||||
KRandomSequence krs1;
|
||||
KRandomSequence krs2;
|
||||
intSequenceType out1(10);
|
||||
intSequenceType out2(10);
|
||||
|
||||
generate(out1.begin(), out1.end(), [&]() {
|
||||
return krs1.getInt(maxInt);
|
||||
});
|
||||
generate(out2.begin(), out2.end(), [&]() {
|
||||
return krs2.getInt(maxInt);
|
||||
});
|
||||
QVERIFY(!seqsAreEqual(out1, out2));
|
||||
QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) {
|
||||
return x < maxInt;
|
||||
}));
|
||||
QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) {
|
||||
return x < maxInt;
|
||||
}));
|
||||
|
||||
// Compare same-seed
|
||||
krs1.setSeed(5000);
|
||||
krs2.setSeed(5000);
|
||||
|
||||
generate(out1.begin(), out1.end(), [&]() {
|
||||
return krs1.getInt(maxInt);
|
||||
});
|
||||
generate(out2.begin(), out2.end(), [&]() {
|
||||
return krs2.getInt(maxInt);
|
||||
});
|
||||
QVERIFY(seqsAreEqual(out1, out2));
|
||||
QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) {
|
||||
return x < maxInt;
|
||||
}));
|
||||
QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) {
|
||||
return x < maxInt;
|
||||
}));
|
||||
|
||||
// Compare same-seed and assignment ctor
|
||||
|
||||
krs1 = KRandomSequence(8000);
|
||||
krs2 = KRandomSequence(8000);
|
||||
|
||||
generate(out1.begin(), out1.end(), [&]() {
|
||||
return krs1.getInt(maxInt);
|
||||
});
|
||||
generate(out2.begin(), out2.end(), [&]() {
|
||||
return krs2.getInt(maxInt);
|
||||
});
|
||||
QVERIFY(seqsAreEqual(out1, out2));
|
||||
QVERIFY(all_of(out1.begin(), out1.end(), [&](int x) {
|
||||
return x < maxInt;
|
||||
}));
|
||||
QVERIFY(all_of(out2.begin(), out2.end(), [&](int x) {
|
||||
return x < maxInt;
|
||||
}));
|
||||
}
|
||||
#endif
|
||||
|
||||
void KRandomTest::test_shuffle()
|
||||
{
|
||||
{
|
||||
QRandomGenerator rg(1);
|
||||
QList<int> list = {1, 2, 3, 4, 5};
|
||||
const QList<int> shuffled = {5, 2, 4, 3, 1};
|
||||
KRandom::shuffle(list, &rg);
|
||||
QCOMPARE(list, shuffled);
|
||||
}
|
||||
|
||||
{
|
||||
QRandomGenerator rg(1);
|
||||
QVector<int> vector = {1, 2, 3, 4, 5};
|
||||
const QVector<int> shuffled = {5, 2, 4, 3, 1};
|
||||
KRandom::shuffle(vector, &rg);
|
||||
QCOMPARE(vector, shuffled);
|
||||
}
|
||||
|
||||
{
|
||||
QRandomGenerator rg(1);
|
||||
std::vector<int> std_vector = {1, 2, 3, 4, 5};
|
||||
const std::vector<int> shuffled = {5, 2, 4, 3, 1};
|
||||
KRandom::shuffle(std_vector, &rg);
|
||||
QCOMPARE(std_vector, shuffled);
|
||||
}
|
||||
}
|
||||
|
||||
class KRandomTestThread : public QThread
|
||||
{
|
||||
protected:
|
||||
void run() override
|
||||
{
|
||||
result = KRandom::randomString(32);
|
||||
};
|
||||
|
||||
public:
|
||||
QString result;
|
||||
};
|
||||
|
||||
void KRandomTest::test_randomStringThreaded()
|
||||
{
|
||||
static const int size = 5;
|
||||
KRandomTestThread *threads[size];
|
||||
for (int i = 0; i < size; ++i) {
|
||||
threads[i] = new KRandomTestThread();
|
||||
threads[i]->start();
|
||||
}
|
||||
QSet<QString> results;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
threads[i]->wait(2000);
|
||||
results.insert(threads[i]->result);
|
||||
}
|
||||
// each thread should have returned a unique result
|
||||
QCOMPARE(results.size(), size);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
delete threads[i];
|
||||
}
|
||||
}
|
||||
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 72)
|
||||
// Used by getChildRandSeq... outputs random numbers to stdout and then
|
||||
// exits the process.
|
||||
static void childGenRandom(int count)
|
||||
{
|
||||
// No logic to 300, just wanted to avoid it accidentally being 2.4B...
|
||||
if (count <= 0 || count > 300) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
while (--count > 0) {
|
||||
std::cout << KRandom::random() << ' ';
|
||||
}
|
||||
|
||||
std::cout << KRandom::random() << '@';
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Manually implemented to dispatch to child process if needed to support
|
||||
// subtests
|
||||
int main([[maybe_unused]] int argc, char *argv[])
|
||||
{
|
||||
#if KCOREADDONS_BUILD_DEPRECATED_SINCE(5, 72)
|
||||
if (argc > 1) {
|
||||
childGenRandom(std::atoi(argv[1]));
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
#endif
|
||||
|
||||
binpath = argv[0];
|
||||
KRandomTest randomTest;
|
||||
return QTest::qExec(&randomTest);
|
||||
}
|
||||
|
||||
#include "krandomtest.moc"
|
||||
22
Telegram/ThirdParty/kcoreaddons/autotests/kruntimeplatformtest.cpp
vendored
Normal file
22
Telegram/ThirdParty/kcoreaddons/autotests/kruntimeplatformtest.cpp
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
|
||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
|
||||
#include "kruntimeplatform.h"
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
|
||||
class KRuntimePlatformTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void testRuntimePlatform()
|
||||
{
|
||||
qputenv("PLASMA_PLATFORM", "mobile:bigscreen");
|
||||
QStringList expected{"mobile", "bigscreen"};
|
||||
QCOMPARE(KRuntimePlatform::runtimePlatform(), expected);
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(KRuntimePlatformTest)
|
||||
|
||||
#include "kruntimeplatformtest.moc"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user